Project

General

Profile

« Previous | Next » 

Revision 50075

1. Update pom
2. New method on repository api ( update values on registration )

View differences:

modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApi.java
8 8
import io.swagger.annotations.Api;
9 9
import org.json.JSONException;
10 10
import org.springframework.http.MediaType;
11
import org.springframework.web.bind.annotation.RequestMapping;
12
import org.springframework.web.bind.annotation.RequestMethod;
13
import org.springframework.web.bind.annotation.ResponseBody;
14
import org.springframework.web.bind.annotation.RestController;
11
import org.springframework.web.bind.annotation.*;
15 12

  
16 13
import java.util.List;
17 14
import java.util.Map;
......
70 67
    @RequestMapping(value = "/addRepository", method = RequestMethod.POST,
71 68
            consumes = MediaType.APPLICATION_JSON_VALUE)
72 69
    @ResponseBody
73
    void addRepository( String params) throws Exception;
70
    void addRepository( String datatype,Repository repository) throws Exception;
74 71

  
72

  
75 73
    @RequestMapping(value = "/deleteInterface", method = RequestMethod.DELETE)
76 74
    @ResponseBody
77 75
    void deleteRepositoryInterface(String id);
......
79 77
    @RequestMapping(value = "/addInterface", method = RequestMethod.POST,
80 78
            consumes = MediaType.APPLICATION_JSON_VALUE)
81 79
    @ResponseBody
82
    RepositoryInterface addRepositoryInterface(String params) throws JSONException;
80
    RepositoryInterface addRepositoryInterface(String datatype,
81
                                               String repoId,
82
                                               RepositoryInterface iFace) throws JSONException;
83 83

  
84 84
    @RequestMapping(value = "/getDnetCountries", method = RequestMethod.GET,
85 85
            produces = MediaType.APPLICATION_JSON_VALUE)
modules/uoa-repository-manager-service/src/main/java/eu/dnetlib/repo/manager/service/controllers/RepositoryApiImpl.java
29 29
import org.springframework.web.util.UriComponentsBuilder;
30 30

  
31 31
import javax.annotation.PostConstruct;
32
import javax.ws.rs.Path;
33
import javax.ws.rs.QueryParam;
32 34
import java.io.IOException;
33 35
import java.sql.Timestamp;
34 36
import java.text.Normalizer;
......
175 177
                    .build().expand(page, size).encode();
176 178
            rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
177 179
        }
178
        for (Repository r : resultSet)
180
        for (Repository r : resultSet){
181
            r.setInterfaces(this.getRepositoryInterface(r.getId()));
179 182
            r.setCountryName(getCountryName(r.getCountryCode()));
183
        }
184

  
180 185
        return resultSet;
181 186
    }
182 187

  
......
288 293
    }
289 294

  
290 295
    @Override
291
    public void addRepository(@RequestBody String params) throws Exception {
296
    public void addRepository(@RequestParam("datatype") String datatype,
297
                              @RequestBody Repository repository) throws Exception {
292 298

  
293
        JSONObject json_params = new JSONObject(params);
299
        /*JSONObject json_params = new JSONObject(params);
294 300
        String datatype = json_params.getString("datatype");
295 301
        String json_repository = json_params.getString("repository");
296
        Repository repository = null;
302
        Repository repository = null;*/
297 303
        ObjectMapper mapper = new ObjectMapper();
298 304
        mapper.disable(DeserializationFeature.FAIL_ON_UNK‌​NOWN_PROPERTIES);
299 305
        try {
300
            LOGGER.debug("repository -> " + json_repository);
301
            repository = mapper.readValue(json_repository, Repository.class);
306
            String json_repo = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(repository);
307
            LOGGER.debug("repository -> " + json_repo);
308
          //  repository = mapper.readValue(json_repository, Repository.class);
302 309
        } catch (Exception e) {
303 310
            LOGGER.debug("Error parsing repository ", e);
304 311
            throw  e;
305 312
        }
306

  
307 313
        repository = this.setRepositoryFeatures(datatype,repository);
308 314

  
309 315
        LOGGER.debug("storing " + datatype + " repository with id: " + repository.getId());
......
320 326
                }
321 327
            }
322 328
        } else {
323
            this.updateRegisteredByValue(repository.getId(),repository.getRegisteredBy());
329
            this.updateRepository(repository);
324 330
        }
325 331

  
326 332
        LOGGER.debug("Inserting Interfaces");
......
341 347
        }
342 348
    }
