Author: bdaw
Date: 2009-04-24 05:07:15 -0400 (Fri, 24 Apr 2009)
New Revision: 457
Added:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/AbstractQuery.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/GroupQueryImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/RoleQueryImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/UserQueryImpl.java
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySession.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/IdentitySessionImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java
Log:
some code for the query api
Added:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/AbstractQuery.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/AbstractQuery.java
(rev 0)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/AbstractQuery.java 2009-04-24
09:07:15 UTC (rev 457)
@@ -0,0 +1,136 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.api.query;
+
+import org.jboss.identity.idm.api.IdentitySearchCriteria;
+import org.jboss.identity.idm.api.SortOrder;
+import org.jboss.identity.idm.api.UnsupportedCriterium;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.IdentityType;
+import org.jboss.identity.idm.api.query.UserQuery;
+import org.jboss.identity.idm.api.query.UnsupportedQueryCriterium;
+import org.jboss.identity.idm.api.query.Query;
+import org.jboss.identity.idm.impl.api.IdentitySearchCriteriaImpl;
+import org.jboss.identity.idm.impl.api.model.SimpleGroup;
+import org.jboss.identity.idm.impl.api.model.GroupId;
+import org.jboss.identity.idm.impl.api.model.SimpleUser;
+import org.jboss.identity.idm.impl.api.session.IdentitySessionImpl;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class AbstractQuery implements Query
+{
+ //TODO: query should check criteria with features description
+
+ protected IdentitySessionImpl identitySession;
+
+ protected IdentitySearchCriteriaImpl searchCriteria = new
IdentitySearchCriteriaImpl();
+
+ public AbstractQuery(IdentitySessionImpl identitySession)
+ {
+ this.identitySession = identitySession;
+ }
+
+ public Query sort(SortOrder order) throws UnsupportedQueryCriterium
+ {
+ try
+ {
+ searchCriteria.sort(order);
+ }
+ catch (UnsupportedCriterium unsupportedCriterium)
+ {
+ throw new UnsupportedQueryCriterium(unsupportedCriterium);
+ }
+ return this;
+ }
+
+ public Query sortAttributeName(String name) throws UnsupportedQueryCriterium
+ {
+ try
+ {
+ searchCriteria.sortAttributeName(name);
+ }
+ catch (UnsupportedCriterium unsupportedCriterium)
+ {
+ throw new UnsupportedQueryCriterium(unsupportedCriterium);
+ }
+ return this;
+ }
+
+ public Query page(int firstResult, int maxResults) throws UnsupportedQueryCriterium
+ {
+ try
+ {
+ searchCriteria.page(firstResult, maxResults);
+ }
+ catch (UnsupportedCriterium unsupportedCriterium)
+ {
+ throw new UnsupportedQueryCriterium(unsupportedCriterium);
+ }
+ return this;
+ }
+
+ public Query attributeValuesFilter(String attributeName, String[] attributeValue)
throws UnsupportedQueryCriterium
+ {
+ try
+ {
+ searchCriteria.attributeValuesFilter(attributeName, attributeValue);
+ }
+ catch (UnsupportedCriterium unsupportedCriterium)
+ {
+ throw new UnsupportedQueryCriterium(unsupportedCriterium);
+ }
+ return this;
+ }
+
+
+ protected void checkNotNullArgument(Object arg, String name)
+ {
+ if (arg == null)
+ {
+ throw new IllegalArgumentException(name + " cannot be null");
+ }
+ }
+
+ protected Group createGroupFromId(String id)
+ {
+ return new SimpleGroup(new GroupId(id));
+ }
+
+ protected IdentityType createIdentityTypeFromId(String id)
+ {
+ if (GroupId.validateId(id))
+ {
+ GroupId groupId = new GroupId(id);
+
+ return new SimpleGroup(groupId);
+ }
+ else
+ {
+ return new SimpleUser(id);
+ }
+ }
+}
Added:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/GroupQueryImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/GroupQueryImpl.java
(rev 0)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/GroupQueryImpl.java 2009-04-24
09:07:15 UTC (rev 457)
@@ -0,0 +1,286 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.api.query;
+
+import org.jboss.identity.idm.api.query.GroupQuery;
+import org.jboss.identity.idm.api.query.UnsupportedQueryCriterium;
+import org.jboss.identity.idm.api.query.QueryException;
+import org.jboss.identity.idm.api.SortOrder;
+import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.User;
+import org.jboss.identity.idm.impl.NotYetImplementedException;
+import org.jboss.identity.idm.impl.api.session.IdentitySessionImpl;
+import org.jboss.identity.idm.impl.api.model.GroupId;
+import org.jboss.identity.idm.impl.api.model.SimpleGroup;
+import org.jboss.identity.idm.impl.api.model.SimpleUser;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class GroupQueryImpl extends AbstractQuery implements GroupQuery
+{
+ private GroupId groupId;
+
+ private String groupName;
+
+ private String groupType;
+
+ private Set<Group> associatedParentGroups = new HashSet<Group>();
+
+ private Set<Group> associatedChildGroups = new HashSet<Group>();
+
+ private Set<User> usersAssociated = new HashSet<User>();
+
+ private Set<User> usersRelated = new HashSet<User>();
+
+ private Set<User> usersConnectedByRole = new HashSet<User>();
+
+ public GroupQueryImpl(IdentitySessionImpl identitySession)
+ {
+ super(identitySession);
+ }
+
+ public Collection<Group> execute() throws QueryException
+ {
+ prepare();
+ throw new NotYetImplementedException();
+ }
+
+ private void prepare()
+ {
+ if (groupId == null && (groupName != null && groupType != null))
+ {
+ groupId = new GroupId(groupName, groupType);
+ }
+ }
+
+ public Group uniqueResult() throws QueryException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public List<Group> list() throws QueryException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public GroupQuery setId(String id)
+ {
+ groupId = new GroupId(id);
+ return this;
+ }
+
+ public GroupQuery setNameAndType(String name, String type)
+ {
+ groupId = new GroupId(name, type);
+ groupName = name;
+ groupType = type;
+
+ return this;
+ }
+
+ public GroupQuery setName(String name)
+ {
+ checkNotNullArgument(name, "Group name");
+ groupName = name;
+ return this;
+ }
+
+ public GroupQuery setType(String type)
+ {
+ checkNotNullArgument(type, "Group type");
+ groupType = type;
+ return this;
+ }
+
+ public GroupQuery addAssociatedGroup(Group group, boolean parent)
+ {
+ checkNotNullArgument(group, "Group");
+ if (parent)
+ {
+ associatedParentGroups.add(group);
+ }
+ else
+ {
+ associatedChildGroups.add(group);
+ }
+ return this;
+ }
+
+ public GroupQuery addAssociatedGroup(String id, boolean parent)
+ {
+ checkNotNullArgument(id, "Group id");
+
+ Group group = new SimpleGroup(new GroupId(id));
+
+ if (parent)
+ {
+ associatedParentGroups.add(group);
+ }
+ else
+ {
+ associatedChildGroups.add(group);
+ }
+
+
+ return this;
+ }
+
+ public GroupQuery addAssociatedGroups(Collection<Group> groups, boolean parent)
+ {
+ checkNotNullArgument(groups, "Groups");
+
+ if (parent)
+ {
+ associatedParentGroups.addAll(groups);
+ }
+ else
+ {
+ associatedChildGroups.addAll(groups);
+ }
+
+ return this;
+ }
+
+ public GroupQuery addAssociatedGroupsIds(Collection<String> ids, boolean
parent)
+ {
+ checkNotNullArgument(ids, "Groups ids");
+ for (String groupId : ids)
+ {
+ Group group = new SimpleGroup(new GroupId(groupId));
+
+ if (parent)
+ {
+ associatedParentGroups.add(group);
+ }
+ else
+ {
+ associatedChildGroups.add(group);
+ }
+ }
+
+ return this;
+ }
+
+ public GroupQuery addAssociatedUser(User user)
+ {
+ checkNotNullArgument(user, "User");
+ usersAssociated.add(user);
+ return this;
+ }
+
+ public GroupQuery addAssociatedUser(String id)
+ {
+ checkNotNullArgument(id, "User id");
+ usersAssociated.add(new SimpleUser(id));
+ return this;
+ }
+
+ public GroupQuery addAssociatedUsers(Collection<User> users)
+ {
+ checkNotNullArgument(users, "Users");
+ usersAssociated.addAll(users);
+ return this;
+ }
+
+ public GroupQuery addAssociatedUsersIds(Collection<String> ids)
+ {
+ checkNotNullArgument(ids, "Users ids");
+ for (String id : ids)
+ {
+ usersAssociated.add(new SimpleUser(id));
+ }
+ return this;
+ }
+
+ public GroupQuery addUserConnectedByRole(User user)
+ {
+ checkNotNullArgument(user, "User");
+ usersConnectedByRole.add(user);
+ return this;
+ }
+
+ public GroupQuery addUserConnectedByRole(String id)
+ {
+ checkNotNullArgument(id, "User id");
+ usersConnectedByRole.add(new SimpleUser(id));
+ return this;
+ }
+
+ public GroupQuery addUsersConnectedByRole(Collection<User> users)
+ {
+ checkNotNullArgument(users, "Users");
+ usersConnectedByRole.addAll(users);
+ return this;
+ }
+
+ public GroupQuery addUsersIdsConnectedByRole(Collection<String> ids)
+ {
+ checkNotNullArgument(ids, "Users ids");
+ for (String id : ids)
+ {
+ usersConnectedByRole.add(new SimpleUser(id));
+ }
+ return this;
+ }
+
+ public GroupQuery addRelatedUser(User user)
+ {
+ checkNotNullArgument(user, "User");
+ usersRelated.add(user);
+ return this;
+ }
+
+ public GroupQuery addRelatedUser(String id)
+ {
+ checkNotNullArgument(id, "User id");
+ usersRelated.add(new SimpleUser(id));
+ return this;
+ }
+
+ public GroupQuery sort(SortOrder order) throws UnsupportedQueryCriterium
+ {
+ return (GroupQuery)super.sort(order);
+ }
+
+ public GroupQuery sortAttributeName(String name) throws UnsupportedQueryCriterium
+ {
+ return (GroupQuery)super.sortAttributeName(name);
+ }
+
+ public GroupQuery page(int firstResult, int maxResults) throws
UnsupportedQueryCriterium
+ {
+ return (GroupQuery)super.page(firstResult, maxResults);
+ }
+
+ public GroupQuery attributeValuesFilter(String attributeName, String[] attributeValue)
throws UnsupportedQueryCriterium
+ {
+ return (GroupQuery)super.attributeValuesFilter(attributeName, attributeValue);
+ }
+}
Added:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/RoleQueryImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/RoleQueryImpl.java
(rev 0)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/RoleQueryImpl.java 2009-04-24
09:07:15 UTC (rev 457)
@@ -0,0 +1,161 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.api.query;
+
+import org.jboss.identity.idm.api.query.RoleQuery;
+import org.jboss.identity.idm.api.query.GroupQuery;
+import org.jboss.identity.idm.api.query.UnsupportedQueryCriterium;
+import org.jboss.identity.idm.api.query.QueryException;
+import org.jboss.identity.idm.api.SortOrder;
+import org.jboss.identity.idm.api.Role;
+import org.jboss.identity.idm.api.User;
+import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.RoleType;
+import org.jboss.identity.idm.api.IdentityType;
+import org.jboss.identity.idm.impl.api.session.IdentitySessionImpl;
+import org.jboss.identity.idm.impl.api.model.SimpleUser;
+import org.jboss.identity.idm.impl.api.model.GroupId;
+import org.jboss.identity.idm.impl.api.model.SimpleGroup;
+import org.jboss.identity.idm.impl.api.model.SimpleRoleType;
+import org.jboss.identity.idm.impl.NotYetImplementedException;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class RoleQueryImpl extends AbstractQuery implements RoleQuery
+{
+
+ private User user;
+
+ private Group group;
+
+ private RoleType roleType;
+
+ public RoleQueryImpl(IdentitySessionImpl identitySession)
+ {
+ super(identitySession);
+ }
+
+ public Collection<Role> execute() throws QueryException
+ {
+ throw new NotYetImplementedException();
+
+ }
+
+ public Role uniqueResult() throws QueryException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public List<Role> list() throws QueryException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public RoleQuery setUser(User user)
+ {
+ checkNotNullArgument(user, "User");
+ this.user = user;
+ return this;
+ }
+
+ public RoleQuery setUser(String id)
+ {
+ checkNotNullArgument(id, "User id");
+ this.user = new SimpleUser(id);
+ return this;
+ }
+
+ public RoleQuery setGroup(Group group)
+ {
+ checkNotNullArgument(group, "Group");
+ this.group = group;
+ return this;
+ }
+
+ public RoleQuery setGroup(String id)
+ {
+ checkNotNullArgument(id, "Group id");
+ this.group = new SimpleGroup(new GroupId(id));
+ return this;
+ }
+
+ public RoleQuery setRoleType(RoleType roleType)
+ {
+ checkNotNullArgument(roleType, "RoleType");
+ this.roleType = roleType;
+ return this;
+ }
+
+ public RoleQuery setRoleType(String roleTypeName)
+ {
+ checkNotNullArgument(roleTypeName, "RoleType name");
+ this.roleType = new SimpleRoleType(roleTypeName);
+ return this;
+ }
+
+ public RoleQuery setIdentityType(IdentityType identityType)
+ {
+ checkNotNullArgument(identityType, "IdentityType");
+ if (identityType instanceof User)
+ {
+ this.user = (User)identityType;
+ }
+ else
+ {
+ this.group = (Group)identityType;
+ }
+ return this;
+ }
+
+ public RoleQuery setIdentityTypeId(String id)
+ {
+ checkNotNullArgument(id, "IdentityType id");
+ IdentityType identityType = createIdentityTypeFromId(id);
+ return setIdentityType(identityType);
+ }
+
+ public RoleQuery sort(SortOrder order) throws UnsupportedQueryCriterium
+ {
+ return (RoleQuery)super.sort(order);
+ }
+
+ public RoleQuery sortAttributeName(String name) throws UnsupportedQueryCriterium
+ {
+ return (RoleQuery)super.sortAttributeName(name);
+ }
+
+ public RoleQuery page(int firstResult, int maxResults) throws
UnsupportedQueryCriterium
+ {
+ return (RoleQuery)super.page(firstResult, maxResults);
+ }
+
+ public RoleQuery attributeValuesFilter(String attributeName, String[] attributeValue)
throws UnsupportedQueryCriterium
+ {
+ return (RoleQuery)super.attributeValuesFilter(attributeName, attributeValue);
+ }
+}
Added:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/UserQueryImpl.java
===================================================================
--- idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/UserQueryImpl.java
(rev 0)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/query/UserQueryImpl.java 2009-04-24
09:07:15 UTC (rev 457)
@@ -0,0 +1,193 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.identity.idm.impl.api.query;
+
+import org.jboss.identity.idm.api.query.UserQuery;
+import org.jboss.identity.idm.api.query.QueryException;
+import org.jboss.identity.idm.api.query.UnsupportedQueryCriterium;
+import org.jboss.identity.idm.api.User;
+import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.SortOrder;
+import org.jboss.identity.idm.impl.api.session.IdentitySessionImpl;
+import org.jboss.identity.idm.impl.NotYetImplementedException;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class UserQueryImpl extends AbstractQuery implements UserQuery
+{
+
+ private String userId;
+
+ private Set<Group> groupsAssociatedWith = new HashSet<Group>();
+
+ private Set<Group> groupsConnectedWithRole = new HashSet<Group>();
+
+ private Set<Group> groupsRelated = new HashSet<Group>();
+
+ public UserQueryImpl(IdentitySessionImpl identitySession)
+ {
+ super(identitySession);
+ }
+
+ public Collection<User> execute() throws QueryException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public User uniqueResult() throws QueryException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public List<User> list() throws QueryException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public UserQuery withUserId(String id)
+ {
+ checkNotNullArgument(id, "User id");
+ userId = id;
+ return this;
+ }
+
+ public UserQuery addAssociatedGroup(Group group)
+ {
+ checkNotNullArgument(group, "Group");
+ groupsAssociatedWith.add(group);
+ return this;
+ }
+
+ public UserQuery addAssociatedGroup(String id)
+ {
+ checkNotNullArgument(id, "Group id");
+ groupsAssociatedWith.add(createGroupFromId(id));
+ return this;
+ }
+
+ public UserQuery addAssociatedGroups(Collection<Group> groups)
+ {
+ checkNotNullArgument(groups, "Groups");
+ groupsAssociatedWith.addAll(groups);
+ return this;
+ }
+
+ public UserQuery addAssociatedGroupsIds(Collection<String> groups)
+ {
+ checkNotNullArgument(groups, "Groups");
+ for (String groupId : groups)
+ {
+ groupsAssociatedWith.add(createGroupFromId(groupId));
+ }
+ return this;
+ }
+
+ public UserQuery addGroupConnectedWithRole(Group group)
+ {
+ checkNotNullArgument(group, "Group");
+ groupsConnectedWithRole.add(group);
+ return this;
+ }
+
+ public UserQuery addGroupConnectedWithRole(String id)
+ {
+ checkNotNullArgument(id, "Group id");
+ groupsConnectedWithRole.add(createGroupFromId(id));
+ return this;
+ }
+
+ public UserQuery addGroupsConnectedWithRole(Collection<Group> groups)
+ {
+ checkNotNullArgument(groups, "Groups");
+ groupsConnectedWithRole.addAll(groups);
+ return this;
+ }
+
+ public UserQuery addGroupsIdsConnectedWithRole(Collection<String> groups)
+ {
+ checkNotNullArgument(groups, "Groups");
+ for (String groupId : groups)
+ {
+ groupsConnectedWithRole.add(createGroupFromId(groupId));
+ }
+ return this;
+ }
+
+ public UserQuery addRelatedGroup(Group group)
+ {
+ checkNotNullArgument(group, "Group");
+ groupsRelated.add(group);
+ return this;
+ }
+
+ public UserQuery addRelatedGroup(String id)
+ {
+ checkNotNullArgument(id, "Group id");
+ groupsRelated.add(createGroupFromId(id));
+ return this;
+ }
+
+ public UserQuery addRelatedGroups(Collection<Group> group)
+ {
+ checkNotNullArgument(group, "Group");
+ groupsRelated.addAll(group);
+ return this;
+ }
+
+ public UserQuery addRelatedGroupsIds(Collection<String> ids)
+ {
+ checkNotNullArgument(ids, "Groups ids");
+ for (String id : ids)
+ {
+ groupsRelated.add(createGroupFromId(id));
+ }
+ return this;
+ }
+
+ public UserQuery sort(SortOrder order) throws UnsupportedQueryCriterium
+ {
+ return (UserQuery)super.sort(order);
+ }
+
+ public UserQuery sortAttributeName(String name) throws UnsupportedQueryCriterium
+ {
+ return (UserQuery)super.sortAttributeName(name);
+ }
+
+ public UserQuery page(int firstResult, int maxResults) throws
UnsupportedQueryCriterium
+ {
+ return (UserQuery)super.page(firstResult, maxResults);
+ }
+
+ public UserQuery attributeValuesFilter(String attributeName, String[] attributeValue)
throws UnsupportedQueryCriterium
+ {
+ return (UserQuery)super.attributeValuesFilter(attributeName, attributeValue);
+ }
+}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/IdentitySessionImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/IdentitySessionImpl.java 2009-04-23
15:09:40 UTC (rev 456)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/IdentitySessionImpl.java 2009-04-24
09:07:15 UTC (rev 457)
@@ -30,6 +30,9 @@
import org.jboss.identity.idm.api.RelationshipManager;
import org.jboss.identity.idm.api.AttributesManager;
import org.jboss.identity.idm.api.RoleManager;
+import org.jboss.identity.idm.api.query.UserQuery;
+import org.jboss.identity.idm.api.query.GroupQuery;
+import org.jboss.identity.idm.api.query.RoleQuery;
import org.jboss.identity.idm.exception.IdentityException;
import org.jboss.identity.idm.exception.FeatureNotSupportedException;
import org.jboss.identity.idm.spi.store.IdentityStoreSession;
@@ -45,6 +48,10 @@
import org.jboss.identity.idm.impl.api.session.managers.AttributesManagerImpl;
import org.jboss.identity.idm.impl.api.session.managers.RoleManagerImpl;
import org.jboss.identity.idm.impl.api.session.SimpleTransactionImpl;
+import org.jboss.identity.idm.impl.api.query.UserQueryImpl;
+import org.jboss.identity.idm.impl.api.query.GroupQueryImpl;
+import org.jboss.identity.idm.impl.api.query.RoleQueryImpl;
+import org.jboss.identity.idm.impl.NotYetImplementedException;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -164,4 +171,26 @@
return roleManager;
}
+
+ public UserQuery createUserQuery()
+ {
+ return new UserQueryImpl(this);
+
+ }
+
+ public GroupQuery createGroupQuery()
+ {
+ return new GroupQueryImpl(this);
+
+ }
+
+ public RoleQuery createRoleQuery() throws FeatureNotSupportedException
+ {
+ if
(!getSessionContext().getIdentityStoreRepository().getSupportedFeatures().isNamedRelationshipsSupported())
+ {
+ throw new FeatureNotSupportedException("Role management not supported by
underlaying configured identity stores");
+ }
+
+ return new RoleQueryImpl(this);
+ }
}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-04-23
15:09:40 UTC (rev 456)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-04-24
09:07:15 UTC (rev 457)
@@ -177,8 +177,8 @@
}
}
-
+
protected Group createGroupFromId(String id)
{
return new SimpleGroup(new GroupId(id));
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java 2009-04-23
15:09:40 UTC (rev 456)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AttributesManagerImpl.java 2009-04-24
09:07:15 UTC (rev 457)
@@ -316,12 +316,11 @@
getRepository().updateCredential(getInvocationContext(),
createIdentityObject(identity), new PasswordCredential(password));
}
- public boolean hasCredential(User identity, CredentialType credentialType) throws
IdentityException
+ public boolean isCredentialTypeSupported(CredentialType credentialType) throws
IdentityException
{
- checkNotNullArgument(identity, "User");
checkNotNullArgument(credentialType, "CredentialType");
- return
getRepository().getSupportedFeatures().isCredentialSupported(createIdentityObject(identity).getIdentityType(),
new SimpleCredentialType(credentialType.getName()));
+ return
getRepository().getSupportedFeatures().isCredentialSupported(getUserObjectType(), new
SimpleCredentialType(credentialType.getName()));
}
public boolean validateCredentials(User identity, Credential[] credentials) throws
IdentityException
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java 2009-04-23
15:09:40 UTC (rev 456)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/OrganizationTest.java 2009-04-24
09:07:15 UTC (rev 457)
@@ -29,7 +29,6 @@
import org.jboss.identity.idm.api.IdentitySessionFactory;
import org.jboss.identity.idm.api.Attribute;
import org.jboss.identity.idm.api.AttributeDescription;
-import org.jboss.identity.idm.api.CredentialType;
import org.jboss.identity.idm.api.Credential;
import org.jboss.identity.idm.p3p.P3PConstants;
@@ -305,7 +304,7 @@
// Credential
User anotherOne = bdawidowUser;
//session.getPersistenceManager().createUser("blah1");
- assertTrue(session.getAttributesManager().hasCredential(anotherOne,
PasswordCredential.TYPE));
+
assertTrue(session.getAttributesManager().isCredentialTypeSupported(PasswordCredential.TYPE));
// #1
session.getAttributesManager().updatePassword(anotherOne, "secret");
@@ -334,7 +333,7 @@
// #3
- if (session.getAttributesManager().hasCredential(anotherOne,
BinaryCredential.TYPE))
+ if
(session.getAttributesManager().isCredentialTypeSupported(BinaryCredential.TYPE))
{
// 500 kilobytes
byte[] cert = new byte[512000];
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java 2009-04-23
15:09:40 UTC (rev 456)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/AttributesManager.java 2009-04-24
09:07:15 UTC (rev 457)
@@ -267,12 +267,11 @@
void updatePassword(User identity, String password) throws IdentityException;
/**
- * Check if identity can be protected with a given credential type
+ * Check if user can be protected with a given credential type
*
- * @param identity
* @param credentialType
*/
- boolean hasCredential(User identity, CredentialType credentialType) throws
IdentityException;
+ boolean isCredentialTypeSupported(CredentialType credentialType) throws
IdentityException;
/**
* Validate credential for a given identity
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySession.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySession.java 2009-04-23
15:09:40 UTC (rev 456)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySession.java 2009-04-24
09:07:15 UTC (rev 457)
@@ -24,6 +24,9 @@
import org.jboss.identity.idm.exception.IdentityException;
import org.jboss.identity.idm.exception.FeatureNotSupportedException;
+import org.jboss.identity.idm.api.query.RoleQuery;
+import org.jboss.identity.idm.api.query.GroupQuery;
+import org.jboss.identity.idm.api.query.UserQuery;
/**
* Expose all identity management operations within a given realm
@@ -104,4 +107,23 @@
*/
RoleManager getRoleManager() throws FeatureNotSupportedException ;
+ /**
+ *
+ * @return
+ */
+ UserQuery createUserQuery();
+
+ /**
+ *
+ * @return
+ */
+ GroupQuery createGroupQuery();
+
+ /**
+ *
+ * @return
+ */
+ RoleQuery createRoleQuery() throws FeatureNotSupportedException;
+
+
}
\ No newline at end of file
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java 2009-04-23
15:09:40 UTC (rev 456)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java 2009-04-24
09:07:15 UTC (rev 457)
@@ -45,6 +45,10 @@
*/
RelationshipManagerFeaturesDescription getFeaturesDescription();
+ /**
+ *
+ * @return
+ */
IdentitySearchCriteria createIdentitySearchConstraints();
// Assignation
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java 2009-04-23
15:09:40 UTC (rev 456)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java 2009-04-24
09:07:15 UTC (rev 457)
@@ -23,6 +23,7 @@
package org.jboss.identity.idm.api;
import org.jboss.identity.idm.exception.IdentityException;
+import org.jboss.identity.idm.api.query.RoleQuery;
import java.util.Collection;
import java.util.Map;
@@ -47,6 +48,10 @@
*/
RoleManagerFeaturesDescription getSupportedFeatures();
+ /**
+ *
+ * @return
+ */
IdentitySearchCriteria createIdentitySearchConstraints();
// RoleType