Skip to content

Commit 75977aa

Browse files
author
eugenp
committed
cleanup work
1 parent cb8adf1 commit 75977aa

10 files changed

Lines changed: 120 additions & 111 deletions

File tree

‎eclipse/INTEGRATION-BUILD.launch‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
3-
<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/>
4-
<stringAttribute key="M2_GOALS" value="clean install"/>
5-
<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
6-
<booleanAttribute key="M2_OFFLINE" value="false"/>
7-
<stringAttribute key="M2_PROFILES" value="integration"/>
8-
<listAttribute key="M2_PROPERTIES">
9-
<listEntry value="target=dev"/>
10-
<listEntry value="persistenceTarget=h2"/>
11-
</listAttribute>
12-
<stringAttribute key="M2_RUNTIME" value="C:\opt\maven\apache-maven-3.0.4"/>
13-
<booleanAttribute key="M2_SKIP_TESTS" value="false"/>
14-
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
15-
<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false"/>
16-
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:/rest}"/>
17-
</launchConfiguration>
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
3+
<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/>
4+
<stringAttribute key="M2_GOALS" value="clean install"/>
5+
<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
6+
<booleanAttribute key="M2_OFFLINE" value="false"/>
7+
<stringAttribute key="M2_PROFILES" value="integration"/>
8+
<listAttribute key="M2_PROPERTIES">
9+
<listEntry value="target=dev"/>
10+
<listEntry value="persistenceTarget=h2"/>
11+
</listAttribute>
12+
<stringAttribute key="M2_RUNTIME" value="/opt/maven/instances/apache-maven-3.0.4"/>
13+
<booleanAttribute key="M2_SKIP_TESTS" value="false"/>
14+
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
15+
<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false"/>
16+
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:/rest}"/>
17+
</launchConfiguration>

‎pom.xml‎

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
32
<modelVersion>4.0.0</modelVersion>
43
<groupId>org</groupId>
54
<artifactId>rest</artifactId>
@@ -23,16 +22,21 @@
2322
</dependency>
2423

2524
<dependency>
26-
<groupId>javax.servlet</groupId>
27-
<artifactId>servlet-api</artifactId>
28-
<version>2.5</version>
29-
<scope>provided</scope>
25+
<groupId>org.apache.httpcomponents</groupId>
26+
<artifactId>httpcore</artifactId>
27+
<version>${http.version}</version>
28+
<exclusions>
29+
<exclusion>
30+
<artifactId>commons-logging</artifactId>
31+
<groupId>commons-logging</groupId>
32+
</exclusion>
33+
</exclusions>
3034
</dependency>
3135

3236
<dependency>
3337
<groupId>org.apache.httpcomponents</groupId>
34-
<artifactId>httpcore</artifactId>
35-
<version>${http.version}</version>
38+
<artifactId>httpclient</artifactId>
39+
<version>${httpclient.version}</version>
3640
<exclusions>
3741
<exclusion>
3842
<artifactId>commons-logging</artifactId>
@@ -60,6 +64,15 @@
6064
<version>${spring.version}</version>
6165
</dependency>
6266

67+
<!-- web -->
68+
69+
<dependency>
70+
<groupId>javax.servlet</groupId>
71+
<artifactId>servlet-api</artifactId>
72+
<version>2.5</version>
73+
<scope>provided</scope>
74+
</dependency>
75+
6376
<!-- security -->
6477

6578
<dependency>
@@ -160,16 +173,16 @@
160173
<version>2.2.8</version>
161174
</dependency>
162175

163-
<!-- persistence - query -->
164-
165176
<!-- persistence - JPA 2 metamodel -->
177+
166178
<dependency>
167179
<groupId>org.hibernate</groupId>
168180
<artifactId>hibernate-jpamodelgen</artifactId>
169181
<version>1.2.0.Final</version>
170182
</dependency>
171183

172184
<!-- logging -->
185+
173186
<dependency>
174187
<groupId>org.slf4j</groupId>
175188
<artifactId>slf4j-api</artifactId>
@@ -188,18 +201,6 @@
188201
<scope>runtime</scope>
189202
</dependency>
190203

191-
<dependency>
192-
<groupId>org.apache.httpcomponents</groupId>
193-
<artifactId>httpclient</artifactId>
194-
<version>${httpclient.version}</version>
195-
<exclusions>
196-
<exclusion>
197-
<artifactId>commons-logging</artifactId>
198-
<groupId>commons-logging</groupId>
199-
</exclusion>
200-
</exclusions>
201-
</dependency>
202-
203204
<!-- test scoped -->
204205

205206
<dependency>
@@ -334,17 +335,26 @@
334335
</executions>
335336
</plugin>
336337

