Package org.jboss.portal.portlet

Examples of org.jboss.portal.portlet.Portlet


         throw new InvalidPortletIdException("Cannot configure producer offered portlets", portletId);
      }
      StatefulContext statefulContext = (StatefulContext)context;

      // Get the container
      Portlet referencedPortlet = super.getPortlet(context.getPortletContext());

      // We need the referenced portlet
      if (referencedPortlet == null)
      {
         throw new PortletInvokerException("The portlet " + context.getPortletContext() + " referenced by this clone " + portletId + " is not available");
      }

      // Get the portlet info
      PortletInfo referencedPortletInfo = referencedPortlet.getInfo();

      //
      PreferencesInfo prefs = referencedPortletInfo.getPreferences();

      // Clone the current state
View Full Code Here


    * @throws PortletInvokerException any portlet invoker exception
    */
   private void getPropertiesFromMetaData(PortletContext portletContext, PropertyMap props) throws PortletInvokerException
   {
      //
      Portlet portlet = super.getPortlet(portletContext);

      // The prefs info
      PreferencesInfo prefs = portlet.getInfo().getPreferences();

      // Collect missing or read only properties from the referenced portlet
      Set<String> keys = new HashSet<String>();
      for (String key : prefs.getKeys())
      {
View Full Code Here

         if (state != null)
         {
            try
            {
               PortletState portletState = stateConverter.unmarshall(state);
               Portlet delegate = super.getPortlet(PortletContext.createPortletContext(portletState.getPortletId()));
               return new ProducerPortlet(portletContext, delegate);
            }
            catch (StateConversionException e)
            {
               throw new PortletInvokerException(e);
            }
         }
         else
         {
            throw new InvalidPortletIdException("", portletId);
         }
      }
      else if (portletId.startsWith(PRODUCER_CLONE_ID_PREFIX))
      {
         try
         {
            String stateId = portletId.substring(PRODUCER_CLONE_ID_PREFIX.length());
            PortletStateContext stateContext = persistenceManager.loadState(stateId);
            PortletState state = stateContext.getState();
            Portlet delegate = super.getPortlet(PortletContext.createPortletContext(state.getPortletId()));
            return new ProducerPortlet(portletContext, delegate);
         }
         catch (NoSuchStateException e)
         {
            throw new NoSuchPortletException(e, portletId);
View Full Code Here

      {
         access = AccessMode.READ_ONLY;
      }

      // Get the portlet container and set it on invocation
      Portlet portlet = super.getPortlet(context.getPortletContext());
      if (portlet == null)
      {
         throw new NoSuchPortletException("Portlet " + context.getPortletContext() + " not found", context.getPortletId());
      }

      // Create prefs
      AbstractPropertyContext prefs = new AbstractPropertyContext(
         access,
         context.isStateful() ? ((StatefulContext)context).getProperties() : null,
         invocation instanceof RenderInvocation);

      //
      PortletInvocationResponse response;
      try
      {
         invocation.setTarget(context.getPortletContext());
         invocation.setAttribute(PropertyContext.PREFERENCES_ATTRIBUTE, prefs);

         // Invoke
         response = super.invoke(invocation);
      }
      finally
      {
         invocation.setTarget(portletContext);
         invocation.removeAttribute(PropertyContext.PREFERENCES_ATTRIBUTE);
      }

      //
      int status = prefs.getStatus();

      // Producer state management if the invocation was succesful
      if ((invocation instanceof ActionInvocation || invocation instanceof ResourceInvocation || invocation instanceof EventInvocation) && status == AbstractPropertyContext.UPDATE_SUCCESSFUL)
      {
         // Get the potentially updated prefs
         PropertyMap newPrefs = prefs.getPrefs();

         //
         switch(access)
         {
            case CLONE_BEFORE_WRITE:
            {
               boolean persist = stateManagementPolicy.persistLocally();

               // Create the state
               if (context.isStateful())
               {
                  StatefulContext statefulContext = (StatefulContext)context;
                  if (persist)
                  {
                     try
                     {
                        // The state id should be ok as it was used before to load the state
                        LocalContext localContext = (LocalContext)statefulContext;
                        String portletStateId = localContext.getStateId();
                        String cloneStateId = persistenceManager.cloneState(portletStateId, newPrefs);

                        // Return the clone context
                        String cloneId = PRODUCER_CLONE_ID_PREFIX + cloneStateId;
                        PortletContext clonedCtx = PortletContext.createPortletContext(cloneId);
                        StateEvent event = new StateEvent(clonedCtx, StateEvent.Type.PORTLET_CLONED_EVENT);
                        instanceCtx.onStateEvent(event);
                     }
                     catch (NoSuchStateException e)
                     {
                        throw new PortletInvokerException("Unexpected exception", e);
                     }
                     catch (InvalidStateIdException e)
                     {
                        throw new PortletInvokerException("Unexpected exception", e);
                     }
                  }
                  else
                  {
                     PortletContext clonedCtx = marshall(context.getPortletId(), newPrefs);
                     StateEvent event = new StateEvent(clonedCtx, StateEvent.Type.PORTLET_CLONED_EVENT);
                     instanceCtx.onStateEvent(event);
                  }
               }
               else
               {
                  // Add the missing mutable portlet state
                  getPropertiesFromMetaData(portlet.getContext(), newPrefs);

                  //
                  if (persist)
                  {
                     // Create the new state
View Full Code Here

         // Dereference the portlet
         PortletContext refPortletContext = context.getPortletContext();

         // Get the referenced portlet
         Portlet refPortlet = super.getPortlet(refPortletContext);

         // We need the referenced portlet
         if (refPortlet == null)
         {
            throw new PortletInvokerException("The portlet " + refPortletContext + " referenced by this clone " + portletId + " is not available");
View Full Code Here

         throw new InvalidPortletIdException("Cannot configure producer offered portlets", portletId);
      }
      StatefulContext statefulContext = (StatefulContext)context;

      // Get the container
      Portlet referencedPortlet = super.getPortlet(context.getPortletContext());

      // We need the referenced portlet
      if (referencedPortlet == null)
      {
         throw new PortletInvokerException("The portlet " + context.getPortletContext() + " referenced by this clone " + portletId + " is not available");
      }

      // Get the portlet info
      PortletInfo referencedPortletInfo = referencedPortlet.getInfo();

      //
      PreferencesInfo prefs = referencedPortletInfo.getPreferences();

      // Clone the current state
View Full Code Here

    * @throws PortletInvokerException any portlet invoker exception
    */
   private void getPropertiesFromMetaData(PortletContext portletContext, PropertyMap props) throws PortletInvokerException
   {
      //
      Portlet portlet = super.getPortlet(portletContext);

      // The prefs info
      PreferencesInfo prefs = portlet.getInfo().getPreferences();

      // Collect missing or read only properties from the referenced portlet
      Set<String> keys = new HashSet<String>();
      for (String key : prefs.getKeys())
      {
View Full Code Here

TOP

Related Classes of org.jboss.portal.portlet.Portlet

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.