Package org.apache.pluto.om.portlet

Examples of org.apache.pluto.om.portlet.PortletDefinition


        // access to the portal would cause portlet entities to be cached
        // with their associated window without there corresponding PortletDefinition
        // (becuase the PortletApplication has yet to be registered).
        if(this.portletDefinition == null)
        {
            PortletDefinition pd = registry.getPortletDefinitionByIdentifier(getPortletUniqueName());
            if ( pd != null )
            {
              // only store a really found PortletDefinition
              // to prevent an IllegalArgumentException to be thrown
              setPortletDefinition(pd);
            }
            else
            {
                return null;
            }
        }       
       
        // Wrap the portlet defintion every request thread
        PortletDefinition fpd = (PortletDefinition)fragmentPortletDefinition.get();
        if (fpd == null)
        {
            fpd = new FragmentPortletDefinition(this.portletDefinition, fragment);
            fragmentPortletDefinition.set(fpd);
        }       
View Full Code Here


    protected void invoke(PortletRequest portletRequest, PortletResponse portletResponse, Integer methodID)
        throws PortletException, IOException
    {
        // In case of parallel mode, the portletDefinition member is not thread-safe.
        // So, hide the member variable by the following local variable.
        PortletDefinition portletDefinition = null;

        // In case of parallel mode, get portlet definition object from the worker thread context.
        // Otherwise, refer the member variable.
        boolean isParallelMode = (Thread.currentThread() instanceof Worker || CurrentWorkerContext.getCurrentWorkerContextUsed());

        if (isParallelMode)
        {
            portletDefinition = (PortletDefinition) CurrentWorkerContext.getAttribute(PortalReservedParameters.PORTLET_DEFINITION_ATTRIBUTE);
        }
       
        if (portletDefinition == null)
        {
            portletDefinition = this.portletDefinition;
        }
       
        MutablePortletApplication app = (MutablePortletApplication)portletDefinition.getPortletApplicationDefinition();

        WebApplicationDefinition webApplicationDefinition = app.getWebApplicationDefinition();
        if(webApplicationDefinition == null)
        {
          throw new IllegalStateException("Portlet application "+app.getName()+ " has no associated web application.");
        }
        String portletApplicationName = webApplicationDefinition.getContextRoot();

        // gather all required data from request and response
        ServletRequest servletRequest = ((HttpServletRequestWrapper)((HttpServletRequestWrapper)((HttpServletRequestWrapper)portletRequest).getRequest()).getRequest()).getRequest();

        ServletResponse servletResponse = ((HttpServletResponseWrapper) portletResponse).getResponse();

        ServletContext appContext = jetspeedContext.getContext(portletApplicationName);
        if (null == appContext)
        {
            String message = "Failed to find Servlet context for Portlet Application: " + portletApplicationName;
            log.error(message);
            throw new PortletException(message);
        }
        PortletInstance portletInstance = portletFactory.getPortletInstance(appContext, portletDefinition);
        RequestDispatcher dispatcher = appContext.getRequestDispatcher(servletMappingName);
        if (null == dispatcher)
        {
            String message =
                "Failed to get Request Dispatcher for Portlet Application: "
                    + portletApplicationName
                    + ", servlet: "
                    + servletMappingName;
            log.error(message);
            throw new PortletException(message);
        }

        try
        {
            servletRequest.setAttribute(ContainerConstants.PORTLET, portletInstance);
            servletRequest.setAttribute(ContainerConstants.PORTLET_CONFIG, portletInstance.getConfig());
            servletRequest.setAttribute(ContainerConstants.PORTLET_REQUEST, portletRequest);
            servletRequest.setAttribute(ContainerConstants.PORTLET_RESPONSE, portletResponse);
            servletRequest.setAttribute(ContainerConstants.METHOD_ID, methodID);
            servletRequest.setAttribute(ContainerConstants.PORTLET_NAME, app.getName()+"::"+portletDefinition.getName());
            RequestContext requestContext = (RequestContext)servletRequest.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
            servletRequest.setAttribute(ContainerConstants.PORTAL_CONTEXT, requestContext.getRequest().getContextPath());

            // Store same request attributes into the worker in parallel mode.
            if (isParallelMode)
            {
                CurrentWorkerContext.setAttribute(ContainerConstants.PORTLET, portletInstance);
                CurrentWorkerContext.setAttribute(ContainerConstants.PORTLET_CONFIG, portletInstance.getConfig());
                CurrentWorkerContext.setAttribute(ContainerConstants.PORTLET_REQUEST, portletRequest);
                CurrentWorkerContext.setAttribute(ContainerConstants.PORTLET_RESPONSE, portletResponse);
                CurrentWorkerContext.setAttribute(ContainerConstants.METHOD_ID, methodID);
                CurrentWorkerContext.setAttribute(ContainerConstants.PORTLET_NAME, app.getName()+"::"+portletDefinition.getName());
                CurrentWorkerContext.setAttribute(ContainerConstants.PORTAL_CONTEXT, requestContext.getRequest().getContextPath());               
            }

            PortletRequestContext.createContext(portletDefinition, portletInstance, portletRequest, portletResponse);
            dispatcher.include(servletRequest, servletResponse);
View Full Code Here

            buffer.append(getPath());
        }
        PortletEntity pe = window.getPortletEntity();
        buffer.append( "?entity=" ).append( pe.getId() );
       
        PortletDefinition portlet = pe.getPortletDefinition();
        MutablePortletApplication app = (MutablePortletApplication)portlet.getPortletApplicationDefinition();
        String uniqueName = app.getName() + "::" + portlet.getName();
        buffer.append( "&portlet=" ).append( uniqueName );

        return buffer.toString();
    }       
