// query from database if not cached and cache
DatabasePageManagerCachedFragmentPropertyList globalFragmentPropertyList = DatabasePageManagerCache.fragmentPropertyListCacheLookup(fragmentKey);
if (globalFragmentPropertyList == null)
{
globalFragmentPropertyList = new DatabasePageManagerCachedFragmentPropertyList(baseFragmentElementImpl.getBaseFragmentsElement().getPath());
Criteria filter = new Criteria();
filter.addEqualTo("fragment", new Integer(baseFragmentElementImpl.getIdentity()));
filter.addIsNull("scope");
QueryByCriteria query = QueryFactory.newQuery(FragmentPropertyImpl.class, filter);
Collection fragmentProperties = getPersistenceBrokerTemplate().getCollectionByQuery(query);
globalFragmentPropertyList.addAll(fragmentProperties);
DatabasePageManagerCache.fragmentPropertyListCacheAdd(fragmentKey, globalFragmentPropertyList, false);
}
Map principalFragmentPropertyLists = null;
DatabasePageManagerCachedFragmentPropertyList userFragmentPropertyList = null;
if (subject != null)
{
if (GROUP_AND_ROLE_PROPERTY_SCOPES_ENABLED)
{
Set principals = subject.getPrincipals();
Iterator principalsIter = principals.iterator();
while (principalsIter.hasNext())
{
Principal principal = (Principal)principalsIter.next();
String principalScope = null;
if (principal instanceof User)
{
principalScope = USER_PROPERTY_SCOPE;
}
else if (principal instanceof Group)
{
principalScope = GROUP_PROPERTY_SCOPE;
}
else if (principal instanceof Role)
{
principalScope = ROLE_PROPERTY_SCOPE;
}
if (principalScope != null)
{
String principalKey = getFragmentPropertyListPrincipalKey(principalScope, principal.getName());
DatabasePageManagerCachedFragmentPropertyList principalFragmentPropertyList = DatabasePageManagerCache.principalFragmentPropertyListCacheLookup(principalKey);
if (principalFragmentPropertyList == null)
{
principalFragmentPropertyList = new DatabasePageManagerCachedFragmentPropertyList(principalScope, principalKey);
Criteria filter = new Criteria();
filter.addEqualTo("scope", principalScope);
filter.addEqualTo("scopeValue", principal.getName());
QueryByCriteria query = QueryFactory.newQuery(FragmentPropertyImpl.class, filter);
Collection fragmentProperties = getPersistenceBrokerTemplate().getCollectionByQuery(query);
principalFragmentPropertyList.addAll(fragmentProperties);
DatabasePageManagerCache.principalFragmentPropertyListCacheAdd(principalKey, principalFragmentPropertyList, false);
}
if (principalFragmentPropertyList != null)
{
if (principalFragmentPropertyLists == null)
{
principalFragmentPropertyLists = new HashMap();
}
principalFragmentPropertyLists.put(principalKey, principalFragmentPropertyList);
}
}
}
}
else if (userPrincipal != null)
{
String principalKey = getFragmentPropertyListPrincipalKey(USER_PROPERTY_SCOPE, userPrincipal.getName());
userFragmentPropertyList = DatabasePageManagerCache.principalFragmentPropertyListCacheLookup(principalKey);
if (userFragmentPropertyList == null)
{
userFragmentPropertyList = new DatabasePageManagerCachedFragmentPropertyList(USER_PROPERTY_SCOPE, principalKey);
Criteria filter = new Criteria();
filter.addEqualTo("scope", USER_PROPERTY_SCOPE);
filter.addEqualTo("scopeValue", userPrincipal.getName());
QueryByCriteria query = QueryFactory.newQuery(FragmentPropertyImpl.class, filter);
Collection fragmentProperties = getPersistenceBrokerTemplate().getCollectionByQuery(query);
userFragmentPropertyList.addAll(fragmentProperties);
DatabasePageManagerCache.principalFragmentPropertyListCacheAdd(principalKey, userFragmentPropertyList, false);
}