Package org.jasig.portal.portlet.om

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


    public Tuple<IPortletWindow, StartElement> getPortletWindow(HttpServletRequest request, StartElement element) {
        //Check if the layout node explicitly specifies the window id
        final Attribute windowIdAttribute = element.getAttributeByName(PORTLET_WINDOW_ID_ATTR_NAME);
        if (windowIdAttribute != null) {
            final String windowIdStr = windowIdAttribute.getValue();
            final IPortletWindowId portletWindowId = this.getPortletWindowId(request, windowIdStr);
            final IPortletWindow portletWindow = this.getPortletWindow(request, portletWindowId);
            return new Tuple<IPortletWindow, StartElement>(portletWindow, element);
        }

        //No explicit window id, look it up based on the layout node id
        final Attribute nodeIdAttribute = element.getAttributeByName(IUserLayoutManager.ID_ATTR_NAME);
        final String layoutNodeId = nodeIdAttribute.getValue();

        IPortletWindow portletWindow = this.getOrCreateDefaultPortletWindowByLayoutNodeId(request, layoutNodeId);
        if (portletWindow == null) {
            //No window for the layout node, return null
            return null;
        }

        final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
        if (portalRequestInfo.getUrlState() == UrlState.DETACHED) {
            /*
             * We want to handle DETACHED portlet windows differently/explicitly,
             * but we need to be aware there may be other portlets on the page
             * besides the targeted one.  These would be portlets in regions
             * (Respondr theme) -- such as DynamicRespondrSkin.
             *
             * We need to confirm, therefore, that this is actually the portlet
             * in DETACHED.  If it is, we'll send back a 'stateless' PortletWindow.
             */
            if (portalRequestInfo.getTargetedPortletWindowId().toString().contains("_" + layoutNodeId + "_")) {
                final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
                portletWindow = this.getOrCreateStatelessPortletWindow(request, portletWindowId);
            }

        }

View Full Code Here


        if (windows == null) {
            return;
        }
       
        for (final PortletWindowData portletWindowData : windows) {
            final IPortletWindowId portletWindowId = portletWindowData.getPortletWindowId();
           
            //Skip data windows that aren't for this entity and for windows that are already in the request cache
            if (!portletEntityId.equals(portletWindowData.getPortletEntityId()) || portletWindowMap.containsWindow(portletWindowId)) {
                continue;
            }
View Full Code Here

    public IPortletUrlBuilder getPortletUrlBuilder(HttpServletRequest request, IPortalUrlBuilder portalUrlBuilder, String fname, String layoutId, String state, String mode, String copyCurrentRenderParameters, String resourceId) {
        final IPortletUrlBuilder portletUrlBuilder;
       
        if (StringUtils.isNotEmpty(fname)) {
            final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(request, fname);
            final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
            portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
        }
        else if (StringUtils.isNotEmpty(layoutId)) {
            final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByLayoutNodeId(request, layoutId);
            final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
            portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
        }
        else {
            final IPortletWindowId targetPortletWindowId = portalUrlBuilder.getTargetPortletWindowId();
            if (targetPortletWindowId == null) {
              if (this.logger.isDebugEnabled()) {
                this.logger.warn("Can only target the default portlet if the root portal-url targets a portlet.", new Throwable());
              }
              else {
View Full Code Here

       
        if (portletRequestInfo == null) {
            throw new IllegalArgumentException("A portlet must be targeted when using the EXCLUSIVE WindowState: " + portalRequestInfo);
        }
       
        final IPortletWindowId portletWindowId = portletRequestInfo.getPortletWindowId();
        this.portletExecutionManager.getPortletOutput(portletWindowId, request, response);
    }
View Full Code Here

        final IPortletRequestInfo portletRequestInfo = portalRequestInfo.getTargetedPortletRequestInfo();
       
       
        final IPortalUrlBuilder actionRedirectUrl;
        if (portletRequestInfo != null) {
            final IPortletWindowId targetWindowId = portletRequestInfo.getPortletWindowId();
            actionRedirectUrl = this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(request, targetWindowId, UrlType.RENDER);
        }
        else {
            final String targetedLayoutNodeId = portalRequestInfo.getTargetedLayoutNodeId();
           
            if (targetedLayoutNodeId != null) {
                actionRedirectUrl = this.portalUrlProvider.getPortalUrlBuilderByLayoutNode(request, targetedLayoutNodeId, UrlType.RENDER);
            }
            else {
                actionRedirectUrl = this.portalUrlProvider.getDefaultUrl(request);
            }
        }
       
        //Stuff the action-redirect URL builder into the request so other code can use it during request processing
        this.portalUrlProvider.convertToPortalActionUrlBuilder(request, actionRedirectUrl);

        if (portletRequestInfo != null) {
            final IPortletWindowId targetWindowId = portletRequestInfo.getPortletWindowId();
           
           
            try {
                this.portletExecutionManager.doPortletAction(targetWindowId, request, response);
            }
            catch (RuntimeException e) {
                this.logger.error("Exception thrown while executing portlet action for: " + portletRequestInfo, e);
               
                //TODO this should be a constant right?
                actionRedirectUrl.setParameter("portletActionError", targetWindowId.toString());
            }
        }
       
        sendRedirect(actionRedirectUrl, response);
    }
View Full Code Here

    @RequestMapping(headers={"org.jasig.portal.url.UrlType=RESOURCE"})
    public void resourceRequest(HttpServletRequest request, HttpServletResponse response) {
      final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
        final IPortletRequestInfo portletRequestInfo = portalRequestInfo.getTargetedPortletRequestInfo();
        if (portletRequestInfo != null) {
            final IPortletWindowId targetWindowId = portletRequestInfo.getPortletWindowId();
            this.portletExecutionManager.doPortletServeResource(targetWindowId, request, response);
        } else {
          this.logger.error("portletRequestInfo was null for resourceRequest");
        }
    }
View Full Code Here

     * Publish the portlet render event
     */
    protected void publishRenderEvent(IPortletWindow portletWindow, HttpServletRequest httpServletRequest,
            RenderPart renderPart, long executionTime, boolean cached) {

        final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();

        //Determine if the portlet was targeted
        final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(httpServletRequest);
        final boolean targeted = portletWindowId.equals(portalRequestInfo.getTargetedPortletWindowId());

        renderPart.publishRenderExecutionEvent(this.portalEventFactory,
                this,
                httpServletRequest,
                portletWindowId,
View Full Code Here

     * Publish the portlet resource event
     */
    protected void publishResourceEvent(IPortletWindow portletWindow, HttpServletRequest httpServletRequest,
            long executionTime, boolean usedBrowserCache, boolean usedPortalCache) {

        final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();

        this.portalEventFactory.publishPortletResourceExecutionEvent(httpServletRequest, this, portletWindowId, executionTime, usedBrowserCache, usedPortalCache);
    }
View Full Code Here

            }

            final IUrlNodeSyntaxHelper urlNodeSyntaxHelper = this.urlNodeSyntaxHelperRegistry.getCurrentUrlNodeSyntaxHelper(request);

            final PortalRequestInfoImpl portalRequestInfo = new PortalRequestInfoImpl();
            IPortletWindowId targetedPortletWindowId = null;
            PortletRequestInfoImpl targetedPortletRequestInfo = null;
           
            final String[] requestPathParts = SLASH_PATTERN.split(requestPath);

            UrlState requestedUrlState = null;
            ParseStep parseStep = ParseStep.FOLDER;
            for (int pathPartIndex = 0; pathPartIndex < requestPathParts.length; pathPartIndex++) {
                String pathPart = requestPathParts[pathPartIndex];

                logger.trace("In parseStep {} considering pathPart [{}].", parseStep, pathPart);

                if (StringUtils.isEmpty(pathPart)) {
                    continue;
                }
               
                switch (parseStep) {
                    case FOLDER: {
                        parseStep = ParseStep.PORTLET;
                       
                        if (FOLDER_PATH_PREFIX.equals(pathPart)) {

                            logger.trace("Skipping adding {} to the folders deque " +
                                    "because it is simply the folder path prefix.", pathPart);

                            pathPartIndex++;
                           
                            final LinkedList<String> folders = new LinkedList<String>();
                            for (;pathPartIndex < requestPathParts.length; pathPartIndex++) {
                                pathPart = requestPathParts[pathPartIndex];

                                if (PORTLET_PATH_PREFIX.equals(pathPart)) {
                                    logger.trace("Found the portlet part of the path " +
                                            "demarked by portlet path prefix [{}]; " +
                                            "stepping back one path part to finish folder processing", pathPart);
                                    pathPartIndex--;
                                    break;
                                } else {


                                    if (pathPart.endsWith(REQUEST_TYPE_SUFFIX)) {
                                        logger.trace("Found the end of the folder path with pathPart [{}];" +
                                                " stepping back one, checking for state, " +
                                                "and finishing folder parsing", pathPart);
                                        pathPartIndex--;
                                        pathPart = requestPathParts[pathPartIndex];

                                        // If a state was added to the folder list remove it and step back one so
                                        // other code can handle it
                                        if (UrlState.valueOfIngoreCase(pathPart, null) != null) {
                                            logger.trace("A state was added to the end of folder list {};" +
                                                    " removing it.", folders);
                                            folders.removeLast();
                                            pathPartIndex--;
                                        }
                                        break;
                                    }
                                }

                                logger.trace("Adding pathPart [{}] to folders.", pathPart);
                                folders.add(pathPart);
                            }

                            logger.trace("Folders is [{}]", folders);
                            if (folders.size() > 0) {
                                final String targetedLayoutNodeId = urlNodeSyntaxHelper.getLayoutNodeForFolderNames(request, folders);
                                portalRequestInfo.setTargetedLayoutNodeId(targetedLayoutNodeId);
                            }
                            break;
                        }
                    }
                    case PORTLET: {
                        parseStep = ParseStep.STATE;
                       
                        final String targetedLayoutNodeId = portalRequestInfo.getTargetedLayoutNodeId();
                       
                        if (PORTLET_PATH_PREFIX.equals(pathPart)) {
                            if (++pathPartIndex < requestPathParts.length) {
                                pathPart = requestPathParts[pathPartIndex];

                                targetedPortletWindowId = urlNodeSyntaxHelper.getPortletForFolderName(request, targetedLayoutNodeId, pathPart);
                            }

                            break;
                        }
                       
                        //See if a portlet was targeted by parameter 
                        final String[] targetedPortletIds = parameterMap.remove(PARAM_TARGET_PORTLET);
                        if (targetedPortletIds != null && targetedPortletIds.length > 0) {
                            final String targetedPortletString = targetedPortletIds[0];
                            targetedPortletWindowId = urlNodeSyntaxHelper.getPortletForFolderName(request, targetedLayoutNodeId, targetedPortletString);
                        }
                       
                    }
                    case STATE: {
                        parseStep = ParseStep.TYPE;
                       
                        //States other than the default only make sense if a portlet is being targeted
                        if (targetedPortletWindowId == null) {
                            break;
                        }
                       
                        requestedUrlState = UrlState.valueOfIngoreCase(pathPart, null);
   
                        //Set the URL state
                        if (requestedUrlState != null) {
                            portalRequestInfo.setUrlState(requestedUrlState);
                           
                            //If the request is stateless
                            if (statelessUrlStates.contains(requestedUrlState)) {
                                final IPortletWindow statelessPortletWindow = this.portletWindowRegistry.getOrCreateStatelessPortletWindow(request, targetedPortletWindowId);
                                targetedPortletWindowId = statelessPortletWindow.getPortletWindowId();
                            }
                           
                            //Create the portlet request info
                            targetedPortletRequestInfo = portalRequestInfo.getPortletRequestInfo(targetedPortletWindowId);
                            portalRequestInfo.setTargetedPortletWindowId(targetedPortletWindowId);
                           
                            //Set window state based on URL State first then look for the window state parameter
                            switch (requestedUrlState) {
                                case MAX: {
                                    targetedPortletRequestInfo.setWindowState(WindowState.MAXIMIZED);
                                }
                                break;
               
                                case DETACHED: {
                                    targetedPortletRequestInfo.setWindowState(IPortletRenderer.DETACHED);
                                }
                                break;
               
                                case EXCLUSIVE: {
                                    targetedPortletRequestInfo.setWindowState(IPortletRenderer.EXCLUSIVE);
                                }
                                break;
                            }
                           
                            break;
                        }
                    }
                    case TYPE: {
                        parseStep = ParseStep.COMPLETE;
                       
                        if (pathPartIndex == requestPathParts.length - 1 && pathPart.endsWith(REQUEST_TYPE_SUFFIX) && pathPart.length() > REQUEST_TYPE_SUFFIX.length()) {
                            final String urlTypePart = pathPart.substring(0, pathPart.length() - REQUEST_TYPE_SUFFIX.length());
                            final UrlType urlType;
                           
                            //Handle inline resourceIds, look for a . in the request type string and use the suffix as the urlType
                            final int lastPeriod = urlTypePart.lastIndexOf('.');
                            if (lastPeriod >= 0 && lastPeriod < urlTypePart.length()) {
                                final String urlTypePartSuffix = urlTypePart.substring(lastPeriod + 1);
                                urlType = UrlType.valueOfIngoreCase(urlTypePartSuffix, null);
                                if (urlType == UrlType.RESOURCE && targetedPortletRequestInfo != null) {
                                    final String resourceId = urlTypePart.substring(0, lastPeriod);
                                    targetedPortletRequestInfo.setResourceId(resourceId);
                                }
                            }
                            else {
                                urlType = UrlType.valueOfIngoreCase(urlTypePart, null);
                            }
                           
                            if (urlType != null) {
                                portalRequestInfo.setUrlType(urlType);
                                break;
                            }
                        }
                    }
                }
            }

            //If a targeted portlet window ID is found but no targeted portlet request info has been retrieved yet, set it up
            if (targetedPortletWindowId != null && targetedPortletRequestInfo == null) {
                targetedPortletRequestInfo = portalRequestInfo.getPortletRequestInfo(targetedPortletWindowId);
                portalRequestInfo.setTargetedPortletWindowId(targetedPortletWindowId);
            }
           
            //Get the set of portlet window ids that also have parameters on the url
            final String[] additionalPortletIdArray = parameterMap.remove(PARAM_ADDITIONAL_PORTLET);
            final Set<String> additionalPortletIds = Sets.newHashSet(additionalPortletIdArray != null ? additionalPortletIdArray : new String[0]);
           
            //Used if there is delegation to capture form-submit and other non-prefixed parameters
            //Map of parent id to delegate id
            final Map<IPortletWindowId, IPortletWindowId> delegateIdMappings = new LinkedHashMap<IPortletWindowId, IPortletWindowId>(0);
           
            //Parse all remaining parameters from the request
            final Set<Entry<String, String[]>> parameterEntrySet = parameterMap.entrySet();
            for (final Iterator<Entry<String, String[]>> parameterEntryItr = parameterEntrySet.iterator(); parameterEntryItr.hasNext(); ) {
                final Entry<String, String[]> parameterEntry = parameterEntryItr.next();
               
                final String name = parameterEntry.getKey();
                final List<String> values = Arrays.asList(parameterEntry.getValue());
               
                /* NOTE: continues are being used to allow fall-through behavior like a switch statement would provide */
               
                //Portal Parameters, just need to remove the prefix
                if (name.startsWith(PORTAL_PARAM_PREFIX)) {
                    final Map<String, List<String>> portalParameters = portalRequestInfo.getPortalParameters();
                    portalParameters.put(this.safeSubstringAfter(PORTAL_PARAM_PREFIX, name), values);
                    parameterEntryItr.remove();
                    continue;
                }
               
                //Generic portlet parameters, have to remove the prefix and see if there was a portlet windowId between the prefix and parameter name
                if (name.startsWith(PORTLET_PARAM_PREFIX)) {
                    final Tuple<String, IPortletWindowId> portletParameterParts = this.parsePortletParameterName(request, name, additionalPortletIds);
                    final IPortletWindowId portletWindowId = portletParameterParts.second;
                    final String paramName = portletParameterParts.first;

                    //Get the portlet parameter map to add the parameter to
                    final Map<String, List<String>> portletParameters;
                    if (portletWindowId == null) {
                        if (targetedPortletRequestInfo == null) {
                            this.logger.warn("Parameter " + name + " is for the targeted portlet but no portlet is targeted by the request. The parameter will be ignored. Value: " + values);
                            parameterEntryItr.remove();
                            break;
                        }
                       
                        portletParameters = targetedPortletRequestInfo.getPortletParameters();
                    }
                    else {
                        final PortletRequestInfoImpl portletRequestInfoImpl = portalRequestInfo.getPortletRequestInfo(portletWindowId);
                        portletParameters = portletRequestInfoImpl.getPortletParameters();
                    }
                   
                    portletParameters.put(paramName, values);
                    parameterEntryItr.remove();
                    continue;
                }
               
                //Portlet control parameters are either used directly or as a prefix to a windowId. Use the SuffixedPortletParameter to simplify their parsing
                for (final SuffixedPortletParameter suffixedPortletParameter : SuffixedPortletParameter.values()) {
                    final String parameterPrefix = suffixedPortletParameter.getParameterPrefix();
                    //Skip to the next parameter prefix if the current doesn't match
                    if (!name.startsWith(parameterPrefix)) {
                        continue;
                    }
                   
                    //All of these parameters require at least one value
                    if (values.isEmpty()) {
                        this.logger.warn("Ignoring parameter " + name + " as it must have a value. Value: " + values);
                        break;
                    }
                   
                    //Verify the parameter is being used on the correct type of URL
                    final Set<UrlType> validUrlTypes = suffixedPortletParameter.getValidUrlTypes();
                    if (!validUrlTypes.contains(portalRequestInfo.getUrlType())) {
                        this.logger.warn("Ignoring parameter " + name + " as it is only valid for " + validUrlTypes + " requests and this is a " + portalRequestInfo.getUrlType() + " request. Value: " + values);
                        break;
                    }
                   
                    //Determine the portlet window and request info the parameter targets
                    final IPortletWindowId portletWindowId = this.parsePortletWindowIdSuffix(request, parameterPrefix, additionalPortletIds, name);
                    final PortletRequestInfoImpl portletRequestInfo = getTargetedPortletRequestInfo(portalRequestInfo, targetedPortletRequestInfo, portletWindowId);
                    if (portletRequestInfo == null) {
                        this.logger.warn("Parameter " + name + " is for the targeted portlet but no portlet is targeted by the request. The parameter will be ignored. Value: " + values);
                        break;
                    }
View Full Code Here

        if (fname != null && fname.length > 0) {
            final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(request, fname[0]);
            if (portletWindow != null) {
                logger.debug("Legacy fname parameter {} resolved to {}", fname[0], portletWindow);
               
                final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
                portalRequestInfo.setTargetedPortletWindowId(portletWindowId);

                final PortletRequestInfoImpl portletRequestInfo = portalRequestInfo.getPortletRequestInfo(portletWindowId);
               
                //Check the portlet request type
View Full Code Here

TOP

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

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.