001: //$HeadURL: svn+ssh://mschneider@svn.wald.intevation.org/deegree/base/trunk/resources/eclipse/svn_classfile_header_template.xml $
002: /*---------------- FILE HEADER ------------------------------------------
003: This file is part of deegree.
004: Copyright (C) 2001-2008 by:
005: Department of Geography, University of Bonn
006: http://www.giub.uni-bonn.de/deegree/
007: lat/lon GmbH
008: http://www.lat-lon.de
009:
010: This library is free software; you can redistribute it and/or
011: modify it under the terms of the GNU Lesser General Public
012: License as published by the Free Software Foundation; either
013: version 2.1 of the License, or (at your option) any later version.
014: This library is distributed in the hope that it will be useful,
015: but WITHOUT ANY WARRANTY; without even the implied warranty of
016: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: Lesser General Public License for more details.
018: You should have received a copy of the GNU Lesser General Public
019: License along with this library; if not, write to the Free Software
020: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
021: Contact:
022:
023: Andreas Poth
024: lat/lon GmbH
025: Aennchenstr. 19
026: 53177 Bonn
027: Germany
028: E-Mail: poth@lat-lon.de
029:
030: Prof. Dr. Klaus Greve
031: Department of Geography
032: University of Bonn
033: Meckenheimer Allee 166
034: 53115 Bonn
035: Germany
036: E-Mail: greve@giub.uni-bonn.de
037: ---------------------------------------------------------------------------*/
038:
039: package org.deegree.ogcwebservices.wfs.operation;
040:
041: import java.util.List;
042: import java.util.Map;
043:
044: import org.deegree.framework.xml.XMLParsingException;
045: import org.deegree.framework.xml.XMLTools;
046: import org.deegree.i18n.Messages;
047: import org.deegree.ogcwebservices.InvalidParameterValueException;
048: import org.deegree.ogcwebservices.wfs.operation.GetFeature.RESULT_TYPE;
049: import org.deegree.ogcwebservices.wfs.operation.LockFeature.ALL_SOME_TYPE;
050: import org.w3c.dom.Element;
051:
052: /**
053: * Parser for "wfs:GetFeatureWithLock" requests.
054: * <p>
055: * Identical to "wfs:GetFeature" requests, except for two additional attributes in the root element
056: * (and the name of the root element, of course).
057: *
058: * @author <a href="mailto:schneider@lat-lon.de">Markus Schneider </a>
059: * @author last edited by: $Author:$
060: *
061: * @version $Revision:$, $Date:$
062: */
063: public class GetFeatureWithLockDocument extends GetFeatureDocument {
064:
065: private static final long serialVersionUID = -5865330735585920611L;
066:
067: /**
068: * Parses the underlying document into a <code>GetFeatureWithLock</code> request object.
069: *
070: * @param id
071: * @return corresponding <code>GetFeatureWithLock</code> object
072: * @throws XMLParsingException
073: */
074: @Override
075: public GetFeatureWithLock parse(String id)
076: throws XMLParsingException {
077:
078: checkServiceAttribute();
079: String version = checkVersionAttribute();
080:
081: boolean useVersion_1_0_0 = "1.0.0".equals(version);
082:
083: Element root = this .getRootElement();
084: String handle = XMLTools.getNodeAsString(root, "@handle",
085: nsContext, null);
086: String outputFormat = XMLTools.getNodeAsString(root,
087: "@outputFormat", nsContext,
088: AbstractWFSRequest.FORMAT_GML3);
089:
090: int maxFeatures = XMLTools.getNodeAsInt(root, "@maxFeatures",
091: nsContext, -1);
092: int startPosition = XMLTools.getNodeAsInt(root,
093: "@startPosition", nsContext, 1);
094: if (startPosition < 1) {
095: String msg = Messages.getMessage(
096: "WFS_INVALID_STARTPOSITION", Integer
097: .toString(startPosition));
098: throw new XMLParsingException(msg);
099: }
100:
101: int traverseXLinkDepth = XMLTools.getNodeAsInt(root,
102: "@traverseXLinkDepth", nsContext, -1);
103: int traverseXLinkExpiry = XMLTools.getNodeAsInt(root,
104: "@traverseXLinkExpiry", nsContext, -1);
105:
106: String resultTypeString = XMLTools.getNodeAsString(root,
107: "@resultType", nsContext, "results");
108: RESULT_TYPE resultType;
109: if ("results".equals(resultTypeString)) {
110: resultType = RESULT_TYPE.RESULTS;
111: } else if ("hits".equals(resultTypeString)) {
112: resultType = RESULT_TYPE.HITS;
113: } else {
114: String msg = Messages.getMessage("WFS_INVALID_RESULT_TYPE",
115: resultTypeString);
116: throw new XMLParsingException(msg);
117: }
118:
119: List<Element> nl = XMLTools.getRequiredElements(root,
120: "wfs:Query", nsContext);
121: Query[] queries = new Query[nl.size()];
122: for (int i = 0; i < queries.length; i++) {
123: queries[i] = parseQuery(nl.get(i), useVersion_1_0_0);
124: }
125:
126: // vendorspecific attributes; required by deegree rights management
127: Map<String, String> vendorSpecificParams = parseDRMParams(root);
128:
129: long expiry = LockFeatureDocument.parseExpiry(root);
130:
131: String lockActionString = XMLTools.getNodeAsString(root,
132: "@lockAction", nsContext, "ALL");
133: ALL_SOME_TYPE lockAction = ALL_SOME_TYPE.ALL;
134: try {
135: lockAction = LockFeature
136: .validateLockAction(lockActionString);
137: } catch (InvalidParameterValueException e) {
138: throw new XMLParsingException(e.getMessage());
139: }
140:
141: GetFeatureWithLock req = new GetFeatureWithLock(version, id,
142: handle, resultType, outputFormat, maxFeatures,
143: startPosition, traverseXLinkDepth, traverseXLinkExpiry,
144: queries, vendorSpecificParams, expiry, lockAction);
145: return req;
146: }
147: }
|