Search in sources :

Example 6 with IPortletDefinition

use of org.apereo.portal.portlet.om.IPortletDefinition in project uPortal by Jasig.

the class PortletEntityRegistryImpl method getPortletDefinition.

protected IPortletDefinition getPortletDefinition(HttpServletRequest request, IUserInstance userInstance, String portletDefinitionIdStr) {
    request = this.portalRequestUtils.getOriginalPortalRequest(request);
    final ConcurrentMap<String, IPortletDefinition> portletDefinitions = PortalWebUtils.getMapRequestAttribute(request, PORTLET_DEFINITION_LOOKUP_MAP_ATTRIBUTE);
    IPortletDefinition portletDefinition = portletDefinitions.get(portletDefinitionIdStr);
    if (portletDefinition == NO_PERMISSION_PORTLET_DEFINITION) {
        return null;
    }
    if (portletDefinition != null) {
        return portletDefinition;
    }
    portletDefinition = this.portletDefinitionRegistry.getPortletDefinition(portletDefinitionIdStr);
    portletDefinition = checkPortletDefinitionRenderPermissions(userInstance, portletDefinition);
    if (portletDefinition == null) {
        portletDefinitions.put(portletDefinitionIdStr, NO_PERMISSION_PORTLET_DEFINITION);
    } else {
        portletDefinitions.put(portletDefinitionIdStr, portletDefinition);
    }
    return portletDefinition;
}
Also used : IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 7 with IPortletDefinition

use of org.apereo.portal.portlet.om.IPortletDefinition in project uPortal by Jasig.

the class PortletEntityRegistryImpl method getOrCreateDefaultPortletEntity.

@Override
public IPortletEntity getOrCreateDefaultPortletEntity(HttpServletRequest request, IPortletDefinitionId portletDefinitionId) {
    Validate.notNull(request, "HttpServletRequest cannot be null");
    Validate.notNull(portletDefinitionId, "portletDefinitionId cannot be null");
    final IPortletDefinition portletDefinition = this.getPortletDefinition(request, portletDefinitionId);
    if (portletDefinition == null) {
        throw new IllegalArgumentException("No portlet definition found for id '" + portletDefinitionId + "'.");
    }
    //Determine the appropriate portlet window ID for the definition
    final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
    final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
    final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
    //Determine the subscribe ID
    final String portletFName = portletDefinition.getFName();
    final String layoutNodeId = userLayoutManager.getSubscribeId(portletFName);
    if (layoutNodeId == null) {
        throw new IllegalArgumentException("No layout node ID found for fname '" + portletFName + "'.");
    }
    this.logger.trace("Found layout node {} for portlet definition {}", layoutNodeId, portletFName);
    final IPerson person = userInstance.getPerson();
    final int personId = person.getID();
    return this.getOrCreatePortletEntity(request, portletDefinitionId, layoutNodeId, personId);
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IPerson(org.apereo.portal.security.IPerson) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager) IUserLayoutManager(org.apereo.portal.layout.IUserLayoutManager) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 8 with IPortletDefinition

use of org.apereo.portal.portlet.om.IPortletDefinition in project uPortal by Jasig.

the class PortletWindowRegistryImpl method getOrCreateStatelessPortletWindow.

