Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

Um die Anbindung eigener Anwendungen an den URN-Service bzw. die URN-Rest-API zu unterstützen, bieten wir einen Java-Client. 

Die Nutzung des Java-Clients erfolgt auf eigene Gefahr. Anpassungen finden nur innerhalb unseres URN-Releases-Prozess statt. 


Folgende Schnittstellen 


UrnNamespaceRepository

Interface for using the query- and creation-methods related to URN-Namespaces.

UrnOrganisationRepository

Interface for using the query-methods related to URN-Organisations.

UrnPoliciesRepository

Interface for using the query-methods related to URN-Policies.

UrnRepository

Interface for REST-API-Entry-Point to get information via RESTApiInfoResource about the URN-REST-API itself.

UrnUrnRepositoryInterface for using the query- and creation-methods related to URNs.

...

Info
titleBeispielantwort mittels toString() und Log4j

[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - getUrns()...
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.RESTUrnResource - Response in CheckedFunction is: 200
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - You will only see information enabled for your login.
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - Request successful: true Count results: 4 Results have several pages: true
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest -
These items are on the first resultpage:
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest -
urn:nbn:de:0135-2301201121028.86502742928,
2023-01-20T10:21:36.660Z,
2023-01-20T10:21:36.660Z,
http://api.nbn-resolving.org.test/v2/urns/urn/urn:nbn:de:0135-2301201121028.86502742928/my-urls,
http://api.nbn-resolving.org.test/v2/namespaces/name/urn:nbn:de:0135,
null,

[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest -
urn:nbn:de:0143-2305191057333.414036554117,
2023-05-19T08:57:58.087Z,
2023-05-19T08:57:58.087Z, http://api.nbn-resolving.org.test/v2/urns/urn/urn:nbn:de:0143-2305191057333.414036554117/my-urls,
http://api.nbn-resolving.org.test/v2/namespaces/name/urn:nbn:de:0143,
null,
....
....
....
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - End of first page...

[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - Response End...

...

getUrnSuggestions()

Ein berechtigter Nutzer fügt dem URN-System eine neue URN samt URLs hinzulässt sich URN-Namen für den eigenen Namensraum vorschlagen.

Notwendige Parameter sind wieder ORG_LOGIN, ORG_PASSWORD, Identifier der zu suchenden Organisation. Der letzte Parameter ist nur für Admins relevant (runAs) und kann leer bleiben. Name des betreffenden Namensraumes (ORG_NAMESPACE). Anzahl der Vorschläge (zw. 1 - 50). 

ORG_LOGIN und ORG_PASSWORD sind Platzhalter für das eigene LOGIN/PASSWORD.


Codeblock
languagejava
themeEclipse
titlegetUrnSuggestions()
private static final String V2_URI = "http://api.nbn-resolving.org/sandbox/v2/";
private static final String ORG_ID = "19066";
private static UrnNamespaceRestClient naspRepository;

public static void main(String[] args) {
 	   
        naspRepository = new UrnNamespaceRestClient(V2_URI);
        UrnRestResultNamespaceObject suggestResult;
        try {
            suggestResult = naspRepository.suggestUrnName(ORG_USER, ORG_PASSW, ORG_NAMESPACE, "2");
                    
        } catch (final UrnRestApiNotAvailableException e) {
            System.out.println("The client cannot connect to the URN-REST-API.");
        }

}


Diese Anfrage liefert ein Ergebnisobjekt vom Typ UrnRestResultNamespaceObject. Das UrnRestResultNamespaceObject "wrapt" die ursprünglichen RESTNamespaceRepresentation-Objekte und fügt weitere wichtige Informationen hinzu (Anfrage erfolgreich, Anzahl Treffer, weitere Trefferseiten verfügbar, ...). In diesem Fall ist nur die ArrayList mit den generierten URN-Namen relevant.

Info
titleBeispielantwort mittels toString() und Log4j

[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - getUrnSuggestions()...
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - UrnRestResultNamespaceObject
[urnNameSugg=[
urn:nbn:de:0007-2307251300155.775903492814,
urn:nbn:de:0007-2307251300155.902099895923],
toString()=UrnRestResultObject [successful=true, httpStatusCode=200, ]]
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - Response End...


addUrn()

Ein berechtigter Nutzer fügt dem URN-System eine neue URN samt URLs hinzu.

Notwendige Parameter sind wieder ORG_LOGIN, ORG_PASSWORD, Identifier der zu suchenden Organisation. Der letzte Parameter ist nur für Admins relevant (runAs) und kann leer bleiben. 

ORG_LOGINORG_LOGIN und ORG_PASSWORD sind Platzhalter für das eigene LOGIN/PASSWORD.

...

Codeblock
languagejava
themeEclipse
titlegetUrnsaddUrn()
private static final String V2_URI = "http://api.nbn-resolving.org/sandbox/v2/";
private static final String ORG_ID = "19066";

public static void main(String[] args) {
 	    URI uriEins = null;
        URI orgaId = null;
        URI uriZwei = null;
        String urnString = "urn:nbn:de:0007-2307251255492.453473381209";

        try {
            uriEins = new URI("https://test/forUrnClient_1.pdf");
            uriZwei = new URI("https://test/fforUrnClient_2.docx");
            orgaId = new URI(V2_URI + "organisations/id/" + ORG_ID);
        } catch (final URISyntaxException e) {
            System.out.println("URI Syntax not conform to RFC.");
        }

        final List<de.dnb.resolvingdienste.urnadministration.urn.restapi.model.RESTCreateUrlRequest> requestsListUrls = new ArrayList<RESTCreateUrlRequest>();

        UrnRestResultUrnObject response = null;

         requestsListUrls.add(RESTCreateUrlRequestWithDefaultsBuilder.aRESTCreateUrlRequest().withOrganisation(orgaId)
                .withUrl(uriEins).build());

        requestsListUrls.add(RESTCreateUrlRequestWithDefaultsBuilder.aRESTCreateUrlRequest().withOrganisation(orgaId)
                .withUrl(uriZwei).build());

        final de.dnb.resolvingdienste.urnadministration.urn.restapi.model.RESTCreateUrnRequest createRequest = RESTCreateUrnRequestWithDefaultsBuilder
                .aRESTCreateUrnRequest()
                .withUrn(urnString).withUrls(requestsListUrls).build();

        try {
            response = urnUrnRepository.addNewUrn(ORG_USER, ORG_PASSW, createRequest, ORG_USER);
        } catch (final UrnRestApiNotAvailableException e1) {
             System.out.println("The client cannot connect to the URN-REST-API.");
        }       
}

...