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);
}
}
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;
}
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;
}
Aggregations