def parse(self, document, initInputs=None): if initInputs: self.inputs = initInputs self.document = document # input DOM firstChild = self.isSoapFirstChild(self.document) owsNameSpace = pywps.OWS_NAMESPACE identifiers = [] identifierNode = None # # Mandatory options # service & Request are already controlled # version self.checkVersion(firstChild) # identifiers for identifierNode in self.document.getElementsByTagNameNS( owsNameSpace, "Identifier"): identifiers.append(identifierNode.firstChild.nodeValue) if len(identifiers) == 0: raise pywps.MissingParameterValue("Identifier") self.inputs["identifier"] = identifiers # # Optional options # language self.checkLanguage(firstChild) return self.inputs
def parse(self, unparsedInputs, initInputs=None): """ Parse given raw inputs""" if initInputs: self.inputs = initInputs self.unparsedInputs = unparsedInputs # # Mandatory options # service & Request are already controlled # version self.checkVersion() # identifier if "identifier" in self.unparsedInputs: self.inputs["identifier"] = self.unparsedInputs[ "identifier"].split(",") else: raise pywps.MissingParameterValue("identifier") # # Optional options # Language self.checkLanguage() return self.inputs
def checkVersion(self, node): """ Check optional language parameter. """ if node.hasAttribute("version"): value = node.getAttribute("version") if value not in self.wps.versions: raise pywps.VersionNegotiationFailed( 'The requested version "' + value + '" is not supported by this server.') else: self.inputs["version"] = value else: raise pywps.MissingParameterValue("version")
def parseHeaderDataInput(self,headerNode): """ Parse header node """ header = {} if headerNode: header[headerNode.getAttributeNS(self.nameSpace,"key")] =\ headerNode.getAttributeNS(self.nameSpace,"value") if len(header.keys()) == 0: raise pywps.MissingParameterValue("Header") return header
def checkService(self, node): """Check mandatory service name parameter. :param node: :class:`xml.dom.Node`, where to search """ # service name is mandatory for all requests (OWS_1-1-0 p.14 tab.3 + # p.46 tab.26); service must be "WPS" (WPS_1-0-0 p.17 tab.13 + p.32 tab.39) if node.hasAttribute("service"): value=node.getAttribute("service").upper() if value != "WPS": raise pywps.InvalidParameterValue("service") else: self.inputs["service"] = "wps" else: raise pywps.MissingParameterValue("service")
def parse(self,unparsedInputs, initInputs=None): """ Parse given inputs """ if initInputs: self.inputs = initInputs self.unparsedInputs = unparsedInputs # # Mandatory options # # service & Request are already controlled # version self.checkVersion() # identifier if "identifier" in self.unparsedInputs: self.inputs["identifier"] = [self.unparsedInputs["identifier"]] else: raise pywps.MissingParameterValue("identifier") # # Optional options # # Language self.checkLanguage() # dataInputs try: self.inputs["datainputs"] = self.parseDataInputs( self.unparsedInputs["datainputs"]) except KeyError: self.inputs["datainputs"] = None # ResponseForm self.inputs["responseform"] = {} # ResponseDocument try: self.inputs["responseform"]["responsedocument"] = \ {"outputs": self.parseDataInputs(self.unparsedInputs["responsedocument"])} except KeyError: self.inputs["responseform"]["responsedocument"] = {} # RawDataOutput try: preparsed = self.parseDataInputs(self.unparsedInputs["rawdataoutput"]) self.inputs["responseform"]["rawdataoutput"] = self._parseRawDataOutput(preparsed[0]) except KeyError: self.inputs["responseform"]["rawdataoutput"] = {} # storeExecuteResponse if "storeexecuteresponse" in self.unparsedInputs: if self.unparsedInputs["storeexecuteresponse"].lower() ==\ "true": self.inputs["responseform"]["responsedocument"]["storeexecuteresponse"] = True else: self.inputs["responseform"]["responsedocument"]["storeexecuteresponse"] = False # lineage if "lineage" in self.unparsedInputs: if self.unparsedInputs["lineage"].lower() == "true": self.inputs["responseform"]["responsedocument"]["lineage"]=\ True else: self.inputs["responseform"]["responsedocument"]["lineage"]=\ False # status if "status" in self.unparsedInputs: if self.unparsedInputs["status"].lower() == "true": self.inputs["responseform"]["responsedocument"]["status"]=\ True else: self.inputs["responseform"]["responsedocument"]["status"]=\ False # OGC 05-007r7 page 36, Table 49 # Either responseDocument or rawDataOutput should be specified, not both if len(self.inputs["responseform"]["rawdataoutput"])>0 and \ len(self.inputs["responseform"]["responsedocument"])>0: raise pywps.InvalidParameterValue("responseDocument", "Either responseDocument or rawDataOutput should be specified, but not both") return self.inputs
def parse(self,document, initInputs=None): """ Parse given XML document """ if initInputs: self.inputs = initInputs self.document = document # input DOM firstChild = self.isSoapFirstChild(self.document) # no comments or # white spaces self.nameSpace = firstChild.namespaceURI # document namespace self.nameSpace = pywps.WPS_NAMESPACE self.owsNameSpace = pywps.OWS_NAMESPACE self.xlinkNameSpace = pywps.XLINK_NAMESPACE language = None identifiers = [] identifierNode = None dataInputs = [] # # Mandatory options # # service & Request are already controlled # version self.checkVersion(firstChild) # identifier try: self.inputs["identifier"] = [ firstChild.getElementsByTagNameNS(self.owsNameSpace,"Identifier")[0].firstChild.nodeValue ] except IndexError: raise pywps.MissingParameterValue("Identifier") # # Optional options # # language self.checkLanguage(firstChild) # dataInputs try: inputsNode = firstChild.getElementsByTagNameNS( self.nameSpace,"DataInputs")[0] self.inputs["datainputs"] = self.parseDataInputs(inputsNode) except IndexError: self.inputs["datainputs"] = None # responseForm try: responseFormNode = \ firstChild.getElementsByTagNameNS(self.nameSpace, "ResponseForm")[0] self.inputs["responseform"] = self.parseResponseForm( responseFormNode) except IndexError: self.inputs["responseform"] = {} # OGC 05-007r7 page 36, Table 49 # Either responseDocument or rawDataOutput should be specified, not both if self.inputs.has_key('responseform') and \ (self.inputs["responseform"].has_key("rawdataoutput") and \ self.inputs["responseform"].has_key("responsedocument")) and \ self.inputs["responseform"]["responsedocument"] and \ self.inputs["responseform"]["rawdataoutput"]: raise pywps.InvalidParameterValue("responseDocument", "Either responseDocument or rawDataOutput should be specified, but not both") if not self.inputs["responseform"].has_key("rawdataoutput"): self.inputs["responseform"]["rawdataoutput"] = {} if not self.inputs["responseform"].has_key("responsedocument"): self.inputs["responseform"]["responsedocument"] = {} return self.inputs
def parseReferenceDataInput(self,dataTypeNode): """ Parse given complex value reference node """ attributes = {} # # mandatory attributes # attributes["value"] =\ dataTypeNode.getAttributeNS(self.xlinkNameSpace,"href") if attributes["value"] == "": raise pywps.MissingParameterValue("'href'") # # optional attributes # # mimeType, encoding, schema - are now supportd supported ^_^ #jmdj attributes["mimetype"]=dataTypeNode.getAttribute("mimeType") attributes["encoding"]=dataTypeNode.getAttribute("encoding") attributes["schema"]=dataTypeNode.getAttribute("schema") #jmdj GET method doesn't have a namespace attributes["method"] = dataTypeNode.getAttribute("method") if attributes["method"] == "": attributes["method"] = "GET" # header try: attributes["header"] = self.parseHeaderDataInput( dataTypeNode.getElementsByTagNameNS( self.nameSpace, "Header")[0]) except IndexError: attributes["header"] = None # body try: attributes["body"] = \ dataTypeNode.getElementsByTagNameNS(self.nameSpace, "Body")[0].firstChild # get node value, if node type is Text or CDATA if attributes["body"].nodeType == \ xml.dom.minidom.Text.nodeType or\ attributes["body"].nodeType ==\ xml.dom.minidom.CDATASection.nodeType: attributes["body"] = attributes["body"].nodeValue except IndexError: attributes["body"] = None # bodyreference try: bodyReferenceNode = dataTypeNode.getElementsByTagNameNS( self.nameSpace,"BodyReference")[0] attributes["bodyreference"] = bodyReferenceNode.getAttributeNS( self.xlinkNameSpace,"href") except IndexError: attributes["bodyreference"] = None attributes["type"] = "ComplexValue" attributes["asReference"] = True return attributes