Package org.gatein.registration.spi

Examples of org.gatein.registration.spi.RegistrationSPI


   }

   public PortletContext setProperties(PortletContext portletContext, PropertyChange[] changes)
      throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
   {
      RegistrationSPI registration = getRegistrationAsSPI();

      if (registration != null)
      {
         checkOperationIsAllowed(portletContext, registration, "setProperties");
         PortletContext updatedPortletContext = super.setProperties(portletContext, changes);

         if (!portletContext.getId().equals(updatedPortletContext.getId()))
         {
            try
            {
               // as the portlet context should have been modified after a clone, we need to associate it to the current Registration
               registration.addPortletContext(updatedPortletContext);
            }
            catch (RegistrationException e)
            {
               throw new PortletInvokerException("Couldn't add portlet context '" + updatedPortletContext + "' to registration '" + registration.getRegistrationHandle() + "'", e);
            }
         }

         return updatedPortletContext;
      }
View Full Code Here


   public PortletContext importPortlet(PortletStateType stateType, PortletContext originalPortletContext)
      throws PortletInvokerException, IllegalArgumentException
   {
      // The original portletcontext is the non cloned version and should be one the PC available from the getPortlets operation
      RegistrationSPI registration = getRegistrationAsSPI();

      if (registration != null)
      {
         checkOperationIsAllowed(originalPortletContext, registration, "importPortlet");

         PortletContext newPortletContext = super.importPortlet(stateType, originalPortletContext);

         if (!newPortletContext.getId().equals(originalPortletContext.getId()))
         {
            try
            {
               registration.addPortletContext(newPortletContext);
            }
            catch (RegistrationException e)
            {
               throw new PortletInvokerException("Couldn't add portlet context '" + newPortletContext + "' to registration '" + registration.getRegistrationHandle() + "'", e);
            }
         }

         return newPortletContext;
      }
View Full Code Here

      if (rpm != null)
      {
         props = rpm.toPropMap();
      }

      RegistrationSPI reg = persistenceManager.newRegistrationSPI(consumer, props);
      return toModel(reg, persistenceManager);
   }
View Full Code Here

   }

   @Override
   protected RegistrationSPI internalCreateRegistration(ConsumerSPI consumer, Map<QName, Object> registrationProperties) throws RegistrationException
   {
      RegistrationSPI registration = super.internalCreateRegistration(consumer, registrationProperties);
      try
      {
         ChromatticSession session = persister.getSession();

         ConsumerMapping cm = session.findById(ConsumerMapping.class, consumer.getPersistentKey());
         RegistrationMapping rm = cm.createAndAddRegistrationMappingFrom(null);
         rm.initFrom(registration);
         registration.setPersistentKey(rm.getPersistentKey());

         persister.save();
      }
      catch (Exception e)
      {
View Full Code Here

      return consumerSPI;
   }

   protected RegistrationSPI internalSaveChangesTo(Registration registration) throws RegistrationException
   {
      RegistrationSPI registrationSPI = (RegistrationSPI)registration;

      try
      {
         ChromatticSession session = persister.getSession();
View Full Code Here

            {
               portlets.add(super.getPortlet(context));
            }
            catch (NoSuchPortletException e)
            {
               final RegistrationSPI registrationSPI = getRegistrationAsSPI();
               try
               {
                  registrationSPI.removePortletContext(context);
                  log.debug("Removed '" + context + "' from Registration '" + registration.getRegistrationHandle() + "' because it cannot be resolved anymore.");
               }
               catch (RegistrationException e1)
               {
                  throw new PortletInvokerException(e1);
View Full Code Here

   public PortletInvocationResponse invoke(PortletInvocation invocation) throws IllegalArgumentException, PortletInvokerException
   {
      PortletContext portletContext = invocation.getTarget();

      RegistrationSPI registration = getRegistrationAsSPI();

      if (registration != null)
      {
         checkOperationIsAllowed(portletContext, registration, "invoke");

         PortletInvocationResponse response = super.invoke(invocation);

         InstanceContext instanceContext = invocation.getInstanceContext();
         if (instanceContext instanceof WSRPInstanceContext)
         {
            WSRPInstanceContext wsrpIC = (WSRPInstanceContext)instanceContext;
            PortletContext responseContext = wsrpIC.getPortletContext();
            if (wsrpIC.wasModified() && !responseContext.getId().equals(portletContext.getId()))
            {
               try
               {
                  registration.addPortletContext(responseContext);
               }
               catch (RegistrationException e)
               {
                  throw new PortletInvokerException("Couldn't add portlet context '" + responseContext + "' to registration '" + registration.getRegistrationHandle() + "'", e);
               }
            }
         }

         return response;
View Full Code Here

   }

   public PortletContext createClone(PortletStateType stateType, PortletContext portletContext)
      throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
   {
      RegistrationSPI registration = getRegistrationAsSPI();

      if (registration != null)
      {
         checkOperationIsAllowed(portletContext, registration, "createClone");

         PortletContext clonedPortletContext = super.createClone(stateType, portletContext);
         try
         {
            registration.addPortletContext(clonedPortletContext);
         }
         catch (RegistrationException e)
         {
            throw new PortletInvokerException("Couldn't add portlet context '" + clonedPortletContext + "' to registration '" + registration.getRegistrationHandle() + "'", e);
         }

         return clonedPortletContext;
      }
      else
View Full Code Here

   }

   public List<DestroyCloneFailure> destroyClones(List<PortletContext> portletContexts)
      throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
   {
      RegistrationSPI registration = getRegistrationAsSPI();

      if (registration != null)
      {
         for (PortletContext portletContext : portletContexts)
         {
            checkOperationIsAllowed(portletContext, registration, "destroyClones");
         }
      }

      List<DestroyCloneFailure> cloneFailures = super.destroyClones(portletContexts);
      boolean noFailures = cloneFailures.isEmpty();

      if (registration != null)
      {
         for (PortletContext portletContext : portletContexts)
         {
            // only remove the portlet context if there are no failures or it's not part of the failed clones
            if (noFailures || !cloneFailures.contains(new DestroyCloneFailure(portletContext.getId())))
            {
               try
               {
                  registration.removePortletContext(portletContext);
               }
               catch (RegistrationException e)
               {
                  throw new PortletInvokerException("Couldn't remove portlet context '" + portletContext + "' to registration '" + registration.getRegistrationHandle() + "'", e);
               }
            }
         }
      }
View Full Code Here

   }

   public PortletContext setProperties(PortletContext portletContext, PropertyChange[] changes)
      throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
   {
      RegistrationSPI registration = getRegistrationAsSPI();

      if (registration != null)
      {
         checkOperationIsAllowed(portletContext, registration, "setProperties");
         PortletContext updatedPortletContext = super.setProperties(portletContext, changes);

         if (!portletContext.getId().equals(updatedPortletContext.getId()))
         {
            try
            {
               registration.addPortletContext(updatedPortletContext);
            }
            catch (RegistrationException e)
            {
               throw new PortletInvokerException("Couldn't add portlet context '" + updatedPortletContext + "' to registration '" + registration.getRegistrationHandle() + "'", e);
            }
         }

         return updatedPortletContext;
      }
View Full Code Here

TOP

Related Classes of org.gatein.registration.spi.RegistrationSPI

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.