[gatein-commits] gatein SVN: r3775 - components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Aug 9 05:35:03 EDT 2010


Author: chris.laprun at jboss.com
Date: 2010-08-09 05:35:02 -0400 (Mon, 09 Aug 2010)
New Revision: 3775

Modified:
   components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/PortletManagementHandler.java
Log:
- Minor: no need to create a logger per class instance.

Modified: components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/PortletManagementHandler.java
===================================================================
--- components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/PortletManagementHandler.java	2010-08-09 07:01:37 UTC (rev 3774)
+++ components/wsrp/trunk/producer/src/main/java/org/gatein/wsrp/producer/PortletManagementHandler.java	2010-08-09 09:35:02 UTC (rev 3775)
@@ -25,7 +25,6 @@
 
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Multimap;
-
 import org.gatein.common.NotYetImplemented;
 import org.gatein.common.i18n.LocalizedString;
 import org.gatein.common.logging.Logger;
@@ -66,13 +65,13 @@
 import org.oasis.wsrp.v2.GetPortletDescription;
 import org.oasis.wsrp.v2.GetPortletProperties;
 import org.oasis.wsrp.v2.GetPortletPropertyDescription;
+import org.oasis.wsrp.v2.GetPortletsLifetime;
+import org.oasis.wsrp.v2.GetPortletsLifetimeResponse;
 import org.oasis.wsrp.v2.ImportPortlet;
 import org.oasis.wsrp.v2.ImportPortlets;
 import org.oasis.wsrp.v2.ImportPortletsFailed;
 import org.oasis.wsrp.v2.ImportPortletsResponse;
 import org.oasis.wsrp.v2.ImportedPortlet;
-import org.oasis.wsrp.v2.GetPortletsLifetime;
-import org.oasis.wsrp.v2.GetPortletsLifetimeResponse;
 import org.oasis.wsrp.v2.InconsistentParameters;
 import org.oasis.wsrp.v2.InvalidHandle;
 import org.oasis.wsrp.v2.InvalidRegistration;
@@ -120,13 +119,12 @@
    private static final String GET_PORTLET_PROPERTIES = "GetPortletProperties";
    private static final String PORTLET_CONTEXT = "PortletContext";
    private static final String GET_PORTLET_DESCRIPTION = "GetPortletDescription";
-   
-   private final Logger log; 
 
+   private static final Logger log = LoggerFactory.getLogger(PortletManagementHandler.class);
+
    PortletManagementHandler(WSRPProducerImpl producer)
    {
       super(producer);
-      log = LoggerFactory.getLogger(PortletManagementHandler.class);
    }
 
    public PortletDescriptionResponse getPortletDescription(GetPortletDescription getPortletDescription)
@@ -268,7 +266,7 @@
             failedPortlets = new ArrayList<FailedPortlets>(reasonToHandles.size());
             for (String reason : reasonToHandles.keys())
             {
-               failedPortlets.add(WSRPTypeFactory.createFailedPortlets(reasonToHandles.get(reason),ErrorCodes.Codes.OPERATIONFAILED, reason));
+               failedPortlets.add(WSRPTypeFactory.createFailedPortlets(reasonToHandles.get(reason), ErrorCodes.Codes.OPERATIONFAILED, reason));
             }
          }
          else
@@ -469,22 +467,22 @@
    }
 
    public ExportPortletsResponse exportPortlets(ExportPortlets exportPortlets) throws AccessDenied,
-         ExportByValueNotSupported, InconsistentParameters, InvalidHandle, InvalidRegistration, InvalidUserCategory,
-         MissingParameters, ModifyRegistrationRequired, OperationFailed, OperationNotSupported, ResourceSuspended
+      ExportByValueNotSupported, InconsistentParameters, InvalidHandle, InvalidRegistration, InvalidUserCategory,
+      MissingParameters, ModifyRegistrationRequired, OperationFailed, OperationNotSupported, ResourceSuspended
    {
       WSRP2ExceptionFactory.throwMissingParametersIfValueIsMissing(exportPortlets, "ExportPortlets", "ExportPortlets");
-      
+
       List<PortletContext> portletContexts = exportPortlets.getPortletContext();
       if (portletContexts == null || portletContexts.isEmpty())
       {
          throw WSRP2ExceptionFactory.createWSException(MissingParameters.class, "Missing required portletContext in ExportPortlets.", null);
-      } 
-      
+      }
+
       Registration registration = producer.getRegistrationOrFailIfInvalid(exportPortlets.getRegistrationContext());
