Search in sources :

Example 1 with IPortletEntityId

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();
    }
}
Also used : IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId)

Example 2 with IPortletEntityId

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();
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager) IUserLayoutManager(org.apereo.portal.layout.IUserLayoutManager) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 3 with IPortletEntityId

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;
    }
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 4 with IPortletEntityId

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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow)

Example 5 with IPortletEntityId

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;
        }
    });
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) IPortletType(org.apereo.portal.portlet.om.IPortletType) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) Test(org.junit.Test) BasePortalJpaDaoTest(org.apereo.portal.test.BasePortalJpaDaoTest)

Aggregations

IPortletEntityId (org.apereo.portal.portlet.om.IPortletEntityId)33 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)25 IPortletDefinitionId (org.apereo.portal.portlet.om.IPortletDefinitionId)14 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)10 BasePortalJpaDaoTest (org.apereo.portal.test.BasePortalJpaDaoTest)9 Test (org.junit.Test)9 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)8 List (java.util.List)7 PortletPreferenceImpl (org.apereo.portal.portlet.dao.jpa.PortletPreferenceImpl)7 IPortletPreference (org.apereo.portal.portlet.om.IPortletPreference)7 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)6 IUserInstance (org.apereo.portal.user.IUserInstance)6 Callable (java.util.concurrent.Callable)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 HttpSession (javax.servlet.http.HttpSession)4 IUserPreferencesManager (org.apereo.portal.IUserPreferencesManager)4 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)4 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)4 Map (java.util.Map)3 Lock (java.util.concurrent.locks.Lock)3