This is an automated email from the git hooks/post-receive script. New commit to branch feature/8148-correctionParanamer in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 35725f02286e1365cfaf473452b11aef3cf850bc Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Tue Mar 22 13:56:47 2016 +0100 remplacer la librairie Paranamer par l'api Java 8 (see #8148). --- .../web/injector/ObserveDtoInjector.java | 27 ++++++++++++++++++++++ observe-entities/pom.xml | 4 ---- observe-services-api/pom.xml | 21 +++++++++-------- observe-services-configuration-api/pom.xml | 19 --------------- ...bserveDataSourceConfigurationRestConstants.java | 2 ++ .../services/ObserveServiceFactoryRest.java | 17 ++++++++++++-- observe-services-runner/pom.xml | 19 --------------- .../referential/ReferentialBinderSupport.java | 2 +- 8 files changed, 56 insertions(+), 55 deletions(-) diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/injector/ObserveDtoInjector.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/injector/ObserveDtoInjector.java index 5694eee..29891c5 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/injector/ObserveDtoInjector.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/injector/ObserveDtoInjector.java @@ -23,6 +23,8 @@ package fr.ird.observe.application.web.injector; */ import com.google.gson.Gson; +import com.google.gson.JsonParseException; +import fr.ird.observe.services.configuration.ObserveDataSourceConfigurationRestConstants; import fr.ird.observe.services.dto.ObserveDto; import org.apache.commons.beanutils.converters.AbstractConverter; import org.apache.commons.logging.Log; @@ -32,6 +34,7 @@ import org.debux.webmotion.server.handler.ExecutorParametersInjectorHandler; import org.debux.webmotion.server.mapping.Mapping; import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; /** * Created on 07/09/15. @@ -59,6 +62,30 @@ public class ObserveDtoInjector extends AbstractConverter implements ExecutorPar String gsonContent= ((String[])parameterTree.getValue())[0]; + if (generic instanceof TypeVariable) { + TypeVariable typeVariable = (TypeVariable) generic; + + String parameterizedTypeParam = ObserveDataSourceConfigurationRestConstants.PARAMETERIZED_TYPE_PREFIX + typeVariable.getName(); + + Call.ParameterTree parameterizedTypeParameterTree = call.getParameterTree().getObject().get(parameterizedTypeParam); + + String parameterizedTypeClassName= ((String[])parameterizedTypeParameterTree.getValue())[0]; + + try { + generic = Class.forName(parameterizedTypeClassName); + } catch (ClassNotFoundException cnfe) { + if (log.isErrorEnabled()) { + log.error("An exception occurred", cnfe); + } + throw new JsonParseException("Class not found: " + parameterizedTypeClassName, cnfe); + } + + if (log.isInfoEnabled()) { + log.info("find parameterized type " + typeVariable.getName() + " as " + parameterizedTypeClassName); + } + + } + observeDto = gson.fromJson(gsonContent, generic); if (log.isInfoEnabled()) { diff --git a/observe-entities/pom.xml b/observe-entities/pom.xml index d4fcf4a..1049d9a 100644 --- a/observe-entities/pom.xml +++ b/observe-entities/pom.xml @@ -54,10 +54,6 @@ <groupId>org.nuiton</groupId> <artifactId>nuiton-version</artifactId> </dependency> - <dependency> - <groupId>org.nuiton.i18n</groupId> - <artifactId>nuiton-i18n</artifactId> - </dependency> <!-- commons --> <dependency> diff --git a/observe-services-api/pom.xml b/observe-services-api/pom.xml index b3da66d..5c07f09 100644 --- a/observe-services-api/pom.xml +++ b/observe-services-api/pom.xml @@ -42,6 +42,10 @@ <groupId>org.nuiton</groupId> <artifactId>nuiton-validator</artifactId> </dependency> + <dependency> + <groupId>org.nuiton.i18n</groupId> + <artifactId>nuiton-i18n</artifactId> + </dependency> <!-- commons dependencies --> <dependency> @@ -119,16 +123,13 @@ </executions> </plugin> <plugin> - <groupId>com.thoughtworks.paranamer</groupId> - <artifactId>paranamer-maven-plugin</artifactId> - <executions> - <execution> - <id>extract-paranamer</id> - <goals> - <goal>generate</goal> - </goals> - </execution> - </executions> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <compilerArgs> + <arg>-parameters</arg> + </compilerArgs> + </configuration> </plugin> </plugins> diff --git a/observe-services-configuration-api/pom.xml b/observe-services-configuration-api/pom.xml index 372c433..bad9429 100644 --- a/observe-services-configuration-api/pom.xml +++ b/observe-services-configuration-api/pom.xml @@ -52,23 +52,4 @@ </dependencies> - <build> - - <plugins> - <plugin> - <groupId>com.thoughtworks.paranamer</groupId> - <artifactId>paranamer-maven-plugin</artifactId> - <executions> - <execution> - <id>extract-paranamer</id> - <goals> - <goal>generate</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - - </build> - </project> \ No newline at end of file diff --git a/observe-services-configuration-rest/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationRestConstants.java b/observe-services-configuration-rest/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationRestConstants.java index 217b6dd..dbba4d4 100644 --- a/observe-services-configuration-rest/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationRestConstants.java +++ b/observe-services-configuration-rest/src/main/java/fr/ird/observe/services/configuration/ObserveDataSourceConfigurationRestConstants.java @@ -45,4 +45,6 @@ public interface ObserveDataSourceConfigurationRestConstants { String DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ssZ"; + String PARAMETERIZED_TYPE_PREFIX = "parameterized_type_"; + } diff --git a/observe-services-rest/src/main/java/fr/ird/observe/services/ObserveServiceFactoryRest.java b/observe-services-rest/src/main/java/fr/ird/observe/services/ObserveServiceFactoryRest.java index 03dc3d7..57af2f9 100644 --- a/observe-services-rest/src/main/java/fr/ird/observe/services/ObserveServiceFactoryRest.java +++ b/observe-services-rest/src/main/java/fr/ird/observe/services/ObserveServiceFactoryRest.java @@ -52,6 +52,8 @@ import org.apache.commons.logging.LogFactory; import java.io.IOException; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +import java.lang.reflect.TypeVariable; import java.text.SimpleDateFormat; import java.util.Collection; import java.util.Date; @@ -318,9 +320,9 @@ public class ObserveServiceFactoryRest extends ObserveServiceFactorySupport impl SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN); - String[] strings = paranamer.lookupParameterNames(method); int index = 0; - for (String name : strings) { + for (Parameter parameter : method.getParameters()) { + String name = parameter.getName(); if (args.length >= (index + 1)) { Object value = args[index]; if (value != null && value instanceof String) { @@ -332,6 +334,17 @@ public class ObserveServiceFactoryRest extends ObserveServiceFactorySupport impl } else if (value != null) { requestBuilder.addParameter(name, value); } + // si c'est un type parametré, on envoie la class correspondante a ce type + if (parameter.getParameterizedType() instanceof TypeVariable) { + TypeVariable typeVariable = (TypeVariable) parameter.getParameterizedType(); + requestBuilder.addParameter(PARAMETERIZED_TYPE_PREFIX + typeVariable.getName(), value.getClass().getCanonicalName()); + + if (log.isInfoEnabled()) { + log.info("add parameterized type " + typeVariable.getName() + " as " + value.getClass() + " into request" ); + } + + } + } if (reinjectConfiguration && PARAMETER_DATA_SOURCE_CONFIGURATION.equals(name)) { diff --git a/observe-services-runner/pom.xml b/observe-services-runner/pom.xml index ae389b1..34b782a 100644 --- a/observe-services-runner/pom.xml +++ b/observe-services-runner/pom.xml @@ -92,23 +92,4 @@ </dependencies> - <build> - - <plugins> - <plugin> - <groupId>com.thoughtworks.paranamer</groupId> - <artifactId>paranamer-maven-plugin</artifactId> - <executions> - <execution> - <id>extract-paranamer</id> - <goals> - <goal>generate</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - - </build> - </project> \ No newline at end of file diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/binder/referential/ReferentialBinderSupport.java b/observe-services-topia/src/main/java/fr/ird/observe/services/binder/referential/ReferentialBinderSupport.java index a19c380..7055adc 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/binder/referential/ReferentialBinderSupport.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/binder/referential/ReferentialBinderSupport.java @@ -136,10 +136,10 @@ public abstract class ReferentialBinderSupport<E extends ObserveReferentialEntit protected void copyEntityI18nFieldsToDto(I18nReferentialEntity entity, I18nReferentialDto dto) { + dto.setLabel1(entity.getLabel1()); dto.setLabel2(entity.getLabel2()); dto.setLabel3(entity.getLabel3()); dto.setLabel4(entity.getLabel4()); - dto.setLabel1(entity.getLabel1()); dto.setLabel5(entity.getLabel5()); dto.setLabel6(entity.getLabel6()); dto.setLabel7(entity.getLabel7()); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.