Author: chris.laprun(a)jboss.com
Date: 2008-07-14 16:52:19 -0400 (Mon, 14 Jul 2008)
New Revision: 11444
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RefreshResult.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
Log:
- JBPORTAL-1800: Improved InvalidRegistration handling.
- RefreshResult has now a default SUCCESS status.
- Added some documentation.
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2008-07-14
20:44:27 UTC (rev 11443)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2008-07-14
20:52:19 UTC (rev 11444)
@@ -301,8 +301,10 @@
if (forceRefresh || isRefreshNeeded(true))
{
log.debug("Refreshing info for producer '" + getId() +
"'");
- // Refresh occurs until proven otherwise! :)
- RefreshResult result = new RefreshResult(RefreshResult.Status.SUCCESS);
+
+
+ RefreshResult result = new RefreshResult(); // success by default!
+
try
{
persistentEndpointInfo.refresh();
@@ -316,6 +318,7 @@
// save changes to endpoint
registry.updateProducerInfo(this);
+ // get the service description from the producer
try
{
// if we don't yet have registration information, get an unregistered
service description
@@ -324,17 +327,20 @@
}
catch (OperationFailedFault operationFailedFault)
{
+ // if we have local registration info, the OperationFailedFault might
indicate a need to call modifyRegistration
if (hasLocalRegistrationInfo())
{
log.debug("OperationFailedFault occurred, might indicate a need to
modify registration");
+
// attempt to get unregistered service description
serviceDescription = getServiceDescription(true);
result.setServiceDescription(serviceDescription);
- // validate the registration information
+ // re-validate the registration information
RefreshResult registrationResult =
internalRefreshRegistration(serviceDescription, false, true, true);
if (registrationResult.hasIssues())
{
+ // if the registration validation has issues, we need to modify our
local information
isModifyRegistrationRequired = true;
setActiveAndSave(false);
}
@@ -354,52 +360,76 @@
serviceDescription = rethrowAsInvokerUnvailable(operationFailedFault);
}
}
+ catch (InvalidRegistrationFault invalidRegistrationFault)
+ {
+ log.debug("InvalidRegistrationFault occurred");
- // do we need to call initCookie or not?
- requiresInitCookie = serviceDescription.getRequiresInitCookie();
+ // attempt to get unregistered service description
+ serviceDescription = getServiceDescription(true);
+ result.setServiceDescription(serviceDescription);
- // custom mode descriptions
- customModes = toMap(serviceDescription.getCustomModeDescriptions());
+ // check our registration information against what is sent in the service
description
+ RefreshResult registrationResult =
internalRefreshRegistration(serviceDescription, false, true, true);
+ if (registrationResult.hasIssues())
+ {
+ setActiveAndSave(false);
+ rethrowAsInvokerUnvailable(invalidRegistrationFault);
+ }
- // custom window state descriptions
- customWindowStates =
toMap(serviceDescription.getCustomWindowStateDescriptions());
+ return refreshInfo(false, serviceDescription, result);
+ }
- // do we need to register?
- if (serviceDescription.isRequiresRegistration())
+ return refreshInfo(forceRefresh, serviceDescription, result);
+ }
+
+ return new RefreshResult(RefreshResult.Status.BYPASSED);
+ }
+
+ private RefreshResult refreshInfo(boolean forceRefresh, ServiceDescription
serviceDescription, RefreshResult result)
+ throws PortletInvokerException
+ {
+ // do we need to call initCookie or not?
+ requiresInitCookie = serviceDescription.getRequiresInitCookie();
+
+ // custom mode descriptions
+ customModes = toMap(serviceDescription.getCustomModeDescriptions());
+
+ // custom window state descriptions
+ customWindowStates = toMap(serviceDescription.getCustomWindowStateDescriptions());
+
+ // do we need to register?
+ if (serviceDescription.isRequiresRegistration())
+ {
+ // refresh and force check for extra props if the registered SD failed
+ // todo: deal with forcing check of extra registration properties properly (if
needed)
+ RefreshResult registrationResult =
internalRefreshRegistration(serviceDescription, true, forceRefresh, false);
+ registry.updateProducerInfo(this);
+
+ // attempt to register and determine if the current service description can be
used to extract POPs
+ if (!registrationResult.hasIssues())
{
- // refresh and force check for extra props if the registered SD failed
- // todo: deal with forcing check of extra registration properties properly
(if needed)
- RefreshResult registrationResult =
internalRefreshRegistration(serviceDescription, true, forceRefresh, false);
- registry.updateProducerInfo(this);
-
- // attempt to register and determine if the current service description can
be used to extract POPs
+ registrationResult = register(serviceDescription, false);
if (!registrationResult.hasIssues())
{
- registrationResult = register(serviceDescription, false);
- if (!registrationResult.hasIssues())
- {
- // registration occurred, so we should ask for a new service
description
- serviceDescription = getServiceDescription(false);
- }
-
- // extract the POPs
- extractOfferedPortlets(serviceDescription);
+ // registration occurred, so we should ask for a new service description
+ serviceDescription = getServiceDescription(false);
}
- result.setRegistrationResult(registrationResult);
-
- return result;
- }
- else
- {
- log.debug("Registration not required");
- persistentRegistrationInfo = new RegistrationInfo(this, false);
+ // extract the POPs
extractOfferedPortlets(serviceDescription);
- return result;
}
+
+ result.setRegistrationResult(registrationResult);
+
+ return result;
}
-
- return new RefreshResult(RefreshResult.Status.BYPASSED);
+ else
+ {
+ log.debug("Registration not required");
+ persistentRegistrationInfo = new RegistrationInfo(this, false);
+ extractOfferedPortlets(serviceDescription);
+ return result;
+ }
}
private Map<String, ItemDescription> toMap(ItemDescription[] itemDescriptions)
@@ -652,7 +682,7 @@
this.persistentExpirationCacheSeconds = expirationCacheSeconds;
}
- private ServiceDescription getUnmanagedServiceDescription(boolean asUnregistered)
throws PortletInvokerException, OperationFailedFault
+ private ServiceDescription getUnmanagedServiceDescription(boolean asUnregistered)
throws PortletInvokerException, OperationFailedFault, InvalidRegistrationFault
{
GetServiceDescription request = getServiceDescriptionRequest(asUnregistered);
@@ -681,6 +711,8 @@
if (e instanceof InvalidRegistrationFault)
{
resetRegistration();
+
+ throw (InvalidRegistrationFault)e;
}
else if (e instanceof OperationFailedFault)
{
@@ -701,6 +733,10 @@
{
return rethrowAsInvokerUnvailable(operationFailedFault);
}
+ catch (InvalidRegistrationFault invalidRegistrationFault)
+ {
+ return rethrowAsInvokerUnvailable(invalidRegistrationFault);
+ }
}
private ServiceDescription rethrowAsInvokerUnvailable(Exception e) throws
InvokerUnavailableException
@@ -744,7 +780,8 @@
persistentRegistrationInfo.resetRegistration();
}
- refresh(true);
+ invalidateCache();
+ registry.updateProducerInfo(this);
}
// make package only after package reorg
@@ -876,10 +913,7 @@
try
{
persistentEndpointInfo.getRegistrationService().deregister(getRegistrationContext());
- persistentRegistrationInfo.resetRegistration();
log.info("Consumer with id '" + persistentId + "'
deregistered.");
-
- invalidateCache();
}
catch (Exception e)
{
@@ -887,7 +921,7 @@
}
finally
{
- registry.updateProducerInfo(this);
+ resetRegistration();
}
}
else
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RefreshResult.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RefreshResult.java 2008-07-14
20:44:27 UTC (rev 11443)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RefreshResult.java 2008-07-14
20:52:19 UTC (rev 11444)
@@ -42,9 +42,10 @@
private Status status;
private RefreshResult registrationResult;
+ /** A RefreshResult is assumed successful unless proven otherwise. Same as
RefreshResult(SUCCESS). */
public RefreshResult()
{
- status = UNKNOWN;
+ this(SUCCESS);
}
public RefreshResult(Status status)
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2008-07-14
20:44:27 UTC (rev 11443)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2008-07-14
20:52:19 UTC (rev 11444)
@@ -396,6 +396,7 @@
persistentRegistrationProperties = getOrCreateRegistrationPropertiesMap(true);
RegistrationRefreshResult result = new RegistrationRefreshResult();
+ result.setServiceDescription(serviceDescription);
// if we're not merging, we need to copy the current properties so that we
can collect validation results.
if (!mergeWithLocalInfo)
@@ -490,8 +491,9 @@
else
{
RegistrationRefreshResult result = new RegistrationRefreshResult();
- result.setStatus(RefreshResult.Status.SUCCESS);
+ result.setStatus(RefreshResult.Status.BYPASSED);
result.setRegistrationProperties(persistentRegistrationProperties);
+ result.setServiceDescription(serviceDescription);
return result;
}
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2008-07-14
20:44:27 UTC (rev 11443)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2008-07-14
20:52:19 UTC (rev 11444)
@@ -204,7 +204,7 @@
}
ClonePortlet clonePortlet =
WSRPTypeFactory.createClonePortlet(getRegistrationContext(),
- WSRPUtils.convertToWSRPPortletContext(portletContext),
UserAccess.getUserContext());
+ WSRPUtils.convertToWSRPPortletContext(portletContext),
UserAccess.getUserContext());
try
{
return
WSRPUtils.convertToPortalPortletContext(getPortletManagementService().clonePortlet(clonePortlet));
@@ -235,7 +235,7 @@
log.debug("Attempting to destroy clones: " + handles);
DestroyPortlets destroyPortlets =
WSRPTypeFactory.createDestroyPortlets(getRegistrationContext(),
- handles.toArray(new String[handles.size()]));
+ handles.toArray(new String[handles.size()]));
try
{
@@ -286,7 +286,7 @@
ParameterValidation.throwIllegalArgExceptionIfNull(portletContext,
"PortletContext");
GetPortletProperties getPortletProperties =
WSRPTypeFactory.createGetPortletProperties(getRegistrationContext(),
- WSRPUtils.convertToWSRPPortletContext(portletContext));
+ WSRPUtils.convertToWSRPPortletContext(portletContext));
getPortletProperties.setNames(keys);
try
@@ -328,7 +328,7 @@
}
public PortletContext setProperties(PortletContext portletContext, PropertyChange[]
changes) throws IllegalArgumentException,
- PortletInvokerException, UnsupportedOperationException
+ PortletInvokerException, UnsupportedOperationException
{
ParameterValidation.throwIllegalArgExceptionIfNull(portletContext,
"PortletContext");
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(changes, "Property
changes");
@@ -337,7 +337,7 @@
if (portlet == null)
{
throw new PortletInvokerException("Cannot set properties on portlet
'" + portletContext.getId()
- + "' because there is no such portlet.");
+ + "' because there is no such portlet.");
}
PropertyList propertyList = WSRPTypeFactory.createPropertyList();
@@ -356,7 +356,7 @@
case PropertyChange.PREF_UPDATE:
// todo: deal with language more appropriately
updates.add(WSRPTypeFactory.createProperty(change.getKey(),
- WSRPUtils.toString(Locale.getDefault()),
change.getValue().asString()));
+ WSRPUtils.toString(Locale.getDefault()),
change.getValue().asString()));
break;
default:
@@ -366,7 +366,7 @@
propertyList.setProperties(updates.toArray(new Property[updates.size()]));
propertyList.setResetProperties(resets.toArray(new ResetProperty[resets.size()]));
SetPortletProperties setPortletProperties =
- WSRPTypeFactory.createSetPortletProperties(getRegistrationContext(),
WSRPUtils.convertToWSRPPortletContext(portletContext), propertyList);
+ WSRPTypeFactory.createSetPortletProperties(getRegistrationContext(),
WSRPUtils.convertToWSRPPortletContext(portletContext), propertyList);
try
{
@@ -441,6 +441,7 @@
{
// reset registration data and try again
producerInfo.resetRegistration();
+ producerInfo.refresh(true);
}
RegistrationContext getRegistrationContext() throws PortletInvokerException
@@ -638,7 +639,7 @@
WSRPPortletInfo info = getPortletInfo(invocation);
if (info != null && info.isDoesUrlTemplateProcessing()
- && (!info.isTemplatesStoredInSession() || runtimeContext.getSessionID()
== null))
+ && (!info.isTemplatesStoredInSession() ||
runtimeContext.getSessionID() == null))
{
// we need to supply the templates since the portlet does URL processing and
either doesn't store
// templates in the session or no session has been established yet