@Override public String getLayoutNodeId() { return this.persistentEntity.getLayoutNodeId(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!IPortletEntity.class.isAssignableFrom(obj.getClass())) return false; IPortletEntity other = (IPortletEntity) obj; if (this.layoutNodeId == null) { if (other.getLayoutNodeId() != null) return false; } else if (!this.layoutNodeId.equals(other.getLayoutNodeId())) return false; if (this.portletDefinition == null) { if (other.getPortletDefinition() != null) return false; } else if (!this.portletDefinition.equals(other.getPortletDefinition())) return false; if (this.userId != other.getUserId()) return false; return true; }
@Override public boolean shouldBePersisted(IPortletEntity portletEntity) { // Delegate entities should NEVER be persisted final String layoutNodeId = portletEntity.getLayoutNodeId(); if (PortletEntityIdStringUtils.isDelegateLayoutNode(layoutNodeId)) { return false; } // Only non delegate entities with preferences or a non-null window state should be // persisted final List<IPortletPreference> preferences = portletEntity.getPortletPreferences(); return !CollectionUtils.isEmpty(preferences) || !portletEntity.getWindowStates().isEmpty(); }
@Override public boolean shouldBePersisted(IPortletEntity portletEntity) { // Delegate entities should NEVER be persisted final String layoutNodeId = portletEntity.getLayoutNodeId(); if (PortletEntityIdStringUtils.isDelegateLayoutNode(layoutNodeId)) { return false; } // Only non delegate entities with preferences or a non-null window state should be // persisted final List<IPortletPreference> preferences = portletEntity.getPortletPreferences(); return !CollectionUtils.isEmpty(preferences) || !portletEntity.getWindowStates().isEmpty(); }
@Override public String toString() { return "PortletEntity [" + "portletEntityId=" + this.standardEntityId + ", " + "layoutNodeId=" + this.persistentEntity.getLayoutNodeId() + ", " + "userId=" + this.persistentEntity.getUserId() + ", " + "portletDefinition=" + this.persistentEntity.getPortletDefinition() + "]"; } }
@Override @DialectAwareTransactional(value = PostgreSQL81Dialect.class, exclude = false) @PortalTransactionalReadOnly @OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME) public IPortletEntity getPortletEntity(String layoutNodeId, int userId) { Validate.notNull(layoutNodeId, "portletEntity can not be null"); /* Since portal entities mostly are retrieved in batches (for each "channel" element in user's layout), it is * faster to retrieve all portlet entities, so that persistence framework can place them in 2nd level cache, and * iterate over them manually instead of retrieving single portlet entity one by one. */ Set<IPortletEntity> entities = getPortletEntitiesForUser(userId); for (IPortletEntity entity : entities) { if (StringUtils.equals(entity.getLayoutNodeId(), layoutNodeId)) { return entity; } } return null; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!IPortletEntity.class.isAssignableFrom(obj.getClass())) return false; IPortletEntity other = (IPortletEntity) obj; if (this.portletEntityData.getLayoutNodeId() == null) { if (other.getLayoutNodeId() != null) return false; } else if (!this.portletEntityData.getLayoutNodeId().equals(other.getLayoutNodeId())) return false; if (this.portletDefinition == null) { if (other.getPortletDefinition() != null) return false; } else if (!this.portletDefinition.equals(other.getPortletDefinition())) return false; if (this.portletEntityData.getUserId() != other.getUserId()) return false; return true; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!IPortletEntity.class.isAssignableFrom(obj.getClass())) return false; IPortletEntity other = (IPortletEntity) obj; if (this.transientLayoutNodeId == null) { if (other.getLayoutNodeId() != null) return false; } else if (!this.transientLayoutNodeId.equals(other.getLayoutNodeId())) return false; if (this.delegatePortletEntity.getPortletDefinition() == null) { if (other.getPortletDefinition() != null) return false; } else if (!this.delegatePortletEntity .getPortletDefinition() .equals(other.getPortletDefinition())) return false; if (this.delegatePortletEntity.getUserId() != other.getUserId()) return false; return true; }
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); }
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); }
/** * Adds a TransientPortletEntity wrapper to the portletEntity if it is needed. If the specified * entity is transient but no transient subscribe id has been registered for it yet in the * transientIdMap null is returned. If no wrapping is needed the original entity is returned. */ protected IPortletEntity wrapEntity(IPortletEntity portletEntity) { if (portletEntity == null) { return null; } final String persistentLayoutNodeId = portletEntity.getLayoutNodeId(); if (persistentLayoutNodeId.startsWith(TransientUserLayoutManagerWrapper.SUBSCRIBE_PREFIX)) { final IUserLayoutManager userLayoutManager = this.getUserLayoutManager(); if (userLayoutManager == null) { this.logger.warn( "Could not find IUserLayoutManager when trying to wrap transient portlet entity: " + portletEntity); return portletEntity; } final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition(); final String fname = portletDefinition.getFName(); final String layoutNodeId = userLayoutManager.getSubscribeId(fname); return new TransientPortletEntity(portletEntity, layoutNodeId); } return portletEntity; }
@RequestCache(keyMask = {false, true}) @Override public String getFolderNameForPortlet( HttpServletRequest request, IPortletWindowId portletWindowId) { final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId); final IPortletEntity portletEntity = portletWindow.getPortletEntity(); final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition(); final String fname = portletDefinition.getFName(); final String layoutNodeId = portletEntity.getLayoutNodeId(); // Build the targeted portlet string (fname + subscribeId) return fname + PORTLET_PATH_ELEMENT_SEPERATOR + layoutNodeId; }
@RequestCache(keyMask = {false, true}) @Override public String getFolderNameForPortlet( HttpServletRequest request, IPortletWindowId portletWindowId) { final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId); final IPortletEntity portletEntity = portletWindow.getPortletEntity(); final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition(); final String fname = portletDefinition.getFName(); final String channelSubscribeId = portletEntity.getLayoutNodeId(); // Build the targeted portlet string (fname + subscribeId) return fname + PORTLET_PATH_ELEMENT_SEPERATOR + channelSubscribeId; }
@RequestCache(keyMask = {false, true}) @Override public String getFolderNameForPortlet( HttpServletRequest request, IPortletWindowId portletWindowId) { final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId); final IPortletEntity portletEntity = portletWindow.getPortletEntity(); final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition(); final String fname = portletDefinition.getFName(); final String layoutNodeId = portletEntity.getLayoutNodeId(); // Build the targeted portlet string (fname + subscribeId) return fname + PORTLET_PATH_ELEMENT_SEPERATOR + layoutNodeId; }
@RequestCache(keyMask = {false, true}) @Override public String getFolderNameForPortlet( HttpServletRequest request, IPortletWindowId portletWindowId) { final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId); final IPortletEntity portletEntity = portletWindow.getPortletEntity(); final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition(); final String fname = portletDefinition.getFName(); final String channelSubscribeId = portletEntity.getLayoutNodeId(); // Build the targeted portlet string (fname + subscribeId) return fname + PORTLET_PATH_ELEMENT_SEPERATOR + channelSubscribeId; }
protected IPortletEntity createPersistentEntity( final IPortletEntity portletEntity, final IPortletEntityId wrapperPortletEntityId) { final IPortletDefinitionId portletDefinitionId = portletEntity.getPortletDefinitionId(); final String layoutNodeId = portletEntity.getLayoutNodeId(); final int userId = portletEntity.getUserId();
protected IPortletEntity createPersistentEntity( final IPortletEntity portletEntity, final IPortletEntityId wrapperPortletEntityId) { final IPortletDefinitionId portletDefinitionId = portletEntity.getPortletDefinitionId(); final String layoutNodeId = portletEntity.getLayoutNodeId(); final int userId = portletEntity.getUserId();
/** * Verify the requested portlet window corresponds to a node in the user's layout and return the * corresponding layout node id */ protected String verifyPortletWindowId( HttpServletRequest request, IPortletWindowId portletWindowId) { final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request); final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager(); final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager(); final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId); final IPortletWindowId delegationParentWindowId = portletWindow.getDelegationParentId(); if (delegationParentWindowId != null) { return verifyPortletWindowId(request, delegationParentWindowId); } final IPortletEntity portletEntity = portletWindow.getPortletEntity(); final String channelSubscribeId = portletEntity.getLayoutNodeId(); final IUserLayoutNodeDescription node = userLayoutManager.getNode(channelSubscribeId); if (node == null) { throw new IllegalArgumentException( "No layout node exists for id " + channelSubscribeId + " of window " + portletWindowId); } return node.getId(); }
final IPortletEntity existingPersistentEntity = this.portletEntityDao.getPortletEntity( persistentEntity.getLayoutNodeId(), persistentEntity.getUserId()); if (existingPersistentEntity != null) { this.portletEntityDao.deletePortletEntity(existingPersistentEntity);
final IPortletEntity existingPersistentEntity = this.portletEntityDao.getPortletEntity( persistentEntity.getLayoutNodeId(), persistentEntity.getUserId()); if (existingPersistentEntity != null) { this.portletEntityDao.deletePortletEntity(existingPersistentEntity);