Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2016-07-18 16:09:23 -0400
committerAngel Avila2016-10-04 21:34:47 -0400
commit9ce3c17a98857c8c15acef639963017b98a900f2 (patch)
treeb29cae3453b2a2cc5127d6598f302028919c5e16
parent51ab8a7ad99101482fa0d19ca21b8856eff8fb95 (diff)
downloadorg.eclipse.osee-9ce3c17a98857c8c15acef639963017b98a900f2.tar.gz
org.eclipse.osee-9ce3c17a98857c8c15acef639963017b98a900f2.tar.xz
org.eclipse.osee-9ce3c17a98857c8c15acef639963017b98a900f2.zip
refactor: Add OrcsParamConverterProvider
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientConfiguratorTest.java2
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientConfigurator.java3
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/IdParamConverter.java34
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/OrcsParamConverterProvider.java34
4 files changed, 70 insertions, 3 deletions
diff --git a/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientConfiguratorTest.java b/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientConfiguratorTest.java
index d1f4a74f052..16b0d0d35d2 100644
--- a/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientConfiguratorTest.java
+++ b/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientConfiguratorTest.java
@@ -236,7 +236,7 @@ public class CxfJaxRsClientConfiguratorTest {
assertEquals(JsonMappingExceptionMapper.class, iterator.next());
assertEquals(OAuthJSONProvider.class, iterator.next().getClass());
assertEquals(OAuthContextProvider.class, iterator.next().getClass());
-
+ assertEquals(OrcsParamConverterProvider.class, iterator.next().getClass());
assertEquals(OseeAccountClientRequestFilter.class, iterator.next().getClass());
assertEquals(LoggingFeature.class, iterator.next().getClass());
assertEquals(GZIPFeature.class, iterator.next().getClass());
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientConfigurator.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientConfigurator.java
index a5be34a3033..db9d0d2f2d3 100644
--- a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientConfigurator.java
+++ b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientConfigurator.java
@@ -94,6 +94,7 @@ public final class CxfJaxRsClientConfigurator implements JaxRsClientConfigurator
providers.add(new GenericResponseExceptionMapper());
providers.addAll(JacksonFeature.getProviders());
providers.addAll(OAuth2Util.getOAuthProviders());
+ providers.add(new OrcsParamConverterProvider());
providers.add(new OseeAccountClientRequestFilter());
this.providers = providers;
@@ -115,7 +116,6 @@ public final class CxfJaxRsClientConfigurator implements JaxRsClientConfigurator
bean.setFeatures(getFeatures());
bean.setProperties(getProperties());
bean.setProviders(getOAuthProviders(config));
- bean.setProvider(new OseeAccountClientRequestFilter());
/**
* If threadSafe is true then multiple threads can invoke on the same proxy or WebClient instance.
@@ -139,7 +139,6 @@ public final class CxfJaxRsClientConfigurator implements JaxRsClientConfigurator
register(builder, getFeatures());
register(builder, getProperties());
register(builder, getOAuthProviders(config));
- builder.register(new OseeAccountClientRequestFilter());
}
@Override
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/IdParamConverter.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/IdParamConverter.java
new file mode 100644
index 00000000000..81e96f4e2f5
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/IdParamConverter.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.jaxrs.client.internal.ext;
+
+import javax.ws.rs.ext.ParamConverter;
+import org.eclipse.osee.framework.jdk.core.type.Id;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class IdParamConverter implements ParamConverter<Id> {
+ @Override
+ public String toString(Id value) {
+ return String.valueOf(value.getId());
+ }
+
+ @Override
+ public Id fromString(String value) {
+ /*
+ * return null so that the default parameter conversion will be used. Namely that
+ * org.apache.cxf.jaxrs.utils.InjectionUtils.handleParameter(String, boolean, Class<T>, Annotation[],
+ * ParameterType, Message) will call valueOf(String value) on the formal parameter type
+ */
+ return null;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/OrcsParamConverterProvider.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/OrcsParamConverterProvider.java
new file mode 100644
index 00000000000..1312b0c1404
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/OrcsParamConverterProvider.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.jaxrs.client.internal.ext;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import javax.ws.rs.ext.ParamConverter;
+import javax.ws.rs.ext.Provider;
+import org.eclipse.osee.framework.jdk.core.type.Id;
+
+/**
+ * @author Ryan D. Brooks
+ */
+@Provider
+public class OrcsParamConverterProvider implements javax.ws.rs.ext.ParamConverterProvider {
+ private final IdParamConverter idConverter = new IdParamConverter();
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) {
+ if (Id.class.isAssignableFrom(rawType)) {
+ return (ParamConverter<T>) idConverter;
+ }
+ return null;
+ }
+} \ No newline at end of file

Back to the top