org.geoserver.wfs.WFSException类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(242)

本文整理了Java中org.geoserver.wfs.WFSException类的一些代码示例,展示了WFSException类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WFSException类的具体详情如下:
包路径:org.geoserver.wfs.WFSException
类名称:WFSException

WFSException介绍

[英]WFS application specific exception.
[中]WFS应用程序特定异常。

代码示例

代码示例来源:origin: org.geoserver/gs-wfs

  1. /**
  2. *
  3. * <!-- begin-user-doc -->
  4. * <!-- end-user-doc -->
  5. *
  6. * @generated modifiable
  7. */
  8. public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
  9. throw new WFSException("Circle is not supported", "InvalidParameterValue");
  10. }
  11. }

代码示例来源:origin: org.geoserver/gs-wfs

  1. void validateStoredQuery(CreateStoredQueryType request, StoredQueryDescriptionType sq)
  2. throws WFSException {
  3. if (sq.getQueryExpressionText().isEmpty()) {
  4. throw new WFSException(request, "Stored query does not specify any queries");
  5. if (language != null && !storedQueryProvider.supportsLanguage(language)) {
  6. WFSException e =
  7. new WFSException(
  8. request,
  9. "Invalid language " + queryExpressionTextType.getLanguage(),
  10. ServiceException.INVALID_PARAMETER_VALUE);
  11. e.setLocator("language");
  12. throw e;
  13. for (int i = 1; i < sq.getQueryExpressionText().size(); i++) {
  14. if (!language.equals(sq.getQueryExpressionText().get(i).getLanguage())) {
  15. throw new WFSException(
  16. request,
  17. "Stored query specifies queries with multiple languages. "
  18. storedQueryProvider.createStoredQuery(sq, false).validate();
  19. } catch (WFSException e) {
  20. throw new WFSException(request, e.getMessage(), e, e.getCode());
  21. } catch (Exception e) {
  22. throw new WFSException(request, "Error validating stored query", e);

代码示例来源:origin: org.geoserver/gs-wfs

  1. FeatureTypeInfo featureTypeInfo(QName name, GetFeatureRequest request)
  2. throws WFSException, IOException {
  3. FeatureTypeInfo meta =
  4. catalog.getFeatureTypeByName(name.getNamespaceURI(), name.getLocalPart());
  5. if (meta == null) {
  6. String msg = "Could not locate " + name + " in catalog.";
  7. throw new WFSException(request, msg, "InvalidParameterValue").locator("typeName");
  8. }
  9. return meta;
  10. }

代码示例来源:origin: org.geoserver/gs-wfs

  1. public static void checkValidationErrors(Parser parser, XmlRequestReader requestReader) {
  2. // TODO: HACK, disabling validation for transaction
  3. if (!"Transaction".equalsIgnoreCase(requestReader.getElement().getLocalPart())) {
  4. if (!parser.getValidationErrors().isEmpty()) {
  5. WFSException exception =
  6. new WFSException("Invalid request", "InvalidParameterValue");
  7. for (Iterator e = parser.getValidationErrors().iterator(); e.hasNext(); ) {
  8. Exception error = (Exception) e.next();
  9. exception.getExceptionText().add(error.getLocalizedMessage());
  10. }
  11. throw exception;
  12. }
  13. }
  14. }

代码示例来源:origin: org.geoserver/gs-wfs

  1. /** Returns the list of requested sections (never null or emtpy) */
  2. protected Set<Sections> getSections(GetCapabilitiesRequest request) {
  3. List<String> sectionNames = request.getSections();
  4. if (sectionNames == null || sectionNames.isEmpty()) {
  5. return ALL_SECTIONS;
  6. }
  7. Set<Sections> sections = new HashSet<>();
  8. for (String sectionName : sectionNames) {
  9. try {
  10. Sections section = Sections.valueOf(sectionName);
  11. sections.add(section);
  12. } catch (IllegalArgumentException e) {
  13. WFSException exception =
  14. new WFSException(
  15. request, "Unknown section " + sectionName, "InvalidParameterValue");
  16. exception.setLocator("sections");
  17. throw exception;
  18. }
  19. }
  20. if (sections.contains(Sections.All)) {
  21. return ALL_SECTIONS;
  22. }
  23. return sections;
  24. }

代码示例来源:origin: org.geoserver/gs-wfs

  1. /**
  2. * Test {@link WFSException#init(Object)} for Exception with a WFS11 {@link Delete}-Action.
  3. *
  4. * @see "https://osgeo-org.atlassian.net/browse/GEOS-5857"
  5. */
  6. @Test
  7. public void testWFS11Delete() {
  8. WFSException tmpEx = new WFSException(new Delete.WFS11(deleteElementType1), "test");
  9. // WFS 1.x: no locator
  10. Assert.assertNull(tmpEx.getLocator());
  11. }

代码示例来源:origin: org.geoserver/gs-wfs

  1. throw new WFSException(request, "No query specified");
  2. && request.isLockRequest()
  3. && request.isResultTypeHits()) {
  4. throw new WFSException(
  5. "GetFeatureWithLock cannot be used with result type 'hits'",
  6. ServiceException.INVALID_PARAMETER_VALUE,
  7. throw new WFSException(
  8. request,
  9. String.format(
  10. throw new WFSException(request, "Join query must specify a filter");
  11. joins = extractor.getJoins();
  12. if (joins.size() != metas.size() - 1) {
  13. throw new WFSException(
  14. request,
  15. String.format(
  16. Join join = joins.get(j - 1);
  17. if (!isValidJoinFilter(join.getJoinFilter())) {
  18. throw new WFSException(
  19. request,
  20. "Unable to perform join with specified join filter: "
  21. throw new WFSException(request, mesg, "InvalidParameterValue");
  22. && (e.getLocator() == null

代码示例来源:origin: org.geoserver/gs-wfs

  1. throw new WFSException(request, "Lock support is not enabled");
  2. "Attempting to use a lockID that does not exist"
  3. + ", it has either expired or was entered wrong.";
  4. throw new WFSException(request, mesg, "InvalidParameterValue");
  5. throw new WFSException(
  6. request,
  7. "Authorization ID '" + authorizationID + "' not useable",
  8. && ((WFSException) exception).getCode() != null)) {
  9. exception = new WFSException(request, exception);

代码示例来源:origin: org.geoserver/gs-wfs

  1. /** https://osgeo-org.atlassian.net/browse/GEOS-1875 */
  2. @Test
  3. @SuppressWarnings("unchecked")
  4. public void testInvalidTypeNameBbox() throws Exception {
  5. Map raw = new HashMap();
  6. raw.put("service", "WFS");
  7. raw.put("version", "1.1.0");
  8. raw.put("request", "GetFeature");
  9. raw.put("bbox", "-80.4864795578115,25.6176257083275,-80.3401307394915,25.7002737069969");
  10. raw.put("typeName", "cite:InvalidTypeName");
  11. Map parsed = parseKvp(raw);
  12. try {
  13. // before fix for GEOS-1875 this would bomb out with an NPE instead of the proper
  14. // exception
  15. reader.read(WfsFactory.eINSTANCE.createGetFeatureType(), parsed, raw);
  16. } catch (WFSException e) {
  17. assertEquals("InvalidParameterValue", e.getCode());
  18. assertEquals("typeName", e.getLocator());
  19. System.out.println(e.getMessage());
  20. assertTrue(e.getMessage().contains("cite:InvalidTypeName"));
  21. }
  22. }

代码示例来源:origin: org.geoserver.script/gs-script-core

  1. public void testHookError() throws Exception {
  2. File script = copyOverFile("tx-error");
  3. TransactionRequest tx = new TransactionRequest.WFS11(null);
  4. TransactionResponse res = new TransactionResponse.WFS11(null);
  5. Map context = new HashMap();
  6. ScriptEngine eng = scriptMgr.createNewEngine(script);
  7. eng.eval(new FileReader(script));
  8. WfsTxHook hook = getScriptManager().lookupWfsTxHook(script);
  9. try {
  10. hook.handleBefore(eng, tx, context);
  11. fail("exected WFS exception");
  12. } catch (WFSException e) {
  13. assertEquals("before exception", e.getMessage());
  14. }
  15. }
  16. }

代码示例来源:origin: org.geoserver/gs-wfs

  1. public WFSException init(Object request) {
  2. if (request != null) {
  3. // wfs 2.0 has more requirements for exception codes and handles
  4. if (OwsUtils.has(request, "version")) {
  5. Object ver = OwsUtils.get(request, "version");
  6. Version version = Version.negotiate(ver != null ? ver.toString() : null);
  7. if (version != null && version.compareTo(Version.V_20) < 0) {
  8. return this; // not 2.0
  9. }
  10. }
  11. if (locator == null && OwsUtils.has(request, "handle")) {
  12. // check the request object
  13. locator = (String) OwsUtils.get(request, "handle");
  14. }
  15. if (locator == null) {
  16. locator = determineDefaultLocator(request);
  17. }
  18. if (code == null) {
  19. code = Code.OperationProcessingFailed.name();
  20. }
  21. }
  22. return this;
  23. }

代码示例来源:origin: org.geoserver/gs-wfs

  1. private void validateValue(TransactionElement element, Property property, Class<?> binding) {
  2. Object value = property.getValue();
  3. // was it a null? If so, assume valid (already checked for nulls before)
  4. if (value == null // parsed as null
  5. || (value instanceof String
  6. && ((String) value).trim().isEmpty()) // as an empty string
  7. || (value instanceof Map
  8. && ((Map) value).isEmpty()) // or the usual map that the parser creates
  9. ) {
  10. return;
  11. }
  12. // see if the datastore machinery will be able to convert
  13. Object converted = Converters.convert(value, binding);
  14. if (converted == null) {
  15. String propertyName = property.getName().getLocalPart();
  16. WFSException e =
  17. new WFSException(
  18. element,
  19. "Invalid value for property " + propertyName,
  20. WFSException.INVALID_VALUE);
  21. e.setLocator(propertyName);
  22. throw e;
  23. }
  24. }

代码示例来源:origin: org.geoserver/gs-wfs

  1. /**
  2. * Test {@link WFSException#init(Object)} for Exception with a WFS20 {@link Delete}-Action.
  3. *
  4. * @see "https://osgeo-org.atlassian.net/browse/GEOS-5857"
  5. */
  6. @Test
  7. public void testWFS20Delete() {
  8. WFSException tmpEx = new WFSException(new Delete.WFS20(deleteType2), "test");
  9. Assert.assertEquals("Delete", tmpEx.getLocator());
  10. }

代码示例来源:origin: org.geoserver/gs-wfs

  1. public ValueCollectionType run(GetPropertyValueType request) throws WFSException {
  2. throw new WFSException(request, "No valueReference specified", "MissingParameterValue")
  3. .locator("valueReference");
  4. } else if ("".equals(request.getValueReference().trim())) {
  5. throw new WFSException(
  6. request,
  7. "ValueReference cannot be empty",
  8. ServiceException.INVALID_PARAMETER_VALUE)
  9. .locator("valueReference");
  10. FEATURE_ID_PATTERN.matcher(request.getValueReference()).matches();
  11. if (descriptor == null && !featureIdRequest) {
  12. throw new WFSException(
  13. request, "No such attribute: " + request.getValueReference());
  14. return vc;
  15. } catch (IOException e) {
  16. throw new WFSException(request, e);

代码示例来源:origin: org.geoserver/gs-wfs

  1. WFSException exception = new WFSException("Invalid request", "InvalidParameterValue");
  2. exception.getExceptionText().add(error.getLocalizedMessage());

代码示例来源:origin: org.geoserver/gs-wfs

  1. /** Same as GEOS-1875, but let's check without bbox and without name prefix */
  2. @SuppressWarnings("unchecked")
  3. @Test
  4. public void testInvalidTypeName() throws Exception {
  5. Map raw = new HashMap();
  6. raw.put("service", "WFS");
  7. raw.put("version", "1.1.0");
  8. raw.put("request", "GetFeature");
  9. raw.put("typeName", "InvalidTypeName");
  10. try {
  11. Map parsed = parseKvp(raw);
  12. reader.read(WfsFactory.eINSTANCE.createGetFeatureType(), parsed, raw);
  13. } catch (WFSException e) {
  14. assertEquals("InvalidParameterValue", e.getCode());
  15. assertEquals("typeName", e.getLocator());
  16. // System.out.println(e.getMessage());
  17. assertTrue(e.getMessage().contains("InvalidTypeName"));
  18. }
  19. }

代码示例来源:origin: org.geoserver.community/gs-nsg-wfs-profile

  1. void checkTimeout() {
  2. if (!cancelled && System.currentTimeMillis() > timeoutTime) {
  3. this.thrown = true;
  4. throw new WFSException(request, "Timeout exceeded", TIMEOUT_EXCEPTION_CODE);
  5. }
  6. }

代码示例来源:origin: org.geoserver/gs-wfs

  1. throw new WFSException(request, "Stored query not supported");
  2. if (storedQuery == null) {
  3. WFSException exception =
  4. new WFSException(
  5. request,
  6. "Stored query '" + storedQueryId + "' does not" + " exist.",
  7. ServiceException.INVALID_PARAMETER_VALUE);
  8. exception.setLocator("STOREDQUERY_ID");
  9. throw exception;

代码示例来源:origin: org.geoserver/gs-wfs

  1. /**
  2. * Test {@link WFSException#init(Object)} for Exception with a WFS20 {@link
  3. * GetFeatureRequest}-Action.
  4. *
  5. * @see "https://osgeo-org.atlassian.net/browse/GEOS-5857"
  6. */
  7. @Test
  8. public void testWFS20GetFeatureType() {
  9. WFSException tmpEx = new WFSException(new GetFeatureRequest.WFS20(getFeatureType2), "test");
  10. Assert.assertEquals("GetFeature", tmpEx.getLocator());
  11. }
  12. }

代码示例来源:origin: org.geoserver/gs-wfs

  1. /**
  2. * Given a set of keys, this method will ensure that no two keys are specified at the same time
  3. *
  4. * @param kvp
  5. * @param keys
  6. */
  7. protected void ensureMutuallyExclusive(Map kvp, String[] keys, EObject request) {
  8. for (int i = 0; i < keys.length; i++) {
  9. if (kvp.containsKey(keys[i])) {
  10. for (int j = i + 1; j < keys.length; j++) {
  11. if (kvp.containsKey(keys[j])) {
  12. String msg =
  13. keys[i]
  14. + " and "
  15. + keys[j]
  16. + " both specified but are mutually exclusive";
  17. throw new WFSException(request, msg);
  18. }
  19. }
  20. }
  21. }
  22. }

相关文章