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;
}
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);
}
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;
}
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");
}
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);
}
Aggregations