@Override
public IPortletWindow getOrCreateStatelessPortletWindow(HttpServletRequest request, IPortletWindowId basePortletWindowId) {
    //Need the basePortletWindowId to be an instance of PortletWindowIdImpl so that we can extract the entity ID
    if (!(basePortletWindowId instanceof PortletWindowIdImpl)) {
        final String basePortletWindowIdStr = basePortletWindowId.getStringId();
        basePortletWindowId = this.getPortletWindowId(request, basePortletWindowIdStr);
    }
    //Get the entity ID for the portlet window
    final IPortletEntityId portletEntityId = ((PortletWindowIdImpl) basePortletWindowId).getPortletEntityId();
    //Create the stateless ID
    final PortletWindowIdImpl statelessPortletWindowId = this.createPortletWindowId(STATELESS_PORTLET_WINDOW_ID, portletEntityId);
    //See if there is already a request cached stateless window
    IPortletWindow statelessPortletWindow = this.getPortletWindow(request, statelessPortletWindowId);
    if (statelessPortletWindow != null) {
        return statelessPortletWindow;
    }
    //Lookup the base portlet window to clone the stateless from
    final IPortletWindow basePortletWindow = this.getPortletWindow(request, basePortletWindowId);
    final PortletWindowCache<PortletWindowData> statelessPortletWindowDataMap = this.getStatelessPortletWindowDataMap(request, true);
    //If no base to clone from lookup the entity and pluto definition data
    if (basePortletWindow == null) {
        final IPortletEntity portletEntity = this.portletEntityRegistry.getPortletEntity(request, portletEntityId);
        if (portletEntity == null) {
            throw new IllegalArgumentException("No IPortletEntity could be found for " + portletEntity + " while creating stateless portlet window for " + basePortletWindowId);
        }
        final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
        final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId();
        final PortletDefinition portletDescriptor = this.portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId);
        final PortletWindowData portletWindowData = new PortletWindowData(statelessPortletWindowId, portletEntityId);
        statelessPortletWindowDataMap.storeWindow(portletWindowData);
        statelessPortletWindow = new StatelessPortletWindowImpl(portletWindowData, portletEntity, portletDescriptor);
    } else //Clone the existing base window
    {
        final PortletWindowData portletWindowData = new PortletWindowData(statelessPortletWindowId, portletEntityId);
        portletWindowData.setExpirationCache(basePortletWindow.getExpirationCache());
        portletWindowData.setPortletMode(basePortletWindow.getPortletMode());
        portletWindowData.setWindowState(basePortletWindow.getWindowState());
        portletWindowData.setPublicRenderParameters(basePortletWindow.getPublicRenderParameters());
        portletWindowData.setRenderParameters(basePortletWindow.getRenderParameters());
        statelessPortletWindowDataMap.storeWindow(portletWindowData);
        final IPortletEntity portletEntity = basePortletWindow.getPortletEntity();
        final PortletDefinition portletDescriptor = basePortletWindow.getPlutoPortletWindow().getPortletDefinition();
        statelessPortletWindow = new StatelessPortletWindowImpl(portletWindowData, portletEntity, portletDescriptor);
    }
    //Cache the stateless window in the request
    final PortletWindowCache<IPortletWindow> portletWindowMap = this.getPortletWindowMap(request);
    portletWindowMap.storeWindow(statelessPortletWindow);
    return statelessPortletWindow;
}
Also used : IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) PortletDefinition(org.apache.pluto.container.om.portlet.PortletDefinition) IPortletDefinitionId(org.apereo.portal.portlet.om.IPortletDefinitionId) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) IPortletEntityId(org.apereo.portal.portlet.om.IPortletEntityId) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Example 9 with IPortletDefinition

use of org.apereo.portal.portlet.om.IPortletDefinition in project uPortal by Jasig.

the class PortletEntityTranslationController method postPortletTranslation.

@ResourceMapping
@RequestMapping(params = "action=postTranslation")
public ModelAndView postPortletTranslation(@RequestParam("id") String portletId, @RequestParam("locale") String locale, ResourceRequest request) throws Exception {
    final IPortletDefinition definition = portletDefinitionDao.getPortletDefinition(portletId);
    if (definition != null) {
        definition.addLocalizedTitle(locale, request.getParameter("title"));
        definition.addLocalizedName(locale, request.getParameter("name"));
        definition.addLocalizedDescription(locale, request.getParameter("description"));
        portletDefinitionDao.savePortletDefinition(definition);
    }
    return new ModelAndView("json");
}
Also used : ModelAndView(org.springframework.web.portlet.ModelAndView) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) ResourceMapping(org.springframework.web.portlet.bind.annotation.ResourceMapping) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with IPortletDefinition

use of org.apereo.portal.portlet.om.IPortletDefinition in project uPortal by Jasig.

the class PortletEntityTranslationController method getEntityList.

@ResourceMapping
@RequestMapping(params = "action=getEntityList")
public ModelAndView getEntityList() throws Exception {
    final List<IPortletDefinition> portletDefs = portletDefinitionDao.getPortletDefinitions();
    final List<TranslatableEntity> entities = new ArrayList<TranslatableEntity>();
    for (IPortletDefinition portletDef : portletDefs) {
        TranslatableEntity entity = new TranslatableEntity();
        entity.setId(portletDef.getPortletDefinitionId().getStringId());
        entity.setTitle(portletDef.getTitle());
        entities.add(entity);
    }
    return new ModelAndView("json", "entities", entities);
}
Also used : ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.portlet.ModelAndView) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) ResourceMapping(org.springframework.web.portlet.bind.annotation.ResourceMapping) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)103 IPortletEntity (org.apereo.portal.portlet.om.IPortletEntity)24 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)23 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)17 ArrayList (java.util.ArrayList)14 IPortletDefinitionId (org.apereo.portal.portlet.om.IPortletDefinitionId)14 HashSet (java.util.HashSet)13 IPerson (org.apereo.portal.security.IPerson)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 PortletCategory (org.apereo.portal.portlet.om.PortletCategory)12 EntityIdentifier (org.apereo.portal.EntityIdentifier)10 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)9 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)9 HashMap (java.util.HashMap)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)8 IUserInstance (org.apereo.portal.user.IUserInstance)7 Locale (java.util.Locale)6 PortletDefinition (org.apache.pluto.container.om.portlet.PortletDefinition)6 PortalException (org.apereo.portal.PortalException)6 IPortletPreference (org.apereo.portal.portlet.om.IPortletPreference)6