Search in sources :

Example 1 with ExceptionType

use of net.opengis.ows.v_1_1_0.ExceptionType in project ddf by codice.

the class CswResponseExceptionMapper method convertToCswException.

private CswException convertToCswException(ExceptionReport report) {
    CswException cswException = null;
    List<ExceptionType> list = new ArrayList<ExceptionType>(report.getException());
    for (ExceptionType exceptionType : list) {
        String exceptionCode = exceptionType.getExceptionCode();
        String locator = exceptionType.getLocator();
        List<String> exceptionText = exceptionType.getExceptionText();
        StringBuilder exceptionMsg = new StringBuilder();
        // Exception code is required per CSW schema, but check it anyway
        if (StringUtils.isNotBlank(exceptionCode)) {
            exceptionMsg.append("exceptionCode = " + exceptionCode + "\n");
        } else {
            exceptionMsg.append("exceptionCode = UNSPECIFIED");
        }
        // Locator and exception text(s) are both optional
        if (StringUtils.isNotBlank(locator)) {
            exceptionMsg.append("locator = " + locator + "\n");
        }
        if (!CollectionUtils.isEmpty(exceptionText)) {
            for (String text : exceptionText) {
                exceptionMsg.append(text);
            }
        }
        cswException = new CswException(exceptionMsg.toString());
    }
    if (null == cswException) {
        cswException = new CswException("Empty Exception Report (version = " + report.getVersion() + ")");
    }
    return cswException;
}
Also used : ExceptionType(net.opengis.ows.v_1_0_0.ExceptionType) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) ArrayList(java.util.ArrayList)

Example 2 with ExceptionType

use of net.opengis.ows.v_1_1_0.ExceptionType 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)

Example 3 with ExceptionType

use of net.opengis.ows.v_1_1_0.ExceptionType in project ddf by codice.

the class WfsResponseExceptionMapper method convertToWfsException.

private WfsException convertToWfsException(ExceptionReport report) {
    WfsException wfsException = null;
    List<ExceptionType> list = new ArrayList<ExceptionType>(report.getException());
    if (list.size() > 0) {
        Collections.reverse(list);
        for (ExceptionType exceptionType : list) {
            String exceptionCode = exceptionType.getExceptionCode();
            String locator = exceptionType.getLocator();
            List<String> exceptionText = exceptionType.getExceptionText();
            StringBuilder exceptionMsg = new StringBuilder();
            // Exception code is required per CSW schema, but check it anyway
            if (StringUtils.isNotBlank(exceptionCode)) {
                exceptionMsg.append("exceptionCode = " + exceptionCode + "\n");
            } else {
                exceptionMsg.append("exceptionCode = UNSPECIFIED");
            }
            // Locator and exception text(s) are both optional
            if (StringUtils.isNotBlank(locator)) {
                exceptionMsg.append("locator = " + locator + "\n");
            }
            if (!CollectionUtils.isEmpty(exceptionText)) {
                for (String text : exceptionText) {
                    exceptionMsg.append(text);
                }
            }
            wfsException = new WfsException(exceptionMsg.toString());
        }
        if (null == wfsException) {
            wfsException = new WfsException("Empty Service Exception Report (version = " + report.getVersion() + ")");
        }
    } else {
        wfsException = new WfsException("Empty Service Exception Report (version = " + report.getVersion() + ")");
    }
    return wfsException;
}
Also used : ExceptionType(net.opengis.ows.v_1_1_0.ExceptionType) WfsException(org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsException) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 ExceptionType (net.opengis.ows.v_1_0_0.ExceptionType)2 ExceptionReport (net.opengis.ows.v_1_0_0.ExceptionReport)1 ExceptionType (net.opengis.ows.v_1_1_0.ExceptionType)1 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)1 WfsException (org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsException)1