Search in sources :

Example 11 with ExceptionReport

use of net.opengis.ows.v_1_0_0.ExceptionReport in project ddf by codice.

the class CswExceptionMapperTest method testCswExceptionToServiceExceptionReportWithLocatorAndCode.

@Test
public void testCswExceptionToServiceExceptionReportWithLocatorAndCode() {
    CswException exception = new CswException(SERVICE_EXCEPTION_MSG, Status.BAD_REQUEST.getStatusCode(), EXCEPTION_CODE, LOCATOR);
    ExceptionMapper<Throwable> exceptionMapper = new CswExceptionMapper();
    Response response = exceptionMapper.toResponse(exception);
    assertThat(response.getEntity(), is(instanceOf(ExceptionReport.class)));
    ExceptionReport exceptionReport = (ExceptionReport) response.getEntity();
    assertThat(Status.BAD_REQUEST.getStatusCode(), is(response.getStatus()));
    assertThat(SERVICE_EXCEPTION_MSG, is(exceptionReport.getException().get(0).getExceptionText().get(0)));
    assertThat(EXCEPTION_CODE, is(exceptionReport.getException().get(0).getExceptionCode()));
    assertThat(LOCATOR, is(exceptionReport.getException().get(0).getLocator()));
}
Also used : Response(javax.ws.rs.core.Response) ExceptionReport(net.opengis.ows.v_1_0_0.ExceptionReport) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) Test(org.junit.Test)

Example 12 with ExceptionReport

use of net.opengis.ows.v_1_0_0.ExceptionReport in project ddf by codice.

the class CswExceptionMapper method createServiceException.

private ExceptionReport createServiceException(CswException cswException) {
    ExceptionReport exceptionReport = new ExceptionReport();
    exceptionReport.setVersion(SERVICE_EXCEPTION_REPORT_VERSION);
    ExceptionType exception = new ExceptionType();
    exception.setExceptionCode(cswException.getExceptionCode());
    exception.setLocator(cswException.getLocator());
    exception.getExceptionText().add(cswException.getMessage());
    exceptionReport.getException().add(exception);
    return exceptionReport;
}
Also used : ExceptionType(net.opengis.ows.v_1_0_0.ExceptionType) ExceptionReport(net.opengis.ows.v_1_0_0.ExceptionReport)

Aggregations

ExceptionReport (net.opengis.ows.v_1_0_0.ExceptionReport)9 Response (javax.ws.rs.core.Response)6 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)6 Test (org.junit.Test)6 StringReader (java.io.StringReader)3 JAXBException (javax.xml.bind.JAXBException)3 Unmarshaller (javax.xml.bind.Unmarshaller)3 XMLInputFactory (javax.xml.stream.XMLInputFactory)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 ExceptionType (net.opengis.ows.v_1_0_0.ExceptionType)3 JAXBElementProvider (org.apache.cxf.jaxrs.provider.JAXBElementProvider)3 WfsException (org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsException)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)1 ExceptionReport (net.opengis.ows.v_1_1_0.ExceptionReport)1 WfsParseException (org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsParseException)1