/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { throw new WFSException("Circle is not supported", "InvalidParameterValue"); } }
void validateStoredQuery(CreateStoredQueryType request, StoredQueryDescriptionType sq) throws WFSException { if (sq.getQueryExpressionText().isEmpty()) { throw new WFSException(request, "Stored query does not specify any queries"); if (language != null && !storedQueryProvider.supportsLanguage(language)) { WFSException e = new WFSException( request, "Invalid language " + queryExpressionTextType.getLanguage(), ServiceException.INVALID_PARAMETER_VALUE); e.setLocator("language"); throw e; for (int i = 1; i < sq.getQueryExpressionText().size(); i++) { if (!language.equals(sq.getQueryExpressionText().get(i).getLanguage())) { throw new WFSException( request, "Stored query specifies queries with multiple languages. " storedQueryProvider.createStoredQuery(sq, false).validate(); } catch (WFSException e) { throw new WFSException(request, e.getMessage(), e, e.getCode()); } catch (Exception e) { throw new WFSException(request, "Error validating stored query", e);
FeatureTypeInfo featureTypeInfo(QName name, GetFeatureRequest request) throws WFSException, IOException { FeatureTypeInfo meta = catalog.getFeatureTypeByName(name.getNamespaceURI(), name.getLocalPart()); if (meta == null) { String msg = "Could not locate " + name + " in catalog."; throw new WFSException(request, msg, "InvalidParameterValue").locator("typeName"); } return meta; }
public static void checkValidationErrors(Parser parser, XmlRequestReader requestReader) { // TODO: HACK, disabling validation for transaction if (!"Transaction".equalsIgnoreCase(requestReader.getElement().getLocalPart())) { if (!parser.getValidationErrors().isEmpty()) { WFSException exception = new WFSException("Invalid request", "InvalidParameterValue"); for (Iterator e = parser.getValidationErrors().iterator(); e.hasNext(); ) { Exception error = (Exception) e.next(); exception.getExceptionText().add(error.getLocalizedMessage()); } throw exception; } } }
/** Returns the list of requested sections (never null or emtpy) */ protected Set<Sections> getSections(GetCapabilitiesRequest request) { List<String> sectionNames = request.getSections(); if (sectionNames == null || sectionNames.isEmpty()) { return ALL_SECTIONS; } Set<Sections> sections = new HashSet<>(); for (String sectionName : sectionNames) { try { Sections section = Sections.valueOf(sectionName); sections.add(section); } catch (IllegalArgumentException e) { WFSException exception = new WFSException( request, "Unknown section " + sectionName, "InvalidParameterValue"); exception.setLocator("sections"); throw exception; } } if (sections.contains(Sections.All)) { return ALL_SECTIONS; } return sections; }
/** * Test {@link WFSException#init(Object)} for Exception with a WFS11 {@link Delete}-Action. * * @see "https://osgeo-org.atlassian.net/browse/GEOS-5857" */ @Test public void testWFS11Delete() { WFSException tmpEx = new WFSException(new Delete.WFS11(deleteElementType1), "test"); // WFS 1.x: no locator Assert.assertNull(tmpEx.getLocator()); }
throw new WFSException(request, "No query specified"); && request.isLockRequest() && request.isResultTypeHits()) { throw new WFSException( "GetFeatureWithLock cannot be used with result type 'hits'", ServiceException.INVALID_PARAMETER_VALUE, throw new WFSException( request, String.format( throw new WFSException(request, "Join query must specify a filter"); joins = extractor.getJoins(); if (joins.size() != metas.size() - 1) { throw new WFSException( request, String.format( Join join = joins.get(j - 1); if (!isValidJoinFilter(join.getJoinFilter())) { throw new WFSException( request, "Unable to perform join with specified join filter: " throw new WFSException(request, mesg, "InvalidParameterValue"); && (e.getLocator() == null
throw new WFSException(request, "Lock support is not enabled"); "Attempting to use a lockID that does not exist" + ", it has either expired or was entered wrong."; throw new WFSException(request, mesg, "InvalidParameterValue"); throw new WFSException( request, "Authorization ID '" + authorizationID + "' not useable", && ((WFSException) exception).getCode() != null)) { exception = new WFSException(request, exception);
/** https://osgeo-org.atlassian.net/browse/GEOS-1875 */ @Test @SuppressWarnings("unchecked") public void testInvalidTypeNameBbox() throws Exception { Map raw = new HashMap(); raw.put("service", "WFS"); raw.put("version", "1.1.0"); raw.put("request", "GetFeature"); raw.put("bbox", "-80.4864795578115,25.6176257083275,-80.3401307394915,25.7002737069969"); raw.put("typeName", "cite:InvalidTypeName"); Map parsed = parseKvp(raw); try { // before fix for GEOS-1875 this would bomb out with an NPE instead of the proper // exception reader.read(WfsFactory.eINSTANCE.createGetFeatureType(), parsed, raw); } catch (WFSException e) { assertEquals("InvalidParameterValue", e.getCode()); assertEquals("typeName", e.getLocator()); System.out.println(e.getMessage()); assertTrue(e.getMessage().contains("cite:InvalidTypeName")); } }
public void testHookError() throws Exception { File script = copyOverFile("tx-error"); TransactionRequest tx = new TransactionRequest.WFS11(null); TransactionResponse res = new TransactionResponse.WFS11(null); Map context = new HashMap(); ScriptEngine eng = scriptMgr.createNewEngine(script); eng.eval(new FileReader(script)); WfsTxHook hook = getScriptManager().lookupWfsTxHook(script); try { hook.handleBefore(eng, tx, context); fail("exected WFS exception"); } catch (WFSException e) { assertEquals("before exception", e.getMessage()); } } }
public WFSException init(Object request) { if (request != null) { // wfs 2.0 has more requirements for exception codes and handles if (OwsUtils.has(request, "version")) { Object ver = OwsUtils.get(request, "version"); Version version = Version.negotiate(ver != null ? ver.toString() : null); if (version != null && version.compareTo(Version.V_20) < 0) { return this; // not 2.0 } } if (locator == null && OwsUtils.has(request, "handle")) { // check the request object locator = (String) OwsUtils.get(request, "handle"); } if (locator == null) { locator = determineDefaultLocator(request); } if (code == null) { code = Code.OperationProcessingFailed.name(); } } return this; }
private void validateValue(TransactionElement element, Property property, Class<?> binding) { Object value = property.getValue(); // was it a null? If so, assume valid (already checked for nulls before) if (value == null // parsed as null || (value instanceof String && ((String) value).trim().isEmpty()) // as an empty string || (value instanceof Map && ((Map) value).isEmpty()) // or the usual map that the parser creates ) { return; } // see if the datastore machinery will be able to convert Object converted = Converters.convert(value, binding); if (converted == null) { String propertyName = property.getName().getLocalPart(); WFSException e = new WFSException( element, "Invalid value for property " + propertyName, WFSException.INVALID_VALUE); e.setLocator(propertyName); throw e; } }
/** * Test {@link WFSException#init(Object)} for Exception with a WFS20 {@link Delete}-Action. * * @see "https://osgeo-org.atlassian.net/browse/GEOS-5857" */ @Test public void testWFS20Delete() { WFSException tmpEx = new WFSException(new Delete.WFS20(deleteType2), "test"); Assert.assertEquals("Delete", tmpEx.getLocator()); }
public ValueCollectionType run(GetPropertyValueType request) throws WFSException { throw new WFSException(request, "No valueReference specified", "MissingParameterValue") .locator("valueReference"); } else if ("".equals(request.getValueReference().trim())) { throw new WFSException( request, "ValueReference cannot be empty", ServiceException.INVALID_PARAMETER_VALUE) .locator("valueReference"); FEATURE_ID_PATTERN.matcher(request.getValueReference()).matches(); if (descriptor == null && !featureIdRequest) { throw new WFSException( request, "No such attribute: " + request.getValueReference()); return vc; } catch (IOException e) { throw new WFSException(request, e);
WFSException exception = new WFSException("Invalid request", "InvalidParameterValue"); exception.getExceptionText().add(error.getLocalizedMessage());
/** Same as GEOS-1875, but let's check without bbox and without name prefix */ @SuppressWarnings("unchecked") @Test public void testInvalidTypeName() throws Exception { Map raw = new HashMap(); raw.put("service", "WFS"); raw.put("version", "1.1.0"); raw.put("request", "GetFeature"); raw.put("typeName", "InvalidTypeName"); try { Map parsed = parseKvp(raw); reader.read(WfsFactory.eINSTANCE.createGetFeatureType(), parsed, raw); } catch (WFSException e) { assertEquals("InvalidParameterValue", e.getCode()); assertEquals("typeName", e.getLocator()); // System.out.println(e.getMessage()); assertTrue(e.getMessage().contains("InvalidTypeName")); } }
void checkTimeout() { if (!cancelled && System.currentTimeMillis() > timeoutTime) { this.thrown = true; throw new WFSException(request, "Timeout exceeded", TIMEOUT_EXCEPTION_CODE); } }
throw new WFSException(request, "Stored query not supported"); if (storedQuery == null) { WFSException exception = new WFSException( request, "Stored query '" + storedQueryId + "' does not" + " exist.", ServiceException.INVALID_PARAMETER_VALUE); exception.setLocator("STOREDQUERY_ID"); throw exception;
/** * Test {@link WFSException#init(Object)} for Exception with a WFS20 {@link * GetFeatureRequest}-Action. * * @see "https://osgeo-org.atlassian.net/browse/GEOS-5857" */ @Test public void testWFS20GetFeatureType() { WFSException tmpEx = new WFSException(new GetFeatureRequest.WFS20(getFeatureType2), "test"); Assert.assertEquals("GetFeature", tmpEx.getLocator()); } }
/** * Given a set of keys, this method will ensure that no two keys are specified at the same time * * @param kvp * @param keys */ protected void ensureMutuallyExclusive(Map kvp, String[] keys, EObject request) { for (int i = 0; i < keys.length; i++) { if (kvp.containsKey(keys[i])) { for (int j = i + 1; j < keys.length; j++) { if (kvp.containsKey(keys[j])) { String msg = keys[i] + " and " + keys[j] + " both specified but are mutually exclusive"; throw new WFSException(request, msg); } } } } }