use of org.apereo.portal.portlet.om.IPortletEntityId in project uPortal by Jasig.
the class PortletWindowCache method storeWindow.
public void storeWindow(T window) {
writeLock.lock();
try {
final IPortletEntityId portletEntityId = window.getPortletEntityId();
final Set<T> windowSet = this.getWindowSet(portletEntityId, true);
windowSet.add(window);
final IPortletWindowId portletWindowId = window.getPortletWindowId();
this.windowsById.put(portletWindowId, window);
} finally {
writeLock.unlock();
}
}
use of org.apereo.portal.portlet.om.IPortletEntityId in project uPortal by Jasig.
the class SingleTabUrlNodeSyntaxHelper method getPortletForFolderName.
@Override
public IPortletWindowId getPortletForFolderName(HttpServletRequest request, String targetedLayoutNodeId, String folderName) {
// Basic parsing of the
final String fname;
String subscribeId = null;
final int seperatorIndex = folderName.indexOf(PORTLET_PATH_ELEMENT_SEPERATOR);
if (seperatorIndex <= 0 || seperatorIndex + 1 == folderName.length()) {
fname = folderName;
} else {
fname = folderName.substring(0, seperatorIndex);
subscribeId = folderName.substring(seperatorIndex + 1);
}
// If a subscribeId was provided validate that it matches up with the fname
if (subscribeId != null) {
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IPortletEntity portletEntity = this.portletEntityRegistry.getOrCreatePortletEntity(request, userInstance, subscribeId);
if (portletEntity == null || !fname.equals(portletEntity.getPortletDefinition().getFName())) {
// If no entity found or the fname doesn't match ignore the provided subscribeId by
// setting it to null
subscribeId = null;
} else {
// subscribeId matches fname, lookup the window for the entity and return the
// windowId
final IPortletEntityId portletEntityId = portletEntity.getPortletEntityId();
final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindow(request, portletEntityId);
if (portletWindow == null) {
return null;
}
return portletWindow.getPortletWindowId();
}
}
// node
if (targetedLayoutNodeId != null) {
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
// First look for the layout node only under the specified folder
subscribeId = userLayoutManager.getSubscribeId(targetedLayoutNodeId, fname);
}
// Find a subscribeId based on the fname
final IPortletWindow portletWindow;
if (subscribeId == null) {
portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(request, fname);
} else {
portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByLayoutNodeId(request, subscribeId);
}
if (portletWindow == null) {
return null;
}
return portletWindow.getPortletWindowId();
}
use of org.apereo.portal.portlet.om.IPortletEntityId in project uPortal by Jasig.
the class MobileUrlNodeSyntaxHelper method getPortletForFolderName.
/* (non-Javadoc)
* @see org.apereo.portal.url.IUrlNodeSyntaxHelper#getPortletForFolderName(javax.servlet.http.HttpServletRequest, java.lang.String, java.lang.String)
*/
@Override
public IPortletWindowId getPortletForFolderName(HttpServletRequest request, String targetedLayoutNodeId, String folderName) {
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final String fname;
final IPortletEntity portletEntity;
final int seperatorIndex = folderName.indexOf(PORTLET_PATH_ELEMENT_SEPERATOR);
if (seperatorIndex <= 0 || seperatorIndex + 1 == folderName.length()) {
fname = folderName;
portletEntity = this.portletEntityRegistry.getOrCreatePortletEntityByFname(request, userInstance, fname);
} else {
fname = folderName.substring(0, seperatorIndex);
final String subscribeId = folderName.substring(seperatorIndex + 1);
portletEntity = this.portletEntityRegistry.getOrCreatePortletEntityByFname(request, userInstance, fname, subscribeId);
}
if (portletEntity != null) {
final IPortletEntityId portletEntityId = portletEntity.getPortletEntityId();
final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindow(request, portletEntityId);
return portletWindow.getPortletWindowId();
} else {
this.logger.warn(targetedLayoutNodeId + " node for portlet of folder " + folderName + " can't be targeted by the request.");
return null;
}
}
use of org.apereo.portal.portlet.om.IPortletEntityId in project uPortal by Jasig.
the class PortletDelegationLocatorImpl method createRequestDispatcher.
/* (non-Javadoc)
* @see org.apereo.portal.api.portlet.PortletDelegationLocator#createRequestDispatcher(org.apereo.portal.portlet.om.IPortletDefinitionId)
*/
@Override
public PortletDelegationDispatcher createRequestDispatcher(PortletRequest portletRequest, IPortletDefinitionId delegatePortletDefinitionId) {
final HttpServletRequest request = this.portalRequestUtils.getPortletHttpRequest(portletRequest);
final String windowID = portletRequest.getWindowID();
final IPortletWindowId parentPortletWindowId = this.portletWindowRegistry.getPortletWindowId(request, windowID);
final IPortletEntity delegatePortletEntity = this.portletEntityRegistry.getOrCreateDelegatePortletEntity(request, parentPortletWindowId, delegatePortletDefinitionId);
final IPortletEntityId delegatePortletEntityId = delegatePortletEntity.getPortletEntityId();
final IPortletWindow delegatePortletWindow = this.portletWindowRegistry.createDelegatePortletWindow(request, delegatePortletEntityId, parentPortletWindowId);
final IPerson person = this.personManager.getPerson(request);
final int userId = person.getID();
return new PortletDelegationDispatcherImpl(delegatePortletWindow, userId, portalRequestUtils, personManager, portletRenderer, portalUrlProvider, portletDelegationManager);
}
use of org.apereo.portal.portlet.om.IPortletEntityId in project uPortal by Jasig.
the class JpaPortletDaoTest method testAllEntityDaoMethods.
@Test
public void testAllEntityDaoMethods() throws Exception {
final IPortletDefinitionId portletDefinitionId = execute(new Callable<IPortletDefinitionId>() {
@Override
public IPortletDefinitionId call() throws Exception {
final IPortletType channelType = jpaChannelTypeDao.createPortletType("BaseType", "foobar");
// Create a definition
final IPortletDefinition chanDef1 = new PortletDefinitionImpl(channelType, "fname1", "Test Portlet 1", "Test Portlet 1 Title", "/context1", "portletName1", false);
jpaPortletDefinitionDao.savePortletDefinition(chanDef1);
return chanDef1.getPortletDefinitionId();
}
});
final IPortletEntityId portletEntityId = execute(new Callable<IPortletEntityId>() {
@Override
public IPortletEntityId call() throws Exception {
IPortletEntity portEnt1 = jpaPortletEntityDao.createPortletEntity(portletDefinitionId, "chanSub1", 1);
return portEnt1.getPortletEntityId();
}
});
execute(new Callable<Object>() {
@Override
public Object call() throws Exception {
final IPortletEntity portEnt1a = jpaPortletEntityDao.getPortletEntity(portletEntityId);
assertNotNull(portEnt1a);
final IPortletEntity portEnt1b = jpaPortletEntityDao.getPortletEntity("chanSub1", 1);
assertEquals(portEnt1a, portEnt1b);
final IPortletEntity portEnt1c = jpaPortletEntityDao.getPortletEntity("chanSub1", 1);
assertEquals(portEnt1b, portEnt1c);
final Set<IPortletEntity> portletEntities1 = jpaPortletEntityDao.getPortletEntities(portletDefinitionId);
assertEquals(Collections.singleton(portEnt1a), portletEntities1);
final Set<IPortletEntity> portletEntitiesByUser = jpaPortletEntityDao.getPortletEntitiesForUser(1);
assertEquals(Collections.singleton(portEnt1a), portletEntitiesByUser);
return null;
}
});
execute(new Callable<Object>() {
@Override
public Object call() throws Exception {
// Add entity and preferences
final IPortletDefinition portDef1 = jpaPortletDefinitionDao.getPortletDefinition(portletDefinitionId);
portDef1.getPortletPreferences().add(new PortletPreferenceImpl("defpref1", false, "dpv1", "dpv2"));
jpaPortletDefinitionDao.savePortletDefinition(portDef1);
final IPortletEntity portEnt1 = jpaPortletEntityDao.getPortletEntity(portletEntityId);
portEnt1.getPortletPreferences().add(new PortletPreferenceImpl("entpref1", false, "epv1", "epv2"));
// portEnt1.setWindowState(WindowState.MINIMIZED);
jpaPortletEntityDao.updatePortletEntity(portEnt1);
return null;
}
});
execute(new Callable<Object>() {
@Override
public Object call() throws Exception {
// Delete whole tree
final IPortletDefinition portDef2 = jpaPortletDefinitionDao.getPortletDefinition(portletDefinitionId);
jpaPortletDefinitionDao.deletePortletDefinition(portDef2);
return null;
}
});
execute(new Callable<Object>() {
@Override
public Object call() throws Exception {
// Verify it is gone
final Set<IPortletEntity> portletEntities2 = jpaPortletEntityDao.getPortletEntities(portletDefinitionId);
assertEquals(Collections.emptySet(), portletEntities2);
return null;
}
});
}
Aggregations