Um die Anbindung eigener Anwendungen an den URN-Service bzw. die URN-Rest-API zu unterstützen, bieten wir einen Java-Client.
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. |
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:
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(); } |
liefert ein Objekt vom Typ ApiInfo mit folgenden Output (info.toString() ):
ApiInfo [ self=http://api.nbn-resolving.org/sandbox/v2/, ] |
Um die Namensräume gezielt abfragen zu können, werden Filter- und Sortierparameter benötigt.
ORG_LOGIN und ORG_PASSWORD sind Platzhalter für das eigene LOGIN/PASSWORD.
private static final String V2_URI = "http://api.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."); } } |
Diese Anfrage liefert ein Ergebnisobjekt vom Typ UrnRestResultNamespaceObject. Das UrnRestResultNamespaceObject "wrapt" das ursprüngliche RESTNamespaceRepresentation-Objekt und fügt weitere wichtige Informationen hinzu (Anfrage erfolreich, Anzahl Treffer, weitere Trefferseiten verfügbar, ...).Die Ergebnisse werden paginiert innerhalb einer ArrayList abgespeichert.
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - You will only see information enabled for your login. .... .... .... |
Führt eine Suche nach einem bestimmten Namensraum durch.
Notwendige Parameter sind wieder ORG_LOGIN, ORG_PASSWORD, Name des zu suchenden Namespace. Der letzte Parameter ist nur für Admins relevant (runAs) und kann leer bleiben.
private static final String V2_URI = "http://api.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..."); } |
Diese Anfrage liefert ein Ergebnisobjekt vom Typ UrnRestResultNamespaceObject. Die Ergebnisse werden paginiert ausgeliefert. Das UrnRestResultNamespaceObject "wrapt" das ursprüngliche RESTNamespaceRepresentation-Objekt und fügt weitere wichtige Informationen hinzu (Anfrage erfolreich, Anzahl Treffer, weitere Trefferseiten verfügbar, ...)
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - getNamespace()... |
Führt eine Suche nach einer bestimmten Organisation durch.
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.
private static final String V2_URI = "http://api.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."); } } |
Diese Anfrage liefert der Einfachheit halber ein Ergebnisobjekt vom Typ UrnRestResultOrganisationObject zurück. Das eigentliche Ergebnis ist vom Typ RESTOrganisationRepresentation. Das UrnRestResultOrganisationObject "wrapt" das ursprüngliche RESTOrganisationRepresentation -Objekt und fügt weitere Informationen hinzu (Anfrage erfolgreich, Statuscode)
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - getUrn()... |
Verwandte Artikel erscheinen hier basierend auf den Stichwörtern, die Sie auswählen. Klicken Sie, um das Makro zu bearbeiten und Stichwörter hinzuzufügen oder zu ändern.
|