Search in sources :

Example 1 with DuplicateRequestException

use of org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException in project so by onap.

the class RequestHandlerUtils method buildErrorOnDuplicateRecord.

public void buildErrorOnDuplicateRecord(InfraActiveRequests currentActiveReq, Actions action, Map<String, String> instanceIdMap, String instanceName, String requestScope, InfraActiveRequests dup) throws ApiException {
    String instance = null;
    if (instanceName != null) {
        instance = instanceName;
    } else {
        instance = instanceIdMap.get(requestScope + "InstanceId");
    }
    ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_FOUND, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
    DuplicateRequestException dupException = new DuplicateRequestException.Builder(requestScope, instance, dup.getRequestStatus(), dup.getRequestId(), HttpStatus.SC_CONFLICT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
    updateStatus(currentActiveReq, Status.FAILED, dupException.getMessage());
    throw dupException;
}
Also used : ErrorLoggerInfo(org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo) ResponseBuilder(org.onap.so.apihandler.common.ResponseBuilder) DuplicateRequestException(org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException)

Example 2 with DuplicateRequestException

use of org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException in project so by onap.

the class ApiExceptionMapperTest method testDuplicateRequestResponse.

@Test
public void testDuplicateRequestResponse() throws IOException {
    DuplicateRequestException duplicateRequestException = new DuplicateRequestException.Builder("Test1", "Test2", "Test3", "Test4", HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_BAD_PARAMETER).build();
    Response resp = mapper.toResponse((ApiException) duplicateRequestException);
    assertEquals(resp.getStatus(), HttpStatus.SC_BAD_GATEWAY);
}
Also used : Response(javax.ws.rs.core.Response) DuplicateRequestException(org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException) Test(org.junit.Test)

Aggregations

DuplicateRequestException (org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException)2 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 ResponseBuilder (org.onap.so.apihandler.common.ResponseBuilder)1 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)1