protected IPortletDefinition getPortletDefinition( IUserInstance userInstance, IPortletDefinitionId portletDefinitionId) { final IPortletDefinition portletDefinition = this.portletDefinitionRegistry.getPortletDefinition(portletDefinitionId); return checkPortletDefinitionRenderPermissions(userInstance, portletDefinition); }
String layoutNodeId, int userId) { final PortletEntityCache<IPortletEntity> portletEntityCache = getPortletEntityMap(request); this.getPortletEntity(request, portletEntityCache, null, layoutNodeId, userId); portletEntity, portletDefinitionId); this.deletePortletEntity(request, portletEntity, false); this.getPortletEntityDataMap(request); this.createConsistentPortletEntityId(portletDefinitionId, layoutNodeId, userId); PortletEntityData portletEntityData = new PortletEntityData(portletEntityId, portletDefinitionId, layoutNodeId, userId); portletEntityData = portletEntityDataMap.storeIfAbsentEntity(portletEntityData); portletEntity = wrapPortletEntityData(portletEntityData);
@Override public Lock getPortletEntityLock(HttpServletRequest request, IPortletEntityId portletEntityId) { final ConcurrentMap<IPortletEntityId, Lock> lockMap = getPortletEntityLockMap(request); // See if the lock already exist, return if it does Lock lock = lockMap.get(portletEntityId); if (lock != null) { return lock; } // Create a new lock and do a putIfAbsent to avoid synchronizing but still get a single lock // instance for the session. lock = createPortletEntityLock(); return ConcurrentMapUtils.putIfAbsent(lockMap, portletEntityId, lock); }
@Override public IPortletEntity getPortletEntity( HttpServletRequest request, String portletEntityIdString) { final IPortletEntityId portletEntityId = this.parseConsistentPortletEntityId(request, portletEntityIdString); return this.getPortletEntity(request, portletEntityId); }
@Override public IPortletEntity getPortletEntity( HttpServletRequest request, IPortletEntityId portletEntityId) { Validate.notNull(portletEntityId, "portletEntityId can not be null"); // Sync on the request map to make sure duplicate IPortletEntitys aren't ever created final PortletEntityCache<IPortletEntity> portletEntityCache = this.getPortletEntityMap(request); return this.getPortletEntity(request, portletEntityCache, portletEntityId, null, -1); }
final Lock portletEntityLock = this.getPortletEntityLock(request, wrapperPortletEntityId); portletEntityLock.lock(); try { final boolean shouldBePersisted = this.shouldBePersisted(portletEntity); + persistentEntity + ". The passed entity should be persistent so a new persistent entity will be created"); this.deletePortletEntity(request, portletEntity, true); this.createPersistentEntity(persistentEntity, wrapperPortletEntityId); } else { throw e; this.deletePortletEntity(request, portletEntity, false); this.getOrCreatePortletEntity( request, portletDefinitionId, layoutNodeId, userId); this.deletePortletEntity(request, portletEntity, false); createPersistentEntity(portletEntity, wrapperPortletEntityId); if (existingPersistentEntity != null) { final IPortletEntityId consistentPortletEntityId = this.createConsistentPortletEntityId(existingPersistentEntity); existingPersistentEntity = new PersistentPortletEntityWrapper( + existingPersistentEntity + ". The passed entity has no preferences so the persistent version will be deleted");
@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); }
@Override public IPortletEntity getOrCreatePortletEntityByFname( HttpServletRequest request, IUserInstance userInstance, String fname, String preferredChannelSubscribeId) { try { final IPortletEntity portletEntity = this.getOrCreatePortletEntity( request, userInstance, preferredChannelSubscribeId); if (portletEntity != null) { // Verify the fname matches before returning the entity final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition(); if (fname.equals(portletDefinition.getFName())) { return portletEntity; } } } catch (PortalException pe) { // Ignored, can be the case if no layout node exists for the specified subscribe ID } // Either the layout node didn't exist or the entity for the node doesn't match the // requested fname return this.getOrCreatePortletEntityByFname(request, userInstance, fname); }
this.getPortletEntityMap(request); portletEntityMap.removeEntity(portletEntityId); this.getPortletEntityDataMap(request); portletEntityDataMap.removeEntity(portletEntityId);
PortletEntityIdStringUtils.parsePortletDefinitionId(consistentEntityIdString); final IPortletDefinition portletDefinition = this.getPortletDefinition(request, portletDefinitionIdString); if (portletDefinition == null) { throw new IllegalArgumentException( createConsistentPortletEntityId(portletDefinitionId, layoutNodeId, userId);
this.getPortletEntityDataMap(request); final PortletEntityData portletEntityData; if (portletEntityId != null) { this.createConsistentPortletEntityId(portletEntity);
protected IPortletDefinition getPortletDefinition( HttpServletRequest request, IPortletDefinitionId portletDefinitionId) { final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request); return this.getPortletDefinition(userInstance, portletDefinitionId); }
@Override public IPortletEntity getOrCreatePortletEntityByFname( HttpServletRequest request, IUserInstance userInstance, String fname) { final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager(); final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager(); final String subscribeId = userLayoutManager.getSubscribeId(fname); return this.getOrCreatePortletEntity(request, userInstance, subscribeId); }
protected IPortletEntityId createConsistentPortletEntityId(IPortletEntity portletEntity) { final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition(); final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId(); final String layoutNodeId = portletEntity.getLayoutNodeId(); final int userId = portletEntity.getUserId(); return this.createConsistentPortletEntityId(portletDefinitionId, layoutNodeId, userId); }
final Lock portletEntityLock = this.getPortletEntityLock(request, wrapperPortletEntityId); portletEntityLock.lock(); try { final boolean shouldBePersisted = this.shouldBePersisted(portletEntity); + persistentEntity + ". The passed entity should be persistent so a new persistent entity will be created"); this.deletePortletEntity(request, portletEntity, true); this.createPersistentEntity(persistentEntity, wrapperPortletEntityId); } else { throw e; this.deletePortletEntity(request, portletEntity, false); this.getOrCreatePortletEntity( request, portletDefinitionId, layoutNodeId, userId); this.deletePortletEntity(request, portletEntity, false); createPersistentEntity(portletEntity, wrapperPortletEntityId); if (existingPersistentEntity != null) { final IPortletEntityId consistentPortletEntityId = this.createConsistentPortletEntityId(existingPersistentEntity); existingPersistentEntity = new PersistentPortletEntityWrapper( + existingPersistentEntity + ". The passed entity has no preferences so the persistent version will be deleted");
@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); }
@Override public IPortletEntity getPortletEntity( HttpServletRequest request, IPortletEntityId portletEntityId) { Validate.notNull(portletEntityId, "portletEntityId can not be null"); // Sync on the request map to make sure duplicate IPortletEntitys aren't ever created final PortletEntityCache<IPortletEntity> portletEntityCache = this.getPortletEntityMap(request); return this.getPortletEntity(request, portletEntityCache, portletEntityId, null, -1); }
@Override public IPortletEntity getPortletEntity( HttpServletRequest request, String portletEntityIdString) { final IPortletEntityId portletEntityId = this.parseConsistentPortletEntityId(request, portletEntityIdString); return this.getPortletEntity(request, portletEntityId); }
@Override public IPortletEntity getOrCreatePortletEntityByFname( HttpServletRequest request, IUserInstance userInstance, String fname, String preferredChannelSubscribeId) { try { final IPortletEntity portletEntity = this.getOrCreatePortletEntity( request, userInstance, preferredChannelSubscribeId); if (portletEntity != null) { // Verify the fname matches before returning the entity final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition(); if (fname.equals(portletDefinition.getFName())) { return portletEntity; } } } catch (PortalException pe) { // Ignored, can be the case if no layout node exists for the specified subscribe ID } // Either the layout node didn't exist or the entity for the node doesn't match the // requested fname return this.getOrCreatePortletEntityByFname(request, userInstance, fname); }
this.getPortletEntityMap(request); portletEntityMap.removeEntity(portletEntityId); this.getPortletEntityDataMap(request); portletEntityDataMap.removeEntity(portletEntityId);