Author: chris.laprun(a)jboss.com
Date: 2008-07-22 19:36:14 -0400 (Tue, 22 Jul 2008)
New Revision: 11547
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/NeedPortletHandleTest.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/PortletManagementTestCase.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ServiceDescriptionTestCase.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
Log:
- JBPORTAL-2068:
+ Should now properly throw InvalidRegistrationFault when registration is required and
none is provided.
+ Note that this doesn't affect getServiceDescription.
+ Added test cases.
- Found an issue with V1ProducerBaseTest.configureRegistrationSettings which was not
configuring registration settings properly.
This resulted in incorrect tests and not properly handling the case where registration
was required to access the full service
description.
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2008-07-22
18:02:07 UTC (rev 11546)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2008-07-22
23:36:14 UTC (rev 11547)
@@ -32,6 +32,7 @@
import org.jboss.portal.wsrp.core.BlockingInteractionResponse;
import org.jboss.portal.wsrp.core.CacheControl;
import org.jboss.portal.wsrp.core.GetMarkup;
+import org.jboss.portal.wsrp.core.InitCookie;
import org.jboss.portal.wsrp.core.InteractionParams;
import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
import org.jboss.portal.wsrp.core.MarkupContext;
@@ -621,6 +622,66 @@
}
}
+ public void testGetMarkupNoRegistrationWhenRegistrationRequired() throws Exception
+ {
+ configureRegistrationSettings(true, false);
+
+ GetMarkup gm = createMarkupRequest();
+ try
+ {
+ markupService.getMarkup(gm);
+ ExtendedAssert.fail("Should have thrown InvalidRegistrationFault!");
+ }
+ catch (InvalidRegistrationFault invalidRegistrationFault)
+ {
+ // expected
+ }
+ catch (Exception e)
+ {
+ ExtendedAssert.fail(e.getMessage());
+ }
+ }
+
+ public void testPerformBlockingInteractionNoRegistrationWhenRegistrationRequired()
throws Exception
+ {
+ configureRegistrationSettings(true, false);
+
+ PerformBlockingInteraction pbi =
WSRPTypeFactory.createDefaultPerformBlockingInteraction(getHandleForCurrentlyDeployedArchive());
+ try
+ {
+ markupService.performBlockingInteraction(pbi);
+ ExtendedAssert.fail("Should have thrown InvalidRegistrationFault!");
+ }
+ catch (InvalidRegistrationFault invalidRegistrationFault)
+ {
+ // expected
+ }
+ catch (Exception e)
+ {
+ ExtendedAssert.fail(e.getMessage());
+ }
+ }
+
+ public void testInitCookieNoRegistrationWhenRegistrationRequired() throws Exception
+ {
+ configureRegistrationSettings(true, false);
+
+ InitCookie initCookie = WSRPTypeFactory.createInitCookie(null);
+ try
+ {
+ markupService.initCookie(initCookie);
+ ExtendedAssert.fail("Should have thrown InvalidRegistrationFault!");
+ }
+ catch (InvalidRegistrationFault invalidRegistrationFault)
+ {
+ // expected
+ }
+ catch (Exception e)
+ {
+ ExtendedAssert.fail(e.getMessage());
+ }
+ }
+
private String checkPBIAndGetNavigationalState(String symbol) throws Exception
{
PerformBlockingInteraction performBlockingInteraction =
@@ -691,4 +752,4 @@
{
return DEFAULT_MARKUP_PORTLET_WAR;
}
-}
\ No newline at end of file
+}
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/NeedPortletHandleTest.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/NeedPortletHandleTest.java 2008-07-22
18:02:07 UTC (rev 11546)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/NeedPortletHandleTest.java 2008-07-22
23:36:14 UTC (rev 11547)
@@ -56,20 +56,20 @@
public NeedPortletHandleTest(String portletWARFileName)
- throws Exception
+ throws Exception
{
this("NeedPortletHandleTest", portletWARFileName);
this.mostUsedPortletWARFileName = portletWARFileName;
}
protected NeedPortletHandleTest(String name, String portletWARFileName)
- throws Exception
+ throws Exception
{
super(name);
this.mostUsedPortletWARFileName = portletWARFileName;
}
- protected String getDefaultHandle() throws RemoteException, InvalidRegistrationFault,
OperationFailedFault
+ protected String getDefaultHandle()
{
return getFirstHandleFor(mostUsedPortletWARFileName);
}
@@ -84,7 +84,7 @@
return war2Handles.get(archiveName).get(0);
}
- protected String getHandleForCurrentlyDeployedArchive() throws RemoteException,
InvalidRegistrationFault, OperationFailedFault
+ protected String getHandleForCurrentlyDeployedArchive()
{
return getFirstHandleFor(currentlyDeployedArchiveName);
}
@@ -234,7 +234,7 @@
}
protected void checkSessionForCurrentlyDeployedPortlet(MarkupResponse response)
- throws RemoteException, InvalidRegistrationFault, OperationFailedFault
+ throws RemoteException, InvalidRegistrationFault, OperationFailedFault
{
// We don't send any portlet session information, just user cookies... The
producer takes care of the details
// What this means, though is that we don't have access to individual portlet
session ids... so we can only
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/PortletManagementTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/PortletManagementTestCase.java 2008-07-22
18:02:07 UTC (rev 11546)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/PortletManagementTestCase.java 2008-07-22
23:36:14 UTC (rev 11547)
@@ -35,6 +35,7 @@
import org.jboss.portal.wsrp.core.GetPortletPropertyDescription;
import org.jboss.portal.wsrp.core.GetServiceDescription;
import org.jboss.portal.wsrp.core.InconsistentParametersFault;
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
import org.jboss.portal.wsrp.core.ModelDescription;
import org.jboss.portal.wsrp.core.PortletContext;
import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
@@ -56,8 +57,7 @@
{
private static final String TEST_BASIC_PORTLET_WAR =
"test-basic-portlet.war";
- public PortletManagementTestCase()
- throws Exception
+ public PortletManagementTestCase() throws Exception
{
super("PortletManagementTestCase", TEST_BASIC_PORTLET_WAR);
}
@@ -83,6 +83,28 @@
checkServiceDescriptionWithOnlyBasicPortlet(gs);
}
+ public void testClonePortletNoRegistrationWhenRequired()
+ {
+ producer.getProducerRegistrationRequirements().setRegistrationRequired(true);
+
+ String handle = getDefaultHandle();
+ ClonePortlet clonePortlet = WSRPTypeFactory.createSimpleClonePortlet(handle);
+
+ try
+ {
+ portletManagementService.clonePortlet(clonePortlet);
+ ExtendedAssert.fail("Should have thrown InvalidRegistrationFault");
+ }
+ catch (InvalidRegistrationFault invalidRegistrationFault)
+ {
+ // expected
+ }
+ catch (Exception e)
+ {
+ ExtendedAssert.fail(e.getMessage());
+ }
+ }
+
public void testDestroyPortlets() throws Exception
{
// first try to destroy POP, should fail
@@ -107,12 +129,26 @@
ExtendedAssert.assertNull(failures);
}
- private PortletContext clonePortlet(String handle)
- throws org.jboss.portal.wsrp.core.InvalidUserCategoryFault,
org.jboss.portal.wsrp.core.AccessDeniedFault,
org.jboss.portal.wsrp.core.OperationFailedFault,
org.jboss.portal.wsrp.core.InvalidHandleFault,
org.jboss.portal.wsrp.core.InvalidRegistrationFault,
org.jboss.portal.wsrp.core.InconsistentParametersFault,
org.jboss.portal.wsrp.core.MissingParametersFault, java.rmi.RemoteException
+ public void testDestroyPortletsNoRegistrationWhenRequired()
{
- ClonePortlet clonePortlet = WSRPTypeFactory.createSimpleClonePortlet(handle);
- PortletContext portletContext =
portletManagementService.clonePortlet(clonePortlet);
- return portletContext;
+ producer.getProducerRegistrationRequirements().setRegistrationRequired(true);
+
+ String handle = getDefaultHandle();
+ DestroyPortlets dp = WSRPTypeFactory.createDestroyPortlets(null, new
String[]{handle});
+
+ try
+ {
+ portletManagementService.destroyPortlets(dp);
+ ExtendedAssert.fail("Should have thrown InvalidRegistrationFault");
+ }
+ catch (InvalidRegistrationFault invalidRegistrationFault)
+ {
+ // expected
+ }
+ catch (Exception e)
+ {
+ ExtendedAssert.fail(e.getMessage());
+ }
}
public void testGetPortletDescription() throws Exception
@@ -126,6 +162,28 @@
checkBasicPortletDescription(response.getPortletDescription(), handle);
}
+ public void testGetPortletDescriptionNoRegistrationWhenRequired()
+ {
+ producer.getProducerRegistrationRequirements().setRegistrationRequired(true);
+
+ String handle = getDefaultHandle();
+ GetPortletDescription gpd = WSRPTypeFactory.createGetPortletDescription(null,
handle);
+
+ try
+ {
+ portletManagementService.getPortletDescription(gpd);
+ ExtendedAssert.fail("Should have thrown InvalidRegistrationFault");
+ }
+ catch (InvalidRegistrationFault invalidRegistrationFault)
+ {
+ // expected
+ }
+ catch (Exception e)
+ {
+ ExtendedAssert.fail(e.getMessage());
+ }
+ }
+
public void testGetPortletPropertiesNoRegistration() throws Exception
{
String handle = getDefaultHandle();
@@ -135,8 +193,8 @@
PropertyList response =
portletManagementService.getPortletProperties(getPortletProperties);
Property[] expected = new Property[]{
- WSRPTypeFactory.createProperty("prefName1", "en",
"prefValue1"),
- WSRPTypeFactory.createProperty("prefName2", "en",
"prefValue2")
+ WSRPTypeFactory.createProperty("prefName1", "en",
"prefValue1"),
+ WSRPTypeFactory.createProperty("prefName2", "en",
"prefValue2")
};
checkGetPropertiesResponse(response, expected);
@@ -173,6 +231,28 @@
checkPropertyDescriptions(expected, propertyDescriptions);
}
+ public void testGetPortletPropertiesNoRegistrationWhenRequired()
+ {
+ producer.getProducerRegistrationRequirements().setRegistrationRequired(true);
+
+ String handle = getDefaultHandle();
+ GetPortletPropertyDescription getPortletPropertyDescription =
WSRPTypeFactory.createSimpleGetPortletPropertyDescription(handle);
+
+ try
+ {
+
portletManagementService.getPortletPropertyDescription(getPortletPropertyDescription);
+ ExtendedAssert.fail("Should have thrown InvalidRegistrationFault");
+ }
+ catch (InvalidRegistrationFault invalidRegistrationFault)
+ {
+ // expected
+ }
+ catch (Exception e)
+ {
+ ExtendedAssert.fail(e.getMessage());
+ }
+ }
+
public void testSetPortletProperties() throws Exception
{
String handle = getDefaultHandle();
@@ -180,8 +260,8 @@
PortletContext portletContext = clonePortlet(handle);
PropertyList propertyList = WSRPTypeFactory.createPropertyList();
Property[] properties = new Property[]{
- WSRPTypeFactory.createProperty("prefName1", "en",
"newPrefValue1"),
- WSRPTypeFactory.createProperty("prefName2", "en",
"newPrefValue2")
+ WSRPTypeFactory.createProperty("prefName1", "en",
"newPrefValue1"),
+ WSRPTypeFactory.createProperty("prefName2", "en",
"newPrefValue2")
};
propertyList.setProperties(properties);
SetPortletProperties setPortletProperties =
WSRPTypeFactory.createSetPortletProperties(null, portletContext, propertyList);
@@ -203,6 +283,42 @@
}
}
+ public void testSetPortletPropertiesNoRegistrationWhenRequired()
+ {
+ producer.getProducerRegistrationRequirements().setRegistrationRequired(true);
+
+ PropertyList propertyList = WSRPTypeFactory.createPropertyList();
+ Property[] properties = new Property[]{
+ WSRPTypeFactory.createProperty("prefName1", "en",
"newPrefValue1"),
+ WSRPTypeFactory.createProperty("prefName2", "en",
"newPrefValue2")
+ };
+ propertyList.setProperties(properties);
+ SetPortletProperties setPortletProperties =
WSRPTypeFactory.createSetPortletProperties(null,
+ WSRPTypeFactory.createPortletContext(getDefaultHandle()), propertyList);
+
+ try
+ {
+ portletManagementService.setPortletProperties(setPortletProperties);
+ ExtendedAssert.fail("Should have thrown InvalidRegistrationFault");
+ }
+ catch (InvalidRegistrationFault invalidRegistrationFault)
+ {
+ // expected
+ }
+ catch (Exception e)
+ {
+ ExtendedAssert.fail(e.getMessage());
+ }
+ }
+
+ private PortletContext clonePortlet(String handle)
+ throws org.jboss.portal.wsrp.core.InvalidUserCategoryFault,
org.jboss.portal.wsrp.core.AccessDeniedFault,
org.jboss.portal.wsrp.core.OperationFailedFault,
org.jboss.portal.wsrp.core.InvalidHandleFault,
org.jboss.portal.wsrp.core.InvalidRegistrationFault,
org.jboss.portal.wsrp.core.InconsistentParametersFault,
org.jboss.portal.wsrp.core.MissingParametersFault, java.rmi.RemoteException
+ {
+ ClonePortlet clonePortlet = WSRPTypeFactory.createSimpleClonePortlet(handle);
+ PortletContext portletContext =
portletManagementService.clonePortlet(clonePortlet);
+ return portletContext;
+ }
+
private Property[] checkGetPropertiesResponse(PropertyList response, Property[]
expected)
{
ExtendedAssert.assertNotNull(response);
@@ -286,7 +402,7 @@
public String toString()
{
return new StringBuffer().append("Property:
").append(prop.getName()).append("=")
- .append(prop.getStringValue()).append("
(").append(prop.getLang()).append(")").toString();
+ .append(prop.getStringValue()).append("
(").append(prop.getLang()).append(")").toString();
}
}
}
\ No newline at end of file
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java 2008-07-22
18:02:07 UTC (rev 11546)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java 2008-07-22
23:36:14 UTC (rev 11547)
@@ -144,7 +144,7 @@
// now modify Producer's set of required registration info
String newPropName = "New Prop";
RegistrationPropertyDescription regProp = new
RegistrationPropertyDescription(newPropName,
- new QName("urn:oasis:names:tc:wsrp:v1:types",
"LocalizedString", "ns1"));
+ new QName("urn:oasis:names:tc:wsrp:v1:types",
"LocalizedString", "ns1"));
regProp.setDefaultLabel("New Registration Property");
producer.getProducerRegistrationRequirements().addRegistrationProperty(regProp);
@@ -184,7 +184,7 @@
// remove registration context, try again and check that we get new registration
info
gs.setRegistrationContext(null);
PropertyDescription[] pds = serviceDescriptionService.getServiceDescription(gs)
- .getRegistrationPropertyDescription().getPropertyDescriptions();
+ .getRegistrationPropertyDescription().getPropertyDescriptions();
ExtendedAssert.assertEquals(2, pds.length);
assertEquals(WSRPUtils.convertToPropertyDescription(regProp), pds[1]);
@@ -211,7 +211,7 @@
// now modify Producer's set of required registration info
String newPropName = "New Prop";
RegistrationPropertyDescription regProp = new
RegistrationPropertyDescription(newPropName,
- new QName("urn:oasis:names:tc:wsrp:v1:types",
"LocalizedString", "ns1"));
+ new QName("urn:oasis:names:tc:wsrp:v1:types",
"LocalizedString", "ns1"));
regProp.setDefaultLabel("New Registration Property");
producer.getProducerRegistrationRequirements().addRegistrationProperty(regProp);
@@ -286,4 +286,42 @@
// expected
}
}
+
+ public void testModifyRegistrationNoRegistrationWhenRegistrationRequired() throws
Exception
+ {
+ configureRegistrationSettings(true, false);
+
+ try
+ {
+ registrationService.modifyRegistration(null);
+ ExtendedAssert.fail("Shouldn't be possible to modify registration if no
registration is required.");
+ }
+ catch (OperationFailedFault operationFailedFault)
+ {
+ // expected
+ }
+ catch (Exception e)
+ {
+ ExtendedAssert.fail(e.getMessage());
+ }
+ }
+
+ public void testDeregisterNoRegistrationWhenRegistrationRequired() throws Exception
+ {
+ configureRegistrationSettings(true, false);
+
+ try
+ {
+ registrationService.deregister(null);
+ ExtendedAssert.fail("Shouldn't be possible to modify registration if no
registration is required.");
+ }
+ catch (OperationFailedFault operationFailedFault)
+ {
+ // expected
+ }
+ catch (Exception e)
+ {
+ ExtendedAssert.fail(e.getMessage());
+ }
+ }
}
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ServiceDescriptionTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ServiceDescriptionTestCase.java 2008-07-22
18:02:07 UTC (rev 11546)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ServiceDescriptionTestCase.java 2008-07-22
23:36:14 UTC (rev 11547)
@@ -47,13 +47,12 @@
*/
public class ServiceDescriptionTestCase extends V1ProducerBaseTest
{
- public ServiceDescriptionTestCase()
- throws Exception
+ public ServiceDescriptionTestCase() throws Exception
{
super("ServiceDescriptionTestCase");
}
- public void testGetServiceDescriptionNotRequiringRegistration() throws Throwable
+ public void testNotRequiringRegistration() throws Throwable
{
producer.getProducerRegistrationRequirements().setRegistrationRequired(false);
@@ -68,7 +67,7 @@
ExtendedAssert.assertNull(sd.getRegistrationPropertyDescription());
}
- public void testGetServiceDescriptionRequiringRegistrationNoOfferedPortlets() throws
Throwable
+ public void testRequiringRegistrationNotProvidingPortlets() throws Throwable
{
RegistrationPropertyDescription regProp = configureRegistrationSettings(true,
false);
@@ -87,8 +86,7 @@
ExtendedAssert.assertNull(sd.getOfferedPortlets());
}
-
- public void testGetServiceDescriptionRequiringRegistrationOfferedPortlets() throws
Throwable
+ public void testRequiringRegistrationProvidingPortlets() throws Throwable
{
RegistrationPropertyDescription regProp = configureRegistrationSettings(true,
true);
@@ -104,18 +102,8 @@
checkRequiredRegistrationProperties(sd, regProp);
}
- private void checkRequiredRegistrationProperties(ServiceDescription sd,
RegistrationPropertyDescription regProp)
+ public void testLiveDeployment() throws Throwable
{
- ModelDescription registrationPropertyDescription =
sd.getRegistrationPropertyDescription();
- ExtendedAssert.assertNotNull(registrationPropertyDescription);
- PropertyDescription[] propertyDescriptions =
registrationPropertyDescription.getPropertyDescriptions();
- ExtendedAssert.assertNotNull(propertyDescriptions);
- ExtendedAssert.assertEquals(1, propertyDescriptions.length);
- assertEquals(WSRPUtils.convertToPropertyDescription(regProp),
propertyDescriptions[0]);
- }
-
- public void testGetServiceDescriptionLiveDeployment() throws Throwable
- {
try
{
GetServiceDescription gsd = getNoRegistrationServiceDescriptionRequest();
@@ -150,4 +138,14 @@
undeploy("test-session-portlet.war");
}
}
+
+ private void checkRequiredRegistrationProperties(ServiceDescription sd,
RegistrationPropertyDescription regProp)
+ {
+ ModelDescription registrationPropertyDescription =
sd.getRegistrationPropertyDescription();
+ ExtendedAssert.assertNotNull(registrationPropertyDescription);
+ PropertyDescription[] propertyDescriptions =
registrationPropertyDescription.getPropertyDescriptions();
+ ExtendedAssert.assertNotNull(propertyDescriptions);
+ ExtendedAssert.assertEquals(1, propertyDescriptions.length);
+ assertEquals(WSRPUtils.convertToPropertyDescription(regProp),
propertyDescriptions[0]);
+ }
}
\ No newline at end of file
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java 2008-07-22
18:02:07 UTC (rev 11546)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java 2008-07-22
23:36:14 UTC (rev 11547)
@@ -89,8 +89,6 @@
public void tearDown() throws Exception
{
- producer.getProducerRegistrationRequirements().clearRegistrationProperties();
- producer.getRegistrationManager().clear();
resetRegistrationInfo();
super.tearDown();
}
@@ -128,7 +126,7 @@
{
deploy("test-basic-portlet.war");
//Invoke the Web Service
- ServiceDescription sd = serviceDescriptionService.getServiceDescription(gs);
+ ServiceDescription sd = serviceDescriptionService.getServiceDescription(gs);
ExtendedAssert.assertNotNull("sd != null", sd);
@@ -169,7 +167,7 @@
{
// define expected registration infos
producer.getProducerRegistrationRequirements().setRegistrationRequired(requiresRegistration);
-
producer.getProducerRegistrationRequirements().setRegistrationRequiredForFullDescription(provideUnregisteredFullDescription);
+
producer.getProducerRegistrationRequirements().setRegistrationRequiredForFullDescription(!provideUnregisteredFullDescription);
if (requiresRegistration)
{
@@ -207,12 +205,15 @@
}
}
- protected void resetRegistrationInfo()
+ protected void resetRegistrationInfo() throws RegistrationException
{
ProducerRegistrationRequirements registrationRequirements =
producer.getProducerRegistrationRequirements();
registrationRequirements.setRegistrationRequired(false);
registrationRequirements.clearRegistrationProperties();
registrationRequirements.clearRegistrationPropertyChangeListeners();
+ producer.getProducerRegistrationRequirements().clearRegistrationProperties();
+ producer.getRegistrationManager().clear();
+
producer.getProducerRegistrationRequirements().removeRegistrationPropertyChangeListener(producer.getRegistrationManager());
}
protected GetServiceDescription getNoRegistrationServiceDescriptionRequest()
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2008-07-22
18:02:07 UTC (rev 11546)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2008-07-22
23:36:14 UTC (rev 11547)
@@ -245,18 +245,21 @@
/**
* @param reg
- * @param throwExceptionIfExistsAndNotValid
- *
+ * @param throwExceptionIfInvalid
* @return
* @since 2.6.2
*/
- boolean isRegistrationValid(Registration reg, boolean
throwExceptionIfExistsAndNotValid)
+ boolean isRegistrationValid(Registration reg, boolean throwExceptionIfInvalid) throws
InvalidRegistrationFault
{
if (reg == null)
{
if (producer.getProducerRegistrationRequirements().isRegistrationRequired())
{
log.debug("Registration is required yet no RegistrationContext was
provided: registration invalid!");
+ if(throwExceptionIfInvalid)
+ {
+ throwInvalidRegistrationFault("registration is required yet no
RegistrationContext was provided!");
+ }
return false;
}
@@ -269,7 +272,7 @@
boolean isPending = RegistrationStatus.PENDING.equals(reg.getStatus());
log.debug("Registration required: registration is " + (isValid ?
"valid!" : (isPending ? "pending!" : "invalid!")));
- if (throwExceptionIfExistsAndNotValid)
+ if (throwExceptionIfInvalid)
{
if (isPending)
{
@@ -280,7 +283,7 @@
{
if (!isValid)
{
- throwInvalidRegistrationFault("Registration with handle
'" + reg.getRegistrationHandle() + "' is not valid!");
+ throwInvalidRegistrationFault("registration with handle
'" + reg.getRegistrationHandle() + "' is not valid!");
}
}
}
@@ -300,11 +303,14 @@
{
if (registrationContext == null)
{
- return null;
+ throwInvalidRegistrationFault("registration context is missing but
registration is required");
}
String regHandle = registrationContext.getRegistrationHandle();
- WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(regHandle,
"registration handle");
+ if (regHandle == null)
+ {
+ throwInvalidRegistrationFault("registration handle is missing but
registration is required");
+ }
try
{
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2008-07-22
18:02:07 UTC (rev 11546)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2008-07-22
23:36:14 UTC (rev 11547)
@@ -45,6 +45,7 @@
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.RegistrationContext;
import org.jboss.portal.wsrp.core.ServiceDescription;
import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
import org.jboss.portal.wsrp.producer.config.ProducerRegistrationRequirements;
@@ -74,52 +75,43 @@
}
public ServiceDescription getServiceDescription(GetServiceDescription gs)
- throws InvalidRegistrationFault, OperationFailedFault, RemoteException
+ throws InvalidRegistrationFault, OperationFailedFault, RemoteException
{
WSRPExceptionFactory.throwOperationFailedFaultIfValueIsMissing(gs,
"GetServiceDescription");
- Registration registration =
producer.getRegistrationFrom(gs.getRegistrationContext());
- boolean registrationValid = producer.isRegistrationValid(registration);
+ RegistrationContext registrationContext = gs.getRegistrationContext();
ProducerRegistrationRequirements requirements =
producer.getProducerRegistrationRequirements();
-
PortletDescription[] offeredPortlets = null;
ServiceDescription serviceDescription =
WSRPTypeFactory.createServiceDescription(requirements.isRegistrationRequired());
serviceDescription.setRequiresInitCookie(BEA_8_CONSUMER_FIX);
serviceDescription.setLocales(producer.getSupportedLocales());
- if (!requirements.isRegistrationRequired())
+ // if a RegistrationContext is provided, we need to validate the registration
information
+ Registration registration = null;
+ if (registrationContext != null)
{
- offeredPortlets = getPortletDescriptions(gs.getDesiredLocales(), null);
+ registration = producer.getRegistrationOrFailIfInvalid(registrationContext);
}
- else
- {
- if (!registrationValid)
- {
- log.debug("Unregistered consumer while registration is required. Sending
registration information.");
- if (requirements.isRegistrationRequiredForFullDescription())
- {
- log.debug("Sending offered portlets description despite not being
registered, per Producer configuration.");
- offeredPortlets = getPortletDescriptions(gs.getDesiredLocales(), null);
- }
+ // get the portlet descriptions based on registration information
+ offeredPortlets = getPortletDescriptions(gs.getDesiredLocales(), registration);
+ serviceDescription.setOfferedPortlets(offeredPortlets);
- // 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
+ // if we don't have registration information but a registration is required,
send registration props information
+ if (registration == null && requirements.isRegistrationRequired())
+ {
+ log.debug("Unregistered consumer while registration is required. Sending
registration information.");
+
+ // do not create a ModelDescription if there is no registration properties
+ Map info = requirements.getRegistrationProperties();
+ ModelDescription description = null;
+ if (info != null && !info.isEmpty())
{
- log.debug("Sending registered service description.");
- // should we be sending the registration properties description as well?
- offeredPortlets = getPortletDescriptions(gs.getDesiredLocales(),
registration);
+ description =
WSRPUtils.convertRegistrationPropertiesToModelDescription(info);
}
+
+ serviceDescription.setRegistrationPropertyDescription(description);
}
serviceDescription.setOfferedPortlets(offeredPortlets);
@@ -163,18 +155,25 @@
catch (PortletInvokerException e)
{
throw
WSRPExceptionFactory.throwSOAPFaultException(WSRPExceptionFactory.OPERATION_FAILED,
- "Could not retrieve portlet '" + portletContext +
"'", e);
+ "Could not retrieve portlet '" + portletContext +
"'", e);
}
}
/**
- * @param desiredLocales
- * @param registration here so that we can do filtering of portlets based on
registration data (not currently
- * implemented)
- * @return
+ * @param desiredLocales the locales in which the portlet descriptions must be
provided (best effort)
+ * @param registration used to filter offered portlet lists
+ * @return an array of portlet descriptions offered by this producer (which could be
filtered based on the
+ * registration information) or <code>null</code> if no
registration is provided and the producer requires
+ * registration to access the full service description.
*/
private PortletDescription[] getPortletDescriptions(String[] desiredLocales,
Registration registration)
{
+ ProducerRegistrationRequirements registrationReq =
producer.getProducerRegistrationRequirements();
+ if (registration == null && registrationReq.isRegistrationRequired()
&& registrationReq.isRegistrationRequiredForFullDescription())
+ {
+ return null;
+ }
+
Set<PortletDescription> descriptions =
getOfferedPortletDescriptions(desiredLocales);
return descriptions.toArray(new PortletDescription[descriptions.size()]);
}
@@ -201,11 +200,11 @@
{
MediaType mimeType = mediaTypes.next();
markupTypes[i] = new MarkupType(
- mimeType.getValue(),
- getModeNamesFrom(capInfo.getModes(mimeType)),
- getWindowStateNamesFrom(capInfo.getWindowStates(mimeType)),
- getLocaleNamesFrom(capInfo.getLocales(mimeType)),
- null);
+ mimeType.getValue(),
+ getModeNamesFrom(capInfo.getModes(mimeType)),
+ getWindowStateNamesFrom(capInfo.getWindowStates(mimeType)),
+ getLocaleNamesFrom(capInfo.getLocales(mimeType)),
+ null);
}
//todo generate a valid and better portlet handle
@@ -230,7 +229,7 @@
// keywords
// metaInfo contains comma-separated keywords: we need to extract them into an
array
org.jboss.portal.wsrp.core.LocalizedString concatenatedKeywords =
- WSRPUtils.convertToWSRPLocalizedString(metaInfo.getMetaValue(MetaInfo.KEYWORDS),
desiredLocales);
+
WSRPUtils.convertToWSRPLocalizedString(metaInfo.getMetaValue(MetaInfo.KEYWORDS),
desiredLocales);
if (concatenatedKeywords != null)
{
String commaSeparatedKeywords = concatenatedKeywords.getValue();
@@ -239,7 +238,7 @@
String lang = concatenatedKeywords.getLang();
String[] keywordArray = commaSeparatedKeywords.split(",");
org.jboss.portal.wsrp.core.LocalizedString[] keywords =
- new org.jboss.portal.wsrp.core.LocalizedString[keywordArray.length];
+ new org.jboss.portal.wsrp.core.LocalizedString[keywordArray.length];
for (int i = 0; i < keywordArray.length; i++)
{
keywords[i] = WSRPTypeFactory.createLocalizedString(lang, null,
keywordArray[i].trim()); // fix-me: resource name
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2008-07-22
18:02:07 UTC (rev 11546)
+++
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2008-07-22
23:36:14 UTC (rev 11547)
@@ -464,22 +464,20 @@
Registration getRegistrationOrFailIfInvalid(RegistrationContext registrationContext)
throws InvalidRegistrationFault, OperationFailedFault
{
Registration registration = getRegistrationFrom(registrationContext);
- if (!isRegistrationValid(registration))
- {
- registrationHandler.throwInvalidRegistrationFault("Invalid
registration");
- }
-
+ isRegistrationValid(registration, true);
+
return registration;
}
/**
* @param registration
+ * @param throwExceptionIfInvalid
* @return
* @since 2.6.2
*/
- boolean isRegistrationValid(Registration registration)
+ boolean isRegistrationValid(Registration registration, boolean
throwExceptionIfInvalid) throws InvalidRegistrationFault
{
- return registrationHandler.isRegistrationValid(registration, true);
+ return registrationHandler.isRegistrationValid(registration,
throwExceptionIfInvalid);
}
/**