Skip navigation links

Package fr.cnes.doi.resource.mds

Provides resources for Meta Data Store application.

See: Description

Package fr.cnes.doi.resource.mds Description

Provides resources for Meta Data Store application. The DoiMdsApplication is the main DOI application that brings together a set of resources handling the life of DOIs.

An application is instantiated only once when the server starts. On the contrary a resource is instantiated at each call. The DoiMdsApplication routes the different resources according to an URI.

Some of the above resources are protected by several mechanism. This mechanism is defined as a pipeline: The clientMDS implements the call to DataCite. This clients supports the proxy by the use of HttpDOIClientHelper plugin. This plugin is registered by default when the method BaseClient.getClient() is used. The proxy parameters are automatically set from the config.properties by the use of ProxySettings MDS application

How to create a DOI

Here are the different steps to create a DOI: As below, an example of a code to create a DOI.
 
      // 1 - Upload the metadata
      // -------------------

      // Prepare the request
      ClientResource client = new ClientResource("http://localhost:" + port + METADATA_SERVICE);
      // Set the login/pwd for basic authentication
      client.setChallengeResponse(
          new ChallengeResponse(ChallengeScheme.HTTP_BASIC, "malapert", "pwd")
      );
      // Set the project identifier (which is a part of the DOI) for authorisation
      reqAttribs = client.getRequestAttributes();
      headers = (Series) reqAttribs.get(RESTLET_HTTP_HEADERS);
      if (headers == null) {
          headers = new Series<>(Header.class);
          reqAttribs.put(RESTLET_HTTP_HEADERS, headers);
      }
      headers.add(UtilsHeader.SELECTED_ROLE_PARAMETER, "828606");
      // Request the metadata service
      try {
          Representation rep = client.post(
              new StringRepresentation(this.doiMetadata, MediaType.APPLICATION_XML)
          );
      } catch (ResourceException ex) {
      } finally {
          client.release();
      }

      // 2 - now we need to upload the landing page URL
      //------------------------------------------------

      // Create the first input parameter : DOI
      Form doiForm = new Form();
      doiForm.add(
          new Parameter(
              DoisResource.DOI_PARAMETER,
              "10.5072/828606/8c3e91ad45ca855b477126bc073ae44b"
          )
      );
      // Create the second input parameter : landing page
      doiForm.add(new Parameter(DoisResource.URL_PARAMETER, "http://www.cnes.fr"));

      // Prepare the query
      String port = DoiSettings.getInstance().getString(Consts.SERVER_HTTP_PORT);
      client = new ClientResource("http://localhost:" + port + DOIS_SERVICE);
      // Set the login/password
      client.setChallengeResponse(
          new ChallengeResponse(
              ChallengeScheme.HTTP_BASIC,
              "malapert",
              "pwd"
          )
      );
      // Define the role based on the project identifier
      final String RESTLET_HTTP_HEADERS = "org.restlet.http.headers";
      Map<String, Object> reqAttribs = client.getRequestAttributes();
      Series headers = (Series) reqAttribs.get(RESTLET_HTTP_HEADERS);
      if (headers == null) {
          headers = new Series<>(Header.class);
          reqAttribs.put(RESTLET_HTTP_HEADERS, headers);
      }
      headers.add(UtilsHeader.SELECTED_ROLE_PARAMETER, "828606");

      // Make the request
      try {
          Representation rep = client.post(doiForm);
      } catch (ResourceException ex) {
      } finally {
          client.release();
      }
 
 
See Also:
Architecture definition
Skip navigation links

Copyright © 2017–2020 CNES. All rights reserved.