Search in sources :

Example 1 with WFSExceptionReportHandler

use of vcs.citydb.wfs.exception.WFSExceptionReportHandler in project web-feature-service by 3dcitydb.

the class WFSService method init.

@Override
public void init() throws ServletException {
    // check whether servlet initialization threw an error
    Object error = getServletContext().getAttribute(Constants.INIT_ERROR_ATTRNAME);
    if (error instanceof ServletException)
        throw (ServletException) error;
    log.info("WFS service is loaded by the servlet container.");
    // service specific initialization
    ObjectRegistry registry = ObjectRegistry.getInstance();
    config = registry.getConfig();
    cityGMLBuilder = registry.getCityGMLBuilder();
    limiter = registry.lookup(RequestLimiter.class);
    accessController = registry.lookup(AccessController.class);
    wfsConfig = registry.lookup(WFSConfig.class);
    exceptionReportHandler = new WFSExceptionReportHandler(cityGMLBuilder);
    saxParserFactory = SAXParserFactory.newInstance();
    saxParserFactory.setNamespaceAware(true);
    try {
        StoredQueryManager storedQueryManager = new StoredQueryManager(cityGMLBuilder, saxParserFactory, getServletContext().getRealPath(Constants.STORED_QUERIES_PATH), wfsConfig);
        registry.register(storedQueryManager);
    } catch (Throwable e) {
        String message = "Failed to initialize stored query manager.";
        log.error(message);
        log.error(e.getMessage());
        throw new ServletException(message, e);
    }
    // read WFS 2.0 schema to validate requests
    if (wfsConfig.getOperations().getRequestEncoding().isUseXMLValidation()) {
        try {
            SchemaHandler schemaHandler = registry.lookup(SchemaHandler.class);
            schemaHandler.parseSchema(new File(getServletContext().getRealPath(Constants.SCHEMAS_PATH + "/ogc/wfs/2.0.2/wfs.xsd")));
            schemaHandler.parseSchema(new File(getServletContext().getRealPath(Constants.SCHEMAS_PATH + "/ogc/wfs/extensions/wfs-vcs.xsd")));
            SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            wfsSchema = schemaFactory.newSchema(schemaHandler.getSchemaSources());
        } catch (SAXException e) {
            String message = "Failed to read WFS XML Schema from " + Constants.SCHEMAS_PATH + "/ogc/wfs.";
            log.error(message);
            log.error(e.getMessage());
            throw new ServletException(message, e);
        }
    }
    // register cache cleaner pool
    cacheCleanerPool = new SingleWorkerPool<>("cache_cleaner", CacheCleanerWorker::new, wfsConfig.getServer().getMaxParallelRequests());
    cacheCleanerPool.prestartCoreWorker();
    registry.register(CacheCleanerWorker.class.getName(), cacheCleanerPool);
    // register paging cache manager
    if (wfsConfig.getConstraints().isUseResultPaging()) {
        PagingCacheManager pagingCacheManager = new PagingCacheManager(cacheCleanerPool, wfsConfig);
        registry.register(pagingCacheManager);
    }
}
Also used : SchemaHandler(org.citygml4j.xml.schema.SchemaHandler) SchemaFactory(javax.xml.validation.SchemaFactory) WFSExceptionReportHandler(vcs.citydb.wfs.exception.WFSExceptionReportHandler) PagingCacheManager(vcs.citydb.wfs.paging.PagingCacheManager) SAXException(org.xml.sax.SAXException) ServletException(javax.servlet.ServletException) AccessController(vcs.citydb.wfs.security.AccessController) WFSConfig(vcs.citydb.wfs.config.WFSConfig) File(java.io.File) ObjectRegistry(org.citydb.core.registry.ObjectRegistry)

Example 2 with WFSExceptionReportHandler

use of vcs.citydb.wfs.exception.WFSExceptionReportHandler in project web-feature-service by 3dcitydb.

the class QueryExecuter method getTruncatedResponse.

private TruncatedResponse getTruncatedResponse(WFSException wfsException, HttpServletRequest request) {
    WFSExceptionReportHandler reportHandler = new WFSExceptionReportHandler(cityGMLBuilder);
    ExceptionReport exceptionReport = reportHandler.getExceptionReport(wfsException, KVPConstants.GET_FEATURE, request, true);
    TruncatedResponse truncatedResponse = new TruncatedResponse();
    truncatedResponse.setExceptionReport(exceptionReport);
    return truncatedResponse;
}
Also used : ExceptionReport(net.opengis.ows._1.ExceptionReport) TruncatedResponse(net.opengis.wfs._2.TruncatedResponse) WFSExceptionReportHandler(vcs.citydb.wfs.exception.WFSExceptionReportHandler)

Example 3 with WFSExceptionReportHandler

use of vcs.citydb.wfs.exception.WFSExceptionReportHandler in project web-feature-service by 3dcitydb.

the class QueryExecuter method getTruncatedResponse.

private TruncatedResponse getTruncatedResponse(WFSException wfsException, HttpServletRequest request) {
    WFSExceptionReportHandler reportHandler = new WFSExceptionReportHandler(cityGMLBuilder);
    ExceptionReport exceptionReport = reportHandler.getExceptionReport(wfsException, KVPConstants.GET_PROPERTY_VALUE, request, true);
    TruncatedResponse truncatedResponse = new TruncatedResponse();
    truncatedResponse.setExceptionReport(exceptionReport);
    return truncatedResponse;
}
Also used : ExceptionReport(net.opengis.ows._1.ExceptionReport) TruncatedResponse(net.opengis.wfs._2.TruncatedResponse) WFSExceptionReportHandler(vcs.citydb.wfs.exception.WFSExceptionReportHandler)

Aggregations

WFSExceptionReportHandler (vcs.citydb.wfs.exception.WFSExceptionReportHandler)3 ExceptionReport (net.opengis.ows._1.ExceptionReport)2 TruncatedResponse (net.opengis.wfs._2.TruncatedResponse)2 File (java.io.File)1 ServletException (javax.servlet.ServletException)1 SchemaFactory (javax.xml.validation.SchemaFactory)1 ObjectRegistry (org.citydb.core.registry.ObjectRegistry)1 SchemaHandler (org.citygml4j.xml.schema.SchemaHandler)1 SAXException (org.xml.sax.SAXException)1 WFSConfig (vcs.citydb.wfs.config.WFSConfig)1 PagingCacheManager (vcs.citydb.wfs.paging.PagingCacheManager)1 AccessController (vcs.citydb.wfs.security.AccessController)1