Package org.geoserver.wfs

Examples of org.geoserver.wfs.WFSException


            BeanUtils.setProperty(copy, "outputFormat", info.getSourceFormat());
            final Operation sourceOperation = new Operation(operation.getId(),
                    operation.getService(), operation.getMethod(), new Object[] { copy });
            return sourceOperation;
        } catch (Exception e) {
            throw new WFSException(
                    "Failed to create the source operation for XSLT, this is unexpected", e);
        }
    }
View Full Code Here


        TransformInfo result = null;
        FeatureType reference = null;
        for (FeatureType ft : featureTypes) {
            TransformInfo curr = locateTransform(outputFormat, ft);
            if (curr == null) {
                throw new WFSException("Could not find a XSLT transformation generating "
                        + outputFormat + " for feature type " + ft.getName(), ServiceException.INVALID_PARAMETER_VALUE, "typeName");
            } else if (result == null) {
                reference = ft;
                result = curr;
            } else if (!result.equals(curr)) {
                throw new WFSException(
                        "Multiple feature types are mapped to different XLST transformations, cannot proceed: "
                                + result.getXslt() + ", " + curr.getXslt(), ServiceException.INVALID_PARAMETER_VALUE, "typeName");

            }
        }
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

                }
                if (storedQueryId != null) {
                    buildStoredQueries(eObject, storedQueryId, kvp);
                }
                else {
                    throw new WFSException(eObject, "The query should specify either typeName, featureId filter" +
                        ", or a stored query id", "MissingParameterValue");
                }
            }
        }
       
        //filter
        if (kvp.containsKey("filter")) {
            querySet(eObject, "filter", (List) kvp.get("filter"));
        } else if (kvp.containsKey("cql_filter")) {
            querySet(eObject, "filter", (List) kvp.get("cql_filter"));
        } else if (kvp.containsKey("featureId") || kvp.containsKey("resourceId")) {
            //set filter from featureId
            List featureIdList = (List) kvp.get("featureId");
            featureIdList = featureIdList != null ? featureIdList : (List) kvp.get("resourceId");
            Set ids = new HashSet();

            for (Iterator i = featureIdList.iterator(); i.hasNext();) {
                String fid = (String) i.next();
                FeatureId featureId = filterFactory.featureId(fid);
               ids.add(featureId);
            }
            // build a single feature id filter
            List filters = Collections.singletonList(filterFactory.id(ids));

            querySet(eObject, "filter", filters);
        } else if (kvp.containsKey("bbox")) {
            //set filter from bbox
            Envelope bbox = (Envelope) kvp.get("bbox");

            List<Query> queries = GetFeatureRequest.adapt(eObject).getQueries();
            List filters = new ArrayList();

            for (Iterator<Query> it = queries.iterator(); it.hasNext();) {
                Query q = it.next();
               
                List typeName = q.getTypeNames();
                Filter filter = null;

                if (typeName.size() > 1) {
                    //TODO: not sure what to do here, just going to and them up
                    List and = new ArrayList(typeName.size());

                    for (Iterator t = typeName.iterator(); t.hasNext();) {
                        and.add(bboxFilter((QName) t.next(), bbox));
                    }

                    filter = filterFactory.and(and);
                } else {
                    filter = bboxFilter((QName) typeName.get(0), bbox);
                }

                filters.add(filter);
            }

            querySet(eObject, "filter", filters);
        }

        //aliases
        if (kvp.containsKey("aliases")) {
            querySet(eObject, "aliases", (List) kvp.get("aliases"));
        }

        //propertyName
        if (kvp.containsKey("propertyName")) {
            List<String> propertyNames = new ArrayList<String>();
            if( kvp.get("propertyName") != null && kvp.get("propertyName") instanceof List )
            {
                propertyNames = (List) kvp.get("propertyName");
            }
            else if( kvp.get("propertyName") != null && kvp.get("propertyName") instanceof String )
            {
                propertyNames.addAll(KvpUtils.readFlat((String) kvp.get("propertyName")));
            }
            querySet(eObject, "propertyName", propertyNames);
        }

        //sortBy
        if (kvp.containsKey("sortBy")) {
            querySet(eObject, "sortBy", (List) kvp.get("sortBy"));
        }

        //srsName
        if (kvp.containsKey("srsName")) {
            querySet(eObject, "srsName",Collections.singletonList((URI)kvp.get("srsName")));
        }

        //featureversion
        if (kvp.containsKey("featureVersion")) {
            querySet(eObject, "featureVersion",
                Collections.singletonList((String) kvp.get("featureVersion")));
        }
       
        GetFeatureRequest req = GetFeatureRequest.adapt(request);
        if(kvp.containsKey("format_options")) {
            req.getFormatOptions().putAll((Map) kvp.get("format_options"));
        }
       
        // sql view params
        if(kvp.containsKey("viewParams")) {
           
            if(req.getViewParams() == null) {
                req.setViewParams(new ArrayList<Map<String,String>>());
            }

            // fan out over all layers if necessary
            List<Map<String, String>> viewParams = (List<Map<String, String>>) kvp.get("viewParams");
            if(viewParams.size() > 0) {               
                int layerCount = req.getQueries().size();

                // if we have just one replicate over all layers
                if(viewParams.size() == 1 && layerCount > 1) {
                    List<Map<String, String>> replacement = new ArrayList<Map<String,String>>();
                    for (int i = 0; i < layerCount; i++) {
                        replacement.add(viewParams.get(0));
                    }
                    viewParams = replacement;
                } else if(viewParams.size() != layerCount) {
                    String msg = layerCount + " feature types requested, but found " + viewParams.size()
                   + " view params specified. ";
                    throw new WFSException(eObject, msg, getClass().getName());
                }
            }

            req.setViewParams(viewParams);
        }
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(request, msg);
                    }
                }
            }
        }
    }
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");
        }
        return qName;
    }
