Package org.jasig.portal.portlet.om

Examples of org.jasig.portal.portlet.om.IPortletEntity


     * {@link WindowState} and {@link javax.portlet.PortletMode}
     */
    protected void initializePortletWindowData(HttpServletRequest request, PortletWindowData portletWindowData) {
        final IStylesheetDescriptor stylesheetDescriptor = getThemeStylesheetDescriptor(request);
        final IPortletEntityId portletEntityId = portletWindowData.getPortletEntityId();
        final IPortletEntity portletEntity = this.portletEntityRegistry.getPortletEntity(request, portletEntityId);
        final WindowState entityWindowState = portletEntity.getWindowState(stylesheetDescriptor);
        if (persistentWindowStates.contains(entityWindowState)) {
            portletWindowData.setWindowState(entityWindowState);
        }
        else if (entityWindowState != null) {
            //Set of persistent window states must have changed, nuke the old value
            this.logger.warn("PortletEntity.windowState=" + entityWindowState + " but that state is not in the set of persistent WindowStates. PortletEntity.windowState will be set to null");
            portletEntity.setWindowState(stylesheetDescriptor, null);
            this.portletEntityRegistry.storePortletEntity(request, portletEntity);
        }
    }
View Full Code Here


    @Override
    protected boolean storeInternal() throws IOException, ValidatorException {
        final HttpServletRequest containerRequest = portletRequestContext.getContainerRequest();
       
        final IPortletEntity portletEntity = this.portletEntityRegistry.getPortletEntity(containerRequest, portletEntityId);
        final IPortletEntityId portletEntityId = portletEntity.getPortletEntityId();
        final Lock portletEntityLock = this.portletEntityRegistry.getPortletEntityLock(containerRequest, portletEntityId);
       
        //Do a tryLock first so that we can warn about concurrent preference modification if it fails
        boolean locked = portletEntityLock.tryLock();
        try {
            if (!locked) {
                logger.warn("Concurrent portlet preferences modification by: " + portletEntity +  " " +
                        "This has the potential for changes to preferences to be lost. " +
                        "This portlet should be modified to synchronize its preference modifications appropriately", new Throwable());
               
                portletEntityLock.lock();
                locked = true;
            }
           
            return this.transactionOperations.execute(new TransactionCallback<Boolean>() {
                @Override
                public Boolean doInTransaction(TransactionStatus status) {
                    //Refresh the entity to avoid optimistic locking errors
                    final IPortletEntity portletEntity = portletEntityRegistry.getPortletEntity(containerRequest, portletEntityId);
               
                    final Map<String, IPortletPreference> targetPortletPreferences = getTargetPortletPreferences();
                    final Collection<IPortletPreference> values = targetPortletPreferences.values();
                    final boolean modified = portletEntity.setPortletPreferences(new ArrayList<IPortletPreference>(values));
                    if (!modified) {
                        //Nothing actually changed, skip the store
                        return Boolean.FALSE;
                    }
                   
View Full Code Here

  public boolean isPasswordRequested(PortletRequest request, PortletWindow plutoPortletWindow) throws PortletContainerException {

      // get the list of requested user attributes
        final HttpServletRequest httpServletRequest = this.portalRequestUtils.getPortletHttpRequest(request);
        final IPortletWindow portletWindow = this.portletWindowRegistry.convertPortletWindow(httpServletRequest, plutoPortletWindow);
        final IPortletEntity portletEntity = portletWindow.getPortletEntity();
        final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
        final PortletApplicationDefinition portletApplicationDescriptor = this.portletDefinitionRegistry.getParentPortletApplicationDescriptor(portletDefinition.getPortletDefinitionId());
       
        // check to see if the password key is one of the requested user attributes
        List<? extends UserAttribute> requestedUserAttributes = portletApplicationDescriptor.getUserAttributes();
        for (final UserAttribute userAttributeDD : requestedUserAttributes) {
View Full Code Here

            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;
    }
View Full Code Here

    @Override
    public IPortletEntity getOrCreatePortletEntity(HttpServletRequest request, IPortletDefinitionId portletDefinitionId, String layoutNodeId, int userId) {
        final PortletEntityCache<IPortletEntity> portletEntityCache = getPortletEntityMap(request);
       
        //Try just getting an existing entity first
        IPortletEntity portletEntity = this.getPortletEntity(request, portletEntityCache, null, layoutNodeId, userId);
       
        //Found an existing entity!
        if (portletEntity != null) {
            //Verify the definition IDs match, this is a MUST in the case where the subscribed portlet changes
            final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
            if (portletDefinitionId.equals(portletDefinition.getPortletDefinitionId())) {
                return portletEntity;
            }
           
            //Remove the entity if the definition IDs don't match
View Full Code Here

    }
   
    @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;
        }
            }
        }
View Full Code Here

        try {
            final boolean shouldBePersisted = this.shouldBePersisted(portletEntity);
           
            if (portletEntity instanceof PersistentPortletEntityWrapper) {
                //Unwrap the persistent entity
                final IPortletEntity persistentEntity = ((PersistentPortletEntityWrapper)portletEntity).getPersistentEntity();
               
                //Already persistent entity that still has prefs
                if (shouldBePersisted) {
                    try {
                        this.portletEntityDao.updatePortletEntity(persistentEntity);
                    }
                    catch (HibernateOptimisticLockingFailureException e) {
                        //Check if this exception is from the entity being deleted from under us.
                        final boolean exists = this.portletEntityDao.portletEntityExists(persistentEntity.getPortletEntityId());
                        if (!exists) {
                            this.logger.warn("The persistent portlet has already been deleted: " + 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;
                        }
                    }
                }
                //Already persistent entity that should not be, DELETE!
                else {
                    //Capture identifiers needed to recreate the entity as session persistent
                    final IPortletDefinitionId portletDefinitionId = portletEntity.getPortletDefinitionId();
                    final String layoutNodeId = portletEntity.getLayoutNodeId();
                    final int userId = portletEntity.getUserId();
                   
                    //Delete the persistent entity
                    this.deletePortletEntity(request, portletEntity, false);

                    //Create a new entity and stick it in the cache
                    this.getOrCreatePortletEntity(request, portletDefinitionId, layoutNodeId, userId);
                }
            }
            else if (portletEntity instanceof SessionPortletEntityImpl) {
                //There are preferences on the interim entity, create an store it
                if (shouldBePersisted) {
                    //Remove the session scoped entity from the request and session caches
                    this.deletePortletEntity(request, portletEntity, false);
                   
                    final IPortletEntity persistentEntity = createPersistentEntity(portletEntity, wrapperPortletEntityId);
                   
                    if (this.logger.isTraceEnabled()) {
                        this.logger.trace("Session scoped entity " + wrapperPortletEntityId + " should now be persistent. Deleted it from session cache and created persistent portlet entity " + persistentEntity.getPortletEntityId());
                    }
                }
                //Session scoped entity that is still session scoped,
                else {
                    //Look for a persistent entity and delete it
                    final String channelSubscribeId = portletEntity.getLayoutNodeId();
                    final int userId = portletEntity.getUserId();
                    IPortletEntity existingPersistentEntity = this.portletEntityDao.getPortletEntity(channelSubscribeId, userId);
                    if (existingPersistentEntity != null) {
                        final IPortletEntityId consistentPortletEntityId = this.createConsistentPortletEntityId(existingPersistentEntity);
                        existingPersistentEntity = new PersistentPortletEntityWrapper(existingPersistentEntity, consistentPortletEntityId);
                       
                        this.logger.warn("A persistent portlet entity already exists: " + existingPersistentEntity + ". The passed entity has no preferences so the persistent version will be deleted");
View Full Code Here

    protected IPortletEntity createPersistentEntity(final IPortletEntity portletEntity, final IPortletEntityId wrapperPortletEntityId) {
        final IPortletDefinitionId portletDefinitionId = portletEntity.getPortletDefinitionId();
        final String layoutNodeId = portletEntity.getLayoutNodeId();
        final int userId = portletEntity.getUserId();
       
        IPortletEntity persistentEntity = this.portletEntityDao.getPortletEntity(layoutNodeId, userId);
        if (persistentEntity != null) {
            this.logger.warn("A persistent portlet entity already exists: " + persistentEntity + ". The data from the passed in entity will be copied to the persistent entity: " + portletEntity);
        }
        else {
            persistentEntity = this.portletEntityDao.createPortletEntity(portletDefinitionId, layoutNodeId, userId);
        }
       
        //Copy over preferences to avoid modifying any part of the interim entity by reference
        final List<IPortletPreference> existingPreferences = portletEntity.getPortletPreferences();
        final List<IPortletPreference> persistentPreferences = persistentEntity.getPortletPreferences();
       
        //Only do the copy if the List objects are not the same instance
        if (persistentPreferences != existingPreferences) {
            persistentPreferences.clear();
            for (final IPortletPreference preference : existingPreferences) {
                persistentPreferences.add(new PortletPreferenceImpl(preference));
            }
        }
       
        //Copy over WindowStates
        final Map<Long, WindowState> windowStates = portletEntity.getWindowStates();
        for (Map.Entry<Long, WindowState> windowStateEntry : windowStates.entrySet()) {
            final Long stylesheetDescriptorId = windowStateEntry.getKey();
            final IStylesheetDescriptor stylesheetDescriptor = stylesheetDescriptorDao.getStylesheetDescriptor(stylesheetDescriptorId);
            final WindowState windowState = windowStateEntry.getValue();
            persistentEntity.setWindowState(stylesheetDescriptor, windowState);
        }
       
        this.portletEntityDao.updatePortletEntity(persistentEntity);
       
        return persistentEntity;
View Full Code Here

        //Remove from session cache
        final PortletEntityCache<PortletEntityData> portletEntityDataMap = this.getPortletEntityDataMap(request);
        portletEntityDataMap.removeEntity(portletEntityId);
       
        if (!cacheOnly && portletEntity instanceof PersistentPortletEntityWrapper) {
            final IPortletEntity persistentEntity = ((PersistentPortletEntityWrapper)portletEntity).getPersistentEntity();
           
            try {
                this.portletEntityDao.deletePortletEntity(persistentEntity);
            }
            catch (HibernateOptimisticLockingFailureException e) {
                this.logger.warn("This persistent portlet has already been deleted: " + persistentEntity + ", trying to find and delete by layout node and user.");
                final IPortletEntity existingPersistentEntity = this.portletEntityDao.getPortletEntity(persistentEntity.getLayoutNodeId(), persistentEntity.getUserId());
                if (existingPersistentEntity != null) {
                    this.portletEntityDao.deletePortletEntity(existingPersistentEntity);
                }
            }
        }
View Full Code Here

    protected IPortletEntity getPortletEntity(
            HttpServletRequest request,
            PortletEntityCache<IPortletEntity> portletEntityCache,
            IPortletEntityId portletEntityId, String layoutNodeId, int userId) {
       
        IPortletEntity portletEntity;
   
        //First look in the request map
        if (portletEntityId != null) {
            portletEntity = portletEntityCache.getEntity(portletEntityId);
        }
        else {
            portletEntity = portletEntityCache.getEntity(layoutNodeId, userId);
        }
       
        if (portletEntity != null) {
            logger.trace("Found IPortletEntity {} in request cache", portletEntity.getPortletEntityId());
            return portletEntity;
        }
       
        //Didn't find it, next look in the session map
        final PortletEntityCache<PortletEntityData> portletEntityDataMap = this.getPortletEntityDataMap(request);
        final PortletEntityData portletEntityData;
        if (portletEntityId != null) {
            portletEntityData = portletEntityDataMap.getEntity(portletEntityId);
        }
        else {
            portletEntityData = portletEntityDataMap.getEntity(layoutNodeId, userId);
        }
       
        if (portletEntityData != null) {
           
            //Stick the entity wrapper in the request map (if it wasn't already added by another thread)
            portletEntity = portletEntityCache.storeIfAbsentEntity(portletEntityData.getPortletEntityId(), new Function<IPortletEntityId, IPortletEntity>() {
                @Override
                public IPortletEntity apply(IPortletEntityId input) {
                    //Found a session stored entity, wrap it to make it a real IPortletEntity
                    logger.trace("Found PortletEntityData {} in session cache, caching wrapper in the request", portletEntityData.getPortletEntityId());
                   
                    return wrapPortletEntityData(portletEntityData);
                }
            });
           
            return portletEntity;
        }
       
        //Still didn't find it, look in the persistent store
        if (portletEntityId != null) {
            if (portletEntityId instanceof PortletEntityIdImpl) {
                final PortletEntityIdImpl consistentPortletEntityId = (PortletEntityIdImpl)portletEntityId;
                final String localLayoutNodeId = consistentPortletEntityId.getLayoutNodeId();
                final int localUserId = consistentPortletEntityId.getUserId();
               
                portletEntity = this.portletEntityDao.getPortletEntity(localLayoutNodeId, localUserId);
            }
            else {
                portletEntity = this.portletEntityDao.getPortletEntity(portletEntityId);
            }
        }
        else {
            portletEntity = this.portletEntityDao.getPortletEntity(layoutNodeId, userId);
        }
       
        //Found a persistent entity, wrap it to make the id consistent between the persistent and session stored entities
        if (portletEntity != null) {
            final IPortletEntityId consistentPortletEntityId = this.createConsistentPortletEntityId(portletEntity);
           
            final IPortletEntity anonPortletEntity = portletEntity;
           
            //Stick the entity wrapper in the request map (if it wasn't already added by another thread)
            portletEntity = portletEntityCache.storeIfAbsentEntity(consistentPortletEntityId, new Function<IPortletEntityId, IPortletEntity>() {
                @Override
                public IPortletEntity apply(IPortletEntityId input) {
                    logger.trace("Found persistent IPortletEntity {}, mapped id to {}, caching the wrapper in the request", anonPortletEntity.getPortletEntityId(), consistentPortletEntityId);
                    return new PersistentPortletEntityWrapper(anonPortletEntity, consistentPortletEntityId);
                }
            });
           
            return portletEntity;
View Full Code Here

TOP

Related Classes of org.jasig.portal.portlet.om.IPortletEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.