Versionen im Vergleich

Schlüssel

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

...

Codeblock
languagejava
themeEclipse
titlegetNamespace()
collapsetrue
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) {
            LOGGERSystem.out.errorprintln("The client cannot connect to the server. Is there an internet connection?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=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...

UrnOrganisationClient

getOrganisationById()

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. 

Codeblock
languagejava
themeEclipse
titlegetNamespace()
collapsetrue
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)

Info
titleBeispielantwort mittels toString() und Log4j

[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - getUrn()...
[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=http://api.nbn-resolving.org/sandbox/v2/organisations/id/19066,
id=19066,
login=Doyle,
created=2023-07-11T09:06:29Z,
lastModified=2023-07-11T09:06:29Z,
name=Test Client for Doyle,
email= testClient-user@example.org,
address=RESTAddress [street=TestClientweg 1, postcode=12345, city=TestClient Stadt, country=TestClient Republik],
comment=null,
primaryContactSurname=Sir Client Tester,
primaryContactForename=Test The Client,
primaryContactEmail=testClient-user@example.org,
primaryContactPhone=+49 69 1000-0,
primaryContactFunction=null,
primaryContactComment=null,
contacts=http://api.nbn-resolving.org/sandbox/v2/organisations/id/19066/contacts,
namespaces=http://api.nbn-resolving.org/sandbox/v2/organisations/id/19066/namespaces],
toString()=UrnRestResultObject [successful=true, httpStatusCode=200, ]]
[main] INFO de.dnb.resolvingdienste.urn.restapi.client.testurnclient.mainForTest - Response End...

...