public override bool Parse(XmlNode node) { Format.ParseValue(node); if (Formats.Find(delegate(ComplexFormat cf) { return(cf.Equals(Format)); }) == null) { throw new ExceptionReport(string.Format("Requested format for the output {0} is not supported", Identifier), ExceptionCode.InvalidParameterValue, Identifier); } return(true); }
public override bool Parse(string str, ProcessDescription processDescription) { if (String.IsNullOrEmpty(str)) { return(false); } string[] tokens = str.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (tokens.Length != 1) { throw new ExceptionReport("One identifier is mandatory when requesting a raw data output but " + tokens.Length + " were found.", ExceptionCode.InvalidParameterValue, "RawDataOutput"); } string[] kv = str.Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries); if (kv.Length > 0) { OutputData outputData = processDescription.GetProcessOutputParameter(kv[0]); if (outputData == null) { throw new ExceptionReport(String.Format("The output {0} is not a valid output for the process {1}", kv[0], processDescription.Identifier), ExceptionCode.InvalidParameterValue, "rawDataOutput"); } ComplexOutput output = outputData.asComplexOutput(); if (output == null) { throw new ExceptionReport(String.Format("Only ComplexOutputs can be requested as rawDataOutput but {0} is a {1}", kv[0], outputData.GetType().ToString()), ExceptionCode.InvalidParameterValue, "rawDataOutput"); } Identifier = kv[0]; Format = output.Format; // default format Format.ParseValue(str); if (output.Formats.Find(delegate(ComplexFormat cf) { return(cf.Equals(Format)); }) == null) { throw new ExceptionReport(string.Format("Requested format for the output {0} is not supported", kv[0]), ExceptionCode.InvalidParameterValue, kv[0]); } } return(false); }
public override bool Parse(XmlNode node, ProcessDescription processDescription) { if (node == null) { return(false); } XmlNamespaceManager nsmgr = Utils.CreateWPSNamespaceManager(node.OwnerDocument); XmlNodeList childs = node.SelectNodes("ows:Identifier", nsmgr); if (childs.Count != 1) { throw new ExceptionReport("One identifier is mandatory when requesting a raw data output but " + childs.Count + " were found.", ExceptionCode.InvalidParameterValue, "wps:RawDataOutput/ows:Identifier"); } Identifier = childs[0].InnerText; OutputData outputData = processDescription.GetProcessOutputParameter(Identifier); if (outputData == null) { throw new ExceptionReport(String.Format("The output {0} is not a valid output for the process {1}", Identifier, processDescription.Identifier), ExceptionCode.InvalidParameterValue, "rawDataOutput"); } ComplexOutput processOutput = outputData.asComplexOutput(); if (processOutput == null) { throw new ExceptionReport(String.Format("Only ComplexOutputs can be requested as rawDataOutput but {0} is a {1}", Identifier, outputData.GetType().Name), ExceptionCode.InvalidParameterValue, "rawDataOutput"); } Format = processOutput.Format; Format.ParseValue(node); return(true); }
public override bool ParseValue(XmlNode node) { XmlNamespaceManager nsmgr = Utils.CreateWPSNamespaceManager(node.OwnerDocument); XmlNode childNode = node.SelectSingleNode("wps:Data/wps:ComplexData", nsmgr); if (childNode == null) { childNode = node.SelectSingleNode("wps:Reference", nsmgr); if (childNode == null) { throw new ExceptionReport("The parameter '" + Identifier + "' has not a valid value!", ExceptionCode.InvalidParameterValue, Identifier); } asReference = true; Reference = Utils.GetXmlAttributesValue(childNode, "xlink:href"); Method = Utils.GetXmlAttributesValue(childNode, "method", Method); if (Utils.StrICmp(Method, "POST")) { XmlNodeList headerList = childNode.SelectNodes("Header", nsmgr); foreach (XmlNode headerItem in headerList) { string key = Utils.GetXmlAttributesValue(headerItem, "key"); string value = Utils.GetXmlAttributesValue(headerItem, "value"); if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(value)) { throw new ExceptionReport(String.Format("[key:{0}; value:{1}] is not a valid request header. when parsing header data structure from the reference related to '{2}'!", key, value, Identifier), ExceptionCode.InvalidParameterValue, "Header"); } Header.Add(key, value); } XmlNode bodyNode = childNode.SelectSingleNode("Body", nsmgr); XmlNode bodyReferenceNode = childNode.SelectSingleNode("BodyReference", nsmgr); if (bodyNode != null) { if (bodyReferenceNode != null) { throw new ExceptionReport(String.Format("Only one kind of Request Body is allowed, but Body and BodyReference were found when parsing the parameter {0}!", Identifier), ExceptionCode.InvalidParameterValue, "Reference"); } Body = bodyNode.InnerXml; } else if (bodyReferenceNode != null) { BodyAsReference = true; BodyReference = Utils.GetXmlAttributesValue(bodyReferenceNode, "xlink:href"); try { Body = System.Text.Encoding.UTF8.GetString(Utils.GetReferenceDataFromGetRequest(BodyReference)); } catch (WebException e) { throw new ExceptionReport(String.Format("An error occurred when gathering the POST request for the complex input {0} from {1}: {2}", Identifier, BodyReference, e.Message), ExceptionCode.NoApplicableCode); } catch (Exception /*e*/) { throw new ExceptionReport(String.Format("An error occurred when gathering the POST request for the complex input {0} from {1}. You may contact the administrator if the problem persists.", Identifier), ExceptionCode.NoApplicableCode); } } else { throw new ExceptionReport("Only one kind of Request Body is allowed, but Body and BodyReference were found!", ExceptionCode.InvalidParameterValue, "ResponseForm"); } } else if (!Utils.StrICmp(Method, "GET")) { throw new ExceptionReport(String.Format("The input {0} can not be retrieved because '{1}' is not a valid value for the parameter method!", Identifier, Method), ExceptionCode.InvalidParameterValue, "method"); } GetValueFromReference(); } else { // ComplexData embedded in the xml Value = System.Text.Encoding.UTF8.GetBytes(childNode.InnerXml); } Format.ParseValue(childNode); if (Formats.Find(delegate(ComplexFormat cf) { return(cf.Equals(Format)); }) == null) { throw new ExceptionReport(string.Format("Requested format for the input {0} is not supported", Identifier), ExceptionCode.InvalidParameterValue, Identifier); } if (maximumMegabytes != -1 && Value.Length / 1048576 > maximumMegabytes) { throw new ExceptionReport("Maximum file size is " + maximumMegabytes + " MB, but provided data size is " + Value.Length / 1048576 + " MB.", ExceptionCode.FileSizeExceeded, Identifier); } return(true); }
public override bool Parse(string str, ProcessDescription processDescription) { if (String.IsNullOrEmpty(str)) return false; string[] tokens = str.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (tokens.Length != 1) throw new ExceptionReport("One identifier is mandatory when requesting a raw data output but " + tokens.Length + " were found.", ExceptionCode.InvalidParameterValue, "RawDataOutput"); string[] kv = str.Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries); if (kv.Length > 0) { OutputData outputData = processDescription.GetProcessOutputParameter(kv[0]); if (outputData == null) throw new ExceptionReport(String.Format("The output {0} is not a valid output for the process {1}", kv[0], processDescription.Identifier), ExceptionCode.InvalidParameterValue, "rawDataOutput"); ComplexOutput output = outputData.asComplexOutput(); if (output == null) throw new ExceptionReport(String.Format("Only ComplexOutputs can be requested as rawDataOutput but {0} is a {1}", kv[0], outputData.GetType().ToString()), ExceptionCode.InvalidParameterValue, "rawDataOutput"); Identifier = kv[0]; Format = output.Format; // default format Format.ParseValue(str); if (output.Formats.Find(delegate(ComplexFormat cf) { return cf.Equals(Format); }) == null) throw new ExceptionReport(string.Format("Requested format for the output {0} is not supported", kv[0]), ExceptionCode.InvalidParameterValue, kv[0]); } return false; }
public override bool Parse(XmlNode node, ProcessDescription processDescription) { if (node == null) return false; XmlNamespaceManager nsmgr = Utils.CreateWPSNamespaceManager(node.OwnerDocument); XmlNodeList childs = node.SelectNodes("ows:Identifier", nsmgr); if (childs.Count != 1) throw new ExceptionReport("One identifier is mandatory when requesting a raw data output but " + childs.Count + " were found.", ExceptionCode.InvalidParameterValue, "wps:RawDataOutput/ows:Identifier"); Identifier = childs[0].InnerText; OutputData outputData = processDescription.GetProcessOutputParameter(Identifier); if (outputData == null) throw new ExceptionReport(String.Format("The output {0} is not a valid output for the process {1}", Identifier, processDescription.Identifier), ExceptionCode.InvalidParameterValue, "rawDataOutput"); ComplexOutput processOutput = outputData.asComplexOutput(); if (processOutput == null) throw new ExceptionReport(String.Format("Only ComplexOutputs can be requested as rawDataOutput but {0} is a {1}", Identifier, outputData.GetType().Name), ExceptionCode.InvalidParameterValue, "rawDataOutput"); Format = processOutput.Format; Format.ParseValue(node); return true; }