-   
+
       UserContext userContext = exportPortlets.getUserContext();
       checkUserAuthorization(userContext);
-      
+
       boolean exportByValueRequired;
       if (exportPortlets.isExportByValueRequired() != null)
       {
@@ -494,35 +492,35 @@
       {
          exportByValueRequired = false;
       }
-      
-      
+
+
       //check that the export manager can handle export by value
       if (exportByValueRequired && !producer.getExportManager().supportExportByValue())
       {
          //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>();
       Map<String, FailedPortlets> failedPortletsMap = new HashMap<String, FailedPortlets>();
-      
+
       try
       {
          RegistrationLocal.setRegistration(registration);
-      
+
          //TODO: try catch here?
          ExportContext exportContext = producer.getExportManager().createExportContext(exportByValueRequired, exportPortlets.getLifetime());
-         
+
          for (PortletContext portletContext : exportPortlets.getPortletContext())
          {
             try
             {
                byte[] exportData;
-               
+
                String portletHandle = portletContext.getPortletHandle();
                byte[] portletState = portletContext.getPortletState();
-               
+
                if (portletHandle != null)
                {
                   org.gatein.pc.api.PortletContext portalPC = WSRPUtils.convertToPortalPortletContext(portletContext);
@@ -535,22 +533,22 @@
                {
                   WSRP2ExceptionFactory.throwWSException(InvalidHandle.class, "A portlet handle cannot be null.", null);
                }
-               
+
                //get the exportPortletData
                ExportPortletData exportPortletData = producer.getExportManager().createExportPortletData(exportContext, portletHandle, portletState);
-               
+
                //Create the exportedPortlet
                ExportedPortlet exportedPortlet = WSRPTypeFactory.createExportedPortlet(portletHandle, exportPortletData.encodeAsBytes());
                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)
@@ -563,12 +561,12 @@
                   errorCode = ErrorCodes.Codes.OPERATIONFAILED;
                   reason = "Error preparing portlet for export";
                }
-               
-               if(!failedPortletsMap.containsKey(errorCode.name()))
+
+               if (!failedPortletsMap.containsKey(errorCode.name()))
                {
                   List<String> portletHandles = new ArrayList<String>();
                   portletHandles.add(portletContext.getPortletHandle());
-                  
+
                   FailedPortlets failedPortlets = WSRPTypeFactory.createFailedPortlets(portletHandles, errorCode, reason);
                   failedPortletsMap.put(errorCode.name(), failedPortlets);
                }
@@ -579,10 +577,10 @@
                }
             }
          }
-         
+
          //TODO: handle resourceLists better (should be using for things like errors)
          ResourceList resourceList = null;
-         
+
          return WSRPTypeFactory.createExportPortletsResponse(exportContext.encodeAsBytes(), exportedPortlets, new ArrayList<FailedPortlets>(failedPortletsMap.values()), exportContext.getLifeTime(), resourceList);
       }
       catch (Exception e)//TODO ADD PROPER EXCEPTION HANDLING
