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 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 RESTOrganisationRepresentationObjekt ursprüngliche RESTOrganisationRepresentationObjekt und fügt weitere Informationen hinzu (Anfrage erfolgreich, Statuscode). 
Gut zu sehen, ist der Umstand, dass man als Nicht-Admin oder NIchtNicht-Besitzer der Organisation nur eine eingeschränkte Sicht auf die Informationen hat (null-Werte). 

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=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,
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=http://api.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
titlegetNamespaces()
private static final String V2_URI = "http://api.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_USERLOGIN , ORG_PASSWPASSWORD , orgFilter,
                    new OrganisationSortParameters(), new PagingParameters());
        } catch (final UrnRestApiNotAvailableException e) {
            LOGGER.error("The client cannot connect to the server. Is there an internet connection?");
        }
}

...