343 349

  
350
    private void updateRepository(Repository repository) {
351
        this.updateRegisteredByValue(repository.getId(),repository.getRegisteredBy());
352
        this.updateEnglishName(repository.getId(),repository.getEnglishName());
353
        this.updateLogoUrl(repository.getId(),repository.getLogoUrl());
354
        this.updateTimezone(repository.getId(), String.valueOf(repository.getTimezone()));
355
        //TODO update datasource type
356
    }
357

  
344 358
    private void updateRegisteredByValue(String id, String registeredBy) {
345 359

  
346 360
        LOGGER.debug("Updating registered by value with  : " + registeredBy );
......
470 484
    }
471 485

  
472 486
    @Override
473
    public RepositoryInterface addRepositoryInterface(@RequestBody String params) throws JSONException {
487
    public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
488
                                                      @RequestParam("repoId") String repoId,
489
                                                      @RequestBody RepositoryInterface repositoryInterface) throws JSONException {
474 490

  
475
        JSONObject json_params = new JSONObject(params);
476

  
477
        LOGGER.debug(params);
491
     /*   JSONObject json_params = new JSONObject(params);
492
       // LOGGER.debug(params);
478 493
        //TODO iFace parameter from gui. Object to json
479 494
        String datatype = json_params.getString("datatype");
480 495
        String repoId = json_params.getString("repoId");
......
486 501
            iFace = mapper.readValue(json_iFace, RepositoryInterface.class);
487 502
        } catch (Exception e1) {
488 503
            LOGGER.debug("Error parsing repository interface ", e1);
489
        }
490

  
491
        return registerRepositoryInterface(repoId,iFace,datatype);
504
        }*/
505
        return registerRepositoryInterface(repoId,repositoryInterface,datatype);
492 506
    }
493 507

  
494 508
    private RepositoryInterface registerRepositoryInterface(String repoId, RepositoryInterface iFace, String datatype) {
modules/uoa-repository-manager-service/src/main/webapp/WEB-INF/applicationContext.xml
14 14

  
15 15
    <!-- <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>-->
16 16

  
17
      <import resource="classpath:META-INF/cxf/cxf.xml"/>
17
    <import resource="classpath:META-INF/cxf/cxf.xml"/>
18 18

  
19 19
     <import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml"/>
20 20
     <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
......
31 31
     <import resource="classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"/>
32 32

  
33 33
     <import resource="classpath*:/eu/dnetlib/repos/springContext-repos-dms-cached.xml"/>
34

  
35 34
    <context:property-placeholder location="classpath*:/eu/**/application.properties" />
36 35

  
37 36
    <bean class="eu.dnetlib.repo.manager.service.config.CascadingPropertyLoader" id="propertyLoader">
......
91 90
    <mvc:resources mapping="swagger-ui.html" location="classpath:/META-INF/resources/"/>
92 91
    <mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
93 92
    <bean class="eu.dnetlib.repo.manager.service.config.SwaggerConfig"/>
94
</beans>
93
</beans>
modules/uoa-repository-manager-service/pom.xml
35 35
                    <failOnMissingWebXml>false</failOnMissingWebXml>
36 36
                </configuration>
37 37
            </plugin>
38
           <!-- <plugin>
38
            <!--<plugin>
39 39
                <groupId>cz.habarta.typescript-generator</groupId>
40 40
                <artifactId>typescript-generator-maven-plugin</artifactId>
41
                <version>1.27.339</version>
41
                <version>1.29.366</version>
42 42
                <executions>
43 43
                    <execution>
44 44
                        <id>generate1</id>
......
214 214
        <dependency>
215 215
            <groupId>io.springfox</groupId>
216 216
            <artifactId>springfox-swagger-ui</artifactId>
217
            <version>2.7.1-SNAPSHOT</version>
217
            <version>2.7.0</version>
218 218
        </dependency>
219

  
220
        <!-- https://mvnrepository.com/artifact/cz.habarta.typescript-generator/typescript-generator-maven-plugin -->
221
        <dependency>
222
            <groupId>cz.habarta.typescript-generator</groupId>
223
            <artifactId>typescript-generator-maven-plugin</artifactId>
224
            <version>1.29.366</version>
225
        </dependency>
226

  
227

  
219 228
    </dependencies>
220 229

  
221
    <repositories>
222
        <repository>
223
            <id>jcenter-snapshots</id>
224
            <name>jcenter</name>
225
            <url>http://oss.jfrog.org/artifactory/oss-snapshot-local/</url>
226
        </repository>
227
    </repositories>
228

  
229
</project>
230
</project>

Also available in: Unified diff