Exemple #1
0
        public override bool Parse(string str, ProcessDescription processDescription)
        {
            if (String.IsNullOrEmpty(str))
            {
                return(false);
            }

            string[] tokens = str.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            ExceptionReport exception = null;

            foreach (string param in tokens)
            {
                string[] kv = param.Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries);
                if (kv.Length > 0)
                {
                    OutputData output = processDescription.GetProcessOutputParameter(kv[0]);
                    if (output != null)
                    {
                        OutputData myoutput = output.Clone();
                        try
                        {
                            myoutput.Parse(param);
                            Outputs.Add(myoutput);
                        }
                        catch (ExceptionReport e)
                        {
                            exception = new ExceptionReport(e, exception);
                        }
                    }
                    else
                    {
                        exception = new ExceptionReport(exception, "The output "
                                                        + kv[0] + " is not a valid output for the process " + processDescription.Identifier,
                                                        ExceptionCode.InvalidParameterValue, "responseDocument");
                    }
                }
            }

            if (exception != null)
            {
                throw exception;
            }

            return(tokens.Length != 0);
        }
Exemple #2
0
        public override bool Parse(XmlNode node, ProcessDescription processDescription)
        {
            if (node == null)
            {
                return(false);
            }

            // Create an XmlNamespaceManager for resolving namespaces.
            XmlNamespaceManager nsmgr = Utils.CreateWPSNamespaceManager(node.OwnerDocument);

            lineage = Boolean.Parse(Utils.GetXmlAttributesValue(node, "lineage", "false"));
            status  = Boolean.Parse(Utils.GetXmlAttributesValue(node, "status", "false"));
            storeExecuteResponse = Boolean.Parse(Utils.GetXmlAttributesValue(node, "storeExecuteResponse", "false"));

            XmlNodeList outputs = node.SelectNodes("wps:Output", nsmgr);

            if (outputs.Count == 0)
            {
                throw new ExceptionReport(String.Format("No 'wps:Output' node was found inside the 'wps:ResponseDocument' node for the process '{0}'. Please check your request.",
                                                        processDescription.Identifier),
                                          ExceptionCode.MissingParameterValue, processDescription.Identifier);
            }

            ExceptionReport exception = null;

            foreach (XmlNode output in outputs)
            {
                XmlNode id    = output.SelectSingleNode("ows:Identifier", nsmgr);
                XmlNode abst  = output.SelectSingleNode("ows:Abstract", nsmgr);
                XmlNode title = output.SelectSingleNode("ows:Title", nsmgr);

                string identifier = id.InnerText;
                string titleStr   = title != null ? title.InnerText : "";
                string abstStr    = abst != null ? abst.InnerText : "";

                OutputData processOutput = processDescription.GetProcessOutputParameter(identifier);
                if (processOutput != null)
                {
                    OutputData myoutput = processOutput.Clone();
                    myoutput.Title       = titleStr;
                    myoutput.Abstract    = abstStr;
                    myoutput.asReference = Boolean.Parse(Utils.GetXmlAttributesValue(output, "asReference", "false"));
                    if (myoutput.asReference && !processDescription.storeSupported)
                    {
                        exception = new ExceptionReport(exception,
                                                        String.Format("The storage of response is not supported for the process {0} but is requested for the output {1}.",
                                                                      processDescription.Identifier, identifier),
                                                        ExceptionCode.StorageNotSupported);
                    }
                    try
                    {
                        myoutput.Parse(output);
                        Outputs.Add(myoutput);
                    }
                    catch (ExceptionReport e)
                    {
                        exception = new ExceptionReport(e, exception);
                    }
                }
                else
                {
                    exception = new ExceptionReport(exception, String.Format("The output {0} is not a valid output for the process {1}",
                                                                             identifier, processDescription.Identifier), ExceptionCode.InvalidParameterValue, "responseDocument");
                }
            }

            if (exception != null)
            {
                throw exception;
            }

            return(true);
        }