Author: chris.laprun(a)jboss.com
Date: 2011-11-07 11:05:27 -0500 (Mon, 07 Nov 2011)
New Revision: 8002
Modified:
components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/consumers.xhtml
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/editConsumer.xhtml
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/WSRPConsumer.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ProducerInfo.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationDispatcher.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java
Log:
- GTNWSRP-262: record supported options from producer and throw an exception if
unsupported operations are called.
- Renamed isSupportsExport method to isImportExportSupported and fixed implementation
using ProducerInfo's recorded supported options.
Modified:
components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java
===================================================================
---
components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java 2011-11-07
15:52:28 UTC (rev 8001)
+++
components/wsrp/trunk/admin-gui/src/main/java/org/gatein/wsrp/admin/ui/ConsumerBean.java 2011-11-07
16:05:27 UTC (rev 8002)
@@ -740,9 +740,9 @@
currentExport = (ExportInfoDisplay)existingExports.getRowData();
}
- public boolean isSupportsExport()
+ public boolean isImportExportSupported()
{
- return isActive() && getConsumer().isSupportsExport();
+ return isActive() && getConsumer().isImportExportSupported();
}
public boolean isAvailableExportInfosEmpty()
Modified: components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/consumers.xhtml
===================================================================
---
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/consumers.xhtml 2011-11-07
15:52:28 UTC (rev 8001)
+++
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/consumers.xhtml 2011-11-07
16:05:27 UTC (rev 8002)
@@ -1,6 +1,6 @@
<!--
~ JBoss, a division of Red Hat
- ~ Copyright 2010, Red Hat Middleware, LLC, and individual
+ ~ Copyright 2011, Red Hat Middleware, LLC, and individual
~ contributors as indicated by the @authors tag. See the
~ copyright.txt in the distribution for a full listing of
~ individual contributors.
@@ -89,7 +89,7 @@
<f:param name="id"
value="#{cons.producerId}"/>
#{i18n.consumers_table_action_delete}
</h:commandLink>
- <h:panelGroup rendered="#{cons.active and
cons.supportsExport}">
+ <h:panelGroup rendered="#{cons.active and
cons.importExportSupported}">
<h:panelGroup rendered="#{!
cons.migrationService.availableExportInfosEmpty}">|
<h:commandLink action="#{consumersMgr.importPortlets}"
styleClass="actionImport" id="import">
<f:param name="id"
value="#{cons.producerId}"/>
Modified:
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/editConsumer.xhtml
===================================================================
---
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/editConsumer.xhtml 2011-11-07
15:52:28 UTC (rev 8001)
+++
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/editConsumer.xhtml 2011-11-07
16:05:27 UTC (rev 8002)
@@ -1,6 +1,6 @@
<!--
~ JBoss, a division of Red Hat
- ~ Copyright 2010, Red Hat Middleware, LLC, and individual
+ ~ Copyright 2011, Red Hat Middleware, LLC, and individual
~ contributors as indicated by the @authors tag. See the
~ copyright.txt in the distribution for a full listing of
~ individual contributors.
@@ -65,13 +65,13 @@
</td>
</tr>
<c:if test="#{consumer.wssAvailable}">
-<tr>
- <th>#{i18n.edit_enable_ws_security}</th>
- <td>
- <h:selectBooleanCheckbox value="#{consumer.wssEnabled}"/>
- <h:message styleClass="portlet-msg-error" for="wsdl"/>
- </td>
-</tr>
+ <tr>
+ <th>#{i18n.edit_enable_ws_security}</th>
+ <td>
+ <h:selectBooleanCheckbox value="#{consumer.wssEnabled}"/>
+ <h:message styleClass="portlet-msg-error"
for="wsdl"/>
+ </td>
+ </tr>
</c:if>
<c:if test="#{consumer.localInfoPresent}">
<tr>
@@ -269,7 +269,7 @@
<div class="ButtonMiddle">
<h:commandLink id="export-cons-link"
action="#{consumersMgr.exportPortlets}"
actionListener="#{consumersMgr.selectConsumer}"
- rendered="#{consumer.supportsExport}"
+
rendered="#{consumer.importExportSupported}"
value="#{i18n.edit_consumer_export}"
title="#{i18n.edit_consumer_export_title}">
<f:param name="id"
value="#{consumer.id}"/>
@@ -284,7 +284,7 @@
<div class="ButtonMiddle">
<h:commandLink id="import-cons-link"
action="#{consumersMgr.importPortlets}"
actionListener="#{consumersMgr.selectConsumer}"
- rendered="#{consumer.supportsExport and !
consumer.availableExportInfosEmpty}"
+ rendered="#{consumer.importExportSupported
and ! consumer.availableExportInfosEmpty}"
value="#{i18n.edit_consumer_import}"
title="#{i18n.edit_consumer_import_title}">
<f:param name="id"
value="#{consumer.id}"/>
Modified: components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/WSRPConsumer.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/WSRPConsumer.java 2011-11-07
15:52:28 UTC (rev 8001)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/WSRPConsumer.java 2011-11-07
16:05:27 UTC (rev 8002)
@@ -128,7 +128,7 @@
MigrationService getMigrationService();
- boolean isSupportsExport();
+ boolean isImportExportSupported();
ImportInfo importPortlets(ExportInfo exportInfo, List<String> portlets) throws
PortletInvokerException;
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ProducerInfo.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ProducerInfo.java 2011-11-07
15:52:28 UTC (rev 8001)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/ProducerInfo.java 2011-11-07
16:05:27 UTC (rev 8002)
@@ -66,6 +66,7 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.namespace.QName;
import javax.xml.ws.Holder;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -118,31 +119,34 @@
// Transient information
/** The Cookie handling policy required by the Producer */
- private CookieProtocol requiresInitCookie;
+ private transient CookieProtocol requiresInitCookie;
/** The Producer-Offered Portlets (handle -> WSRPPortlet) */
- private Map<String, Portlet> popsMap;
+ private transient Map<String, Portlet> popsMap;
/** A cache for Consumer-Configured Portlets (handle -> WSRPPortlet) */
- private Map<String, Portlet> ccpsMap;
+ private transient Map<String, Portlet> ccpsMap;
/** Portlet groups. */
- private Map<String, Set<Portlet>> portletGroups;
+ private transient Map<String, Set<Portlet>> portletGroups;
/** Time at which the cache expires */
- private long expirationTimeMillis;
+ private transient long expirationTimeMillis;
- private final ConsumerRegistrySPI registry;
+ private transient final ConsumerRegistrySPI registry;
private static final String ERASED_LOCAL_REGISTRATION_INFORMATION = "Erased local
registration information!";
private transient RegistrationInfo expectedRegistrationInfo;
- private Map<String, ItemDescription> customModes;
- private Map<String, ItemDescription> customWindowStates;
+ private transient Map<String, ItemDescription> customModes;
+ private transient Map<String, ItemDescription> customWindowStates;
/** Events */
- private Map<QName, EventInfo> eventDescriptions;
+ private transient Map<QName, EventInfo> eventDescriptions;
+ /** Supported options */
+ private transient List<String> supportedOptions = Collections.emptyList();
+
/*protected org.oasis.wsrp.v1.ItemDescription[] userCategoryDescriptions;
protected org.oasis.wsrp.v1.ItemDescription[] customUserProfileItemDescriptions;
@@ -503,6 +507,13 @@
requiresInitCookie = serviceDescription.getRequiresInitCookie();
log.debug("Requires initCookie: " + requiresInitCookie);
+ // supported options
+ final List<String> supportedOptions =
serviceDescription.getSupportedOptions();
+ if (ParameterValidation.existsAndIsNotEmpty(supportedOptions))
+ {
+ this.supportedOptions = new ArrayList<String>(supportedOptions);
+ }
+
// custom mode descriptions
customModes = toMap(serviceDescription.getCustomModeDescriptions());
@@ -1295,4 +1306,9 @@
{
this.lastModified = lastModified;
}
+
+ public List<String> getSupportedOptions()
+ {
+ return supportedOptions;
+ }
}
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java 2011-11-07
15:52:28 UTC (rev 8001)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java 2011-11-07
16:05:27 UTC (rev 8002)
@@ -64,6 +64,7 @@
import org.gatein.wsrp.services.RegistrationService;
import org.gatein.wsrp.services.ServiceDescriptionService;
import org.gatein.wsrp.servlet.UserAccess;
+import org.gatein.wsrp.spec.v2.WSRP2Constants;
import org.oasis.wsrp.v2.ExportedPortlet;
import org.oasis.wsrp.v2.Extension;
import org.oasis.wsrp.v2.FailedPortlets;
@@ -527,9 +528,10 @@
return supportedUserScopes.contains(userScope);
}
- public boolean isSupportsExport()
+ public boolean isImportExportSupported()
{
- return isUsingWSRP2(); // todo: fix-me, using WSRP 2 doesn't necessarily equals
supporting export...
+ final List<String> supportedOptions = producerInfo.getSupportedOptions();
+ return isUsingWSRP2() &&
supportedOptions.contains(WSRP2Constants.OPTIONS_IMPORT) &&
supportedOptions.contains(WSRP2Constants.OPTIONS_EXPORT);
}
// Registration
*****************************************************************************************************
@@ -776,114 +778,120 @@
public ExportInfo exportPortlets(List<String> portletHandles) throws
PortletInvokerException
{
- if (ParameterValidation.existsAndIsNotEmpty(portletHandles))
+ if (isImportExportSupported())
{
-
- List<org.oasis.wsrp.v2.PortletContext> portletContexts = new
ArrayList<org.oasis.wsrp.v2.PortletContext>(portletHandles.size());
- for (String handle : portletHandles)
+ if (ParameterValidation.existsAndIsNotEmpty(portletHandles))
{
- portletContexts.add(WSRPTypeFactory.createPortletContext(handle));
- }
+ List<org.oasis.wsrp.v2.PortletContext> portletContexts = new
ArrayList<org.oasis.wsrp.v2.PortletContext>(portletHandles.size());
+ for (String handle : portletHandles)
+ {
+ portletContexts.add(WSRPTypeFactory.createPortletContext(handle));
+ }
- try
- {
- Holder<byte[]> exportContextHolder = new Holder<byte[]>();
- Holder<List<ExportedPortlet>> exportedPortletsHolder = new
Holder<List<ExportedPortlet>>();
- Holder<List<FailedPortlets>> failedPortletsHolder = new
Holder<List<FailedPortlets>>();
- Holder<Lifetime> lifetimeHolder = new Holder<Lifetime>();
- getPortletManagementService().exportPortlets(getRegistrationContext(),
portletContexts, UserAccess.getUserContext(),
- lifetimeHolder, true, exportContextHolder, exportedPortletsHolder,
failedPortletsHolder,
- new Holder<ResourceList>(), new
Holder<List<Extension>>());
+ try
+ {
+ Holder<byte[]> exportContextHolder = new Holder<byte[]>();
+ Holder<List<ExportedPortlet>> exportedPortletsHolder = new
Holder<List<ExportedPortlet>>();
+ Holder<List<FailedPortlets>> failedPortletsHolder = new
Holder<List<FailedPortlets>>();
+ Holder<Lifetime> lifetimeHolder = new Holder<Lifetime>();
+ getPortletManagementService().exportPortlets(getRegistrationContext(),
portletContexts, UserAccess.getUserContext(),
+ lifetimeHolder, true, exportContextHolder, exportedPortletsHolder,
failedPortletsHolder,
+ new Holder<ResourceList>(), new
Holder<List<Extension>>());
- SortedMap<String, byte[]> handleToState = null;
- List<ExportedPortlet> exportedPortlets = exportedPortletsHolder.value;
- if (ParameterValidation.existsAndIsNotEmpty(exportedPortlets))
- {
- handleToState = new TreeMap<String, byte[]>();
- for (ExportedPortlet exportedPortlet : exportedPortlets)
+ SortedMap<String, byte[]> handleToState = null;
+ List<ExportedPortlet> exportedPortlets =
exportedPortletsHolder.value;
+ if (ParameterValidation.existsAndIsNotEmpty(exportedPortlets))
{
- handleToState.put(exportedPortlet.getPortletHandle(),
exportedPortlet.getExportData());
+ handleToState = new TreeMap<String, byte[]>();
+ for (ExportedPortlet exportedPortlet : exportedPortlets)
+ {
+ handleToState.put(exportedPortlet.getPortletHandle(),
exportedPortlet.getExportData());
+ }
}
- }
- SortedMap<QName, List<String>> errorCodeToHandle = null;
- List<FailedPortlets> failedPortlets = failedPortletsHolder.value;
- if (ParameterValidation.existsAndIsNotEmpty(failedPortlets))
- {
- errorCodeToHandle = new TreeMap<QName, List<String>>();
- for (FailedPortlets failedPortletsForReason : failedPortlets)
+ SortedMap<QName, List<String>> errorCodeToHandle = null;
+ List<FailedPortlets> failedPortlets = failedPortletsHolder.value;
+ if (ParameterValidation.existsAndIsNotEmpty(failedPortlets))
{
- errorCodeToHandle.put(failedPortletsForReason.getErrorCode(),
failedPortletsForReason.getPortletHandles());
+ errorCodeToHandle = new TreeMap<QName, List<String>>();
+ for (FailedPortlets failedPortletsForReason : failedPortlets)
+ {
+ errorCodeToHandle.put(failedPortletsForReason.getErrorCode(),
failedPortletsForReason.getPortletHandles());
+ }
}
+
+ // todo: deal with expiration time
+ Lifetime lifetime = lifetimeHolder.value;
+ if (lifetime != null)
+ {
+ XMLGregorianCalendar currentTime = lifetime.getCurrentTime();
+ Duration refreshDuration = lifetime.getRefreshDuration();
+ XMLGregorianCalendar terminationTime = lifetime.getTerminationTime();
+ }
+
+ ExportInfo exportInfo = new ExportInfo(System.currentTimeMillis(),
errorCodeToHandle, handleToState, exportContextHolder.value);
+ getConsumerRegistry().getMigrationService().add(exportInfo);
+ return exportInfo;
}
-
- // todo: deal with expiration time
- Lifetime lifetime = lifetimeHolder.value;
- if (lifetime != null)
+ catch (OperationNotSupported operationNotSupported)
{
- XMLGregorianCalendar currentTime = lifetime.getCurrentTime();
- Duration refreshDuration = lifetime.getRefreshDuration();
- XMLGregorianCalendar terminationTime = lifetime.getTerminationTime();
+ throw new UnsupportedOperationException(operationNotSupported);
}
-
- ExportInfo exportInfo = new ExportInfo(System.currentTimeMillis(),
errorCodeToHandle, handleToState, exportContextHolder.value);
- getConsumerRegistry().getMigrationService().add(exportInfo);
- return exportInfo;
+ catch (InconsistentParameters inconsistentParameters)
+ {
+ throw new IllegalArgumentException(inconsistentParameters);
+ }
+ /*
+ // GTNWSRP-62
+ catch (AccessDenied accessDenied)
+ {
+ accessDenied.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
+ }
+ catch (ExportByValueNotSupported exportByValueNotSupported)
+ {
+ exportByValueNotSupported.printStackTrace(); //To change body of catch
statement use File | Settings | File Templates.
+ }
+ catch (InvalidHandle invalidHandle)
+ {
+ invalidHandle.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
+ }
+ catch (InvalidRegistration invalidRegistration)
+ {
+ invalidRegistration.printStackTrace(); //To change body of catch
statement use File | Settings | File Templates.
+ }
+ catch (InvalidUserCategory invalidUserCategory)
+ {
+ invalidUserCategory.printStackTrace(); //To change body of catch
statement use File | Settings | File Templates.
+ }
+ catch (MissingParameters missingParameters)
+ {
+ missingParameters.printStackTrace(); //To change body of catch statement
use File | Settings | File Templates.
+ }
+ catch (ModifyRegistrationRequired modifyRegistrationRequired)
+ {
+ modifyRegistrationRequired.printStackTrace(); //To change body of catch
statement use File | Settings | File Templates.
+ }
+ catch (OperationFailed operationFailed)
+ {
+ operationFailed.printStackTrace(); //To change body of catch statement
use File | Settings | File Templates.
+ }
+ catch (ResourceSuspended resourceSuspended)
+ {
+ resourceSuspended.printStackTrace(); //To change body of catch statement
use File | Settings | File Templates.
+ }*/
+ catch (Exception e)
+ {
+ throw new PortletInvokerException(e.getLocalizedMessage(), e);
+ }
}
- catch (OperationNotSupported operationNotSupported)
+ else
{
- throw new UnsupportedOperationException(operationNotSupported);
+ throw new IllegalArgumentException("Must provide a non-null, non-empty
list of portlet handles.");
}
- catch (InconsistentParameters inconsistentParameters)
- {
- throw new IllegalArgumentException(inconsistentParameters);
- }
- /*
- // GTNWSRP-62
- catch (AccessDenied accessDenied)
- {
- accessDenied.printStackTrace(); //To change body of catch statement use File
| Settings | File Templates.
- }
- catch (ExportByValueNotSupported exportByValueNotSupported)
- {
- exportByValueNotSupported.printStackTrace(); //To change body of catch
statement use File | Settings | File Templates.
- }
- catch (InvalidHandle invalidHandle)
- {
- invalidHandle.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
- }
- catch (InvalidRegistration invalidRegistration)
- {
- invalidRegistration.printStackTrace(); //To change body of catch statement
use File | Settings | File Templates.
- }
- catch (InvalidUserCategory invalidUserCategory)
- {
- invalidUserCategory.printStackTrace(); //To change body of catch statement
use File | Settings | File Templates.
- }
- catch (MissingParameters missingParameters)
- {
- missingParameters.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
- }
- catch (ModifyRegistrationRequired modifyRegistrationRequired)
- {
- modifyRegistrationRequired.printStackTrace(); //To change body of catch
statement use File | Settings | File Templates.
- }
- catch (OperationFailed operationFailed)
- {
- operationFailed.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
- }
- catch (ResourceSuspended resourceSuspended)
- {
- resourceSuspended.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
- }*/
- catch (Exception e)
- {
- throw new PortletInvokerException(e.getLocalizedMessage(), e);
- }
}
else
{
- throw new IllegalArgumentException("Must provide a non-null, non-empty list
of portlet handles.");
+ throw new UnsupportedOperationException("Producer " +
producerInfo.getId() + " doesn't support import/export functionality.");
}
}
@@ -894,127 +902,134 @@
public void releaseExport(ExportInfo exportInfo) throws PortletInvokerException
{
- ParameterValidation.throwIllegalArgExceptionIfNull(exportInfo, "ExportInfo to
release");
+ if (isImportExportSupported())
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(exportInfo, "ExportInfo
to release");
- getPortletManagementService().releaseExport(getRegistrationContext(),
exportInfo.getExportContext(), UserAccess.getUserContext());
+ getPortletManagementService().releaseExport(getRegistrationContext(),
exportInfo.getExportContext(), UserAccess.getUserContext());
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Producer " +
producerInfo.getId() + " doesn't support import/export functionality.");
+ }
}
public ImportInfo importPortlets(ExportInfo exportInfo, List<String> portlets)
throws PortletInvokerException
{
- ParameterValidation.throwIllegalArgExceptionIfNull(exportInfo, "ExportInfo to
import from");
+ if (isImportExportSupported())
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(exportInfo, "ExportInfo
to import from");
- if (ParameterValidation.existsAndIsNotEmpty(portlets))
- {
- try
+ if (ParameterValidation.existsAndIsNotEmpty(portlets))
{
- List<ImportPortlet> importPortlets = new
ArrayList<ImportPortlet>(portlets.size());
- for (String portlet : portlets)
+ try
{
- // todo: check semantics
- importPortlets.add(WSRPTypeFactory.createImportPortlet(portlet,
exportInfo.getPortletStateFor(portlet)));
- }
+ List<ImportPortlet> importPortlets = new
ArrayList<ImportPortlet>(portlets.size());
+ for (String portlet : portlets)
+ {
+ // todo: check semantics
+ importPortlets.add(WSRPTypeFactory.createImportPortlet(portlet,
exportInfo.getPortletStateFor(portlet)));
+ }
- Holder<List<ImportedPortlet>> importedPortletsHolder = new
Holder<List<ImportedPortlet>>();
- Holder<List<ImportPortletsFailed>> failedPortletsHolder = new
Holder<List<ImportPortletsFailed>>();
- Holder<ResourceList> resourceListHolder = new
Holder<ResourceList>();
- getPortletManagementService().importPortlets(getRegistrationContext(),
exportInfo.getExportContext(),
- importPortlets, UserAccess.getUserContext(), null, importedPortletsHolder,
failedPortletsHolder,
- resourceListHolder, new Holder<List<Extension>>());
+ Holder<List<ImportedPortlet>> importedPortletsHolder = new
Holder<List<ImportedPortlet>>();
+ Holder<List<ImportPortletsFailed>> failedPortletsHolder = new
Holder<List<ImportPortletsFailed>>();
+ Holder<ResourceList> resourceListHolder = new
Holder<ResourceList>();
+ getPortletManagementService().importPortlets(getRegistrationContext(),
exportInfo.getExportContext(),
+ importPortlets, UserAccess.getUserContext(), null,
importedPortletsHolder, failedPortletsHolder,
+ resourceListHolder, new Holder<List<Extension>>());
- List<ImportedPortlet> importedPortlets = importedPortletsHolder.value;
- SortedMap<String, PortletContext> importIdToPortletContext = new
TreeMap<String, PortletContext>();
- if (ParameterValidation.existsAndIsNotEmpty(importedPortlets))
- {
- for (ImportedPortlet importedPortlet : importedPortlets)
+ List<ImportedPortlet> importedPortlets =
importedPortletsHolder.value;
+ SortedMap<String, PortletContext> importIdToPortletContext = new
TreeMap<String, PortletContext>();
+ if (ParameterValidation.existsAndIsNotEmpty(importedPortlets))
{
- org.oasis.wsrp.v2.PortletContext portletContext =
importedPortlet.getNewPortletContext();
- PortletContext apiPC =
PortletContext.createPortletContext(portletContext.getPortletHandle(),
portletContext.getPortletState(), false);
- // we need to reference the resulting PortletContext so that it can
then be used properly
- importIdToPortletContext.put(importedPortlet.getImportID(),
PortletContext.reference(getProducerId(), apiPC));
+ for (ImportedPortlet importedPortlet : importedPortlets)
+ {
+ org.oasis.wsrp.v2.PortletContext portletContext =
importedPortlet.getNewPortletContext();
+ PortletContext apiPC =
PortletContext.createPortletContext(portletContext.getPortletHandle(),
portletContext.getPortletState(), false);
+ // we need to reference the resulting PortletContext so that it can
then be used properly
+ importIdToPortletContext.put(importedPortlet.getImportID(),
PortletContext.reference(getProducerId(), apiPC));
+ }
}
- }
- SortedMap<QName, List<String>> errorCodeToHandle = null;
- List<ImportPortletsFailed> failedPortlets =
failedPortletsHolder.value;
- if (ParameterValidation.existsAndIsNotEmpty(failedPortlets))
- {
- errorCodeToHandle = new TreeMap<QName, List<String>>();
- for (ImportPortletsFailed failedPortletsForReason : failedPortlets)
+ SortedMap<QName, List<String>> errorCodeToHandle = null;
+ List<ImportPortletsFailed> failedPortlets =
failedPortletsHolder.value;
+ if (ParameterValidation.existsAndIsNotEmpty(failedPortlets))
{
- errorCodeToHandle.put(failedPortletsForReason.getErrorCode(),
failedPortletsForReason.getImportID());
+ errorCodeToHandle = new TreeMap<QName, List<String>>();
+ for (ImportPortletsFailed failedPortletsForReason : failedPortlets)
+ {
+ errorCodeToHandle.put(failedPortletsForReason.getErrorCode(),
failedPortletsForReason.getImportID());
+ }
}
+
+ return new ImportInfo(System.currentTimeMillis(), errorCodeToHandle,
importIdToPortletContext);
}
-
- return new ImportInfo(System.currentTimeMillis(), errorCodeToHandle,
importIdToPortletContext);
+ catch (OperationNotSupported operationNotSupported)
+ {
+ throw new UnsupportedOperationException(operationNotSupported);
+ }
+ catch (InconsistentParameters inconsistentParameters)
+ {
+ throw new IllegalArgumentException(inconsistentParameters);
+ }
+ /*
+ // GTNWSRP-62
+ catch (AccessDenied accessDenied)
+ {
+ accessDenied.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
+ }
+ catch (ExportByValueNotSupported exportByValueNotSupported)
+ {
+ exportByValueNotSupported.printStackTrace(); //To change body of catch
statement use File | Settings | File Templates.
+ }
+ catch (InvalidHandle invalidHandle)
+ {
+ invalidHandle.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
+ }
+ catch (InvalidRegistration invalidRegistration)
+ {
+ invalidRegistration.printStackTrace(); //To change body of catch
statement use File | Settings | File Templates.
+ }
+ catch (InvalidUserCategory invalidUserCategory)
+ {
+ invalidUserCategory.printStackTrace(); //To change body of catch
statement use File | Settings | File Templates.
+ }
+ catch (MissingParameters missingParameters)
+ {
+ missingParameters.printStackTrace(); //To change body of catch statement
use File | Settings | File Templates.
+ }
+ catch (ModifyRegistrationRequired modifyRegistrationRequired)
+ {
+ modifyRegistrationRequired.printStackTrace(); //To change body of catch
statement use File | Settings | File Templates.
+ }
+ catch (OperationFailed operationFailed)
+ {
+ operationFailed.printStackTrace(); //To change body of catch statement
use File | Settings | File Templates.
+ }
+ catch (ResourceSuspended resourceSuspended)
+ {
+ resourceSuspended.printStackTrace(); //To change body of catch statement
use File | Settings | File Templates.
+ }*/
+ catch (Exception e)
+ {
+ throw new PortletInvokerException(e.getLocalizedMessage(), e);
+ }
}
- catch (OperationNotSupported operationNotSupported)
+ else
{
- throw new UnsupportedOperationException(operationNotSupported);
+ throw new IllegalArgumentException("Must provide a non-null, non-empty
list of portlet handles.");
}
- catch (InconsistentParameters inconsistentParameters)
- {
- throw new IllegalArgumentException(inconsistentParameters);
- }
- /*
- // GTNWSRP-62
- catch (AccessDenied accessDenied)
- {
- accessDenied.printStackTrace(); //To change body of catch statement use File
| Settings | File Templates.
- }
- catch (ExportByValueNotSupported exportByValueNotSupported)
- {
- exportByValueNotSupported.printStackTrace(); //To change body of catch
statement use File | Settings | File Templates.
- }
- catch (InvalidHandle invalidHandle)
- {
- invalidHandle.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
- }
- catch (InvalidRegistration invalidRegistration)
- {
- invalidRegistration.printStackTrace(); //To change body of catch statement
use File | Settings | File Templates.
- }
- catch (InvalidUserCategory invalidUserCategory)
- {
- invalidUserCategory.printStackTrace(); //To change body of catch statement
use File | Settings | File Templates.
- }
- catch (MissingParameters missingParameters)
- {
- missingParameters.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
- }
- catch (ModifyRegistrationRequired modifyRegistrationRequired)
- {
- modifyRegistrationRequired.printStackTrace(); //To change body of catch
statement use File | Settings | File Templates.
- }
- catch (OperationFailed operationFailed)
- {
- operationFailed.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
- }
- catch (ResourceSuspended resourceSuspended)
- {
- resourceSuspended.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
- }*/
- catch (Exception e)
- {
- throw new PortletInvokerException(e.getLocalizedMessage(), e);
- }
}
else
{
- throw new IllegalArgumentException("Must provide a non-null, non-empty list
of portlet handles.");
+ throw new UnsupportedOperationException("Producer " +
producerInfo.getId() + " doesn't support import/export functionality.");
}
}
public boolean isUsingWSRP2()
{
Version wsrpVersion = getWSRPVersion();
- if (wsrpVersion != null)
- {
- return wsrpVersion.getMajor() >= 2;
- }
- else
- {
- return false;
- }
+ return wsrpVersion != null && wsrpVersion.getMajor() >= 2;
}
public MigrationService getMigrationService()
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationDispatcher.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationDispatcher.java 2011-11-07
15:52:28 UTC (rev 8001)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationDispatcher.java 2011-11-07
16:05:27 UTC (rev 8002)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, Red Hat Middleware, LLC, and individual
* contributors as indicated by the @authors tag. See the
* copyright.txt in the distribution for a full listing of
* individual contributors.
@@ -35,7 +35,9 @@
import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
import org.gatein.wsrp.WSRPResourceURL;
import org.gatein.wsrp.WSRPRewritingConstants;
+import org.gatein.wsrp.consumer.ProducerInfo;
import org.gatein.wsrp.consumer.WSRPConsumerImpl;
+import org.gatein.wsrp.spec.v2.WSRP2Constants;
import org.gatein.wsrp.spec.v2.WSRP2RewritingConstants;
import java.util.Map;
@@ -127,7 +129,16 @@
}
else if (invocation instanceof EventInvocation)
{
- handler = eventHandler;
+ final ProducerInfo producerInfo = consumer.getProducerInfo();
+ if (producerInfo.getSupportedOptions().contains(WSRP2Constants.OPTIONS_EVENTS))
+ {
+ handler = eventHandler;
+ }
+ else
+ {
+ // do something better here?
+ return new ErrorResponse("Producer " + producerInfo.getId() +
" doesn't support event processing.");
+ }
}
else
{
Modified:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java 2011-11-07
15:52:28 UTC (rev 8001)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java 2011-11-07
16:05:27 UTC (rev 8002)
@@ -245,7 +245,7 @@
throw new NotYetImplemented();
}
- public boolean isSupportsExport()
+ public boolean isImportExportSupported()
{
return false;
}