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. |
| UrnUrnRepository | Interface for using the query- and creation-methods related to URNs. |
...
| Info | ||
|---|---|---|
| ||
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - getUrns()... [main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - [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 | ||||||
|---|---|---|---|---|---|---|
| ||||||
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 | ||
|---|---|---|
| ||
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - getUrnSuggestions()... |
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 | ||||||
|---|---|---|---|---|---|---|
| ||||||
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.");
}
} |
...