You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2015/11/19 16:58:44 UTC
[1/3] syncope git commit: Reviewing several client-side builders,
adjusting roles
Repository: syncope
Updated Branches:
refs/heads/master 6ea34cd36 -> b738d3e94
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AnyObjectITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AnyObjectITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AnyObjectITCase.java
index 78bb011..c044187 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AnyObjectITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AnyObjectITCase.java
@@ -26,7 +26,6 @@ import static org.junit.Assert.fail;
import java.util.Set;
import javax.ws.rs.core.Response;
-import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.SyncopeConstants;
import org.apache.syncope.common.lib.patch.AnyObjectPatch;
@@ -36,6 +35,7 @@ import org.apache.syncope.common.lib.to.AttrTO;
import org.apache.syncope.common.lib.to.PagedResult;
import org.apache.syncope.common.lib.types.ClientExceptionType;
import org.apache.syncope.common.lib.types.SchemaType;
+import org.apache.syncope.common.rest.api.beans.AnyListQuery;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
@@ -93,8 +93,8 @@ public class AnyObjectITCase extends AbstractITCase {
@Test
public void list() {
- PagedResult<AnyObjectTO> anyObjectTOs = anyObjectService.list("PRINTER", SyncopeClient.getAnyListQueryBuilder().
- realm(SyncopeConstants.ROOT_REALM).build());
+ PagedResult<AnyObjectTO> anyObjectTOs = anyObjectService.list(
+ "PRINTER", new AnyListQuery.Builder().realm(SyncopeConstants.ROOT_REALM).build());
assertNotNull(anyObjectTOs);
assertTrue(anyObjectTOs.getResult().size() >= 2);
for (AnyObjectTO anyObjectTO : anyObjectTOs.getResult()) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AuthenticationITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AuthenticationITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AuthenticationITCase.java
index a9dda8d..580a209 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AuthenticationITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AuthenticationITCase.java
@@ -38,9 +38,9 @@ import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.SyncopeConstants;
import org.apache.syncope.common.lib.patch.DeassociationPatch;
-import org.apache.syncope.common.lib.patch.LongPatchItem;
import org.apache.syncope.common.lib.patch.PasswordPatch;
import org.apache.syncope.common.lib.patch.StatusPatch;
+import org.apache.syncope.common.lib.patch.StringPatchItem;
import org.apache.syncope.common.lib.patch.StringReplacePatchItem;
import org.apache.syncope.common.lib.patch.UserPatch;
import org.apache.syncope.common.lib.to.AnyObjectTO;
@@ -65,10 +65,10 @@ import org.apache.syncope.common.lib.types.SchemaType;
import org.apache.syncope.common.lib.types.StandardEntitlement;
import org.apache.syncope.common.lib.types.StatusPatchType;
import org.apache.syncope.common.rest.api.RESTHeaders;
+import org.apache.syncope.common.rest.api.beans.AnySearchQuery;
import org.apache.syncope.common.rest.api.service.AnyObjectService;
import org.apache.syncope.common.rest.api.service.SchemaService;
import org.apache.syncope.common.rest.api.service.UserService;
-import org.apache.syncope.core.misc.security.DelegatedAdministrationException;
import org.apache.syncope.core.misc.security.Encryptor;
import org.junit.Assume;
import org.junit.FixMethodOrder;
@@ -167,7 +167,7 @@ public class AuthenticationITCase extends AbstractITCase {
@Test
public void testUserRead() {
UserTO userTO = UserITCase.getUniqueSampleTO("testuserread@test.org");
- userTO.getRoles().add(2L);
+ userTO.getRoles().add("User manager");
userTO = createUser(userTO).getAny();
assertNotNull(userTO);
@@ -192,7 +192,7 @@ public class AuthenticationITCase extends AbstractITCase {
@Test
public void testUserSearch() {
UserTO userTO = UserITCase.getUniqueSampleTO("testusersearch@test.org");
- userTO.getRoles().add(1L);
+ userTO.getRoles().add("User reviewer");
userTO = createUser(userTO).getAny();
assertNotNull(userTO);
@@ -203,7 +203,7 @@ public class AuthenticationITCase extends AbstractITCase {
getService(UserService.class);
PagedResult<UserTO> matchedUsers = userService2.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getUserSearchConditionBuilder().isNotNull("key").query()).build());
assertNotNull(matchedUsers);
assertFalse(matchedUsers.getResult().isEmpty());
@@ -223,7 +223,7 @@ public class AuthenticationITCase extends AbstractITCase {
UserService userService3 = clientFactory.create("puccini", ADMIN_PWD).getService(UserService.class);
matchedUsers = userService3.search(
- SyncopeClient.getAnySearchQueryBuilder().realm("/even/two").
+ new AnySearchQuery.Builder().realm("/even/two").
fiql(SyncopeClient.getUserSearchConditionBuilder().isNotNull("loginDate").query()).build());
assertNotNull(matchedUsers);
assertTrue(CollectionUtils.matchesAll(matchedUsers.getResult(), new Predicate<UserTO>() {
@@ -237,12 +237,12 @@ public class AuthenticationITCase extends AbstractITCase {
@Test
public void delegatedUserCRUD() {
- Long roleKey = null;
+ String roleKey = null;
Long delegatedAdminKey = null;
try {
// 1. create role for full user administration, under realm /even/two
RoleTO role = new RoleTO();
- role.setName("Delegated user admin");
+ role.setKey("Delegated user admin");
role.getEntitlements().add(StandardEntitlement.USER_CREATE);
role.getEntitlements().add(StandardEntitlement.USER_UPDATE);
role.getEntitlements().add(StandardEntitlement.USER_DELETE);
@@ -250,7 +250,7 @@ public class AuthenticationITCase extends AbstractITCase {
role.getEntitlements().add(StandardEntitlement.USER_READ);
role.getRealms().add("/even/two");
- roleKey = Long.valueOf(roleService.create(role).getHeaderString(RESTHeaders.RESOURCE_KEY));
+ roleKey = roleService.create(role).getHeaderString(RESTHeaders.RESOURCE_KEY);
assertNotNull(roleKey);
// 2. as admin, create delegated admin user, and assign the role just created
@@ -327,7 +327,7 @@ public class AuthenticationITCase extends AbstractITCase {
@Test
public void checkFailedLogins() {
UserTO userTO = UserITCase.getUniqueSampleTO("checkFailedLogin@syncope.apache.org");
- userTO.getRoles().add(2L);
+ userTO.getRoles().add("User manager");
userTO = createUser(userTO).getAny();
assertNotNull(userTO);
@@ -353,7 +353,7 @@ public class AuthenticationITCase extends AbstractITCase {
public void checkUserSuspension() {
UserTO userTO = UserITCase.getUniqueSampleTO("checkSuspension@syncope.apache.org");
userTO.setRealm("/odd");
- userTO.getRoles().add(2L);
+ userTO.getRoles().add("User manager");
userTO = createUser(userTO).getAny();
long userKey = userTO.getKey();
@@ -448,7 +448,7 @@ public class AuthenticationITCase extends AbstractITCase {
// 4. give create entitlement for the any type just created
RoleTO role = new RoleTO();
- role.setName("role" + getUUIDString());
+ role.setKey("role" + getUUIDString());
role.getRealms().add(SyncopeConstants.ROOT_REALM);
role.getEntitlements().add(anyTypeKey + "_READ");
role.getEntitlements().add(anyTypeKey + "_CREATE");
@@ -457,7 +457,7 @@ public class AuthenticationITCase extends AbstractITCase {
UserTO bellini = readUser("bellini");
UserPatch patch = new UserPatch();
patch.setKey(bellini.getKey());
- patch.getRoles().add(new LongPatchItem.Builder().
+ patch.getRoles().add(new StringPatchItem.Builder().
operation(PatchOperation.ADD_REPLACE).value(role.getKey()).build());
bellini = updateUser(patch).getAny();
assertTrue(bellini.getRoles().contains(role.getKey()));
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DerSchemaITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DerSchemaITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DerSchemaITCase.java
index ac941b7..766ed0a 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DerSchemaITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DerSchemaITCase.java
@@ -31,6 +31,7 @@ import org.apache.syncope.common.lib.to.DerSchemaTO;
import org.apache.syncope.common.lib.types.ClientExceptionType;
import org.apache.syncope.common.lib.types.EntityViolationType;
import org.apache.syncope.common.lib.types.SchemaType;
+import org.apache.syncope.common.rest.api.beans.SchemaQuery;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
@@ -40,9 +41,9 @@ public class DerSchemaITCase extends AbstractITCase {
@Test
public void list() {
- List<DerSchemaTO> derivedSchemas = schemaService.list(SchemaType.DERIVED, null);
- assertFalse(derivedSchemas.isEmpty());
- for (DerSchemaTO derivedSchemaTO : derivedSchemas) {
+ List<DerSchemaTO> derSchemas = schemaService.list(SchemaType.DERIVED, new SchemaQuery.Builder().build());
+ assertFalse(derSchemas.isEmpty());
+ for (DerSchemaTO derivedSchemaTO : derSchemas) {
assertNotNull(derivedSchemaTO);
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ExceptionMapperITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ExceptionMapperITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ExceptionMapperITCase.java
index 924a24b..da0295c 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ExceptionMapperITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ExceptionMapperITCase.java
@@ -28,8 +28,8 @@ import org.apache.commons.io.IOUtils;
import org.apache.syncope.common.lib.SyncopeClientCompositeException;
import org.apache.syncope.common.lib.SyncopeConstants;
import org.apache.syncope.common.lib.to.AnyTypeClassTO;
+import org.apache.syncope.common.lib.to.GroupTO;
import org.apache.syncope.common.lib.to.PlainSchemaTO;
-import org.apache.syncope.common.lib.to.RoleTO;
import org.apache.syncope.common.lib.to.UserTO;
import org.apache.syncope.common.lib.types.AttrSchemaType;
import org.apache.syncope.common.lib.types.SchemaType;
@@ -109,18 +109,21 @@ public class ExceptionMapperITCase extends AbstractITCase {
}
@Test
- public void sameRoleName() {
- // Create the first role
- RoleTO roleTO1 = new RoleTO();
- String roleUUID = getUUIDString();
- roleTO1.setName("child1" + roleUUID);
- createRole(roleTO1);
-
- // Create the second role, with the same parent and the same role of roleTO1
- RoleTO roleTO2 = new RoleTO();
- roleTO2.setName("child1" + roleUUID);
+ public void sameGroupName() {
+ String groupUUID = getUUIDString();
+
+ // Create the first group
+ GroupTO groupTO1 = new GroupTO();
+ groupTO1.setName("child1" + groupUUID);
+ groupTO1.setRealm(SyncopeConstants.ROOT_REALM);
+ createGroup(groupTO1);
+
+ // Create the second group, with the same name of groupTO1
+ GroupTO groupTO2 = new GroupTO();
+ groupTO2.setName("child1" + groupUUID);
+ groupTO2.setRealm(SyncopeConstants.ROOT_REALM);
try {
- createRole(roleTO2);
+ createGroup(groupTO2);
fail();
} catch (Exception e) {
String message = ERROR_MESSAGES.getProperty("errMessage.UniqueConstraintViolation");
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java
index d580152..f5a503b 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java
@@ -76,6 +76,8 @@ import org.apache.syncope.common.lib.types.ResourceDeassociationAction;
import org.apache.syncope.common.lib.types.SchemaType;
import org.apache.syncope.common.rest.api.Preference;
import org.apache.syncope.common.rest.api.RESTHeaders;
+import org.apache.syncope.common.rest.api.beans.AnyListQuery;
+import org.apache.syncope.common.rest.api.beans.AnySearchQuery;
import org.apache.syncope.common.rest.api.service.GroupService;
import org.junit.FixMethodOrder;
import org.junit.Test;
@@ -159,7 +161,7 @@ public class GroupITCase extends AbstractITCase {
@Test
public void list() {
PagedResult<GroupTO> groupTOs =
- groupService.list(SyncopeClient.getAnyListQueryBuilder().realm(SyncopeConstants.ROOT_REALM).build());
+ groupService.list(new AnyListQuery.Builder().realm(SyncopeConstants.ROOT_REALM).build());
assertNotNull(groupTOs);
assertTrue(groupTOs.getResult().size() >= 8);
for (GroupTO groupTO : groupTOs.getResult()) {
@@ -558,16 +560,14 @@ public class GroupITCase extends AbstractITCase {
public void anonymous() {
GroupService unauthenticated = clientFactory.create().getService(GroupService.class);
try {
- unauthenticated.
- list(SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).build());
+ unauthenticated.list(new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).build());
fail();
} catch (AccessControlException e) {
assertNotNull(e);
}
GroupService anonymous = clientFactory.create(ANONYMOUS_UNAME, ANONYMOUS_KEY).getService(GroupService.class);
- assertFalse(anonymous.list(SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
- build()).
+ assertFalse(anonymous.list(new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).build()).
getResult().isEmpty());
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/MultitenancyITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/MultitenancyITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/MultitenancyITCase.java
index 5aac6c0..d675692 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/MultitenancyITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/MultitenancyITCase.java
@@ -50,6 +50,8 @@ import org.apache.syncope.common.lib.types.MappingPurpose;
import org.apache.syncope.common.lib.types.PropagationTaskExecStatus;
import org.apache.syncope.common.lib.types.SchemaType;
import org.apache.syncope.common.lib.types.SyncMode;
+import org.apache.syncope.common.rest.api.beans.AnySearchQuery;
+import org.apache.syncope.common.rest.api.beans.SchemaQuery;
import org.apache.syncope.common.rest.api.service.ConnectorService;
import org.apache.syncope.common.rest.api.service.DomainService;
import org.apache.syncope.common.rest.api.service.LoggerService;
@@ -101,7 +103,8 @@ public class MultitenancyITCase extends AbstractITCase {
@Test
public void readPlainSchemas() {
- assertEquals(17, adminClient.getService(SchemaService.class).list(SchemaType.PLAIN, null).size());
+ assertEquals(17, adminClient.getService(SchemaService.class).
+ list(SchemaType.PLAIN, new SchemaQuery.Builder().build()).size());
}
@Test
@@ -209,7 +212,7 @@ public class MultitenancyITCase extends AbstractITCase {
// verify that synchronized user is found
PagedResult<UserTO> matchingUsers = adminClient.getService(UserService.class).search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getUserSearchConditionBuilder().is("username").equalTo("syncFromLDAP").query()).
build());
assertNotNull(matchingUsers);
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java
index 2a75805..7f46848 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.security.AccessControlException;
import java.util.List;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
@@ -44,7 +43,7 @@ import org.apache.syncope.common.lib.types.CipherAlgorithm;
import org.apache.syncope.common.lib.types.ClientExceptionType;
import org.apache.syncope.common.lib.types.EntityViolationType;
import org.apache.syncope.common.lib.types.SchemaType;
-import org.apache.syncope.common.rest.api.service.SchemaService;
+import org.apache.syncope.common.rest.api.beans.SchemaQuery;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
@@ -159,7 +158,7 @@ public class PlainSchemaITCase extends AbstractITCase {
@Test
public void list() {
- List<PlainSchemaTO> schemas = schemaService.list(SchemaType.PLAIN, null);
+ List<PlainSchemaTO> schemas = schemaService.list(SchemaType.PLAIN, new SchemaQuery.Builder().build());
assertFalse(schemas.isEmpty());
for (PlainSchemaTO schemaTO : schemas) {
assertNotNull(schemaTO);
@@ -169,8 +168,9 @@ public class PlainSchemaITCase extends AbstractITCase {
@Test
public void listByAnyTypeClass() {
final String clazz = anyTypeService.read(AnyTypeKind.USER.name()).getClasses().get(0);
-
- List<PlainSchemaTO> userSchemas = schemaService.list(SchemaType.PLAIN, clazz);
+
+ List<PlainSchemaTO> userSchemas = schemaService.list(
+ SchemaType.PLAIN, new SchemaQuery.Builder().anyTypeClass(clazz).build());
assertTrue(CollectionUtils.exists(userSchemas, new Predicate<PlainSchemaTO>() {
@@ -332,18 +332,4 @@ public class PlainSchemaITCase extends AbstractITCase {
assertTrue(e.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
}
}
-
- @Test
- public void anonymous() {
- SchemaService unauthenticated = clientFactory.create().getService(SchemaService.class);
- try {
- unauthenticated.list(SchemaType.VIRTUAL, null);
- fail();
- } catch (AccessControlException e) {
- assertNotNull(e);
- }
-
- SchemaService anonymous = clientFactory.create(ANONYMOUS_UNAME, ANONYMOUS_KEY).getService(SchemaService.class);
- assertFalse(anonymous.list(SchemaType.VIRTUAL, null).isEmpty());
- }
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PropagationTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PropagationTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PropagationTaskITCase.java
index 7f2964f..ec0f275 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PropagationTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PropagationTaskITCase.java
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
-import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.common.lib.to.AbstractTaskTO;
import org.apache.syncope.common.lib.to.BulkAction;
import org.apache.syncope.common.lib.to.PagedResult;
@@ -33,6 +32,7 @@ import org.apache.syncope.common.lib.to.PropagationTaskTO;
import org.apache.syncope.common.lib.to.TaskExecTO;
import org.apache.syncope.common.lib.to.UserTO;
import org.apache.syncope.common.lib.types.TaskType;
+import org.apache.syncope.common.rest.api.beans.TaskQuery;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
@@ -44,7 +44,7 @@ public class PropagationTaskITCase extends AbstractTaskITCase {
public void paginatedList() {
PagedResult<PropagationTaskTO> tasks = taskService.list(
TaskType.PROPAGATION,
- SyncopeClient.getTaskQueryBuilder().page(1).size(2).build());
+ new TaskQuery.Builder().page(1).size(2).build());
assertNotNull(tasks);
assertEquals(2, tasks.getResult().size());
@@ -54,7 +54,7 @@ public class PropagationTaskITCase extends AbstractTaskITCase {
tasks = taskService.list(
TaskType.PROPAGATION,
- SyncopeClient.getTaskQueryBuilder().page(2).size(2).build());
+ new TaskQuery.Builder().page(2).size(2).build());
assertNotNull(tasks);
assertEquals(2, tasks.getPage());
assertEquals(2, tasks.getResult().size());
@@ -65,7 +65,7 @@ public class PropagationTaskITCase extends AbstractTaskITCase {
tasks = taskService.list(
TaskType.PROPAGATION,
- SyncopeClient.getTaskQueryBuilder().page(1000).size(2).build());
+ new TaskQuery.Builder().page(1000).size(2).build());
assertNotNull(tasks);
assertTrue(tasks.getResult().isEmpty());
}
@@ -87,7 +87,7 @@ public class PropagationTaskITCase extends AbstractTaskITCase {
@Test
public void bulkAction() {
PagedResult<PropagationTaskTO> before = taskService.list(
- TaskType.PROPAGATION, SyncopeClient.getTaskQueryBuilder().build());
+ TaskType.PROPAGATION, new TaskQuery.Builder().build());
// create user with testdb resource
UserTO userTO = UserITCase.getUniqueSampleTO("taskBulk@apache.org");
@@ -95,7 +95,7 @@ public class PropagationTaskITCase extends AbstractTaskITCase {
createUser(userTO);
List<PropagationTaskTO> after = new ArrayList<>(
- taskService.<PropagationTaskTO>list(TaskType.PROPAGATION, SyncopeClient.getTaskQueryBuilder().build()).
+ taskService.<PropagationTaskTO>list(TaskType.PROPAGATION, new TaskQuery.Builder().build()).
getResult());
after.removeAll(before.getResult());
assertFalse(after.isEmpty());
@@ -109,7 +109,7 @@ public class PropagationTaskITCase extends AbstractTaskITCase {
taskService.bulk(bulkAction);
- assertFalse(taskService.list(TaskType.PROPAGATION, SyncopeClient.getTaskQueryBuilder().build()).getResult().
+ assertFalse(taskService.list(TaskType.PROPAGATION, new TaskQuery.Builder().build()).getResult().
containsAll(after));
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PushTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PushTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PushTaskITCase.java
index bf294f6..3a907b2 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PushTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PushTaskITCase.java
@@ -52,6 +52,7 @@ import org.apache.syncope.common.lib.types.SchemaType;
import org.apache.syncope.common.lib.types.TaskType;
import org.apache.syncope.common.lib.types.TraceLevel;
import org.apache.syncope.common.lib.types.UnmatchingRule;
+import org.apache.syncope.common.rest.api.beans.TaskQuery;
import org.apache.syncope.common.rest.api.service.NotificationService;
import org.apache.syncope.common.rest.api.service.ResourceService;
import org.apache.syncope.common.rest.api.service.TaskService;
@@ -79,8 +80,7 @@ public class PushTaskITCase extends AbstractTaskITCase {
@Test
public void list() {
- PagedResult<PushTaskTO> tasks = taskService.list(
- TaskType.PUSH, SyncopeClient.getTaskQueryBuilder().build());
+ PagedResult<PushTaskTO> tasks = taskService.list(TaskType.PUSH, new TaskQuery.Builder().build());
assertFalse(tasks.getResult().isEmpty());
for (AbstractTaskTO task : tasks.getResult()) {
if (!(task instanceof PushTaskTO)) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java
index 99be00a..f2c940c 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java
@@ -35,8 +35,6 @@ import java.util.Set;
import javax.ws.rs.core.Response;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.Transformer;
-import org.apache.syncope.client.lib.SyncopeClient;
-import org.apache.syncope.client.lib.builders.ConnObjectTOListQueryBuilder;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.to.BulkAction;
import org.apache.syncope.common.lib.to.ConnObjectTO;
@@ -53,6 +51,7 @@ import org.apache.syncope.common.lib.types.ConnConfProperty;
import org.apache.syncope.common.lib.types.EntityViolationType;
import org.apache.syncope.common.lib.types.IntMappingType;
import org.apache.syncope.common.lib.types.MappingPurpose;
+import org.apache.syncope.common.rest.api.beans.ConnObjectTOListQuery;
import org.apache.syncope.common.rest.api.service.ResourceService;
import org.identityconnectors.framework.common.objects.ObjectClass;
import org.junit.FixMethodOrder;
@@ -542,7 +541,7 @@ public class ResourceITCase extends AbstractITCase {
int totalRead = 0;
Set<String> read = new HashSet<>();
try {
- ConnObjectTOListQueryBuilder builder = SyncopeClient.getConnObjectTOListQueryBuilder().size(10);
+ ConnObjectTOListQuery.Builder builder = new ConnObjectTOListQuery.Builder().size(10);
PagedConnObjectTOResult list;
do {
list = null;
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/RoleITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/RoleITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/RoleITCase.java
index c745324..a44b5f5 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/RoleITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/RoleITCase.java
@@ -41,7 +41,7 @@ public class RoleITCase extends AbstractITCase {
public static RoleTO getSampleRoleTO(final String name) {
RoleTO role = new RoleTO();
- role.setName(name + getUUIDString());
+ role.setKey(name + getUUIDString());
role.getRealms().add("/even");
role.getEntitlements().add(StandardEntitlement.LOG_SET_LEVEL);
@@ -60,7 +60,7 @@ public class RoleITCase extends AbstractITCase {
@Test
public void read() {
- RoleTO roleTO = roleService.read(3L);
+ RoleTO roleTO = roleService.read("Other");
assertNotNull(roleTO);
assertTrue(roleTO.getEntitlements().contains(StandardEntitlement.GROUP_READ));
}
@@ -80,7 +80,7 @@ public class RoleITCase extends AbstractITCase {
assertEquals(ClientExceptionType.InvalidRole, e.getType());
}
- role.setName("new" + getUUIDString());
+ role.setKey("new" + getUUIDString());
role = createRole(role);
assertNotNull(role);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SchedTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SchedTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SchedTaskITCase.java
index 614f5d3..a8f4d23 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SchedTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SchedTaskITCase.java
@@ -28,7 +28,6 @@ import static org.junit.Assert.fail;
import java.util.List;
import java.util.Set;
import javax.ws.rs.core.Response;
-import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.common.lib.to.AbstractTaskTO;
import org.apache.syncope.common.lib.to.PagedResult;
import org.apache.syncope.common.lib.to.PushTaskTO;
@@ -38,6 +37,7 @@ import org.apache.syncope.common.lib.to.TaskExecTO;
import org.apache.syncope.common.lib.types.JobAction;
import org.apache.syncope.common.lib.types.JobStatusType;
import org.apache.syncope.common.lib.types.TaskType;
+import org.apache.syncope.common.rest.api.beans.TaskQuery;
import org.apache.syncope.common.rest.api.service.TaskService;
import org.junit.FixMethodOrder;
import org.junit.Test;
@@ -56,7 +56,7 @@ public class SchedTaskITCase extends AbstractTaskITCase {
@Test
public void list() {
PagedResult<SchedTaskTO> tasks =
- taskService.list(TaskType.SCHEDULED, SyncopeClient.getTaskQueryBuilder().build());
+ taskService.list(TaskType.SCHEDULED, new TaskQuery.Builder().build());
assertFalse(tasks.getResult().isEmpty());
for (AbstractTaskTO task : tasks.getResult()) {
if (!(task instanceof SchedTaskTO) || task instanceof SyncTaskTO || task instanceof PushTaskTO) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SearchITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SearchITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SearchITCase.java
index 59d158d..38624b9 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SearchITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SearchITCase.java
@@ -34,6 +34,7 @@ import org.apache.syncope.common.lib.to.PagedResult;
import org.apache.syncope.common.lib.to.GroupTO;
import org.apache.syncope.common.lib.to.RoleTO;
import org.apache.syncope.common.lib.to.UserTO;
+import org.apache.syncope.common.rest.api.beans.AnySearchQuery;
import org.apache.syncope.common.rest.api.service.RoleService;
import org.junit.FixMethodOrder;
import org.junit.Test;
@@ -46,7 +47,7 @@ public class SearchITCase extends AbstractITCase {
public void searchUser() {
// LIKE
PagedResult<UserTO> matchingUsers = userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getUserSearchConditionBuilder().
is("fullname").equalTo("*o*").and("fullname").equalTo("*i*").query()).build());
assertNotNull(matchingUsers);
@@ -58,7 +59,7 @@ public class SearchITCase extends AbstractITCase {
// ISNULL
matchingUsers = userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getUserSearchConditionBuilder().isNull("loginDate").query()).build());
assertNotNull(matchingUsers);
assertFalse(matchingUsers.getResult().isEmpty());
@@ -76,7 +77,7 @@ public class SearchITCase extends AbstractITCase {
@Test
public void searchByUsernameAndKey() {
PagedResult<UserTO> matchingUsers = userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getUserSearchConditionBuilder().
is("username").equalTo("rossini").and("key").lessThan(2).query()).build());
assertNotNull(matchingUsers);
@@ -88,7 +89,7 @@ public class SearchITCase extends AbstractITCase {
@Test
public void searchByGroupNameAndKey() {
PagedResult<GroupTO> matchingGroups = groupService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getUserSearchConditionBuilder().
is("name").equalTo("root").and("key").lessThan(2).query()).build());
assertNotNull(matchingGroups);
@@ -100,7 +101,7 @@ public class SearchITCase extends AbstractITCase {
@Test
public void searchByGroup() {
PagedResult<UserTO> matchingUsers = userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getUserSearchConditionBuilder().inGroups(1L).query()).
build());
assertNotNull(matchingUsers);
@@ -123,7 +124,7 @@ public class SearchITCase extends AbstractITCase {
assertNotNull(group);
PagedResult<UserTO> matchingUsers = userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getUserSearchConditionBuilder().inGroups(group.getKey()).query()).
build());
assertNotNull(matchingUsers);
@@ -141,8 +142,8 @@ public class SearchITCase extends AbstractITCase {
@Test
public void searchByRole() {
PagedResult<UserTO> matchingUsers = userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getUserSearchConditionBuilder().inRoles(3L).query()).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
+ fiql(SyncopeClient.getUserSearchConditionBuilder().inRoles("Other").query()).
build());
assertNotNull(matchingUsers);
assertFalse(matchingUsers.getResult().isEmpty());
@@ -165,7 +166,7 @@ public class SearchITCase extends AbstractITCase {
assertNotNull(role);
PagedResult<UserTO> matchingUsers = userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getUserSearchConditionBuilder().inRoles(role.getKey()).query()).
build());
assertNotNull(matchingUsers);
@@ -183,7 +184,7 @@ public class SearchITCase extends AbstractITCase {
@Test
public void searchUserByResourceName() {
PagedResult<UserTO> matchingUsers = userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getUserSearchConditionBuilder().hasResources(RESOURCE_NAME_MAPPINGS2).query()).
build());
assertNotNull(matchingUsers);
@@ -202,7 +203,7 @@ public class SearchITCase extends AbstractITCase {
public void paginatedSearch() {
// LIKE
PagedResult<UserTO> matchingUsers = userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getUserSearchConditionBuilder().
is("fullname").equalTo("*o*").and("fullname").equalTo("*i*").query()).page(1).size(2).build());
assertNotNull(matchingUsers);
@@ -214,7 +215,7 @@ public class SearchITCase extends AbstractITCase {
// ISNULL
matchingUsers = userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getUserSearchConditionBuilder().isNull("loginDate").query()).page(2).size(2).
build());
assertNotNull(matchingUsers);
@@ -225,7 +226,7 @@ public class SearchITCase extends AbstractITCase {
@Test
public void searchByBooleanAnyCond() {
PagedResult<GroupTO> matchingGroups = groupService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getGroupSearchConditionBuilder().is("show").equalTo("true").query()).build());
assertNotNull(matchingGroups);
assertFalse(matchingGroups.getResult().isEmpty());
@@ -234,7 +235,7 @@ public class SearchITCase extends AbstractITCase {
@Test
public void searchByRelationshipAnyCond() {
PagedResult<GroupTO> matchingGroups = groupService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getGroupSearchConditionBuilder().is("userOwner").equalTo(5).query()).build());
assertNotNull(matchingGroups);
assertEquals(1, matchingGroups.getResult().size());
@@ -244,7 +245,7 @@ public class SearchITCase extends AbstractITCase {
@Test
public void nested() {
PagedResult<UserTO> matchingUsers = userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql("((fullname==*o*,fullname==*i*);$resources!=ws-target-resource-1)").page(1).size(2).build());
assertNotNull(matchingUsers);
@@ -257,7 +258,7 @@ public class SearchITCase extends AbstractITCase {
@Test
public void searchByType() {
PagedResult<AnyObjectTO> matching = anyObjectService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getAnyObjectSearchConditionBuilder().type("PRINTER").query()).build());
assertNotNull(matching);
@@ -267,7 +268,7 @@ public class SearchITCase extends AbstractITCase {
}
matching = anyObjectService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getAnyObjectSearchConditionBuilder().type("UNEXISTING").query()).build());
assertNotNull(matching);
@@ -277,7 +278,7 @@ public class SearchITCase extends AbstractITCase {
@Test
public void orderBy() {
PagedResult<UserTO> matchingUsers = userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getUserSearchConditionBuilder().is("userId").equalTo("*@apache.org").query()).
orderBy(SyncopeClient.getOrderByClauseBuilder().asc("status").desc("firstname").build()).build());
assertNotNull(matchingUsers);
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SyncTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SyncTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SyncTaskITCase.java
index 7d2d13b..e94001f 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SyncTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SyncTaskITCase.java
@@ -64,6 +64,8 @@ import org.apache.syncope.common.lib.types.PropagationTaskExecStatus;
import org.apache.syncope.common.lib.types.ResourceDeassociationAction;
import org.apache.syncope.common.lib.types.SyncMode;
import org.apache.syncope.common.lib.types.TaskType;
+import org.apache.syncope.common.rest.api.beans.AnySearchQuery;
+import org.apache.syncope.common.rest.api.beans.TaskQuery;
import org.apache.syncope.common.rest.api.service.TaskService;
import org.apache.syncope.core.misc.security.Encryptor;
import org.apache.syncope.core.provisioning.java.sync.DBPasswordSyncActions;
@@ -95,8 +97,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
@Test
public void list() {
- PagedResult<SyncTaskTO> tasks =
- taskService.list(TaskType.SYNCHRONIZATION, SyncopeClient.getTaskQueryBuilder().build());
+ PagedResult<SyncTaskTO> tasks = taskService.list(TaskType.SYNCHRONIZATION, new TaskQuery.Builder().build());
assertFalse(tasks.getResult().isEmpty());
for (AbstractTaskTO task : tasks.getResult()) {
if (!(task instanceof SyncTaskTO)) {
@@ -163,7 +164,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
// -----------------------------
try {
int usersPre = userService.list(
- SyncopeClient.getAnyListQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
page(1).size(1).build()).getTotalCount();
assertNotNull(usersPre);
@@ -219,7 +220,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
// check for sync results
int usersPost = userService.list(
- SyncopeClient.getAnyListQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
page(1).size(1).build()).getTotalCount();
assertNotNull(usersPost);
assertEquals(usersPre + 8, usersPost);
@@ -294,7 +295,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
*/
private void ldapCleanup() {
PagedResult<GroupTO> matchingGroups = groupService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getGroupSearchConditionBuilder().is("name").equalTo("testLDAPGroup").query()).
build());
if (matchingGroups.getSize() > 0) {
@@ -308,7 +309,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
}
}
PagedResult<UserTO> matchingUsers = userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getUserSearchConditionBuilder().is("username").equalTo("syncFromLDAP").query()).
build());
if (matchingUsers.getSize() > 0) {
@@ -336,7 +337,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
// 2. verify that synchronized group is found
PagedResult<GroupTO> matchingGroups = groupService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getGroupSearchConditionBuilder().is("name").equalTo("testLDAPGroup").query()).
build());
assertNotNull(matchingGroups);
@@ -344,7 +345,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
// 3. verify that synchronized user is found
PagedResult<UserTO> matchingUsers = userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getUserSearchConditionBuilder().is("username").equalTo("syncFromLDAP").query()).
build());
assertNotNull(matchingUsers);
@@ -413,7 +414,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
// 3. unlink any existing printer and delete from Syncope (printer is now only on external resource)
PagedResult<AnyObjectTO> matchingPrinters = anyObjectService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getAnyObjectSearchConditionBuilder().type("PRINTER").and().
is("location").equalTo("sync*").query()).build());
assertTrue(matchingPrinters.getSize() > 0);
@@ -432,7 +433,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
// 5. verify that printer was re-created in Syncope (implies that location does not start with given prefix,
// hence PrefixMappingItemTransformer was applied during sync)
matchingPrinters = anyObjectService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
fiql(SyncopeClient.getAnyObjectSearchConditionBuilder().type("PRINTER").and().
is("location").equalTo("sync*").query()).build());
assertTrue(matchingPrinters.getSize() > 0);
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserITCase.java
index c502ed1..e8ccf7d 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserITCase.java
@@ -91,6 +91,8 @@ import org.apache.syncope.common.lib.types.StatusPatchType;
import org.apache.syncope.common.lib.types.TaskType;
import org.apache.syncope.common.rest.api.Preference;
import org.apache.syncope.common.rest.api.RESTHeaders;
+import org.apache.syncope.common.rest.api.beans.AnySearchQuery;
+import org.apache.syncope.common.rest.api.beans.TaskQuery;
import org.apache.syncope.common.rest.api.service.ResourceService;
import org.apache.syncope.common.rest.api.service.UserSelfService;
import org.apache.syncope.common.rest.api.service.UserService;
@@ -149,7 +151,7 @@ public class UserITCase extends AbstractITCase {
// get task list
PagedResult<PropagationTaskTO> tasks = taskService.list(
TaskType.PROPAGATION,
- SyncopeClient.getTaskQueryBuilder().page(1).size(1).build());
+ new TaskQuery.Builder().page(1).size(1).build());
assertNotNull(tasks);
assertFalse(tasks.getResult().isEmpty());
@@ -165,7 +167,7 @@ public class UserITCase extends AbstractITCase {
// get the new task list
tasks = taskService.list(
TaskType.PROPAGATION,
- SyncopeClient.getTaskQueryBuilder().page(1).size(1).build());
+ new TaskQuery.Builder().page(1).size(1).build());
assertNotNull(tasks);
assertFalse(tasks.getResult().isEmpty());
@@ -355,7 +357,7 @@ public class UserITCase extends AbstractITCase {
// get task list
PagedResult<PropagationTaskTO> tasks = taskService.list(
TaskType.PROPAGATION,
- SyncopeClient.getTaskQueryBuilder().page(1).size(1).build());
+ new TaskQuery.Builder().page(1).size(1).build());
assertNotNull(tasks);
assertFalse(tasks.getResult().isEmpty());
@@ -397,7 +399,7 @@ public class UserITCase extends AbstractITCase {
// get the new task list
tasks = taskService.list(
TaskType.PROPAGATION,
- SyncopeClient.getTaskQueryBuilder().page(1).size(1).build());
+ new TaskQuery.Builder().page(1).size(1).build());
assertNotNull(tasks);
assertFalse(tasks.getResult().isEmpty());
@@ -543,7 +545,7 @@ public class UserITCase extends AbstractITCase {
@Test
public void list() {
PagedResult<UserTO> users = userService.list(
- SyncopeClient.getAnyListQueryBuilder().realm(SyncopeConstants.ROOT_REALM).build());
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).build());
assertNotNull(users);
assertFalse(users.getResult().isEmpty());
@@ -555,7 +557,7 @@ public class UserITCase extends AbstractITCase {
@Test
public void paginatedList() {
PagedResult<UserTO> users = userService.list(
- SyncopeClient.getAnyListQueryBuilder().realm(SyncopeConstants.ROOT_REALM).page(1).size(2).build());
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).page(1).size(2).build());
assertNotNull(users);
assertFalse(users.getResult().isEmpty());
assertEquals(2, users.getResult().size());
@@ -564,13 +566,13 @@ public class UserITCase extends AbstractITCase {
assertNotNull(user);
}
- users = userService.list(SyncopeClient.getAnyListQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ users = userService.list(new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
page(2).size(2).build());
assertNotNull(users);
assertEquals(2, users.getPage());
assertEquals(2, users.getResult().size());
- users = userService.list(SyncopeClient.getAnyListQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
+ users = userService.list(new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
page(100).size(2).build());
assertNotNull(users);
assertTrue(users.getResult().isEmpty());
@@ -692,7 +694,7 @@ public class UserITCase extends AbstractITCase {
@Test
public void updatePasswordOnly() {
int beforeTasks = taskService.list(TaskType.PROPAGATION,
- SyncopeClient.getTaskQueryBuilder().page(1).size(1).build()).getTotalCount();
+ new TaskQuery.Builder().page(1).size(1).build()).getTotalCount();
assertFalse(beforeTasks <= 0);
UserTO userTO = getUniqueSampleTO("pwdonly@t.com");
@@ -710,7 +712,7 @@ public class UserITCase extends AbstractITCase {
assertNotNull(userTO.getChangePwdDate());
int afterTasks = taskService.list(TaskType.PROPAGATION,
- SyncopeClient.getTaskQueryBuilder().page(1).size(1).build()).getTotalCount();
+ new TaskQuery.Builder().page(1).size(1).build()).getTotalCount();
assertFalse(beforeTasks <= 0);
assertTrue(beforeTasks < afterTasks);
@@ -722,7 +724,7 @@ public class UserITCase extends AbstractITCase {
// get task list
PagedResult<PropagationTaskTO> tasks = taskService.list(
TaskType.PROPAGATION,
- SyncopeClient.getTaskQueryBuilder().page(1).size(1).build());
+ new TaskQuery.Builder().page(1).size(1).build());
assertNotNull(tasks);
assertFalse(tasks.getResult().isEmpty());
@@ -743,7 +745,7 @@ public class UserITCase extends AbstractITCase {
// get the new task list
tasks = taskService.list(
TaskType.PROPAGATION,
- SyncopeClient.getTaskQueryBuilder().page(1).size(1).build());
+ new TaskQuery.Builder().page(1).size(1).build());
assertNotNull(tasks);
assertFalse(tasks.getResult().isEmpty());
@@ -769,7 +771,7 @@ public class UserITCase extends AbstractITCase {
// get the new task list
tasks = taskService.list(
TaskType.PROPAGATION,
- SyncopeClient.getTaskQueryBuilder().page(1).size(1).build());
+ new TaskQuery.Builder().page(1).size(1).build());
maxKey = newMaxKey;
newMaxKey = tasks.getResult().iterator().next().getKey();
@@ -791,7 +793,7 @@ public class UserITCase extends AbstractITCase {
// get the new task list
tasks = taskService.list(
TaskType.PROPAGATION,
- SyncopeClient.getTaskQueryBuilder().page(1).size(1).build());
+ new TaskQuery.Builder().page(1).size(1).build());
maxKey = newMaxKey;
newMaxKey = tasks.getResult().iterator().next().getKey();
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserWorkflowITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserWorkflowITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserWorkflowITCase.java
index cb0bdce..150b0bc 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserWorkflowITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserWorkflowITCase.java
@@ -30,8 +30,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.patch.LongPatchItem;
import org.apache.syncope.common.lib.patch.PasswordPatch;
+import org.apache.syncope.common.lib.patch.StringPatchItem;
import org.apache.syncope.common.lib.patch.UserPatch;
import org.apache.syncope.common.lib.to.MembershipTO;
import org.apache.syncope.common.lib.to.ProvisioningResult;
@@ -76,17 +76,17 @@ public class UserWorkflowITCase extends AbstractITCase {
assertNotNull(form.getTaskId());
assertNull(form.getOwner());
- // 3. claim task as rossini, with role 2 granting entitlement to claim forms but not in group 7,
+ // 3. claim task as rossini, with role "User manager" granting entitlement to claim forms but not in group 7,
// designated for approval in workflow definition: fail
UserTO rossini = userService.read(1L);
- if (!rossini.getRoles().contains(2L)) {
+ if (!rossini.getRoles().contains("User manager")) {
UserPatch userPatch = new UserPatch();
userPatch.setKey(1L);
- userPatch.getRoles().add(new LongPatchItem.Builder().
- operation(PatchOperation.ADD_REPLACE).value(2L).build());
+ userPatch.getRoles().add(new StringPatchItem.Builder().
+ operation(PatchOperation.ADD_REPLACE).value("User manager").build());
rossini = updateUser(userPatch).getAny();
}
- assertTrue(rossini.getRoles().contains(2L));
+ assertTrue(rossini.getRoles().contains("User manager"));
UserWorkflowService userService2 = clientFactory.create("rossini", ADMIN_PWD).
getService(UserWorkflowService.class);
@@ -97,7 +97,7 @@ public class UserWorkflowITCase extends AbstractITCase {
assertEquals(ClientExceptionType.Workflow, e.getType());
}
- // 4. claim task from bellini, with role 2 and in group 7
+ // 4. claim task from bellini, with role "User manager" and in group 7
UserWorkflowService userService3 = clientFactory.create("bellini", ADMIN_PWD).
getService(UserWorkflowService.class);
form = userService3.claimForm(form.getTaskId());
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/VirSchemaITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/VirSchemaITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/VirSchemaITCase.java
index 45b4762..f19f9dd 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/VirSchemaITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/VirSchemaITCase.java
@@ -18,12 +18,14 @@
*/
package org.apache.syncope.fit.core.reference;
+import static org.apache.syncope.fit.core.reference.AbstractITCase.clientFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.security.AccessControlException;
import java.util.List;
import javax.ws.rs.core.Response;
import org.apache.syncope.common.lib.SyncopeClientException;
@@ -32,6 +34,8 @@ import org.apache.syncope.common.lib.to.VirSchemaTO;
import org.apache.syncope.common.lib.types.ClientExceptionType;
import org.apache.syncope.common.lib.types.EntityViolationType;
import org.apache.syncope.common.lib.types.SchemaType;
+import org.apache.syncope.common.rest.api.beans.SchemaQuery;
+import org.apache.syncope.common.rest.api.service.SchemaService;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
@@ -41,7 +45,7 @@ public class VirSchemaITCase extends AbstractITCase {
@Test
public void list() {
- List<VirSchemaTO> vSchemas = schemaService.list(SchemaType.VIRTUAL, null);
+ List<VirSchemaTO> vSchemas = schemaService.list(SchemaType.VIRTUAL, new SchemaQuery.Builder().build());
assertFalse(vSchemas.isEmpty());
for (VirSchemaTO vSchemaTO : vSchemas) {
assertNotNull(vSchemaTO);
@@ -88,6 +92,20 @@ public class VirSchemaITCase extends AbstractITCase {
}
@Test
+ public void anonymous() {
+ SchemaService unauthenticated = clientFactory.create().getService(SchemaService.class);
+ try {
+ unauthenticated.list(SchemaType.VIRTUAL, new SchemaQuery.Builder().build());
+ fail();
+ } catch (AccessControlException e) {
+ assertNotNull(e);
+ }
+
+ SchemaService anonymous = clientFactory.create(ANONYMOUS_UNAME, ANONYMOUS_KEY).getService(SchemaService.class);
+ assertFalse(anonymous.list(SchemaType.VIRTUAL, new SchemaQuery.Builder().build()).isEmpty());
+ }
+
+ @Test
public void issueSYNCOPE323() {
VirSchemaTO actual = schemaService.read(SchemaType.VIRTUAL, "virtualdata");
assertNotNull(actual);
[3/3] syncope git commit: Reviewing several client-side builders,
adjusting roles
Posted by il...@apache.org.
Reviewing several client-side builders, adjusting roles
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/b738d3e9
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/b738d3e9
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/b738d3e9
Branch: refs/heads/master
Commit: b738d3e94877528cb74fc1b0b75c4c11e83aa16d
Parents: 6ea34cd
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Thu Nov 19 16:52:42 2015 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Thu Nov 19 16:52:42 2015 +0100
----------------------------------------------------------------------
.../entitlement/EntitlementResultManager.java | 1 -
.../EntitlementSyncopeOperations.java | 8 +--
.../cli/commands/role/RoleResultManager.java | 1 -
.../commands/role/RoleSyncopeOperations.java | 12 ++--
.../schema/SchemaSyncopeOperations.java | 15 ++--
.../cli/commands/user/UserResultManager.java | 12 ++--
.../commands/user/UserSyncopeOperations.java | 11 +--
.../console/rest/AnyObjectRestClient.java | 6 +-
.../client/console/rest/GroupRestClient.java | 11 +--
.../client/console/rest/SchemaRestClient.java | 33 ++-------
.../client/console/rest/TaskRestClient.java | 10 +--
.../client/console/rest/UserRestClient.java | 11 +--
.../enduser/resources/AbstractBaseResource.java | 14 +---
.../enduser/resources/SchemaResource.java | 29 +++-----
.../resources/SecurityQuestionResource.java | 3 +-
.../resources/UserSelfCreateResource.java | 3 +-
.../resources/UserSelfUpdateResource.java | 4 +-
.../syncope/client/lib/SyncopeClient.java | 57 +---------------
.../lib/builders/AbstractQueryBuilder.java | 57 ----------------
.../lib/builders/AnyListQueryBuilder.java | 68 ------------------
.../client/lib/builders/AnyQueryBuilder.java | 49 -------------
.../lib/builders/AnySearchQueryBuilder.java | 70 -------------------
.../builders/ConnObjectTOListQueryBuilder.java | 48 -------------
.../client/lib/builders/TaskQueryBuilder.java | 60 ----------------
.../syncope/common/lib/AnyOperations.java | 27 ++++----
.../syncope/common/lib/patch/UserPatch.java | 4 +-
.../search/UserFiqlSearchConditionBuilder.java | 6 +-
.../syncope/common/lib/search/UserProperty.java | 4 +-
.../apache/syncope/common/lib/to/RoleTO.java | 16 +----
.../apache/syncope/common/lib/to/UserTO.java | 8 +--
.../org/apache/syncope/common/lib/JSONTest.java | 4 +-
.../common/rest/api/beans/AbstractQuery.java | 36 ++++++++++
.../common/rest/api/beans/AnyListQuery.java | 23 +++++++
.../syncope/common/rest/api/beans/AnyQuery.java | 14 ++++
.../common/rest/api/beans/AnySearchQuery.java | 29 ++++++++
.../rest/api/beans/ConnObjectTOListQuery.java | 25 +++++++
.../common/rest/api/beans/SchemaQuery.java | 72 ++++++++++++++++++++
.../common/rest/api/beans/TaskQuery.java | 24 +++++++
.../common/rest/api/service/RoleService.java | 4 +-
.../common/rest/api/service/SchemaService.java | 12 ++--
.../syncope/core/logic/AnyTypeClassLogic.java | 6 +-
.../apache/syncope/core/logic/AnyTypeLogic.java | 6 +-
.../apache/syncope/core/logic/DomainLogic.java | 6 +-
.../syncope/core/logic/NotificationLogic.java | 18 ++---
.../core/logic/RelationshipTypeLogic.java | 6 +-
.../apache/syncope/core/logic/RoleLogic.java | 26 +++----
.../apache/syncope/core/logic/SchemaLogic.java | 23 +++++--
.../core/misc/search/SearchCondVisitor.java | 2 +-
.../core/misc/security/AuthDataAccessor.java | 35 +++++++---
.../misc/security/SyncopeGrantedAuthority.java | 4 +-
.../misc/search/SearchCondConverterTest.java | 6 +-
.../core/persistence/api/dao/RoleDAO.java | 8 +--
.../core/persistence/api/dao/SchemaDAO.java | 3 +-
.../persistence/api/dao/search/RoleCond.java | 6 +-
.../core/persistence/api/entity/Role.java | 6 +-
.../persistence/jpa/dao/JPAAnySearchDAO.java | 30 ++++----
.../persistence/jpa/dao/JPAAnyTypeClassDAO.java | 7 +-
.../persistence/jpa/dao/JPADerSchemaDAO.java | 12 ++--
.../persistence/jpa/dao/JPAPlainSchemaDAO.java | 12 ++--
.../core/persistence/jpa/dao/JPARoleDAO.java | 23 +------
.../persistence/jpa/dao/JPAVirSchemaDAO.java | 12 ++--
.../core/persistence/jpa/entity/JPARole.java | 22 ++----
.../persistence/jpa/entity/user/JPAUser.java | 6 +-
.../entity/ExternalResourceValidator.java | 2 +-
.../jpa/validation/entity/RoleCheck.java | 41 +++++++++++
.../jpa/validation/entity/RoleValidator.java | 40 +++++++++++
.../resources/META-INF/spring-orm-oracle.xml | 9 ---
.../resources/META-INF/spring-orm-sqlserver.xml | 9 ---
.../src/main/resources/META-INF/spring-orm.xml | 9 ---
.../src/main/resources/views.xml | 4 +-
.../persistence/jpa/inner/AnySearchTest.java | 4 +-
.../core/persistence/jpa/inner/RoleTest.java | 23 +++----
.../persistence/jpa/outer/AnySearchTest.java | 2 +-
.../core/persistence/jpa/outer/RealmTest.java | 4 +-
.../core/persistence/jpa/outer/RoleTest.java | 4 +-
.../test/resources/domains/MasterContent.xml | 56 +++++++--------
.../java/data/AnyTypeClassDataBinderImpl.java | 7 +-
.../java/data/RoleDataBinderImpl.java | 23 +++----
.../java/data/UserDataBinderImpl.java | 14 ++--
.../core/rest/cxf/service/RoleServiceImpl.java | 10 +--
.../rest/cxf/service/SchemaServiceImpl.java | 5 +-
.../fit/core/reference/AbstractTaskITCase.java | 4 +-
.../fit/core/reference/AnyObjectITCase.java | 6 +-
.../core/reference/AuthenticationITCase.java | 26 +++----
.../fit/core/reference/DerSchemaITCase.java | 7 +-
.../core/reference/ExceptionMapperITCase.java | 27 ++++----
.../syncope/fit/core/reference/GroupITCase.java | 10 +--
.../fit/core/reference/MultitenancyITCase.java | 7 +-
.../fit/core/reference/PlainSchemaITCase.java | 24 ++-----
.../core/reference/PropagationTaskITCase.java | 14 ++--
.../fit/core/reference/PushTaskITCase.java | 4 +-
.../fit/core/reference/ResourceITCase.java | 5 +-
.../syncope/fit/core/reference/RoleITCase.java | 6 +-
.../fit/core/reference/SchedTaskITCase.java | 4 +-
.../fit/core/reference/SearchITCase.java | 37 +++++-----
.../fit/core/reference/SyncTaskITCase.java | 21 +++---
.../syncope/fit/core/reference/UserITCase.java | 30 ++++----
.../fit/core/reference/UserWorkflowITCase.java | 14 ++--
.../fit/core/reference/VirSchemaITCase.java | 20 +++++-
99 files changed, 779 insertions(+), 939 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/cli/src/main/java/org/apache/syncope/client/cli/commands/entitlement/EntitlementResultManager.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/entitlement/EntitlementResultManager.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/entitlement/EntitlementResultManager.java
index 6f023c4..02d3e67 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/entitlement/EntitlementResultManager.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/entitlement/EntitlementResultManager.java
@@ -41,7 +41,6 @@ public class EntitlementResultManager extends CommonsResultManager {
private void printRole(final RoleTO roleTO) {
System.out.println(" > ROLE ID: " + roleTO.getKey());
- System.out.println(" name: " + roleTO.getName());
System.out.println(" REALMS: ");
printRealms(roleTO.getRealms());
System.out.println("");
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/cli/src/main/java/org/apache/syncope/client/cli/commands/entitlement/EntitlementSyncopeOperations.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/entitlement/EntitlementSyncopeOperations.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/entitlement/EntitlementSyncopeOperations.java
index 797678f..8ee92f0 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/entitlement/EntitlementSyncopeOperations.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/entitlement/EntitlementSyncopeOperations.java
@@ -48,8 +48,8 @@ public class EntitlementSyncopeOperations {
public Set<String> usernameEntitlements(final String username) {
final Set<String> entitlements = new TreeSet<>();
final UserTO userTO = userSyncopeOperations.read(userSyncopeOperations.getIdFromUsername(username));
- for (final Long role : userTO.getRoles()) {
- entitlements.addAll(roleSyncopeOperations.read(String.valueOf(role)).getEntitlements());
+ for (final String role : userTO.getRoles()) {
+ entitlements.addAll(roleSyncopeOperations.read(role).getEntitlements());
}
return entitlements;
}
@@ -57,8 +57,8 @@ public class EntitlementSyncopeOperations {
public Set<String> userIdEntitlements(final String userId) {
final Set<String> entitlements = new TreeSet<>();
final UserTO userTO = userSyncopeOperations.read(userId);
- for (final Long role : userTO.getRoles()) {
- entitlements.addAll(roleSyncopeOperations.read(String.valueOf(role)).getEntitlements());
+ for (final String role : userTO.getRoles()) {
+ entitlements.addAll(roleSyncopeOperations.read(role).getEntitlements());
}
return entitlements;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/cli/src/main/java/org/apache/syncope/client/cli/commands/role/RoleResultManager.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/role/RoleResultManager.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/role/RoleResultManager.java
index d8d8861..4ca13da 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/role/RoleResultManager.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/role/RoleResultManager.java
@@ -35,7 +35,6 @@ public class RoleResultManager extends CommonsResultManager {
private void printRole(final RoleTO roleTO) {
System.out.println(" > ROLE ID: " + roleTO.getKey());
- System.out.println(" name: " + roleTO.getName());
System.out.println(" REALMS: ");
printRealms(roleTO.getRealms());
System.out.println(" ENTITLEMENTS:");
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/cli/src/main/java/org/apache/syncope/client/cli/commands/role/RoleSyncopeOperations.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/role/RoleSyncopeOperations.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/role/RoleSyncopeOperations.java
index 11c207d..6bffb17 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/role/RoleSyncopeOperations.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/role/RoleSyncopeOperations.java
@@ -30,12 +30,12 @@ public class RoleSyncopeOperations {
public List<RoleTO> list() {
return roleService.list();
}
-
- public RoleTO read(final String roleId) {
- return roleService.read(Long.valueOf(roleId));
+
+ public RoleTO read(final String role) {
+ return roleService.read(role);
}
-
- public void delete(final String roleId) {
- roleService.delete(Long.valueOf(roleId));
+
+ public void delete(final String role) {
+ roleService.delete(role);
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/cli/src/main/java/org/apache/syncope/client/cli/commands/schema/SchemaSyncopeOperations.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/schema/SchemaSyncopeOperations.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/schema/SchemaSyncopeOperations.java
index 757e2d6..73c483d 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/schema/SchemaSyncopeOperations.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/schema/SchemaSyncopeOperations.java
@@ -22,6 +22,7 @@ import java.util.List;
import org.apache.syncope.client.cli.SyncopeServices;
import org.apache.syncope.common.lib.to.AbstractSchemaTO;
import org.apache.syncope.common.lib.types.SchemaType;
+import org.apache.syncope.common.rest.api.beans.SchemaQuery;
import org.apache.syncope.common.rest.api.service.SchemaService;
public class SchemaSyncopeOperations {
@@ -33,19 +34,19 @@ public class SchemaSyncopeOperations {
}
public <T extends AbstractSchemaTO> List<T> list(final String schemaTypeString) {
- return schemaService.list(SchemaType.valueOf(schemaTypeString), null);
- }
-
- public <T extends AbstractSchemaTO> List<T> listVirtual() {
- return schemaService.list(SchemaType.VIRTUAL, null);
+ return schemaService.list(SchemaType.valueOf(schemaTypeString), new SchemaQuery.Builder().build());
}
public <T extends AbstractSchemaTO> List<T> listPlain() {
- return schemaService.list(SchemaType.PLAIN, null);
+ return schemaService.list(SchemaType.PLAIN, new SchemaQuery.Builder().build());
}
public <T extends AbstractSchemaTO> List<T> listDerived() {
- return schemaService.list(SchemaType.DERIVED, null);
+ return schemaService.list(SchemaType.DERIVED, new SchemaQuery.Builder().build());
+ }
+
+ public <T extends AbstractSchemaTO> List<T> listVirtual() {
+ return schemaService.list(SchemaType.VIRTUAL, new SchemaQuery.Builder().build());
}
public void delete(final String schemaTypeString, final String schemaName) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/cli/src/main/java/org/apache/syncope/client/cli/commands/user/UserResultManager.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/user/UserResultManager.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/user/UserResultManager.java
index e7002d9..8e3dae2 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/user/UserResultManager.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/user/UserResultManager.java
@@ -75,8 +75,8 @@ public class UserResultManager extends CommonsResultManager {
}
}
- private void printRole(final List<Long> roles) {
- for (final Long role : roles) {
+ private void printRole(final List<String> roles) {
+ for (final String role : roles) {
System.out.println(" - " + role);
}
}
@@ -94,16 +94,16 @@ public class UserResultManager extends CommonsResultManager {
System.out.println(attributeSentence);
}
}
-
+
private void printRelationships(final List<RelationshipTO> relationshipTOs) {
for (final RelationshipTO relationshipTO : relationshipTOs) {
System.out.println(" type: " + relationshipTO.getType());
}
}
-
+
public void printUndeletedUsers(final Map<String, String> users) {
- final Table.TableBuilder tableBuilder
- = new Table.TableBuilder("Users not deleted").header("user id").header("cause");
+ final Table.TableBuilder tableBuilder =
+ new Table.TableBuilder("Users not deleted").header("user id").header("cause");
for (final Map.Entry<String, String> entrySet : users.entrySet()) {
tableBuilder.rowValues(new LinkedList<>(Arrays.asList(entrySet.getKey(), entrySet.getValue())));
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/cli/src/main/java/org/apache/syncope/client/cli/commands/user/UserSyncopeOperations.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/user/UserSyncopeOperations.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/user/UserSyncopeOperations.java
index aec9271..9cdabd7 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/user/UserSyncopeOperations.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/user/UserSyncopeOperations.java
@@ -29,6 +29,7 @@ import org.apache.syncope.common.lib.to.PagedResult;
import org.apache.syncope.common.lib.to.UserTO;
import org.apache.syncope.common.rest.api.RESTHeaders;
import org.apache.syncope.common.rest.api.beans.AnyListQuery;
+import org.apache.syncope.common.rest.api.beans.AnySearchQuery;
import org.apache.syncope.common.rest.api.service.UserService;
public class UserSyncopeOperations {
@@ -46,21 +47,21 @@ public class UserSyncopeOperations {
public List<UserTO> searchByRole(final String realm, final String role) {
return userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(realm).
- fiql(SyncopeClient.getUserSearchConditionBuilder().inRoles(Long.valueOf(role))
+ new AnySearchQuery.Builder().realm(realm).
+ fiql(SyncopeClient.getUserSearchConditionBuilder().inRoles(role)
.query()).build()).getResult();
}
public List<UserTO> searchByResource(final String realm, final String resource) {
return userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(realm).
+ new AnySearchQuery.Builder().realm(realm).
fiql(SyncopeClient.getUserSearchConditionBuilder().hasResources(resource)
.query()).build()).getResult();
}
public List<UserTO> searchByAttribute(final String realm, final String attributeName, final String attributeValue) {
return userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(realm).
+ new AnySearchQuery.Builder().realm(realm).
fiql(SyncopeClient.getUserSearchConditionBuilder().is(attributeName).equalTo(attributeValue)
.query()).build()).getResult();
}
@@ -88,7 +89,7 @@ public class UserSyncopeOperations {
public Map<String, BulkActionResult.Status> deleteByAttribute(
final String realm, final String attributeName, final String attributeValue) {
final List<UserTO> users = userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(realm).
+ new AnySearchQuery.Builder().realm(realm).
fiql(SyncopeClient.getUserSearchConditionBuilder().is(attributeName).equalTo(attributeValue)
.query()).build()).getResult();
return deleteBulk(users);
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/console/src/main/java/org/apache/syncope/client/console/rest/AnyObjectRestClient.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/rest/AnyObjectRestClient.java b/client/console/src/main/java/org/apache/syncope/client/console/rest/AnyObjectRestClient.java
index b5d0fcc..b845eb7 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/rest/AnyObjectRestClient.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/rest/AnyObjectRestClient.java
@@ -20,7 +20,6 @@ package org.apache.syncope.client.console.rest;
import java.util.List;
import javax.ws.rs.core.Response;
-import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.syncope.common.lib.to.AnyTO;
@@ -29,6 +28,7 @@ import org.apache.syncope.common.lib.to.BulkActionResult;
import org.apache.syncope.common.lib.to.ConnObjectTO;
import org.apache.syncope.common.lib.to.PagedResult;
import org.apache.syncope.common.lib.to.ProvisioningResult;
+import org.apache.syncope.common.rest.api.beans.AnyListQuery;
import org.apache.syncope.common.rest.api.service.AnyObjectService;
import org.apache.syncope.common.rest.api.service.AnyService;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
@@ -50,7 +50,7 @@ public class AnyObjectRestClient extends AbstractAnyRestClient<AnyObjectTO> {
@Override
public int count(final String type, final String realm) {
return getService(AnyObjectService.class).list(
- type, SyncopeClient.getAnyListQueryBuilder().realm(realm).page(1).size(1).build()).getTotalCount();
+ type, new AnyListQuery.Builder().realm(realm).page(1).size(1).build()).getTotalCount();
}
@Override
@@ -62,7 +62,7 @@ public class AnyObjectRestClient extends AbstractAnyRestClient<AnyObjectTO> {
public PagedResult<AnyObjectTO> list(final String type, final String realm) {
return getService(AnyObjectService.class).
- list(type, SyncopeClient.getAnyListQueryBuilder().realm(realm).build());
+ list(type, new AnyListQuery.Builder().realm(realm).build());
}
@Override
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/console/src/main/java/org/apache/syncope/client/console/rest/GroupRestClient.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/rest/GroupRestClient.java b/client/console/src/main/java/org/apache/syncope/client/console/rest/GroupRestClient.java
index fc060e4..72f80f5 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/rest/GroupRestClient.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/rest/GroupRestClient.java
@@ -22,7 +22,6 @@ import java.util.List;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
-import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.common.lib.patch.GroupPatch;
import org.apache.syncope.common.lib.to.BulkAction;
import org.apache.syncope.common.lib.to.BulkActionResult;
@@ -30,6 +29,8 @@ import org.apache.syncope.common.lib.to.ConnObjectTO;
import org.apache.syncope.common.lib.to.GroupTO;
import org.apache.syncope.common.lib.to.ProvisioningResult;
import org.apache.syncope.common.lib.types.AnyTypeKind;
+import org.apache.syncope.common.rest.api.beans.AnyListQuery;
+import org.apache.syncope.common.rest.api.beans.AnySearchQuery;
import org.apache.syncope.common.rest.api.service.AnyService;
import org.apache.syncope.common.rest.api.service.ResourceService;
import org.apache.syncope.common.rest.api.service.GroupService;
@@ -52,7 +53,7 @@ public class GroupRestClient extends AbstractAnyRestClient<GroupTO> {
@Override
public int count(final String realm, final String type) {
return getService(GroupService.class).
- list(SyncopeClient.getAnyListQueryBuilder().realm(realm).page(1).size(1).build()).
+ list(new AnyListQuery.Builder().realm(realm).page(1).size(1).build()).
getTotalCount();
}
@@ -60,7 +61,7 @@ public class GroupRestClient extends AbstractAnyRestClient<GroupTO> {
public List<GroupTO> list(final String realm, final int page, final int size, final SortParam<String> sort,
final String type) {
return getService(GroupService.class).
- list(SyncopeClient.getAnyListQueryBuilder().realm(realm).page(page).size(size).
+ list(new AnyListQuery.Builder().realm(realm).page(page).size(size).
orderBy(toOrderBy(sort)).details(false).build()).
getResult();
}
@@ -68,7 +69,7 @@ public class GroupRestClient extends AbstractAnyRestClient<GroupTO> {
@Override
public int searchCount(final String realm, final String fiql, final String type) {
return getService(GroupService.class).
- search(SyncopeClient.getAnySearchQueryBuilder().realm(realm).fiql(fiql).page(1).size(1).build()).
+ search(new AnySearchQuery.Builder().realm(realm).fiql(fiql).page(1).size(1).build()).
getTotalCount();
}
@@ -78,7 +79,7 @@ public class GroupRestClient extends AbstractAnyRestClient<GroupTO> {
final String type) {
return getService(GroupService.class).
- search(SyncopeClient.getAnySearchQueryBuilder().realm(realm).fiql(fiql).page(page).size(size).
+ search(new AnySearchQuery.Builder().realm(realm).fiql(fiql).page(page).size(size).
orderBy(toOrderBy(sort)).details(false).build()).
getResult();
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/console/src/main/java/org/apache/syncope/client/console/rest/SchemaRestClient.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/rest/SchemaRestClient.java b/client/console/src/main/java/org/apache/syncope/client/console/rest/SchemaRestClient.java
index 4d5f9fb..517aaa4 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/rest/SchemaRestClient.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/rest/SchemaRestClient.java
@@ -31,6 +31,7 @@ import org.apache.syncope.common.lib.to.DerSchemaTO;
import org.apache.syncope.common.lib.to.PlainSchemaTO;
import org.apache.syncope.common.lib.to.VirSchemaTO;
import org.apache.syncope.common.lib.types.SchemaType;
+import org.apache.syncope.common.rest.api.beans.SchemaQuery;
import org.apache.syncope.common.rest.api.service.SchemaService;
import org.springframework.stereotype.Component;
@@ -62,11 +63,11 @@ public class SchemaRestClient extends BaseRestClient {
try {
if (kind == null || kind.length == 0) {
- schemas.addAll(getService(SchemaService.class).<T>list(schemaType, null));
+ schemas.addAll(getService(SchemaService.class).
+ <T>list(schemaType, new SchemaQuery.Builder().build()));
} else {
- for (String clazz : kind) {
- schemas.addAll(getService(SchemaService.class).<T>list(schemaType, clazz));
- }
+ schemas.addAll(getService(SchemaService.class).
+ <T>list(schemaType, new SchemaQuery.Builder().anyTypeClasses(kind).build()));
}
} catch (SyncopeClientException e) {
LOG.error("While getting all {} schemas for {}", schemaType, kind, e);
@@ -96,34 +97,10 @@ public class SchemaRestClient extends BaseRestClient {
return getSchemaNames(SchemaType.PLAIN);
}
- public List<DerSchemaTO> getDerSchemas() {
- List<DerSchemaTO> userDerSchemas = null;
-
- try {
- userDerSchemas = getService(SchemaService.class).list(SchemaType.DERIVED, null);
- } catch (SyncopeClientException e) {
- LOG.error("While getting all user derived schemas", e);
- }
-
- return userDerSchemas;
- }
-
public List<String> getDerSchemaNames() {
return getSchemaNames(SchemaType.DERIVED);
}
- public List<VirSchemaTO> getVirSchemas() {
- List<VirSchemaTO> userVirSchemas = null;
-
- try {
- userVirSchemas = getService(SchemaService.class).list(SchemaType.VIRTUAL, null);
- } catch (SyncopeClientException e) {
- LOG.error("While getting all virtual schemas", e);
- }
-
- return userVirSchemas;
- }
-
public List<String> getVirSchemaNames() {
return getSchemaNames(SchemaType.VIRTUAL);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/console/src/main/java/org/apache/syncope/client/console/rest/TaskRestClient.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/rest/TaskRestClient.java b/client/console/src/main/java/org/apache/syncope/client/console/rest/TaskRestClient.java
index 30087ce..175633f 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/rest/TaskRestClient.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/rest/TaskRestClient.java
@@ -21,7 +21,6 @@ package org.apache.syncope.client.console.rest;
import java.util.List;
import java.util.Set;
import org.apache.syncope.client.console.SyncopeConsoleSession;
-import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.common.lib.to.AbstractTaskTO;
import org.apache.syncope.common.lib.to.BulkAction;
import org.apache.syncope.common.lib.to.BulkActionResult;
@@ -31,6 +30,7 @@ import org.apache.syncope.common.lib.to.PushTaskTO;
import org.apache.syncope.common.lib.to.SchedTaskTO;
import org.apache.syncope.common.lib.to.SyncTaskTO;
import org.apache.syncope.common.lib.types.TaskType;
+import org.apache.syncope.common.rest.api.beans.TaskQuery;
import org.apache.syncope.common.rest.api.service.TaskService;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
import org.springframework.stereotype.Component;
@@ -63,16 +63,16 @@ public class TaskRestClient extends BaseRestClient implements ExecutionRestClien
*/
public int count(final String kind) {
return getService(TaskService.class).
- list(TaskType.fromString(kind), SyncopeClient.getTaskQueryBuilder().page(1).size(1).build()).
+ list(TaskType.fromString(kind), new TaskQuery.Builder().page(1).size(1).build()).
getTotalCount();
}
@SuppressWarnings("unchecked")
- public <T extends AbstractTaskTO> List<T> list(final Class<T> reference,
- final int page, final int size, final SortParam<String> sort) {
+ public <T extends AbstractTaskTO> List<T> list(
+ final Class<T> reference, final int page, final int size, final SortParam<String> sort) {
return (List<T>) getService(TaskService.class).
- list(getTaskType(reference), SyncopeClient.getTaskQueryBuilder().page(page).size(size).
+ list(getTaskType(reference), new TaskQuery.Builder().page(page).size(size).
orderBy(toOrderBy(sort)).build()).
getResult();
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/console/src/main/java/org/apache/syncope/client/console/rest/UserRestClient.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/rest/UserRestClient.java b/client/console/src/main/java/org/apache/syncope/client/console/rest/UserRestClient.java
index dd79b3a..9b8f697 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/rest/UserRestClient.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/rest/UserRestClient.java
@@ -23,7 +23,6 @@ import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import org.apache.syncope.client.console.commons.status.StatusBean;
import org.apache.syncope.client.console.commons.status.StatusUtils;
-import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.patch.StatusPatch;
import org.apache.syncope.common.lib.patch.UserPatch;
@@ -34,6 +33,8 @@ import org.apache.syncope.common.lib.to.ProvisioningResult;
import org.apache.syncope.common.lib.to.UserTO;
import org.apache.syncope.common.lib.types.AnyTypeKind;
import org.apache.syncope.common.lib.types.StatusPatchType;
+import org.apache.syncope.common.rest.api.beans.AnyListQuery;
+import org.apache.syncope.common.rest.api.beans.AnySearchQuery;
import org.apache.syncope.common.rest.api.service.AnyService;
import org.apache.syncope.common.rest.api.service.ResourceService;
import org.apache.syncope.common.rest.api.service.UserService;
@@ -56,7 +57,7 @@ public class UserRestClient extends AbstractAnyRestClient<UserTO> {
@Override
public int count(final String realm, final String type) {
return getService(UserService.class).
- list(SyncopeClient.getAnyListQueryBuilder().realm(realm).page(1).size(1).build()).
+ list(new AnyListQuery.Builder().realm(realm).page(1).size(1).build()).
getTotalCount();
}
@@ -64,7 +65,7 @@ public class UserRestClient extends AbstractAnyRestClient<UserTO> {
public List<UserTO> list(final String realm, final int page, final int size, final SortParam<String> sort,
final String type) {
return getService(UserService.class).
- list(SyncopeClient.getAnyListQueryBuilder().realm(realm).page(page).size(size).
+ list(new AnyListQuery.Builder().realm(realm).page(page).size(size).
orderBy(toOrderBy(sort)).details(false).build()).getResult();
}
@@ -103,7 +104,7 @@ public class UserRestClient extends AbstractAnyRestClient<UserTO> {
@Override
public int searchCount(final String realm, final String fiql, final String type) {
return getService(UserService.class).
- search(SyncopeClient.getAnySearchQueryBuilder().realm(realm).fiql(fiql).page(1).size(1).build()).
+ search(new AnySearchQuery.Builder().realm(realm).fiql(fiql).page(1).size(1).build()).
getTotalCount();
}
@@ -113,7 +114,7 @@ public class UserRestClient extends AbstractAnyRestClient<UserTO> {
final String type) {
return getService(UserService.class).
- search(SyncopeClient.getAnySearchQueryBuilder().realm(realm).fiql(fiql).page(page).size(size).
+ search(new AnySearchQuery.Builder().realm(realm).fiql(fiql).page(page).size(size).
orderBy(toOrderBy(sort)).details(false).build()).getResult();
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AbstractBaseResource.java
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AbstractBaseResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AbstractBaseResource.java
index a3aedfc..69fe72f 100644
--- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AbstractBaseResource.java
+++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AbstractBaseResource.java
@@ -30,19 +30,7 @@ public abstract class AbstractBaseResource extends AbstractResource {
private static final Logger LOG = LoggerFactory.getLogger(AbstractBaseResource.class);
- protected <T> T getService(final Class<T> serviceClass) {
- return SyncopeEnduserSession.get().getService(serviceClass);
- }
-
- protected <T> T getService(final String etag, final Class<T> serviceClass) {
- return SyncopeEnduserSession.get().getService(etag, serviceClass);
- }
-
- protected <T> void resetClient(final Class<T> serviceClass) {
- SyncopeEnduserSession.get().resetClient(serviceClass);
- }
-
- protected boolean isSelfRegistrationAllowed() {
+ protected final boolean isSelfRegistrationAllowed() {
Boolean result = null;
try {
result = SyncopeEnduserSession.get().getSyncopeTO().isSelfRegAllowed();
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SchemaResource.java
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SchemaResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SchemaResource.java
index 501a32f..3cf3fc0 100644
--- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SchemaResource.java
+++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SchemaResource.java
@@ -21,6 +21,7 @@ package org.apache.syncope.client.enduser.resources;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import org.apache.syncope.client.enduser.SyncopeEnduserSession;
import org.apache.syncope.client.enduser.model.SchemaResponse;
import org.apache.syncope.common.lib.to.AbstractSchemaTO;
import org.apache.syncope.common.lib.to.AnyTypeTO;
@@ -29,6 +30,7 @@ import org.apache.syncope.common.lib.to.PlainSchemaTO;
import org.apache.syncope.common.lib.to.VirSchemaTO;
import org.apache.syncope.common.lib.types.AnyTypeKind;
import org.apache.syncope.common.lib.types.SchemaType;
+import org.apache.syncope.common.rest.api.beans.SchemaQuery;
import org.apache.syncope.common.rest.api.service.AnyTypeClassService;
import org.apache.syncope.common.rest.api.service.AnyTypeService;
import org.apache.syncope.common.rest.api.service.SchemaService;
@@ -51,9 +53,9 @@ public class SchemaResource extends AbstractBaseResource {
private final SchemaService schemaService;
public SchemaResource() {
- anyTypeService = getService(AnyTypeService.class);
- anyTypeClassService = getService(AnyTypeClassService.class);
- schemaService = getService(SchemaService.class);
+ anyTypeService = SyncopeEnduserSession.get().getService(AnyTypeService.class);
+ anyTypeClassService = SyncopeEnduserSession.get().getService(AnyTypeClassService.class);
+ schemaService = SyncopeEnduserSession.get().getService(SchemaService.class);
}
@Override
@@ -66,22 +68,14 @@ public class SchemaResource extends AbstractBaseResource {
int responseStatus = 200;
try {
-
final AnyTypeTO anyTypeUserTO = anyTypeService.read(AnyTypeKind.USER.name());
- final List<PlainSchemaTO> plainSchemas = new ArrayList<>();
- final List<DerSchemaTO> derSchemas = new ArrayList<>();
- final List<VirSchemaTO> virSchemas = new ArrayList<>();
-
- // read all USER type schemas
- for (String clazz : anyTypeUserTO.getClasses()) {
- plainSchemas.addAll(getSchemaTOs(anyTypeClassService.read(clazz).getPlainSchemas(), SchemaType.PLAIN,
- PlainSchemaTO.class));
- derSchemas.addAll(getSchemaTOs(anyTypeClassService.read(clazz).getDerSchemas(), SchemaType.DERIVED,
- DerSchemaTO.class));
- virSchemas.addAll(getSchemaTOs(anyTypeClassService.read(clazz).getVirSchemas(), SchemaType.VIRTUAL,
- VirSchemaTO.class));
- }
+ final List<PlainSchemaTO> plainSchemas = schemaService.list(
+ SchemaType.PLAIN, new SchemaQuery.Builder().anyTypeClasses(anyTypeUserTO.getClasses()).build());
+ final List<DerSchemaTO> derSchemas = schemaService.list(
+ SchemaType.DERIVED, new SchemaQuery.Builder().anyTypeClasses(anyTypeUserTO.getClasses()).build());
+ final List<VirSchemaTO> virSchemas = schemaService.list(
+ SchemaType.VIRTUAL, new SchemaQuery.Builder().anyTypeClasses(anyTypeUserTO.getClasses()).build());
response.setWriteCallback(new AbstractResource.WriteCallback() {
@@ -93,7 +87,6 @@ public class SchemaResource extends AbstractBaseResource {
virSchemas(virSchemas)));
}
});
-
} catch (Exception e) {
LOG.error("Error retrieving {} any type kind related schemas", AnyTypeKind.USER.name(), e);
responseStatus = 400;
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SecurityQuestionResource.java
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SecurityQuestionResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SecurityQuestionResource.java
index f31cba5..60ab318 100644
--- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SecurityQuestionResource.java
+++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SecurityQuestionResource.java
@@ -20,6 +20,7 @@ package org.apache.syncope.client.enduser.resources;
import java.io.IOException;
import java.util.List;
+import org.apache.syncope.client.enduser.SyncopeEnduserSession;
import org.apache.syncope.common.lib.to.SecurityQuestionTO;
import org.apache.syncope.common.rest.api.service.SecurityQuestionService;
import org.apache.syncope.core.misc.serialization.POJOHelper;
@@ -37,7 +38,7 @@ public class SecurityQuestionResource extends AbstractBaseResource {
private final SecurityQuestionService securityQuestionService;
public SecurityQuestionResource() {
- securityQuestionService = getService(SecurityQuestionService.class);
+ securityQuestionService = SyncopeEnduserSession.get().getService(SecurityQuestionService.class);
}
@Override
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfCreateResource.java
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfCreateResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfCreateResource.java
index 7e9341b..02297fb 100644
--- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfCreateResource.java
+++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfCreateResource.java
@@ -20,6 +20,7 @@ package org.apache.syncope.client.enduser.resources;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
+import org.apache.syncope.client.enduser.SyncopeEnduserSession;
import org.apache.syncope.client.enduser.adapters.UserTOAdapter;
import org.apache.syncope.client.enduser.model.UserTORequest;
import org.apache.syncope.common.rest.api.service.UserSelfService;
@@ -40,7 +41,7 @@ public class UserSelfCreateResource extends AbstractBaseResource {
public UserSelfCreateResource() {
userTOAdapter = new UserTOAdapter();
- userSelfService = getService(UserSelfService.class);
+ userSelfService = SyncopeEnduserSession.get().getService(UserSelfService.class);
}
@Override
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfUpdateResource.java
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfUpdateResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfUpdateResource.java
index 2d72d69..4e2d90a 100644
--- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfUpdateResource.java
+++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/UserSelfUpdateResource.java
@@ -43,7 +43,7 @@ public class UserSelfUpdateResource extends AbstractBaseResource {
public UserSelfUpdateResource() {
userTOAdapter = new UserTOAdapter();
- userSelfService = getService(UserSelfService.class);
+ userSelfService = SyncopeEnduserSession.get().getService(UserSelfService.class);
}
@Override
@@ -69,7 +69,7 @@ public class UserSelfUpdateResource extends AbstractBaseResource {
// update user
Response res = userSelfService.update(userTO);
responseStatus = res.getStatus();
-
+
responseMessage = "User updated successfully";
response.setWriteCallback(new WriteCallback() {
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClient.java
----------------------------------------------------------------------
diff --git a/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClient.java b/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClient.java
index 905fb4c..198b585 100644
--- a/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClient.java
+++ b/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClient.java
@@ -30,11 +30,6 @@ import javax.ws.rs.core.Response;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.syncope.client.lib.builders.AnyQueryBuilder;
-import org.apache.syncope.client.lib.builders.AnyListQueryBuilder;
-import org.apache.syncope.client.lib.builders.AnySearchQueryBuilder;
-import org.apache.syncope.client.lib.builders.ConnObjectTOListQueryBuilder;
-import org.apache.syncope.client.lib.builders.TaskQueryBuilder;
import org.apache.syncope.common.lib.search.AnyObjectFiqlSearchConditionBuilder;
import org.apache.syncope.common.lib.search.OrderByClauseBuilder;
import org.apache.syncope.common.lib.search.GroupFiqlSearchConditionBuilder;
@@ -114,56 +109,6 @@ public class SyncopeClient {
}
/**
- * Returns a new instance of {@link TaskQueryBuilder}, for assisted building of some service's {@code list()}
- * arguments.
- *
- * @return default instance of {@link AnyQueryBuilder}
- */
- public static TaskQueryBuilder getTaskQueryBuilder() {
- return new TaskQueryBuilder();
- }
-
- /**
- * Returns a new instance of {@link AnyQueryBuilder}, for assisted building of some service's {@code list()}
- * arguments.
- *
- * @return default instance of {@link AnyQueryBuilder}
- */
- public static AnyQueryBuilder getAnyQueryBuilder() {
- return new AnyQueryBuilder();
- }
-
- /**
- * Returns a new instance of {@link AnyListQueryBuilder}, for assisted building of some service's {@code list()}
- * arguments.
- *
- * @return default instance of {@link AnyListQueryBuilder}
- */
- public static AnyListQueryBuilder getAnyListQueryBuilder() {
- return new AnyListQueryBuilder();
- }
-
- /**
- * Returns a new instance of {@link AnySearchQueryBuilder}, for assisted building of some service's
- * {@code search()} arguments.
- *
- * @return default instance of {@link AnySearchQueryBuilder}
- */
- public static AnySearchQueryBuilder getAnySearchQueryBuilder() {
- return new AnySearchQueryBuilder();
- }
-
- /**
- * Returns a new instance of {@link ConnObjectTOListQueryBuilder}, for assisted building of some service's
- * {@code list()} arguments.
- *
- * @return default instance of {@link ConnObjectTOListQueryBuilder}
- */
- public static ConnObjectTOListQueryBuilder getConnObjectTOListQueryBuilder() {
- return new ConnObjectTOListQueryBuilder();
- }
-
- /**
* Creates an instance of the given service class, with configured content type and authentication.
*
* @param <T> any service class
@@ -196,7 +141,7 @@ public class SyncopeClient {
(Map<String, Set<String>>) new ObjectMapper().readValue(
response.getHeaderString(RESTHeaders.OWNED_ENTITLEMENTS),
new TypeReference<HashMap<String, Set<String>>>() {
- }),
+ }),
response.readEntity(UserTO.class));
} catch (IOException e) {
throw new IllegalStateException(e);
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/lib/src/main/java/org/apache/syncope/client/lib/builders/AbstractQueryBuilder.java
----------------------------------------------------------------------
diff --git a/client/lib/src/main/java/org/apache/syncope/client/lib/builders/AbstractQueryBuilder.java b/client/lib/src/main/java/org/apache/syncope/client/lib/builders/AbstractQueryBuilder.java
deleted file mode 100644
index 4c61554..0000000
--- a/client/lib/src/main/java/org/apache/syncope/client/lib/builders/AbstractQueryBuilder.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.client.lib.builders;
-
-import org.apache.syncope.common.rest.api.beans.AbstractQuery;
-
-public abstract class AbstractQueryBuilder<Q extends AbstractQuery, B extends AbstractQueryBuilder<Q, B>> {
-
- private Q instance;
-
- protected abstract Q newInstance();
-
- protected Q getInstance() {
- if (instance == null) {
- instance = newInstance();
- }
- return instance;
- }
-
- @SuppressWarnings("unchecked")
- public B page(final Integer page) {
- getInstance().setPage(page);
- return (B) this;
- }
-
- @SuppressWarnings("unchecked")
- public B size(final Integer size) {
- getInstance().setSize(size);
- return (B) this;
- }
-
- @SuppressWarnings("unchecked")
- public B orderBy(final String orderBy) {
- getInstance().setOrderBy(orderBy);
- return (B) this;
- }
-
- public Q build() {
- return getInstance();
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/lib/src/main/java/org/apache/syncope/client/lib/builders/AnyListQueryBuilder.java
----------------------------------------------------------------------
diff --git a/client/lib/src/main/java/org/apache/syncope/client/lib/builders/AnyListQueryBuilder.java b/client/lib/src/main/java/org/apache/syncope/client/lib/builders/AnyListQueryBuilder.java
deleted file mode 100644
index da069cc..0000000
--- a/client/lib/src/main/java/org/apache/syncope/client/lib/builders/AnyListQueryBuilder.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.client.lib.builders;
-
-import java.util.ArrayList;
-import org.apache.syncope.common.rest.api.beans.AnyQuery;
-import org.apache.syncope.common.rest.api.beans.AnyListQuery;
-
-public class AnyListQueryBuilder extends AnyQueryBuilder {
-
- private final AnyListQuery instance = new AnyListQuery();
-
- @Override
- public AnyListQueryBuilder page(final Integer page) {
- return AnyListQueryBuilder.class.cast(super.page(page));
- }
-
- @Override
- public AnyListQueryBuilder size(final Integer size) {
- return AnyListQueryBuilder.class.cast(super.size(size));
- }
-
- @Override
- public AnyListQueryBuilder orderBy(final String orderBy) {
- return AnyListQueryBuilder.class.cast(super.orderBy(orderBy));
- }
-
- @Override
- public AnyListQueryBuilder details(final boolean details) {
- return AnyListQueryBuilder.class.cast(super.details(details));
- }
-
- public AnyListQueryBuilder realm(final String realm) {
- if (instance.getRealms() == null) {
- instance.setRealms(new ArrayList<String>());
- }
- instance.getRealms().add(realm);
-
- return this;
- }
-
- @Override
- public AnyListQuery build() {
- AnyQuery lq = super.build();
- instance.setPage(lq.getPage());
- instance.setSize(lq.getSize());
- instance.setOrderBy(lq.getOrderBy());
- instance.setDetails(lq.isDetails());
-
- return instance;
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/lib/src/main/java/org/apache/syncope/client/lib/builders/AnyQueryBuilder.java
----------------------------------------------------------------------
diff --git a/client/lib/src/main/java/org/apache/syncope/client/lib/builders/AnyQueryBuilder.java b/client/lib/src/main/java/org/apache/syncope/client/lib/builders/AnyQueryBuilder.java
deleted file mode 100644
index ad5457e..0000000
--- a/client/lib/src/main/java/org/apache/syncope/client/lib/builders/AnyQueryBuilder.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.client.lib.builders;
-
-import org.apache.syncope.common.rest.api.beans.AnyQuery;
-
-public class AnyQueryBuilder extends AbstractQueryBuilder<AnyQuery, AnyQueryBuilder> {
-
- @Override
- protected AnyQuery newInstance() {
- return new AnyQuery();
- }
-
- @Override
- public AnyQueryBuilder page(final Integer page) {
- return AnyQueryBuilder.class.cast(super.page(page));
- }
-
- @Override
- public AnyQueryBuilder size(final Integer size) {
- return AnyQueryBuilder.class.cast(super.size(size));
- }
-
- @Override
- public AnyQueryBuilder orderBy(final String orderBy) {
- return AnyQueryBuilder.class.cast(super.orderBy(orderBy));
- }
-
- public AnyQueryBuilder details(final boolean details) {
- getInstance().setDetails(details);
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/lib/src/main/java/org/apache/syncope/client/lib/builders/AnySearchQueryBuilder.java
----------------------------------------------------------------------
diff --git a/client/lib/src/main/java/org/apache/syncope/client/lib/builders/AnySearchQueryBuilder.java b/client/lib/src/main/java/org/apache/syncope/client/lib/builders/AnySearchQueryBuilder.java
deleted file mode 100644
index 5bffdcc..0000000
--- a/client/lib/src/main/java/org/apache/syncope/client/lib/builders/AnySearchQueryBuilder.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.client.lib.builders;
-
-import org.apache.syncope.common.rest.api.beans.AnyListQuery;
-import org.apache.syncope.common.rest.api.beans.AnySearchQuery;
-
-public class AnySearchQueryBuilder extends AnyListQueryBuilder {
-
- private final AnySearchQuery instance = new AnySearchQuery();
-
- @Override
- public AnySearchQueryBuilder realm(final String realm) {
- return AnySearchQueryBuilder.class.cast(super.realm(realm));
- }
-
- @Override
- public AnySearchQueryBuilder page(final Integer page) {
- return AnySearchQueryBuilder.class.cast(super.page(page));
- }
-
- @Override
- public AnySearchQueryBuilder size(final Integer size) {
- return AnySearchQueryBuilder.class.cast(super.size(size));
- }
-
- @Override
- public AnySearchQueryBuilder orderBy(final String orderBy) {
- return AnySearchQueryBuilder.class.cast(super.orderBy(orderBy));
- }
-
- @Override
- public AnySearchQueryBuilder details(final boolean details) {
- return AnySearchQueryBuilder.class.cast(super.details(details));
- }
-
- public AnySearchQueryBuilder fiql(final String fiql) {
- instance.setFiql(fiql);
-
- return this;
- }
-
- @Override
- public AnySearchQuery build() {
- AnyListQuery slq = super.build();
- instance.setRealms(slq.getRealms());
- instance.setPage(slq.getPage());
- instance.setSize(slq.getSize());
- instance.setOrderBy(slq.getOrderBy());
- instance.setDetails(slq.isDetails());
-
- return instance;
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/lib/src/main/java/org/apache/syncope/client/lib/builders/ConnObjectTOListQueryBuilder.java
----------------------------------------------------------------------
diff --git a/client/lib/src/main/java/org/apache/syncope/client/lib/builders/ConnObjectTOListQueryBuilder.java b/client/lib/src/main/java/org/apache/syncope/client/lib/builders/ConnObjectTOListQueryBuilder.java
deleted file mode 100644
index 619f391..0000000
--- a/client/lib/src/main/java/org/apache/syncope/client/lib/builders/ConnObjectTOListQueryBuilder.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.client.lib.builders;
-
-import org.apache.syncope.common.rest.api.beans.ConnObjectTOListQuery;
-
-public class ConnObjectTOListQueryBuilder {
-
- private final ConnObjectTOListQuery instance = new ConnObjectTOListQuery();
-
- public ConnObjectTOListQueryBuilder size(final Integer size) {
- instance.setSize(size);
-
- return this;
- }
-
- public ConnObjectTOListQueryBuilder pagedResultsCookie(final String pagedResultsCookie) {
- instance.setPagedResultsCookie(pagedResultsCookie);
-
- return this;
- }
-
- public ConnObjectTOListQueryBuilder orderBy(final String orderBy) {
- instance.setOrderBy(orderBy);
-
- return this;
- }
-
- public ConnObjectTOListQuery build() {
- return instance;
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/client/lib/src/main/java/org/apache/syncope/client/lib/builders/TaskQueryBuilder.java
----------------------------------------------------------------------
diff --git a/client/lib/src/main/java/org/apache/syncope/client/lib/builders/TaskQueryBuilder.java b/client/lib/src/main/java/org/apache/syncope/client/lib/builders/TaskQueryBuilder.java
deleted file mode 100644
index c87b68c..0000000
--- a/client/lib/src/main/java/org/apache/syncope/client/lib/builders/TaskQueryBuilder.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.client.lib.builders;
-
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.rest.api.beans.TaskQuery;
-
-public class TaskQueryBuilder extends AbstractQueryBuilder<TaskQuery, TaskQueryBuilder> {
-
- @Override
- protected TaskQuery newInstance() {
- return new TaskQuery();
- }
-
- @Override
- public TaskQueryBuilder page(final Integer page) {
- return TaskQueryBuilder.class.cast(super.page(page));
- }
-
- @Override
- public TaskQueryBuilder size(final Integer size) {
- return TaskQueryBuilder.class.cast(super.size(size));
- }
-
- @Override
- public TaskQueryBuilder orderBy(final String orderBy) {
- return TaskQueryBuilder.class.cast(super.orderBy(orderBy));
- }
-
- public TaskQueryBuilder resource(final String resource) {
- getInstance().setResource(resource);
- return this;
- }
-
- public TaskQueryBuilder anyTypeKind(final AnyTypeKind anyTypeKind) {
- getInstance().setAnyTypeKind(anyTypeKind);
- return this;
- }
-
- public TaskQueryBuilder anyTypeKey(final Long anyTypeKey) {
- getInstance().setAnyTypeKey(anyTypeKey);
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java b/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java
index f7cd2e8..1a36c4f 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java
@@ -35,7 +35,6 @@ import org.apache.syncope.common.lib.patch.PasswordPatch;
import org.apache.syncope.common.lib.patch.RelationshipPatch;
import org.apache.syncope.common.lib.patch.AbstractReplacePatchItem;
import org.apache.syncope.common.lib.patch.BooleanReplacePatchItem;
-import org.apache.syncope.common.lib.patch.LongPatchItem;
import org.apache.syncope.common.lib.patch.LongReplacePatchItem;
import org.apache.syncope.common.lib.patch.StringPatchItem;
import org.apache.syncope.common.lib.patch.StringReplacePatchItem;
@@ -110,14 +109,14 @@ public final class AnyOperations {
CollectionUtils.forAllDo(CollectionUtils.subtract(originalAttrs.keySet(), updatedAttrs.keySet()),
new Closure<String>() {
- @Override
- public void execute(final String schema) {
- result.getPlainAttrs().add(new AttrPatch.Builder().
- operation(PatchOperation.DELETE).
- attrTO(new AttrTO.Builder().schema(schema).build()).
- build());
- }
- });
+ @Override
+ public void execute(final String schema) {
+ result.getPlainAttrs().add(new AttrPatch.Builder().
+ operation(PatchOperation.DELETE).
+ attrTO(new AttrTO.Builder().schema(schema).build()).
+ build());
+ }
+ });
}
for (AttrTO attrTO : updatedAttrs.values()) {
@@ -254,15 +253,15 @@ public final class AnyOperations {
// 4. roles
if (!incremental) {
- for (Long toRemove : CollectionUtils.subtract(original.getRoles(), updated.getRoles())) {
+ for (String toRemove : CollectionUtils.subtract(original.getRoles(), updated.getRoles())) {
result.getRoles().add(
- new LongPatchItem.Builder().operation(PatchOperation.DELETE).value(toRemove).build());
+ new StringPatchItem.Builder().operation(PatchOperation.DELETE).value(toRemove).build());
}
}
- for (Long toAdd : CollectionUtils.subtract(updated.getRoles(), original.getRoles())) {
+ for (String toAdd : CollectionUtils.subtract(updated.getRoles(), original.getRoles())) {
result.getRoles().add(
- new LongPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(toAdd).build());
+ new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(toAdd).build());
}
// 5. relationships
@@ -522,7 +521,7 @@ public final class AnyOperations {
}
// 5. roles
- for (LongPatchItem rolePatch : userPatch.getRoles()) {
+ for (StringPatchItem rolePatch : userPatch.getRoles()) {
switch (rolePatch.getOperation()) {
case ADD_REPLACE:
result.getRoles().add(rolePatch.getValue());
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/common/lib/src/main/java/org/apache/syncope/common/lib/patch/UserPatch.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/UserPatch.java b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/UserPatch.java
index 9131abd..3f4e9eb 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/patch/UserPatch.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/patch/UserPatch.java
@@ -46,7 +46,7 @@ public class UserPatch extends AnyPatch {
private final Set<MembershipPatch> memberships = new HashSet<>();
- private final Set<LongPatchItem> roles = new HashSet<>();
+ private final Set<StringPatchItem> roles = new HashSet<>();
public StringReplacePatchItem getUsername() {
return username;
@@ -105,7 +105,7 @@ public class UserPatch extends AnyPatch {
@XmlElementWrapper(name = "roles")
@XmlElement(name = "role")
@JsonProperty("roles")
- public Set<LongPatchItem> getRoles() {
+ public Set<StringPatchItem> getRoles() {
return roles;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserFiqlSearchConditionBuilder.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserFiqlSearchConditionBuilder.java b/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserFiqlSearchConditionBuilder.java
index 802694e..323e38b 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserFiqlSearchConditionBuilder.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserFiqlSearchConditionBuilder.java
@@ -50,7 +50,7 @@ public class UserFiqlSearchConditionBuilder extends AbstractFiqlSearchConditionB
return newBuilderInstance().is(SpecialAttr.GROUPS.toString()).inGroups(group, moreGroups);
}
- public CompleteCondition inRoles(final Long role, final Long... moreRoles) {
+ public CompleteCondition inRoles(final String role, final String... moreRoles) {
return newBuilderInstance().is(SpecialAttr.ROLES.toString()).inRoles(role, moreRoles);
}
@@ -99,13 +99,13 @@ public class UserFiqlSearchConditionBuilder extends AbstractFiqlSearchConditionB
}
@Override
- public CompleteCondition inRoles(final Long role, final Long... moreRoles) {
+ public CompleteCondition inRoles(final String role, final String... moreRoles) {
this.result = SpecialAttr.ROLES.toString();
return condition(FiqlParser.EQ, role, (Object[]) moreRoles);
}
@Override
- public CompleteCondition notInRoles(final Long role, final Long... moreRoles) {
+ public CompleteCondition notInRoles(final String role, final String... moreRoles) {
this.result = SpecialAttr.ROLES.toString();
return condition(FiqlParser.NEQ, role, (Object[]) moreRoles);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserProperty.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserProperty.java b/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserProperty.java
index 5a659b7..210274c 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserProperty.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/search/UserProperty.java
@@ -26,8 +26,8 @@ public interface UserProperty extends SyncopeProperty {
CompleteCondition notInGroups(Long group, Long... moreGroups);
- CompleteCondition inRoles(Long role, Long... moreRoles);
+ CompleteCondition inRoles(String role, String... moreRoles);
- CompleteCondition notInRoles(Long role, Long... moreRoles);
+ CompleteCondition notInRoles(String role, String... moreRoles);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/common/lib/src/main/java/org/apache/syncope/common/lib/to/RoleTO.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/RoleTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/RoleTO.java
index fab8a06..7160fdc 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/to/RoleTO.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/RoleTO.java
@@ -36,9 +36,7 @@ public class RoleTO extends AbstractBaseBean {
private static final long serialVersionUID = 4560822655754800031L;
- private long key;
-
- private String name;
+ private String key;
private final Set<String> entitlements = new HashSet<>();
@@ -46,23 +44,15 @@ public class RoleTO extends AbstractBaseBean {
private String dynMembershipCond;
- public long getKey() {
+ public String getKey() {
return key;
}
@PathParam("key")
- public void setKey(final long key) {
+ public void setKey(final String key) {
this.key = key;
}
- public String getName() {
- return name;
- }
-
- public void setName(final String name) {
- this.name = name;
- }
-
@XmlElementWrapper(name = "entitlements")
@XmlElement(name = "entitlement")
@JsonProperty("entitlements")
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/common/lib/src/main/java/org/apache/syncope/common/lib/to/UserTO.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/UserTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/UserTO.java
index 7018cd5..e18d8bc 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/to/UserTO.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/UserTO.java
@@ -43,9 +43,9 @@ public class UserTO extends AnyTO {
private String password;
- private final List<Long> roles = new ArrayList<>();
+ private final List<String> roles = new ArrayList<>();
- private final List<Long> dynRoles = new ArrayList<>();
+ private final List<String> dynRoles = new ArrayList<>();
private String token;
@@ -92,14 +92,14 @@ public class UserTO extends AnyTO {
@XmlElementWrapper(name = "roles")
@XmlElement(name = "role")
@JsonProperty("roles")
- public List<Long> getRoles() {
+ public List<String> getRoles() {
return roles;
}
@XmlElementWrapper(name = "dynRoles")
@XmlElement(name = "role")
@JsonProperty("dynRoles")
- public List<Long> getDynRoles() {
+ public List<String> getDynRoles() {
return dynRoles;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/common/lib/src/test/java/org/apache/syncope/common/lib/JSONTest.java
----------------------------------------------------------------------
diff --git a/common/lib/src/test/java/org/apache/syncope/common/lib/JSONTest.java b/common/lib/src/test/java/org/apache/syncope/common/lib/JSONTest.java
index e0f8093..4eeaf8f 100644
--- a/common/lib/src/test/java/org/apache/syncope/common/lib/JSONTest.java
+++ b/common/lib/src/test/java/org/apache/syncope/common/lib/JSONTest.java
@@ -25,7 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.io.StringWriter;
import org.apache.syncope.common.lib.patch.PasswordPatch;
-import org.apache.syncope.common.lib.patch.LongPatchItem;
+import org.apache.syncope.common.lib.patch.StringPatchItem;
import org.apache.syncope.common.lib.patch.StringReplacePatchItem;
import org.apache.syncope.common.lib.patch.UserPatch;
import org.apache.syncope.common.lib.report.UserReportletConf;
@@ -79,7 +79,7 @@ public class JSONTest {
value("newpassword").
build());
assertNotNull(patch.getPassword().getValue());
- patch.getRoles().add(new LongPatchItem.Builder().operation(PatchOperation.DELETE).value(7L).build());
+ patch.getRoles().add(new StringPatchItem.Builder().operation(PatchOperation.DELETE).value("role").build());
ObjectMapper mapper = new ObjectMapper();
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AbstractQuery.java
----------------------------------------------------------------------
diff --git a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AbstractQuery.java b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AbstractQuery.java
index a8c6bb8..eb37f52 100644
--- a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AbstractQuery.java
+++ b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AbstractQuery.java
@@ -28,6 +28,42 @@ public abstract class AbstractQuery extends AbstractBaseBean {
private static final long serialVersionUID = -371488230250055359L;
+ protected abstract static class Builder<Q extends AbstractQuery, B extends Builder<Q, B>> {
+
+ private Q instance;
+
+ protected abstract Q newInstance();
+
+ protected Q getInstance() {
+ if (instance == null) {
+ instance = newInstance();
+ }
+ return instance;
+ }
+
+ @SuppressWarnings("unchecked")
+ public B page(final Integer page) {
+ getInstance().setPage(page);
+ return (B) this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public B size(final Integer size) {
+ getInstance().setSize(size);
+ return (B) this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public B orderBy(final String orderBy) {
+ getInstance().setOrderBy(orderBy);
+ return (B) this;
+ }
+
+ public Q build() {
+ return getInstance();
+ }
+ }
+
private Integer page;
private Integer size;
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AnyListQuery.java
----------------------------------------------------------------------
diff --git a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AnyListQuery.java b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AnyListQuery.java
index ef9b93d..a763c21 100644
--- a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AnyListQuery.java
+++ b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AnyListQuery.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.common.rest.api.beans;
+import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.MatrixParam;
@@ -27,6 +28,28 @@ public class AnyListQuery extends AnyQuery {
private static final long serialVersionUID = -5197167078435619636L;
+ public static class Builder extends AbstractQuery.Builder<AnyListQuery, Builder> {
+
+ @Override
+ protected AnyListQuery newInstance() {
+ return new AnyListQuery();
+ }
+
+ public Builder details(final boolean details) {
+ getInstance().setDetails(details);
+ return this;
+ }
+
+ public Builder realm(final String realm) {
+ if (getInstance().getRealms() == null) {
+ getInstance().setRealms(new ArrayList<String>());
+ }
+ getInstance().getRealms().add(realm);
+
+ return this;
+ }
+ }
+
private List<String> realms;
public List<String> getRealms() {
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AnyQuery.java
----------------------------------------------------------------------
diff --git a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AnyQuery.java b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AnyQuery.java
index bcf10ce..d369ee2 100644
--- a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AnyQuery.java
+++ b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AnyQuery.java
@@ -26,6 +26,20 @@ public class AnyQuery extends AbstractQuery {
private static final long serialVersionUID = -371488230250055359L;
+ public static class Builder extends AbstractQuery.Builder<AnyQuery, Builder> {
+
+ @Override
+ protected AnyQuery newInstance() {
+ return new AnyQuery();
+ }
+
+ public Builder details(final boolean details) {
+ getInstance().setDetails(details);
+ return this;
+ }
+
+ }
+
private Boolean details;
public boolean isDetails() {
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AnySearchQuery.java
----------------------------------------------------------------------
diff --git a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AnySearchQuery.java b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AnySearchQuery.java
index 3e0a516..dca93cf 100644
--- a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AnySearchQuery.java
+++ b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/AnySearchQuery.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.common.rest.api.beans;
+import java.util.ArrayList;
import javax.ws.rs.QueryParam;
import org.apache.syncope.common.rest.api.service.JAXRSService;
@@ -25,6 +26,34 @@ public class AnySearchQuery extends AnyListQuery {
private static final long serialVersionUID = -6736562952418964707L;
+ public static class Builder extends AbstractQuery.Builder<AnySearchQuery, Builder> {
+
+ @Override
+ protected AnySearchQuery newInstance() {
+ return new AnySearchQuery();
+ }
+
+ public Builder details(final boolean details) {
+ getInstance().setDetails(details);
+ return this;
+ }
+
+ public Builder realm(final String realm) {
+ if (getInstance().getRealms() == null) {
+ getInstance().setRealms(new ArrayList<String>());
+ }
+ getInstance().getRealms().add(realm);
+
+ return this;
+ }
+
+ public Builder fiql(final String fiql) {
+ getInstance().setFiql(fiql);
+
+ return this;
+ }
+ }
+
private String fiql;
public String getFiql() {
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/ConnObjectTOListQuery.java
----------------------------------------------------------------------
diff --git a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/ConnObjectTOListQuery.java b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/ConnObjectTOListQuery.java
index 32a7359..53df9fb 100644
--- a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/ConnObjectTOListQuery.java
+++ b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/ConnObjectTOListQuery.java
@@ -32,6 +32,31 @@ public class ConnObjectTOListQuery implements Serializable {
private static final long serialVersionUID = -371488230250055359L;
+ public static class Builder {
+
+ private final ConnObjectTOListQuery instance = new ConnObjectTOListQuery();
+
+ public Builder size(final Integer size) {
+ instance.setSize(size);
+ return this;
+ }
+
+ public Builder pagedResultsCookie(final String pagedResultsCookie) {
+ instance.setPagedResultsCookie(pagedResultsCookie);
+ return this;
+ }
+
+ public Builder orderBy(final String orderBy) {
+ instance.setOrderBy(orderBy);
+ return this;
+ }
+
+ public ConnObjectTOListQuery build() {
+ return instance;
+ }
+
+ }
+
private Integer size;
private String pagedResultsCookie;
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/SchemaQuery.java
----------------------------------------------------------------------
diff --git a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/SchemaQuery.java b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/SchemaQuery.java
new file mode 100644
index 0000000..a96b09f
--- /dev/null
+++ b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/SchemaQuery.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.common.rest.api.beans;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import javax.ws.rs.QueryParam;
+import org.apache.syncope.common.lib.AbstractBaseBean;
+
+public class SchemaQuery extends AbstractBaseBean {
+
+ private static final long serialVersionUID = -1863334226169614417L;
+
+ public static class Builder {
+
+ private final SchemaQuery instance = new SchemaQuery();
+
+ public Builder anyTypeClass(final String anyTypeClass) {
+ if (instance.getAnyTypeClasses() == null) {
+ instance.setAnyTypeClasses(new ArrayList<String>());
+ }
+ instance.getAnyTypeClasses().add(anyTypeClass);
+
+ return this;
+ }
+
+ public Builder anyTypeClasses(final Collection<String> anyTypeClasses) {
+ for (String anyTypeClass : anyTypeClasses) {
+ anyTypeClass(anyTypeClass);
+ }
+ return this;
+ }
+
+ public Builder anyTypeClasses(final String... anyTypeClasses) {
+ return anyTypeClasses(Arrays.asList(anyTypeClasses));
+ }
+
+ public SchemaQuery build() {
+ return instance;
+ }
+ }
+
+ private List<String> anyTypeClasses;
+
+ public List<String> getAnyTypeClasses() {
+ return anyTypeClasses;
+ }
+
+ @QueryParam("anyTypeClass")
+ public void setAnyTypeClasses(final List<String> anyTypeClasses) {
+ this.anyTypeClasses = anyTypeClasses;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/TaskQuery.java
----------------------------------------------------------------------
diff --git a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/TaskQuery.java b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/TaskQuery.java
index 7f59abf..8fe942f 100644
--- a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/TaskQuery.java
+++ b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/TaskQuery.java
@@ -27,6 +27,30 @@ public class TaskQuery extends AbstractQuery {
private static final long serialVersionUID = -8792519310029596796L;
+ public static class Builder extends AbstractQuery.Builder<TaskQuery, Builder> {
+
+ @Override
+ protected TaskQuery newInstance() {
+ return new TaskQuery();
+ }
+
+ public Builder resource(final String resource) {
+ getInstance().setResource(resource);
+ return this;
+ }
+
+ public Builder anyTypeKind(final AnyTypeKind anyTypeKind) {
+ getInstance().setAnyTypeKind(anyTypeKind);
+ return this;
+ }
+
+ public Builder anyTypeKey(final Long anyTypeKey) {
+ getInstance().setAnyTypeKey(anyTypeKey);
+ return this;
+ }
+
+ }
+
private String resource;
private AnyTypeKind anyTypeKind;
[2/3] syncope git commit: Reviewing several client-side builders,
adjusting roles
Posted by il...@apache.org.
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/RoleService.java
----------------------------------------------------------------------
diff --git a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/RoleService.java b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/RoleService.java
index 45628c7..8a9082b 100644
--- a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/RoleService.java
+++ b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/RoleService.java
@@ -56,7 +56,7 @@ public interface RoleService extends JAXRSService {
@GET
@Path("{key}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- RoleTO read(@NotNull @PathParam("key") Long key);
+ RoleTO read(@NotNull @PathParam("key") String key);
/**
* Creates a new role.
@@ -85,5 +85,5 @@ public interface RoleService extends JAXRSService {
*/
@DELETE
@Path("{key}")
- void delete(@NotNull @PathParam("key") Long key);
+ void delete(@NotNull @PathParam("key") String key);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/SchemaService.java
----------------------------------------------------------------------
diff --git a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/SchemaService.java b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/SchemaService.java
index e6ec502..9049f92 100644
--- a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/SchemaService.java
+++ b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/SchemaService.java
@@ -20,6 +20,7 @@ package org.apache.syncope.common.rest.api.service;
import java.util.List;
import javax.validation.constraints.NotNull;
+import javax.ws.rs.BeanParam;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
@@ -28,11 +29,11 @@ import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.syncope.common.lib.to.AbstractSchemaTO;
import org.apache.syncope.common.lib.types.SchemaType;
+import org.apache.syncope.common.rest.api.beans.SchemaQuery;
/**
* REST operations for attribute schemas.
@@ -55,17 +56,18 @@ public interface SchemaService extends JAXRSService {
@NotNull @PathParam("type") SchemaType type, @NotNull @PathParam("key") String key);
/**
- * Returns a list of schemas with matching type, for the given anyTypeClass if provided.
+ * Returns a list of schemas matching type and the given query.
*
* @param <T> actual SchemaTO
* @param type type for schemas to be listed
- * @param anyTypeClass any type class name
+ * @param query query conditions
* @return list of schemas with matching type, for the given anyTypeClass if provided
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- <T extends AbstractSchemaTO> List<T> list(@NotNull @PathParam("type") SchemaType type,
- @QueryParam("anyType") String anyTypeClass);
+ <T extends AbstractSchemaTO> List<T> list(
+ @NotNull @PathParam("type") SchemaType type,
+ @BeanParam SchemaQuery query);
/**
* Creates a new schema.
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeClassLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeClassLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeClassLogic.java
index 6d090dd..daaaf56 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeClassLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeClassLogic.java
@@ -50,7 +50,7 @@ public class AnyTypeClassLogic extends AbstractTransactionalLogic<AnyTypeClassTO
if (anyType == null) {
LOG.error("Could not find anyType '" + key + "'");
- throw new NotFoundException(String.valueOf(key));
+ throw new NotFoundException(key);
}
return binder.getAnyTypeClassTO(anyType);
@@ -77,7 +77,7 @@ public class AnyTypeClassLogic extends AbstractTransactionalLogic<AnyTypeClassTO
AnyTypeClass anyType = anyTypeClassDAO.find(anyTypeClassTO.getKey());
if (anyType == null) {
LOG.error("Could not find anyTypeClass '" + anyTypeClassTO.getKey() + "'");
- throw new NotFoundException(String.valueOf(anyTypeClassTO.getKey()));
+ throw new NotFoundException(anyTypeClassTO.getKey());
}
binder.update(anyType, anyTypeClassTO);
@@ -92,7 +92,7 @@ public class AnyTypeClassLogic extends AbstractTransactionalLogic<AnyTypeClassTO
if (anyTypeClass == null) {
LOG.error("Could not find anyTypeClass '" + key + "'");
- throw new NotFoundException(String.valueOf(key));
+ throw new NotFoundException(key);
}
AnyTypeClassTO deleted = binder.getAnyTypeClassTO(anyTypeClass);
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeLogic.java
index 6e76e60..3116ae8 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/AnyTypeLogic.java
@@ -53,7 +53,7 @@ public class AnyTypeLogic extends AbstractTransactionalLogic<AnyTypeTO> {
if (anyType == null) {
LOG.error("Could not find anyType '" + key + "'");
- throw new NotFoundException(String.valueOf(key));
+ throw new NotFoundException(key);
}
return binder.getAnyTypeTO(anyType);
@@ -82,7 +82,7 @@ public class AnyTypeLogic extends AbstractTransactionalLogic<AnyTypeTO> {
AnyType anyType = anyTypeDAO.find(anyTypeTO.getKey());
if (anyType == null) {
LOG.error("Could not find anyType '" + anyTypeTO.getKey() + "'");
- throw new NotFoundException(String.valueOf(anyTypeTO.getKey()));
+ throw new NotFoundException(anyTypeTO.getKey());
}
EntitlementsHolder.getInstance().removeFor(anyTypeTO.getKey());
@@ -101,7 +101,7 @@ public class AnyTypeLogic extends AbstractTransactionalLogic<AnyTypeTO> {
if (anyType == null) {
LOG.error("Could not find anyType '" + key + "'");
- throw new NotFoundException(String.valueOf(key));
+ throw new NotFoundException(key);
}
AnyTypeTO deleted = binder.getAnyTypeTO(anyType);
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/logic/src/main/java/org/apache/syncope/core/logic/DomainLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/DomainLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/DomainLogic.java
index a1dbfab..cfefdd0 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/DomainLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/DomainLogic.java
@@ -55,7 +55,7 @@ public class DomainLogic extends AbstractTransactionalLogic<DomainTO> {
if (domain == null) {
LOG.error("Could not find domain '" + key + "'");
- throw new NotFoundException(String.valueOf(key));
+ throw new NotFoundException(key);
}
return binder.getDomainTO(domain);
@@ -88,7 +88,7 @@ public class DomainLogic extends AbstractTransactionalLogic<DomainTO> {
Domain domain = domainDAO.find(domainTO.getKey());
if (domain == null) {
LOG.error("Could not find domain '" + domainTO.getKey() + "'");
- throw new NotFoundException(String.valueOf(domainTO.getKey()));
+ throw new NotFoundException(domainTO.getKey());
}
binder.update(domain, domainTO);
@@ -104,7 +104,7 @@ public class DomainLogic extends AbstractTransactionalLogic<DomainTO> {
if (domain == null) {
LOG.error("Could not find domain '" + key + "'");
- throw new NotFoundException(String.valueOf(key));
+ throw new NotFoundException(key);
}
DomainTO deleted = binder.getDomainTO(domain);
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/logic/src/main/java/org/apache/syncope/core/logic/NotificationLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/NotificationLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/NotificationLogic.java
index fc4c8ac..da2c13e 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/NotificationLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/NotificationLogic.java
@@ -44,12 +44,12 @@ public class NotificationLogic extends AbstractTransactionalLogic<NotificationTO
private NotificationDataBinder binder;
@PreAuthorize("hasRole('" + StandardEntitlement.NOTIFICATION_READ + "')")
- public NotificationTO read(final Long notificationKey) {
- Notification notification = notificationDAO.find(notificationKey);
+ public NotificationTO read(final Long key) {
+ Notification notification = notificationDAO.find(key);
if (notification == null) {
- LOG.error("Could not find notification '" + notificationKey + "'");
+ LOG.error("Could not find notification '" + key + "'");
- throw new NotFoundException(String.valueOf(notificationKey));
+ throw new NotFoundException(String.valueOf(key));
}
return binder.getNotificationTO(notification);
@@ -86,16 +86,16 @@ public class NotificationLogic extends AbstractTransactionalLogic<NotificationTO
}
@PreAuthorize("hasRole('" + StandardEntitlement.NOTIFICATION_DELETE + "')")
- public NotificationTO delete(final Long notificationKey) {
- Notification notification = notificationDAO.find(notificationKey);
+ public NotificationTO delete(final Long key) {
+ Notification notification = notificationDAO.find(key);
if (notification == null) {
- LOG.error("Could not find notification '" + notificationKey + "'");
+ LOG.error("Could not find notification '" + key + "'");
- throw new NotFoundException(String.valueOf(notificationKey));
+ throw new NotFoundException(String.valueOf(key));
}
NotificationTO deleted = binder.getNotificationTO(notification);
- notificationDAO.delete(notificationKey);
+ notificationDAO.delete(key);
return deleted;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/logic/src/main/java/org/apache/syncope/core/logic/RelationshipTypeLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/RelationshipTypeLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/RelationshipTypeLogic.java
index 3c6bfa6..6d96e8b 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/RelationshipTypeLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/RelationshipTypeLogic.java
@@ -50,7 +50,7 @@ public class RelationshipTypeLogic extends AbstractTransactionalLogic<Relationsh
if (relationshipType == null) {
LOG.error("Could not find relationshipType '" + key + "'");
- throw new NotFoundException(String.valueOf(key));
+ throw new NotFoundException(key);
}
return binder.getRelationshipTypeTO(relationshipType);
@@ -78,7 +78,7 @@ public class RelationshipTypeLogic extends AbstractTransactionalLogic<Relationsh
RelationshipType relationshipType = relationshipTypeDAO.find(relationshipTypeTO.getKey());
if (relationshipType == null) {
LOG.error("Could not find relationshipType '" + relationshipTypeTO.getKey() + "'");
- throw new NotFoundException(String.valueOf(relationshipTypeTO.getKey()));
+ throw new NotFoundException(relationshipTypeTO.getKey());
}
binder.update(relationshipType, relationshipTypeTO);
@@ -93,7 +93,7 @@ public class RelationshipTypeLogic extends AbstractTransactionalLogic<Relationsh
if (relationshipType == null) {
LOG.error("Could not find relationshipType '" + key + "'");
- throw new NotFoundException(String.valueOf(key));
+ throw new NotFoundException(key);
}
RelationshipTypeTO deleted = binder.getRelationshipTypeTO(relationshipType);
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/logic/src/main/java/org/apache/syncope/core/logic/RoleLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/RoleLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/RoleLogic.java
index 60f65a0..92cb880 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/RoleLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/RoleLogic.java
@@ -44,12 +44,12 @@ public class RoleLogic extends AbstractTransactionalLogic<RoleTO> {
private RoleDAO roleDAO;
@PreAuthorize("hasRole('" + StandardEntitlement.ROLE_READ + "')")
- public RoleTO read(final Long roleKey) {
- Role role = roleDAO.find(roleKey);
+ public RoleTO read(final String key) {
+ Role role = roleDAO.find(key);
if (role == null) {
- LOG.error("Could not find role '" + roleKey + "'");
+ LOG.error("Could not find role '" + key + "'");
- throw new NotFoundException(String.valueOf(roleKey));
+ throw new NotFoundException(key);
}
return binder.getRoleTO(role);
@@ -76,7 +76,7 @@ public class RoleLogic extends AbstractTransactionalLogic<RoleTO> {
Role role = roleDAO.find(roleTO.getKey());
if (role == null) {
LOG.error("Could not find role '" + roleTO.getKey() + "'");
- throw new NotFoundException(String.valueOf(roleTO.getKey()));
+ throw new NotFoundException(roleTO.getKey());
}
binder.update(role, roleTO);
@@ -86,16 +86,16 @@ public class RoleLogic extends AbstractTransactionalLogic<RoleTO> {
}
@PreAuthorize("hasRole('" + StandardEntitlement.ROLE_DELETE + "')")
- public RoleTO delete(final Long roleKey) {
- Role role = roleDAO.find(roleKey);
+ public RoleTO delete(final String key) {
+ Role role = roleDAO.find(key);
if (role == null) {
- LOG.error("Could not find role '" + roleKey + "'");
+ LOG.error("Could not find role '" + key + "'");
- throw new NotFoundException(String.valueOf(roleKey));
+ throw new NotFoundException(key);
}
RoleTO deleted = binder.getRoleTO(role);
- roleDAO.delete(roleKey);
+ roleDAO.delete(key);
return deleted;
}
@@ -103,12 +103,12 @@ public class RoleLogic extends AbstractTransactionalLogic<RoleTO> {
protected RoleTO resolveReference(final Method method, final Object... args)
throws UnresolvedReferenceException {
- Long key = null;
+ String key = null;
if (ArrayUtils.isNotEmpty(args)) {
for (int i = 0; key == null && i < args.length; i++) {
- if (args[i] instanceof Long) {
- key = (Long) args[i];
+ if (args[i] instanceof String) {
+ key = (String) args[i];
} else if (args[i] instanceof RoleTO) {
key = ((RoleTO) args[i]).getKey();
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/logic/src/main/java/org/apache/syncope/core/logic/SchemaLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/SchemaLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/SchemaLogic.java
index a57f2e1..1e94c96 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/SchemaLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/SchemaLogic.java
@@ -145,13 +145,26 @@ public class SchemaLogic extends AbstractTransactionalLogic<AbstractSchemaTO> {
@PreAuthorize("isAuthenticated()")
@SuppressWarnings("unchecked")
- public <T extends AbstractSchemaTO> List<T> list(final SchemaType schemaType, final String anyTypeClass) {
- AnyTypeClass clazz = anyTypeClass == null ? null : anyTypeClassDAO.find(anyTypeClass);
+ public <T extends AbstractSchemaTO> List<T> list(
+ final SchemaType schemaType, final List<String> anyTypeClasses) {
+
+ List<AnyTypeClass> classes = new ArrayList<>(anyTypeClasses == null ? 0 : anyTypeClasses.size());
+ if (anyTypeClasses != null) {
+ for (String anyTypeClass : anyTypeClasses) {
+ AnyTypeClass clazz = anyTypeClassDAO.find(anyTypeClass);
+ if (clazz == null) {
+ LOG.warn("Ignoring invalid {}: {}", AnyTypeClass.class.getSimpleName(), anyTypeClass);
+ } else {
+ classes.add(clazz);
+ }
+ }
+ }
+
List<T> result;
switch (schemaType) {
case VIRTUAL:
result = CollectionUtils.collect(
- clazz == null ? virSchemaDAO.findAll() : virSchemaDAO.findByAnyTypeClass(clazz),
+ classes.isEmpty() ? virSchemaDAO.findAll() : virSchemaDAO.findByAnyTypeClasses(classes),
new Transformer<VirSchema, T>() {
@Override
@@ -163,7 +176,7 @@ public class SchemaLogic extends AbstractTransactionalLogic<AbstractSchemaTO> {
case DERIVED:
result = CollectionUtils.collect(
- clazz == null ? derSchemaDAO.findAll() : derSchemaDAO.findByAnyTypeClass(clazz),
+ classes.isEmpty() ? derSchemaDAO.findAll() : derSchemaDAO.findByAnyTypeClasses(classes),
new Transformer<DerSchema, T>() {
@Override
@@ -176,7 +189,7 @@ public class SchemaLogic extends AbstractTransactionalLogic<AbstractSchemaTO> {
case PLAIN:
default:
result = CollectionUtils.collect(
- clazz == null ? plainSchemaDAO.findAll() : plainSchemaDAO.findByAnyTypeClass(clazz),
+ classes.isEmpty() ? plainSchemaDAO.findAll() : plainSchemaDAO.findByAnyTypeClasses(classes),
new Transformer<PlainSchema, T>() {
@Override
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/misc/src/main/java/org/apache/syncope/core/misc/search/SearchCondVisitor.java
----------------------------------------------------------------------
diff --git a/core/misc/src/main/java/org/apache/syncope/core/misc/search/SearchCondVisitor.java b/core/misc/src/main/java/org/apache/syncope/core/misc/search/SearchCondVisitor.java
index c7efa8a..6b067ca 100644
--- a/core/misc/src/main/java/org/apache/syncope/core/misc/search/SearchCondVisitor.java
+++ b/core/misc/src/main/java/org/apache/syncope/core/misc/search/SearchCondVisitor.java
@@ -113,7 +113,7 @@ public class SearchCondVisitor extends AbstractSearchConditionVisitor<SearchBean
case ROLES:
RoleCond roleCond = new RoleCond();
- roleCond.setRoleKey(Long.valueOf(value));
+ roleCond.setRoleKey(value);
leaf = SearchCond.getLeafCond(roleCond);
break;
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/misc/src/main/java/org/apache/syncope/core/misc/security/AuthDataAccessor.java
----------------------------------------------------------------------
diff --git a/core/misc/src/main/java/org/apache/syncope/core/misc/security/AuthDataAccessor.java b/core/misc/src/main/java/org/apache/syncope/core/misc/security/AuthDataAccessor.java
index 1332404..afca81a 100644
--- a/core/misc/src/main/java/org/apache/syncope/core/misc/security/AuthDataAccessor.java
+++ b/core/misc/src/main/java/org/apache/syncope/core/misc/security/AuthDataAccessor.java
@@ -18,12 +18,12 @@
*/
package org.apache.syncope.core.misc.security;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import org.apache.commons.collections4.Closure;
@@ -260,6 +260,8 @@ public class AuthDataAccessor {
if (user.isMustChangePassword()) {
authorities.add(new SyncopeGrantedAuthority(StandardEntitlement.MUST_CHANGE_PASSWORD));
} else {
+ final Map<String, Set<String>> entForRealms = new HashMap<>();
+
// Give entitlements as assigned by roles (with realms, where applicable) - assigned either
// statically and dynamically
for (final Role role : userDAO.findAllRoles(user)) {
@@ -267,18 +269,19 @@ public class AuthDataAccessor {
@Override
public void execute(final String entitlement) {
- SyncopeGrantedAuthority authority = new SyncopeGrantedAuthority(entitlement);
- authorities.add(authority);
+ Set<String> realms = entForRealms.get(entitlement);
+ if (realms == null) {
+ realms = new HashSet<>();
+ entForRealms.put(entitlement, realms);
+ }
- List<String> realmFullPahs = new ArrayList<>();
CollectionUtils.collect(role.getRealms(), new Transformer<Realm, String>() {
@Override
public String transform(final Realm realm) {
return realm.getFullPath();
}
- }, realmFullPahs);
- authority.addRealms(realmFullPahs);
+ }, realms);
}
});
}
@@ -290,12 +293,22 @@ public class AuthDataAccessor {
StandardEntitlement.GROUP_UPDATE,
StandardEntitlement.GROUP_DELETE)) {
- SyncopeGrantedAuthority authority = new SyncopeGrantedAuthority(entitlement);
- authority.addRealm(
- RealmUtils.getGroupOwnerRealm(group.getRealm().getFullPath(), group.getKey()));
- authorities.add(authority);
+ Set<String> realms = entForRealms.get(entitlement);
+ if (realms == null) {
+ realms = new HashSet<>();
+ entForRealms.put(entitlement, realms);
+ }
+
+ realms.add(RealmUtils.getGroupOwnerRealm(group.getRealm().getFullPath(), group.getKey()));
}
}
+
+ // Finally normalize realms for each given entitlement and generate authorities
+ for (Map.Entry<String, Set<String>> entry : entForRealms.entrySet()) {
+ SyncopeGrantedAuthority authority = new SyncopeGrantedAuthority(entry.getKey());
+ authority.addRealms(RealmUtils.normalize(entry.getValue()));
+ authorities.add(authority);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/misc/src/main/java/org/apache/syncope/core/misc/security/SyncopeGrantedAuthority.java
----------------------------------------------------------------------
diff --git a/core/misc/src/main/java/org/apache/syncope/core/misc/security/SyncopeGrantedAuthority.java b/core/misc/src/main/java/org/apache/syncope/core/misc/security/SyncopeGrantedAuthority.java
index 198b1e8..1cdae17 100644
--- a/core/misc/src/main/java/org/apache/syncope/core/misc/security/SyncopeGrantedAuthority.java
+++ b/core/misc/src/main/java/org/apache/syncope/core/misc/security/SyncopeGrantedAuthority.java
@@ -18,9 +18,9 @@
*/
package org.apache.syncope.core.misc.security;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import org.apache.commons.collections4.Closure;
import org.apache.commons.collections4.CollectionUtils;
@@ -53,7 +53,7 @@ public class SyncopeGrantedAuthority implements GrantedAuthority {
return RealmUtils.normalizingAddTo(realms, newRealm);
}
- public void addRealms(final List<String> newRealms) {
+ public void addRealms(final Collection<String> newRealms) {
CollectionUtils.forAllDo(newRealms, new Closure<String>() {
@Override
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/misc/src/test/java/org/apache/syncope/core/misc/search/SearchCondConverterTest.java
----------------------------------------------------------------------
diff --git a/core/misc/src/test/java/org/apache/syncope/core/misc/search/SearchCondConverterTest.java b/core/misc/src/test/java/org/apache/syncope/core/misc/search/SearchCondConverterTest.java
index caa9c54..29f3c64 100644
--- a/core/misc/src/test/java/org/apache/syncope/core/misc/search/SearchCondConverterTest.java
+++ b/core/misc/src/test/java/org/apache/syncope/core/misc/search/SearchCondConverterTest.java
@@ -98,11 +98,11 @@ public class SearchCondConverterTest {
@Test
public void roles() {
- String fiqlExpression = new UserFiqlSearchConditionBuilder().inRoles(1L).query();
- assertEquals(SpecialAttr.ROLES + "==1", fiqlExpression);
+ String fiqlExpression = new UserFiqlSearchConditionBuilder().inRoles("User reviewer").query();
+ assertEquals(SpecialAttr.ROLES + "==User reviewer", fiqlExpression);
RoleCond roleCond = new RoleCond();
- roleCond.setRoleKey(1L);
+ roleCond.setRoleKey("User reviewer");
SearchCond simpleCond = SearchCond.getLeafCond(roleCond);
assertEquals(simpleCond, SearchCondConverter.convert(fiqlExpression));
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/RoleDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/RoleDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/RoleDAO.java
index d1a3101..d838df7 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/RoleDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/RoleDAO.java
@@ -23,11 +23,9 @@ import org.apache.syncope.core.persistence.api.entity.Realm;
import org.apache.syncope.core.persistence.api.entity.Role;
import org.apache.syncope.core.persistence.api.entity.user.User;
-public interface RoleDAO extends DAO<Role, Long> {
+public interface RoleDAO extends DAO<Role, String> {
- Role find(Long key);
-
- Role find(String name);
+ Role find(String key);
List<Role> findByRealm(Realm realm);
@@ -37,7 +35,7 @@ public interface RoleDAO extends DAO<Role, Long> {
void delete(Role role);
- void delete(Long key);
+ void delete(String key);
void refreshDynMemberships(User user);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SchemaDAO.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SchemaDAO.java
index 9e350fb..64a78fb 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SchemaDAO.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/SchemaDAO.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.core.persistence.api.dao;
+import java.util.Collection;
import java.util.List;
import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
import org.apache.syncope.core.persistence.api.entity.Schema;
@@ -26,7 +27,7 @@ public interface SchemaDAO<S extends Schema> extends DAO<S, String> {
S find(String name);
- List<S> findByAnyTypeClass(AnyTypeClass anyTypeClass);
+ List<S> findByAnyTypeClasses(Collection<AnyTypeClass> anyTypeClasses);
List<S> findAll();
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/RoleCond.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/RoleCond.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/RoleCond.java
index be6688f..0ee7648 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/RoleCond.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/search/RoleCond.java
@@ -22,13 +22,13 @@ public class RoleCond extends AbstractSearchCond {
private static final long serialVersionUID = 3581958527829522490L;
- private Long roleKey;
+ private String roleKey;
- public Long getRoleKey() {
+ public String getRoleKey() {
return roleKey;
}
- public void setRoleKey(final Long roleKey) {
+ public void setRoleKey(final String roleKey) {
this.roleKey = roleKey;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Role.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Role.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Role.java
index dba65ae..c26c15b 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Role.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/Role.java
@@ -22,11 +22,9 @@ import org.apache.syncope.core.persistence.api.entity.user.DynRoleMembership;
import java.util.List;
import java.util.Set;
-public interface Role extends Entity<Long> {
+public interface Role extends Entity<String> {
- String getName();
-
- void setName(String name);
+ void setKey(String name);
Set<String> getEntitlements();
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
index 7b1df89..f5c3922 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
@@ -399,10 +399,8 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>, Long> implements AnySea
if (any == null) {
LOG.error("Could not find {} with id {}, even though returned by the native query",
typeKind, actualKey);
- } else {
- if (!result.contains(any)) {
- result.add(any);
- }
+ } else if (!result.contains(any)) {
+ result.add(any);
}
}
@@ -554,7 +552,7 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>, Long> implements AnySea
query.append("SELECT DISTINCT any_id ").append("FROM ").
append(svs.role().name).append(" WHERE ").
- append("role_id=?").append(setParameter(parameters, cond.getRoleKey())).
+ append("role_name=?").append(setParameter(parameters, cond.getRoleKey())).
append(')');
if (not) {
@@ -565,7 +563,7 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>, Long> implements AnySea
query.append("SELECT DISTINCT any_id ").append("FROM ").
append(svs.dynrolemembership().name).append(" WHERE ").
- append("role_id=?").append(setParameter(parameters, cond.getRoleKey())).
+ append("role_name=?").append(setParameter(parameters, cond.getRoleKey())).
append(')');
return query.toString();
@@ -721,20 +719,18 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>, Long> implements AnySea
append(" WHERE any_id NOT IN (SELECT any_id FROM ").
append(svs.nullAttr().name).
append(" WHERE schema_name='").append(schema.getKey()).append("')");
+ } else if (cond.getType() == AttributeCond.Type.ISNULL) {
+ query.append(svs.nullAttr().name).
+ append(" WHERE schema_name='").append(schema.getKey()).append("'");
} else {
- if (cond.getType() == AttributeCond.Type.ISNULL) {
- query.append(svs.nullAttr().name).
- append(" WHERE schema_name='").append(schema.getKey()).append("'");
+ if (schema.isUniqueConstraint()) {
+ query.append(svs.uniqueAttr().name);
} else {
- if (schema.isUniqueConstraint()) {
- query.append(svs.uniqueAttr().name);
- } else {
- query.append(svs.attr().name);
- }
- query.append(" WHERE schema_name='").append(schema.getKey());
-
- fillAttributeQuery(query, attrValue, schema, cond, not, parameters, svs);
+ query.append(svs.attr().name);
}
+ query.append(" WHERE schema_name='").append(schema.getKey());
+
+ fillAttributeQuery(query, attrValue, schema, cond, not, parameters, svs);
}
return query.toString();
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyTypeClassDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyTypeClassDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyTypeClassDAO.java
index 9a01442..a999e14 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyTypeClassDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnyTypeClassDAO.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.core.persistence.jpa.dao;
+import java.util.Collections;
import java.util.List;
import javax.persistence.TypedQuery;
import org.apache.syncope.core.persistence.api.dao.AnyTypeClassDAO;
@@ -85,13 +86,13 @@ public class JPAAnyTypeClassDAO extends AbstractDAO<AnyTypeClass, String> implem
return;
}
- for (PlainSchema schema : plainSchemaDAO.findByAnyTypeClass(anyTypeClass)) {
+ for (PlainSchema schema : plainSchemaDAO.findByAnyTypeClasses(Collections.singletonList(anyTypeClass))) {
schema.setAnyTypeClass(null);
}
- for (DerSchema schema : derSchemaDAO.findByAnyTypeClass(anyTypeClass)) {
+ for (DerSchema schema : derSchemaDAO.findByAnyTypeClasses(Collections.singletonList(anyTypeClass))) {
schema.setAnyTypeClass(null);
}
- for (VirSchema schema : virSchemaDAO.findByAnyTypeClass(anyTypeClass)) {
+ for (VirSchema schema : virSchemaDAO.findByAnyTypeClasses(Collections.singletonList(anyTypeClass))) {
schema.setAnyTypeClass(null);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerSchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerSchemaDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerSchemaDAO.java
index 8221493..5b342b2 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerSchemaDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPADerSchemaDAO.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.core.persistence.jpa.dao;
+import java.util.Collection;
import java.util.List;
import javax.persistence.TypedQuery;
import org.apache.syncope.common.lib.types.AnyTypeKind;
@@ -43,13 +44,16 @@ public class JPADerSchemaDAO extends AbstractDAO<DerSchema, String> implements D
}
@Override
- public List<DerSchema> findByAnyTypeClass(final AnyTypeClass anyTypeClass) {
+ public List<DerSchema> findByAnyTypeClasses(final Collection<AnyTypeClass> anyTypeClasses) {
StringBuilder queryString = new StringBuilder("SELECT e FROM ").
append(JPADerSchema.class.getSimpleName()).
- append(" e WHERE e.anyTypeClass=:anyTypeClass");
+ append(" e WHERE ");
+ for (AnyTypeClass anyTypeClass : anyTypeClasses) {
+ queryString.append("e.anyTypeClass.name='").append(anyTypeClass.getKey()).append("' OR");
+ }
- TypedQuery<DerSchema> query = entityManager().createQuery(queryString.toString(), DerSchema.class);
- query.setParameter("anyTypeClass", anyTypeClass);
+ TypedQuery<DerSchema> query = entityManager().createQuery(
+ queryString.substring(0, queryString.length() - 3), DerSchema.class);
return query.getResultList();
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainSchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainSchemaDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainSchemaDAO.java
index 47e8fe3..d6e0315 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainSchemaDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPlainSchemaDAO.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.core.persistence.jpa.dao;
+import java.util.Collection;
import java.util.List;
import javax.persistence.TypedQuery;
import org.apache.syncope.common.lib.types.AnyTypeKind;
@@ -49,13 +50,16 @@ public class JPAPlainSchemaDAO extends AbstractDAO<PlainSchema, String> implemen
}
@Override
- public List<PlainSchema> findByAnyTypeClass(final AnyTypeClass anyTypeClass) {
+ public List<PlainSchema> findByAnyTypeClasses(final Collection<AnyTypeClass> anyTypeClasses) {
StringBuilder queryString = new StringBuilder("SELECT e FROM ").
append(JPAPlainSchema.class.getSimpleName()).
- append(" e WHERE e.anyTypeClass=:anyTypeClass");
+ append(" e WHERE ");
+ for (AnyTypeClass anyTypeClass : anyTypeClasses) {
+ queryString.append("e.anyTypeClass.name='").append(anyTypeClass.getKey()).append("' OR");
+ }
- TypedQuery<PlainSchema> query = entityManager().createQuery(queryString.toString(), PlainSchema.class);
- query.setParameter("anyTypeClass", anyTypeClass);
+ TypedQuery<PlainSchema> query = entityManager().createQuery(
+ queryString.substring(0, queryString.length() - 3), PlainSchema.class);
return query.getResultList();
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPARoleDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPARoleDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPARoleDAO.java
index 168241f..4dc1688 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPARoleDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPARoleDAO.java
@@ -19,7 +19,6 @@
package org.apache.syncope.core.persistence.jpa.dao;
import java.util.List;
-import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import org.apache.syncope.common.lib.SyncopeConstants;
import org.apache.syncope.common.lib.types.AnyTypeKind;
@@ -37,33 +36,17 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@Repository
-public class JPARoleDAO extends AbstractDAO<Role, Long> implements RoleDAO {
+public class JPARoleDAO extends AbstractDAO<Role, String> implements RoleDAO {
@Autowired
private AnySearchDAO searchDAO;
@Override
- public Role find(final Long key) {
+ public Role find(final String key) {
return entityManager().find(JPARole.class, key);
}
@Override
- public Role find(final String name) {
- TypedQuery<Role> query = entityManager().createQuery(
- "SELECT e FROM " + JPARole.class.getSimpleName() + " e WHERE e.name=:name", Role.class);
- query.setParameter("name", name);
-
- Role result = null;
- try {
- result = query.getSingleResult();
- } catch (NoResultException e) {
- LOG.debug("Found more than one match", e);
- }
-
- return result;
- }
-
- @Override
public List<Role> findByRealm(final Realm realm) {
TypedQuery<Role> query = entityManager().createQuery(
"SELECT e FROM " + JPARole.class.getSimpleName() + " e WHERE :realm MEMBER OF e.realms", Role.class);
@@ -108,7 +91,7 @@ public class JPARoleDAO extends AbstractDAO<Role, Long> implements RoleDAO {
}
@Override
- public void delete(final Long key) {
+ public void delete(final String key) {
Role role = find(key);
if (role == null) {
return;
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java
index aa38d77..854b065 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAVirSchemaDAO.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.core.persistence.jpa.dao;
+import java.util.Collection;
import java.util.List;
import javax.persistence.TypedQuery;
import org.apache.syncope.common.lib.types.AnyTypeKind;
@@ -45,13 +46,16 @@ public class JPAVirSchemaDAO extends AbstractDAO<VirSchema, String> implements V
}
@Override
- public List<VirSchema> findByAnyTypeClass(final AnyTypeClass anyTypeClass) {
+ public List<VirSchema> findByAnyTypeClasses(final Collection<AnyTypeClass> anyTypeClasses) {
StringBuilder queryString = new StringBuilder("SELECT e FROM ").
append(JPAVirSchema.class.getSimpleName()).
- append(" e WHERE e.anyTypeClass=:anyTypeClass");
+ append(" e WHERE ");
+ for (AnyTypeClass anyTypeClass : anyTypeClasses) {
+ queryString.append("e.anyTypeClass.name='").append(anyTypeClass.getKey()).append("' OR");
+ }
- TypedQuery<VirSchema> query = entityManager().createQuery(queryString.toString(), VirSchema.class);
- query.setParameter("anyTypeClass", anyTypeClass);
+ TypedQuery<VirSchema> query = entityManager().createQuery(
+ queryString.substring(0, queryString.length() - 3), VirSchema.class);
return query.getResultList();
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARole.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARole.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARole.java
index 529a606..78d7380 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARole.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/JPARole.java
@@ -37,37 +37,34 @@ import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
import org.apache.syncope.core.persistence.api.entity.user.DynRoleMembership;
import org.apache.syncope.core.persistence.api.entity.Realm;
import org.apache.syncope.core.persistence.api.entity.Role;
+import org.apache.syncope.core.persistence.jpa.validation.entity.RoleCheck;
@Entity
@Table(name = JPARole.TABLE)
@Cacheable
-public class JPARole extends AbstractEntity<Long> implements Role {
+@RoleCheck
+public class JPARole extends AbstractEntity<String> implements Role {
private static final long serialVersionUID = -7657701119422588832L;
public static final String TABLE = "SyncopeRole";
@Id
- private Long id;
-
- @Column(unique = true)
- @NotNull
private String name;
@ElementCollection(fetch = FetchType.EAGER)
@Column(name = "entitlement")
@CollectionTable(name = "SyncopeRole_entitlements",
joinColumns =
- @JoinColumn(name = "role_id", referencedColumnName = "id"))
+ @JoinColumn(name = "role_name", referencedColumnName = "name"))
private Set<String> entitlements = new HashSet<>();
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(joinColumns =
- @JoinColumn(name = "role_id"),
+ @JoinColumn(name = "role_name"),
inverseJoinColumns =
@JoinColumn(name = "realm_id"))
@Valid
@@ -78,17 +75,12 @@ public class JPARole extends AbstractEntity<Long> implements Role {
private JPADynRoleMembership dynMembership;
@Override
- public Long getKey() {
- return id;
- }
-
- @Override
- public String getName() {
+ public String getKey() {
return name;
}
@Override
- public void setName(final String name) {
+ public void setKey(final String name) {
this.name = name;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java
index 26fd229..3626804 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java
@@ -92,7 +92,7 @@ public class JPAUser extends AbstractAny<UPlainAttr> implements User {
@JoinTable(joinColumns =
@JoinColumn(name = "user_id"),
inverseJoinColumns =
- @JoinColumn(name = "role_id"))
+ @JoinColumn(name = "role_name"))
private List<JPARole> roles = new ArrayList<>();
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
@@ -442,8 +442,8 @@ public class JPAUser extends AbstractAny<UPlainAttr> implements User {
res = passwordHistory.subList(size >= passwordHistory.size()
? 0
: passwordHistory.size() - size, passwordHistory.size()).contains(cipherAlgorithm == null
- ? password
- : Encryptor.getInstance().encode(password, cipherAlgorithm));
+ ? password
+ : Encryptor.getInstance().encode(password, cipherAlgorithm));
} catch (Exception e) {
LOG.error("Error evaluating password history", e);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/ExternalResourceValidator.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/ExternalResourceValidator.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/ExternalResourceValidator.java
index d328eac..2f97699 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/ExternalResourceValidator.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/ExternalResourceValidator.java
@@ -189,7 +189,7 @@ public class ExternalResourceValidator extends AbstractValidator<ExternalResourc
public boolean isValid(final ExternalResource resource, final ConstraintValidatorContext context) {
context.disableDefaultConstraintViolation();
- if (!NAME_PATTERN.matcher(resource.getKey()).matches()) {
+ if (resource.getKey() == null || !NAME_PATTERN.matcher(resource.getKey()).matches()) {
context.buildConstraintViolationWithTemplate(
getTemplate(EntityViolationType.InvalidName, "Invalid Resource name")).
addPropertyNode("name").addConstraintViolation();
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/RoleCheck.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/RoleCheck.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/RoleCheck.java
new file mode 100644
index 0000000..fbb5f0a
--- /dev/null
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/RoleCheck.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa.validation.entity;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+@Target({ ElementType.TYPE })
+@Retention(RetentionPolicy.RUNTIME)
+@Constraint(validatedBy = RoleValidator.class)
+@Documented
+public @interface RoleCheck {
+
+ String message() default "{org.apache.syncope.core.persistence.validation.role}";
+
+ Class<?>[] groups() default {};
+
+ Class<? extends Payload>[] payload() default {};
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/RoleValidator.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/RoleValidator.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/RoleValidator.java
new file mode 100644
index 0000000..29558a0
--- /dev/null
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/RoleValidator.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa.validation.entity;
+
+import javax.validation.ConstraintValidatorContext;
+import org.apache.syncope.common.lib.types.EntityViolationType;
+import org.apache.syncope.core.persistence.api.entity.Role;
+
+public class RoleValidator extends AbstractValidator<RoleCheck, Role> {
+
+ @Override
+ public boolean isValid(final Role role, final ConstraintValidatorContext context) {
+ context.disableDefaultConstraintViolation();
+
+ if (role.getKey() == null || !NAME_PATTERN.matcher(role.getKey()).matches()) {
+ context.buildConstraintViolationWithTemplate(
+ getTemplate(EntityViolationType.InvalidName, "Invalid Role name")).
+ addPropertyNode("name").addConstraintViolation();
+ return false;
+ }
+
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
index 15ff3aa..a2eb846 100644
--- a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
+++ b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
@@ -75,15 +75,6 @@ under the License.
</attributes>
</entity>
- <entity class="org.apache.syncope.core.persistence.jpa.entity.JPARole">
- <attributes>
- <id name="id">
- <generated-value generator="SEQ_Role" strategy="TABLE"/>
- <table-generator name="SEQ_Role" pk-column-value="SEQ_Role" initial-value="100"/>
- </id>
- </attributes>
- </entity>
-
<entity class="org.apache.syncope.core.persistence.jpa.entity.user.JPADynRoleMembership">
<attributes>
<id name="id">
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
index 15ff3aa..a2eb846 100644
--- a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
+++ b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
@@ -75,15 +75,6 @@ under the License.
</attributes>
</entity>
- <entity class="org.apache.syncope.core.persistence.jpa.entity.JPARole">
- <attributes>
- <id name="id">
- <generated-value generator="SEQ_Role" strategy="TABLE"/>
- <table-generator name="SEQ_Role" pk-column-value="SEQ_Role" initial-value="100"/>
- </id>
- </attributes>
- </entity>
-
<entity class="org.apache.syncope.core.persistence.jpa.entity.user.JPADynRoleMembership">
<attributes>
<id name="id">
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml b/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml
index aeb24ee..5b820ff 100644
--- a/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml
+++ b/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml
@@ -75,15 +75,6 @@ under the License.
</attributes>
</entity>
- <entity class="org.apache.syncope.core.persistence.jpa.entity.JPARole">
- <attributes>
- <id name="id">
- <generated-value generator="SEQ_Role" strategy="TABLE"/>
- <table-generator name="SEQ_Role" pk-column-value="SEQ_Role" initial-value="100"/>
- </id>
- </attributes>
- </entity>
-
<entity class="org.apache.syncope.core.persistence.jpa.entity.user.JPADynRoleMembership">
<attributes>
<id name="id">
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/main/resources/views.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/resources/views.xml b/core/persistence-jpa/src/main/resources/views.xml
index 2e14834..fd0bf9c 100644
--- a/core/persistence-jpa/src/main/resources/views.xml
+++ b/core/persistence-jpa/src/main/resources/views.xml
@@ -90,13 +90,13 @@ under the License.
<entry key="user_search_role">
CREATE VIEW user_search_role AS
- SELECT ss.user_id AS any_id, ss.role_id AS role_id
+ SELECT ss.user_id AS any_id, ss.role_name AS role_name
FROM SyncopeUser_SyncopeRole ss
</entry>
<entry key="user_search_dynrmemb">
CREATE VIEW user_search_dynrmemb AS
- SELECT ds.user_id AS any_id, d.role_id AS role_id
+ SELECT ds.user_id AS any_id, d.role_name AS role_name
FROM DynRoleMembership d, DynRoleMembership_User ds
WHERE d.id = ds.dynRoleMembership_id
</entry>
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java
index b5f99ce..5c8dde9 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java
@@ -91,7 +91,7 @@ public class AnySearchTest extends AbstractTest {
assertTrue(searchDAO.matches(user, SearchCond.getLeafCond(groupCond), AnyTypeKind.USER));
RoleCond roleCond = new RoleCond();
- roleCond.setRoleKey(3L);
+ roleCond.setRoleKey("Other");
assertTrue(searchDAO.matches(user, SearchCond.getLeafCond(roleCond), AnyTypeKind.USER));
}
@@ -228,7 +228,7 @@ public class AnySearchTest extends AbstractTest {
@Test
public void searchByRole() {
RoleCond roleCond = new RoleCond();
- roleCond.setRoleKey(3L);
+ roleCond.setRoleKey("Other");
List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
SearchCond.getLeafCond(roleCond), AnyTypeKind.USER);
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/RoleTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/RoleTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/RoleTest.java
index b57e713..ce2039a 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/RoleTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/RoleTest.java
@@ -45,15 +45,12 @@ public class RoleTest extends AbstractTest {
@Test
public void find() {
- Role role1 = roleDAO.find(2L);
- assertNotNull(role1);
- assertNotNull(role1.getName());
- assertFalse(role1.getRealms().isEmpty());
- assertFalse(role1.getEntitlements().isEmpty());
- assertTrue(role1.getEntitlements().contains(StandardEntitlement.USER_LIST));
-
- Role role2 = roleDAO.find(role1.getName());
- assertEquals(role1, role2);
+ Role role = roleDAO.find("User manager");
+ assertNotNull(role);
+ assertNotNull(role.getKey());
+ assertFalse(role.getRealms().isEmpty());
+ assertFalse(role.getEntitlements().isEmpty());
+ assertTrue(role.getEntitlements().contains(StandardEntitlement.USER_LIST));
}
@Test
@@ -69,7 +66,7 @@ public class RoleTest extends AbstractTest {
@Test
public void save() {
Role role = entityFactory.newEntity(Role.class);
- role.setName("new");
+ role.setKey("new");
role.add(realmDAO.getRoot());
role.add(realmDAO.find("/even/two"));
role.getEntitlements().add(StandardEntitlement.LOG_LIST);
@@ -81,9 +78,9 @@ public class RoleTest extends AbstractTest {
@Test
public void delete() {
- assertNotNull(roleDAO.find(3L));
+ assertNotNull(roleDAO.find("Other"));
- roleDAO.delete(3L);
- assertNull(roleDAO.find(3L));
+ roleDAO.delete("Other");
+ assertNull(roleDAO.find("Other"));
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnySearchTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnySearchTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnySearchTest.java
index 24a4e7e..001a984 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnySearchTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/AnySearchTest.java
@@ -85,7 +85,7 @@ public class AnySearchTest extends AbstractTest {
public void searchByDynMembership() {
// 1. create role with dynamic membership
Role role = entityFactory.newEntity(Role.class);
- role.setName("new");
+ role.setKey("new");
role.add(realmDAO.getRoot());
role.add(realmDAO.find("/even/two"));
role.getEntitlements().add(StandardEntitlement.LOG_LIST);
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/RealmTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/RealmTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/RealmTest.java
index 5bf1b83..2b67e6a 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/RealmTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/RealmTest.java
@@ -45,7 +45,7 @@ public class RealmTest extends AbstractTest {
Realm realm = realmDAO.find("/odd");
assertNotNull(realm);
- Role role = roleDAO.find(1L);
+ Role role = roleDAO.find("User reviewer");
assertTrue(role.getRealms().contains(realm));
int beforeSize = role.getRealms().size();
@@ -54,7 +54,7 @@ public class RealmTest extends AbstractTest {
realmDAO.flush();
- role = roleDAO.find(1L);
+ role = roleDAO.find("User reviewer");
assertEquals(beforeSize - 1, role.getRealms().size());
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/RoleTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/RoleTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/RoleTest.java
index bff367e..a3a4ea6 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/RoleTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/RoleTest.java
@@ -98,7 +98,7 @@ public class RoleTest extends AbstractTest {
// 1. create role with dynamic membership
Role role = entityFactory.newEntity(Role.class);
- role.setName("new");
+ role.setKey("new");
role.add(realmDAO.getRoot());
role.add(realmDAO.find("/even/two"));
role.getEntitlements().add(StandardEntitlement.LOG_LIST);
@@ -165,7 +165,7 @@ public class RoleTest extends AbstractTest {
public void delete() {
// 0. create role
Role role = entityFactory.newEntity(Role.class);
- role.setName("new");
+ role.setKey("new");
role.add(realmDAO.getRoot());
role.add(realmDAO.find("/even/two"));
role.getEntitlements().add(StandardEntitlement.LOG_LIST);
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/resources/domains/MasterContent.xml b/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
index 73fee53..b0a1a1a 100644
--- a/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
+++ b/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
@@ -8,7 +8,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
@@ -170,37 +170,37 @@ under the License.
<ARelationship id="1" left_anyObject_id="1" right_anyObject_id="2" type_name="neighborhood"/>
- <SyncopeRole id="1" name="User reviewer"/>
- <SyncopeRole_entitlements entitlement="USER_READ" role_id="1"/>
- <SyncopeRole_entitlements entitlement="USER_LIST" role_id="1"/>
- <SyncopeRole_entitlements entitlement="USER_SEARCH" role_id="1"/>
- <SyncopeRole_Realm role_id="1" realm_id="2"/>
- <SyncopeRole_Realm role_id="1" realm_id="3"/>
+ <SyncopeRole name="User reviewer"/>
+ <SyncopeRole_entitlements entitlement="USER_READ" role_name="User reviewer"/>
+ <SyncopeRole_entitlements entitlement="USER_LIST" role_name="User reviewer"/>
+ <SyncopeRole_entitlements entitlement="USER_SEARCH" role_name="User reviewer"/>
+ <SyncopeRole_Realm role_name="User reviewer" realm_id="2"/>
+ <SyncopeRole_Realm role_name="User reviewer" realm_id="3"/>
- <SyncopeRole id="2" name="User manager"/>
- <SyncopeRole_entitlements entitlement="USER_READ" role_id="2"/>
- <SyncopeRole_entitlements entitlement="USER_LIST" role_id="2"/>
- <SyncopeRole_entitlements entitlement="USER_SEARCH" role_id="2"/>
- <SyncopeRole_entitlements entitlement="WORKFLOW_FORM_CLAIM" role_id="2"/>
- <SyncopeRole_entitlements entitlement="WORKFLOW_FORM_SUBMIT" role_id="2"/>
- <SyncopeRole_Realm role_id="2" realm_id="1"/>
+ <SyncopeRole name="User manager"/>
+ <SyncopeRole_entitlements entitlement="USER_READ" role_name="User manager"/>
+ <SyncopeRole_entitlements entitlement="USER_LIST" role_name="User manager"/>
+ <SyncopeRole_entitlements entitlement="USER_SEARCH" role_name="User manager"/>
+ <SyncopeRole_entitlements entitlement="WORKFLOW_FORM_CLAIM" role_name="User manager"/>
+ <SyncopeRole_entitlements entitlement="WORKFLOW_FORM_SUBMIT" role_name="User manager"/>
+ <SyncopeRole_Realm role_name="User manager" realm_id="1"/>
- <SyncopeRole id="3" name="Other"/>
- <SyncopeRole_entitlements entitlement="SCHEMA_READ" role_id="3"/>
- <SyncopeRole_entitlements entitlement="GROUP_READ" role_id="3"/>
- <SyncopeRole_entitlements entitlement="WORKFLOW_FORM_CLAIM" role_id="3"/>
- <SyncopeRole_Realm role_id="3" realm_id="2"/>
+ <SyncopeRole name="Other"/>
+ <SyncopeRole_entitlements entitlement="SCHEMA_READ" role_name="Other"/>
+ <SyncopeRole_entitlements entitlement="GROUP_READ" role_name="Other"/>
+ <SyncopeRole_entitlements entitlement="WORKFLOW_FORM_CLAIM" role_name="Other"/>
+ <SyncopeRole_Realm role_name="Other" realm_id="2"/>
- <SyncopeRole id="4" name="Search for /even/two"/>
- <SyncopeRole_entitlements entitlement="USER_READ" role_id="4"/>
- <SyncopeRole_entitlements entitlement="USER_SEARCH" role_id="4"/>
- <SyncopeRole_Realm role_id="4" realm_id="4"/>
+ <SyncopeRole name="Search for /even/two"/>
+ <SyncopeRole_entitlements entitlement="USER_READ" role_name="Search for /even/two"/>
+ <SyncopeRole_entitlements entitlement="USER_SEARCH" role_name="Search for /even/two"/>
+ <SyncopeRole_Realm role_name="Search for /even/two" realm_id="4"/>
<SyncopeUser id="1" workflowId="4" status="active" password="5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8" cipherAlgorithm="SHA1"
realm_id="3"
username="rossini" creator="admin" lastModifier="admin"
creationDate="2010-10-20 11:00:00" lastChangeDate="2010-10-20 11:00:00" suspended="0"/>
- <SyncopeUser_SyncopeRole user_id="1" role_id="3"/>
+ <SyncopeUser_SyncopeRole user_id="1" role_name="Other"/>
<SyncopeUser id="2" workflowId="6" status="active" password="5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8" cipherAlgorithm="SHA1"
realm_id="1"
username="verdi" creator="admin" lastModifier="admin"
@@ -213,13 +213,13 @@ under the License.
realm_id="1"
username="bellini" creator="admin" lastModifier="admin"
creationDate="2010-10-20 11:00:00" lastChangeDate="2010-10-20 11:00:00" suspended="0"/>
- <SyncopeUser_SyncopeRole user_id="4" role_id="1"/>
- <SyncopeUser_SyncopeRole user_id="4" role_id="2"/>
+ <SyncopeUser_SyncopeRole user_id="4" role_name="User reviewer"/>
+ <SyncopeUser_SyncopeRole user_id="4" role_name="User manager"/>
<SyncopeUser id="5" workflowId="12" status="active" password="5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8" cipherAlgorithm="SHA1"
realm_id="1"
username="puccini" creator="admin" lastModifier="admin"
creationDate="2010-10-20 11:00:00" lastChangeDate="2010-10-20 11:00:00" suspended="0"/>
- <SyncopeUser_SyncopeRole user_id="5" role_id="4"/>
+ <SyncopeUser_SyncopeRole user_id="5" role_name="Search for /even/two"/>
<SyncopeGroup id="1" name="root"
realm_id="1"
@@ -1110,4 +1110,4 @@ under the License.
<SyncopeLogger logName="syncope.audit.[REST]:[EntitlementLogic]:[]:[getOwn]:[SUCCESS]" logLevel="DEBUG" logType="AUDIT"/>
<SecurityQuestion id="1" content="What's your mother's maiden name?"/>
-</dataset>
+</dataset>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyTypeClassDataBinderImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyTypeClassDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyTypeClassDataBinderImpl.java
index 8a33e12..047633d 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyTypeClassDataBinderImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/AnyTypeClassDataBinderImpl.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.core.provisioning.java.data;
+import java.util.Collections;
import org.apache.syncope.common.lib.to.AnyTypeClassTO;
import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
@@ -63,7 +64,7 @@ public class AnyTypeClassDataBinderImpl implements AnyTypeClassDataBinder {
anyTypeClass.setKey(anyTypeClassTO.getKey());
}
- for (PlainSchema schema : plainSchemaDAO.findByAnyTypeClass(anyTypeClass)) {
+ for (PlainSchema schema : plainSchemaDAO.findByAnyTypeClasses(Collections.singletonList(anyTypeClass))) {
schema.setAnyTypeClass(null);
}
@@ -78,7 +79,7 @@ public class AnyTypeClassDataBinderImpl implements AnyTypeClassDataBinder {
}
}
- for (DerSchema schema : derSchemaDAO.findByAnyTypeClass(anyTypeClass)) {
+ for (DerSchema schema : derSchemaDAO.findByAnyTypeClasses(Collections.singletonList(anyTypeClass))) {
schema.setAnyTypeClass(null);
}
@@ -93,7 +94,7 @@ public class AnyTypeClassDataBinderImpl implements AnyTypeClassDataBinder {
}
}
- for (VirSchema schema : virSchemaDAO.findByAnyTypeClass(anyTypeClass)) {
+ for (VirSchema schema : virSchemaDAO.findByAnyTypeClasses(Collections.singletonList(anyTypeClass))) {
schema.setAnyTypeClass(null);
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RoleDataBinderImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RoleDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RoleDataBinderImpl.java
index 542b07c..1bef90e 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RoleDataBinderImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RoleDataBinderImpl.java
@@ -75,7 +75,7 @@ public class RoleDataBinderImpl implements RoleDataBinder {
@Override
public void update(final Role role, final RoleTO roleTO) {
- role.setName(roleTO.getName());
+ role.setKey(roleTO.getKey());
role.getEntitlements().clear();
role.getEntitlements().addAll(roleTO.getEntitlements());
@@ -93,17 +93,15 @@ public class RoleDataBinderImpl implements RoleDataBinder {
// dynamic membership
if (role.getKey() == null && roleTO.getDynMembershipCond() != null) {
setDynMembership(role, roleTO.getDynMembershipCond());
- } else {
- if (role.getDynMembership() != null && roleTO.getDynMembershipCond() == null) {
- role.setDynMembership(null);
- } else if (role.getDynMembership() == null && roleTO.getDynMembershipCond() != null) {
- setDynMembership(role, roleTO.getDynMembershipCond());
- } else if (role.getDynMembership() != null && roleTO.getDynMembershipCond() != null
- && !role.getDynMembership().getFIQLCond().equals(roleTO.getDynMembershipCond())) {
-
- role.getDynMembership().getMembers().clear();
- setDynMembership(role, roleTO.getDynMembershipCond());
- }
+ } else if (role.getDynMembership() != null && roleTO.getDynMembershipCond() == null) {
+ role.setDynMembership(null);
+ } else if (role.getDynMembership() == null && roleTO.getDynMembershipCond() != null) {
+ setDynMembership(role, roleTO.getDynMembershipCond());
+ } else if (role.getDynMembership() != null && roleTO.getDynMembershipCond() != null
+ && !role.getDynMembership().getFIQLCond().equals(roleTO.getDynMembershipCond())) {
+
+ role.getDynMembership().getMembers().clear();
+ setDynMembership(role, roleTO.getDynMembershipCond());
}
}
@@ -112,7 +110,6 @@ public class RoleDataBinderImpl implements RoleDataBinder {
RoleTO roleTO = new RoleTO();
roleTO.setKey(role.getKey());
- roleTO.setName(role.getName());
roleTO.getEntitlements().addAll(role.getEntitlements());
CollectionUtils.collect(role.getRealms(), new Transformer<Realm, String>() {
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/UserDataBinderImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/UserDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/UserDataBinderImpl.java
index 5bf13c5..ca3448c 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/UserDataBinderImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/UserDataBinderImpl.java
@@ -32,10 +32,10 @@ import org.apache.commons.collections4.Transformer;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.lib.SyncopeClientCompositeException;
import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.patch.LongPatchItem;
import org.apache.syncope.common.lib.patch.MembershipPatch;
import org.apache.syncope.common.lib.patch.PasswordPatch;
import org.apache.syncope.common.lib.patch.RelationshipPatch;
+import org.apache.syncope.common.lib.patch.StringPatchItem;
import org.apache.syncope.common.lib.patch.UserPatch;
import org.apache.syncope.common.lib.to.MembershipTO;
import org.apache.syncope.common.lib.to.RelationshipTO;
@@ -164,7 +164,7 @@ public class UserDataBinderImpl extends AbstractAnyDataBinder implements UserDat
SyncopeClientCompositeException scce = SyncopeClientException.buildComposite();
// roles
- for (Long roleKey : userTO.getRoles()) {
+ for (String roleKey : userTO.getRoles()) {
Role role = roleDAO.find(roleKey);
if (role == null) {
LOG.warn("Ignoring unknown role with id {}", roleKey);
@@ -317,7 +317,7 @@ public class UserDataBinderImpl extends AbstractAnyDataBinder implements UserDat
}
// roles
- for (LongPatchItem patch : userPatch.getRoles()) {
+ for (StringPatchItem patch : userPatch.getRoles()) {
Role role = roleDAO.find(patch.getValue());
if (role == null) {
LOG.warn("Ignoring unknown role with key {}", patch.getValue());
@@ -452,10 +452,10 @@ public class UserDataBinderImpl extends AbstractAnyDataBinder implements UserDat
if (details) {
// roles
- CollectionUtils.collect(user.getRoles(), new Transformer<Role, Long>() {
+ CollectionUtils.collect(user.getRoles(), new Transformer<Role, String>() {
@Override
- public Long transform(final Role role) {
+ public String transform(final Role role) {
return role.getKey();
}
}, userTO.getRoles());
@@ -480,10 +480,10 @@ public class UserDataBinderImpl extends AbstractAnyDataBinder implements UserDat
}, userTO.getMemberships());
// dynamic memberships
- CollectionUtils.collect(userDAO.findDynRoleMemberships(user), new Transformer<Role, Long>() {
+ CollectionUtils.collect(userDAO.findDynRoleMemberships(user), new Transformer<Role, String>() {
@Override
- public Long transform(final Role role) {
+ public String transform(final Role role) {
return role.getKey();
}
}, userTO.getDynRoles());
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RoleServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RoleServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RoleServiceImpl.java
index 006767c..1eec4a3 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RoleServiceImpl.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RoleServiceImpl.java
@@ -40,14 +40,14 @@ public class RoleServiceImpl extends AbstractServiceImpl implements RoleService
}
@Override
- public RoleTO read(final Long roleKey) {
- return logic.read(roleKey);
+ public RoleTO read(final String key) {
+ return logic.read(key);
}
@Override
public Response create(final RoleTO roleTO) {
RoleTO created = logic.create(roleTO);
- URI location = uriInfo.getAbsolutePathBuilder().path(String.valueOf(created.getKey())).build();
+ URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build();
return Response.created(location).
header(RESTHeaders.RESOURCE_KEY, created.getKey()).
build();
@@ -59,8 +59,8 @@ public class RoleServiceImpl extends AbstractServiceImpl implements RoleService
}
@Override
- public void delete(final Long roleKey) {
- logic.delete(roleKey);
+ public void delete(final String key) {
+ logic.delete(key);
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SchemaServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SchemaServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SchemaServiceImpl.java
index 07d84fb..fc98926 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SchemaServiceImpl.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/SchemaServiceImpl.java
@@ -24,6 +24,7 @@ import javax.ws.rs.core.Response;
import org.apache.syncope.common.lib.to.AbstractSchemaTO;
import org.apache.syncope.common.lib.types.SchemaType;
import org.apache.syncope.common.rest.api.RESTHeaders;
+import org.apache.syncope.common.rest.api.beans.SchemaQuery;
import org.apache.syncope.common.rest.api.service.SchemaService;
import org.apache.syncope.core.logic.SchemaLogic;
import org.springframework.beans.factory.annotation.Autowired;
@@ -51,8 +52,8 @@ public class SchemaServiceImpl extends AbstractServiceImpl implements SchemaServ
}
@Override
- public <T extends AbstractSchemaTO> List<T> list(final SchemaType schemaType, final String anyTypeClass) {
- return logic.list(schemaType, anyTypeClass);
+ public <T extends AbstractSchemaTO> List<T> list(final SchemaType schemaType, final SchemaQuery query) {
+ return logic.list(schemaType, query.getAnyTypeClasses());
}
@Override
http://git-wip-us.apache.org/repos/asf/syncope/blob/b738d3e9/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractTaskITCase.java
index c118224..2d98fd8 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractTaskITCase.java
@@ -35,13 +35,13 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.Predicate;
-import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.common.lib.to.AbstractTaskTO;
import org.apache.syncope.common.lib.to.NotificationTaskTO;
import org.apache.syncope.common.lib.to.PagedResult;
import org.apache.syncope.common.lib.to.TaskExecTO;
import org.apache.syncope.common.lib.to.UserTO;
import org.apache.syncope.common.lib.types.TaskType;
+import org.apache.syncope.common.rest.api.beans.TaskQuery;
import org.apache.syncope.common.rest.api.service.TaskService;
import org.apache.syncope.core.logic.notification.NotificationJob;
@@ -166,7 +166,7 @@ public abstract class AbstractTaskITCase extends AbstractITCase {
protected NotificationTaskTO findNotificationTaskBySender(final String sender) {
PagedResult<NotificationTaskTO> tasks =
- taskService.list(TaskType.NOTIFICATION, SyncopeClient.getTaskQueryBuilder().build());
+ taskService.list(TaskType.NOTIFICATION, new TaskQuery.Builder().build());
assertNotNull(tasks);
assertFalse(tasks.getResult().isEmpty());