View Full Code Here

        try
        {
            if ( !fragment.getType().equals( ContentFragment.LAYOUT ) )
            {
                PortletWindow portletWindow = getPortletWindowAccessor().getPortletWindow( fragment );
                PortletDefinition pd = portletWindow.getPortletEntity().getPortletDefinition();
                if ( pd != null && getPortletFactory().isPortletApplicationRegistered((PortletApplication)pd.getPortletApplicationDefinition() ) )
                {
                    String portletApplicationContextPath = pd.getPortletApplicationDefinition().getWebApplicationDefinition().getContextRoot();
                    Portlet portlet = getPortletFactory().getPortletInstance( context.getConfig().getServletContext().getContext( portletApplicationContextPath ), pd ).getRealPortlet();           
                    if ( portlet != null && portlet instanceof SupportsHeaderPhase )
                    {
                        log.debug( "renderHeaderFragment: " + pd.getName() + " supports header phase" );
                       
                        HeaderResource hr = getHeaderResourceFactory().getHeaderResource( context, this.baseUrlAccess, isDesktop(), getHeaderConfiguration() );
                        PortletHeaderRequest headerRequest = new PortletHeaderRequestImpl( context, portletWindow, portletApplicationContextPath );
                        PortletHeaderResponse headerResponse = new PortletHeaderResponseImpl( context, hr, isDesktop(), getHeaderConfiguration(), getHeaderResourceRegistry() );
                        ((SupportsHeaderPhase)portlet).doHeader( headerRequest, headerResponse );
View Full Code Here

     * while more PAs for each portletDef
     * list:entityMan:getPortletEntity(pd)
     */
    PortletDefinitionList portletList = pa.getPortletDefinitionList(); // .get(JetspeedObjectID.createFromString(TEST_PORTLET));
    Iterator pi = portletList.iterator();
    PortletDefinition pd = null;

    JSPortlets portlets = new JSPortlets();
    while (pi.hasNext())
    {
      try
      {
        pd = (PortletDefinition) pi.next();
        JSPortlet p = exportPD(pd);
        if (p != null)
        {
          System.out.println("--processed PA " + pa.getName()
              + " with pd=" + pd.getName());
          portlets.add(p);
        } else
          System.out.println("--processed PA " + pa.getName()
              + " with NULL pd=" + pd.getName());

      } catch (Exception e)
      {
        throw new SerializerException(
            SerializerException.CREATE_SERIALIZED_OBJECT_FAILED
View Full Code Here

   
    Iterator pi = app.getPortlets().iterator();
    while (pi.hasNext())
    {
      JSPortlet portlet = (JSPortlet)pi.next();
      PortletDefinition pd  = pa.getPortletDefinitionByName(portlet.getName());
      if (pd != null)
      {
        importPD(portlet,pd);
      }
    }
View Full Code Here

                PortletEntity portlet = null;
                // search for portlet
                found = false;
                while ( portletIt.hasNext() && ! found ) {
                    portlet = (PortletEntity) portletIt.next();
                    PortletDefinition tmpPortletDef = portlet.getPortletDefinition();
                    if ( tmpPortletDef == null ) {
                      log("ERROR: Portlet definition of portlet enity (id="+portlet.getId()+") not found!");
                      log("       Portlet may not be defined in portlet.xml!");
                      throw new ServletException("Portlet definition of portlet enity (id="+portlet.getId()+") not found!");
                  }
                    String tmpPortletName = tmpPortletDef.getName();
                    //delete all existing preferences for this portlet entity
                    if (tmpPortletName != null && tmpPortletName.equals(portletName)) {
                        for (Iterator iter = portlet.getPreferenceSet().iterator(); iter.hasNext();) {
                            iter.next();
                            iter.remove();
                        }
                        found = true;
                    }
                }
                if (!found) {
                    for (Iterator appIter = definitionList.iterator(); !found && appIter.hasNext();) {
                        PortletApplicationDefinition appDef = (PortletApplicationDefinition)appIter.next();
                        if (appDef.getId().toString().equals(appName)) {
                            for (Iterator portletIter = appDef.getPortletDefinitionList().iterator(); !found && portletIter.hasNext();) {
                                PortletDefinition portletDef = (PortletDefinition)portletIter.next();
                                if (portletDef.getId().toString().equals(appName + "." + portletName)) {
                                    //PortletEntityListCtrl entityListCtrl = (PortletEntityListCtrl)ControllerObjectAccess.get(appEntity.getPortletEntityList());
                                    PortletEntityListCtrl entityListCtrl = (PortletEntityListCtrl)appEntity.getPortletEntityList();
                                    portlet = entityListCtrl.add(appEntity, portletDef.getId().toString());
                                    PortletEntityRegistry.refresh(portlet);
                                    log("added Portlet " + portletName + " to PortletEntityRegistry");
                                    found = true;
                                }
                            }
View Full Code Here

            Iterator portlets =
                portletApp.getPortletDefinitionList().iterator();
            while (portlets.hasNext()) {

                PortletDefinition portlet = (PortletDefinition) portlets.next();

                // check if already exists
                ServletDefinition servlet =
                    webApp.getServletDefinitionList().get(portlet.getName());
                if (servlet != null) {
                    if (!servlet
                        .getServletClass()
                        .equals("org.apache.pluto.core.PortletServlet")) {
                        System.out.println(
                            "Note: Replaced already existing the servlet with the name '"
                                + portlet.getName()
                                + "' with the wrapper servlet.");
                    }
                    ServletDefinitionCtrl _servletCtrl =
                        (ServletDefinitionCtrl) controllerFactory.get(servlet);
                    _servletCtrl.setServletClass(
                        "org.apache.pluto.core.PortletServlet");
                } else {
                    servlet =
                        servletDefinitionSetCtrl.add(
                            portlet.getName(),
                            "org.apache.pluto.core.PortletServlet");
                }

                ServletDefinitionCtrl servletCtrl =
                    (ServletDefinitionCtrl) controllerFactory.get(servlet);

                DisplayNameImpl dispName = new DisplayNameImpl();
                dispName.setDisplayName(portlet.getName() + " Wrapper");
                dispName.setLocale(Locale.ENGLISH);
                DisplayNameSetImpl dispSet = new DisplayNameSetImpl();
                dispSet.add(dispName);
                servletCtrl.setDisplayNames(dispSet);
                DescriptionImpl desc = new DescriptionImpl();
                desc.setDescription("Automated generated Portlet Wrapper");
                desc.setLocale(Locale.ENGLISH);
                DescriptionSetImpl descSet = new DescriptionSetImpl();
                descSet.add(desc);
                servletCtrl.setDescriptions(descSet);
                ParameterSet parameters = servlet.getInitParameterSet();

                ParameterSetCtrl parameterSetCtrl =
                    (ParameterSetCtrl) controllerFactory.get(parameters);

                Parameter parameter1 = parameters.get("portlet-class");
                if (parameter1 == null) {
                    parameterSetCtrl.add(
                        "portlet-class",
                        portlet.getClassName());
                } else {
                    ParameterCtrl parameterCtrl =
                        (ParameterCtrl) controllerFactory.get(parameter1);
                    parameterCtrl.setValue(portlet.getClassName());

                }
                Parameter parameter2 = parameters.get("portlet-guid");
                if (parameter2 == null) {
                    parameterSetCtrl.add(
                        "portlet-guid",
                        portlet.getId().toString());
                } else {
                    ParameterCtrl parameterCtrl =
                        (ParameterCtrl) controllerFactory.get(parameter2);
                    parameterCtrl.setValue(portlet.getId().toString());

                }

                boolean found = false;
                Iterator mappings = servletMappings.iterator();
                while (mappings.hasNext()) {
                    ServletMappingImpl servletMapping =
                        (ServletMappingImpl) mappings.next();
                    if (servletMapping
                        .getServletName()
                        .equals(portlet.getName())) {
                        found = true;
                        servletMapping.setUrlPattern(
                            "/" + portlet.getName().replace(' ', '_') + "/*");
                    }
                }
                if (!found) {
                    ServletMappingImpl servletMapping =
                        new ServletMappingImpl();
                    servletMapping.setServletName(portlet.getName());
                    servletMapping.setUrlPattern(
                        "/" + portlet.getName().replace(' ', '_') + "/*");
                    servletMappings.add(servletMapping);
                }

                SecurityRoleRefSet servletSecurityRoleRefs =
                    ((ServletDefinitionImpl)servlet).getInitSecurityRoleRefSet();

                SecurityRoleRefSetCtrl servletSecurityRoleRefSetCtrl =
                    (SecurityRoleRefSetCtrl) controllerFactory.get(
                        servletSecurityRoleRefs);

                SecurityRoleSet webAppSecurityRoles = webApp.getSecurityRoles();
                   
                SecurityRoleRefSet portletSecurityRoleRefs =
                    portlet.getInitSecurityRoleRefSet();

                // TODO - Do we need this call? The variable is never read
                SecurityRoleRefSetCtrl portletSecurityRoleRefSetCtrl =
                    (SecurityRoleRefSetCtrl) controllerFactory.get(
                        portletSecurityRoleRefs);

                Iterator p = portletSecurityRoleRefs.iterator();

                while (p.hasNext()) {
                    SecurityRoleRef portletSecurityRoleRef =
                        (SecurityRoleRef) p.next();
                   
                    if portletSecurityRoleRef.getRoleLink()== null
                        &&   
                            webAppSecurityRoles.get(portletSecurityRoleRef.getRoleName())==null
                    ){
                        System.out.println(
                            "Note: The web application has no security role defined which matches the role name \""
                                + portletSecurityRoleRef.getRoleName()
                                + "\" of the security-role-ref element defined for the wrapper-servlet with the name '"
                                + portlet.getName()
                                + "'.");
                        break;           
                    }
                    SecurityRoleRef servletSecurityRoleRef =
                        servletSecurityRoleRefs.get(
                            portletSecurityRoleRef.getRoleName());
                    if (null != servletSecurityRoleRef) {
                        System.out.println(
                            "Note: Replaced already existing element of type <security-role-ref> with value \""
                                + portletSecurityRoleRef.getRoleName()
                                + "\" for subelement of type <role-name> for the wrapper-servlet with the name '"
                                + portlet.getName()
                                + "'.");
                        servletSecurityRoleRefSetCtrl.remove(
                            servletSecurityRoleRef);
                    }
                    servletSecurityRoleRefSetCtrl.add(portletSecurityRoleRef);
View Full Code Here

     *
     */
    public boolean isUserInRole(String roleName)
    {
        PortletEntity entity = portletWindow.getPortletEntity();
        PortletDefinition def = entity.getPortletDefinition();
        SecurityRoleRefSet set = def.getInitSecurityRoleRefSet();
        SecurityRoleRef ref = set.get(roleName);

        String link = null;
        if ( ref != null && ref.getRoleLink()!=null) {
            link = ref.getRoleLink();
View Full Code Here

        if(index > -1) {
            wildcard = type.substring(0, index);
        }

        PortletEntity entity = portletWindow.getPortletEntity();
        PortletDefinition def = entity.getPortletDefinition();
        ContentTypeSet contentTypes = def.getContentTypeSet();
        Iterator it = contentTypes.iterator();
        while(it.hasNext()) {
            ContentType ct = (ContentType)it.next();
            if(ct.getContentType().equals(type)) {
                return true;
View Full Code Here

TOP

Related Classes of org.apache.pluto.om.portlet.PortletDefinition

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.