@@ -599,27 +597,27 @@
    public ImportPortletsResponse importPortlets(ImportPortlets importPortlets) throws OperationFailed, InvalidRegistration, MissingParameters
    {
       WSRP2ExceptionFactory.throwOperationFailedIfValueIsMissing(importPortlets, "ImportPortlets");
-      
+
       List<ImportPortlet> importPortletList = importPortlets.getImportPortlet();
       WSRP2ExceptionFactory.throwMissingParametersIfValueIsMissing(importPortletList, "ImportPortlet", "ImportPortlets");
-      
+
       Registration registration = producer.getRegistrationOrFailIfInvalid(importPortlets.getRegistrationContext());
-      
+
       // check if we have a valid userContext or not
       UserContext userContext = importPortlets.getUserContext();
       checkUserAuthorization(userContext);
-      
+
       try
       {
          RegistrationLocal.setRegistration(registration);
-         
+
          byte[] importContext = importPortlets.getImportContext();
-         
+
          Lifetime lifeTime = importPortlets.getLifetime();
-         
+
          List<ImportedPortlet> importedPortlets = new ArrayList<ImportedPortlet>();
          Map<String, ImportPortletsFailed> failedPortletsMap = new HashMap<String, ImportPortletsFailed>();
-         
+
          ExportContext exportContext;
          try
          {
@@ -629,7 +627,7 @@
          {
             throw WSRPExceptionFactory.createWSException(OperationFailed.class, "Invalid ImportContext.", e);
          }
-         
+
          for (ImportPortlet importPortlet : importPortletList)
          {
             try
@@ -657,7 +655,7 @@
                {
                   log.warn("Error occured while trying to import a portlet.", e);
                }
-               
+
                ErrorCodes.Codes errorCode;
                String reason;
                if (e instanceof NoSuchPortletException || e instanceof InvalidHandle)
@@ -680,12 +678,12 @@
                   errorCode = ErrorCodes.Codes.OPERATIONFAILED;
                   reason = "Error preparing portlet for export";
                }
-               
-               if(!failedPortletsMap.containsKey(errorCode.name()))
+
+               if (!failedPortletsMap.containsKey(errorCode.name()))
                {
                   List<String> portleIDs = new ArrayList<String>();
                   portleIDs.add(importPortlet.getImportID());
-                  
+
                   ImportPortletsFailed failedPortlets = WSRPTypeFactory.createImportPortletsFailed(portleIDs, errorCode, reason);
                   failedPortletsMap.put(errorCode.name(), failedPortlets);
                }
@@ -696,9 +694,9 @@
                }
             }
          }
-         
+
          ResourceList resourceList = null; //TODO: figure out what exactly should be stored in the resource list here
-         
+
          return WSRPTypeFactory.createImportPortletsResponse(importedPortlets, new ArrayList<ImportPortletsFailed>(failedPortletsMap.values()), resourceList);
       }
       finally
@@ -724,7 +722,7 @@
             log.warn("Error occured while trying to perform a ReleaseExport", e);
          }
       }
-      
+
       //this method shouldn't return anything
       return new ReturnAny().getExtensions();
    }
@@ -732,28 +730,28 @@
    public Lifetime setExportLifetime(SetExportLifetime setExportLifetime) throws OperationFailed, InvalidRegistration
    {
       WSRP2ExceptionFactory.throwOperationFailedIfValueIsMissing(setExportLifetime, "setExportLifetimePortlets");
-      
+
       byte[] exportContextBytes = setExportLifetime.getExportContext();
       //NOTE: we can't throw a MissingParameterException since its not allowed as part of the spec
       if (exportContextBytes == null)
       {
          WSRPExceptionFactory.throwWSException(OperationFailed.class, "Cannot call setExportLifetime with an empty ExportContext.", null);
       }
-      
+
       Registration registration = producer.getRegistrationOrFailIfInvalid(setExportLifetime.getRegistrationContext());
-      
+
       // check if we have a valid userContext or not
       UserContext userContext = setExportLifetime.getUserContext();
       checkUserAuthorization(userContext);
-      
+
       try
       {
          RegistrationLocal.setRegistration(registration);
-         
+
          ExportContext exportContext = producer.getExportManager().createExportContext(exportContextBytes);
-         
-         return producer.getExportManager().setExportLifetime(exportContext,setExportLifetime.getLifetime());
-         
+
+         return producer.getExportManager().setExportLifetime(exportContext, setExportLifetime.getLifetime());
+
       }
       catch (Exception e)
       {



More information about the gatein-commits mailing list