Skip to main content
Version: ADONIS 16/ADOIT 17/ADOGRC 13

Inspect an artifact's data

This article shows how to use the ADOXX API to retrieve data for a specific object.

The Java snippet below will fetch the details for an ArchiMate artifact object whose ID we retrieved (e.g. via a search call) and for which we now want to retrieve details about the object itself and the objects that are served by this artifact.

note

The Java snippet below uses Basic Authentication.

Replace the values in angle brackets with values that fit your setup, e.g. instead of <HOST> use the host at which you access your ADOXX instance.

Click to view the code!

Source Code

public class GetArtifactData
{
public static void main (final String [] args) throws ClientProtocolException, IOException
{
final CloseableHttpClient aClient = HttpClients.createDefault ();

final String sUser = "<USER>";
final String sPass = "<PASSWORD>";
final String sRepoID = "<REPO_ID>";
final String sArtifactID = "<ARTIFACT_ID>";
String sPath = "http://<HOST>:<PORT>/ADOIT/rest/2.0/repos/" +
sRepoID +
"/objects/" +
sArtifactID +
"?";

final List <Entry <String, String>> aSearchParameters = new ArrayList <Map.Entry <String, String>> ();
aSearchParameters.add (new AbstractMap.SimpleEntry <> ("attribute", "NAME"));
aSearchParameters.add (new AbstractMap.SimpleEntry <> ("attribute", "A_DESCRIPTION"));
aSearchParameters.add (new AbstractMap.SimpleEntry <> ("relation", "RC_SERVING"));

// Iterate through the search parameters and construct the URL
for (final Entry <String, String> aParam : aSearchParameters)
{
final String sParamName = aParam.getKey ();
final String sParamValue = aParam.getValue ();
sPath += sParamName + "=" + URLEncoder.encode (sParamValue, "UTF-8") + "&";
}
final HttpGet aMethod = new HttpGet (sPath);

// The headers controlling the return type and the language do not have to be considered for
// token generation
aMethod.addHeader ("Accept", "application/json");
aMethod.addHeader ("Accept-Language", "en");

// Construction of the header to pass the basic authentication information
aMethod.addHeader ("Authorization",
"Basic " +
DatatypeConverter.printBase64Binary ((sUser + ":" + sPass).getBytes ()));

final CloseableHttpResponse aResponse = aClient.execute (aMethod);

try
{
final String sResult = EntityUtils.toString (aResponse.getEntity (), "UTF-8");
final StatusLine aStatusLine = aResponse.getStatusLine ();
System.out.println ("Status Code: " + aStatusLine.getStatusCode ());
System.out.println ("Result: \n" + sResult);
}
catch (final Exception aEx)
{
aEx.printStackTrace ();
}
finally
{
aResponse.close ();
}
}
}

The result should look similar to the following:

Status Code: 200
Result:
{
"locale": "en",
"item": {
"rest_links": [ ... ],
"id": " ... ",
"name": " ... ",
"type": " ... ",
"artefactType": " ... ",
"metaName": " ... ",
"link": { ... },
"icon": { ... },
"attributes": [ ... ],
"relations": [
{
"name": " ... ",
"metaName": " ... ",
"targets": [ ... ]
},
...
]
}
}