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/
    /urn-suggestion
    ").

Implementierungen

...

Anker
urnrestclient
urnrestclient
URNRestClient


Codeblock
languagejava
themeEclipse
private static final String V2_URI = "httphttps://apisandbox.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=httphttps://apisandbox.nbn-resolving.org/sandbox/v2/,
version=4.2.7,
admins=httphttps://apisandbox.nbn-resolving.org/sandbox/v2/admins,
namespaces=httphttps://apisandbox.nbn-resolving.org/sandbox/v2/namespaces,
organisations=httphttps://apisandbox.nbn-resolving.org/sandbox/v2/organisations,
validationPolicies=httphttps://apisandbox.nbn-resolving.org/sandbox/v2/policies/urn-naming,
urlPolicies=httphttps://apisandbox.nbn-resolving.org/sandbox/v2/policies/url,
urns=httphttps://apisandbox.nbn-resolving.org/sandbox/v2/urns,
documentation=httphttps://apisandbox.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. 

...

Codeblock
languagejava
themeEclipse
titlegetNamespaces()
private static final String V2_URI = "httphttps://apisandbox.nbn-resolving.org/sandbox/v2/";
private static final String DEFAULT_NASP_WILDCARD = "urn:nbn:de*";
private static UrnNamespaceRestClient naspRepository;


public static void main(String[] args) {
 	naspRepository = new UrnNamespaceRestClient(V2_URI);
	
	  final Optional<NamespaceFilter> naspFilter = Optional
                .of(new NamespaceFilter(NamespaceFilterKey.NAME, DEFAULT_NASP_WILDCARD));
        final NamespaceSortParameters naspsortparams = new NamespaceSortParameters().getDefault();
        naspsortparams.setSortBy(NamespaceSortKey.NAME);
        final PagingParameters pagingParameters = new PagingParameters().getDefault();

        UrnRestResultNamespaceObject result = null;

        try {
            result = naspRepository.getNamespacesWithFilter(ORG_LOGIN, ORG_PASSWORD, naspFilter, naspsortparams,
                    pagingParameters);
        } catch (final UrnRestApiNotAvailableException e) {
            System.out.println("The client cannot connect to the URN-REST-API.");
        }
}

...

Info
titleBeispielantwort mittels toString() und Log4j

[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: 428 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,
2003-10-01T06:00:00Z,
2006-04-25T09:36:22Z,
httphttps://apisandbox.nbn-resolving.org/sandbox/v2/organisations/id/1,
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest -
urn:nbn:de:0001,
2003-10-17T12:39:18Z,
2003-10-17T12:39:18Z,
httphttps://apisandbox.nbn-resolving.org/sandbox/v2/organisations/id/35,
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest -
urn:nbn:de:0002,
2003-10-17T12:36:50Z,
2003-10-17T12:36:50Z,
httphttps://apisandbox.nbn-resolving.org/sandbox/v2/organisations/id/22,

....

....

....

Suche nach einem bestimmten Namensraum mittels Namen

...

Codeblock
languagejava
themeEclipse
titlegetNamespace()
private static final String V2_URI = "httphttps://apisandbox.nbn-resolving.org/sandbox/v2/";
private static final String DEFAULT_NASP_WILDCARD = "urn:nbn:de*";
private static final String ORG_NAMESPACE = "urn:nbn:de:0007";
private static UrnNamespaceRestClient naspRepository;


public static void main(String[] args) {
 	naspRepository = new UrnNamespaceRestClient(V2_URI);
	
	UrnRestResultNamespaceObject result = null;

        try {
            result = naspRepository.getNamespaceViaName(ORG_LOGIN, ORG_PASSWORD, ORG_NAMESPACE, ORG_USER);
        } catch (final UrnRestApiNotAvailableException e) {
            System.out.println("The client cannot connect to the URN-REST-API.");
        }

        LOGGER.info("Response End...");
}

...

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=httphttps://apisandbox.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=httphttps://apisandbox.nbn-resolving.org/sandboxv2/v2/organisations/id/19066,
urnNamingPolicy=httphttps://apisandbox.nbn-resolving.org/sandbox/v2/policies/urn-naming/id/default,
urlPolicy=httphttps://apisandbox.nbn-resolving.org/sandbox/v2/policies/url/id/only-http-ftp,
urns=httphttps://apisandbox.nbn-resolving.org/sandbox/v2/namespaces/name/urn:nbn:de:0007/urns,
urnSuggestion=httphttps://apisandbox.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

...

Codeblock
languagejava
themeEclipse
titlegetOrganisationById()
private static final String V2_URI = "httphttps://apisandbox.nbn-resolving.org/sandbox/v2/";
private static UrnOrganisationRestClient orgRepository;

public static void main(String[] args) {
 	orgRepository = new UrnOrganisationRestClient(V2_URI);
	
	 UrnRestResultOrganisationObject resultObject = null;
        try {
            resultObject = orgRepository.getOrganisationByLogin(ORG_USER, ORG_PASSW, ORG_USER, ORG_USER);
        } catch (final UrnRestApiNotAvailableException e) {
            System.out.println("The client cannot connect to the URN-REST-API.");
        }
}

...

Info
titleBeispielantwort mittels toString() und Log4j

[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - getOrganisationByID()...
[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 [
getOrganisation()=RESTOrganisationRepresentation [
self=httphttps://apisandbox.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,
address=RESTAddress [street=TestClientDorfweg 1, postcode=12111, city=TestClient Dorf, country=TestClient Republik],
comment=null,
primaryContactSurname=null,
primaryContactForename=null,
primaryContactEmail=null,
primaryContactPhone=null,
primaryContactFunction=null,
primaryContactComment=null,
contacts=null,
namespaces=httphttps://apisandbox.nbn-resolving.org/sandbox/v2/organisations/id/19068/namespaces],
toString()=UrnRestResultObject [successful=true, httpStatusCode=200, ]]
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - Response End...

...

Codeblock
languagejava
themeEclipse
titlegetOrganisationWithFilter()
private static final String V2_URI = "httphttps://apisandbox.nbn-resolving.org/sandbox/v2/";
 private static UrnOrganisationRepository orgRepository;

public static void main(String[] args) {
 	orgRepository = new UrnOrganisationRestClient(V2_URI);
	
	    final Optional<OrganisationFilter> orgFilter = Optional
                .of(new OrganisationFilter(OrganisationFilterKey.NAME, "Test*"));

        UrnRestResultOrganisationObject resultObject = null;
        try {
            resultObject = orgRepository.getOrganisationsWithParams(ORG_LOGIN , ORG_PASSWORD , orgFilter,
                    new OrganisationSortParameters(), new PagingParameters());
        } catch (final UrnRestApiNotAvailableException e) {
            System.out.println("The client cannot connect to the URN-REST-API.");
        }
}

...

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=httphttps://apisandbox.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=httphttps://apisandbox.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=httphttps://apisandbox.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
titlegetUrns()
private static final String V2_URI = "httphttps://apisandbox.nbn-resolving.org/sandbox/v2/";
private static final String DEFAULT_URN_WILDCARD = "urn:nbn:de:01*";
private static UrnUrnRestClient urnUrnRepository;

public static void main(String[] args) {
 	    urnUrnRepository = new UrnUrnRestClient(V2_URI);
	
	    final Optional<UrnFilter> urnFilter = Optional.of(new UrnFilter(UrnFilterKey.URN, DEFAULT_URN_WILDCARD));
        final UrnSortParameters urnsortparams = new UrnSortParameters().getDefault();
        final PagingParameters pagingParameters = new PagingParameters().getDefault();

        UrnRestResultUrnObject result = null;

        try {
            result = urnUrnRepository.getUrnsWithParams(ORG_LOGIN, ORG_PASSWORD, urnFilter, urnsortparams,
                    pagingParameters);
            logUrnRestResultUrnObjectToString(result);
            
        } catch (final UrnRestApiNotAvailableException e) {
           System.out.println("The client cannot connect to the URN-REST-API.");
        }

}

...

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,
httphttps://api.nbn-resolving.org.test/v2/urns/urn/urn:nbn:de:0135-2301201121028.86502742928/my-urls,
httphttps://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, httphttps://api.nbn-resolving.org.test/v2/urns/urn/urn:nbn:de:0143-2305191057333.414036554117/my-urls,
httphttps://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...

...

Codeblock
languagejava
themeEclipse
titlegetUrnSuggestions()
private static final String V2_URI = "httphttps://apisandbox.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.");
        }

}

...

Codeblock
languagejava
themeEclipse
titleaddUrn()
private static final String V2_URI = "httphttps://apisandbox.nbn-resolving.org/sandbox/v2/";
private static final String ORG_ID = "19066";
private static UrnUrnRestClient urnUrnRepository;

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.");
        }       
}

