Author: bdaw
Date: 2011-05-17 15:37:59 -0400 (Tue, 17 May 2011)
New Revision: 946
Modified:
idm/trunk/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache/JBossCacheAPICacheProviderImpl.java
idm/trunk/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache/JBossCacheIdentityStoreCacheProviderImpl.java
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/session/managers/RelationshipManagerImpl.java
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/cache/JBossCacheIdentityStoreWrapper.java
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/FallbackIdentityStoreRepository.java
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/WrapperIdentityStoreRepository.java
idm/trunk/picketlink-idm-hibernate/pom.xml
idm/trunk/picketlink-idm-hibernate/src/main/java/org/picketlink/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
idm/trunk/picketlink-idm-jpa/src/main/java/org/picketlink/idm/impl/store/jpa/JpaIdentityStore.java
idm/trunk/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
idm/trunk/picketlink-idm-spi/src/main/java/org/picketlink/idm/spi/store/IdentityStore.java
idm/trunk/pom.xml
Log:
- Merge setExpiration() usage in cache impl.
- Many smaller performance optimizations
Modified:
idm/trunk/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache/JBossCacheAPICacheProviderImpl.java
===================================================================
---
idm/trunk/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache/JBossCacheAPICacheProviderImpl.java 2011-05-17
15:03:46 UTC (rev 945)
+++
idm/trunk/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache/JBossCacheAPICacheProviderImpl.java 2011-05-17
19:37:59 UTC (rev 946)
@@ -29,6 +29,7 @@
import org.picketlink.idm.api.query.RoleQuery;
import org.picketlink.idm.impl.api.model.GroupKey;
import org.jboss.cache.*;
+import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
import java.io.InputStream;
import java.util.List;
@@ -112,6 +113,8 @@
public static final String MAIN_ROOT = "NODE_MAIN_ROOT";
+ private int expiration = -1;
+
private Fqn getRootNode()
{
return Fqn.fromString("/" + MAIN_ROOT);
@@ -258,6 +261,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, user);
if (log.isLoggable(Level.FINER))
@@ -308,6 +312,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, unmodifiableCollection(users));
if (log.isLoggable(Level.FINER))
@@ -362,6 +367,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, count);
if (log.isLoggable(Level.FINER))
@@ -414,6 +420,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, group);
if (log.isLoggable(Level.FINER))
@@ -465,6 +472,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, unmodifiableCollection(groups));
if (log.isLoggable(Level.FINER))
@@ -518,6 +526,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, count);
if (log.isLoggable(Level.FINER))
@@ -572,6 +581,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, role);
if (log.isLoggable(Level.FINER))
@@ -616,6 +626,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, role);
if (log.isLoggable(Level.FINER))
@@ -659,6 +670,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, Collections.unmodifiableMap(attributes));
if (log.isLoggable(Level.FINER))
@@ -717,6 +729,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, Collections.unmodifiableMap(properties));
if (log.isLoggable(Level.FINER))
@@ -775,6 +788,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, Collections.unmodifiableMap(properties));
if (log.isLoggable(Level.FINER))
@@ -851,6 +865,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, unmodifiableCollection(results));
if (log.isLoggable(Level.FINER))
@@ -891,6 +906,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, unmodifiableCollection(results));
if (log.isLoggable(Level.FINER))
@@ -929,6 +945,7 @@
if (ioNode == null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, result);
if (log.isLoggable(Level.FINER))
@@ -967,6 +984,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, unmodifiableCollection(results));
if (log.isLoggable(Level.FINER))
@@ -1005,6 +1023,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, unmodifiableCollection(results));
if (log.isLoggable(Level.FINER))
@@ -1055,6 +1074,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_QUERY_KEY, results);
if (log.isLoggable(Level.FINER))
@@ -1073,6 +1093,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_QUERY_UNIQUE_KEY, user);
if (log.isLoggable(Level.FINER))
@@ -1143,6 +1164,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_QUERY_KEY, unmodifiableCollection(results));
if (log.isLoggable(Level.FINER))
@@ -1161,6 +1183,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_QUERY_UNIQUE_KEY, group);
if (log.isLoggable(Level.FINER))
@@ -1231,6 +1254,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_QUERY_KEY, results);
if (log.isLoggable(Level.FINER))
@@ -1249,6 +1273,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_QUERY_UNIQUE_KEY, role);
if (log.isLoggable(Level.FINER))
@@ -1332,4 +1357,23 @@
return Collections.unmodifiableCollection(collection);
}
+
+ public void setExpiration(Node node)
+ {
+ if (expiration != -1 && expiration > 0)
+ {
+ Long future = new Long(System.currentTimeMillis() + expiration);
+ node.put(ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
+ }
+ }
+
+ public int getExpiration()
+ {
+ return expiration;
+ }
+
+ public void setExpiration(int expiration)
+ {
+ this.expiration = expiration;
+ }
}
Modified:
idm/trunk/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache/JBossCacheIdentityStoreCacheProviderImpl.java
===================================================================
---
idm/trunk/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache/JBossCacheIdentityStoreCacheProviderImpl.java 2011-05-17
15:03:46 UTC (rev 945)
+++
idm/trunk/picketlink-idm-cache/src/main/java/org/picketlink/idm/impl/cache/JBossCacheIdentityStoreCacheProviderImpl.java 2011-05-17
19:37:59 UTC (rev 946)
@@ -23,6 +23,7 @@
package org.picketlink.idm.impl.cache;
import org.jboss.cache.*;
+import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
import org.picketlink.idm.spi.configuration.IdentityConfigurationContext;
import org.picketlink.idm.spi.model.IdentityObject;
@@ -91,6 +92,8 @@
public static final String MAIN_ROOT = "NODE_MAIN_ROOT";
+ private int expiration = -1;
+
private Fqn getRootNode()
{
return Fqn.fromString("/" + MAIN_ROOT);
@@ -248,6 +251,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, count);
if (log.isLoggable(Level.FINER))
@@ -303,6 +307,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, safeCopyIO(results));
if (log.isLoggable(Level.FINER))
@@ -352,6 +357,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, safeCopyIOR(results));
if (log.isLoggable(Level.FINER))
@@ -401,6 +407,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, results);
if (log.isLoggable(Level.FINER))
@@ -450,6 +457,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, properties);
if (log.isLoggable(Level.FINER))
@@ -518,6 +526,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, properties);
if (log.isLoggable(Level.FINER))
@@ -579,6 +588,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, safeCopyAttr(attributes));
if (log.isLoggable(Level.FINER))
@@ -637,6 +647,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, value);
if (log.isLoggable(Level.FINER))
@@ -729,5 +740,23 @@
return nr;
}
+ public void setExpiration(Node node)
+ {
+ if (expiration != -1 && expiration > 0)
+ {
+ Long future = new Long(System.currentTimeMillis() + expiration);
+ node.put(ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
+ }
+ }
+ public int getExpiration()
+ {
+ return expiration;
+ }
+
+ public void setExpiration(int expiration)
+ {
+ this.expiration = expiration;
+ }
+
}
Modified:
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/session/managers/RelationshipManagerImpl.java
===================================================================
---
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/session/managers/RelationshipManagerImpl.java 2011-05-17
15:03:46 UTC (rev 945)
+++
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/api/session/managers/RelationshipManagerImpl.java 2011-05-17
19:37:59 UTC (rev 946)
@@ -903,6 +903,8 @@
IdentityObjectType iot = groupType != null ? getIdentityObjectType(groupType) :
null;
+ Collection excludes = new HashSet<IdentityObjectType>();
+ excludes.add(getUserObjectType());
if (cascade)
{
@@ -928,8 +930,16 @@
else
{
- Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(group),
MEMBER, parent, convertSearchControls(criteria));
+ Collection<IdentityObject> ios = getRepository().
+ findIdentityObject(
+ getInvocationContext(),
+ createIdentityObject(group),
+ MEMBER,
+ excludes,
+ parent,
+ convertSearchControls(criteria));
+
for (IdentityObject io : ios)
{
if ((iot == null &&
!io.getIdentityType().getName().equals(getUserObjectType().getName())) ||
@@ -1009,8 +1019,18 @@
IdentityObjectType iot = groupType != null ? getIdentityObjectType(groupType) :
null;
- Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(user),
MEMBER, false, convertSearchControls(criteria));
+ Collection excludes = new HashSet<IdentityObjectType>();
+ excludes.add(getUserObjectType());
+ Collection<IdentityObject> ios = getRepository().
+ findIdentityObject(
+ getInvocationContext(),
+ createIdentityObject(user),
+ MEMBER,
+ excludes,
+ false,
+ convertSearchControls(criteria));
+
for (IdentityObject io : ios)
{
if (iot == null || io.getIdentityType().getName().equals(iot.getName()))
@@ -1082,9 +1102,19 @@
List<Group> identities = new LinkedList<Group>();
- Collection<IdentityObject> ios =
getRepository().findIdentityObject(getInvocationContext(), createIdentityObject(user),
MEMBER, false, convertSearchControls(criteria));
+ Collection excludes = new HashSet<IdentityObjectType>();
+ excludes.add(getUserObjectType());
+ Collection<IdentityObject> ios = getRepository().
+ findIdentityObject(
+ getInvocationContext(),
+ createIdentityObject(user),
+ MEMBER,
+ excludes,
+ false,
+ convertSearchControls(criteria));
+
String userTypeName = getUserObjectType().getName();
for (IdentityObject io : ios)
Modified:
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/cache/JBossCacheIdentityStoreWrapper.java
===================================================================
---
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2011-05-17
15:03:46 UTC (rev 945)
+++
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/cache/JBossCacheIdentityStoreWrapper.java 2011-05-17
19:37:59 UTC (rev 946)
@@ -245,13 +245,22 @@
}
-
+ public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCxt,
+ IdentityObject identity,
+ IdentityObjectRelationshipType
relationshipType,
+ boolean parent,
+ IdentityObjectSearchCriteria
criteria) throws IdentityException
+ {
+ return findIdentityObject(invocationCxt, identity, relationshipType, null, parent,
criteria);
+ }
+
public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCtx,
IdentityObject identity,
IdentityObjectRelationshipType
relationshipType,
+
Collection<IdentityObjectType> excludes,
boolean parent,
- IdentityObjectSearchCriteria
criteria) throws IdentityException
+ IdentityObjectSearchCriteria
criteria) throws IdentityException
{
IdentityObjectSearchImpl search = new IdentityObjectSearchImpl();
Modified:
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/FallbackIdentityStoreRepository.java
===================================================================
---
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/FallbackIdentityStoreRepository.java 2011-05-17
15:03:46 UTC (rev 945)
+++
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/FallbackIdentityStoreRepository.java 2011-05-17
19:37:59 UTC (rev 946)
@@ -834,7 +834,18 @@
boolean parent,
IdentityObjectSearchCriteria
criteria) throws IdentityException
{
+ return findIdentityObject(invocationCxt, identity, relationshipType, null, parent,
criteria);
+ }
+
+ public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCxt,
+ IdentityObject identity,
+ IdentityObjectRelationshipType
relationshipType,
+
Collection<IdentityObjectType> excludes,
+ boolean parent,
+ IdentityObjectSearchCriteria
criteria) throws IdentityException
+ {
+
try
{
List<IdentityStore> mappedStores =
resolveIdentityStores(identity.getIdentityType());
Modified:
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/WrapperIdentityStoreRepository.java
===================================================================
---
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/WrapperIdentityStoreRepository.java 2011-05-17
15:03:46 UTC (rev 945)
+++
idm/trunk/picketlink-idm-core/src/main/java/org/picketlink/idm/impl/repository/WrapperIdentityStoreRepository.java 2011-05-17
19:37:59 UTC (rev 946)
@@ -187,9 +187,19 @@
public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCtx,
IdentityObject identity,
IdentityObjectRelationshipType
relationshipType,
+
Collection<IdentityObjectType> excludes,
boolean parent,
IdentityObjectSearchCriteria
criteria) throws IdentityException
{
+ return
defaultIdentityStore.findIdentityObject(resolveIdentityStoreInvocationContext(invocationCtx),
identity, relationshipType, excludes, parent, criteria);
+ }
+
+ public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCtx,
+ IdentityObject identity,
+ IdentityObjectRelationshipType
relationshipType,
+ boolean parent,
+ IdentityObjectSearchCriteria
criteria) throws IdentityException
+ {
return
defaultIdentityStore.findIdentityObject(resolveIdentityStoreInvocationContext(invocationCtx),
identity, relationshipType, parent, criteria);
}
Modified: idm/trunk/picketlink-idm-hibernate/pom.xml
===================================================================
--- idm/trunk/picketlink-idm-hibernate/pom.xml 2011-05-17 15:03:46 UTC (rev 945)
+++ idm/trunk/picketlink-idm-hibernate/pom.xml 2011-05-17 19:37:59 UTC (rev 946)
@@ -81,7 +81,7 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
-
+
</dependencies>
Modified:
idm/trunk/picketlink-idm-hibernate/src/main/java/org/picketlink/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java
===================================================================
---
idm/trunk/picketlink-idm-hibernate/src/main/java/org/picketlink/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2011-05-17
15:03:46 UTC (rev 945)
+++
idm/trunk/picketlink-idm-hibernate/src/main/java/org/picketlink/idm/impl/store/hibernate/HibernateIdentityStoreImpl.java 2011-05-17
19:37:59 UTC (rev 946)
@@ -26,6 +26,7 @@
import org.picketlink.idm.impl.helper.Tools;
import org.picketlink.idm.impl.model.hibernate.*;
import org.picketlink.idm.impl.store.FeaturesMetaDataImpl;
+import org.picketlink.idm.impl.types.SimpleIdentityObject;
import org.picketlink.idm.spi.configuration.IdentityStoreConfigurationContext;
import org.picketlink.idm.spi.configuration.metadata.IdentityObjectAttributeMetaData;
import org.picketlink.idm.spi.configuration.metadata.IdentityObjectTypeMetaData;
@@ -662,32 +663,8 @@
checkIOType(type);
- HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx,
type);
+ HibernateIdentityObject hibernateObject = safeGet(ctx, new
SimpleIdentityObject(name, type));
- HibernateIdentityObject hibernateObject = null;
-
- try
- {
- hibernateObject = (HibernateIdentityObject)getHibernateSession(ctx).
- createCriteria(HibernateIdentityObject.class)
- .add(Restrictions.eq("name", name))
- .createAlias("realm", "rm")
- .add(Restrictions.eq("rm.name", getRealmName(ctx)))
- .createAlias("identityType", "type")
- .add(Restrictions.eq("type.name", hibernateType.getName()))
- .setCacheable(true)
- .uniqueResult();
- }
- catch (Exception e)
- {
- if (log.isLoggable(Level.FINER))
- {
- log.log(Level.FINER, "Exception occurred: ", e);
- }
-
- throw new IdentityException("Cannot find IdentityObject with name
'" + name + "' and type '" + type.getName() +
"'", e);
- }
-
// Check result with case sensitive compare:
if (isAllowNotCaseSensitiveSearch())
{
@@ -738,6 +715,7 @@
checkIOType(identityType);
HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx,
identityType);
+ HibernateRealm realm = getRealm(getHibernateSession(ctx),ctx);
List<IdentityObject> results;
@@ -748,10 +726,8 @@
Criteria hc = hibernateSession.createCriteria(HibernateIdentityObject.class)
.setCacheable(true)
- .createAlias("realm", "rm")
- .add(Restrictions.eq("rm.name", getRealmName(ctx)))
- .createAlias("identityType", "type")
- .add(Restrictions.eq("type.name", hibernateType.getName()));
+ .add(Restrictions.eq("realm", realm))
+ .add(Restrictions.eq("identityType", hibernateType));
if (criteria != null && criteria.isSorted())
{
@@ -821,11 +797,22 @@
@SuppressWarnings("unchecked")
+ public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCxt,
+ IdentityObject identity,
+ IdentityObjectRelationshipType
relationshipType,
+ boolean parent,
+ IdentityObjectSearchCriteria
criteria) throws IdentityException
+ {
+ return findIdentityObject(invocationCxt, identity, relationshipType, null, parent,
criteria);
+ }
+
+ @SuppressWarnings("unchecked")
public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext ctx,
IdentityObject identity,
IdentityObjectRelationshipType
relationshipType,
+
Collection<IdentityObjectType> excludes,
boolean parent,
- IdentityObjectSearchCriteria
criteria) throws IdentityException
+ IdentityObjectSearchCriteria
criteria) throws IdentityException
{
//TODO:test
@@ -865,6 +852,18 @@
hqlString.append("select distinct ior.toIdentityObject from
HibernateIdentityObjectRelationship ior where " +
"ior.toIdentityObject.name like :nameFilter and
ior.fromIdentityObject = :identity");
}
+
+ if (excludes != null && excludes.size() > 0)
+ {
+
+ int i = 0;
+ for (IdentityObjectType exclude : excludes)
+ {
+ hqlString.append(" and ior.toIdentityObject.identityType.name !=
")
+ .append(":exclude" + i++);
+ }
+ }
+
if (orderByName)
{
hqlString.append(" order by ior.toIdentityObject.name");
@@ -887,9 +886,19 @@
"ior.fromIdentityObject.name like :nameFilter and
ior.toIdentityObject = :identity");
}
+ if (excludes != null && excludes.size() > 0)
+ {
+ int i = 0;
+ for (IdentityObjectType exclude : excludes)
+ {
+ hqlString.append(" and ior.fromIdentityObject.identityType.name !=
")
+ .append(":exclude" + i++);
+ }
+ }
+
if (orderByName)
{
- hqlString.append(" order by ior.toIdentityObject.name");
+ hqlString.append(" order by ior.fromIdentityObject.name");
if (ascending)
{
hqlString.append(" asc");
@@ -916,7 +925,14 @@
q.setParameter("nameFilter", "%");
}
-
+ if (excludes != null && excludes.size() > 0)
+ {
+ int i = 0;
+ for (IdentityObjectType exclude : excludes)
+ {
+ q.setParameter("exclude" + i++, exclude.getName());
+ }
+ }
if (criteria != null && criteria.isPaged() &&
!criteria.isFiltered())
{
q.setFirstResult(criteria.getFirstResult());
@@ -991,6 +1007,7 @@
}
HibernateIdentityObjectRelationship relationship = null;
+ HibernateRealm hibernateRealm = getRealm(getHibernateSession(ctx),ctx);
if (name != null)
{
@@ -999,9 +1016,8 @@
(HibernateIdentityObjectRelationshipName)getHibernateSession(ctx).
createCriteria(HibernateIdentityObjectRelationshipName.class).
setCacheable(true).
- createAlias("realm", "r").
add(Restrictions.eq("name", name)).
- add(Restrictions.eq("r.name", realm.getName())).
+ add(Restrictions.eq("realm", hibernateRealm)).
uniqueResult();
if (relationshipName == null)
@@ -1245,6 +1261,9 @@
criteria.add(Restrictions.eq("toIdentityObject", hio));
}
+ criteria.setFetchMode("fromIdentityObject", FetchMode.JOIN);
+ criteria.setFetchMode("toIdentityObject", FetchMode.JOIN);
+
List<HibernateIdentityObjectRelationship> results = criteria.list();
Hibernate.initialize(results);
@@ -1811,22 +1830,23 @@
public Map<String, IdentityObjectAttribute>
getAttributes(IdentityStoreInvocationContext ctx, IdentityObject identity) throws
IdentityException
{
- HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
+ HibernateRealm realm = getRealm(getHibernateSession(ctx), ctx);
+ HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx,
identity.getIdentityType());
-
-
Map<String, IdentityObjectAttribute> result = new HashMap<String,
IdentityObjectAttribute>();
- if (hibernateObject == null)
- {
- return result;
- }
+ Criteria criteria = getHibernateSession(ctx).
+ createCriteria(HibernateIdentityObjectAttribute.class)
+ .setCacheable(true)
+ .setFetchMode("textValues", FetchMode.JOIN)
+ .setFetchSize(20)
+ .createAlias("identityObject", "io")
+ .add(Restrictions.eq("io.name", identity.getName()))
+ .add(Restrictions.eq("io.realm", realm))
+ .add(Restrictions.eq("io.identityType", hibernateType));
- Set<HibernateIdentityObjectAttribute> storeAttributes =
hibernateObject.getAttributes();
+ Collection<HibernateIdentityObjectAttribute> storeAttributes =
(Collection<HibernateIdentityObjectAttribute>)criteria.list();
- Hibernate.initialize(storeAttributes);
-
-
// Remap the names
for (HibernateIdentityObjectAttribute attribute : storeAttributes)
{
@@ -2604,6 +2624,8 @@
{
HibernateIdentityObject hibernateObject = null;
+ HibernateIdentityObjectType hibernateType = getHibernateIdentityObjectType(ctx,
io.getIdentityType());
+ HibernateRealm realm = getRealm(getHibernateSession(ctx),ctx);
Session hibernateSession = getHibernateSession(ctx);
@@ -2612,10 +2634,8 @@
hibernateObject =
(HibernateIdentityObject)hibernateSession.createCriteria(HibernateIdentityObject.class)
.add(Restrictions.eq("name", io.getName()))
- .createAlias("identityType", "type")
- .add(Restrictions.eq("type.name", io.getIdentityType().getName()))
- .createAlias("realm", "rm")
- .add(Restrictions.eq("rm.name", getRealmName(ctx)))
+ .add(Restrictions.eq("identityType", hibernateType))
+ .add(Restrictions.eq("realm", realm))
.setCacheable(true)
.uniqueResult();
Modified:
idm/trunk/picketlink-idm-jpa/src/main/java/org/picketlink/idm/impl/store/jpa/JpaIdentityStore.java
===================================================================
---
idm/trunk/picketlink-idm-jpa/src/main/java/org/picketlink/idm/impl/store/jpa/JpaIdentityStore.java 2011-05-17
15:03:46 UTC (rev 945)
+++
idm/trunk/picketlink-idm-jpa/src/main/java/org/picketlink/idm/impl/store/jpa/JpaIdentityStore.java 2011-05-17
19:37:59 UTC (rev 946)
@@ -1319,11 +1319,25 @@
return objs;
}
- public Collection<IdentityObject> findIdentityObject(
- IdentityStoreInvocationContext invocationCxt, IdentityObject identity,
- IdentityObjectRelationshipType relationshipType, boolean parent,
- IdentityObjectSearchCriteria criteria) throws IdentityException
+
+
+ public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCxt,
+ IdentityObject identity,
+ IdentityObjectRelationshipType
relationshipType,
+ boolean parent,
+ IdentityObjectSearchCriteria
criteria) throws IdentityException
{
+ return findIdentityObject(invocationCxt, identity, relationshipType, null, parent,
criteria);
+ }
+
+
+ public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCxt,
+ IdentityObject identity,
+ IdentityObjectRelationshipType
relationshipType,
+
Collection<IdentityObjectType> excludes,
+ boolean parent,
+ IdentityObjectSearchCriteria
criteria) throws IdentityException
+ {
List<IdentityObject> objs = new ArrayList<IdentityObject>();
System.out.println("*** Invoked unimplemented method
findIdentityObject()");
Modified:
idm/trunk/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreImpl.java
===================================================================
---
idm/trunk/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2011-05-17
15:03:46 UTC (rev 945)
+++
idm/trunk/picketlink-idm-ldap/src/main/java/org/picketlink/idm/impl/store/ldap/LDAPIdentityStoreImpl.java 2011-05-17
19:37:59 UTC (rev 946)
@@ -1111,12 +1111,26 @@
}
+ public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext invocationCxt,
+ IdentityObject identity,
+ IdentityObjectRelationshipType
relationshipType,
+ boolean parent,
+ IdentityObjectSearchCriteria
criteria) throws IdentityException
+ {
+ return findIdentityObject(invocationCxt, identity, relationshipType, null, parent,
criteria);
+ }
+
+
public Collection<IdentityObject>
findIdentityObject(IdentityStoreInvocationContext ctx,
IdentityObject identity,
IdentityObjectRelationshipType
relationshipType,
+
Collection<IdentityObjectType> excludes,
boolean parent,
- IdentityObjectSearchCriteria
criteria) throws IdentityException
+ IdentityObjectSearchCriteria
criteria) throws IdentityException
{
+
+ //TODO: implement excludes
+
if (log.isLoggable(Level.FINER))
{
Tools.logMethodIn(
Modified:
idm/trunk/picketlink-idm-spi/src/main/java/org/picketlink/idm/spi/store/IdentityStore.java
===================================================================
---
idm/trunk/picketlink-idm-spi/src/main/java/org/picketlink/idm/spi/store/IdentityStore.java 2011-05-17
15:03:46 UTC (rev 945)
+++
idm/trunk/picketlink-idm-spi/src/main/java/org/picketlink/idm/spi/store/IdentityStore.java 2011-05-17
19:37:59 UTC (rev 946)
@@ -168,6 +168,24 @@
boolean parent,
IdentityObjectSearchCriteria
criteria) throws IdentityException;
+ /**
+ * Find identites that have relationship with given identity. Relationships are
directional (from parent to child).
+ *
+ * @param invocationCxt
+ * @param identity
+ * @param relationshipType
+ * @param excludes list of object types to not include in search
+ * @param parent defines if given identity is parent or child side in the
+ * relationship - default is true (parent)
+ * @param criteria
+ * @return
+ * @throws IdentityException
+ */
+ Collection<IdentityObject> findIdentityObject(IdentityStoreInvocationContext
invocationCxt, IdentityObject identity,
+ IdentityObjectRelationshipType
relationshipType,
+ Collection<IdentityObjectType>
excludes,
+ boolean parent,
+ IdentityObjectSearchCriteria
criteria) throws IdentityException;
/**
Modified: idm/trunk/pom.xml
===================================================================
--- idm/trunk/pom.xml 2011-05-17 15:03:46 UTC (rev 945)
+++ idm/trunk/pom.xml 2011-05-17 19:37:59 UTC (rev 946)
@@ -45,6 +45,26 @@
</modules>
</profile>
<profile>
+ <id>dev</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>parent</module>
+ <module>picketlink-idm-common</module>
+ <module>picketlink-idm-spi</module>
+ <module>picketlink-idm-api</module>
+ <module>picketlink-idm-core</module>
+ <module>picketlink-idm-testsuite/common</module>
+ <module>picketlink-idm-hibernate</module>
+ <module>picketlink-idm-jpa</module>
+ <module>picketlink-idm-ldap</module>
+ <module>picketlink-idm-cache</module>
+ <module>picketlink-idm-auth</module>
+ <module>picketlink-idm-testsuite/integration</module>
+ </modules>
+ </profile>
+ <profile>
<id>all</id>
<modules>
<module>parent</module>