use of net.sf.ehcache.Element in project uPortal by Jasig.
the class LocalGroupsCacheAuthenticationListener method userAuthenticated.
@Override
public void userAuthenticated(IPerson user) {
/*
* Used to log the time it takes to complete this operation; the author
* has some anxiety about running time with large numbers of elements in
* the cache.
*/
final long timestamp = System.currentTimeMillis();
/*
* Group/member relationships are cached 2 ways: child-to-parents and
* parent-to-children. We need to flush both.
*/
final EntityIdentifier ei = user.getEntityIdentifier();
final Element parentGroupsElement = parentGroupsCache.get(ei);
if (parentGroupsElement != null) {
// We have some flushing work to do...
final Set<IEntityGroup> parentGroups = (Set<IEntityGroup>) parentGroupsElement.getObjectValue();
for (IEntityGroup group : parentGroups) {
final EntityIdentifier uei = group.getUnderlyingEntityIdentifier();
childrenCache.remove(uei);
}
parentGroupsCache.remove(ei);
logger.debug("Purged the following local group cache entries for authenticated user '{}' in {}ms: {}", user.getUserName(), Long.toBinaryString(System.currentTimeMillis() - timestamp), parentGroups);
}
}
use of net.sf.ehcache.Element in project uPortal by Jasig.
the class EhcacheMemberIdAttributeExtractorTest method testAttributeFor.
@Test
public void testAttributeFor() {
final EntityIdentifier parentEntityIdentifier = new EntityIdentifier("mock.group", IPerson.class);
final String memberId = "mock.user";
final EntityIdentifier childEntityIdentifier = new EntityIdentifier(memberId, IPerson.class);
final MembershipCacheKey membershipCacheKey = new MembershipCacheKey(parentEntityIdentifier, childEntityIdentifier);
final Element element = new Element(membershipCacheKey, new Object());
final EhcacheMemberIdAttributeExtractor attributeExtractor = new EhcacheMemberIdAttributeExtractor();
Assert.assertEquals(attributeExtractor.attributeFor(element, null), memberId);
}
use of net.sf.ehcache.Element in project uPortal by Jasig.
the class EntityPersonAttributesGroupStore method convertPagsGroupToEntity.
private IEntityGroup convertPagsGroupToEntity(IPersonAttributesGroupDefinition group) {
final String cacheKey = group.getName();
Element element = entityGroupCache.get(cacheKey);
if (element == null) {
final IEntityGroup entityGroup = new EntityTestingGroupImpl(group.getName(), IPERSON_CLASS);
entityGroup.setName(group.getName());
entityGroup.setDescription(group.getDescription());
element = new Element(cacheKey, entityGroup);
entityGroupCache.put(element);
}
return (IEntityGroup) element.getObjectValue();
}
use of net.sf.ehcache.Element in project uPortal by Jasig.
the class LayoutCachingService method getCachedLayout.
@Override
public DistributedUserLayout getCachedLayout(IPerson owner, IUserProfile profile) {
final CacheKey cacheKey = this.getCacheKey(owner, profile);
final Element element = this.layoutCache.get(cacheKey);
if (element != null) {
return (DistributedUserLayout) element.getObjectValue();
}
return null;
}
use of net.sf.ehcache.Element in project uPortal by Jasig.
the class AbstractDynamicSkinService method getSkinNames.
@Override
public /**
* Returns the set of skins to use. This implementation parses the skinList.xml file and returns the set of
* skin-key element values. If there is an error parsing the XML file, return an empty set.
*/
SortedSet<String> getSkinNames(PortletRequest request) {
// Context to access the filesystem
PortletContext ctx = request.getPortletSession().getPortletContext();
// Determine the full path to the skins directory
String skinsFilepath = ctx.getRealPath(this.localRelativeRootPath + "/skinList.xml");
// Create File object to access the filesystem
File skinList = new File(skinsFilepath);
TreeSet<String> skins = new TreeSet<>();
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(skinList);
doc.getDocumentElement().normalize();
NodeList nList = doc.getElementsByTagName("skin-key");
for (int temp = 0; temp < nList.getLength(); temp++) {
org.w3c.dom.Element element = (org.w3c.dom.Element) nList.item(temp);
String skinName = element.getTextContent();
log.debug("Found skin-key value {}", skinName);
skins.add(skinName);
}
} catch (SAXException | ParserConfigurationException | IOException e) {
log.error("Error processing skinsFilepath {}", skinsFilepath, e);
}
return skins;
}
Aggregations