Author: bdaw
Date: 2009-03-23 15:20:55 -0400 (Mon, 23 Mar 2009)
New Revision: 398
Added:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchConstraintType.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchConstraints.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchCriteria.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/SortOrder.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/UnsupportedConstraint.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/search/
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/search/IdentityObjectSearchConstraints.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityObjectSearchConstraintType.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/IdentitySearchConstraintsImpl.java
Removed:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchControl.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/searchcontrol/
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/AttributeFilterSearchControl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/NameFilterSearchControl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/PageSearchControl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/SortByNameSearchControl.java
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManagerFeaturesDescription.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/RelationshipManagerFeaturesDescription.java
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/RoleManagerFeaturesDescription.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/query/GroupQuery.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/query/Query.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/query/RoleQuery.java
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/query/UserQuery.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/FeaturesMetaData.java
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStore.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/GroupId.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/PersistenceManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/FeaturesMetaDataImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/ModelTestCase.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/CommonIdentityStoreTest.java
Log:
Get rid of ugly search controls
Deleted:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/AttributeFilterSearchControl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/AttributeFilterSearchControl.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/AttributeFilterSearchControl.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -1,80 +0,0 @@
-/*
-* 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;
-
-import org.jboss.identity.idm.api.IdentitySearchControl;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
-
-import java.util.Map;
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
- * @version : 0.1 $
- */
-public class AttributeFilterSearchControl implements IdentitySearchControl,
IdentityObjectSearchControl
-{
- private final Map<String, String[]> attributes;
-
- public AttributeFilterSearchControl(Map<String, String[]> attributes)
- {
- if (attributes == null)
- {
- throw new IllegalArgumentException("attributes is null");
- }
- this.attributes = Collections.unmodifiableMap(attributes);
- }
-
- public Map<String, String[]> getValues()
- {
- return attributes;
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- AttributeFilterSearchControl that = (AttributeFilterSearchControl)o;
-
- if (!attributes.equals(that.attributes))
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- return attributes.hashCode();
- }
-}
Added:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/IdentitySearchConstraintsImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/IdentitySearchConstraintsImpl.java
(rev 0)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/IdentitySearchConstraintsImpl.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -0,0 +1,242 @@
+/*
+* 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;
+
+import org.jboss.identity.idm.api.IdentitySearchConstraints;
+import org.jboss.identity.idm.api.SortOrder;
+import org.jboss.identity.idm.api.UnsupportedConstraint;
+import org.jboss.identity.idm.spi.search.IdentityObjectSearchConstraints;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class IdentitySearchConstraintsImpl implements IdentitySearchConstraints,
IdentityObjectSearchConstraints
+{
+
+ private boolean sorted = false;
+
+ private String sortByName;
+
+ private boolean ascending = true;
+
+ private boolean paged = false;
+
+ private int firstResult;
+
+ private int maxResults;
+
+ private boolean filtered = false;
+
+ private final Map<String, String[]> attributes = new HashMap<String,
String[]>();
+
+ private String filter;
+
+ public IdentitySearchConstraintsImpl()
+ {
+
+ }
+
+ public IdentitySearchConstraints sort(SortOrder order) throws UnsupportedConstraint
+ {
+ sorted = true;
+ if (order.equals(SortOrder.ASCENDING))
+ {
+ ascending = true;
+ }
+ else
+ {
+ ascending = false;
+ }
+
+ return this;
+ }
+
+ public IdentitySearchConstraints sortAttributeName(String name) throws
UnsupportedConstraint
+ {
+ sorted = true;
+ sortByName = name;
+
+ return this;
+ }
+
+ public IdentitySearchConstraints page(int firstResult, int maxResults) throws
UnsupportedConstraint
+ {
+ paged = true;
+
+ this.firstResult = firstResult;
+ this.maxResults = maxResults;
+
+
+ return this;
+ }
+
+ public IdentitySearchConstraints attributeValuesFilter(String attributeName, String[]
attributeValue) throws UnsupportedConstraint
+ {
+ if (attributeName == null)
+ {
+ throw new IllegalArgumentException("Attribute name is null");
+ }
+
+ if (attributeValue == null)
+ {
+ throw new IllegalArgumentException("Attribute values are null");
+
+ }
+
+ filtered = true;
+
+ attributes.put(attributeName, attributeValue);
+
+ return this;
+ }
+
+ public IdentitySearchConstraints idFilter(String filter) throws UnsupportedConstraint
+ {
+ if (filter == null)
+ {
+ throw new IllegalArgumentException("ID filter is null");
+ }
+
+ this.filter = filter;
+
+ return this;
+ }
+
+ public String getFilter()
+ {
+ return filter;
+ }
+
+ public boolean isSorted()
+ {
+ return sorted;
+ }
+
+ public boolean isAscending()
+ {
+ return ascending;
+ }
+
+ public String getSortAttributeName()
+ {
+ return sortByName;
+ }
+
+ public boolean isPaged()
+ {
+ return paged;
+ }
+
+ public int getFirstResult()
+ {
+ return firstResult;
+ }
+
+ public int getMaxResults()
+ {
+ return maxResults;
+ }
+
+ public boolean isFiltered()
+ {
+ return filtered;
+ }
+
+ public Map<String, String[]> getValues()
+ {
+ return attributes;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ IdentitySearchConstraintsImpl that = (IdentitySearchConstraintsImpl)o;
+
+ if (ascending != that.ascending)
+ {
+ return false;
+ }
+ if (filtered != that.filtered)
+ {
+ return false;
+ }
+ if (firstResult != that.firstResult)
+ {
+ return false;
+ }
+ if (maxResults != that.maxResults)
+ {
+ return false;
+ }
+ if (paged != that.paged)
+ {
+ return false;
+ }
+ if (sorted != that.sorted)
+ {
+ return false;
+ }
+ if (!attributes.equals(that.attributes))
+ {
+ return false;
+ }
+ if (filter != null ? !filter.equals(that.filter) : that.filter != null)
+ {
+ return false;
+ }
+ if (sortByName != null ? !sortByName.equals(that.sortByName) : that.sortByName !=
null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = (sorted ? 1 : 0);
+ result = 31 * result + (sortByName != null ? sortByName.hashCode() : 0);
+ result = 31 * result + (ascending ? 1 : 0);
+ result = 31 * result + (paged ? 1 : 0);
+ result = 31 * result + firstResult;
+ result = 31 * result + maxResults;
+ result = 31 * result + (filtered ? 1 : 0);
+ result = 31 * result + attributes.hashCode();
+ result = 31 * result + (filter != null ? filter.hashCode() : 0);
+ return result;
+ }
+}
Deleted:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/NameFilterSearchControl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/NameFilterSearchControl.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/NameFilterSearchControl.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -1,74 +0,0 @@
-/*
-* 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;
-
-import org.jboss.identity.idm.api.IdentitySearchControl;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
- * @version : 0.1 $
- */
-public class NameFilterSearchControl implements IdentitySearchControl,
IdentityObjectSearchControl
-{
-
- private final String filter;
-
- public NameFilterSearchControl(String filter)
- {
- this.filter = filter;
- }
-
- public String getFilter()
- {
- return filter;
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- NameFilterSearchControl that = (NameFilterSearchControl)o;
-
- if (filter != null ? !filter.equals(that.filter) : that.filter != null)
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- return filter != null ? filter.hashCode() : 0;
- }
-}
Deleted:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/PageSearchControl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/PageSearchControl.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/PageSearchControl.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -1,87 +0,0 @@
-/*
-* 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;
-
-import org.jboss.identity.idm.api.IdentitySearchControl;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
- * @version : 0.1 $
- */
-public class PageSearchControl implements IdentitySearchControl,
IdentityObjectSearchControl
-{
- private final int offset;
-
- private final int limit;
-
- public PageSearchControl(int offset, int limit)
- {
- this.offset = offset;
- this.limit = limit;
- }
-
- public int getOffset()
- {
- return offset;
- }
-
- public int getLimit()
- {
- return limit;
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- PageSearchControl that = (PageSearchControl)o;
-
- if (limit != that.limit)
- {
- return false;
- }
- if (offset != that.offset)
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = offset;
- result = 31 * result + limit;
- return result;
- }
-}
Deleted:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/SortByNameSearchControl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/SortByNameSearchControl.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/SortByNameSearchControl.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -1,73 +0,0 @@
-/*
-* 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;
-
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
-import org.jboss.identity.idm.api.IdentitySearchControl;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
- * @version : 0.1 $
- */
-public class SortByNameSearchControl implements IdentitySearchControl,
IdentityObjectSearchControl
-{
- private final boolean ascending;
-
- public SortByNameSearchControl(boolean ascending)
- {
- this.ascending = ascending;
- }
-
- public boolean isAscending()
- {
- return ascending;
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- SortByNameSearchControl that = (SortByNameSearchControl)o;
-
- if (ascending != that.ascending)
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- return (ascending ? 1 : 0);
- }
-}
Modified: idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/GroupId.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/GroupId.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/model/GroupId.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -28,8 +28,12 @@
*/
public class GroupId
{
- public static final String PREFIX = "group:/";
+ public static final String PREFIX = "jbpid_group_id";
+ public static final String SEPARATOR = "_._._";
+
+ public static final String SEPARATOR_REGEX = "_\\._\\._";
+
private String name;
private String type;
@@ -56,11 +60,12 @@
throw new IllegalArgumentException("id is null");
}
- String[] parts = id.split("/");
+ String[] parts = id.split(SEPARATOR_REGEX);
if (!validateId(id))
{
- throw new IllegalArgumentException("group id not following required format:
group/type/name: " + id);
+ throw new IllegalArgumentException("group id not following required format:
" +
+ PREFIX + SEPARATOR + "groupType" + SEPARATOR + "name : "
+ id);
}
name = parts[2];
@@ -69,9 +74,9 @@
public static boolean validateId(String id)
{
- String[] parts = id.split("/");
+ String[] parts = id.split(SEPARATOR_REGEX);
- if (parts == null || parts.length != 3 || parts[0].equals(PREFIX.substring(0,
PREFIX.length())))
+ if (parts == null || parts.length != 3 || parts[0].equals(PREFIX.substring(0,
PREFIX.length() - 1)))
{
return false;
}
@@ -91,6 +96,6 @@
public String getId()
{
- return PREFIX + type + "/" + name;
+ return PREFIX + SEPARATOR + type + SEPARATOR + name;
}
}
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-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/AbstractManager.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -26,14 +26,14 @@
import org.jboss.identity.idm.api.User;
import org.jboss.identity.idm.api.Group;
import org.jboss.identity.idm.api.IdentityType;
-import org.jboss.identity.idm.api.IdentitySearchControl;
import org.jboss.identity.idm.api.Attribute;
+import org.jboss.identity.idm.api.IdentitySearchConstraints;
import org.jboss.identity.idm.spi.repository.IdentityStoreRepository;
import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
import org.jboss.identity.idm.spi.model.IdentityObject;
import org.jboss.identity.idm.spi.model.IdentityObjectType;
import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
+import org.jboss.identity.idm.spi.search.IdentityObjectSearchConstraints;
import org.jboss.identity.idm.impl.types.SimpleIdentityObject;
import org.jboss.identity.idm.impl.api.session.context.IdentitySessionContext;
import org.jboss.identity.idm.impl.api.session.IdentitySessionImpl;
@@ -41,6 +41,8 @@
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.SimpleAttribute;
+import org.jboss.identity.idm.impl.api.IdentitySearchConstraintsImpl;
+import org.jboss.identity.idm.exception.IdentityException;
import java.util.List;
import java.util.LinkedList;
@@ -63,6 +65,11 @@
return identitySession;
}
+ public IdentitySearchConstraints createIdentitySearchConstraints()
+ {
+ return new IdentitySearchConstraintsImpl();
+ }
+
protected IdentitySessionContext getSessionContext()
{
if (identitySession instanceof IdentitySessionImpl)
@@ -176,31 +183,21 @@
return new SimpleGroup(new GroupId(id));
}
- protected IdentityObjectSearchControl[] convertSearchControls(IdentitySearchControl[]
controls)
+ protected IdentityObjectSearchConstraints
convertSearchControls(IdentitySearchConstraints controls)
{
if (controls == null)
{
return null;
}
- //TODO: simple check
- List<IdentityObjectSearchControl> result = new
LinkedList<IdentityObjectSearchControl>();
-
- for (IdentitySearchControl control : controls)
+ if (controls instanceof IdentityObjectSearchConstraints)
{
- if (control instanceof IdentityObjectSearchControl)
- {
- result.add((IdentityObjectSearchControl)control);
- }
+ return (IdentityObjectSearchConstraints)controls;
}
-
- if (result.size() == 0)
+ else
{
- return null;
+ throw new IllegalArgumentException("Not supported IdentitySearchConstraints
implementation: " + controls.getClass());
}
-
- return result.toArray(new IdentityObjectSearchControl[result.size()]);
-
}
protected IdentityObjectType getUserObjectType()
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/PersistenceManagerImpl.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -27,12 +27,12 @@
import org.jboss.identity.idm.api.Group;
import org.jboss.identity.idm.api.IdentitySession;
import org.jboss.identity.idm.api.PersistenceManagerFeaturesDescription;
-import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.api.IdentitySearchConstraints;
+import org.jboss.identity.idm.api.IdentitySearchConstraintType;
import org.jboss.identity.idm.exception.IdentityException;
import org.jboss.identity.idm.spi.model.IdentityObjectType;
import org.jboss.identity.idm.spi.model.IdentityObject;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
-import org.jboss.identity.idm.impl.NotYetImplementedException;
+import org.jboss.identity.idm.spi.store.IdentityObjectSearchConstraintType;
import org.jboss.identity.idm.impl.api.session.managers.AbstractManager;
import org.jboss.identity.idm.impl.api.model.GroupId;
@@ -73,49 +73,38 @@
isIdentityObjectAddRemoveSupported(objectType);
}
- public boolean isUsersSearchControlSupported(IdentitySearchControl control)
+ public boolean isUsersSearchConstraintTypeSupported(IdentitySearchConstraintType
constraintType)
{
IdentityObjectType objectType =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
- if (control instanceof IdentityObjectSearchControl)
+ IdentityObjectSearchConstraintType constraint =
IdentityObjectSearchConstraintType.valueOf(constraintType.name());
+
+
+ if (constraint != null)
{
return
getSessionContext().getIdentityStoreRepository().getSupportedFeatures().
- isControlSupported(objectType, (IdentityObjectSearchControl)control);
+ isSearchConstraintTypeSupported(objectType, constraint);
}
return false;
}
- public boolean isUsersSearchControlSupported(Class controlClazz)
+ public boolean isGroupsSearchConstraintTypeSupported(String groupType,
IdentitySearchConstraintType constraintType)
{
- IdentityObjectType objectType =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
-
- return
getSessionContext().getIdentityStoreRepository().getSupportedFeatures().
- isControlSupported(objectType, controlClazz);
-
- }
-
- public boolean isGroupsSearchControlSupported(String groupType,
IdentitySearchControl control)
- {
IdentityObjectType objectType =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(groupType);
- if (control instanceof IdentityObjectSearchControl)
+ IdentityObjectSearchConstraintType constraint =
IdentityObjectSearchConstraintType.valueOf(constraintType.name());
+
+ if (constraint != null)
{
return
getSessionContext().getIdentityStoreRepository().getSupportedFeatures().
- isControlSupported(objectType, (IdentityObjectSearchControl)control);
+ isSearchConstraintTypeSupported(objectType, constraint);
}
return false;
}
- public boolean isGroupsSearchControlSupported(String groupType, Class
controlClazz)
- {
- IdentityObjectType objectType =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(groupType);
-
- return
getSessionContext().getIdentityStoreRepository().getSupportedFeatures().
- isControlSupported(objectType, controlClazz);
- }
};
}
@@ -213,7 +202,7 @@
return createUser(getRepository().findIdentityObject(getInvocationContext(), name,
getUserObjectType()));
}
- public Collection<User> findUser(IdentitySearchControl[] controls) throws
IdentityException
+ public Collection<User> findUser(IdentitySearchConstraints controls) throws
IdentityException
{
@@ -243,7 +232,7 @@
return createGroup(getRepository().findIdentityObject(getInvocationContext(),
id));
}
- public Collection<Group> findGroup(String groupType, IdentitySearchControl[]
controls) throws IdentityException
+ public Collection<Group> findGroup(String groupType, IdentitySearchConstraints
controls) throws IdentityException
{
checkNotNullArgument(groupType, "Group type");
@@ -263,7 +252,7 @@
{
checkNotNullArgument(groupType, "Group type");
- return findGroup(groupType, (IdentitySearchControl[]) null);
+ return findGroup(groupType, (IdentitySearchConstraints) null);
}
// public boolean isVirtual(User identity)
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RelationshipManagerImpl.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -28,13 +28,14 @@
import org.jboss.identity.idm.api.User;
import org.jboss.identity.idm.api.IdentityType;
import org.jboss.identity.idm.api.RelationshipManagerFeaturesDescription;
-import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.api.IdentitySearchConstraints;
+import org.jboss.identity.idm.api.IdentitySearchConstraintType;
import org.jboss.identity.idm.exception.IdentityException;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
import org.jboss.identity.idm.spi.model.IdentityObject;
import org.jboss.identity.idm.spi.model.IdentityObjectType;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.spi.store.IdentityObjectSearchConstraintType;
import org.jboss.identity.idm.impl.NotYetImplementedException;
import org.jboss.identity.idm.impl.api.session.managers.AbstractManager;
@@ -102,49 +103,36 @@
}
}
- public boolean isIdentitiesSearchControlSupported(IdentitySearchControl
control)
+ public boolean
isIdentitiesSearchConstraintTypeSupported(IdentitySearchConstraintType constraintType)
{
IdentityObjectType objectType =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
- if (control instanceof IdentityObjectSearchControl)
+ IdentityObjectSearchConstraintType constraint =
IdentityObjectSearchConstraintType.valueOf(constraintType.name());
+
+
+ if (constraint != null)
{
return
getSessionContext().getIdentityStoreRepository().getSupportedFeatures().
- isControlSupported(objectType, (IdentityObjectSearchControl)control);
+ isSearchConstraintTypeSupported(objectType, constraint);
}
return false;
}
-
- public boolean isIdentitiesSearchControlSupported(Class controlClazz)
+ public boolean isGroupsSearchConstraintTypeSupported(String groupType,
IdentitySearchConstraintType constraintType)
{
- IdentityObjectType objectType =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType();
-
- return
getSessionContext().getIdentityStoreRepository().getSupportedFeatures().
- isControlSupported(objectType, controlClazz);
-
- }
-
- public boolean isGroupsSearchControlSupported(String groupType,
IdentitySearchControl control)
- {
IdentityObjectType objectType =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(groupType);
- if (control instanceof IdentityObjectSearchControl)
+ IdentityObjectSearchConstraintType constraint =
IdentityObjectSearchConstraintType.valueOf(constraintType.name());
+
+ if (constraint != null)
{
return
getSessionContext().getIdentityStoreRepository().getSupportedFeatures().
- isControlSupported(objectType, (IdentityObjectSearchControl)control);
+ isSearchConstraintTypeSupported(objectType, constraint);
}
return false;
}
-
- public boolean isGroupsSearchControlSupported(String groupType, Class
controlClazz)
- {
- IdentityObjectType objectType =
getSessionContext().getIdentityObjectTypeMapper().getIdentityObjectType(groupType);
-
- return
getSessionContext().getIdentityStoreRepository().getSupportedFeatures().
- isControlSupported(objectType, controlClazz);
- }
};
}
@@ -479,7 +467,7 @@
return true;
}
- public Collection<Group> findAssociatedGroups(Group group, String groupType,
boolean parent, boolean inherited, IdentitySearchControl[] controls) throws
IdentityException
+ public Collection<Group> findAssociatedGroups(Group group, String groupType,
boolean parent, boolean inherited, IdentitySearchConstraints controls) throws
IdentityException
{
checkNotNullArgument(group, "Group");
@@ -509,7 +497,7 @@
}
- public Collection<Group> findAssociatedGroups(String groupId, String groupType,
boolean parent, boolean inherited, IdentitySearchControl[] controls) throws
IdentityException
+ public Collection<Group> findAssociatedGroups(String groupId, String groupType,
boolean parent, boolean inherited, IdentitySearchConstraints controls) throws
IdentityException
{
checkNotNullArgument(groupId, "Group Id");
// checkNotNullArgument(groupType, "Group type");
@@ -527,7 +515,7 @@
return findAssociatedGroups(group, groupType, parent, inherited, null);
}
- public Collection<Group> findAssociatedGroups(User identity, String groupType,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<Group> findAssociatedGroups(User identity, String groupType,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(identity, "User");
//checkNotNullArgument(groupType, "Group type");
@@ -549,7 +537,7 @@
return identities;
}
- public Collection<Group> findAssociatedGroups(String userName, String groupType,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<Group> findAssociatedGroups(String userName, String groupType,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(userName, "User name");
//checkNotNullArgument(groupType, "Group type");
@@ -567,7 +555,7 @@
return findAssociatedGroups(identity, groupType, null);
}
- public Collection<Group> findAssociatedGroups(User identity,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<Group> findAssociatedGroups(User identity,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(identity, "User");
@@ -589,7 +577,7 @@
return identities;
}
- public Collection<Group> findAssociatedGroups(String userName,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<Group> findAssociatedGroups(String userName,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(userName, "User name");
@@ -602,10 +590,10 @@
{
checkNotNullArgument(identity, "User");
- return findAssociatedGroups(identity, new IdentitySearchControl[] {});
+ return findAssociatedGroups(identity, (IdentitySearchConstraints)null);
}
- public Collection<User> findAssociatedUsers(Group group, boolean inherited,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<User> findAssociatedUsers(Group group, boolean inherited,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(group, "Group");
@@ -633,7 +621,7 @@
return identities;
}
- public Collection<User> findAssociatedUsers(String groupId, boolean inherited,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<User> findAssociatedUsers(String groupId, boolean inherited,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(groupId, "Group Id");
@@ -649,7 +637,7 @@
return findAssociatedUsers(group, inherited, null);
}
- public Collection<Group> findRelatedGroups(User user, String groupType,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<Group> findRelatedGroups(User user, String groupType,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(user, "User");
@@ -670,7 +658,7 @@
return identities;
}
- public Collection<Group> findRelatedGroups(String userName, String groupType,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<Group> findRelatedGroups(String userName, String groupType,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(userName, "User name");
@@ -679,7 +667,7 @@
return findRelatedGroups(user, groupType, controls);
}
- public Collection<User> findRelatedUsers(Group group, IdentitySearchControl[]
controls) throws IdentityException
+ public Collection<User> findRelatedUsers(Group group, IdentitySearchConstraints
controls) throws IdentityException
{
checkNotNullArgument(group, "Group");
@@ -705,7 +693,7 @@
return identities;
}
- public Collection<User> findRelatedUsers(String groupId, IdentitySearchControl[]
controls) throws IdentityException
+ public Collection<User> findRelatedUsers(String groupId,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(groupId, "Group Id");
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/api/session/managers/RoleManagerImpl.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -30,15 +30,15 @@
import org.jboss.identity.idm.api.Group;
import org.jboss.identity.idm.api.IdentityType;
import org.jboss.identity.idm.api.RoleManagerFeaturesDescription;
-import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.api.IdentitySearchConstraints;
+import org.jboss.identity.idm.api.IdentitySearchConstraintType;
import org.jboss.identity.idm.exception.IdentityException;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
import org.jboss.identity.idm.spi.model.IdentityObjectType;
import org.jboss.identity.idm.spi.model.IdentityObject;
import org.jboss.identity.idm.spi.exception.OperationNotSupportedException;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
-import org.jboss.identity.idm.impl.api.session.managers.AbstractManager;
+import org.jboss.identity.idm.spi.store.IdentityObjectSearchConstraintType;
import org.jboss.identity.idm.impl.api.model.SimpleRoleType;
import org.jboss.identity.idm.impl.api.model.SimpleRole;
@@ -75,17 +75,14 @@
return
getSessionContext().getIdentityStoreRepository().getSupportedFeatures().isRelationshipNameAddRemoveSupported();
}
- public boolean isRoleTypeSearchControlSupported(Class controlClazz)
+ public boolean
isRoleTypeSearchConstraintTypeSupported(IdentitySearchConstraintType constraintType)
{
- return
getSessionContext().getIdentityStoreRepository().getSupportedFeatures().isRoleNameControlSupported(controlClazz);
- }
+ IdentityObjectSearchConstraintType constraint =
IdentityObjectSearchConstraintType.valueOf(constraintType.name());
- public boolean isRoleTypeSearchControlSupported(IdentitySearchControl control)
- {
- if (control instanceof IdentityObjectSearchControl)
+ if (constraint != null)
{
return
getSessionContext().getIdentityStoreRepository().getSupportedFeatures().
- isRoleNameControlSupported((IdentityObjectSearchControl)control);
+ isRoleNameSearchConstraintSupported(constraint);
}
else
{
@@ -160,7 +157,7 @@
return null;
}
- public Collection<RoleType> findRoleTypes(IdentitySearchControl[] controls)
throws IdentityException
+ public Collection<RoleType> findRoleTypes(IdentitySearchConstraints controls)
throws IdentityException
{
@@ -280,7 +277,7 @@
return findRoleTypes(identity, group, null);
}
- public Collection<RoleType> findRoleTypes(User identity, Group group,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<RoleType> findRoleTypes(User identity, Group group,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(identity, "User");
checkNotNullArgument(group, "Group");
@@ -298,7 +295,7 @@
}
- public Collection<RoleType> findRoleTypes(String userName, String groupId,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<RoleType> findRoleTypes(String userName, String groupId,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(userName, "User name");
checkNotNullArgument(groupId, "Group Id");
@@ -316,7 +313,7 @@
return findUserRoleTypes(identity, null);
}
- public Collection<RoleType> findUserRoleTypes(User identity,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<RoleType> findUserRoleTypes(User identity,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(identity, "User");
@@ -341,7 +338,7 @@
}
- public Collection<RoleType> findUserRoleTypes(String userName,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<RoleType> findUserRoleTypes(String userName,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(userName, "User name");
@@ -357,7 +354,7 @@
return findGroupRoleTypes(group, null);
}
- public Collection<RoleType> findGroupRoleTypes(String groupId,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<RoleType> findGroupRoleTypes(String groupId,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(groupId, "Group Id");
@@ -366,7 +363,7 @@
return findGroupRoleTypes(group, controls);
}
- public Collection<RoleType> findGroupRoleTypes(Group group,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<RoleType> findGroupRoleTypes(Group group,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(group, "Group");
@@ -391,7 +388,7 @@
}
- public Collection<Group> findGroupsWithRelatedRole(User identity,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<Group> findGroupsWithRelatedRole(User identity,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(identity, "User");
@@ -411,7 +408,7 @@
return identities;
}
- public Collection<Group> findGroupsWithRelatedRole(String userName,
IdentitySearchControl[] controls) throws IdentityException
+ public Collection<Group> findGroupsWithRelatedRole(String userName,
IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(userName, "User name");
@@ -420,7 +417,7 @@
return findGroupsWithRelatedRole(user, controls);
}
- public Collection<Group> findGroupsWithRelatedRole(User identity, String
groupType, IdentitySearchControl[] controls) throws IdentityException
+ public Collection<Group> findGroupsWithRelatedRole(User identity, String
groupType, IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(identity, "User");
checkNotNullArgument(groupType, "Group type");
@@ -444,7 +441,7 @@
return identities;
}
- public Collection<Group> findGroupsWithRelatedRole(String userName, String
groupType, IdentitySearchControl[] controls) throws IdentityException
+ public Collection<Group> findGroupsWithRelatedRole(String userName, String
groupType, IdentitySearchConstraints controls) throws IdentityException
{
checkNotNullArgument(userName, "User name");
checkNotNullArgument(groupType, "Group type");
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/IdentityStoreCacheSupport.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -30,16 +30,13 @@
import org.jboss.identity.idm.spi.model.IdentityObjectType;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.spi.search.IdentityObjectSearchConstraints;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.Map;
import java.util.Set;
import java.util.Collection;
-import java.util.List;
-import java.util.Arrays;
-import java.util.HashSet;
/**
* Helper class providing caching support for IdentityStore. Stores search methods
results using hash from a set of used
@@ -459,7 +456,7 @@
}
protected void putIdentityObjectSearchIntoCache(IdentityObjectType identityType,
- IdentityObjectSearchControl[] controls,
+ IdentityObjectSearchConstraints
controls,
Collection<IdentityObject>
results)
{
Fqn nodeFqn = createIOTypeSearchNodeFQN(identityType, getControlsHash(controls));
@@ -475,7 +472,7 @@
}
protected Collection<IdentityObject>
getIdentityObjectSearchFromCache(IdentityObjectType identityType,
-
IdentityObjectSearchControl[] controls)
+
IdentityObjectSearchConstraints controls)
{
Fqn nodeFqn = createIOTypeSearchNodeFQN(identityType, getControlsHash(controls));
@@ -502,7 +499,7 @@
protected void putIdentityObjectSearchToCache(IdentityObject identity,
IdentityObjectRelationshipType
relationshipType,
boolean parent,
- IdentityObjectSearchControl[] controls,
+ IdentityObjectSearchConstraints controls,
Collection<IdentityObject> results)
{
@@ -524,7 +521,7 @@
protected Collection<IdentityObject>
getIdentityObjectSearchFromCache(IdentityObject identity,
IdentityObjectRelationshipType relationshipType,
boolean parent,
-
IdentityObjectSearchControl[] controls)
+
IdentityObjectSearchConstraints controls)
{
Fqn nodeFqn = createIOSearchNodeFQN(identity, relationshipType, parent,
getControlsHash(controls));
@@ -814,7 +811,7 @@
- protected void putRelationshipNamesSearchIntoCache(IdentityObjectSearchControl[]
controls, Set<String> results)
+ protected void putRelationshipNamesSearchIntoCache(IdentityObjectSearchConstraints
controls, Set<String> results)
{
Fqn fqn = createRelationshipNamesAllSearchFqn(getControlsHash(controls));
@@ -831,7 +828,7 @@
}
- protected Set<String>
getRelationshipNamesSearchFromCache(IdentityObjectSearchControl[] controls)
+ protected Set<String>
getRelationshipNamesSearchFromCache(IdentityObjectSearchConstraints controls)
{
Fqn fqn = createRelationshipNamesAllSearchFqn(getControlsHash(controls));
@@ -856,7 +853,7 @@
}
protected void putRelationshipNamesSearchIntoCache(IdentityObject identity,
- IdentityObjectSearchControl[]
controls,
+ IdentityObjectSearchConstraints
controls,
Set<String> results)
{
@@ -875,7 +872,7 @@
}
- protected Set<String> getRelationshipNamesSearchFromCache(IdentityObject
identity, IdentityObjectSearchControl[] controls)
+ protected Set<String> getRelationshipNamesSearchFromCache(IdentityObject
identity, IdentityObjectSearchConstraints controls)
{
@@ -899,16 +896,14 @@
return null;
}
- private int getControlsHash(IdentityObjectSearchControl[] controls)
+ private int getControlsHash(IdentityObjectSearchConstraints controls)
{
// Convert controls to Set to have the same hashcode regardles order of controls
int hashcode = 0;
if (controls != null)
{
- List<IdentityObjectSearchControl> list = Arrays.asList(controls);
- Set<IdentityObjectSearchControl> controlsSet = new
HashSet<IdentityObjectSearchControl>(list);
- hashcode = controlsSet.hashCode();
+ hashcode = controls.hashCode();
}
return hashcode;
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -25,31 +25,20 @@
import org.jboss.identity.idm.spi.store.IdentityStore;
import org.jboss.identity.idm.spi.store.FeaturesMetaData;
import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
-import org.jboss.identity.idm.spi.store.IdentityStoreSession;
import org.jboss.identity.idm.spi.model.IdentityObject;
import org.jboss.identity.idm.spi.model.IdentityObjectType;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
import org.jboss.identity.idm.spi.model.IdentityObjectCredential;
-import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
import org.jboss.identity.idm.spi.exception.OperationNotSupportedException;
-import
org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
-import
org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
+import org.jboss.identity.idm.spi.search.IdentityObjectSearchConstraints;
import org.jboss.identity.idm.exception.IdentityException;
-import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.CacheFactory;
-import org.jboss.cache.lock.IsolationLevel;
-import org.jboss.cache.transaction.GenericTransactionManagerLookup;
-import org.jboss.cache.config.Configuration;
import java.util.Map;
import java.util.Collection;
import java.util.Set;
import java.util.logging.Logger;
-import java.io.File;
/**
* IdentityStore implementation that wraps another IdentityStore and uses JBossCache to
cache results.
@@ -201,7 +190,7 @@
public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCtx,
IdentityObjectType identityType,
- IdentityObjectSearchControl[]
controls) throws IdentityException
+ IdentityObjectSearchConstraints
controls) throws IdentityException
{
Collection<IdentityObject> results =
getIdentityObjectSearchFromCache(identityType, controls);
@@ -231,7 +220,7 @@
IdentityObject identity,
IdentityObjectRelationshipType
relationshipType,
boolean parent,
- IdentityObjectSearchControl[]
controls) throws IdentityException
+ IdentityObjectSearchConstraints
controls) throws IdentityException
{
Collection<IdentityObject> results =
getIdentityObjectSearchFromCache(identity, relationshipType, parent, controls);
@@ -353,7 +342,7 @@
}
public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
- IdentityObjectSearchControl[] controls) throws
IdentityException, OperationNotSupportedException
+ IdentityObjectSearchConstraints controls)
throws IdentityException, OperationNotSupportedException
{
Set<String> results = getRelationshipNamesSearchFromCache(controls);
@@ -370,7 +359,7 @@
public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObject identity,
- IdentityObjectSearchControl[] controls) throws
IdentityException, OperationNotSupportedException
+ IdentityObjectSearchConstraints controls)
throws IdentityException, OperationNotSupportedException
{
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/FallbackIdentityStoreRepository.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -27,13 +27,12 @@
import org.jboss.identity.idm.spi.store.FeaturesMetaData;
import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
import org.jboss.identity.idm.spi.store.IdentityStoreSession;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.spi.store.IdentityObjectSearchConstraintType;
import org.jboss.identity.idm.spi.model.IdentityObject;
import org.jboss.identity.idm.spi.model.IdentityObjectType;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
import org.jboss.identity.idm.spi.exception.OperationNotSupportedException;
-import
org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
import
org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
import
org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
import org.jboss.identity.idm.spi.configuration.IdentityRepositoryConfigurationContext;
@@ -41,10 +40,9 @@
import org.jboss.identity.idm.spi.model.IdentityObjectCredential;
import org.jboss.identity.idm.spi.model.IdentityObjectCredentialType;
import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
+import org.jboss.identity.idm.spi.search.IdentityObjectSearchConstraints;
import org.jboss.identity.idm.exception.IdentityException;
import org.jboss.identity.idm.impl.store.SimpleIdentityStoreInvocationContext;
-import org.jboss.identity.idm.impl.api.PageSearchControl;
-import org.jboss.identity.idm.impl.api.SortByNameSearchControl;
import org.jboss.identity.idm.impl.api.session.managers.RoleManagerImpl;
import java.util.Map;
@@ -58,7 +56,6 @@
import java.util.Comparator;
import java.util.Arrays;
import java.util.ArrayList;
-import java.util.LinkedHashSet;
/**
* <p>In FallbackIdentityStoreRepository one IdentityStore plays the role of
default store. Any operation that cannot be
@@ -150,16 +147,11 @@
return
defaultIdentityStore.getSupportedFeatures().isNamedRelationshipsSupported();
}
- public boolean isControlSupported(IdentityObjectType identityObjectType,
IdentityObjectSearchControl control)
+ public boolean isSearchConstraintTypeSupported(IdentityObjectType
identityObjectType, IdentityObjectSearchConstraintType storeSearchConstraint)
{
- return
resolveIdentityStore(identityObjectType).getSupportedFeatures().isControlSupported(identityObjectType,
control);
+ return
resolveIdentityStore(identityObjectType).getSupportedFeatures().isSearchConstraintTypeSupported(identityObjectType,
storeSearchConstraint);
}
- public boolean isControlSupported(IdentityObjectType identityObjectType,
Class<?> controlClazz)
- {
- return
resolveIdentityStore(identityObjectType).getSupportedFeatures().isControlSupported(identityObjectType,
controlClazz);
- }
-
public Set<String> getSupportedIdentityObjectTypes()
{
Set<String> supportedIOTs = new HashSet<String>();
@@ -232,36 +224,22 @@
}
- public boolean isRoleNameControlSupported(IdentityObjectSearchControl control)
+ public boolean
isRoleNameSearchConstraintSupported(IdentityObjectSearchConstraintType constraint)
{
// If there is any IdentityStore that supports named relationships...
for (IdentityStore identityStore : getIdentityStoreMappings().values())
{
if (identityStore.getSupportedFeatures().isNamedRelationshipsSupported()
&&
-
identityStore.getSupportedFeatures().isRoleNameControlSupported(control))
+
identityStore.getSupportedFeatures().isRoleNameSearchConstraintSupported(constraint))
{
return true;
}
}
return
defaultIdentityStore.getSupportedFeatures().isNamedRelationshipsSupported() &&
-
defaultIdentityStore.getSupportedFeatures().isRoleNameControlSupported(control);
+
defaultIdentityStore.getSupportedFeatures().isRoleNameSearchConstraintSupported(constraint);
}
- public boolean isRoleNameControlSupported(Class<?> controlClazz)
- {
- // If there is any IdentityStore that supports named relationships...
- for (IdentityStore identityStore : getIdentityStoreMappings().values())
- {
- if (identityStore.getSupportedFeatures().isNamedRelationshipsSupported()
&&
-
identityStore.getSupportedFeatures().isRoleNameControlSupported(controlClazz))
- {
- return true;
- }
- }
- return
defaultIdentityStore.getSupportedFeatures().isNamedRelationshipsSupported() &&
-
defaultIdentityStore.getSupportedFeatures().isRoleNameControlSupported(controlClazz);
- }
- };
+ };
}
@@ -412,7 +390,7 @@
return defaultIdentityStore.findIdentityObject(invocationContext, id);
}
- public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObjectType
identityType, IdentityObjectSearchControl[] controls) throws IdentityException
+ public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObjectType
identityType, IdentityObjectSearchConstraints controls) throws IdentityException
{
IdentityStore targetStore = resolveIdentityStore(identityType);
IdentityStoreInvocationContext targetCtx = resolveInvocationContext(targetStore,
invocationCtx);
@@ -424,7 +402,7 @@
IdentityObject identity,
IdentityObjectRelationshipType
relationshipType,
boolean parent,
- IdentityObjectSearchControl[]
controls) throws IdentityException
+ IdentityObjectSearchConstraints
constraints) throws IdentityException
{
// Check in the mapped store and merge with default
@@ -437,7 +415,7 @@
if (mappedStore == defaultIdentityStore)
{
- return defaultIdentityStore.findIdentityObject(defaultCtx, identity,
relationshipType, parent, controls);
+ return defaultIdentityStore.findIdentityObject(defaultCtx, identity,
relationshipType, parent, constraints);
}
Collection<IdentityObject> results = new LinkedList<IdentityObject>();
@@ -445,7 +423,7 @@
if (relationshipType == null ||
!RoleManagerImpl.ROLE.getName().equals(relationshipType.getName()) ||
mappedStore.getSupportedFeatures().isNamedRelationshipsSupported())
{
- results = mappedStore.findIdentityObject(mappedCtx, identity, relationshipType,
parent, controls);
+ results = mappedStore.findIdentityObject(mappedCtx, identity, relationshipType,
parent, constraints);
}
IdentityObject defaultStoreIdentityObject = null;
@@ -461,27 +439,8 @@
if (defaultStoreIdentityObject != null)
{
- Collection<IdentityObject> objects =
defaultIdentityStore.findIdentityObject(defaultCtx, identity, relationshipType, parent,
controls);
+ Collection<IdentityObject> objects =
defaultIdentityStore.findIdentityObject(defaultCtx, identity, relationshipType, parent,
constraints);
- PageSearchControl pageSearchControl = null;
- SortByNameSearchControl sortSearchControl = null;
-
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (control instanceof PageSearchControl)
- {
- pageSearchControl = (PageSearchControl)control;
- }
- else if (control instanceof SortByNameSearchControl)
- {
- sortSearchControl = (SortByNameSearchControl)control;
- }
- }
- }
-
-
// If default store contain related relationships merge and sort/page once more
if (objects != null && objects.size() != 0)
{
@@ -489,15 +448,15 @@
results.addAll(objects);
//TODO: hardcoded - expects List
- if (pageSearchControl != null && results instanceof List)
+ if (constraints != null && constraints.isPaged() && results
instanceof List)
{
- results = cutPageFromResults((List<IdentityObject>)results,
pageSearchControl);
+ results = cutPageFromResults((List<IdentityObject>)results,
constraints);
}
//TODO: hardcoded - expects List
- if (sortSearchControl != null && results instanceof List)
+ if (constraints != null && constraints.isSorted() && results
instanceof List)
{
- sortByName((List<IdentityObject>)results,
sortSearchControl.isAscending());
+ sortByName((List<IdentityObject>)results,
constraints.isAscending());
}
}
}
@@ -691,7 +650,7 @@
return name;
}
- public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObjectSearchControl[] controls) throws IdentityException,
OperationNotSupportedException
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObjectSearchConstraints controls) throws IdentityException,
OperationNotSupportedException
{
Set<String> results = new HashSet<String>();
@@ -709,7 +668,7 @@
return results;
}
- public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObject identity, IdentityObjectSearchControl[] controls) throws IdentityException,
OperationNotSupportedException
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObject identity, IdentityObjectSearchConstraints controls) throws
IdentityException, OperationNotSupportedException
{
IdentityStore toStore = resolveIdentityStore(identity);
@@ -1040,10 +999,10 @@
}
//TODO: other way
- private List<IdentityObject> cutPageFromResults(List<IdentityObject>
objects, PageSearchControl pageControl)
+ private List<IdentityObject> cutPageFromResults(List<IdentityObject>
objects, IdentityObjectSearchConstraints constraints)
{
List<IdentityObject> results = new LinkedList<IdentityObject>();
- for (int i = pageControl.getOffset(); i < pageControl.getOffset() +
pageControl.getLimit(); i++)
+ for (int i = constraints.getFirstResult(); i < constraints.getFirstResult() +
constraints.getMaxResults(); i++)
{
if (i < objects.size())
{
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/repository/WrapperIdentityStoreRepository.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -27,9 +27,7 @@
import org.jboss.identity.idm.spi.store.IdentityStoreSession;
import org.jboss.identity.idm.spi.store.FeaturesMetaData;
import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
-import
org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
import
org.jboss.identity.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
-import
org.jboss.identity.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
import org.jboss.identity.idm.spi.configuration.IdentityRepositoryConfigurationContext;
import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
import org.jboss.identity.idm.spi.model.IdentityObject;
@@ -39,7 +37,7 @@
import org.jboss.identity.idm.spi.model.IdentityObjectCredential;
import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
import org.jboss.identity.idm.spi.exception.OperationNotSupportedException;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.spi.search.IdentityObjectSearchConstraints;
import org.jboss.identity.idm.exception.IdentityException;
import org.jboss.identity.idm.impl.store.SimpleIdentityStoreInvocationContext;
@@ -165,7 +163,7 @@
public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCtx,
IdentityObjectType identityType,
- IdentityObjectSearchControl[]
controls) throws IdentityException
+ IdentityObjectSearchConstraints
controls) throws IdentityException
{
return
defaultIdentityStore.findIdentityObject(resolveIdentityStoreInvocationContext(invocationCtx),
identityType, controls);
}
@@ -174,7 +172,7 @@
IdentityObject identity,
IdentityObjectRelationshipType
relationshipType,
boolean parent,
- IdentityObjectSearchControl[]
controls) throws IdentityException
+ IdentityObjectSearchConstraints
controls) throws IdentityException
{
return
defaultIdentityStore.findIdentityObject(resolveIdentityStoreInvocationContext(invocationCtx),
identity, relationshipType, parent, controls);
}
@@ -239,14 +237,14 @@
}
public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
- IdentityObjectSearchControl[] controls) throws
IdentityException, OperationNotSupportedException
+ IdentityObjectSearchConstraints controls)
throws IdentityException, OperationNotSupportedException
{
return
defaultIdentityStore.getRelationshipNames(resolveIdentityStoreInvocationContext(ctx),
controls);
}
public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObject identity,
- IdentityObjectSearchControl[] controls) throws
IdentityException, OperationNotSupportedException
+ IdentityObjectSearchConstraints controls)
throws IdentityException, OperationNotSupportedException
{
return
defaultIdentityStore.getRelationshipNames(resolveIdentityStoreInvocationContext(ctx),
identity, controls);
}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/FeaturesMetaDataImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/FeaturesMetaDataImpl.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/FeaturesMetaDataImpl.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -35,8 +35,8 @@
import org.jboss.identity.idm.spi.model.IdentityObjectCredentialType;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
import org.jboss.identity.idm.spi.model.IdentityObjectType;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
import org.jboss.identity.idm.spi.store.FeaturesMetaData;
+import org.jboss.identity.idm.spi.store.IdentityObjectSearchConstraintType;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -46,7 +46,7 @@
{
private Set<String> supportedTypeNames = new HashSet<String>();
- private final Set<Class<?>> supportedSearchControls;
+ private final Set<IdentityObjectSearchConstraintType>
supportedSearchConstraintTypes;
private final Map<String, Set<String>> supportedCredentials;
@@ -59,7 +59,7 @@
public FeaturesMetaDataImpl(IdentityStoreConfigurationMetaData configurationMD,
- Set<Class<?>> supportedControls,
+ Set<IdentityObjectSearchConstraintType>
supportedControls,
boolean namedRelationshipsSupport,
Set<String> readOnlyObjectTypes)
{
@@ -84,7 +84,7 @@
this.supportedCredentials = Collections.unmodifiableMap(supportedCredentials);
- this.supportedSearchControls = Collections.unmodifiableSet(supportedControls);
+ this.supportedSearchConstraintTypes =
Collections.unmodifiableSet(supportedControls);
@@ -162,24 +162,15 @@
return namedRelationshipsSupport;
}
- public boolean isControlSupported(IdentityObjectType identityObjectType,
IdentityObjectSearchControl control)
+ public boolean isSearchConstraintTypeSupported(IdentityObjectType identityObjectType,
IdentityObjectSearchConstraintType storeSearchConstraint)
{
- if (supportedSearchControls.contains(control.getClass()))
+ if (supportedSearchConstraintTypes.contains(storeSearchConstraint))
{
return true;
}
return false;
}
- public boolean isControlSupported(IdentityObjectType identityObjectType,
Class<?> controlClazz)
- {
- if (supportedSearchControls.contains(controlClazz))
- {
- return true;
- }
- return false;
- }
-
public Set<String> getSupportedIdentityObjectTypes()
{
return supportedTypeNames;
@@ -222,15 +213,10 @@
return false;
}
- public boolean isRoleNameControlSupported(IdentityObjectSearchControl control)
+ public boolean isRoleNameSearchConstraintSupported(IdentityObjectSearchConstraintType
constraint)
{
// For now simple - use the same allowed controls list for everything
- return isNamedRelationshipsSupported() && isControlSupported(null,
control);
+ return isNamedRelationshipsSupported() &&
isSearchConstraintTypeSupported(null, constraint);
}
- public boolean isRoleNameControlSupported(Class<?> controlClazz)
- {
- // For now simple - use the same allowed controls list for everything
- return isNamedRelationshipsSupported() && isControlSupported(null,
controlClazz);
- }
}
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -41,10 +41,6 @@
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.criterion.Restrictions;
import org.jboss.identity.idm.exception.IdentityException;
-import org.jboss.identity.idm.impl.api.AttributeFilterSearchControl;
-import org.jboss.identity.idm.impl.api.NameFilterSearchControl;
-import org.jboss.identity.idm.impl.api.PageSearchControl;
-import org.jboss.identity.idm.impl.api.SortByNameSearchControl;
import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject;
import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute;
import
org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute;
@@ -69,11 +65,12 @@
import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
import org.jboss.identity.idm.spi.model.IdentityObjectType;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
import org.jboss.identity.idm.spi.store.FeaturesMetaData;
import org.jboss.identity.idm.spi.store.IdentityStore;
import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
import org.jboss.identity.idm.spi.store.IdentityStoreSession;
+import org.jboss.identity.idm.spi.store.IdentityObjectSearchConstraintType;
+import org.jboss.identity.idm.spi.search.IdentityObjectSearchConstraints;
//import javax.persistence.Persistence;
import javax.naming.InitialContext;
@@ -141,7 +138,8 @@
// TODO: rewrite this into some more handy object
private IdentityStoreConfigurationMetaData configurationMD;
- private static Set<Class<?>> supportedIdentityObjectSearchControls = new
HashSet<Class<?>>();
+ private static Set<IdentityObjectSearchConstraintType>
supportedIdentityObjectSearchControls =
+ new HashSet<IdentityObjectSearchConstraintType>();
private static Set<String> supportedCredentialTypes = new
HashSet<String>();
@@ -157,10 +155,10 @@
static {
// List all supported controls classes
- supportedIdentityObjectSearchControls.add(PageSearchControl.class);
- supportedIdentityObjectSearchControls.add(SortByNameSearchControl.class);
- supportedIdentityObjectSearchControls.add(AttributeFilterSearchControl.class);
- supportedIdentityObjectSearchControls.add(NameFilterSearchControl.class);
+
supportedIdentityObjectSearchControls.add(IdentityObjectSearchConstraintType.ATTRIBUTE_FILTER);
+
supportedIdentityObjectSearchControls.add(IdentityObjectSearchConstraintType.NAME_FILTER);
+
supportedIdentityObjectSearchControls.add(IdentityObjectSearchConstraintType.PAGE);
+
supportedIdentityObjectSearchControls.add(IdentityObjectSearchConstraintType.SORT);
// credential types supported by this impl
supportedCredentialTypes.add(CREDENTIAL_TYPE_PASSWORD);
@@ -602,40 +600,10 @@
@SuppressWarnings("unchecked")
public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext ctx,
IdentityObjectType identityType,
- IdentityObjectSearchControl[]
controls) throws IdentityException
+ IdentityObjectSearchConstraints
constraints) throws IdentityException
{
checkIOType(identityType);
- checkControls(controls);
-
- PageSearchControl pageSearchControl = null;
- SortByNameSearchControl sortSearchControl = null;
- AttributeFilterSearchControl attributeFilterControl = null;
- NameFilterSearchControl nameFilterSearchControl = null;
-
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (control instanceof PageSearchControl)
- {
- pageSearchControl = (PageSearchControl)control;
- }
- else if (control instanceof SortByNameSearchControl)
- {
- sortSearchControl = (SortByNameSearchControl)control;
- }
- else if (control instanceof AttributeFilterSearchControl)
- {
- attributeFilterControl = (AttributeFilterSearchControl)control;
- }
- else if (control instanceof NameFilterSearchControl)
- {
- nameFilterSearchControl = (NameFilterSearchControl)control;
- }
- }
- }
-
HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx,
identityType);
List<IdentityObject> results;
@@ -647,9 +615,9 @@
Query q = null;
- if (sortSearchControl != null)
+ if (constraints != null && constraints.isSorted())
{
- if (sortSearchControl.isAscending())
+ if (constraints.isAscending())
{
q =
hibernateSession.createQuery(HibernateIdentityObject.findIdentityObjectsByTypeOrderedByNameAsc);
}
@@ -663,22 +631,22 @@
q =
hibernateSession.createQuery(HibernateIdentityObject.findIdentityObjectsByType);
}
- if (pageSearchControl != null)
+ if (constraints != null && constraints.isPaged())
{
- if (pageSearchControl.getLimit() > 0)
+ if (constraints.getMaxResults() > 0)
{
- q.setMaxResults(pageSearchControl.getLimit());
+ q.setMaxResults(constraints.getMaxResults());
}
- q.setFirstResult(pageSearchControl.getOffset());
+ q.setFirstResult(constraints.getFirstResult());
}
q.setParameter("realm", getRealm(hibernateSession, ctx))
.setParameter("typeName", hibernateType.getName());
- if (nameFilterSearchControl != null)
+ if (constraints != null && constraints.getFilter() != null)
{
- q.setParameter("nameFilter",
nameFilterSearchControl.getFilter().replaceAll("\\*", "%"));
+ q.setParameter("nameFilter",
constraints.getFilter().replaceAll("\\*", "%"));
}
else
{
@@ -695,9 +663,9 @@
throw new IdentityException("Cannot find IdentityObjects with type
'" + identityType.getName() + "'", e);
}
- if (attributeFilterControl != null)
+ if (constraints != null && constraints.isFiltered())
{
- filterByAttributesValues(results, attributeFilterControl.getValues());
+ filterByAttributesValues(results, constraints.getValues());
}
return results;
@@ -716,7 +684,7 @@
IdentityObject identity,
IdentityObjectRelationshipType
relationshipType,
boolean parent,
- IdentityObjectSearchControl[]
controls) throws IdentityException
+ IdentityObjectSearchConstraints
constraints) throws IdentityException
{
//TODO:test
@@ -724,43 +692,13 @@
List<IdentityObject> results;
- checkControls(controls);
-
- PageSearchControl pageSearchControl = null;
- SortByNameSearchControl sortSearchControl = null;
- AttributeFilterSearchControl attributeFilterControl = null;
- NameFilterSearchControl nameFilterSearchControl = null;
-
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (control instanceof PageSearchControl)
- {
- pageSearchControl = (PageSearchControl)control;
- }
- else if (control instanceof SortByNameSearchControl)
- {
- sortSearchControl = (SortByNameSearchControl)control;
- }
- else if (control instanceof AttributeFilterSearchControl)
- {
- attributeFilterControl = (AttributeFilterSearchControl)control;
- }
- else if (control instanceof NameFilterSearchControl)
- {
- nameFilterSearchControl = (NameFilterSearchControl)control;
- }
- }
- }
-
boolean orderByName = false;
boolean ascending = true;
- if (sortSearchControl != null)
+ if (constraints != null && constraints.isSorted())
{
orderByName = true;
- ascending = sortSearchControl.isAscending();
+ ascending = constraints.isAscending();
}
try
@@ -834,9 +772,9 @@
q.setParameter("relType", relationshipType.getName());
}
- if (nameFilterSearchControl != null)
+ if (constraints != null && constraints.getFilter() != null)
{
- q.setParameter("nameFilter",
nameFilterSearchControl.getFilter().replaceAll("\\*", "%"));
+ q.setParameter("nameFilter",
constraints.getFilter().replaceAll("\\*", "%"));
}
else
{
@@ -844,12 +782,12 @@
}
- if (pageSearchControl != null)
+ if (constraints != null && constraints.isPaged())
{
- q.setFirstResult(pageSearchControl.getOffset());
- if (pageSearchControl.getLimit() > 0)
+ q.setFirstResult(constraints.getFirstResult());
+ if (constraints.getMaxResults() > 0)
{
- q.setMaxResults(pageSearchControl.getLimit());
+ q.setMaxResults(constraints.getMaxResults());
}
}
@@ -864,9 +802,9 @@
throw new IdentityException("Cannot find IdentityObjects", e);
}
- if (attributeFilterControl != null)
+ if (constraints != null && constraints.isFiltered())
{
- filterByAttributesValues(results, attributeFilterControl.getValues());
+ filterByAttributesValues(results, constraints.getValues());
}
return results;
@@ -1172,51 +1110,20 @@
return name;
}
- public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObjectSearchControl[] controls) throws IdentityException,
OperationNotSupportedException
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObjectSearchConstraints constraints) throws IdentityException,
OperationNotSupportedException
{
Set<String> names = null;
Session em = getHibernateSession(ctx);
- checkControls(controls);
-
- PageSearchControl pageSearchControl = null;
- SortByNameSearchControl sortSearchControl = null;
- AttributeFilterSearchControl attributeFilterControl = null;
- NameFilterSearchControl nameFilterSearchControl = null;
-
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (control instanceof PageSearchControl)
- {
- pageSearchControl = (PageSearchControl)control;
- }
- else if (control instanceof SortByNameSearchControl)
- {
- sortSearchControl = (SortByNameSearchControl)control;
- }
- else if (control instanceof AttributeFilterSearchControl)
- {
- attributeFilterControl = (AttributeFilterSearchControl)control;
- }
- else if (control instanceof NameFilterSearchControl)
- {
- nameFilterSearchControl = (NameFilterSearchControl)control;
- }
- }
- }
-
-
try
{
Query q = null;
- if (sortSearchControl != null)
+ if (constraints != null && constraints.isSorted())
{
- if (sortSearchControl.isAscending())
+ if (constraints.isAscending())
{
q =
em.createQuery(HibernateIdentityObjectRelationshipName.findIdentityObjectRelationshipNamesOrderedByNameAsc);
}
@@ -1232,9 +1139,9 @@
q.setParameter("realm", getRealm(em, ctx));
- if (nameFilterSearchControl != null)
+ if (constraints != null && constraints.getFilter() != null)
{
- q.setParameter("nameFilter",
nameFilterSearchControl.getFilter().replaceAll("\\*", "%"));
+ q.setParameter("nameFilter",
constraints.getFilter().replaceAll("\\*", "%"));
}
else
{
@@ -1242,12 +1149,12 @@
}
- if (pageSearchControl != null)
+ if (constraints != null && constraints.isPaged())
{
- q.setFirstResult(pageSearchControl.getOffset());
- if (pageSearchControl.getLimit() > 0)
+ q.setFirstResult(constraints.getMaxResults());
+ if (constraints.getFirstResult() > 0)
{
- q.setMaxResults(pageSearchControl.getLimit());
+ q.setMaxResults(constraints.getMaxResults());
}
}
@@ -1266,10 +1173,10 @@
public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx)
throws IdentityException, OperationNotSupportedException
{
- return getRelationshipNames(ctx, new IdentityObjectSearchControl[]{});
+ return getRelationshipNames(ctx, (IdentityObjectSearchConstraints)null);
}
- public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObject identity, IdentityObjectSearchControl[] controls) throws IdentityException,
OperationNotSupportedException
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObject identity, IdentityObjectSearchConstraints constraints) throws
IdentityException, OperationNotSupportedException
{
Set<String> names;
@@ -1278,33 +1185,13 @@
Session em = getHibernateSession(ctx);
- checkControls(controls);
-
- PageSearchControl pageSearchControl = null;
- SortByNameSearchControl sortSearchControl = null;
-
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (control instanceof PageSearchControl)
- {
- pageSearchControl = (PageSearchControl)control;
- }
- else if (control instanceof SortByNameSearchControl)
- {
- sortSearchControl = (SortByNameSearchControl)control;
- }
- }
- }
-
try
{
Query q = null;
- if (sortSearchControl != null)
+ if (constraints != null)
{
- if (sortSearchControl.isAscending())
+ if (constraints.isAscending())
{
q =
em.createQuery(HibernateIdentityObjectRelationshipName.findIdentityObjectRelationshipNamesForIdentityObjectOrderedByNameAsc);
}
@@ -1320,12 +1207,12 @@
q.setParameter("identityObject", hibernateObject);
- if (pageSearchControl != null)
+ if (constraints != null && constraints.isPaged())
{
- q.setFirstResult(pageSearchControl.getOffset());
- if (pageSearchControl.getLimit() > 0)
+ q.setFirstResult(constraints.getFirstResult());
+ if (constraints.getMaxResults() > 0)
{
- q.setMaxResults(pageSearchControl.getLimit());
+ q.setMaxResults(constraints.getMaxResults());
}
}
@@ -2152,19 +2039,19 @@
return isAllowNotDefinedAttributes;
}
- private void checkControls(IdentityObjectSearchControl[] controls) throws
IdentityException
- {
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (!supportedIdentityObjectSearchControls.contains(control.getClass()))
- {
- throw new IdentityException("IdentityObjectSearchControl not
supported by this IdentityStore: " + control.getClass());
- }
- }
- }
- }
+// private void checkControls(IdentityObjectSearchConstraints controls) throws
IdentityException
+// {
+// if (controls != null)
+// {
+// for (IdentityObjectSearchControl control : controls)
+// {
+// if (!supportedIdentityObjectSearchControls.contains(control.getClass()))
+// {
+// throw new IdentityException("IdentityObjectSearchControl not
supported by this IdentityStore: " + control.getClass());
+// }
+// }
+// }
+// }
/**
* Resolve store mapping for attribute name. If attribute is not mapped and store
doesn't allow not defined
Modified:
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
===================================================================
---
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/main/java/org/jboss/identity/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -58,11 +58,7 @@
import org.jboss.identity.idm.exception.IdentityException;
import org.jboss.identity.idm.impl.NotYetImplementedException;
-import org.jboss.identity.idm.impl.api.AttributeFilterSearchControl;
-import org.jboss.identity.idm.impl.api.NameFilterSearchControl;
-import org.jboss.identity.idm.impl.api.PageSearchControl;
import org.jboss.identity.idm.impl.api.SimpleAttribute;
-import org.jboss.identity.idm.impl.api.SortByNameSearchControl;
import org.jboss.identity.idm.impl.helper.Tools;
import org.jboss.identity.idm.impl.model.ldap.LDAPIdentityObjectImpl;
import org.jboss.identity.idm.impl.model.ldap.LDAPIdentityObjectRelationshipImpl;
@@ -78,11 +74,12 @@
import org.jboss.identity.idm.spi.model.IdentityObjectRelationship;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
import org.jboss.identity.idm.spi.model.IdentityObjectType;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
import org.jboss.identity.idm.spi.store.FeaturesMetaData;
import org.jboss.identity.idm.spi.store.IdentityStore;
import org.jboss.identity.idm.spi.store.IdentityStoreInvocationContext;
import org.jboss.identity.idm.spi.store.IdentityStoreSession;
+import org.jboss.identity.idm.spi.store.IdentityObjectSearchConstraintType;
+import org.jboss.identity.idm.spi.search.IdentityObjectSearchConstraints;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -105,7 +102,8 @@
IdentityStoreConfigurationMetaData configurationMD;
- private static Set<Class<?>> supportedSearchControls = new
HashSet<Class<?>>();
+ private static Set<IdentityObjectSearchConstraintType>
supportedSearchConstraintTypes =
+ new HashSet<IdentityObjectSearchConstraintType>();
// <IdentityObjectType name, <Attribute name, MD>
private Map<String, Map<String, IdentityObjectAttributeMetaData>>
attributesMetaData = new HashMap<String, Map<String,
IdentityObjectAttributeMetaData>>();
@@ -114,9 +112,9 @@
// List all supported controls classes
//TODO: attribute filter
- supportedSearchControls.add(SortByNameSearchControl.class);
- supportedSearchControls.add(PageSearchControl.class);
- supportedSearchControls.add(NameFilterSearchControl.class);
+ supportedSearchConstraintTypes.add(IdentityObjectSearchConstraintType.SORT);
+ supportedSearchConstraintTypes.add(IdentityObjectSearchConstraintType.PAGE);
+
supportedSearchConstraintTypes.add(IdentityObjectSearchConstraintType.NAME_FILTER);
//supportedSearchControls.add(AttributeFilterSearchControl.class);
}
@@ -146,7 +144,7 @@
}
}
- supportedFeatures = new FeaturesMetaDataImpl(configurationMD,
supportedSearchControls, false, readOnlyObjectTypes);
+ supportedFeatures = new FeaturesMetaDataImpl(configurationMD,
supportedSearchConstraintTypes, false, readOnlyObjectTypes);
// Attribute mappings - helper structures
@@ -551,48 +549,21 @@
return null;
}
- public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCtx, IdentityObjectType type,
IdentityObjectSearchControl[] controls) throws IdentityException
+ public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCtx,
+ IdentityObjectType type,
+ IdentityObjectSearchConstraints
constraints) throws IdentityException
{
- checkControls(controls);
-
//TODO: page control with LDAP request control
- PageSearchControl pageSearchControl = null;
- SortByNameSearchControl sortSearchControl = null;
- AttributeFilterSearchControl attributeFilterSearchControl = null;
- NameFilterSearchControl nameFilterSearchControl = null;
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (control instanceof PageSearchControl)
- {
- pageSearchControl = (PageSearchControl)control;
- }
- else if (control instanceof SortByNameSearchControl)
- {
- sortSearchControl = (SortByNameSearchControl)control;
- }
- else if (control instanceof AttributeFilterSearchControl)
- {
- attributeFilterSearchControl = (AttributeFilterSearchControl)control;
- }
- else if (control instanceof NameFilterSearchControl)
- {
- nameFilterSearchControl = (NameFilterSearchControl)control;
- }
- }
- }
-
String nameFilter = "*";
//Filter by name
- if (nameFilterSearchControl != null)
+ if (constraints != null && constraints.getFilter() != null)
{
- nameFilter = nameFilterSearchControl.getFilter();
+ nameFilter = constraints.getFilter();
}
@@ -610,9 +581,10 @@
Control[] requestControls = null;
// Sort control
- if (sortSearchControl != null)
+ if (constraints != null && constraints.isSorted())
{
//TODO: make criticallity optional
+ //TODO sort by attribute name
requestControls = new Control[]{
new SortControl(typeConfiguration.getIdAttributeName(),
Control.NONCRITICAL)
};
@@ -621,11 +593,11 @@
StringBuilder af = new StringBuilder();
// Filter by attribute values
- if (attributeFilterSearchControl != null)
+ if (constraints != null && constraints.isFiltered())
{
af.append("(&");
- for (Map.Entry<String, String[]> stringEntry :
attributeFilterSearchControl.getValues().entrySet())
+ for (Map.Entry<String, String[]> stringEntry :
constraints.getValues().entrySet())
{
for (String value : stringEntry.getValue())
{
@@ -672,11 +644,11 @@
{
ctx = (LdapContext)res.getObject();
String dn = ctx.getNameInNamespace();
- if (sortSearchControl != null)
+ if (constraints != null && constraints.isSorted())
{
// It seams that the sort order is not configurable and
// sort control returns entries in descending order by default...
- if (!sortSearchControl.isAscending())
+ if (!constraints.isAscending())
{
objects.addFirst(createIdentityObjectInstance(invocationCtx, type,
res.getAttributes(), dn));
}
@@ -718,9 +690,9 @@
}
}
- if (pageSearchControl != null)
+ if (constraints != null && constraints.isPaged())
{
- objects = (LinkedList)cutPageFromResults(objects, pageSearchControl);
+ objects = (LinkedList)cutPageFromResults(objects, constraints);
}
return objects;
@@ -732,44 +704,17 @@
}
- public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext ctx, IdentityObject identity,
IdentityObjectRelationshipType relationshipType, boolean parent,
IdentityObjectSearchControl[] controls) throws IdentityException
+ public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext ctx,
+ IdentityObject identity,
+ IdentityObjectRelationshipType
relationshipType,
+ boolean parent,
+ IdentityObjectSearchConstraints
constraints) throws IdentityException
{
//TODO: relationshipType is ignored - maybe check and allow only MEMBERSHIP?
- checkControls(controls);
-
- PageSearchControl pageSearchControl = null;
- SortByNameSearchControl sortSearchControl = null;
- AttributeFilterSearchControl attributeFilterSearchControl = null;
- NameFilterSearchControl nameFilterSearchControl = null;
-
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (control instanceof PageSearchControl)
- {
- pageSearchControl = (PageSearchControl)control;
- }
- else if (control instanceof SortByNameSearchControl)
- {
- sortSearchControl = (SortByNameSearchControl)control;
- }
- else if (control instanceof AttributeFilterSearchControl)
- {
- attributeFilterSearchControl = (AttributeFilterSearchControl)control;
- }
- else if (control instanceof NameFilterSearchControl)
- {
- nameFilterSearchControl = (NameFilterSearchControl)control;
- }
-
- }
- }
-
LDAPIdentityObjectImpl ldapFromIO = getSafeLDAPIO(ctx, identity);
LDAPIdentityObjectTypeConfiguration typeConfig = getTypeConfiguration(ctx,
identity.getIdentityType());
@@ -804,10 +749,10 @@
{
//TODO: use direct LDAP query instaed of other find method and add
attributesFilter
- if (nameFilterSearchControl != null)
+ if (constraints != null && constraints.getFilter() != null)
{
String name = Tools.stripDnToName(memberRef);
- String regex =
Tools.wildcardToRegex(nameFilterSearchControl.getFilter());
+ String regex = Tools.wildcardToRegex(constraints.getFilter());
if (Pattern.matches(regex, name))
{
@@ -853,9 +798,9 @@
String nameFilter = "*";
//Filter by name
- if (nameFilterSearchControl != null)
+ if (constraints != null && constraints.getFilter() != null)
{
- nameFilter = nameFilterSearchControl.getFilter();
+ nameFilter = constraints.getFilter();
}
Control[] requestControls = null;
@@ -863,11 +808,11 @@
StringBuilder af = new StringBuilder();
// Filter by attribute values
- if (attributeFilterSearchControl != null)
+ if (constraints != null && constraints.isFiltered())
{
af.append("(&");
- for (Map.Entry<String, String[]> stringEntry :
attributeFilterSearchControl.getValues().entrySet())
+ for (Map.Entry<String, String[]> stringEntry :
constraints.getValues().entrySet())
{
for (String value : stringEntry.getValue())
{
@@ -954,14 +899,14 @@
}
}
- if (pageSearchControl != null)
+ if (constraints != null && constraints.isPaged())
{
- objects = cutPageFromResults(objects, pageSearchControl);
+ objects = cutPageFromResults(objects, constraints);
}
- if (sortSearchControl != null)
+ if (constraints != null && constraints.isSorted())
{
- sortByName(objects, sortSearchControl.isAscending());
+ sortByName(objects, constraints.isAscending());
}
return objects;
@@ -1379,7 +1324,7 @@
throw new OperationNotSupportedException("Named relationships are not
supported by this implementation of LDAP IdentityStore");
}
- public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObjectSearchControl[] controls) throws IdentityException,
OperationNotSupportedException
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObjectSearchConstraints controls) throws IdentityException,
OperationNotSupportedException
{
throw new OperationNotSupportedException("Named relationships are not
supported by this implementation of LDAP IdentityStore");
}
@@ -1389,7 +1334,7 @@
throw new OperationNotSupportedException("Named relationships are not
supported by this implementation of LDAP IdentityStore");
}
- public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObject identity, IdentityObjectSearchControl[] controls) throws IdentityException,
OperationNotSupportedException
+ public Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObject identity, IdentityObjectSearchConstraints controls) throws
IdentityException, OperationNotSupportedException
{
throw new OperationNotSupportedException("Named relationships are not
supported by this implementation of LDAP IdentityStore");
@@ -2095,20 +2040,6 @@
return this.getClass().getName() + "[" + getId() +"]";
}
- private void checkControls(IdentityObjectSearchControl[] controls) throws
IdentityException
- {
- if (controls != null)
- {
- for (IdentityObjectSearchControl control : controls)
- {
- if (!supportedSearchControls.contains(control.getClass()))
- {
- throw new IdentityException("IdentityObjectSearchControl not
supported by this IdentityStore: " + control.getClass());
- }
- }
- }
- }
-
private void sortByName(List<IdentityObject> objects, final boolean ascending)
{
Collections.sort(objects, new Comparator<IdentityObject>(){
@@ -2127,10 +2058,10 @@
}
//TODO: dummy and inefficient temporary workaround. Need to be implemented with ldap
request control
- private List<IdentityObject> cutPageFromResults(List<IdentityObject>
objects, PageSearchControl pageControl)
+ private List<IdentityObject> cutPageFromResults(List<IdentityObject>
objects, IdentityObjectSearchConstraints constraints)
{
List<IdentityObject> results = new LinkedList<IdentityObject>();
- for (int i = pageControl.getOffset(); i < pageControl.getOffset() +
pageControl.getLimit(); i++)
+ for (int i = constraints.getFirstResult(); i < constraints.getFirstResult() +
constraints.getMaxResults(); i++)
{
if (i < objects.size())
{
Modified: idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/ModelTestCase.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/ModelTestCase.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/ModelTestCase.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -35,7 +35,7 @@
public void testGroupId() throws Exception
{
- GroupId id = new GroupId(GroupId.PREFIX + "groupTypeName/groupName");
+ GroupId id = new GroupId(GroupId.PREFIX + GroupId.SEPARATOR +
"groupTypeName" + GroupId.SEPARATOR + "groupName");
assertEquals("groupName", id.getName());
assertEquals("groupTypeName", id.getType());
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/PersistenceManagerTest.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -26,7 +26,7 @@
import org.jboss.identity.idm.api.Group;
import org.jboss.identity.idm.api.User;
import org.jboss.identity.idm.api.IdentitySessionFactory;
-import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.api.IdentitySearchConstraints;
import junit.framework.Assert;
@@ -131,7 +131,7 @@
id = session.getPersistenceManager().createGroupId("groupName3",
PROJECT);
session.getPersistenceManager().removeGroup(id, false);
- assertEquals(0, session.getPersistenceManager().findGroup(ORGANIZATION,
(IdentitySearchControl[])null).size());
+ assertEquals(0, session.getPersistenceManager().findGroup(ORGANIZATION,
(IdentitySearchConstraints)null).size());
assertEquals(0, session.getPersistenceManager().findGroup(PROJECT).size());
assertEquals(0, session.getPersistenceManager().findGroup(DEPARTMENT).size());
@@ -157,7 +157,7 @@
//TODO: this should throw some meaningfull exception or simply return null
//assertNull(session.getPersistenceManager().findUser("olaf"));
- assertEquals(2,
session.getPersistenceManager().findUser((IdentitySearchControl[])null).size());
+ assertEquals(2,
session.getPersistenceManager().findUser((IdentitySearchConstraints)null).size());
session.getPersistenceManager().removeUser(u1, false);
@@ -167,7 +167,7 @@
assertEquals(0, session.getPersistenceManager().getUserCount());
- assertEquals(0,
session.getPersistenceManager().findUser((IdentitySearchControl[])null).size());
+ assertEquals(0,
session.getPersistenceManager().findUser((IdentitySearchConstraints)null).size());
session.getTransaction().commit();
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/api/RelationshipManagerTest.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -26,7 +26,7 @@
import org.jboss.identity.idm.api.Group;
import org.jboss.identity.idm.api.User;
import org.jboss.identity.idm.api.IdentitySessionFactory;
-import org.jboss.identity.idm.api.IdentitySearchControl;
+import org.jboss.identity.idm.api.IdentitySearchConstraints;
import java.util.Arrays;
@@ -358,10 +358,10 @@
assertEquals(0, session.getRelationshipManager().findAssociatedUsers(group2, false,
null).size());
assertEquals(1, session.getRelationshipManager().findRelatedUsers(group2,
null).size());
- assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user3,
(IdentitySearchControl[])null).size());
+ assertEquals(0, session.getRelationshipManager().findAssociatedGroups(user3,
(IdentitySearchConstraints)null).size());
assertEquals(2, session.getRelationshipManager().findRelatedGroups(user3, null,
null).size());
- assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user2,
(IdentitySearchControl[])null).size());
+ assertEquals(1, session.getRelationshipManager().findAssociatedGroups(user2,
(IdentitySearchConstraints)null).size());
assertEquals(2, session.getRelationshipManager().findRelatedGroups(user2, null,
null).size());
session.getTransaction().commit();
Modified:
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/CommonIdentityStoreTest.java
===================================================================
---
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/CommonIdentityStoreTest.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm/src/test/java/org/jboss/identity/idm/impl/store/CommonIdentityStoreTest.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -25,18 +25,16 @@
import org.jboss.identity.idm.spi.model.IdentityObject;
import org.jboss.identity.idm.spi.model.IdentityObjectCredential;
import org.jboss.identity.idm.spi.model.IdentityObjectAttribute;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.spi.search.IdentityObjectSearchConstraints;
+import org.jboss.identity.idm.spi.store.IdentityObjectSearchConstraintType;
import org.jboss.identity.idm.impl.api.PasswordCredential;
import org.jboss.identity.idm.impl.api.BinaryCredential;
-import org.jboss.identity.idm.impl.api.NameFilterSearchControl;
-import org.jboss.identity.idm.impl.api.SortByNameSearchControl;
-import org.jboss.identity.idm.impl.api.AttributeFilterSearchControl;
-import org.jboss.identity.idm.impl.api.PageSearchControl;
import org.jboss.identity.idm.impl.api.SimpleAttribute;
+import org.jboss.identity.idm.impl.api.IdentitySearchConstraintsImpl;
+import org.jboss.identity.idm.api.SortOrder;
import java.util.Collection;
import java.util.Map;
-import java.util.HashMap;
import java.util.Random;
import java.util.List;
@@ -372,82 +370,88 @@
IdentityObject group8 =
testContext.getStore().createIdentityObject(testContext.getCtx(), "Entity3",
IdentityTypeEnum.USER);
Collection<IdentityObject> results = null;
- IdentityObjectSearchControl control = null;
+ IdentityObjectSearchConstraints constraints = null;
// TODO: by RelationshipType
- if
(testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.USER,
NameFilterSearchControl.class))
+ if (testContext.getStore().getSupportedFeatures().
+ isSearchConstraintTypeSupported(IdentityTypeEnum.USER,
IdentityObjectSearchConstraintType.NAME_FILTER))
{
- control = new NameFilterSearchControl("*");
+ constraints = (IdentityObjectSearchConstraints)new
IdentitySearchConstraintsImpl().idFilter("*");
+
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER,
constraints);
assertEquals(8, results.size());
- control = new NameFilterSearchControl("D*");
+ constraints = (IdentityObjectSearchConstraints)new
IdentitySearchConstraintsImpl().idFilter("D*");
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER,
constraints);
assertEquals(3, results.size());
- control = new NameFilterSearchControl("*2");
+ constraints = (IdentityObjectSearchConstraints)new
IdentitySearchConstraintsImpl().idFilter("*2");
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER,
constraints);
assertEquals(3, results.size());
- control = new NameFilterSearchControl("*3");
+ constraints = (IdentityObjectSearchConstraints)new
IdentitySearchConstraintsImpl().idFilter("*3");
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER,
constraints);
assertEquals(2, results.size());
- control = new NameFilterSearchControl("Company1");
+ constraints = (IdentityObjectSearchConstraints)new
IdentitySearchConstraintsImpl().idFilter("Company1");
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER,
constraints);
assertEquals(1, results.size());
- control = new NameFilterSearchControl("Totoro");
+ constraints = (IdentityObjectSearchConstraints)new
IdentitySearchConstraintsImpl().idFilter("Toronto");
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER,
constraints);
assertEquals(0, results.size());
}
- if
(testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.USER,
PageSearchControl.class))
+ if (testContext.getStore().getSupportedFeatures().
+ isSearchConstraintTypeSupported(IdentityTypeEnum.USER,
IdentityObjectSearchConstraintType.PAGE))
{
- control = new PageSearchControl(0, 3);
+ constraints = (IdentityObjectSearchConstraints)new
IdentitySearchConstraintsImpl().page(0, 3);
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER,
constraints);
assertEquals(3, results.size());
- control = new PageSearchControl(2, 2);
+ constraints = (IdentityObjectSearchConstraints)new
IdentitySearchConstraintsImpl().page(2, 2);
+
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER,
constraints);
assertEquals(2, results.size());
}
- if
(testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.USER,
SortByNameSearchControl.class))
+ if (testContext.getStore().getSupportedFeatures().
+ isSearchConstraintTypeSupported(IdentityTypeEnum.USER,
IdentityObjectSearchConstraintType.SORT))
{
- control = new SortByNameSearchControl(true);
+ constraints = (IdentityObjectSearchConstraints)new
IdentitySearchConstraintsImpl().sort(SortOrder.ASCENDING);
+
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER,
constraints);
assertEquals(8, results.size());
@@ -457,10 +461,11 @@
// And reverse order
- control = new SortByNameSearchControl(false);
+ constraints = (IdentityObjectSearchConstraints)new
IdentitySearchConstraintsImpl().sort(SortOrder.DESCENDING);
+
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER,
constraints);
assertEquals(8, results.size());
@@ -473,22 +478,25 @@
// Combine controls to check that the results are diffrent for pagination
- if
(testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.USER,
PageSearchControl.class))
+ if (testContext.getStore().getSupportedFeatures().
+ isSearchConstraintTypeSupported(IdentityTypeEnum.USER,
IdentityObjectSearchConstraintType.PAGE))
{
- control = new SortByNameSearchControl(true);
- IdentityObjectSearchControl control2 = new PageSearchControl(0, 3);
+ constraints = (IdentityObjectSearchConstraints)new
IdentitySearchConstraintsImpl().sort(SortOrder.ASCENDING).page(0,3);
+
+
+
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control, control2});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER,
constraints);
assertEquals(3, results.size());
assertEquals("Company1",
((List<IdentityObject>)results).get(0).getName());
assertEquals("Division1",
((List<IdentityObject>)results).get(2).getName());
- control2 = new PageSearchControl(3, 1);
+ constraints = (IdentityObjectSearchConstraints)new
IdentitySearchConstraintsImpl().sort(SortOrder.ASCENDING).page(3,1);
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control, control2});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER,
constraints);
assertEquals(1, results.size());
@@ -499,21 +507,23 @@
}
- if
(testContext.getStore().getSupportedFeatures().isControlSupported(IdentityTypeEnum.USER,
AttributeFilterSearchControl.class))
+ if (testContext.getStore().getSupportedFeatures().
+ isSearchConstraintTypeSupported(IdentityTypeEnum.USER,
IdentityObjectSearchConstraintType.ATTRIBUTE_FILTER))
{
- Map<String, String[]> attrs = new HashMap<String, String[]>();
- attrs.put("phone", new String[] {"777 777 777"});
- attrs.put("description", new String[] {"sample desc"});
IdentityObjectAttribute phone = new SimpleAttribute("phone", new
String[] {"777 777 777"});
IdentityObjectAttribute description = new
SimpleAttribute("description", new String[] {"sample desc"});
testContext.getStore().addAttributes(testContext.getCtx(), group1, new
IdentityObjectAttribute[]{phone, description});
- control = new AttributeFilterSearchControl(attrs);
+ constraints = (IdentityObjectSearchConstraints)new
IdentitySearchConstraintsImpl()
+ .attributeValuesFilter("phone", new String[] {"777 777
777"})
+ .attributeValuesFilter("description", new String[] {"sample
desc"});
+
+
results = testContext.getStore().
- findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER, new
IdentityObjectSearchControl[]{control});
+ findIdentityObject(testContext.getCtx(), IdentityTypeEnum.USER,
constraints);
assertEquals(1, results.size());
Added:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchConstraintType.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchConstraintType.java
(rev 0)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchConstraintType.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -0,0 +1,38 @@
+/*
+* 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.api;
+
+
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public enum IdentitySearchConstraintType
+{
+ SORT,
+ PAGE,
+ NAME_FILTER,
+ ATTRIBUTE_FILTER
+}
Added:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchConstraints.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchConstraints.java
(rev 0)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchConstraints.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -0,0 +1,43 @@
+/*
+* 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.api;
+
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentitySearchConstraints
+{
+
+ IdentitySearchConstraints sort(SortOrder order) throws UnsupportedConstraint;
+
+ IdentitySearchConstraints sortAttributeName(String name) throws
UnsupportedConstraint;
+
+ IdentitySearchConstraints page(int firstResult, int maxResults) throws
UnsupportedConstraint;
+
+ IdentitySearchConstraints attributeValuesFilter(String attributeName, String[]
attributeValue) throws UnsupportedConstraint;
+
+ IdentitySearchConstraints idFilter(String filter) throws UnsupportedConstraint;
+
+}
Deleted:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchControl.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchControl.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchControl.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -1,33 +0,0 @@
-/*
-* 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.api;
-
-/**
- * IdentitySearchControl enables to add additional constraints to the results of
operations on identity objects
- *
- * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
- * @version : 0.1 $
- */
-public interface IdentitySearchControl
-{
-}
Added:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchCriteria.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchCriteria.java
(rev 0)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/IdentitySearchCriteria.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -0,0 +1,34 @@
+/*
+* 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.api;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentitySearchCriteria
+{
+
+
+
+}
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManager.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -46,7 +46,9 @@
*/
PersistenceManagerFeaturesDescription getFeaturesDescription();
+ IdentitySearchConstraints createIdentitySearchConstraints();
+
// Create
/**
@@ -151,7 +153,7 @@
* @return
* @throws IdentityException
*/
- Collection<User> findUser(IdentitySearchControl[] controls) throws
IdentityException;
+ Collection<User> findUser(IdentitySearchConstraints controls) throws
IdentityException;
// Search Groups
@@ -182,7 +184,7 @@
* @return
* @throws IdentityException
*/
- Collection<Group> findGroup(String groupType, IdentitySearchControl[] controls)
throws IdentityException;
+ Collection<Group> findGroup(String groupType, IdentitySearchConstraints
controls) throws IdentityException;
/**
*
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManagerFeaturesDescription.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManagerFeaturesDescription.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/PersistenceManagerFeaturesDescription.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -48,34 +48,18 @@
/**
* Check if control can be used in Identity search methods
*
- * @param control
+ * @param constraint
* @return
*/
- boolean isUsersSearchControlSupported(IdentitySearchControl control);
+ boolean isUsersSearchConstraintTypeSupported(IdentitySearchConstraintType
constraint);
/**
- * Check if control can be used in Identity search methods
- *
- * @param controlClazz
- * @return
- */
- boolean isUsersSearchControlSupported(Class<?> controlClazz);
-
- /**
* Check if control can be used in Group search methods
*
* @param groupType
- * @param control
+ * @param constraint
* @return
*/
- boolean isGroupsSearchControlSupported(String groupType, IdentitySearchControl
control);
+ boolean isGroupsSearchConstraintTypeSupported(String groupType,
IdentitySearchConstraintType constraint);
- /**
- * Check if control can be used in Group search methods
- *
- * @param groupType
- * @param controlClazz
- * @return
- */
- boolean isGroupsSearchControlSupported(String groupType, Class<?>
controlClazz);
}
\ 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-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManager.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -45,6 +45,8 @@
*/
RelationshipManagerFeaturesDescription getFeaturesDescription();
+ IdentitySearchConstraints createIdentitySearchConstraints();
+
// Assignation
/**
@@ -306,7 +308,7 @@
String groupType,
boolean parent,
boolean inherited,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
* Find groups that are associated with given group.
@@ -326,7 +328,7 @@
String groupType,
boolean parent,
boolean inherited,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
* Find all groups that given identity is associated with.
@@ -348,7 +350,7 @@
*/
Collection<Group> findAssociatedGroups(User user,
String groupType,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
* Find all groups that given identity is associated with.
@@ -360,7 +362,7 @@
*/
Collection<Group> findAssociatedGroups(String userId,
String groupType,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
* Find all groups that given identity is associated with.
@@ -370,7 +372,7 @@
* @throws org.jboss.identity.idm.exception.IdentityException
*/
Collection<Group> findAssociatedGroups(User user,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
* Find all groups that given identity is associated with.
@@ -380,7 +382,7 @@
* @throws org.jboss.identity.idm.exception.IdentityException
*/
Collection<Group> findAssociatedGroups(String userId,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
* Find all groups that given identity is associated with.
@@ -412,7 +414,7 @@
*/
Collection<User> findAssociatedUsers(Group group,
boolean inherited,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
* Find identities that have relationship with given parent group.
@@ -424,7 +426,7 @@
*/
Collection<User> findAssociatedUsers(String groupId,
boolean inherited,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
@@ -437,7 +439,7 @@
*/
Collection<Group> findRelatedGroups(User user,
String groupType,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
* Find all groups that given identity is associated with. Will return groups
connected with a given user with a role
@@ -449,7 +451,7 @@
*/
Collection<Group> findRelatedGroups(String userId,
String groupType,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
* Find identities that have relationship with given parent group. Will return users
connected with a given group with a role
@@ -458,7 +460,7 @@
* @return
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- Collection<User> findRelatedUsers(Group group, IdentitySearchControl[] controls)
throws IdentityException;
+ Collection<User> findRelatedUsers(Group group, IdentitySearchConstraints
controls) throws IdentityException;
/**
* Find identities that have relationship with given parent group. Will return users
connected with a given group with a role
@@ -467,7 +469,7 @@
* @return
* @throws org.jboss.identity.idm.exception.IdentityException
*/
- Collection<User> findRelatedUsers(String groupId, IdentitySearchControl[]
controls) throws IdentityException;
+ Collection<User> findRelatedUsers(String groupId, IdentitySearchConstraints
controls) throws IdentityException;
}
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManagerFeaturesDescription.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManagerFeaturesDescription.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RelationshipManagerFeaturesDescription.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -49,34 +49,18 @@
/**
* Check if control can be used in Identity search methods
*
- * @param control
+ * @param constraint
* @return
*/
- boolean isIdentitiesSearchControlSupported(IdentitySearchControl control);
+ boolean isIdentitiesSearchConstraintTypeSupported(IdentitySearchConstraintType
constraint);
/**
- * Check if control can be used in Identity search methods
- *
- * @param controlClazz
- * @return
- */
- boolean isIdentitiesSearchControlSupported(Class<?> controlClazz);
-
- /**
* Check if control can be used in Group search methods
*
* @param groupType
- * @param control
+ * @param constraintType
* @return
*/
- boolean isGroupsSearchControlSupported(String groupType, IdentitySearchControl
control);
+ boolean isGroupsSearchConstraintTypeSupported(String groupType,
IdentitySearchConstraintType constraintType);
- /**
- * Check if control can be used in Group search methods
- *
- * @param groupType
- * @param controlClazz
- * @return
- */
- boolean isGroupsSearchControlSupported(String groupType, Class<?>
controlClazz);
}
\ No newline at end of file
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-03-23
03:05:44 UTC (rev 397)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManager.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -46,6 +46,8 @@
*/
RoleManagerFeaturesDescription getSupportedFeatures();
+ IdentitySearchConstraints createIdentitySearchConstraints();
+
// RoleType
/**
@@ -83,7 +85,7 @@
* @return
* @throws IdentityException
*/
- Collection<RoleType> findRoleTypes(IdentitySearchControl[] controls) throws
IdentityException;
+ Collection<RoleType> findRoleTypes(IdentitySearchConstraints controls) throws
IdentityException;
// Role
@@ -160,7 +162,7 @@
* @throws IdentityException
*/
Collection<RoleType> findRoleTypes(User user, Group group,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
* Find RoleType objects for roles associated with a given User and Group
@@ -170,7 +172,7 @@
* @throws IdentityException
*/
Collection<RoleType> findRoleTypes(String userId, String groupId,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
* Find RoleType objects for roles associated with a given User and Group
@@ -195,7 +197,7 @@
* @return
* @throws IdentityException
*/
- Collection<RoleType> findUserRoleTypes(User user, IdentitySearchControl[]
controls) throws IdentityException;
+ Collection<RoleType> findUserRoleTypes(User user, IdentitySearchConstraints
controls) throws IdentityException;
/**
* Find RoleType objects for roles associated with a given Identity
@@ -203,7 +205,7 @@
* @return
* @throws IdentityException
*/
- Collection<RoleType> findUserRoleTypes(String userId, IdentitySearchControl[]
controls) throws IdentityException;
+ Collection<RoleType> findUserRoleTypes(String userId, IdentitySearchConstraints
controls) throws IdentityException;
/**
* Find RoleType objects for roles associated with a given Group
@@ -220,7 +222,7 @@
* @throws IdentityException
*/
Collection<RoleType> findGroupRoleTypes(Group group,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
* Find RoleType objects for roles associated with a given Group
@@ -229,7 +231,7 @@
* @throws IdentityException
*/
Collection<RoleType> findGroupRoleTypes(String groupId,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
* Find all Groups with which User has a Role association
@@ -240,7 +242,7 @@
* @throws IdentityException
*/
Collection<Group> findGroupsWithRelatedRole(User user,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
* Find all Groups with which User has a Role association
@@ -251,7 +253,7 @@
* @throws IdentityException
*/
Collection<Group> findGroupsWithRelatedRole(String userId,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
@@ -264,7 +266,7 @@
*/
Collection<Group> findGroupsWithRelatedRole(User user,
String groupType,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
* Find all Groups with which User has a Role association
@@ -276,7 +278,7 @@
*/
Collection<Group> findGroupsWithRelatedRole(String userId,
String groupType,
- IdentitySearchControl[] controls) throws
IdentityException;
+ IdentitySearchConstraints controls) throws
IdentityException;
/**
* Find Role objects with a given RoleType associated with a given IdentityType
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManagerFeaturesDescription.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManagerFeaturesDescription.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/RoleManagerFeaturesDescription.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -37,14 +37,8 @@
boolean isRoleTypeAddRemoveSupported();
/**
- * @param controlClazz
+ * @param constraintType
* @return
*/
- boolean isRoleTypeSearchControlSupported(Class<?> controlClazz);
-
- /**
- * @param control
- * @return
- */
- boolean isRoleTypeSearchControlSupported(IdentitySearchControl control);
+ boolean isRoleTypeSearchConstraintTypeSupported(IdentitySearchConstraintType
constraintType);
}
\ No newline at end of file
Added: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/SortOrder.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/SortOrder.java
(rev 0)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/SortOrder.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -0,0 +1,34 @@
+/*
+* 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.api;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public enum SortOrder
+{
+ ASCENDING,
+ DESCENDING
+
+}
Added:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/UnsupportedConstraint.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/UnsupportedConstraint.java
(rev 0)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/UnsupportedConstraint.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -0,0 +1,50 @@
+/*
+* 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.api;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public class UnsupportedConstraint extends Exception
+{
+ public UnsupportedConstraint()
+ {
+ super();
+ }
+
+ public UnsupportedConstraint(String message)
+ {
+ super(message);
+ }
+
+ public UnsupportedConstraint(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public UnsupportedConstraint(Throwable cause)
+ {
+ super(cause);
+ }
+}
Modified:
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/query/GroupQuery.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/query/GroupQuery.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/query/GroupQuery.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -24,8 +24,10 @@
import org.jboss.identity.idm.api.Group;
import org.jboss.identity.idm.api.User;
+import org.jboss.identity.idm.api.SortOrder;
import java.util.Collection;
+import java.util.List;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -34,10 +36,16 @@
public interface GroupQuery extends Query
{
+ Collection<Group> execute() throws QueryException;
+
+ Group uniqueResult() throws QueryException;
+
+ List<Group> list() throws QueryException;
+
GroupQuery setId(String id);
GroupQuery setNameAndType(String name, String type);
-
+
GroupQuery setName(String name);
GroupQuery setType(String type);
@@ -70,8 +78,14 @@
GroupQuery addRelatedUser(String id);
- GroupQuery sort(QuerySortOrder order) throws UnsupportedQueryConstraint;
+ GroupQuery sort(SortOrder order) throws UnsupportedQueryConstraint;
+ GroupQuery sortAttributeName(String name) throws UnsupportedQueryConstraint;
+
GroupQuery page(int firstResult, int maxResults) throws UnsupportedQueryConstraint;
+ GroupQuery attributeValuesFilter(String attributeName, String[] attributeValue) throws
UnsupportedQueryConstraint;
+
+
+
}
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/query/Query.java
===================================================================
--- idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/query/Query.java 2009-03-23
03:05:44 UTC (rev 397)
+++ idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/query/Query.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -32,10 +32,6 @@
public interface Query
{
- Collection execute() throws QueryException;
-
- Object singleResult() throws QueryException;
-
- List list() throws QueryException;
+
}
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/query/RoleQuery.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/query/RoleQuery.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/query/RoleQuery.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -26,7 +26,11 @@
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.api.Role;
+import java.util.Collection;
+import java.util.List;
+
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
* @version : 0.1 $
@@ -34,6 +38,12 @@
public interface RoleQuery extends Query
{
+ Collection<Role> execute() throws QueryException;
+
+ Role uniqueResult() throws QueryException;
+
+ List<Role> list() throws QueryException;
+
RoleQuery setUser(User user);
RoleQuery setUser(String id);
Modified: idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/query/UserQuery.java
===================================================================
---
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/query/UserQuery.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm-api/src/main/java/org/jboss/identity/idm/api/query/UserQuery.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -23,8 +23,11 @@
package org.jboss.identity.idm.api.query;
import org.jboss.identity.idm.api.Group;
+import org.jboss.identity.idm.api.User;
+import org.jboss.identity.idm.api.SortOrder;
import java.util.Collection;
+import java.util.List;
/**
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
@@ -32,7 +35,12 @@
*/
public interface UserQuery extends Query
{
+ Collection<User> execute() throws QueryException;
+ User uniqueResult() throws QueryException;
+
+ List<User> list() throws QueryException;
+
UserQuery withUserId(String id);
UserQuery addAssociatedGroup(Group group);
@@ -59,8 +67,12 @@
UserQuery addRelatedGroupsIds(Collection<String> ids);
- UserQuery sort(QuerySortOrder order) throws UnsupportedQueryConstraint;
+ UserQuery sort(SortOrder order) throws UnsupportedQueryConstraint;
+ UserQuery sortAttributeName(String name) throws UnsupportedQueryConstraint;
+
UserQuery page(int firstResult, int maxResults) throws UnsupportedQueryConstraint;
+ UserQuery attributeValuesFilter(String attributeName, String[] attributeValue) throws
UnsupportedQueryConstraint;
+
}
Added:
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/search/IdentityObjectSearchConstraints.java
===================================================================
---
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/search/IdentityObjectSearchConstraints.java
(rev 0)
+++
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/search/IdentityObjectSearchConstraints.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -0,0 +1,50 @@
+/*
+* 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.spi.search;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public interface IdentityObjectSearchConstraints
+{
+ boolean isSorted();
+
+ boolean isAscending();
+
+ String getSortAttributeName();
+
+ boolean isPaged();
+
+ int getFirstResult();
+
+ int getMaxResults();
+
+ boolean isFiltered();
+
+ String getFilter();
+
+ Map<String, String[]> getValues();
+}
Modified:
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/FeaturesMetaData.java
===================================================================
---
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/FeaturesMetaData.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/FeaturesMetaData.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -26,7 +26,6 @@
import org.jboss.identity.idm.spi.model.IdentityObjectType;
import org.jboss.identity.idm.spi.model.IdentityObjectRelationshipType;
import org.jboss.identity.idm.spi.model.IdentityObjectCredentialType;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
import org.jboss.identity.idm.exception.IdentityException;
/**
@@ -57,34 +56,19 @@
/**
*
* @param identityObjectType
- * @param control
+ * @param storeSearchConstraint
* @return
*/
- boolean isControlSupported(IdentityObjectType identityObjectType,
IdentityObjectSearchControl control);
+ boolean isSearchConstraintTypeSupported(IdentityObjectType identityObjectType,
IdentityObjectSearchConstraintType storeSearchConstraint);
/**
- *
- * @param identityObjectType
- * @param controlClazz
- * @return
- */
- boolean isControlSupported(IdentityObjectType identityObjectType, Class<?>
controlClazz);
-
- /**
*
- * @param control
+ * @param constraint
* @return
*/
- boolean isRoleNameControlSupported(IdentityObjectSearchControl control);
+ boolean isRoleNameSearchConstraintSupported(IdentityObjectSearchConstraintType
constraint);
/**
- *
- * @param controlClazz
- * @return
- */
- boolean isRoleNameControlSupported(Class<?> controlClazz);
-
- /**
* @return set of identity types that can be persisted
*/
Set<String> getSupportedIdentityObjectTypes();
Added:
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityObjectSearchConstraintType.java
===================================================================
---
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityObjectSearchConstraintType.java
(rev 0)
+++
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityObjectSearchConstraintType.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -0,0 +1,36 @@
+/*
+* 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.spi.store;/**
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
+ * @version : 0.1 $
+ */
+public enum IdentityObjectSearchConstraintType
+{
+ SORT,
+ PAGE,
+ NAME_FILTER,
+ ATTRIBUTE_FILTER
+}
Modified:
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStore.java
===================================================================
---
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStore.java 2009-03-23
03:05:44 UTC (rev 397)
+++
idm/trunk/idm-spi/src/main/java/org/jboss/identity/idm/spi/store/IdentityStore.java 2009-03-23
19:20:55 UTC (rev 398)
@@ -34,7 +34,7 @@
import
org.jboss.identity.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
import org.jboss.identity.idm.spi.configuration.IdentityStoreConfigurationContext;
import org.jboss.identity.idm.spi.model.IdentityObjectCredential;
-import org.jboss.identity.idm.spi.searchcontrol.IdentityObjectSearchControl;
+import org.jboss.identity.idm.spi.search.IdentityObjectSearchConstraints;
import org.jboss.identity.idm.exception.IdentityException;
/**
@@ -151,7 +151,7 @@
*/
Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext
invocationCtx,
IdentityObjectType identityType,
- IdentityObjectSearchControl[] controls)
throws IdentityException;
+ IdentityObjectSearchConstraints
controls) throws IdentityException;
/**
* Find identites that have relationship with given identity. Relationships are
directional (from parent to child).
*
@@ -167,7 +167,7 @@
Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext
invocationCxt, IdentityObject identity,
IdentityObjectRelationshipType
relationshipType,
boolean parent,
- IdentityObjectSearchControl[]
controls) throws IdentityException;
+ IdentityObjectSearchConstraints
controls) throws IdentityException;
@@ -282,7 +282,7 @@
* @throws OperationNotSupportedException
*/
Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
- IdentityObjectSearchControl[] controls) throws
IdentityException, OperationNotSupportedException;
+ IdentityObjectSearchConstraints controls) throws
IdentityException, OperationNotSupportedException;
/**
@@ -296,7 +296,7 @@
*/
Set<String> getRelationshipNames(IdentityStoreInvocationContext ctx,
IdentityObject identity,
- IdentityObjectSearchControl[] controls) throws
IdentityException, OperationNotSupportedException;
+ IdentityObjectSearchConstraints controls) throws
IdentityException, OperationNotSupportedException;
// Credentials