Author: thomas.heute(a)jboss.com
Date: 2007-09-27 02:50:50 -0400 (Thu, 27 Sep 2007)
New Revision: 8493
Modified:
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
Log:
- JBPORTAL-1722: Surrounded access to portlet invoker by calls to
RegistrationLocal.setRegistration(registration) and finally {
RegistrationLocal.setRegistration(null); }
to make sure that the proper registration is seen.
- Improved service description logic. Should now be possible to write code to filter
service description based on registration data.
- Renamed methods more appropriately.
Modified:
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
===================================================================
---
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2007-09-27
01:53:46 UTC (rev 8492)
+++
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2007-09-27
06:50:50 UTC (rev 8493)
@@ -154,7 +154,7 @@
throws AccessDeniedFault, OperationFailedFault, InvalidRegistrationFault,
RemoteException
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(initCookie,
"InitCookie");
- producer.checkRegistration(initCookie.getRegistrationContext());
+ producer.getRegistrationOrFailIfInvalid(initCookie.getRegistrationContext());
// Force HTTP session creation... this is required for BEA Weblogic version <
9.2.
// See
http://jira.jboss.com/jira/browse/JBPORTAL-1220
Modified:
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
===================================================================
---
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-09-27
01:53:46 UTC (rev 8492)
+++
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2007-09-27
06:50:50 UTC (rev 8493)
@@ -37,6 +37,8 @@
import org.jboss.portal.portlet.state.DestroyCloneFailure;
import org.jboss.portal.portlet.state.PropertyChange;
import org.jboss.portal.portlet.state.PropertyMap;
+import org.jboss.portal.registration.Registration;
+import org.jboss.portal.registration.RegistrationLocal;
import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
import org.jboss.portal.wsrp.WSRPTypeFactory;
@@ -56,6 +58,7 @@
import org.jboss.portal.wsrp.core.MissingParametersFault;
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PortletContext;
+import org.jboss.portal.wsrp.core.PortletDescription;
import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
import org.jboss.portal.wsrp.core.PortletPropertyDescriptionResponse;
import org.jboss.portal.wsrp.core.Property;
@@ -97,7 +100,7 @@
MissingParametersFault, InvalidRegistrationFault, OperationFailedFault,
RemoteException
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(getPortletDescription,
GET_PORTLET_DESCRIPTION);
- producer.checkRegistration(getPortletDescription.getRegistrationContext());
+ Registration registration =
producer.getRegistrationOrFailIfInvalid(getPortletDescription.getRegistrationContext());
PortletContext portletContext = getPortletDescription.getPortletContext();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(portletContext,
PORTLET_CONTEXT, GET_PORTLET_DESCRIPTION);
@@ -105,7 +108,9 @@
UserContext userContext = getPortletDescription.getUserContext();
checkUserAuthorization(userContext);
- return
WSRPTypeFactory.createPortletDescriptionResponse(producer.getPortletDescription(portletContext,
getPortletDescription.getDesiredLocales()));
+ // RegistrationLocal.setRegistration is called further down the invocation in
ServiceDescriptionHandler.getPortletDescription
+ PortletDescription description = producer.getPortletDescription(portletContext,
getPortletDescription.getDesiredLocales(), registration);
+ return WSRPTypeFactory.createPortletDescriptionResponse(description);
}
public PortletPropertyDescriptionResponse
getPortletPropertyDescription(GetPortletPropertyDescription
getPortletPropertyDescription)
@@ -117,13 +122,13 @@
PortletContext portletContext = getPortletPropertyDescription.getPortletContext();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(portletContext,
PORTLET_CONTEXT, GET_PORTLET_PROPERTY_DESCRIPTION);
-
producer.checkRegistration(getPortletPropertyDescription.getRegistrationContext());
+ Registration registration =
producer.getRegistrationOrFailIfInvalid(getPortletPropertyDescription.getRegistrationContext());
UserContext userContext = getPortletPropertyDescription.getUserContext();
checkUserAuthorization(userContext);
String[] desiredLocales = getPortletPropertyDescription.getDesiredLocales();
- Portlet portlet = getPortletFrom(portletContext);
+ Portlet portlet = getPortletFrom(portletContext, registration);
PortletInfo info = portlet.getInfo();
PreferencesInfo prefsInfo = info.getPreferences();
@@ -162,7 +167,7 @@
PortletContext portletContext = clonePortlet.getPortletContext();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(portletContext,
"PortletContext", "ClonePortlet");
- producer.checkRegistration(clonePortlet.getRegistrationContext());
+ Registration registration =
producer.getRegistrationOrFailIfInvalid(clonePortlet.getRegistrationContext());
UserContext userContext = clonePortlet.getUserContext();
checkUserAuthorization(userContext);
@@ -170,6 +175,7 @@
org.jboss.portal.portlet.PortletContext portalPC =
WSRPUtils.convertToPortalPortletContext(portletContext);
try
{
+ RegistrationLocal.setRegistration(registration);
org.jboss.portal.portlet.PortletContext response =
producer.getInvoker().createClone(portalPC);
return WSRPUtils.convertToWSRPPortletContext(response);
}
@@ -188,6 +194,10 @@
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Failed to create clone for portlet '" +
portletContext.getPortletHandle(), e);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
public DestroyPortletsResponse destroyPortlets(DestroyPortlets destroyPortlets) throws
InconsistentParametersFault,
@@ -198,7 +208,7 @@
String[] handles = destroyPortlets.getPortletHandles();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(handles,
"portlet handles to be destroyed", "DestroyPortlets");
- producer.checkRegistration(destroyPortlets.getRegistrationContext());
+ Registration registration =
producer.getRegistrationOrFailIfInvalid(destroyPortlets.getRegistrationContext());
List portletContexts = new ArrayList(handles.length);
for (int i = 0; i < handles.length; i++)
@@ -208,6 +218,7 @@
try
{
+ RegistrationLocal.setRegistration(registration);
List failuresList = producer.getInvoker().destroyClones(portletContexts);
int failuresNumber = failuresList.size();
DestroyFailed[] destroyFailed;
@@ -233,6 +244,10 @@
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Failed to destroy clones", e);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
public PortletContext setPortletProperties(SetPortletProperties setPortletProperties)
throws OperationFailedFault,
@@ -247,7 +262,7 @@
PropertyList propertyList = setPortletProperties.getPropertyList();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(propertyList,
"PropertyList", "SetPortletProperties");
- producer.checkRegistration(setPortletProperties.getRegistrationContext());
+ Registration registration =
producer.getRegistrationOrFailIfInvalid(setPortletProperties.getRegistrationContext());
checkUserAuthorization(setPortletProperties.getUserContext());
@@ -293,6 +308,7 @@
try
{
+ RegistrationLocal.setRegistration(registration);
org.jboss.portal.portlet.PortletContext resultContext =
producer.getInvoker().setProperties(WSRPUtils.convertToPortalPortletContext(portletContext),
(PropertyChange[])changes.toArray(new PropertyChange[0]));
@@ -313,6 +329,10 @@
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Failed to set properties for portlet '" +
portletContext.getPortletHandle(), e);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
return portletContext;
@@ -327,7 +347,7 @@
PortletContext portletContext = getPortletProperties.getPortletContext();
WSRPExceptionFactory.throwMissingParametersFaultIfValueIsMissing(portletContext,
PORTLET_CONTEXT, GET_PORTLET_PROPERTIES);
- producer.checkRegistration(getPortletProperties.getRegistrationContext());
+ Registration registration =
producer.getRegistrationOrFailIfInvalid(getPortletProperties.getRegistrationContext());
UserContext userContext = getPortletProperties.getUserContext();
checkUserAuthorization(userContext);
@@ -340,6 +360,7 @@
PropertyMap properties;
org.jboss.portal.portlet.PortletContext jbpContext =
WSRPUtils.convertToPortalPortletContext(portletContext);
+ RegistrationLocal.setRegistration(registration);
if (keys != null)
{
properties = producer.getInvoker().getProperties(jbpContext, keys);
@@ -350,7 +371,7 @@
}
//todo: we need to check that the user can actually modify the properties
- Portlet portlet = getPortletFrom(portletContext);
+ Portlet portlet = getPortletFrom(portletContext, registration);
PortletInfo info = portlet.getInfo();
PropertyList result = WSRPTypeFactory.createPropertyList();
@@ -386,6 +407,10 @@
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
"Could not retrieve properties for portlet '" + portletContext
+ "'", e);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
private void checkUserAuthorization(UserContext userContext)
@@ -427,18 +452,23 @@
return keys;
}
- private Portlet getPortletFrom(PortletContext portletContext) throws
InvalidHandleFault
+ private Portlet getPortletFrom(PortletContext portletContext, Registration
registration) throws InvalidHandleFault
{
Portlet portlet;
try
{
+ RegistrationLocal.setRegistration(registration);
portlet =
producer.getInvoker().getPortlet(WSRPUtils.convertToPortalPortletContext(portletContext));
+ return portlet;
}
catch (PortletInvokerException e)
{
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
"Could not retrieve portlet '" +
portletContext.getPortletHandle() + "'", e);
}
- return portlet;
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
}
}
Modified:
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
===================================================================
---
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2007-09-27
01:53:46 UTC (rev 8492)
+++
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2007-09-27
06:50:50 UTC (rev 8493)
@@ -29,7 +29,6 @@
import org.jboss.portal.registration.NoSuchRegistrationException;
import org.jboss.portal.registration.Registration;
import org.jboss.portal.registration.RegistrationException;
-import org.jboss.portal.registration.RegistrationLocal;
import org.jboss.portal.registration.RegistrationStatus;
import org.jboss.portal.registration.RegistrationUtils;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
@@ -138,9 +137,6 @@
capabilities.setSupportedUserProfileData(getListFromArray(customUserProfileData,
false));
capabilities.setSupportedUserScopes(getListFromArray(consumerUserScopes, false));
capabilities.setSupportsGetMethod(isMethodGetSupported);
-
- // update RegistrationLocal for downstream use of Registration data
- RegistrationLocal.setRegistration(registration);
}
public ReturnAny deregister(RegistrationContext deregister) throws
OperationFailedFault, InvalidRegistrationFault,
@@ -159,7 +155,6 @@
try
{
producer.getRegistrationManager().removeRegistration(registrationHandle);
- RegistrationLocal.setRegistration(null);
}
catch (NoSuchRegistrationException e)
{
@@ -221,45 +216,71 @@
return null;
}
- public boolean isRegistrationValid(RegistrationContext registrationContext) throws
InvalidRegistrationFault
+ /**
+ * @param reg
+ * @param throwExceptionIfExistsAndInvalid
+ *
+ * @return
+ * @since 2.6.2
+ */
+ boolean isRegistrationValid(Registration reg, boolean
throwExceptionIfExistsAndInvalid)
{
+ if (reg == null)
+ {
+ if (producer.getProducerRegistrationRequirements().requiresRegistration())
+ {
+ log.debug("Registration is required yet no RegistrationContext was
provided: registration invalid!");
+ return false;
+ }
+
+ log.debug("Registration not required, no registration: registration
valid!");
+ return true;
+ }
+ else
+ {
+ boolean result = RegistrationStatus.VALID.equals(reg.getStatus());
+ log.debug("Registration required: registration is " + (result ?
"valid!" : "invalid!"));
+
+ if (throwExceptionIfExistsAndInvalid && !result)
+ {
+ throwInvalidRegistrationFault("registration with handle '" +
reg.getRegistrationHandle() + "' is not valid!");
+ }
+
+ return result;
+ }
+ }
+
+ /**
+ * @param registrationContext
+ * @return
+ * @since 2.6.2
+ */
+ Registration getRegistrationFrom(RegistrationContext registrationContext)
+ {
if (producer.getProducerRegistrationRequirements().requiresRegistration())
{
- log.debug("registration required: checking registration");
if (registrationContext == null)
{
- log.debug("registration is required yet no RegistrationContext was
provided!");
- return false;
+ return null;
}
String regHandle = registrationContext.getRegistrationHandle();
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(regHandle,
"registration handle");
- Registration reg;
try
{
- reg = producer.getRegistrationManager().getRegistration(regHandle);
+ Registration registration =
producer.getRegistrationManager().getRegistration(regHandle);
+ if (registration == null)
+ {
+ throwInvalidRegistrationFault("provided registration handle
'" + regHandle + "' is not registered with this producer");
+ }
+ return registration;
}
catch (RegistrationException e)
{
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Failed to retrieve registration information associated with handle
" + regHandle, e);
}
-
- if (reg == null)
- {
- throwInvalidRegistrationFault("provided registration handle '"
+ regHandle +
- "' is not registered with this producer");
- }
-
- if (!RegistrationStatus.VALID.equals(reg.getStatus()))
- {
- throwInvalidRegistrationFault("provided registration is no longer
valid");
- }
-
- log.debug("registration is valid!");
- RegistrationLocal.setRegistration(reg); // set the current registration for
downstream use
- return true;
}
else
{
@@ -267,12 +288,11 @@
{
throwInvalidRegistrationFault("no registration necessary yet one was
provided!");
}
- RegistrationLocal.setRegistration(null);
- return true;
+ return null;
}
}
- private boolean throwInvalidRegistrationFault(String message) throws
InvalidRegistrationFault
+ boolean throwInvalidRegistrationFault(String message)
{
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_REGISTRATION,
"Invalid registration: " + message, null);
Modified:
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java
===================================================================
---
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java 2007-09-27
01:53:46 UTC (rev 8492)
+++
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/RequestProcessor.java 2007-09-27
06:50:50 UTC (rev 8493)
@@ -37,6 +37,7 @@
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.portlet.spi.WindowContext;
import org.jboss.portal.portlet.state.AccessMode;
+import org.jboss.portal.registration.Registration;
import org.jboss.portal.server.PortalConstants;
import org.jboss.portal.wsrp.UserContextConverter;
import org.jboss.portal.wsrp.WSRPConstants;
@@ -90,7 +91,7 @@
void prepareInvocation() throws InvalidRegistrationFault, OperationFailedFault,
InvalidHandleFault,
UnsupportedMimeTypeFault, UnsupportedWindowStateFault, UnsupportedModeFault
{
- producer.checkRegistration(getRegistrationContext());
+ Registration registration =
producer.getRegistrationOrFailIfInvalid(getRegistrationContext());
// get session information and deal with it
final RuntimeContext runtimeContext = getRuntimeContext();
@@ -110,7 +111,8 @@
// retrieve the portlet
try
{
- portlet = producer.getPortletWith(portletContext);
+ // calls RegistrationLocal.setRegistration so no need to here
+ portlet = producer.getPortletWith(portletContext, registration);
}
catch (PortletInvokerException e)
{
Modified:
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
---
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-09-27
01:53:46 UTC (rev 8492)
+++
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2007-09-27
06:50:50 UTC (rev 8493)
@@ -31,6 +31,7 @@
import org.jboss.portal.portlet.info.ModeInfo;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.info.WindowStateInfo;
+import org.jboss.portal.registration.Registration;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.WSRPUtils;
@@ -76,12 +77,52 @@
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(gs,
"GetServiceDescription");
- if (!producer.isRegistrationValid(gs.getRegistrationContext()))
+ Registration registration =
producer.getRegistrationFrom(gs.getRegistrationContext());
+ boolean registrationValid = producer.isRegistrationValid(registration);
+
+ ProducerRegistrationRequirements requirements =
producer.getProducerRegistrationRequirements();
+
+ PortletDescription[] offeredPortlets = null;
+ ServiceDescription serviceDescription =
WSRPTypeFactory.createServiceDescription(requirements.requiresRegistration());
+ serviceDescription.setRequiresInitCookie(BEA_8_CONSUMER_FIX);
+ serviceDescription.setLocales(producer.getSupportedLocales());
+
+ if (!requirements.requiresRegistration())
{
- return getRegistrationNotProvidedServiceDescription(gs.getDesiredLocales());
+ offeredPortlets = getPortletDescriptions(gs.getDesiredLocales(), null);
}
- log.debug("Returning complete service description");
- return refreshServiceDescription(gs.getDesiredLocales());
+ else
+ {
+ if (!registrationValid)
+ {
+ log.debug("Unregistered consumer while registration is required. Sending
registration information.");
+
+ if (requirements.fullServiceDescriptionRequiresRegistration())
+ {
+ log.debug("Sending offered portlets description despite not being
registered, per Producer configuration.");
+ offeredPortlets = getPortletDescriptions(gs.getDesiredLocales(), null);
+ }
+
+ // do not create a ModelDescription if there is no registration properties
+ Map info = requirements.getRegistrationProperties();
+ ModelDescription description = null;
+ if (info != null && !info.isEmpty())
+ {
+ description =
WSRPUtils.convertRegistrationPropertiesToModelDescription(info);
+ }
+
+ serviceDescription.setRegistrationPropertyDescription(description);
+ }
+ else
+ {
+ log.debug("Sending registered service description.");
+ // should we be sending the registration properties description as well?
+ offeredPortlets = getPortletDescriptions(gs.getDesiredLocales(),
registration);
+ }
+ }
+
+ serviceDescription.setOfferedPortlets(offeredPortlets);
+ return serviceDescription;
}
@@ -110,78 +151,34 @@
return offeredPortletDescriptions;
}
- public PortletDescription getPortletDescription(PortletContext portletContext,
String[] desiredLocales) throws InvalidHandleFault, OperationFailedFault
+ public PortletDescription getPortletDescription(PortletContext portletContext,
String[] desiredLocales, Registration registration) throws InvalidHandleFault,
OperationFailedFault
{
ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "portlet
context");
Portlet portlet;
try
{
- portlet =
producer.getPortletWith(WSRPUtils.convertToPortalPortletContext(portletContext));
+ portlet =
producer.getPortletWith(WSRPUtils.convertToPortalPortletContext(portletContext),
registration);
+ return getPortletDescription(portlet, desiredLocales);
}
catch (PortletInvokerException e)
{
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
"Could not retrieve portlet '" + portletContext +
"'", e);
}
- return getPortletDescription(portlet, desiredLocales);
}
/**
- * Refreshes the service description by asking the portal container about contained
portlets.
- *
- * @param desiredLocales the desired locales for the service description
- * @return the updated service description
+ * @param desiredLocales
+ * @param registration here so that we can do filtering of portlets based on
registration data.
+ * @return
*/
- private ServiceDescription refreshServiceDescription(String[] desiredLocales)
+ private PortletDescription[] getPortletDescriptions(String[] desiredLocales,
Registration registration)
{
- // todo: find out how to cache this
- ProducerRegistrationRequirements requirements =
producer.getProducerRegistrationRequirements();
- // should we be sending the registration properties description as well?
- ServiceDescription serviceDescription =
WSRPTypeFactory.createServiceDescription(requirements.requiresRegistration());
- serviceDescription.setRequiresInitCookie(BEA_8_CONSUMER_FIX);
- PortletDescription[] descriptions = getPortletDescriptions(desiredLocales);
- serviceDescription.setOfferedPortlets(descriptions);
- return serviceDescription;
- }
-
- private PortletDescription[] getPortletDescriptions(String[] desiredLocales)
- {
return (PortletDescription[])getOfferedPortletDescriptions(desiredLocales)
.toArray(new PortletDescription[]{});
}
/**
- * Retrieves the service description offered to unregistered consumers when
registration is required.
- *
- * @param desiredLocales
- * @return the service description offered to unregistered consumers when registration
is required
- */
- protected ServiceDescription getRegistrationNotProvidedServiceDescription(String[]
desiredLocales)
- {
- log.debug("Unregistered consumer while registration is required. Sending
registration information.");
- ProducerRegistrationRequirements requirements =
producer.getProducerRegistrationRequirements();
-
-
- PortletDescription[] offeredPortlets = null;
- if (requirements.fullServiceDescriptionRequiresRegistration())
- {
- log.debug("Sending offered portlets description despite not being
registered, per Producer configuration.");
- offeredPortlets = getPortletDescriptions(desiredLocales);
- }
-
- // do not create a ModelDescription if there is no registration properties
- Map info = requirements.getRegistrationProperties();
- ModelDescription description = null;
- if (info != null && !info.isEmpty())
- {
- description = WSRPUtils.convertRegistrationPropertiesToModelDescription(info);
- }
-
- return new ServiceDescription(true, offeredPortlets, null, null, null, null,
BEA_8_CONSUMER_FIX,
- description, producer.getSupportedLocales(), null, null);
- }
-
- /**
* Creates a PortletDescription based on the user desired locales (ordered according
to user preferences) for the
* specified component.
*
Modified:
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
---
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2007-09-27
01:53:46 UTC (rev 8492)
+++
tags/JBoss_Portal_2_6_2/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2007-09-27
06:50:50 UTC (rev 8493)
@@ -30,6 +30,8 @@
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.registration.Registration;
+import org.jboss.portal.registration.RegistrationLocal;
import org.jboss.portal.registration.RegistrationManager;
import org.jboss.portal.wsrp.ResponseDebugFactory;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
@@ -382,11 +384,12 @@
this.invoker = invoker;
}
- Portlet getPortletWith(org.jboss.portal.portlet.PortletContext portletContext) throws
InvalidHandleFault, PortletInvokerException
+ Portlet getPortletWith(org.jboss.portal.portlet.PortletContext portletContext,
Registration registration) throws InvalidHandleFault, PortletInvokerException
{
Portlet portlet;
try
{
+ RegistrationLocal.setRegistration(registration);
portlet = invoker.getPortlet(portletContext);
}
catch (NoSuchPortletException e)
@@ -394,6 +397,11 @@
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
"Couldn't find portlet with handle '" +
portletContext.getId() + "'", null);
}
+ finally
+ {
+ RegistrationLocal.setRegistration(null);
+ }
+
if (!isRemotable(portlet))
{
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_HANDLE,
@@ -421,9 +429,9 @@
return remotablePortlets;
}
- public PortletDescription getPortletDescription(PortletContext portletContext,
String[] locales) throws InvalidHandleFault, OperationFailedFault
+ public PortletDescription getPortletDescription(PortletContext portletContext,
String[] locales, Registration registration) throws InvalidHandleFault,
OperationFailedFault
{
- return serviceDescriptionHandler.getPortletDescription(portletContext, locales);
+ return serviceDescriptionHandler.getPortletDescription(portletContext, locales,
registration);
}
public PortletDescription getPortletDescription(Portlet portlet, String[] locales)
@@ -432,38 +440,43 @@
}
/**
- * Checks that the specified registration information is valid if this Producer
requires registration.
- *
* @param registrationContext
- * @return <code>true</code> if the registration (when registration is
required) information is valid or if no
- * registration is required, <code>false</code> otherwise
(registration required, invalid information).
+ * @return
+ * @throws InvalidRegistrationFault
+ * @throws OperationFailedFault
+ * @since 2.6.2
*/
- protected boolean isRegistrationValid(RegistrationContext registrationContext) throws
InvalidRegistrationFault, OperationFailedFault
+ Registration getRegistrationOrFailIfInvalid(RegistrationContext registrationContext)
throws InvalidRegistrationFault, OperationFailedFault
{
- return registrationHandler.isRegistrationValid(registrationContext);
+ Registration registration = getRegistrationFrom(registrationContext);
+ if (!isRegistrationValid(registration))
+ {
+ registrationHandler.throwInvalidRegistrationFault("Invalid
registration");
+ }
+
+ return registration;
}
- protected void checkRegistration(RegistrationContext registrationContext) throws
InvalidRegistrationFault, OperationFailedFault
+ /**
+ * @param registration
+ * @return
+ * @since 2.6.2
+ */
+ boolean isRegistrationValid(Registration registration)
{
- if (!isRegistrationValid(registrationContext))
- {
- String message;
- if (registrationContext != null)
- {
- message = "Registration associated with registration handle '"
+ registrationContext.getRegistrationHandle()
- + "' is not a valid registration";
- }
- else
- {
- message = "The given registration context was null";
- }
+ return registrationHandler.isRegistrationValid(registration, true);
+ }
- log.debug(message);
- throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.INVALID_REGISTRATION,
message, null);
- }
+ /**
+ * @param registrationContext
+ * @return
+ * @since 2.6.2
+ */
+ Registration getRegistrationFrom(RegistrationContext registrationContext)
+ {
+ return registrationHandler.getRegistrationFrom(registrationContext);
}
-
private Boolean remotableByDefault;
public Boolean isRemotableByDefault()