Author: chris.laprun(a)jboss.com
Date: 2010-06-14 06:01:10 -0400 (Mon, 14 Jun 2010)
New Revision: 3322
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V1ToV2Converter.java
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2ToV1Converter.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1/V1RegistrationService.java
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/RegistrationEndpoint.java
Log:
- Implemented registration interface for WSRP 1. WSRP 1 re-implementation in terms of WSRP
2 interfaces should now be complete. TESTING REQUIRED!
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V1ToV2Converter.java
===================================================================
---
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V1ToV2Converter.java 2010-06-14
09:44:35 UTC (rev 3321)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V1ToV2Converter.java 2010-06-14
10:01:10 UTC (rev 3322)
@@ -54,6 +54,7 @@
import org.oasis.wsrp.v1.V1PropertyDescription;
import org.oasis.wsrp.v1.V1PropertyList;
import org.oasis.wsrp.v1.V1RegistrationContext;
+import org.oasis.wsrp.v1.V1RegistrationData;
import org.oasis.wsrp.v1.V1ResetProperty;
import org.oasis.wsrp.v1.V1Resource;
import org.oasis.wsrp.v1.V1ResourceList;
@@ -89,6 +90,7 @@
import org.oasis.wsrp.v2.PropertyDescription;
import org.oasis.wsrp.v2.PropertyList;
import org.oasis.wsrp.v2.RegistrationContext;
+import org.oasis.wsrp.v2.RegistrationData;
import org.oasis.wsrp.v2.ResetProperty;
import org.oasis.wsrp.v2.Resource;
import org.oasis.wsrp.v2.ResourceList;
@@ -687,6 +689,47 @@
}
}
+ public static RegistrationData toV2RegistrationData(V1RegistrationData
registrationData)
+ {
+ if (registrationData != null)
+ {
+ RegistrationData result =
WSRPTypeFactory.createRegistrationData(registrationData.getConsumerName(),
registrationData.isMethodGetSupported());
+ result.setConsumerAgent(registrationData.getConsumerAgent());
+
+ List<Property> properties =
WSRPUtils.transform(registrationData.getRegistrationProperties(), PROPERTY);
+ if (properties != null)
+ {
+ result.getRegistrationProperties().addAll(properties);
+ }
+ List<String> modes = registrationData.getConsumerModes();
+ if (ParameterValidation.existsAndIsNotEmpty(modes))
+ {
+ result.getConsumerModes().addAll(modes);
+ }
+ List<String> consumerUserScopes =
registrationData.getConsumerUserScopes();
+ if (ParameterValidation.existsAndIsNotEmpty(consumerUserScopes))
+ {
+ result.getConsumerUserScopes().addAll(consumerUserScopes);
+ }
+ List<String> windowStates = registrationData.getConsumerWindowStates();
+ if (ParameterValidation.existsAndIsNotEmpty(windowStates))
+ {
+ result.getConsumerWindowStates().addAll(windowStates);
+ }
+ List<Extension> extensions =
WSRPUtils.transform(registrationData.getExtensions(), EXTENSION);
+ if (extensions != null)
+ {
+ result.getExtensions().addAll(extensions);
+ }
+
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
public static class V1ToV2Extension implements Function<V1Extension, Extension>
{
public Extension apply(V1Extension from)
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2ToV1Converter.java
===================================================================
---
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2ToV1Converter.java 2010-06-14
09:44:35 UTC (rev 3321)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2ToV1Converter.java 2010-06-14
10:01:10 UTC (rev 3322)
@@ -52,6 +52,7 @@
import org.oasis.wsrp.v1.V1PropertyDescription;
import org.oasis.wsrp.v1.V1PropertyList;
import org.oasis.wsrp.v1.V1RegistrationContext;
+import org.oasis.wsrp.v1.V1RegistrationData;
import org.oasis.wsrp.v1.V1ResetProperty;
import org.oasis.wsrp.v1.V1Resource;
import org.oasis.wsrp.v1.V1ResourceList;
@@ -91,6 +92,7 @@
import org.oasis.wsrp.v2.PropertyDescription;
import org.oasis.wsrp.v2.PropertyList;
import org.oasis.wsrp.v2.RegistrationContext;
+import org.oasis.wsrp.v2.RegistrationData;
import org.oasis.wsrp.v2.ResetProperty;
import org.oasis.wsrp.v2.Resource;
import org.oasis.wsrp.v2.ResourceList;
@@ -787,6 +789,47 @@
}
}
+ public static V1RegistrationData toV1RegistrationData(RegistrationData
registrationData)
+ {
+ if (registrationData != null)
+ {
+ V1RegistrationData result =
WSRP1TypeFactory.createRegistrationData(registrationData.getConsumerName(),
registrationData.isMethodGetSupported());
+ result.setConsumerAgent(registrationData.getConsumerAgent());
+
+ List<V1Property> properties =
WSRPUtils.transform(registrationData.getRegistrationProperties(), PROPERTY);
+ if (properties != null)
+ {
+ result.getRegistrationProperties().addAll(properties);
+ }
+ List<String> modes = registrationData.getConsumerModes();
+ if (ParameterValidation.existsAndIsNotEmpty(modes))
+ {
+ result.getConsumerModes().addAll(modes);
+ }
+ List<String> consumerUserScopes =
registrationData.getConsumerUserScopes();
+ if (ParameterValidation.existsAndIsNotEmpty(consumerUserScopes))
+ {
+ result.getConsumerUserScopes().addAll(consumerUserScopes);
+ }
+ List<String> windowStates = registrationData.getConsumerWindowStates();
+ if (ParameterValidation.existsAndIsNotEmpty(windowStates))
+ {
+ result.getConsumerWindowStates().addAll(windowStates);
+ }
+ List<V1Extension> extensions =
WSRPUtils.transform(registrationData.getExtensions(), EXTENSION);
+ if (extensions != null)
+ {
+ result.getExtensions().addAll(extensions);
+ }
+
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
private static class V2ToV1Extension implements Function<Extension,
V1Extension>
{
public V1Extension apply(Extension from)
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1/V1RegistrationService.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1/V1RegistrationService.java 2010-06-14
09:44:35 UTC (rev 3321)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/services/v1/V1RegistrationService.java 2010-06-14
10:01:10 UTC (rev 3322)
@@ -1,29 +1,37 @@
/*
-* JBoss, a division of Red Hat
-* Copyright 2008, 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.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
package org.gatein.wsrp.services.v1;
-import org.gatein.common.NotYetImplemented;
+import org.gatein.wsrp.WSRPExceptionFactory;
+import org.gatein.wsrp.WSRPUtils;
import org.gatein.wsrp.services.RegistrationService;
+import org.gatein.wsrp.spec.v1.V1ToV2Converter;
+import org.gatein.wsrp.spec.v1.V2ToV1Converter;
+import org.oasis.wsrp.v1.V1Extension;
+import org.oasis.wsrp.v1.V1InvalidRegistration;
+import org.oasis.wsrp.v1.V1MissingParameters;
+import org.oasis.wsrp.v1.V1OperationFailed;
import org.oasis.wsrp.v1.WSRPV1RegistrationPortType;
import org.oasis.wsrp.v2.AccessDenied;
import org.oasis.wsrp.v2.Extension;
@@ -58,30 +66,96 @@
@Override
public void register(RegistrationData registrationData, Lifetime lifetime, UserContext
userContext, Holder<byte[]> registrationState, Holder<Lifetime>
scheduledDestruction, Holder<List<Extension>> extensions, Holder<String>
registrationHandle) throws MissingParameters, OperationFailed, OperationNotSupported
{
- throw new NotYetImplemented();
+ try
+ {
+ Holder<List<V1Extension>> v1Extensions = new
Holder<List<V1Extension>>();
+
+ service.register(
+ registrationData.getConsumerName(),
+ registrationData.getConsumerAgent(),
+ registrationData.isMethodGetSupported(),
+ registrationData.getConsumerModes(),
+ registrationData.getConsumerWindowStates(),
+ registrationData.getConsumerUserScopes(),
+ null,
+ WSRPUtils.transform(registrationData.getRegistrationProperties(),
V2ToV1Converter.PROPERTY),
+ new Holder<List<V1Extension>>(),
+ registrationHandle,
+ registrationState
+ );
+
+ extensions.value = WSRPUtils.transform(v1Extensions.value,
V1ToV2Converter.EXTENSION);
+ }
+ catch (V1MissingParameters v1MissingParameters)
+ {
+ WSRPExceptionFactory.throwWSException(MissingParameters.class,
v1MissingParameters.getMessage(), v1MissingParameters);
+ }
+ catch (V1OperationFailed v1OperationFailed)
+ {
+ WSRPExceptionFactory.throwWSException(OperationFailed.class,
v1OperationFailed.getMessage(), v1OperationFailed);
+ }
}
@Override
public List<Extension> deregister(RegistrationContext registrationContext,
UserContext userContext) throws InvalidRegistration, OperationFailed,
OperationNotSupported, ResourceSuspended
{
- throw new NotYetImplemented();
+ try
+ {
+ Holder<List<V1Extension>> v1Extensions = new
Holder<List<V1Extension>>();
+
+ service.deregister(registrationContext.getRegistrationHandle(),
+ registrationContext.getRegistrationState(),
+ v1Extensions);
+
+ return WSRPUtils.transform(v1Extensions.value, V1ToV2Converter.EXTENSION);
+ }
+ catch (V1InvalidRegistration v1InvalidRegistration)
+ {
+ throw WSRPExceptionFactory.createWSException(InvalidRegistration.class,
v1InvalidRegistration.getMessage(), v1InvalidRegistration);
+ }
+ catch (V1OperationFailed v1OperationFailed)
+ {
+ throw WSRPExceptionFactory.createWSException(OperationFailed.class,
v1OperationFailed.getMessage(), v1OperationFailed);
+ }
}
@Override
public void modifyRegistration(RegistrationContext registrationContext,
RegistrationData registrationData, UserContext userContext, Holder<byte[]>
registrationState, Holder<Lifetime> scheduledDestruction,
Holder<List<Extension>> extensions) throws InvalidRegistration,
MissingParameters, OperationFailed, OperationNotSupported, ResourceSuspended
{
- throw new NotYetImplemented();
+ try
+ {
+ Holder<List<V1Extension>> v1Extensions = new
Holder<List<V1Extension>>();
+
+
service.modifyRegistration(V2ToV1Converter.toV1RegistrationContext(registrationContext),
+ V2ToV1Converter.toV1RegistrationData(registrationData),
+ registrationState,
+ v1Extensions);
+
+ extensions.value = WSRPUtils.transform(v1Extensions.value,
V1ToV2Converter.EXTENSION);
+ }
+ catch (V1InvalidRegistration v1InvalidRegistration)
+ {
+ WSRPExceptionFactory.throwWSException(InvalidRegistration.class,
v1InvalidRegistration.getMessage(), v1InvalidRegistration);
+ }
+ catch (V1MissingParameters v1MissingParameters)
+ {
+ WSRPExceptionFactory.throwWSException(MissingParameters.class,
v1MissingParameters.getMessage(), v1MissingParameters);
+ }
+ catch (V1OperationFailed v1OperationFailed)
+ {
+ WSRPExceptionFactory.throwWSException(OperationFailed.class,
v1OperationFailed.getMessage(), v1OperationFailed);
+ }
}
@Override
public Lifetime getRegistrationLifetime(GetRegistrationLifetime
getRegistrationLifetime) throws AccessDenied, InvalidHandle, InvalidRegistration,
ModifyRegistrationRequired, OperationFailed, OperationNotSupported, ResourceSuspended
{
- throw new NotYetImplemented();
+ throw WSRPExceptionFactory.createWSException(OperationNotSupported.class,
"getRegistrationLifetime is not supported in WSRP 1", null);
}
@Override
public Lifetime setRegistrationLifetime(SetRegistrationLifetime
setRegistrationLifetime) throws AccessDenied, InvalidHandle, InvalidRegistration,
ModifyRegistrationRequired, OperationFailed, OperationNotSupported, ResourceSuspended
{
- throw new NotYetImplemented();
+ throw WSRPExceptionFactory.createWSException(OperationNotSupported.class,
"setRegistrationLifetime is not supported in WSRP 1", null);
}
}
Modified:
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/RegistrationEndpoint.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/RegistrationEndpoint.java 2010-06-14
09:44:35 UTC (rev 3321)
+++
components/wsrp/trunk/wsrp-producer-war/src/main/java/org/gatein/wsrp/endpoints/v1/RegistrationEndpoint.java 2010-06-14
10:01:10 UTC (rev 3322)
@@ -23,19 +23,25 @@
package org.gatein.wsrp.endpoints.v1;
-import org.gatein.common.NotYetImplemented;
+import org.gatein.common.util.ParameterValidation;
+import org.gatein.wsrp.WSRPTypeFactory;
+import org.gatein.wsrp.WSRPUtils;
import org.gatein.wsrp.endpoints.WSRPBaseEndpoint;
+import org.gatein.wsrp.spec.v1.V1ToV2Converter;
+import org.gatein.wsrp.spec.v1.V2ToV1Converter;
+import org.gatein.wsrp.spec.v1.WSRP1ExceptionFactory;
import org.oasis.wsrp.v1.V1Extension;
import org.oasis.wsrp.v1.V1InvalidRegistration;
import org.oasis.wsrp.v1.V1MissingParameters;
-import org.oasis.wsrp.v1.V1ModifyRegistration;
import org.oasis.wsrp.v1.V1OperationFailed;
import org.oasis.wsrp.v1.V1Property;
import org.oasis.wsrp.v1.V1RegistrationContext;
import org.oasis.wsrp.v1.V1RegistrationData;
-import org.oasis.wsrp.v1.V1RegistrationState;
import org.oasis.wsrp.v1.WSRPV1RegistrationPortType;
+import org.oasis.wsrp.v2.InvalidRegistration;
+import org.oasis.wsrp.v2.MissingParameters;
import org.oasis.wsrp.v2.ModifyRegistration;
+import org.oasis.wsrp.v2.OperationFailed;
import org.oasis.wsrp.v2.RegistrationContext;
import org.oasis.wsrp.v2.RegistrationData;
import org.oasis.wsrp.v2.RegistrationState;
@@ -76,23 +82,45 @@
@WebParam(mode = WebParam.Mode.OUT, name = "registrationState",
targetNamespace = "urn:oasis:names:tc:wsrp:v1:types") Holder<byte[]>
registrationState)
throws V1MissingParameters, V1OperationFailed
{
- /*RegistrationData registrationData = new RegistrationData();
- registrationData.setConsumerName(consumerName);
- registrationData.setConsumerAgent(consumerAgent);
- registrationData.getConsumerModes().addAll(consumerModes);
- registrationData.getConsumerWindowStates().addAll(consumerWindowStates);
- registrationData.getConsumerUserScopes().addAll(consumerUserScopes);
+ try
+ {
+ RegistrationData registrationData =
WSRPTypeFactory.createRegistrationData(consumerName, methodGetSupported);
+ registrationData.setConsumerAgent(consumerAgent);
+ if (ParameterValidation.existsAndIsNotEmpty(consumerModes))
+ {
+ registrationData.getConsumerModes().addAll(consumerModes);
+ }
+ if (ParameterValidation.existsAndIsNotEmpty(consumerWindowStates))
+ {
+ registrationData.getConsumerWindowStates().addAll(consumerWindowStates);
+ }
+ if (ParameterValidation.existsAndIsNotEmpty(consumerUserScopes))
+ {
+ registrationData.getConsumerUserScopes().addAll(consumerUserScopes);
+ }
// registrationData.getCustomUserProfileData().addAll(customUserProfileData);
- registrationData.getRegistrationProperties().addAll(registrationProperties);
- registrationData.getExtensions().addAll(extensions.value);
+ if (ParameterValidation.existsAndIsNotEmpty(registrationProperties))
+ {
+
registrationData.getRegistrationProperties().addAll(WSRPUtils.transform(registrationProperties,
V1ToV2Converter.PROPERTY));
+ }
+ if (ParameterValidation.existsAndIsNotEmpty(extensions.value))
+ {
+ registrationData.getExtensions().addAll(WSRPUtils.transform(extensions.value,
V1ToV2Converter.EXTENSION));
+ }
- RegistrationContext registrationContext = producer.register(registrationData);
-
- registrationHandle.value = registrationContext.getRegistrationHandle();
- registrationState.value = registrationContext.getRegistrationState();
- extensions.value = registrationContext.getExtensions();*/
-
- throw new NotYetImplemented();
+ RegistrationContext registrationContext = producer.register(registrationData);
+ registrationHandle.value = registrationContext.getRegistrationHandle();
+ registrationState.value = registrationContext.getRegistrationState();
+ extensions.value = WSRPUtils.transform(registrationContext.getExtensions(),
V2ToV1Converter.EXTENSION);
+ }
+ catch (MissingParameters missingParameters)
+ {
+ WSRP1ExceptionFactory.throwWSException(missingParameters.getClass(),
missingParameters.getMessage(), missingParameters);
+ }
+ catch (OperationFailed operationFailed)
+ {
+ WSRP1ExceptionFactory.throwWSException(operationFailed.getClass(),
operationFailed.getMessage(), operationFailed);
+ }
}
public void deregister(
@@ -101,13 +129,20 @@
@WebParam(name = "extensions", targetNamespace =
"urn:oasis:names:tc:wsrp:v1:types", mode = WebParam.Mode.INOUT)
Holder<List<V1Extension>> extensions
) throws V1InvalidRegistration, V1OperationFailed
{
- /*RegistrationContext rc = new RegistrationContext();
- rc.setRegistrationHandle(registrationHandle);
- rc.setRegistrationState(registrationState);
-
- producer.deregister(rc);*/
-
- throw new NotYetImplemented();
+ try
+ {
+ RegistrationContext rc =
WSRPTypeFactory.createRegistrationContext(registrationHandle);
+ rc.setRegistrationState(registrationState);
+ producer.deregister(rc);
+ }
+ catch (InvalidRegistration invalidRegistration)
+ {
+ WSRP1ExceptionFactory.throwWSException(invalidRegistration.getClass(),
invalidRegistration.getMessage(), invalidRegistration);
+ }
+ catch (OperationFailed operationFailed)
+ {
+ WSRP1ExceptionFactory.throwWSException(operationFailed.getClass(),
operationFailed.getMessage(), operationFailed);
+ }
}
public void modifyRegistration(
@@ -117,19 +152,33 @@
@WebParam(mode = WebParam.Mode.OUT, name = "extensions", targetNamespace
= "urn:oasis:names:tc:wsrp:v1:types") Holder<List<V1Extension>>
extensions)
throws V1MissingParameters, V1InvalidRegistration, V1OperationFailed
{
- /*ModifyRegistration modifyRegistration = new ModifyRegistration();
- modifyRegistration.setRegistrationContext(registrationContext);
- modifyRegistration.setRegistrationData(registrationData);
- RegistrationState result = producer.modifyRegistration(modifyRegistration);
+ try
+ {
+ ModifyRegistration modifyRegistration =
WSRPTypeFactory.createModifyRegistration(
+ V1ToV2Converter.toV2RegistrationContext(registrationContext),
+ V1ToV2Converter.toV2RegistrationData(registrationData));
- // it is possible (if not likely) that result of modifyRegistration be null
- if (result != null)
+ RegistrationState result = producer.modifyRegistration(modifyRegistration);
+
+ // it is possible (if not likely) that result of modifyRegistration be null
+ if (result != null)
+ {
+ registrationState.value = result.getRegistrationState();
+ extensions.value = WSRPUtils.transform(result.getExtensions(),
V2ToV1Converter.EXTENSION);
+ }
+ }
+ catch (MissingParameters missingParameters)
{
- registrationState.value = result.getRegistrationState();
- extensions.value = result.getExtensions();
- }*/
-
- throw new NotYetImplemented();
+ WSRP1ExceptionFactory.throwWSException(missingParameters.getClass(),
missingParameters.getMessage(), missingParameters);
+ }
+ catch (InvalidRegistration invalidRegistration)
+ {
+ WSRP1ExceptionFactory.throwWSException(invalidRegistration.getClass(),
invalidRegistration.getMessage(), invalidRegistration);
+ }
+ catch (OperationFailed operationFailed)
+ {
+ WSRP1ExceptionFactory.throwWSException(operationFailed.getClass(),
operationFailed.getMessage(), operationFailed);
+ }
}
}