Author: bdaw
Date: 2011-08-16 10:20:00 -0400 (Tue, 16 Aug 2011)
New Revision: 7158
Modified:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/IDMUserListAccess.java
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/IntegrationCache.java
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMServiceImpl.java
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInGroup.java
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/classes/picketlink-idm/mappings/HibernateIdentityObject.hbm.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/classes/picketlink-idm/mappings/HibernateIdentityObjectAttribute.hbm.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/classes/picketlink-idm/sybase-mappings/HibernateIdentityObject.hbm.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/classes/picketlink-idm/sybase-mappings/HibernateIdentityObjectAttribute.hbm.xml
Log:
JBEPP-901 Login time of user "root" depends on number of users in DB
JBEPP-903 Performance issue when showing OrganizationManagementPortlet when there are
many users in IDM DB
JBEPP-908 Inefficient search by atrributes (email) when create or update user
JBEPP-948 IDMUserListAccess.getSize() needs to call query for obtain all users from table
"jbid_io"
JBEPP-1064 Stale cache problem when deleting user
JBEPP-1059 Optimalization of criterias for finding single user in
HibernateIdentityStoreImpl
JBEPP-1058 Optimalization in call to persistenceManager.findUser called from
UserDAOImpl.getPopulatedUser
Modified:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java 2011-08-16
14:10:49 UTC (rev 7157)
+++
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java 2011-08-16
14:20:00 UTC (rev 7158)
@@ -235,6 +235,9 @@
try
{
+
+ orgService.flush();
+
jbidGroup =
getIdentitySession().getPersistenceManager().
findGroup(plGroupName,
orgService.getConfiguration().getGroupType(group.getParentId()));
@@ -253,6 +256,8 @@
try
{
+ orgService.flush();
+
Collection<org.picketlink.idm.api.Group> oneLevelChilds =
getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup,
null, true, false);
@@ -308,6 +313,8 @@
try
{
+ orgService.flush();
+
allRoles = getIdentitySession().getRoleManager().findRoles(userName,
membershipType);
}
catch (Exception e)
@@ -333,6 +340,8 @@
try
{
+ orgService.flush();
+
groups =
getIdentitySession().getRelationshipManager().findAssociatedGroups(userName, null);
}
catch (Exception e)
@@ -462,6 +471,8 @@
try
{
+ orgService.flush();
+
plGroups.addAll(getIdentitySession().getRelationshipManager().
findAssociatedGroups(jbidGroup, null, true, false));
}
@@ -591,6 +602,8 @@
try
{
+ orgService.flush();
+
allGroups =
getIdentitySession().getRelationshipManager().findRelatedGroups(user, null, null);
}
catch (Exception e)
@@ -638,6 +651,9 @@
try
{
+
+ orgService.flush();
+
plGroups
.addAll(getIdentitySession().getRelationshipManager().findAssociatedGroups(getRootGroup(),
null, true, true));
}
@@ -746,6 +762,8 @@
try
{
+ orgService.flush();
+
attrs = getIdentitySession().getAttributesManager().getAttributes(jbidGroup);
}
catch (Exception e)
@@ -869,6 +887,8 @@
try
{
+ orgService.flush();
+
parents =
getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup, null, false,
false);
}
catch (Exception e)
Modified:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/IDMUserListAccess.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/IDMUserListAccess.java 2011-08-16
14:10:49 UTC (rev 7157)
+++
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/IDMUserListAccess.java 2011-08-16
14:20:00 UTC (rev 7158)
@@ -21,6 +21,8 @@
import org.exoplatform.commons.utils.ListAccess;
import org.exoplatform.services.organization.User;
+import org.exoplatform.services.organization.impl.UserImpl;
+
import org.gatein.common.logging.LogLevel;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
@@ -29,12 +31,13 @@
import org.picketlink.idm.api.query.UserQueryBuilder;
+import java.io.Serializable;
import java.util.List;
/*
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
*/
-public class IDMUserListAccess implements ListAccess<User>
+public class IDMUserListAccess implements ListAccess<User>, Serializable
{
private static Logger log = LoggerFactory.getLogger(IDMUserListAccess.class);
@@ -48,6 +51,10 @@
private final boolean countAll;
+ private List<org.picketlink.idm.api.User> fullResults;
+
+ private int size = -1;
+
public IDMUserListAccess(UserDAOImpl userDAO, PicketLinkIDMService idmService,
UserQueryBuilder userQueryBuilder,
int pageSize, boolean countAll)
{
@@ -73,17 +80,30 @@
);
}
- userQueryBuilder.page(index, length);
- UserQuery query = userQueryBuilder.sort(SortOrder.ASCENDING).createQuery();
- List<org.picketlink.idm.api.User> users =
idmService.getIdentitySession().list(query);
+ List<org.picketlink.idm.api.User> users = null;
+ if (fullResults == null)
+ {
+ userDAO.getOrgService().flush();
+
+ userQueryBuilder.page(index, length);
+ UserQuery query = userQueryBuilder.sort(SortOrder.ASCENDING).createQuery();
+ users = idmService.getIdentitySession().list(query);
+ }
+ else
+ {
+ users = fullResults.subList(index, index + length);
+ }
+
User[] exoUsers = new User[users.size()];
for (int i = 0; i < users.size(); i++)
{
org.picketlink.idm.api.User user = users.get(i);
- exoUsers[i] = UserDAOImpl.getPopulatedUser(user.getId(),
idmService.getIdentitySession());
+ User gtnUser = new UserImpl(user.getId());
+ userDAO.populateUser(gtnUser, idmService.getIdentitySession());
+ exoUsers[i] = gtnUser;
}
if (log.isTraceEnabled())
@@ -111,22 +131,39 @@
);
}
+ userDAO.getOrgService().flush();
+
int result;
- if (countAll)
+ if (size < 0)
{
- result =
idmService.getIdentitySession().getPersistenceManager().getUserCount();
+
+ if (fullResults != null)
+ {
+ result = fullResults.size();
+ }
+ else if (countAll)
+ {
+ result =
idmService.getIdentitySession().getPersistenceManager().getUserCount();
+ }
+ else
+ {
+ userQueryBuilder.page(0, 0);
+ UserQuery query = userQueryBuilder.sort(SortOrder.ASCENDING).createQuery();
+ fullResults = idmService.getIdentitySession().list(query);
+ result = fullResults.size();
+ }
+
+ size = result;
}
else
{
- userQueryBuilder.page(0, 0);
- UserQuery query = userQueryBuilder.sort(SortOrder.ASCENDING).createQuery();
- result = idmService.getIdentitySession().execute(query).size();
+ result = size;
}
if (log.isTraceEnabled())
{
- Tools.logMethodOut(
+ Tools.logMethodOut(
log,
LogLevel.TRACE,
"getSize",
Modified:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/IntegrationCache.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/IntegrationCache.java 2011-08-16
14:10:49 UTC (rev 7157)
+++
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/IntegrationCache.java 2011-08-16
14:20:00 UTC (rev 7158)
@@ -1,11 +1,17 @@
package org.exoplatform.services.organization.idm;
+import org.exoplatform.commons.utils.LazyPageList;
+import org.exoplatform.services.organization.Query;
+
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheStatus;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
+import org.jboss.cache.eviction.ExpirationConfiguration;
+
import org.picketlink.idm.api.Group;
import org.picketlink.idm.api.User;
@@ -51,10 +57,14 @@
public static final String NULL_NS_NODE = "GTN_IC_COMMON_NS";
+ public static final String USER_QUERY_NODE = "GTN_USER_QUERY_LAZY_LIST";
+
public static final String MAIN_ROOT =
"NODE_GTN_ORG_SERVICE_INT_CACHE_MAIN_ROOT";
public static final String NODE_OBJECT_KEY = "object";
+ private int expiration = -1;
+
private Fqn getRootNode()
{
return Fqn.fromString("/" + MAIN_ROOT);
@@ -152,6 +162,7 @@
if (ioNode != null)
{
ioNode.put(NODE_OBJECT_KEY, id);
+ setExpiration(ioNode);
if (log.isLoggable(Level.FINER))
{
@@ -192,7 +203,61 @@
}
+ /**
+ * Store IDMUserListAccess
+ * @param ns
+ * @param query
+ * @param list
+ */
+ void putGtnUserLazyPageList(String ns, Query query, IDMUserListAccess list)
+ {
+ Fqn nodeFqn = getFqn(ns, USER_QUERY_NODE, getQueryKey(query));
+
+ Node ioNode = getCache().getRoot().addChild(nodeFqn);
+
+ if (ioNode != null)
+ {
+ ioNode.put(NODE_OBJECT_KEY, list);
+ setExpiration(ioNode);
+
+ if (log.isLoggable(Level.FINER))
+ {
+
+ log.finer(this.toString() + "GateIn user query list cached. Query:
" + getQueryKey(query) + ";namespace=" + ns);
+ }
+ }
+ }
+
/**
+ * Retrieve IDMUserListAccess
+ * @param ns
+ * @param query
+ * @return LazyPageList
+ */
+ IDMUserListAccess getGtnUserLazyPageList(String ns, Query query)
+ {
+
+ Fqn nodeFqn = getFqn(ns, USER_QUERY_NODE, getQueryKey(query));
+
+ Node node = getCache().getRoot().getChild(nodeFqn);
+
+ if (node != null)
+ {
+ IDMUserListAccess list = (IDMUserListAccess)node.get(NODE_OBJECT_KEY);
+
+ if (log.isLoggable(Level.FINER) && list != null)
+ {
+ log.finer(this.toString() + "GateIn user query list found in cache.
Query: " + getQueryKey(query) + ";namespace=" + ns);
+ }
+
+ return list;
+ }
+
+ return null;
+
+ }
+
+ /**
* Store PLIDM root group
* @param ns
* @param rootGroup
@@ -205,6 +270,7 @@
if (ioNode != null)
{
+ setExpiration(ioNode);
ioNode.put(NODE_OBJECT_KEY, rootGroup);
if (log.isLoggable(Level.FINER))
@@ -242,4 +308,37 @@
}
+ 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;
+ }
+
+ String getQueryKey(Query query)
+ {
+ StringBuilder sb = new StringBuilder();
+ String SEP = ":::";
+
+ sb.append(query.getEmail()).append(SEP)
+ .append(query.getFirstName()).append(SEP)
+ .append(query.getLastName()).append(SEP)
+ .append(query.getUserName()).append(SEP)
+ .append(query.getFromLoginDate()).append(SEP)
+ .append(query.getToLoginDate()).append(SEP);
+
+ return sb.toString();
+ }
}
Modified:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java 2011-08-16
14:10:49 UTC (rev 7157)
+++
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java 2011-08-16
14:20:00 UTC (rev 7158)
@@ -120,6 +120,8 @@
);
}
+ orgService.flush();
+
if (g == null)
{
throw new InvalidNameException("Can not create membership record for "
+ user.getUserName()
@@ -197,6 +199,7 @@
);
}
+ orgService.flush();
String plGroupName = getPLIDMGroupName(getGroupNameFromId(m.getGroupId()));
@@ -278,6 +281,7 @@
);
}
+ orgService.flush();
Membership m = new MembershipImpl(id);
@@ -377,6 +381,7 @@
);
}
+ orgService.flush();
Collection<Role> roles = new HashSet();
@@ -473,6 +478,7 @@
);
}
+ orgService.flush();
String plGroupName = getPLIDMGroupName(getGroupNameFromId(groupId));
@@ -565,6 +571,8 @@
);
}
+ orgService.flush();
+
if (userName == null)
{
// julien fix : if user name is null, need to check if we do need to return a
special group
@@ -667,6 +675,7 @@
);
}
+ orgService.flush();
Collection<Role> roles = new HashSet();
@@ -759,6 +768,8 @@
);
}
+ orgService.flush();
+
String plGroupName = getPLIDMGroupName(getGroupNameFromId(groupId));
String gid =
@@ -780,12 +791,13 @@
HashSet<MembershipImpl> memberships = new HashSet<MembershipImpl>();
+ Group g = orgService.getGroupHandler().findGroupById(groupId);
+
for (Role role : roles)
{
if (isCreateMembership(role.getRoleType().getName()))
{
MembershipImpl m = new MembershipImpl();
- Group g =
((GroupDAOImpl)orgService.getGroupHandler()).convertGroup(role.getGroup());
m.setGroupId(g.getId());
m.setUserName(role.getUser().getId());
m.setMembershipType(role.getRoleType().getName());
@@ -856,6 +868,8 @@
);
}
+ orgService.flush();
+
Membership m = new MembershipImpl(id);
String plGroupName = getPLIDMGroupName(getGroupNameFromId(m.getGroupId()));
Modified:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java 2011-08-16
14:10:49 UTC (rev 7157)
+++
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java 2011-08-16
14:20:00 UTC (rev 7158)
@@ -45,7 +45,7 @@
// We may have several portal containers thus we need one PicketLinkIDMService per
portal container
// private static PicketLinkIDMService jbidmService_;
- private PicketLinkIDMService idmService_;
+ private PicketLinkIDMServiceImpl idmService_;
public static final String CONFIGURATION_OPTION = "configuration";
@@ -60,7 +60,7 @@
membershipDAO_ = new MembershipDAOImpl(this, idmService);
membershipTypeDAO_ = new MembershipTypeDAOImpl(this, idmService);
- idmService_ = idmService;
+ idmService_ = (PicketLinkIDMServiceImpl)idmService;
if (params != null)
{
@@ -152,6 +152,7 @@
}
else
{
+
if (!idmService_.getIdentitySession().getTransaction().isActive())
{
idmService_.getIdentitySession().beginTransaction();
@@ -164,6 +165,44 @@
}
}
+
+ public void flush()
+ {
+ try
+ {
+
+
+ if (configuration.isUseJTA())
+ {
+ UserTransaction tx = (UserTransaction)new
InitialContext().lookup("java:comp/UserTransaction");
+
+ if (tx.getStatus() != Status.STATUS_NO_TRANSACTION)
+ {
+ tx.commit();
+ }
+
+ if (tx.getStatus() == Status.STATUS_NO_TRANSACTION)
+ {
+ tx.begin();
+ }
+ }
+ else
+ {
+ if (idmService_.getIdentitySession().getTransaction().isActive())
+ {
+ idmService_.getIdentitySession().save();
+ }
+ }
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+
+
public void endRequest(ExoContainer container)
{
try
Modified:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMServiceImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMServiceImpl.java 2011-08-16
14:10:49 UTC (rev 7157)
+++
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMServiceImpl.java 2011-08-16
14:20:00 UTC (rev 7158)
@@ -29,6 +29,8 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.DefaultCacheFactory;
+
+import org.jgroups.JChannelFactory;
import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.api.IdentitySessionFactory;
import org.picketlink.idm.api.cfg.IdentityConfiguration;
@@ -52,7 +54,7 @@
public class PicketLinkIDMServiceImpl implements PicketLinkIDMService, Startable
{
- private static Log log_ = ExoLogger.getLogger(PicketLinkIDMServiceImpl.class);
+ private static Log log = ExoLogger.getLogger(PicketLinkIDMServiceImpl.class);
public static final String PARAM_CONFIG_OPTION = "config";
@@ -70,6 +72,12 @@
public static final String CACHE_CONFIG_STORE_OPTION = "storeCacheConfig";
+ public static final String JGROUPS_CONFIG = "jgroups-configuration";
+
+ public static final String JGROUPS_MUX_ENABLED =
"jgroups-multiplexer-stack";
+
+ public static final String CACHE_EXPIRATION = "cacheExpiration";
+
private IdentitySessionFactory identitySessionFactory;
private String config;
@@ -80,6 +88,10 @@
private IntegrationCache integrationCache;
+ private static final JChannelFactory CHANNEL_FACTORY = new JChannelFactory();
+
+ private HibernateService hibernateService;
+
private PicketLinkIDMServiceImpl()
{
}
@@ -96,7 +108,12 @@
ValueParam realmName = initParams.getValueParam(REALM_NAME_OPTION);
ValueParam apiCacheConfig = initParams.getValueParam(CACHE_CONFIG_API_OPTION);
ValueParam storeCacheConfig = initParams.getValueParam(CACHE_CONFIG_STORE_OPTION);
+ ValueParam jgroupsStack = initParams.getValueParam(JGROUPS_MUX_ENABLED);
+ ValueParam jgroupsConfig = initParams.getValueParam(JGROUPS_CONFIG);
+ ValueParam cacheExpirationParam = initParams.getValueParam(CACHE_EXPIRATION);
+ this.hibernateService = hibernateService;
+
if (config == null && jndiName == null)
{
throw new IllegalStateException("Either '" + PARAM_CONFIG_OPTION +
"' or '" + PARAM_JNDI_NAME_OPTION
@@ -126,11 +143,20 @@
identityConfiguration.getIdentityConfigurationRegistry().register(hibernateService.getSessionFactory(),
"hibernateSessionFactory");
+ int expiration = -1;
+
+ if (cacheExpirationParam != null &&
+ cacheExpirationParam.getValue() != null &&
+ cacheExpirationParam.getValue().length() > 0)
+ {
+ expiration = Integer.decode(cacheExpirationParam.getValue());
+ }
+
if (apiCacheConfig != null)
{
+
InputStream configStream =
confManager.getInputStream(apiCacheConfig.getValue());
- // Create common JBoss Cache instance
CacheFactory factory = new DefaultCacheFactory();
if (configStream == null)
@@ -140,6 +166,8 @@
Cache cache = factory.createCache(configStream);
+ applyJGroupsConfig(cache, confManager, jgroupsStack, jgroupsConfig);
+
cache.create();
cache.start();
@@ -147,22 +175,43 @@
// PLIDM API cache
JBossCacheAPICacheProviderImpl apiCacheProvider = new
JBossCacheAPICacheProviderImpl();
+ apiCacheProvider.setExpiration(expiration);
apiCacheProvider.initialize(cache);
picketLinkIDMCache.register(apiCacheProvider);
identityConfiguration.getIdentityConfigurationRegistry().register(apiCacheProvider,
"apiCacheProvider");
//Integration cache
integrationCache = new IntegrationCache();
+ integrationCache.setExpiration(expiration);
integrationCache.initialize(cache);
picketLinkIDMCache.register(integrationCache);
}
+
+
if (storeCacheConfig != null)
{
InputStream configStream =
confManager.getInputStream(storeCacheConfig.getValue());
+ CacheFactory factory = new DefaultCacheFactory();
+
+ if (configStream == null)
+ {
+ throw new IllegalArgumentException("JBoss Cache configuration
InputStream is null");
+ }
+
+ Cache cache = factory.createCache(configStream);
+
+ applyJGroupsConfig(cache, confManager, jgroupsStack, jgroupsConfig);
+
+ cache.create();
+ cache.start();
+
+ configStream.close();
+
JBossCacheIdentityStoreCacheProviderImpl storeCacheProvider = new
JBossCacheIdentityStoreCacheProviderImpl();
- storeCacheProvider.initialize(configStream);
+ storeCacheProvider.setExpiration(expiration);
+ storeCacheProvider.initialize(cache);
picketLinkIDMCache.register(storeCacheProvider);
identityConfiguration.getIdentityConfigurationRegistry().register(storeCacheProvider,
"storeCacheProvider");
@@ -225,4 +274,66 @@
{
return realmName;
}
+
+ /**
+ * Applying JGroups configuration for JBossCache.
+ * Code forked from org.exoplatform.services.jcr.jbosscacheExoJBossCacheFactory
+ *
+ * @param cache
+ * @param configurationManager
+ * @param jgroupsEnabledParam
+ * @param jgroupsConfigurationParam
+ */
+ private void applyJGroupsConfig(Cache cache,
+ ConfigurationManager configurationManager,
+ ValueParam jgroupsEnabledParam,
+ ValueParam jgroupsConfigurationParam)
+ {
+
+ String jgroupsEnabled = jgroupsEnabledParam != null ?
jgroupsEnabledParam.getValue() : null;
+ String jgroupsConfiguration = jgroupsConfigurationParam != null ?
jgroupsConfigurationParam.getValue() : null;
+
+ // JGroups multiplexer configuration if enabled
+ if (jgroupsEnabled != null &&
jgroupsEnabled.equalsIgnoreCase("true"))
+ {
+ try
+ {
+ if (jgroupsConfiguration != null)
+ {
+ // Create and inject multiplexer factory
+
CHANNEL_FACTORY.setMultiplexerConfig(configurationManager.getResource(jgroupsConfiguration));
+
cache.getConfiguration().getRuntimeConfig().setMuxChannelFactory(CHANNEL_FACTORY);
+ log.info("Multiplexer stack successfully enabled for the
cache.");
+ }
+ }
+ catch (Exception e)
+ {
+ // exception occurred setting mux factory
+ throw new IllegalStateException("Error setting multiplexer
configuration.", e);
+ }
+ }
+ else
+ {
+ // Multiplexer is not enabled. If jGroups configuration preset it is applied
+ if (jgroupsConfiguration != null)
+ {
+ try
+ {
+ cache.getConfiguration().setJgroupsConfigFile(
+ configurationManager.getResource(jgroupsConfiguration));
+ log.info("Custom JGroups configuration set:"
+ + configurationManager.getResource(jgroupsConfiguration));
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Error setting JGroups
configuration.", e);
+ }
+ }
+ }
+ }
+
+ public HibernateService getHibernateService()
+ {
+ return hibernateService;
+ }
}
Modified:
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java 2011-08-16
14:10:49 UTC (rev 7157)
+++
epp/portal/branches/EPP_5_2_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java 2011-08-16
14:20:00 UTC (rev 7158)
@@ -21,8 +21,6 @@
import org.exoplatform.commons.utils.LazyPageList;
import org.exoplatform.commons.utils.ListAccess;
-import org.exoplatform.services.cache.CacheService;
-import org.exoplatform.services.cache.ExoCache;
import org.exoplatform.services.organization.Query;
import org.exoplatform.services.organization.User;
import org.exoplatform.services.organization.UserEventListener;
@@ -37,6 +35,7 @@
import org.picketlink.idm.api.query.UserQueryBuilder;
import org.picketlink.idm.common.exception.IdentityException;
import org.picketlink.idm.impl.api.SimpleAttribute;
+import org.picketlink.idm.impl.api.model.SimpleUser;
import java.text.DateFormat;
import java.text.ParseException;
@@ -145,6 +144,8 @@
try
{
+ orgService.flush();
+
session.getPersistenceManager().createUser(user.getUserName());
}
catch (IdentityException e)
@@ -214,6 +215,8 @@
try
{
+ orgService.flush();
+
foundUser = session.getPersistenceManager().findUser(userName);
}
catch (IdentityException e)
@@ -256,6 +259,11 @@
}
+ if (getIntegrationCache() != null)
+ {
+ getIntegrationCache().invalidateAll();
+ }
+
if (broadcast)
{
postDelete(exoUser);
@@ -361,6 +369,8 @@
{
try
{
+ orgService.flush();
+
IdentitySession session = service_.getIdentitySession();
org.picketlink.idm.api.User idmUser =
session.getPersistenceManager().findUser(user.getUserName());
@@ -407,7 +417,64 @@
);
}
+ // if only condition is email which is unique then delegate to other method as it
will be more efficient
+ if (q.getUserName() == null &&
+ q.getEmail() != null &&
+ q.getFirstName() == null &&
+ q.getLastName() == null)
+ {
+ final User uniqueUser = findUserByEmail(q.getEmail());
+ if (uniqueUser != null)
+ {
+ return new LazyPageList<User>( new ListAccess<User>()
+ {
+ public User[] load(int index, int length) throws Exception,
IllegalArgumentException
+ {
+ return new User[]{uniqueUser};
+ }
+
+ public int getSize() throws Exception
+ {
+ return 1;
+ }
+ }, 1);
+ }
+ else
+ {
+ return new LazyPageList<User>( new ListAccess<User>()
+ {
+ public User[] load(int index, int length) throws Exception,
IllegalArgumentException
+ {
+ return new User[0];
+ }
+
+ public int getSize() throws Exception
+ {
+ return 0;
+ }
+ }, 1);
+ }
+ }
+
+
+ // otherwise use PLIDM queries
+
+ IDMUserListAccess list;
+
+ IntegrationCache cache = getIntegrationCache();
+
+ if (cache != null)
+ {
+ list = cache.getGtnUserLazyPageList(getCacheNS(), q);
+ if (list != null)
+ {
+ return new LazyPageList(list, 20);
+ }
+ }
+
+ orgService.flush();
+
UserQueryBuilder qb = service_.getIdentitySession().createUserQueryBuilder();
if (q.getUserName() != null)
@@ -430,7 +497,26 @@
qb.attributeValuesFilter(UserDAOImpl.USER_LAST_NAME, new
String[]{q.getLastName()});
}
- return new LazyPageList(new IDMUserListAccess(this, service_, qb, 20, false), 20);
+
+
+ if (q.getUserName() == null &&
+ q.getEmail() == null &&
+ q.getFirstName() == null &&
+ q.getLastName() == null)
+ {
+ list = new IDMUserListAccess(this, service_, qb, 20, true);
+ }
+ else
+ {
+ list = new IDMUserListAccess(this, service_, qb, 20, false);
+ }
+
+ if (cache != null)
+ {
+ cache.putGtnUserLazyPageList(getCacheNS(), q, list);
+ }
+
+ return new LazyPageList(list, 20);
}
//
@@ -494,6 +580,8 @@
try
{
+ orgService.flush();
+
plUser = session.getAttributesManager().findUserByUniqueAttribute(USER_EMAIL,
email);
}
catch (IdentityException e)
@@ -565,6 +653,7 @@
public void persistUserInfo(User user, IdentitySession session) throws Exception
{
+ orgService.flush();
AttributesManager am = session.getAttributesManager();
@@ -629,10 +718,12 @@
}
- public static User getPopulatedUser(String userName, IdentitySession session) throws
Exception
+ public User getPopulatedUser(String userName, IdentitySession session) throws
Exception
{
Object u = null;
+ orgService.flush();
+
try
{
u = session.getPersistenceManager().findUser(userName);
@@ -656,8 +747,9 @@
}
- public static void populateUser(User user, IdentitySession session) throws Exception
+ public void populateUser(User user, IdentitySession session) throws Exception
{
+ orgService.flush();
AttributesManager am = session.getAttributesManager();
@@ -665,7 +757,7 @@
try
{
- attrs = am.getAttributes(user.getUserName());
+ attrs = am.getAttributes(new SimpleUser(user.getUserName()));
}
catch (IdentityException e)
{
@@ -754,4 +846,26 @@
}
}
+ public PicketLinkIDMOrganizationServiceImpl getOrgService()
+ {
+ return orgService;
+ }
+
+ private IntegrationCache getIntegrationCache()
+ {
+ // TODO: refactor to remove cast. For now to avoid adding new config option and
share existing cache instannce
+ // TODO: it should be there.
+ return ((PicketLinkIDMServiceImpl)service_).getIntegrationCache();
+ }
+
+ /**
+ * Returns namespace to be used with integration cache
+ * @return
+ */
+ private String getCacheNS()
+ {
+ // TODO: refactor to remove cast. For now to avoid adding new config option and
share existing cache instannce
+ // TODO: it should be there.
+ return ((PicketLinkIDMServiceImpl)service_).getRealmName();
+ }
}
Modified:
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInGroup.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInGroup.java 2011-08-16
14:10:49 UTC (rev 7157)
+++
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInGroup.java 2011-08-16
14:20:00 UTC (rev 7158)
@@ -133,7 +133,6 @@
{
OrganizationService service =
getApplicationComponent(OrganizationService.class);
MembershipHandler handler = service.getMembershipHandler();
- List<?> memberships =
(List<?>)handler.findMembershipsByGroup(group);
pageList = new FindMembershipByGroupPageList(group.getId(), 10);
}
UIGridUser uiGrid = getChild(UIGridUser.class);
Modified:
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/classes/picketlink-idm/mappings/HibernateIdentityObject.hbm.xml
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/classes/picketlink-idm/mappings/HibernateIdentityObject.hbm.xml 2011-08-16
14:10:49 UTC (rev 7157)
+++
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/classes/picketlink-idm/mappings/HibernateIdentityObject.hbm.xml 2011-08-16
14:20:00 UTC (rev 7158)
@@ -12,6 +12,7 @@
<generator class="native"/>
</id>
<set name="attributes"
+ batch-size="20"
inverse="true"
cascade="all, delete-orphan"
lazy="extra"
Modified:
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/classes/picketlink-idm/mappings/HibernateIdentityObjectAttribute.hbm.xml
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/classes/picketlink-idm/mappings/HibernateIdentityObjectAttribute.hbm.xml 2011-08-16
14:10:49 UTC (rev 7157)
+++
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/classes/picketlink-idm/mappings/HibernateIdentityObjectAttribute.hbm.xml 2011-08-16
14:20:00 UTC (rev 7158)
@@ -35,8 +35,9 @@
table="jbid_io_attr_text_values"
cascade="all, delete-orphan"
access="field"
- lazy="extra"
- fetch="subselect">
+ lazy="false"
+ fetch="join"
+ batch-size="20">
<cache usage="transactional"/>
<key column="TEXT_ATTR_VALUE_ID"/>
<element type="string"
Modified:
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/classes/picketlink-idm/sybase-mappings/HibernateIdentityObject.hbm.xml
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/classes/picketlink-idm/sybase-mappings/HibernateIdentityObject.hbm.xml 2011-08-16
14:10:49 UTC (rev 7157)
+++
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/classes/picketlink-idm/sybase-mappings/HibernateIdentityObject.hbm.xml 2011-08-16
14:20:00 UTC (rev 7158)
@@ -12,6 +12,7 @@
<generator class="native"/>
</id>
<set name="attributes"
+ batch-size="20"
inverse="true"
cascade="all, delete-orphan"
lazy="extra"
Modified:
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/classes/picketlink-idm/sybase-mappings/HibernateIdentityObjectAttribute.hbm.xml
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/classes/picketlink-idm/sybase-mappings/HibernateIdentityObjectAttribute.hbm.xml 2011-08-16
14:10:49 UTC (rev 7157)
+++
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/classes/picketlink-idm/sybase-mappings/HibernateIdentityObjectAttribute.hbm.xml 2011-08-16
14:20:00 UTC (rev 7158)
@@ -35,8 +35,9 @@
table="jbid_io_attr_text_values"
cascade="all, delete-orphan"
access="field"
- lazy="extra"
- fetch="subselect">
+ lazy="false"
+ fetch="join"
+ batch-size="20">
<cache usage="transactional"/>
<key column="TEXT_ATTR_VALUE_ID"/>
<element type="string"