Search in sources :

Example 1 with GraphInventoryPayloadException

use of org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryPayloadException in project so by onap.

the class HttpLookupUri method getObjectById.

protected String getObjectById(Object id) throws GraphInventoryUriNotFoundException, GraphInventoryPayloadException {
    if (!this.getCachedValue().isPresent()) {
        AAIResourceUri serviceInstanceUri = AAIUriFactory.createNodesUri(aaiType, id).format(Format.PATHED);
        String resultJson;
        try {
            resultJson = this.getResourcesClient().get(serviceInstanceUri, NotFoundException.class).getJson();
        } catch (BadRequestException e) {
            throw new GraphInventoryUriNotFoundException(aaiType.typeName() + " " + id + " not found at: " + serviceInstanceUri.build());
        }
        try {
            cachedValue = extractRelatedLink(resultJson);
            if (!cachedValue.isPresent()) {
                throw new GraphInventoryUriNotFoundException(aaiType.typeName() + " " + id + " not found at: " + serviceInstanceUri.build());
            }
        } catch (IOException e) {
            throw new GraphInventoryPayloadException("could not map payload: " + resultJson, e);
        }
    }
    return cachedValue.get();
}
Also used : GraphInventoryUriNotFoundException(org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriNotFoundException) BadRequestException(javax.ws.rs.BadRequestException) IOException(java.io.IOException) GraphInventoryPayloadException(org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryPayloadException)

Example 2 with GraphInventoryPayloadException

use of org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryPayloadException in project so by onap.

the class HttpLookupUri method build.

@Override
public URI build() {
    try {
        if (this.values.length == 1) {
            String uri = getObjectById(this.values[0]);
            Map<String, String> map = super.getURIKeys(uri);
            this.values = map.values().toArray(values);
            return super.build(values);
        }
    } catch (GraphInventoryUriNotFoundException | GraphInventoryPayloadException e) {
        throw new GraphInventoryUriComputationException(e);
    }
    return super.build();
}
Also used : GraphInventoryUriNotFoundException(org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriNotFoundException) GraphInventoryUriComputationException(org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriComputationException) GraphInventoryPayloadException(org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryPayloadException)

Example 3 with GraphInventoryPayloadException

use of org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryPayloadException in project so by onap.

the class HttpLookupUri method locateAndBuild.

@Override
public URI locateAndBuild() {
    try {
        if (this.values.length == 1) {
            String uri = getObjectById(this.values[0]);
            Map<String, String> map = super.getURIKeys(uri);
            this.values = map.values().toArray(values);
            return super.build(values);
        }
    } catch (GraphInventoryUriNotFoundException | GraphInventoryPayloadException e) {
        throw new GraphInventoryUriComputationException(e);
    }
    return super.build();
}
Also used : GraphInventoryUriNotFoundException(org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriNotFoundException) GraphInventoryUriComputationException(org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriComputationException) GraphInventoryPayloadException(org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryPayloadException)

Example 4 with GraphInventoryPayloadException

use of org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryPayloadException in project so by onap.

the class GraphInventoryPayloadExceptionTest method callConstructorTest.

@Test
public void callConstructorTest() throws Exception {
    GraphInventoryPayloadException test1 = new GraphInventoryPayloadException("testing");
    GraphInventoryPayloadException test2 = new GraphInventoryPayloadException("testing", t);
    GraphInventoryPayloadException test3 = new GraphInventoryPayloadException(t);
}
Also used : GraphInventoryPayloadException(org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryPayloadException) Test(org.junit.Test)

Aggregations

GraphInventoryPayloadException (org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryPayloadException)4 GraphInventoryUriNotFoundException (org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriNotFoundException)3 GraphInventoryUriComputationException (org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriComputationException)2 IOException (java.io.IOException)1 BadRequestException (javax.ws.rs.BadRequestException)1 Test (org.junit.Test)1