Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe

Commits:

20 changed files:

Changes:

  • client/src/main/java/fr/ird/observe/client/ObserveTextGenerator.java
    ... ... @@ -51,29 +51,27 @@ public class ObserveTextGenerator {
    51 51
     
    
    52 52
         private static final Log log = LogFactory.getLog(ObserveTextGenerator.class);
    
    53 53
     
    
    54
    -    protected static final String DATA_SOURCE_CONFIGURATION_TEMPLATE = "dataSourceConfiguration.ftl";
    
    54
    +    private static final String DATA_SOURCE_CONFIGURATION_TEMPLATE = "dataSourceConfiguration.ftl";
    
    55 55
     
    
    56
    -    protected static final String CONNEXION_TEST_RESULT_TEMPLATE = "connexionTestResult.ftl";
    
    56
    +    private static final String CONNEXION_TEST_RESULT_TEMPLATE = "connexionTestResult.ftl";
    
    57 57
     
    
    58
    -    protected static final String DATA_SOURCE_SELECT_MODE_RESUME_TEMPLATE = "dataSourceSelectModeResume.ftl";
    
    58
    +    private static final String DATA_SOURCE_SELECT_MODE_RESUME_TEMPLATE = "dataSourceSelectModeResume.ftl";
    
    59 59
     
    
    60
    -    protected static final String DATA_SOURCE_CONNECTION_REPORT_TEMPLATE = "dataSourceConnectionReport.ftl";
    
    60
    +    private static final String DATA_SOURCE_CONNECTION_REPORT_TEMPLATE = "dataSourceConnectionReport.ftl";
    
    61 61
     
    
    62
    -    protected static final String DATA_SOURCE_INFORMATION_TEMPLATE = "dataSourceInformation.ftl";
    
    62
    +    private static final String DATA_SOURCE_INFORMATION_TEMPLATE = "dataSourceInformation.ftl";
    
    63 63
     
    
    64
    -    protected static final String DATA_SOURCE_POLICY_TEMPLATE = "dataSourcePolicy.ftl";
    
    64
    +    private static final String DATA_SOURCE_POLICY_TEMPLATE = "dataSourcePolicy.ftl";
    
    65 65
     
    
    66
    -    protected static final String ABOUT_TEMPLATE = "about.ftl";
    
    66
    +    private static final String ABOUT_TEMPLATE = "about.ftl";
    
    67 67
     
    
    68
    -    protected static final String TRANSLATE_TEMPLATE = "translate.ftl";
    
    68
    +    private static final String INIT_STORAGE_TEMPLATE = "initStorage.ftl";
    
    69 69
     
    
    70
    -    protected static final String INIT_STORAGE_TEMPLATE = "initStorage.ftl";
    
    70
    +    private final Configuration freemarkerConfiguration;
    
    71 71
     
    
    72
    -    protected final Configuration freemarkerConfiguration;
    
    72
    +    private final ClientConfig observeConfiguration;
    
    73 73
     
    
    74
    -    protected final ClientConfig observeConfiguration;
    
    75
    -
    
    76
    -    public ObserveTextGenerator(ClientConfig observeConfiguration) {
    
    74
    +    ObserveTextGenerator(ClientConfig observeConfiguration) {
    
    77 75
             this.observeConfiguration = observeConfiguration;
    
    78 76
     
    
    79 77
             freemarkerConfiguration = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
    
    ... ... @@ -116,7 +114,7 @@ public class ObserveTextGenerator {
    116 114
             return generateHtml(DATA_SOURCE_POLICY_TEMPLATE, model);
    
    117 115
         }
    
    118 116
     
    
    119
    -    public String getInitStorage(ObserveSwingApplicationDataSourcesManager.InitStorageModel model) {
    
    117
    +    String getInitStorage(ObserveSwingApplicationDataSourcesManager.InitStorageModel model) {
    
    120 118
             return generateHtml(INIT_STORAGE_TEMPLATE, model);
    
    121 119
         }
    
    122 120
     
    
    ... ... @@ -128,15 +126,6 @@ public class ObserveTextGenerator {
    128 126
             return generateHtml(ABOUT_TEMPLATE, model);
    
    129 127
         }
    
    130 128
     
    
    131
    -    public String getTranslate(File model) {
    
    132
    -        try {
    
    133
    -            URL url = model.toURI().toURL();
    
    134
    -            return generateHtml(TRANSLATE_TEMPLATE, ImmutableMap.of("file", url));
    
    135
    -        } catch (MalformedURLException e) {
    
    136
    -            throw new ObserveSwingTechnicalException(e);
    
    137
    -        }
    
    138
    -    }
    
    139
    -
    
    140 129
         protected String generateHtml(Locale locale, String templateName, Object model) {
    
    141 130
     
    
    142 131
             try {
    

  • client/src/main/java/fr/ird/observe/client/ui/content/impl/seine/FloatingObjectUIHandler.java
    ... ... @@ -247,8 +247,8 @@ public class FloatingObjectUIHandler extends ContentUIHandler<FloatingObjectDto,
    247 247
             SaveResultDto saveResult = getFloatingObjectService().save(activityId, bean);
    
    248 248
             saveResult.toDto(bean);
    
    249 249
     
    
    250
    -        List<FloatingObjectPartDto> parts = getModel().toParts();
    
    251
    -        getFloatingObjectService().save(saveResult.getId(), parts);
    
    250
    +        ImmutableSet<FloatingObjectPartDto> parts = getModel().toParts();
    
    251
    +        getFloatingObjectService().saveParts(saveResult.getId(), parts);
    
    252 252
             saveResult.toDto(bean);
    
    253 253
     
    
    254 254
             return true;
    

  • client/src/main/java/fr/ird/observe/client/ui/content/impl/seine/FloatingObjectUIModel.java
    ... ... @@ -34,7 +34,6 @@ import fr.ird.observe.services.dto.seine.FloatingObjectPartDto;
    34 34
     import fr.ird.observe.services.dto.seine.ObjectMaterialHierarchyDto;
    
    35 35
     import java.util.LinkedHashMap;
    
    36 36
     import java.util.LinkedHashSet;
    
    37
    -import java.util.LinkedList;
    
    38 37
     import java.util.List;
    
    39 38
     import java.util.Map;
    
    40 39
     import java.util.Optional;
    
    ... ... @@ -77,9 +76,9 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> {
    77 76
         public static final String PROPERTY_GENERAL_TAB_VALID = "generalTabValid";
    
    78 77
     
    
    79 78
         private static final String PROPERTY_MATERIALS_TAB_VALID = "materialsTabValid";
    
    80
    -    public static final String PROPERTY_REFERENCE = "reference";
    
    81
    -    public static final String PROPERTY_ARRIVING = "arriving";
    
    82
    -    public static final String PROPERTY_LEAVING = "leaving";
    
    79
    +    static final String PROPERTY_REFERENCE = "reference";
    
    80
    +    private static final String PROPERTY_ARRIVING = "arriving";
    
    81
    +    private static final String PROPERTY_LEAVING = "leaving";
    
    83 82
     
    
    84 83
         public static final Set<String> GENERAL_TAB_PROPERTIES =
    
    85 84
                 ImmutableSet.<String>builder().add(FloatingObjectDto.PROPERTY_OBJECT_OPERATION,
    
    ... ... @@ -90,7 +89,7 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> {
    90 89
                 ImmutableSet.<String>builder().add(FloatingObjectDto.PROPERTY_COMMENT).build();
    
    91 90
     
    
    92 91
         protected boolean generalTabValid;
    
    93
    -    protected boolean materialsTabValid;
    
    92
    +    private boolean materialsTabValid;
    
    94 93
     
    
    95 94
         private final Map<ObjectMaterialDto, String> whenArriving;
    
    96 95
         private final Map<ObjectMaterialDto, String> whenLeaving;
    
    ... ... @@ -116,8 +115,8 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> {
    116 115
         }
    
    117 116
     
    
    118 117
     
    
    119
    -    public List<FloatingObjectPartDto> toParts() {
    
    120
    -        List<FloatingObjectPartDto> result = new LinkedList<>();
    
    118
    +    ImmutableSet<FloatingObjectPartDto> toParts() {
    
    119
    +        ImmutableSet.Builder<FloatingObjectPartDto> result = ImmutableSet.builder();
    
    121 120
             for (ObjectMaterialDto o : getAll()) {
    
    122 121
                 FloatingObjectPartDto partDto = new FloatingObjectPartDto();
    
    123 122
                 partDto.setObjectMaterial(referenceBinderEngine.transformReferentialDtoToReference(referentialLocale, o));
    
    ... ... @@ -129,7 +128,7 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> {
    129 128
                 }
    
    130 129
                 result.add(partDto);
    
    131 130
             }
    
    132
    -        return result;
    
    131
    +        return result.build();
    
    133 132
         }
    
    134 133
     
    
    135 134
         public void reset() {
    
    ... ... @@ -151,7 +150,7 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> {
    151 150
             return alls;
    
    152 151
         }
    
    153 152
     
    
    154
    -    public void setReferentialMap(Map<String, ObjectMaterialDto> referentialMap) {
    
    153
    +    void setReferentialMap(Map<String, ObjectMaterialDto> referentialMap) {
    
    155 154
             this.referentialMap = referentialMap;
    
    156 155
         }
    
    157 156
     
    
    ... ... @@ -171,7 +170,7 @@ public class FloatingObjectUIModel extends ContentUIModel<FloatingObjectDto> {
    171 170
             whenLeaving.put(dto, value);
    
    172 171
         }
    
    173 172
     
    
    174
    -    public DefaultMutableTreeTableNode createRoot(Decorator<ObjectMaterialDto> decoratorByType, List<ObjectMaterialHierarchyDto> referential) {
    
    173
    +    DefaultMutableTreeTableNode createRoot(Decorator<ObjectMaterialDto> decoratorByType, List<ObjectMaterialHierarchyDto> referential) {
    
    175 174
             DefaultMutableTreeTableNode root = new DefaultMutableTreeTableNode();
    
    176 175
             for (ObjectMaterialHierarchyDto dto : referential) {
    
    177 176
                 root.add(new FloatingObjectPartsTreeNode(decoratorByType, this, dto));
    

  • pom.xml
    ... ... @@ -179,7 +179,7 @@
    179 179
         <nuitonUtilsVersion>3.0-rc-18</nuitonUtilsVersion>
    
    180 180
         <nuitonConverterVersion>1.0</nuitonConverterVersion>
    
    181 181
         <nuitonVersionVersion>1.0-rc-2</nuitonVersionVersion>
    
    182
    -    <httpVersion>1.0.2-SNAPSHOT</httpVersion>
    
    182
    +    <httpVersion>1.0.2</httpVersion>
    
    183 183
         <xworkVersion>2.3.33</xworkVersion>
    
    184 184
         <flexmarkVersion>0.22.14</flexmarkVersion>
    
    185 185
         <hibernateVersion>5.1.8.Final</hibernateVersion>
    

  • server/src/main/filtered-resources/mapping
    ... ... @@ -161,7 +161,7 @@ GET /api/v1/data/seine/FloatingObjectService/loadReferenceToRead
    161 161
     GET    /api/v1/data/seine/FloatingObjectService/preCreate                                                                            v1.data.seine.FloatingObjectServiceRestApi.preCreate
    
    162 162
     GET    /api/v1/data/seine/FloatingObjectService/retainExistingIds                                                                    v1.data.seine.FloatingObjectServiceRestApi.retainExistingIds
    
    163 163
     POST   /api/v1/data/seine/FloatingObjectService/save                                                                                 v1.data.seine.FloatingObjectServiceRestApi.save
    
    164
    -POST   /api/v1/data/seine/FloatingObjectService/save                                                                                 v1.data.seine.FloatingObjectServiceRestApi.save
    
    164
    +POST   /api/v1/data/seine/FloatingObjectService/saveParts                                                                            v1.data.seine.FloatingObjectServiceRestApi.saveParts
    
    165 165
     GET    /api/v1/data/seine/NonTargetCatchReleaseService/getSampleSpecies                                                              v1.data.seine.NonTargetCatchReleaseServiceRestApi.getSampleSpecies
    
    166 166
     GET    /api/v1/data/seine/NonTargetCatchReleaseService/loadForm                                                                      v1.data.seine.NonTargetCatchReleaseServiceRestApi.loadForm
    
    167 167
     POST   /api/v1/data/seine/NonTargetCatchReleaseService/save                                                                          v1.data.seine.NonTargetCatchReleaseServiceRestApi.save
    

  • server/src/main/java/fr/ird/observe/server/ObserveWebApplicationListener.java
    ... ... @@ -77,7 +77,7 @@ public class ObserveWebApplicationListener implements WebMotionServerListener {
    77 77
             context.addInjector(new ObserveReferenceSetRequestInjector(gson));
    
    78 78
             context.addInjector(new DateInjector(HRequestBuilder.DATE_PATTERN));
    
    79 79
             context.addInjector(new SqlScriptProducerRequestInjector(gson));
    
    80
    -        context.addInjector(new ImmutableSetInjector());
    
    80
    +        context.addInjector(new ImmutableSetInjector(gson));
    
    81 81
             context.addConverter(new ObserveDtoConverter(gson), ObserveDbUserDto.class);
    
    82 82
     
    
    83 83
             context.getServletContext().setAttribute(ObserveWebApplicationContext.APPLICATION_CONTEXT_PARAMETER, applicationContext);
    

  • server/src/main/java/fr/ird/observe/server/controller/v1/ObserveWebErrorController.java
    ... ... @@ -22,7 +22,7 @@ package fr.ird.observe.server.controller.v1;
    22 22
      * #L%
    
    23 23
      */
    
    24 24
     
    
    25
    -import fr.ird.observe.services.http.ObserveHttpError;
    
    25
    +import io.ultreia.java4all.http.HResponseError;
    
    26 26
     import fr.ird.observe.services.security.ObserveWebSecurityExceptionSupport;
    
    27 27
     import fr.ird.observe.services.security.UnauthorizedException;
    
    28 28
     import java.lang.reflect.InvocationTargetException;
    
    ... ... @@ -42,7 +42,7 @@ import org.debux.webmotion.server.call.HttpContext;
    42 42
      */
    
    43 43
     public class ObserveWebErrorController extends WebMotionController {
    
    44 44
     
    
    45
    -    public ObserveHttpError error(HttpContext.ErrorData errorData) {
    
    45
    +    public HResponseError error(HttpContext.ErrorData errorData) {
    
    46 46
     
    
    47 47
             @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
    
    48 48
             Throwable exception = errorData.getException();
    
    ... ... @@ -96,10 +96,10 @@ public class ObserveWebErrorController extends WebMotionController {
    96 96
     
    
    97 97
             }
    
    98 98
     
    
    99
    -        return new ObserveHttpError(statusCode,
    
    100
    -                                    exception == null ? null : exception.getClass(),
    
    101
    -                                    message,
    
    102
    -                                    exception);
    
    99
    +        return new HResponseError(statusCode,
    
    100
    +                                  exception == null ? null : exception.getClass(),
    
    101
    +                                  message,
    
    102
    +                                  exception);
    
    103 103
     
    
    104 104
         }
    
    105 105
     
    

  • server/src/main/java/fr/ird/observe/server/injector/ImmutableSetInjector.java
    ... ... @@ -23,7 +23,9 @@ package fr.ird.observe.server.injector;
    23 23
      */
    
    24 24
     
    
    25 25
     import com.google.common.collect.ImmutableSet;
    
    26
    +import com.google.gson.Gson;
    
    26 27
     import java.lang.reflect.Type;
    
    28
    +import java.util.Collection;
    
    27 29
     import java.util.Objects;
    
    28 30
     import org.apache.commons.logging.Log;
    
    29 31
     import org.apache.commons.logging.LogFactory;
    
    ... ... @@ -47,6 +49,11 @@ public class ImmutableSetInjector implements ExecutorParametersInjectorHandler.I
    47 49
     
    
    48 50
         /** Logger. */
    
    49 51
         private static final Log log = LogFactory.getLog(ImmutableSetInjector.class);
    
    52
    +    private final Gson gson;
    
    53
    +
    
    54
    +    public ImmutableSetInjector(Gson gson) {
    
    55
    +        this.gson = gson;
    
    56
    +    }
    
    50 57
     
    
    51 58
         @Override
    
    52 59
         public Object getValue(Mapping mapping, Call call, String name, Class<?> type, Type generic) {
    
    ... ... @@ -54,11 +61,8 @@ public class ImmutableSetInjector implements ExecutorParametersInjectorHandler.I
    54 61
             ImmutableSet result = null;
    
    55 62
     
    
    56 63
             if (ImmutableSet.class.isAssignableFrom(type)) {
    
    57
    -            // Type des objets contenu dans le set
    
    58
    -            // Type[] actualTypeArguments = ((ParameterizedType) generic).getActualTypeArguments();
    
    59
    -            // Type subType = actualTypeArguments[0];
    
    60 64
     
    
    61
    -            ImmutableSet.Builder builder = ImmutableSet.builder();
    
    65
    +            ImmutableSet.Builder<Object> builder = ImmutableSet.builder();
    
    62 66
     
    
    63 67
                 if (call.getParameterTree().getObject() != null) {
    
    64 68
                     Call.ParameterTree parameterTree = call.getParameterTree().getObject().get(name);
    
    ... ... @@ -66,9 +70,8 @@ public class ImmutableSetInjector implements ExecutorParametersInjectorHandler.I
    66 70
                     Objects.requireNonNull(parameterTree, "Le paramètre " + name + " n'as pas été trouvé, recompiler (parameter)!");
    
    67 71
     
    
    68 72
                     String[] values = (String[]) parameterTree.getValue();
    
    69
    -                for (String value : values) {
    
    70
    -                    builder.add(value);
    
    71
    -                }
    
    73
    +                Collection o = gson.fromJson(values[0], generic);
    
    74
    +                builder.addAll(o);
    
    72 75
                 }
    
    73 76
                 result = builder.build();
    
    74 77
     
    
    ... ... @@ -81,4 +84,5 @@ public class ImmutableSetInjector implements ExecutorParametersInjectorHandler.I
    81 84
             return result;
    
    82 85
     
    
    83 86
         }
    
    87
    +
    
    84 88
     }

  • services-rest/src/main/java/fr/ird/observe/services/rest/ObserveServiceRestClientContext.java
    ... ... @@ -56,11 +56,11 @@ public class ObserveServiceRestClientContext {
    56 56
             this.locateService = locateService;
    
    57 57
         }
    
    58 58
     
    
    59
    -    public ObserveRequestBuilderFactory getRequestBuilderFactory() {
    
    59
    +    ObserveRequestBuilderFactory getRequestBuilderFactory() {
    
    60 60
             return requestBuilderFactory;
    
    61 61
         }
    
    62 62
     
    
    63
    -    public HResponseBuilder getResponseBuilder() {
    
    63
    +    HResponseBuilder getResponseBuilder() {
    
    64 64
             return responseBuilder;
    
    65 65
         }
    
    66 66
     
    
    ... ... @@ -68,23 +68,19 @@ public class ObserveServiceRestClientContext {
    68 68
             return initializer;
    
    69 69
         }
    
    70 70
     
    
    71
    -    public String getSpeciesListConfigurationAsString() {
    
    71
    +    String getSpeciesListConfigurationAsString() {
    
    72 72
             return speciesListConfigurationAsString;
    
    73 73
         }
    
    74 74
     
    
    75
    -    public Optional<ObserveDataSourceConnectionRest> getDataSourceConnection() {
    
    76
    -        return (Optional) initializer.getDataSourceConnection();
    
    77
    -    }
    
    78
    -
    
    79 75
         public Optional<ObserveDataSourceConfiguration> getDataSourceConfiguration() {
    
    80 76
             return initializer.getDataSourceConfiguration();
    
    81 77
         }
    
    82 78
     
    
    83
    -    public boolean withApplicationLocale() {
    
    79
    +    boolean withApplicationLocale() {
    
    84 80
             return getApplicationLocale() != null;
    
    85 81
         }
    
    86 82
     
    
    87
    -    public Locale getApplicationLocale() {
    
    83
    +    Locale getApplicationLocale() {
    
    88 84
             return initializer.getApplicationLocale();
    
    89 85
         }
    
    90 86
     
    
    ... ... @@ -92,7 +88,7 @@ public class ObserveServiceRestClientContext {
    92 88
             return initializer.getReferentialLocale();
    
    93 89
         }
    
    94 90
     
    
    95
    -    public boolean withReferentialLocale() {
    
    91
    +    boolean withReferentialLocale() {
    
    96 92
             return getReferentialLocale() != null;
    
    97 93
         }
    
    98 94
     
    
    ... ... @@ -101,7 +97,7 @@ public class ObserveServiceRestClientContext {
    101 97
             return getServiceUrl() + suffix;
    
    102 98
         }
    
    103 99
     
    
    104
    -    String getServiceUrl() {
    
    100
    +    private String getServiceUrl() {
    
    105 101
             String serviceUrl;
    
    106 102
             if (initializer.withDataSourceConnection()) {
    
    107 103
     
    

  • services-rest/src/main/java/fr/ird/observe/services/rest/ObserveServiceRestClientSupport.java
    ... ... @@ -25,7 +25,6 @@ package fr.ird.observe.services.rest;
    25 25
     import com.google.gson.Gson;
    
    26 26
     import fr.ird.observe.services.service.ObserveService;
    
    27 27
     import io.ultreia.java4all.http.HRequest;
    
    28
    -import io.ultreia.java4all.http.HRequestBuilder;
    
    29 28
     import io.ultreia.java4all.http.HResponse;
    
    30 29
     import io.ultreia.java4all.http.HRestClientService;
    
    31 30
     import org.nuiton.util.TimeLog;
    
    ... ... @@ -52,7 +51,7 @@ public class ObserveServiceRestClientSupport implements HRestClientService, Obse
    52 51
         }
    
    53 52
     
    
    54 53
         @Override
    
    55
    -    public HRequestBuilder create(String baseUrl) {
    
    54
    +    public ObserveRequestBuilder create(String baseUrl) {
    
    56 55
             return getRequestBuilderFactory().create(serviceContext, baseUrl);
    
    57 56
         }
    
    58 57
     
    
    ... ... @@ -61,6 +60,8 @@ public class ObserveServiceRestClientSupport implements HRestClientService, Obse
    61 60
             long t0 = TimeLog.getTime();
    
    62 61
             try {
    
    63 62
                 return serviceContext.getResponseBuilder().executeRequest(request, expectedStatusCode);
    
    63
    +        } catch (RuntimeException e) {
    
    64
    +            throw e;
    
    64 65
             } catch (Exception e) {
    
    65 66
                 throw new IllegalStateException("Can't execute request " + request, e);
    
    66 67
             } finally {
    
    ... ... @@ -73,6 +74,8 @@ public class ObserveServiceRestClientSupport implements HRestClientService, Obse
    73 74
             long t0 = TimeLog.getTime();
    
    74 75
             try {
    
    75 76
                 return serviceContext.getResponseBuilder().executeRequest(request);
    
    77
    +        } catch (RuntimeException e) {
    
    78
    +            throw e;
    
    76 79
             } catch (Exception e) {
    
    77 80
                 throw new IllegalStateException("Can't execute request " + request, e);
    
    78 81
             } finally {
    

  • services-rest/src/main/java/fr/ird/observe/services/rest/ObserveServiceRestErrorException.java deleted
    1
    -package fr.ird.observe.services.rest;
    
    2
    -
    
    3
    -/*-
    
    4
    - * #%L
    
    5
    - * ObServe :: Services REST Implementation
    
    6
    - * %%
    
    7
    - * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
    
    8
    - * %%
    
    9
    - * This program is free software: you can redistribute it and/or modify
    
    10
    - * it under the terms of the GNU General Public License as
    
    11
    - * published by the Free Software Foundation, either version 3 of the
    
    12
    - * License, or (at your option) any later version.
    
    13
    - * 
    
    14
    - * This program is distributed in the hope that it will be useful,
    
    15
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    - * GNU General Public License for more details.
    
    18
    - * 
    
    19
    - * You should have received a copy of the GNU General Public
    
    20
    - * License along with this program.  If not, see
    
    21
    - * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    - * #L%
    
    23
    - */
    
    24
    -
    
    25
    -/**
    
    26
    - * @author Sylvain Bavencoff - bavencoff@codelutin.com
    
    27
    - */
    
    28
    -public class ObserveServiceRestErrorException extends RuntimeException {
    
    29
    -
    
    30
    -    private static final long serialVersionUID = 1L;
    
    31
    -
    
    32
    -    public ObserveServiceRestErrorException() {
    
    33
    -    }
    
    34
    -
    
    35
    -    public ObserveServiceRestErrorException(String message) {
    
    36
    -        super(message);
    
    37
    -    }
    
    38
    -}

  • services-rest/src/main/java/fr/ird/observe/services/rest/ObserveServiceRestNotAvailableException.java deleted
    1
    -package fr.ird.observe.services.rest;
    
    2
    -
    
    3
    -/*
    
    4
    - * #%L
    
    5
    - * ObServe :: Services REST Implementation
    
    6
    - * %%
    
    7
    - * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
    
    8
    - * %%
    
    9
    - * This program is free software: you can redistribute it and/or modify
    
    10
    - * it under the terms of the GNU General Public License as
    
    11
    - * published by the Free Software Foundation, either version 3 of the
    
    12
    - * License, or (at your option) any later version.
    
    13
    - * 
    
    14
    - * This program is distributed in the hope that it will be useful,
    
    15
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    - * GNU General Public License for more details.
    
    18
    - * 
    
    19
    - * You should have received a copy of the GNU General Public
    
    20
    - * License along with this program.  If not, see
    
    21
    - * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    - * #L%
    
    23
    - */
    
    24
    -
    
    25
    -import java.net.URL;
    
    26
    -
    
    27
    -/**
    
    28
    - * Exception à retourner quand le service n'est pas accessible.
    
    29
    - * <p>
    
    30
    - * Created on 06/09/15.
    
    31
    - *
    
    32
    - * @author Tony Chemit - dev@tchemit.fr
    
    33
    - */
    
    34
    -public class ObserveServiceRestNotAvailableException extends RuntimeException {
    
    35
    -
    
    36
    -    private static final long serialVersionUID = 1L;
    
    37
    -
    
    38
    -    private final URL serverUrl;
    
    39
    -
    
    40
    -    public ObserveServiceRestNotAvailableException(URL serverUrl) {
    
    41
    -        super("Server " + serverUrl + " not available");
    
    42
    -        this.serverUrl = serverUrl;
    
    43
    -    }
    
    44
    -
    
    45
    -    public URL getServerUrl() {
    
    46
    -        return serverUrl;
    
    47
    -    }
    
    48
    -
    
    49
    -}

  • services-rest/src/test/java/fr/ird/observe/services/rest/service/PingServiceRestTest.java
    ... ... @@ -22,13 +22,12 @@ package fr.ird.observe.services.rest.service;
    22 22
      * #L%
    
    23 23
      */
    
    24 24
     
    
    25
    -import fr.ird.observe.services.rest.ObserveServiceRestNotAvailableException;
    
    26 25
     import fr.ird.observe.services.configuration.rest.ObserveDataSourceConfigurationRest;
    
    27 26
     import fr.ird.observe.services.service.PingService;
    
    28
    -import org.junit.Test;
    
    29
    -
    
    27
    +import io.ultreia.java4all.http.HResponseNotAvailableException;
    
    30 28
     import java.net.MalformedURLException;
    
    31 29
     import java.net.URL;
    
    30
    +import org.junit.Test;
    
    32 31
     
    
    33 32
     /**
    
    34 33
      * Created on 07/09/15.
    
    ... ... @@ -37,7 +36,7 @@ import java.net.URL;
    37 36
      */
    
    38 37
     public class PingServiceRestTest extends AbstractServiceRestTest {
    
    39 38
     
    
    40
    -    @Test(expected = ObserveServiceRestNotAvailableException.class)
    
    39
    +    @Test(expected = HResponseNotAvailableException.class)
    
    41 40
         public void testPingWithBadServerUrl() throws MalformedURLException, CloneNotSupportedException {
    
    42 41
     
    
    43 42
             ObserveDataSourceConfigurationRest dataSourceConfiguration = restTestMethodResource.getDataSourceConfiguration().clone();
    

  • services-topia/src/main/java/fr/ird/observe/services/topia/service/data/seine/FloatingObjectServiceTopia.java
    ... ... @@ -184,7 +184,7 @@ public class FloatingObjectServiceTopia extends ObserveServiceTopia implements F
    184 184
         }
    
    185 185
     
    
    186 186
         @Override
    
    187
    -    public SaveResultDto save(String floatingObjectId, List<FloatingObjectPartDto> dtos) {
    
    187
    +    public SaveResultDto saveParts(String floatingObjectId, ImmutableSet<FloatingObjectPartDto> floatingObjectParts) {
    
    188 188
             FloatingObject floatingObject = loadEntity(FloatingObjectDto.class, floatingObjectId);
    
    189 189
     
    
    190 190
             ImmutableMap<String, ObjectMaterial> objectMaterialsMap = Maps.uniqueIndex(getTopiaPersistenceContext().getObjectMaterialDao().findAll(), ObjectMaterial::getTopiaId);
    
    ... ... @@ -192,7 +192,7 @@ public class FloatingObjectServiceTopia extends ObserveServiceTopia implements F
    192 192
             FloatingObjectPartTopiaDao dao = getTopiaPersistenceContext().getFloatingObjectPartDao();
    
    193 193
             Set<String> remainingIds = new LinkedHashSet<>();
    
    194 194
             List<FloatingObjectPart> toSave = new LinkedList<>();
    
    195
    -        for (FloatingObjectPartDto dto : dtos) {
    
    195
    +        for (FloatingObjectPartDto dto : floatingObjectParts) {
    
    196 196
                 FloatingObjectPart floatingObjectPart = existingMap.get(dto.getObjectMaterial().getCode());
    
    197 197
                 if (floatingObjectPart != null) {
    
    198 198
                     String topiaId = floatingObjectPart.getTopiaId();
    

  • services/src/main/java/fr/ird/observe/services/dto/AbstractObserveDto.java
    ... ... @@ -32,7 +32,7 @@ import org.nuiton.util.CollectionUtil;
    32 32
      * @author Tony Chemit - dev@tchemit.fr
    
    33 33
      * @since 7.0
    
    34 34
      */
    
    35
    -public abstract class AbstractObserveDto extends AbstractSerializableBean {
    
    35
    +public abstract class AbstractObserveDto extends AbstractSerializableBean implements ObserveDto{
    
    36 36
     
    
    37 37
         private static final long serialVersionUID = 1L;
    
    38 38
     
    

  • services/src/main/java/fr/ird/observe/services/dto/source/DataSourceCreateConfigurationDto.java
    ... ... @@ -39,31 +39,31 @@ public class DataSourceCreateConfigurationDto extends AbstractObserveDto {
    39 39
         /**
    
    40 40
          * Le contenu de la base à importer (Optionel).
    
    41 41
          */
    
    42
    -    protected byte[] optionalImportDatabase;
    
    42
    +    private byte[] optionalImportDatabase;
    
    43 43
     
    
    44 44
         /**
    
    45 45
          * Une configuration de la dataSource à utiliser pour importer le référentiel (Optionel).
    
    46 46
          */
    
    47
    -    protected ObserveDataSourceConfiguration optionalImportReferentialDataSourceConfiguration;
    
    47
    +    private ObserveDataSourceConfiguration optionalImportReferentialDataSourceConfiguration;
    
    48 48
     
    
    49 49
         /**
    
    50 50
          * Une configuration de la dataSource à utiliser pour importer des données (Optionel).
    
    51 51
          */
    
    52
    -    protected ObserveDataSourceConfiguration optionalImportDataDataSourceConfiguration;
    
    52
    +    private ObserveDataSourceConfiguration optionalImportDataDataSourceConfiguration;
    
    53 53
     
    
    54 54
         /**
    
    55 55
          * Les données à importer (ids des marées) (Optionel).
    
    56 56
          */
    
    57
    -    protected ImmutableSet<String> optionalImportDataIds;
    
    57
    +    private ImmutableSet<String> optionalImportDataIds;
    
    58 58
     
    
    59 59
         /**
    
    60 60
          * Pour autoriser la création d'une base vide (utilisé pour les bases temporaires)
    
    61 61
          */
    
    62
    -    protected boolean canCreateEmptyDatabase;
    
    62
    +    private boolean canCreateEmptyDatabase;
    
    63 63
     
    
    64 64
         private boolean leaveOpenSource;
    
    65 65
     
    
    66
    -    public boolean isCanCreateEmptyDatabase() {
    
    66
    +    private boolean isCanCreateEmptyDatabase() {
    
    67 67
             return canCreateEmptyDatabase;
    
    68 68
         }
    
    69 69
     
    

  • services/src/main/java/fr/ird/observe/services/gson/ObserveDtoGsonSupplier.java
    ... ... @@ -47,8 +47,9 @@ import fr.ird.observe.services.gson.reference.DataReferenceSetAdapter;
    47 47
     import fr.ird.observe.services.gson.reference.ReferentialReferenceAdapter;
    
    48 48
     import fr.ird.observe.services.gson.reference.ReferentialReferenceSetAdapter;
    
    49 49
     import fr.ird.observe.services.gson.reference.UnknownReferenceAdapter;
    
    50
    -import fr.ird.observe.services.http.ObserveHttpError;
    
    50
    +import io.ultreia.java4all.http.HResponseError;
    
    51 51
     import fr.ird.observe.services.service.actions.report.ReportVariable;
    
    52
    +import io.ultreia.java4all.http.HResponseErrorAdapter;
    
    52 53
     import java.sql.Blob;
    
    53 54
     import java.util.Collection;
    
    54 55
     import java.util.Date;
    
    ... ... @@ -144,7 +145,7 @@ public class ObserveDtoGsonSupplier implements Supplier<Gson> {
    144 145
                 gsonBuilder.registerTypeAdapter(Form.class, new FormAdapter());
    
    145 146
                 gsonBuilder.registerTypeAdapter(ReportVariable.class, new ReportVariableAdapter());
    
    146 147
                 gsonBuilder.registerTypeAdapter(Version.class, new VersionAdapter());
    
    147
    -            gsonBuilder.registerTypeAdapter(ObserveHttpError.class, new ObserveHttpErrorAdapter());
    
    148
    +            gsonBuilder.registerTypeAdapter(HResponseError.class, new HResponseErrorAdapter());
    
    148 149
     
    
    149 150
                 gsonBuilder.enableComplexMapKeySerialization();
    
    150 151
             }
    

  • services/src/main/java/fr/ird/observe/services/gson/ObserveHttpErrorAdapter.java deleted
    1
    -package fr.ird.observe.services.gson;
    
    2
    -
    
    3
    -/*-
    
    4
    - * #%L
    
    5
    - * ObServe :: Services
    
    6
    - * %%
    
    7
    - * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
    
    8
    - * %%
    
    9
    - * This program is free software: you can redistribute it and/or modify
    
    10
    - * it under the terms of the GNU General Public License as
    
    11
    - * published by the Free Software Foundation, either version 3 of the
    
    12
    - * License, or (at your option) any later version.
    
    13
    - * 
    
    14
    - * This program is distributed in the hope that it will be useful,
    
    15
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    - * GNU General Public License for more details.
    
    18
    - * 
    
    19
    - * You should have received a copy of the GNU General Public
    
    20
    - * License along with this program.  If not, see
    
    21
    - * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    - * #L%
    
    23
    - */
    
    24
    -
    
    25
    -import com.google.gson.JsonDeserializationContext;
    
    26
    -import com.google.gson.JsonDeserializer;
    
    27
    -import com.google.gson.JsonElement;
    
    28
    -import com.google.gson.JsonObject;
    
    29
    -import com.google.gson.JsonParseException;
    
    30
    -import fr.ird.observe.services.http.ObserveHttpError;
    
    31
    -import java.lang.reflect.Type;
    
    32
    -
    
    33
    -/**
    
    34
    - * @author Sylvain Bavencoff - bavencoff@codelutin.com
    
    35
    - */
    
    36
    -public class ObserveHttpErrorAdapter implements JsonDeserializer<ObserveHttpError> {
    
    37
    -    @Override
    
    38
    -    public ObserveHttpError deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    
    39
    -
    
    40
    -        JsonObject jsonObject = json.getAsJsonObject();
    
    41
    -
    
    42
    -        Integer httpCode = context.deserialize(jsonObject.get(ObserveHttpError.PROPERTY_HTTP_CODE), Integer.class);
    
    43
    -
    
    44
    -        String message = context.deserialize(jsonObject.get(ObserveHttpError.PROPERTY_MESSAGE), String.class);
    
    45
    -
    
    46
    -        Class exceptionType = context.deserialize(jsonObject.get(ObserveHttpError.PROPERTY_EXECPTION_TYPE), Class.class);
    
    47
    -
    
    48
    -        Throwable exception = null;
    
    49
    -
    
    50
    -        if (exceptionType != null) {
    
    51
    -
    
    52
    -            exception = context.deserialize(jsonObject.get(ObserveHttpError.PROPERTY_EXCEPTION), exceptionType);
    
    53
    -
    
    54
    -        }
    
    55
    -
    
    56
    -        return new ObserveHttpError(httpCode, exceptionType, message, exception);
    
    57
    -    }
    
    58
    -}

  • services/src/main/java/fr/ird/observe/services/http/ObserveHttpError.java deleted
    1
    -package fr.ird.observe.services.http;
    
    2
    -
    
    3
    -/*-
    
    4
    - * #%L
    
    5
    - * ObServe :: Services
    
    6
    - * %%
    
    7
    - * Copyright (C) 2008 - 2017 IRD, Code Lutin, Ultreia.io
    
    8
    - * %%
    
    9
    - * This program is free software: you can redistribute it and/or modify
    
    10
    - * it under the terms of the GNU General Public License as
    
    11
    - * published by the Free Software Foundation, either version 3 of the
    
    12
    - * License, or (at your option) any later version.
    
    13
    - * 
    
    14
    - * This program is distributed in the hope that it will be useful,
    
    15
    - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    16
    - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    
    17
    - * GNU General Public License for more details.
    
    18
    - * 
    
    19
    - * You should have received a copy of the GNU General Public
    
    20
    - * License along with this program.  If not, see
    
    21
    - * <http://www.gnu.org/licenses/gpl-3.0.html>.
    
    22
    - * #L%
    
    23
    - */
    
    24
    -
    
    25
    -/**
    
    26
    - * @author Sylvain Bavencoff - bavencoff@codelutin.com
    
    27
    - */
    
    28
    -public class ObserveHttpError {
    
    29
    -
    
    30
    -    public static final String PROPERTY_HTTP_CODE = "httpCode";
    
    31
    -
    
    32
    -    public static final String PROPERTY_EXECPTION_TYPE = "exceptionType";
    
    33
    -
    
    34
    -    public static final String PROPERTY_MESSAGE = "message";
    
    35
    -
    
    36
    -    public static final String PROPERTY_EXCEPTION = "exception";
    
    37
    -
    
    38
    -    protected final Integer httpCode;
    
    39
    -
    
    40
    -    protected final Class<?> exceptionType;
    
    41
    -
    
    42
    -    protected final String message;
    
    43
    -
    
    44
    -    protected final Throwable exception;
    
    45
    -
    
    46
    -    public ObserveHttpError(Integer httpCode, Class<?> exceptionType, String message, Throwable exception) {
    
    47
    -        this.httpCode = httpCode;
    
    48
    -        this.exceptionType = exceptionType;
    
    49
    -        this.message = message;
    
    50
    -        this.exception = exception;
    
    51
    -    }
    
    52
    -
    
    53
    -    public Integer getHttpCode() {
    
    54
    -        return httpCode;
    
    55
    -    }
    
    56
    -
    
    57
    -    public Class<?> getExceptionType() {
    
    58
    -        return exceptionType;
    
    59
    -    }
    
    60
    -
    
    61
    -    public String getMessage() {
    
    62
    -        return message;
    
    63
    -    }
    
    64
    -
    
    65
    -    public Throwable getException() {
    
    66
    -        return exception;
    
    67
    -    }
    
    68
    -}

  • services/src/main/java/fr/ird/observe/services/service/data/seine/FloatingObjectService.java
    ... ... @@ -89,7 +89,7 @@ public interface FloatingObjectService extends ObserveService {
    89 89
         @Write
    
    90 90
         @WriteDataPermission
    
    91 91
         @Post
    
    92
    -    SaveResultDto save(String floatingObjectId, List<FloatingObjectPartDto> dtos);
    
    92
    +    SaveResultDto saveParts(String floatingObjectId, ImmutableSet<FloatingObjectPartDto> floatingObjectParts);
    
    93 93
     
    
    94 94
         @Write
    
    95 95
         @WriteDataPermission