...

Info
titleBeispielantwort mittels toString() und Log4j

[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - addUrn()...
[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 -
urn:nbn:de:0007-2307251255492.453473381209,
2023-07-25T10:55:49.584Z,
2023-07-25T10:55:49.584Z,
httphttps://apisandbox.nbn-resolving.org/sandbox/v2/urns/urn/urn:nbn:de:0007-2307251255492.453473381209/my-urls/,
httphttps://apisandbox.nbn-resolving.org/sandbox/v2/namespaces/name/urn:nbn:de:0007namespaces/name/urn:nbn:de:0007,
null,
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - Response End...

...

Codeblock
languagejava
themeEclipse
titlecreateUrl()
private static final String V2_URI = "httphttps://apisandbox.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 urineu = null;
        URI orgaId = null;

        try {
            urineu = new URI("https://testUri/forClient_3".pdf");
            orgaId = new URI(V2_URI + "organisations/id/" + ORG_ID);
        } catch (final URISyntaxException e) {
            System.out.println("URI Syntax not conform to RFC.");
        }

        final RESTCreateUrlRequest createUrlRequest = new RESTCreateUrlRequest();
        createUrlRequest.setUrl(urineu);
        createUrlRequest.setOwner(orgaId);

        UrnRestResultUrlObject restCallresponse = null;
        try {
            restCallresponse = urnUrnRepository.addNewUrl(ORG_USER, ORG_PASSW, URN_NAME , createUrlRequest, "");
        } catch (final UrnRestApiNotAvailableException e) {
            System.out.println("The client cannot connect to the URN-REST-API.");
        }


}

...

Info
titleBeispielantwort mittels toString() und Log4j

[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - UrnRestResultUrlObject [
singleUrl=RESTUrlRepresentation[
self=httphttps://apisandbox.nbn-resolving.org/sandbox/v2/urns/urn/urn:nbn:de:0007-2307251300155.775903492814/urls/base64/aHR0cHM6Ly90ZXN0VXJpL2ZvckNsaWVudC9WdnlNcS5wZGY=,
url=https://testUri/forClient/VvyMq.pdf,
created=2023-07-25T12:16:14.695Z,
lastModified=2023-07-25T12:16:14.695Z,
urn=null,
owner=httphttps://apisandbox.nbn-resolving.org/sandbox/v2/organisations/id/19066,
priority=126],
toString()=UrnRestResultObject [successful=true, httpStatusCode=201, ]]

...

Codeblock
languagejava
themeEclipse
titleupdateUrl()
private static final String V2_URI = "httphttps://apisandbox.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.");
        }


}

...