Package org.apache.pluto.om.portlet

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


            if(portletDefs != null && portletDefs.size() > 0)
            {
                Iterator pdItr = portletDefs.iterator();
                while(pdItr.hasNext())
                {
                    PortletDefinition pd = (PortletDefinition) pdItr.next();
                    Collection portletEntites = entityAccess.getPortletEntities(pd);
                    if(portletEntites != null && portletEntites.size() > 0)
                    {
                        Iterator peItr = portletEntites.iterator();
                        while(peItr.hasNext())
View Full Code Here


    Iterator portlets = pa.getPortletDefinitions().iterator();

    while (portlets.hasNext())
    {
      PortletDefinition portletDefinition = (PortletDefinition) portlets.next();
      Iterator      entities = entityAccess.getPortletEntities(portletDefinition)
                           .iterator();

      while (entities.hasNext())
      {
View Full Code Here

        // 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

        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

     *         PortletEntityNotGeneratedException
     */
    public MutablePortletEntity generateEntityFromFragment( ContentFragment fragment, String principal )
            throws PortletEntityNotGeneratedException
    {
        PortletDefinition pd = registry.getPortletDefinitionByUniqueName(fragment.getName());
        ObjectID entityKey = generateEntityKey(fragment, principal);
        MutablePortletEntity portletEntity = null;

        if (pd != null)
        {
View Full Code Here

        {
            throw new PortletEntityNotStoredException("Fragment and PortletEntity ids do not match, update skipped: " + fragment.getId() + " != " + portletEntity.getId() );
        }

        // update portlet definition from fragment
        PortletDefinition pd = registry.getPortletDefinitionByUniqueName(fragment.getName());
        if (pd != null)
        {
            ((PortletEntityImpl)portletEntity).setPortletDefinition(pd);
        }
        else
View Full Code Here

       
        verifyDemoAppCreated(TEST_PORTLET_APP_NAME, demoApp);
       
        MutablePortletApplication app = portletRegistry.getPortletApplication(TEST_PORTLET_APP_NAME);
       
        PortletDefinition portlet = (PortletDefinition) app.getPortletDefinitionList().iterator().next();
       
        MutablePortletEntity entity = entityAccess.newPortletEntityInstance(portlet);
        entity.setId("testEnity");
       
        entityAccess.storePortletEntity(entity);
View Full Code Here

        {
          String layoutName = frag.getName();
          if ( layoutName != null && layoutName.length() > 0 )
          {
            // logic below is copied from org.apache.jetspeed.portlets.MultiColumnPortlet
            PortletDefinition portletDef = registry.getPortletDefinitionByUniqueName( layoutName );
                   
            ParameterSet paramSet = portletDef.getInitParameterSet();
            Parameter sizesParam = paramSet.get( "sizes" );
            String sizesParamVal = ( sizesParam == null ) ? null : sizesParam.getValue();
            if ( sizesParamVal != null && sizesParamVal.length() > 0 )
            {
              fragSizes.put( frag.getId(), sizesParamVal );
              //log.info( "GetPageAction settings sizes for " + frag.getId() + " to " + sizesParamVal);
            }
            else
            {
              Parameter colsParam = paramSet.get( "columns" );
              String colsParamVal = ( colsParam == null ) ? null : colsParam.getValue();
              if ( colsParamVal != null && colsParamVal.length() > 0 )
              {
                int cols = 0;
                try
                {
                  cols = Integer.parseInt( colsParamVal );
                }
                catch ( NumberFormatException ex )
                {
                }
                if ( cols < 1 )
                {
                  cols = 2;
                }
                switch (cols)
                      {
                        case 1: sizesParamVal = "100%"; break;
                        case 2: sizesParamVal = "50%,50%"; break;
                        case 3: sizesParamVal = "34%,33%,33%"; break;
                        default: sizesParamVal = "50%,50%"; break;
                      }
                fragSizes.put( frag.getId(), sizesParamVal );
                //log.info( "GetPageAction defaulting sizes for " + frag.getId() + " to " + sizesParamVal);
              }
            }
          }
        }
        List childFragments = frag.getFragments();
        if ( childFragments != null )
        {
          Iterator childFragIter = childFragments.iterator();
          while ( childFragIter.hasNext() )
          {
            Fragment childFrag = (Fragment)childFragIter.next();
                    retrieveFragmentSpecialProperties( requestContext, childFrag, fragSizes, portletIcons );
          }
        }
      }
        else if ( portletIcons != null && "portlet".equals( frag.getType() ) )
        {   // get portlet icon and locale specific portlet display name
            String portletName = frag.getName();
            if ( portletName != null && portletName.length() > 0 )
            {
                PortletDefinition portletDef = registry.getPortletDefinitionByUniqueName( portletName );
               
                if ( portletDef != null && portletIcons != null )
                {
                    ParameterSet paramSet = portletDef.getInitParameterSet();
                    Parameter iconParam = paramSet.get( "portlet-icon" );
                    String iconParamVal = ( iconParam == null ) ? null : iconParam.getValue();
                    if ( iconParamVal != null && iconParamVal.length() > 0 )
                    {
                        portletIcons.put( frag.getId(), iconParamVal );
View Full Code Here

   
    protected final void doCreate(ActionRequest request, ActionResponse response) throws PortletException
    {
        try
        {
            PortletDefinition pd = getPortletDefintion(request);
            String newId = request.getParameter("newEntityId");
            PortletEntity entity = null;
           
            if(newId != null)
            {
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);

        if (isParallelMode)
        {
            portletDefinition = (PortletDefinition) CurrentWorkerContext.getAttribute(PortalReservedParameters.PORTLET_DEFINITION_ATTRIBUTE);
        }
        else
        {
            portletDefinition = this.portletDefinition;
        }
       
        ClassLoader paClassLoader = portletFactory.getPortletApplicationClassLoader((PortletApplication)portletDefinition.getPortletApplicationDefinition());

        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

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.