337-
338-
<!-- Querydsl - used to generate metadata -->
338+
<!-- generation of JPA 2 Metadata -->
339339
<!--(temporarily disabled) -->
340-
<!-- <plugin> <groupId>com.mysema.maven</groupId> <artifactId>maven-apt-plugin</artifactId>
341-
<version>1.0.2</version> <executions> <execution> <phase>generate-sources</phase>
342-
<goals> <goal>process</goal> </goals> <configuration> <outputDirectory>target/generated-sources</outputDirectory>
343-
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor> </configuration>
344-
</execution> </executions> </plugin> -->
345-
346-
<!-- JPA 2 metamodel -->
347-
<!-- -->
340+
<!-- <plugin>
341+
<groupId>com.mysema.maven</groupId>
342+
<artifactId>maven-apt-plugin</artifactId>
343+
<version>1.0.2</version>
344+
<executions>
345+
<execution>
346+
<phase>generate-sources</phase>
347+
<goals>
348+
<goal>process</goal>
349+
</goals>
350+
<configuration>
351+
<outputDirectory>target/generated-sources</outputDirectory>
352+
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
353+
</configuration>
354+
</execution>
355+
</executions>
356+
</plugin> -->
357+
348358
<!-- <plugin>
349359
<groupId>org.bsc.maven</groupId>
350360
<artifactId>maven-processor-plugin</artifactId>
@@ -357,13 +367,13 @@
357367
</goals>
358368
<phase>generate-sources</phase>
359369
<configuration>
360-
source output directory
361370
<outputDirectory>src/main/java</outputDirectory>
362371
</configuration>
363372
</execution>
364373
</executions>
365-
</plugin>
366-
<plugin>
374+
</plugin> -->
375+
376+
<!-- <plugin>
367377
<groupId>org.codehaus.mojo</groupId>
368378
<artifactId>build-helper-maven-plugin</artifactId>
369379
<version>1.7</version>
@@ -387,8 +397,7 @@
387397
<!-- generated by m2e -->
388398
<pluginManagement>
389399
<plugins>
390-
<!--This plugin's configuration is used to store Eclipse m2e settings
391-
only. It has no influence on the Maven build itself. -->
400+
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
392401
<plugin>
393402
<groupId>org.eclipse.m2e</groupId>
394403
<artifactId>lifecycle-mapping</artifactId>

‎src/main/java/org/rest/sec/persistence/service/impl/RoleServiceImpl.java‎

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,12 @@
22

33
import java.util.List;
44

