Project

General

Profile

« Previous | Next » 

Revision 60993

param encoding in mdstore creation request

View differences:

modules/dnet-openaireplus-workflows/trunk/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/dhp/CreateMDStoreHadoopJobNode.java
26 26
public class CreateMDStoreHadoopJobNode extends SimpleJobNode {
27 27

  
28 28
    private static final Log log = LogFactory.getLog(CreateMDStoreHadoopJobNode.class);
29
    public static final String MDSTORE_CREATE_URL_AND_PARAMS = "/new/{format}/{layout}/{interpretation}?dsName={dsName}&dsId={dsid}&apiId={apiId}";
29 30

  
30 31
    /* Workflow params */
31 32
    private String format;
......
41 42

  
42 43
    @Override
43 44
    protected String execute(final NodeToken token) throws Exception {
44
        final String url = getMdStoreManagerUrl() + "/new/{format}/{layout}/{interpretation}";
45 45

  
46
        final Map<String, Object> params = new HashMap<>();
47
        params.put("format", getFormat());
48
        params.put("layout", getLayout());
49
        params.put("interpretation", getInterpretation());
50

  
51 46
        final String repositoryId = token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_ID);
52 47
        final String xquery = String.format(
53 48
                "for $x in collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType') \n" +
......
65 60

  
66 61
        log.info(String.format("got OpenAIRE datasource id '%s' for repository profile '%s'", openAireDataSourceId, repositoryId));
67 62

  
68
        final URI uri = UriComponentsBuilder.fromUriString(url)
69
                .queryParam("dsName", token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_NAME))
70
                .queryParam("dsId", openAireDataSourceId)
71
                .queryParam("apiId", token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE))
72
                .buildAndExpand(params)
73
                .toUri();
63
        final String urlTemplate = getMdStoreManagerUrl() + MDSTORE_CREATE_URL_AND_PARAMS;
74 64

  
75
        final String requestUri = uri.toASCIIString();
76
        log.info("create mdstore request: " + requestUri);
77

  
78 65
        final RestTemplate restTemplate = new RestTemplate();
79
        final MDStoreWithInfo result = restTemplate.getForObject(requestUri, MDStoreWithInfo.class);
66
        final MDStoreWithInfo result = restTemplate.getForObject(
67
                urlTemplate,
68
                MDStoreWithInfo.class,
69
                getFormat(),
70
                getLayout(),
71
                getInterpretation(),
72
                token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_NAME),
73
                openAireDataSourceId,
74
                token.getFullEnv().getAttribute(WorkflowsConstants.DATAPROVIDER_INTERFACE));
80 75

  
81 76
        log.info("created mdstore: " + new Gson().toJson(result));
82 77

  

Also available in: Unified diff