Examples of ExportManager


Examples of org.gatein.exports.ExportManager

         exportByValueRequired = false;
      }


      //check that the export manager can handle export by value
      final ExportManager exportManager = producer.getExportManager();
      if (exportByValueRequired && !exportManager.supportsExportByValue())
      {
         //TODO: instead of passing a string here, we should pass a resource so that its localized
         WSRP2ExceptionFactory.throwWSException(ExportByValueNotSupported.class, "The consumer is requesting portlets to be exported by value, but this consumer only supports export by reference.", null);
      }


      List<ExportedPortlet> exportedPortlets = new ArrayList<ExportedPortlet>(portletContexts.size());
      Map<String, FailedPortlets> failedPortletsMap = new HashMap<String, FailedPortlets>(portletContexts.size());

      try
      {
         RegistrationLocal.setRegistration(registration);

         ExportContext exportContext;
         final Lifetime askedLifetime = exportPortlets.getLifetime();
         if (askedLifetime != null)
         {
            final XMLGregorianCalendar askedLifetimeCurrentTime = askedLifetime.getCurrentTime();
            long currentTime = toLongDate(askedLifetimeCurrentTime);
            long terminationTime = toLongDate(askedLifetime.getTerminationTime());
            long refreshDuration = askedLifetime.getRefreshDuration().getTimeInMillis(askedLifetimeCurrentTime.toGregorianCalendar());
            exportContext = exportManager.createExportContext(exportByValueRequired, currentTime, terminationTime, refreshDuration);
         }
         else
         {
            exportContext = exportManager.createExportContext(exportByValueRequired, -1, -1, -1);
         }

         for (PortletContext portletContext : portletContexts)
         {
            try
            {
               WSRP2ExceptionFactory.throwOperationFailedIfValueIsMissing(portletContext, "Portlet context");
               String portletHandle = portletContext.getPortletHandle();
               WSRP2ExceptionFactory.throwMissingParametersIfValueIsMissing(portletHandle, "Portlet handle", "PortletContext");

               org.gatein.pc.api.PortletContext portalPC = WSRPUtils.convertToPortalPortletContext(portletContext);

               org.gatein.pc.api.PortletContext exportedPortalPC = producer.getPortletInvoker().exportPortlet(PortletStateType.OPAQUE, portalPC);
               if (exportedPortalPC == null)
               {
                  WSRP2ExceptionFactory.throwWSException(InvalidHandle.class, "Could not find a portlet with handle " + portletHandle + " in the producer", null);
               }

               byte[] portletState = WSRPUtils.getStateOrNullFor(exportedPortalPC);

               //get the exportPortletData
               ExportPortletData exportPortletData = exportManager.createExportPortletData(exportContext, portletHandle, portletState);

               //Create the exportedPortlet
               byte[] exportPortletBytes = exportManager.encodeExportPortletData(exportContext, exportPortletData);
               ExportedPortlet exportedPortlet = WSRPTypeFactory.createExportedPortlet(portletHandle, exportPortletBytes);
               exportedPortlets.add(exportedPortlet);
            }

            catch (Exception e)
            {
               if (log.isWarnEnabled())
               {
                  log.warn("Error occured while trying to export a portlet.", e);
               }

               ErrorCodes.Codes errorCode;
               String reason;
               if (e instanceof NoSuchPortletException || e instanceof InvalidHandle)
               {
                  errorCode = ErrorCodes.Codes.INVALIDHANDLE;
                  reason = "The specified portlet handle is invalid";
               }
               else // default error message.
               {
                  errorCode = ErrorCodes.Codes.OPERATIONFAILED;
                  reason = "Error preparing portlet for export";
               }

               final String errorCodeName = errorCode.name();
               if (!failedPortletsMap.containsKey(errorCodeName))
               {
                  List<String> portletHandles = new ArrayList<String>();
                  portletHandles.add(portletContext.getPortletHandle());

                  FailedPortlets failedPortlets = WSRPTypeFactory.createFailedPortlets(portletHandles, errorCode, reason);
                  failedPortletsMap.put(errorCodeName, failedPortlets);
               }
               else
               {
                  FailedPortlets failedPortlets = failedPortletsMap.get(errorCodeName);
                  failedPortlets.getPortletHandles().add(portletContext.getPortletHandle());
               }
            }
         }

         //TODO: handle resourceLists better (should be using for things like errors)
         ResourceList resourceList = null;

         byte[] exportContextBytes = exportManager.encodeExportContextData(exportContext);

         Lifetime lifetime = null;

         if (exportContext.getCurrentTime() > 0)
         {
View Full Code Here

Examples of org.gatein.exports.ExportManager

         List<ImportedPortlet> importedPortlets = new ArrayList<ImportedPortlet>();
         Map<String, ImportPortletsFailed> failedPortletsMap = new HashMap<String, ImportPortletsFailed>();

         ExportContext exportContext;
         final ExportManager exportManager = producer.getExportManager();
         try
         {
            exportContext = exportManager.createExportContext(importContext);
         }
         catch (Exception e)
         {
            throw WSRPExceptionFactory.createWSException(OperationFailed.class, "Invalid ImportContext.", e);
         }

         for (ImportPortlet importPortlet : importPortletList)
         {
            try
            {
               byte[] portletData = importPortlet.getExportData();

               ExportPortletData exportPortletData;
               if (lifeTime != null)
               {
                  long currentTime = toLongDate(lifeTime.getCurrentTime());
                  long terminationTime = toLongDate(lifeTime.getTerminationTime());
                  long refreshDuration = lifeTime.getRefreshDuration().getTimeInMillis(lifeTime.getCurrentTime().toGregorianCalendar());
                  exportPortletData = exportManager.createExportPortletData(exportContext, currentTime, terminationTime, refreshDuration, portletData);
               }
               else
               {
                  exportPortletData = exportManager.createExportPortletData(exportContext, -1, -1, -1, portletData);
               }

               String portletHandle = exportPortletData.getPortletHandle();
               byte[] portletState = exportPortletData.getPortletState();
View Full Code Here

Examples of org.jboss.aesh.console.export.ExportManager

        //enable export
        if(settings.isExportEnabled()) {
            if(settings.isLogging())
                logger.info("enabling exportManager with file: "+settings.getExportFile());
            exportManager = new ExportManager(settings.getExportFile());
            completionList.add(new ExportCompletion(exportManager));
        }

        operations = new ArrayList<ConsoleOperation>();
        currentOperation = null;
View Full Code Here

Examples of org.jboss.aesh.console.export.ExportManager

        //enable export
        if(settings.isExportEnabled()) {
            if(settings.isLogging())
                logger.info("enabling exportManager with file: "+settings.getExportFile());
            exportManager = new ExportManager(settings.getExportFile());
            completionList.add(new ExportCompletion(exportManager));
        }

        processManager = new ProcessManager(this);
View Full Code Here

Examples of org.jboss.aesh.console.export.ExportManager

        //enable export
        if(settings.isExportEnabled()) {
            if(settings.isLogging())
                LOGGER.info("enabling exportManager with file: "+settings.getExportFile());
            exportManager = new ExportManager(settings.getExportFile(), settings.doExportUsesSystemEnvironment());
            completionHandler.addCompletion(new ExportCompletion(exportManager));
        }

        //InterruptHandler for InputProcessor
        InputProcessorInterruptHook interruptHook = new InputProcessorInterruptHook() {
View Full Code Here

Examples of org.jboss.aesh.console.export.ExportManager

        //enable export
        if(settings.isExportEnabled()) {
            if(settings.isLogging())
                LOGGER.info("enabling exportManager with file: "+settings.getExportFile());
            exportManager = new ExportManager(settings.getExportFile(), settings.doExportUsesSystemEnvironment());
            completionHandler.addCompletion(new ExportCompletion(exportManager));
        }

        //InterruptHandler for InputProcessor
        InputProcessorInterruptHook interruptHook = new InputProcessorInterruptHook() {
View Full Code Here

Examples of org.jboss.aesh.console.export.ExportManager

      ShellContextImpl shellContextImpl = new ShellContextImpl(this, currentResource, listeners);
      for (CommandExecutionListener listener : executionListeners)
      {
         shellContextImpl.addCommandExecutionListener(listener);
      }
      ExportManager exportManager = console.getExportManager();
      if (exportManager != null)
      {
         Map<Object, Object> attributeMap = shellContextImpl.getAttributeMap();
         for (String variableName : exportManager.getAllNames())
         {
            // Variable name ends with "=". Aesh Bug?
            if (variableName.endsWith("="))
            {
               variableName = variableName.split("=")[0];
            }
            String variableValue = exportManager.getValue(variableName);
            attributeMap.put(variableName, variableValue);
         }
      }
      return shellContextImpl;
   }
View Full Code Here

Examples of org.jboss.aesh.console.export.ExportManager

      ShellContextImpl shellContextImpl = new ShellContextImpl(this, currentResource, listeners);
      for (CommandExecutionListener listener : executionListeners)
      {
         shellContextImpl.addCommandExecutionListener(listener);
      }
      ExportManager exportManager = console.getExportManager();
      if (exportManager != null)
      {
         Map<Object, Object> attributeMap = shellContextImpl.getAttributeMap();
         for (String variableName : exportManager.getAllNames())
         {
            String variableValue = exportManager.getValue(variableName);
            attributeMap.put(variableName, variableValue);
         }
      }
      return shellContextImpl;
   }
View Full Code Here

Examples of org.jboss.aesh.console.export.ExportManager

        //enable export
        if(settings.isExportEnabled()) {
            if(settings.isLogging())
                LOGGER.info("enabling exportManager with file: "+settings.getExportFile());
            exportManager = new ExportManager(settings.getExportFile());
            completionHandler.addCompletion(new ExportCompletion(exportManager));
        }

        //InterruptHandler for InputProcessor
        InputProcessorInterruptHook interruptHook = new InputProcessorInterruptHook() {
View Full Code Here

Examples of org.jboss.aesh.console.export.ExportManager

      ShellContextImpl shellContextImpl = new ShellContextImpl(this, currentResource, listeners);
      for (CommandExecutionListener listener : executionListeners)
      {
         shellContextImpl.addCommandExecutionListener(listener);
      }
      ExportManager exportManager = console.getExportManager();
      if (exportManager != null)
      {
         Map<Object, Object> attributeMap = shellContextImpl.getAttributeMap();
         for (String variableName : exportManager.getAllNames())
         {
            String variableValue = exportManager.getValue(variableName);
            attributeMap.put(variableName, variableValue);
         }
      }
      return shellContextImpl;
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.