5-
import javax.persistence.criteria.CriteriaBuilder;
6-
import javax.persistence.criteria.CriteriaQuery;
7-
import javax.persistence.criteria.Predicate;
8-
import javax.persistence.criteria.Root;
9-
105
import org.apache.commons.lang3.tuple.ImmutablePair;
116
import org.rest.persistence.service.AbstractService;
127
import org.rest.sec.model.Role;
13-
import org.rest.sec.model.Role_;
148
import org.rest.sec.persistence.dao.IRoleJpaDAO;
159
import org.rest.sec.persistence.service.IRoleService;
10+
import org.rest.sec.util.SearchUtil;
1611
import org.springframework.beans.factory.annotation.Autowired;
1712
import org.springframework.data.jpa.domain.Specification;
1813
import org.springframework.data.jpa.domain.Specifications;
@@ -34,14 +29,14 @@ public RoleServiceImpl() {
3429

3530
// API
3631

37-
// sandbox
32+
// search
3833

3934
@Override
4035
public List<Role> search(final ImmutablePair<String, ?>... constraints) {
41-
final Specification<Role> firstSpec = resolveConstraint(constraints[0]);
36+
final Specification<Role> firstSpec = SearchUtil.resolveConstraint(constraints[0]);
4237
Specifications<Role> specifications = Specifications.where(firstSpec);
4338
for (int i = 1; i < constraints.length; i++) {
44-
specifications = specifications.and(resolveConstraint(constraints[i]));
39+
specifications = specifications.and(SearchUtil.resolveConstraint(constraints[i]));
4540
}
4641
if (firstSpec == null) {
4742
return Lists.newArrayList();
@@ -50,49 +45,6 @@ public List<Role> search(final ImmutablePair<String, ?>... constraints) {
5045
return getDao().findAll(specifications);
5146
}
5247

53-
private Specification<Role> resolveConstraint(final ImmutablePair<String, ?> constraint) {
54-
String constraintName = constraint.getLeft();
55-
boolean negated = false;
56-
if (constraintName.startsWith("~")) {
57-
negated = true;
58-
constraintName = constraintName.substring(1);
59-
}
60-
61-
if (constraintName.equals("name")) {
62-
return byName((String) constraint.getRight(), negated);
63-
}
64-
if (constraintName.equals("id")) {
65-
return byId((Long) constraint.getRight(), negated);
66-
}
67-
return null;
68-
}
69-
70-
// search
71-
72-
public static Specification<Role> byId(final Long id, final boolean negated) {
73-
return new Specification<Role>() {
74-
@Override
75-
public final Predicate toPredicate(final Root<Role> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
76-
if (negated) {
77-
return cb.notEqual(root.get(Role_.id), id);
78-
}
79-
return cb.equal(root.get(Role_.id), id);
80-
}
81-
};
82-
}
83-
84-
public static Specification<Role> byName(final String name, final boolean negated) {
85-
return new Specification<Role>() {
86-
@Override
87-
public final Predicate toPredicate(final Root<Role> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
88-
if (negated) {
89-
return cb.notEqual(root.get(Role_.name), name);
90-
}
91-
return cb.equal(root.get(Role_.name), name);
92-
}
93-
};
94-
}
95-
9648
// get/find
9749

9850
@Override

‎src/main/java/org/rest/sec/util/SearchUtil.java‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

33
import java.util.List;
44

5+
import javax.persistence.criteria.CriteriaBuilder;
6+
import javax.persistence.criteria.CriteriaQuery;
7+
import javax.persistence.criteria.Predicate;
8+
import javax.persistence.criteria.Root;
9+
510
import org.apache.commons.lang3.tuple.ImmutablePair;
11+
import org.rest.sec.model.Role;
12+
import org.rest.sec.model.Role_;
13+
import org.springframework.data.jpa.domain.Specification;
614

715
import com.google.common.base.Preconditions;
816
import com.google.common.collect.Lists;
@@ -44,4 +52,45 @@ private SearchUtil() {
4452
return new ImmutablePair<String, String>(key, value);
4553
}
4654

55+
public static Specification<Role> byId(final Long id, final boolean negated) {
56+
return new Specification<Role>() {
57+
@Override
58+
public final Predicate toPredicate(final Root<Role> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
59+
if (negated) {
60+
return cb.notEqual(root.get(Role_.id), id);
61+
}
62+
return cb.equal(root.get(Role_.id), id);
63+
}
64+
};
65+
}
66+
67+
public static Specification<Role> byName(final String name, final boolean negated) {
68+
return new Specification<Role>() {
69+
@Override
70+
public final Predicate toPredicate(final Root<Role> root, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
71+
if (negated) {
72+
return cb.notEqual(root.get(Role_.name), name);
73+
}
74+
return cb.equal(root.get(Role_.name), name);
75+
}
76+
};
77+
}
78+
79+
public static Specification<Role> resolveConstraint(final ImmutablePair<String, ?> constraint) {
80+
String constraintName = constraint.getLeft();
81+
boolean negated = false;
82+
if (constraintName.startsWith("~")) {
83+
negated = true;
84+
constraintName = constraintName.substring(1);
85+
}
86+
87+
if (constraintName.equals("name")) {
88+
return byName((String) constraint.getRight(), negated);
89+
}
90+
if (constraintName.equals("id")) {
91+
return byId((Long) constraint.getRight(), negated);
92+
}
93+
return null;
94+
}
95+
4796
}

‎src/test/java/org/rest/client/template/AbstractRESTTemplate.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.apache.commons.lang3.tuple.Pair;
66
import org.apache.http.HttpHeaders;
77
import org.rest.client.marshall.IMarshaller;
8-
import org.rest.client.template.impl.ClientOperations;
98
import org.rest.common.IEntity;
109
import org.springframework.beans.factory.annotation.Autowired;
1110
import org.springframework.beans.factory.annotation.Qualifier;

src/test/java/org/rest/client/template/impl/ClientOperations.java renamed to src/test/java/org/rest/client/template/ClientOperations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.rest.client.template.impl;
1+
package org.rest.client.template;
22

33
public enum ClientOperations {
44
EQ, NEG_EQ;

‎src/test/java/org/rest/client/template/ITemplateAsResponse.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.rest.client.template;
22

33
import org.apache.commons.lang3.tuple.Pair;
4-
import org.rest.client.template.impl.ClientOperations;
54
import org.rest.common.IEntity;
65

76
import com.jayway.restassured.response.Response;

‎src/test/java/org/rest/client/template/impl/RoleRESTTemplateImpl.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.apache.commons.lang3.tuple.Pair;
88
import org.apache.http.HttpHeaders;
99
import org.rest.client.template.AbstractRESTTemplate;
10+
import org.rest.client.template.ClientOperations;
1011
import org.rest.sec.client.ExamplePaths;
1112
import org.rest.sec.model.Privilege;
1213
import org.rest.sec.model.Role;

‎src/test/java/org/rest/sec/util/SearchTestUtil.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import static org.rest.sec.util.SearchUtil.SEPARATOR;
88

99
import org.apache.commons.lang3.tuple.Pair;
10-
import org.rest.client.template.impl.ClientOperations;
10+
import org.rest.client.template.ClientOperations;
1111

1212
public final class SearchTestUtil {
1313
private SearchTestUtil() {

‎src/test/java/org/rest/sec/web/role/RoleSearchRESTIntegrationTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.apache.commons.lang3.tuple.ImmutablePair;
1212
import org.junit.Test;
1313
import org.junit.runner.RunWith;
14-
import org.rest.client.template.impl.ClientOperations;
14+
import org.rest.client.template.ClientOperations;
1515
import org.rest.client.template.impl.PrivilegeRESTTemplateImpl;
1616
import org.rest.client.template.impl.RoleRESTTemplateImpl;
1717
import org.rest.sec.model.Role;

0 commit comments

Comments
 (0)