Package org.geoserver.wfs

Examples of org.geoserver.wfs.WFSException


    FeatureTypeInfo featureTypeInfo(QName name) 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(msg);
        }

        return meta;
    }
View Full Code Here


            // load the metadata for the feature type
            String namespaceURI = featureType.getName().getNamespaceURI();
            FeatureTypeInfo meta = catalog.getFeatureTypeByName(namespaceURI, featureType.getTypeName() );

            if (meta == null)
                throw new WFSException("Could not find feature type "
                        + namespaceURI + ":" + featureType.getTypeName()
                        + " in the GeoServer catalog");

            // add it to the map
            Set metas = (Set) ns2metas.get(namespaceURI);
View Full Code Here

            rollback.setHandle((String) node.getAttributeValue("handle"));
        }

        rollback.setFilter((Filter) node.getChildValue(Filter.class));
        if (!node.hasAttribute("typeName"))
            throw new WFSException("The typeName attribute is mandatory");
        rollback.setTypeName((QName) node.getAttributeValue("typeName"));
        rollback.setToFeatureVersion((String) node.getAttributeValue("toFeatureVersion"));
        rollback.setVendorId((String) node.getAttributeValue("vendorId"));
        if (!node.hasAttribute("safeToIgnore"))
            throw new WFSException("The attribute safeToIgnore=true|false is mandatory");
        rollback.setSafeToIgnore(((Boolean) node.getAttributeValue("safeToIgnore")).booleanValue());
        rollback.setUser((String) node.getAttributeValue("user"));

        return rollback;
    }
View Full Code Here

                CoordinateReferenceSystem crs = GML2ParsingUtils.crs(node);
                if ( crs != null ) {
                    context.registerComponentInstance(CoordinateReferenceSystem.class, crs);
                }
            } catch(Exception e) {
                throw new WFSException(e, "InvalidParameterValue");
            }
        }
    }
View Full Code Here

        Object parsed = parser.parse(source);

        // unfortunately insert elements in transactions cannot be validated...
        if(!(parsed instanceof PostDiffType) && !(parsed instanceof GetDiffResponseType)) {
            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;
            }
        }
View Full Code Here

                CoordinateReferenceSystem crs = GML2ParsingUtils.crs(node);
                if ( crs != null ) {
                    context.registerComponentInstance(CoordinateReferenceSystem.class, crs);
                }
            } catch(Exception e) {
                throw new WFSException(e, "InvalidParameterValue");
            }
        }
    }
View Full Code Here

    public FeatureCollectionType run(GetLogType request) {
        List queries = request.getDifferenceQuery();

        // basic checks
        if (queries.isEmpty()) {
            throw new WFSException("No difference query specified");
        }

        if (EMFUtils.isUnset(queries, "typeName")) {
            String msg = "No feature types specified";
            throw new WFSException(msg);
        }

        FeatureCollectionType result = WfsFactory.eINSTANCE.createFeatureCollectionType();
        int residual = request.getMaxFeatures() != null ? request.getMaxFeatures().intValue() : Integer.MAX_VALUE;

        // for each difference query check the feature type is versioned, and
        // gather bounds
        try {
            for (int i = 0; i < queries.size() && residual > 0; i++) {
                DifferenceQueryType query = (DifferenceQueryType) queries.get(i);
                FeatureTypeInfo meta = featureTypeInfo((QName) query.getTypeName());
                FeatureSource<? extends FeatureType, ? extends Feature> source = meta.getFeatureSource(null,null);

                if (!(source instanceof VersioningFeatureSource)) {
                    throw new WFSException("Feature type" + query.getTypeName()
                        + " is not versioned");
                }

                Filter filter = (Filter) query.getFilter();

                //  make sure filters are sane
                if (filter != null) {
                    final FeatureType featureType = source.getSchema();
                    ExpressionVisitor visitor = new AbstractExpressionVisitor() {
                            public Object visit(PropertyName name, Object data) {
                                // case of multiple geometries being returned
                                if (name.evaluate(featureType) == null) {
                                    // we want to throw wfs exception, but cant
                                    throw new WFSException("Illegal property name: "
                                        + name.getPropertyName(), "InvalidParameterValue");
                                }

                                return name;
                            }
                            ;
                        };

                    filter.accept(new AbstractFilterVisitor(visitor), null);
                }

                // extract collection
                VersioningFeatureSource store = (VersioningFeatureSource) source;
                SimpleFeatureCollection logs = store.getLog(query
                        .getFromFeatureVersion(), query.getToFeatureVersion(), filter, null,
                        residual);
                residual -= logs.size();

                // TODO: handle logs reprojection in another CRS
                result.getFeature().add(logs);
            }
        } catch (IOException e) {
            throw new WFSException("Error occurred getting features", e, request.getHandle());
        }

        result.setNumberOfFeatures(BigInteger.valueOf(residual));
        result.setTimeStamp(Calendar.getInstance());
View Full Code Here

    FeatureTypeInfo featureTypeInfo(QName name) 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(msg);
        }

        return meta;
    }
View Full Code Here

                        // so request used a custom prefix and declared the prefix:uri mapping?
                        namespaceURI = namespaces.getURI(qName.getPrefix());
                    }
                    NamespaceInfo ns = catalog.getNamespaceByURI(namespaceURI);
                    if (ns == null) {
                        throw new WFSException("Unknown namespace [" + qName.getPrefix() + "]",
                                "InvalidParameterValue", "namespace");
                    }
                    prefix = ns.getPrefix();
                    qName = new QName(namespaceURI, localPart, prefix);
                }

                if (!XMLConstants.DEFAULT_NS_PREFIX.equals(qName.getPrefix())
                        && catalog.getNamespaceByPrefix(qName.getPrefix()) == null) {
                    throw new WFSException("Unknown namespace [" + qName.getPrefix() + "]",
                            "InvalidParameterValue", "namespace");
                }

                if (catalog.getFeatureTypeByName(namespaceURI, localPart) == null) {
                    String name = qName.getPrefix() + ":" + qName.getLocalPart();
                    throw new WFSException("Feature type " + name + " unknown",
                            "InvalidParameterValue", "typeName");
                }

                List l = new ArrayList();
                l.add(qName);
                list.add(l);
            }

            kvp.put("typeName", list);
            querySet(eObject, "typeName", list);
        } else {
            //check for featureId and infer typeName
            if (kvp.containsKey("featureId")) {
                //use featureId to infer type Names
                List featureId = (List) kvp.get("featureId");

                ArrayList typeNames = new ArrayList();

                QNameKvpParser parser = new QNameKvpParser("typeName", catalog);

                for (int i = 0; i < featureId.size(); i++) {
                    String fid = (String) featureId.get(i);
                    int pos = fid.indexOf(".");

                    if (pos != -1) {
                        String typeName = fid.substring(0, fid.lastIndexOf("."));

                        //add to a list to set on the query
                        List parsed = (List) parser.parse(typeName);
                        typeNames.add(parsed);
                    }
                }

                querySet(eObject, "typeName", typeNames);
            } else {
                throw new WFSException("The query should specify either typeName or a featureId filter", "MissingParameterValue");
            }
        }

        //filter
        if (kvp.containsKey("filter")) {
View Full Code Here

            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(msg);
                    }
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.geoserver.wfs.WFSException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.