View Full Code Here

                return;
            } else {
                //illegal
                String msg = "Specified " + m + " " + property + " for " + n + " queries.";
                throw new WFSException(request, msg);
            }
        }

        EMFUtils.set(query, property, values);
    }
View Full Code Here

    protected void buildStoredQueries(EObject request, List<URI> storedQueryIds, Map kvp) {
        GetFeatureRequest req = GetFeatureRequest.adapt(request);
        req.getAdaptedQueries();
       
        if (!(req instanceof GetFeatureRequest.WFS20)) {
            throw new WFSException(req, "Stored queries only supported in WFS 2.0+");
        }

        StoredQueryProvider sqp = new StoredQueryProvider(catalog);
        for (URI storedQueryId : storedQueryIds) {
            StoredQuery sq = sqp.getStoredQuery(storedQueryId.toString());
            if (sq == null) {
                throw new WFSException(req, "No such stored query: " + storedQueryId);
            }
   
            //JD: since stored queries are 2.0 only we will create 2.0 model objects directly... once
            // the next version of wfs comes out (and if they keep stored queries around) we will have
            // to abstract stored query away with a request object adapter
View Full Code Here

    
            String uri = null;
            if(prefix != null && !"".equals(prefix)) {
                final NamespaceInfo namespace = catalog.getNamespaceByPrefix(prefix);
                if(strict && namespace == null){
                    throw new WFSException("Unknown namespace [" + prefix + "]");
                }
                uri = namespace == null? null : namespace.getURI();
            }

            return new QName(uri, local, prefix);
View Full Code Here

        //parse a GetFeature and copy the query
        GetFeatureType gf = Wfs20Factory.eINSTANCE.createGetFeatureType();
        delegate.read(gf, kvp, rawKvp);

        if (gf.getAbstractQueryExpression().isEmpty()) {
            throw new WFSException(gpv, "Request did not specify a query");
        }

        gpv.setAbstractQueryExpression(gf.getAbstractQueryExpression().get(0));
        return gpv;
    }
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.