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, stellen wir einen Java-Client zur Verfügung. 

Die Nutzung des Java-Clients erfolgt auf eigene Gefahr. Anpassungen finden nur innerhalb unseres URN-Release-Prozesses 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.

wurden hier implementiert:

UrnNamespaceRestClient

Entry point for the users of the URN client to access the RESTNamespaceResources.

UrnOrganisationRestClient

Entry point for the users of the URN client to access the RESTOrganisationResource.

UrnPoliciesRestClient

Entry point for the users of the URN client to access the RESTPoliciesResource.

UrnRestClient

Entry point for the users of the URN client to get information via RESTApiInfoResource about the URn-REST-API.

UrnUrnRestClient

Handles the task of making the connections and the requests to the Urn-Service's RestApi.

...

Technische Voraussetzungen:

  • Die Verwendung von Java 8 oder kompatiblere JVM Sprache in der entsprechenden Version.
  • Berechtigung zur Einspielung von URNS der eigenen Institutionen innerhalb des eigenen Namensraumes in Form von LOGIN / USER Credentials.
  • Die URL zur URN-Rest-API (z.B.: "http://api.nbn-resolving.org/sandbox/v2/").

...

Implementierungen

Anker
urnrestclient
urnrestclient
URNRestClient


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

private static UrnRestClient urnRepository;

public static void main(String[] args) {

 	urnRepository = new UrnRestClient(V2_URI); 
	final ApiInfo info = urnRepository.getInfo();
}

...

Info
visibletrue
deckApiInfo
idapiInfo
labelOutput
titleOutput
cardApiInfo

ApiInfo [

self=http://api.nbn-resolving.org/sandbox/v2/,
version=4.2.7,
admins=http://api.nbn-resolving.org/sandbox/v2/admins,
namespaces=http://api.nbn-resolving.org/sandbox/v2/namespaces,
organisations=http://api.nbn-resolving.org/sandbox/v2/organisations,
validationPolicies=http://api.nbn-resolving.org/sandbox/v2/policies/urn-naming,
urlPolicies=http://api.nbn-resolving.org/sandbox/v2/policies/url,
urns=http://api.nbn-resolving.org/sandbox/v2/urns,
documentation=http://api.nbn-resolving.org/sandbox/v2/docs/index.html

]

...


Anker
urnnamespacerestclient
urnnamespacerestclient
UrnNamespaceRestClient

Um die Namensräume gezielt abfragen zu können, werden Filter- und Sortierparameter benötigt. 

...

Info
titleBeispielantwort mittels toString() und Log4j

[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - getNamespace()...
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest -
UrnRestResultNamespaceObject [
urnNameSugg=[],
namespace=RESTNamespaceRepresentation [
self=http://api.nbn-resolving.org/sandbox/v2/namespaces/name/urn:nbn:de:0007,
name=urn:nbn:de:0007,
created=2023-07-11T09:13:37Z,
lastModified=2023-07-11T09:13:37Z,
allowsRegistration=true,
owner=http://api.nbn-resolving.org/sandbox/v2/organisations/id/19066,
urnNamingPolicy=http://api.nbn-resolving.org/sandbox/v2/policies/urn-naming/id/default,
urlPolicy=http://api.nbn-resolving.org/sandbox/v2/policies/url/id/only-http-ftp,
urns=http://api.nbn-resolving.org/sandbox/v2/namespaces/name/urn:nbn:de:0007/urns,
urnSuggestion=http://api.nbn-resolving.org/sandbox/v2/namespaces/name/urn:nbn:de:0007/urn-suggestion],
UrnRestResultObject [successful=true, httpStatusCode=200, ]]
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - Response End...

...

Anker
urnorganisationrestclient
urnorganisationrestclient
UrnOrganisationRestClient

Suche nach bestimmter Organisation mittels Login-Name

...

Info
titleBeispielantwort mittels toString() und Log4j

[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - getOrganisationWithFilter()...
[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 - UrnRestResultOrganisationObject [
getOrganisationsPage()=ResultPage [results=[
RESTOrganisationRepresentation [self=http://api.nbn-resolving.org/sandbox/v2/organisations/id/19068,
id=19068,
login=null,
created=2023-07-12T11:32:29Z,
lastModified=2023-07-12T11:32:29Z,
name=Test Client for Test,
email= testClient-userDorf@example.org,
....
....
....,
RESTOrganisationRepresentation [
self=http://api.nbn-resolving.org/sandbox/v2/organisations/id/12539,
id=12539,
login=null,
created=2003-10-01T06:00:00Z,
lastModified=2021-07-13T13:05:36Z,
name=Testinstitution,
email=test@dnb.de,
address=RESTAddress [street=Teststraße 1, postcode=12345, city=Frankfurt am Main, country=null],
....
....
namespaces=http://api.nbn-resolving.org/sandbox/v2/organisations/id/12539/namespaces]],
resultCount=4,
hasNext=true,
offset=0, count=20],
toString()=UrnRestResultObject [successful=true, httpStatusCode=200, ]]

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

Anker
urnurnrestclient
urnurnrestclient
UrnUrnRestClient

Suche über alle URNs mittels Filter

...

Codeblock
languagejava
themeEclipse
titleupdateUrl()
private static final String V2_URI = "http://api.nbn-resolving.org/sandbox/v2/";
private static final String ORG_ID = "19066";
private static final String URN_NAME = "urn:nbn:de:0007-2307251300155.775903492814";
private static UrnUrnRestClient urnUrnRepository;

public static void main(String[] args) {
 	    URI uriEins = null;
        URI orgaId = null;
        URI uriZwei = null;
       
        try {
            uriEins = new URI("https://testUri/forClient/repl_1".pdf");
            uriZwei = new URI("https://testUri/forClient/repl_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<RESTReplaceUrlRequest> allMyUrls = new ArrayList<RESTReplaceUrlRequest>();

        final RESTReplaceUrlRequest eins = new RESTReplaceUrlRequest();
        eins.setUrl(uriZwei);
        eins.setPriority(1);

        final RESTReplaceUrlRequest zwei = new RESTReplaceUrlRequest();
        zwei.setUrl(uriDrei);
        zwei.setPriority(0);

        allMyUrls.add(eins);
        allMyUrls.add(zwei);

        UrnRestResultObject restCallresponse = null;
        try {
            restCallresponse = urnUrnRepository.updateUrl(ORG_LOGIN, ORG_PASSWORD, URN_NAME , allMyUrls,
                    "");
        } catch (final UrnRestApiNotAvailableException e) {
            System.out.println("The client cannot connect to the URN-REST-API.");
        }


}


Diese Anfrage liefert lediglich ein Ergebnisobjekt vom Typ UrnRestResultObject. In diesem besonderen Fall werden lediglich Information darüber zurückgegeben, ob der Request erfolgreich war.

...