The detailed data result for the SubmitFile WSDL operation.
        /// <summary>
        /// This operation is used to submit a file and its associated properties to the repository.
        /// </summary>
        /// <param name="fileToSubmit">The contents of the file.</param>
        /// <param name="properties"> The properties of the file.</param>
        /// <param name="recordRouting">The file type.</param>
        /// <param name="sourceUrl">The source URL of the file.</param>
        /// <param name="userName">The name of the user submitting the file.</param>
        /// <returns>The data of SubmitFileResult or SoapException thrown.</returns>
        public SubmitFileResult SubmitFile(
            [XmlElementAttribute(DataType = "base64Binary")] byte[] fileToSubmit,
            [XmlArrayItemAttribute(IsNullable = false)] RecordsRepositoryProperty[] properties,
            string recordRouting,
            string sourceUrl,
            string userName)
        {
            string submitFileResult = this.officialfileService.SubmitFile(
                fileToSubmit, properties, recordRouting, sourceUrl, userName);

            // As response is returned successfully, the transport related requirements can be captured.
            this.VerifyTransportRelatedRequirments();

            SubmitFileResult value = this.VerifyAndParseSubmitFile(submitFileResult);

            return(value);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Verify the requirements of SubmitFile in Adapter.
        /// When the server returns a SubmitFile response successfully,
        /// which includes web service output message and soap fault.
        /// </summary>
        /// <param name="result">The response of SubmitFile.</param>
        /// <returns>Return the SubmitFileResult corresponding class instance.</returns>
        private SubmitFileResult VerifyAndParseSubmitFile(string result)
        {
            #region verify schema of SubmitFile

            // Verify MS-OFFICIALFILE requirement: MS-OFFICIALFILE_R197
            Site.CaptureRequirement(
                "MS-OFFICIALFILE",
                197,
                @"[In SubmitFile] [This method is called to submit a file and its associated properties to the repository.]
                     <wsdl:operation name=""SubmitFile"" xmlns:wsdl=""http://schemas.xmlsoap.org/wsdl/"">
                       <wsdl:input message=""tns:SubmitFileSoapIn""/>
                       <wsdl:output message=""tns:SubmitFileSoapOut""/>
                     </wsdl:operation>");

            // Verify MS-OFFICIALFILE requirement: MS-OFFICIALFILE_R224
            Site.CaptureRequirement(
                "MS-OFFICIALFILE",
                224,
                @"[In SubmitFileSoapOut] The SOAP body contains the SubmitFileResponse element.");

            // Verify MS-OFFICIALFILE requirement: MS-OFFICIALFILE_R198
            Site.CaptureRequirement(
                "MS-OFFICIALFILE",
                198,
                @"[In SubmitFile] The protocol client sends a SubmitFileSoapIn request WSDL message, and the protocol server MUST respond with a SubmitFileSoapOut response WSDL message.");

            // Verify MS-OFFICIALFILE requirement: MS-OFFICIALFILE_R237
            Site.CaptureRequirement(
                "MS-OFFICIALFILE",
                237,
                @"[In SubmitFileResponse] The SubmitFileResponse element specifies the result data for the SubmitFile WSDL operation.
                     <xs:element name=""SubmitFileResponse"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
                       <xs:complexType>
                         <xs:sequence>
                           <xs:element minOccurs=""0"" maxOccurs=""1"" name=""SubmitFileResult"" type=""xs:string""/>
                         </xs:sequence>
                       </xs:complexType>
                     </xs:element>");

            #endregion verify of SubmitFile

            #region schema of response result of SubmitFile

            // Validate the SubmitFileResult string which confirm to the specified XML definition.
            result = @"<SubmitFileResult xmlns=""http://schemas.microsoft.com/sharepoint/soap/recordsrepository/"">" + result + "</SubmitFileResult>";
            Common.ValidationResult validationResult = Common.SchemaValidation.ValidateXml(this.Site, result);

            // Verify MS-OFFICIALFILE requirement: MS-OFFICIALFILE_R238
            Site.CaptureRequirementIfAreEqual <Common.ValidationResult>(
                Common.ValidationResult.Success,
                validationResult,
                "MS-OFFICIALFILE",
                238,
                @"[In SubmitFileResponse] SubmitFileResult: Data details about the result, which is a string of an encoded XML fragment that MUST conform to the XML schema of the SubmitFileResult complex type.");

            // Parse the SubmitFileResult from xml to class.
            SubmitFileResult value = this.ParseSubmitFileResult(result);

            // Verify MS-OFFICIALFILE requirement: MS-OFFICIALFILE_R239
            Site.CaptureRequirementIfAreEqual <Common.ValidationResult>(
                Common.ValidationResult.Success,
                validationResult,
                "MS-OFFICIALFILE",
                239,
                @"[In SubmitFileResult] The detailed data result for the SubmitFile WSDL operation.
                     <xs:complexType name=""SubmitFileResult"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
                       <xs:sequence>
                         <xs:element name=""ResultCode"" type=""tns:SubmitFileResultCode""/>
                         <xs:choice>
                           <xs:element minOccurs=""0"" name=""ResultUrl"" type=""xs:anyURI""/>
                           <xs:element minOccurs=""0"" name=""AdditionalInformation"" type=""xs:string""/>
                         </xs:choice>
                         <xs:element minOccurs=""0"" name=""CustomProcessingResult"" type=""tns:CustomProcessingResult""/>
                       </xs:sequence>
                     </xs:complexType>");

            if (value.CustomProcessingResult != null)
            {
                // Verify MS-OFFICIALFILE requirement: MS-OFFICIALFILE_R244
                Site.CaptureRequirementIfAreEqual <Common.ValidationResult>(
                    Common.ValidationResult.Success,
                    validationResult,
                    "MS-OFFICIALFILE",
                    244,
                    @"[In CustomProcessingResult] The result of custom processing of a legal hold.
                     <xs:complexType name=""CustomProcessingResult"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
                       <xs:sequence>
                         <xs:element minOccurs=""0"" name=""HoldsProcessingResult"" type=""tns:HoldProcessingResult""/>
                       </xs:sequence>
                     </xs:complexType");

                // Verify MS-OFFICIALFILE requirement: MS-OFFICIALFILE_R256
                Site.CaptureRequirementIfAreEqual <Common.ValidationResult>(
                    Common.ValidationResult.Success,
                    validationResult,
                    "MS-OFFICIALFILE",
                    256,
                    @"[In HoldProcessingResult] The result of processing a legal hold.
                     <xs:simpleType name=""HoldProcessingResult"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
                       <xs:restriction base=""xs:string"">
                         <xs:enumeration value=""Success""/>
                         <xs:enumeration value=""Failure""/>
                         <xs:enumeration value=""InDropOffZone""/>
                       </xs:restriction>
                     </xs:simpleType>");
            }

            // Verify MS-OFFICIALFILE requirement: MS-OFFICIALFILE_R246
            Site.CaptureRequirementIfAreEqual <Common.ValidationResult>(
                Common.ValidationResult.Success,
                validationResult,
                "MS-OFFICIALFILE",
                246,
                @"[In SubmitFileResultCode] The result status code of a SubmitFile WSDL operation.
                     <xs:simpleType name=""SubmitFileResultCode"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
                       <xs:restriction base=""xs:string"">
                         <xs:enumeration value=""Success""/>
                         <xs:enumeration value=""MoreInformation""/>
                         <xs:enumeration value=""InvalidRouterConfiguration""/>
                         <xs:enumeration value=""InvalidArgument""/>
                         <xs:enumeration value=""InvalidUser""/>
                         <xs:enumeration value=""NotFound""/>
                         <xs:enumeration value=""FileRejected""/>
                         <xs:enumeration value=""UnknownError""/>
                       </xs:restriction>
                     </xs:simpleType>");
            #endregion schema of response result of SubmitFile
            return(value);
        }
        /// <summary>
        /// This method is used to parse the SubmitFileResult from xml to class.
        /// </summary>
        /// <param name="response">The value response from server.</param>
        /// <returns>Enum value of SubmitFileResult.</returns>
        private SubmitFileResult ParseSubmitFileResult(string response)
        {
            SubmitFileResult result = new SubmitFileResult();

            // Read string in SubmitFileResult response
            XmlDocument document = new XmlDocument();

            document.LoadXml(response);

            XmlNodeList nodeList = null;
            XmlNode     node     = null;

            nodeList = document.GetElementsByTagName("ResultCode");
            if (nodeList != null && nodeList.Count == 1)
            {
                node = nodeList[0];
                switch (node.InnerText)
                {
                case "Success":
                    result.ResultCode = SubmitFileResultCode.Success;
                    break;

                case "MoreInformation":
                    result.ResultCode = SubmitFileResultCode.MoreInformation;
                    break;

                case "InvalidRouterConfiguration":
                    result.ResultCode = SubmitFileResultCode.InvalidRouterConfiguration;
                    break;

                case "InvalidArgument":
                    result.ResultCode = SubmitFileResultCode.InvalidArgument;
                    break;

                case "InvalidUser":
                    result.ResultCode = SubmitFileResultCode.InvalidUser;
                    break;

                case "NotFound":
                    result.ResultCode = SubmitFileResultCode.NotFound;
                    break;

                case "FileRejected":
                    result.ResultCode = SubmitFileResultCode.FileRejected;
                    break;

                case "UnknownError":
                    result.ResultCode = SubmitFileResultCode.UnknownError;
                    break;

                default:
                    break;
                }
            }

            nodeList = document.GetElementsByTagName("CustomProcessingResult");
            if (nodeList != null && nodeList.Count == 1)
            {
                node = nodeList[0];
                result.CustomProcessingResult = new CustomProcessingResult();
                switch (node.InnerText)
                {
                case "Success":
                    result.CustomProcessingResult.HoldProcessingResult = HoldProcessingResult.Success;
                    break;

                case "Failure":
                    result.CustomProcessingResult.HoldProcessingResult = HoldProcessingResult.Failure;
                    break;

                case "InDropOffZone":
                    result.CustomProcessingResult.HoldProcessingResult = HoldProcessingResult.InDropOffZone;
                    break;

                default:
                    break;
                }
            }

            nodeList = document.GetElementsByTagName("ResultUrl");
            if (nodeList != null && nodeList.Count == 1)
            {
                node             = nodeList[0];
                result.ResultUrl = node.InnerText;
            }

            nodeList = document.GetElementsByTagName("AdditionalInformation");
            if (nodeList != null && nodeList.Count == 1)
            {
                node = nodeList[0];
                result.AdditionalInformation = node.InnerText;
            }

            return(result);
        }
        /// <summary>
        /// This method is used to parse the SubmitFileResult from xml to class.
        /// </summary>
        /// <param name="response">The value response from server.</param>
        /// <returns>Enum value of SubmitFileResult.</returns>
        private SubmitFileResult ParseSubmitFileResult(string response)
        {
            SubmitFileResult result = new SubmitFileResult();

            // Read string in SubmitFileResult response
            XmlDocument document = new XmlDocument();
            document.LoadXml(response);

            XmlNodeList nodeList = null;
            XmlNode node = null;

            nodeList = document.GetElementsByTagName("ResultCode");
            if (nodeList != null && nodeList.Count == 1)
            {
                node = nodeList[0];
                switch (node.InnerText)
                {
                    case "Success":
                        result.ResultCode = SubmitFileResultCode.Success;
                        break;
                    case "MoreInformation":
                        result.ResultCode = SubmitFileResultCode.MoreInformation;
                        break;
                    case "InvalidRouterConfiguration":
                        result.ResultCode = SubmitFileResultCode.InvalidRouterConfiguration;
                        break;
                    case "InvalidArgument":
                        result.ResultCode = SubmitFileResultCode.InvalidArgument;
                        break;
                    case "InvalidUser":
                        result.ResultCode = SubmitFileResultCode.InvalidUser;
                        break;
                    case "NotFound":
                        result.ResultCode = SubmitFileResultCode.NotFound;
                        break;
                    case "FileRejected":
                        result.ResultCode = SubmitFileResultCode.FileRejected;
                        break;
                    case "UnknownError":
                        result.ResultCode = SubmitFileResultCode.UnknownError;
                        break;
                    default:
                        break;
                }
            }

            nodeList = document.GetElementsByTagName("CustomProcessingResult");
            if (nodeList != null && nodeList.Count == 1)
            {
                node = nodeList[0];
                result.CustomProcessingResult = new CustomProcessingResult();
                switch (node.InnerText)
                {
                    case "Success":
                        result.CustomProcessingResult.HoldProcessingResult = HoldProcessingResult.Success;
                        break;
                    case "Failure":
                        result.CustomProcessingResult.HoldProcessingResult = HoldProcessingResult.Failure;
                        break;
                    case "InDropOffZone":
                        result.CustomProcessingResult.HoldProcessingResult = HoldProcessingResult.InDropOffZone;
                        break;
                    default:
                        break;
                }
            }

            nodeList = document.GetElementsByTagName("ResultUrl");
            if (nodeList != null && nodeList.Count == 1)
            {
                node = nodeList[0];
                result.ResultUrl = node.InnerText;
            }

            nodeList = document.GetElementsByTagName("AdditionalInformation");
            if (nodeList != null && nodeList.Count == 1)
            {
                node = nodeList[0];
                result.AdditionalInformation = node.InnerText;
            }

            return result;
        }
        /// <summary>
        /// This method is used to verify all the related requirements when the submit file succeeds.
        /// </summary>
        /// <param name="submitFileResult">The SubmitFileResult respond by the protocol server.</param>
        private void VerifySubmitFileSucceed(SubmitFileResult submitFileResult)
        {
            // Add the log information.
            Site.Log.Add(
                Microsoft.Protocols.TestTools.LogEntryKind.Comment,
                "ResultUrl is {0}, ResultCode is {1}.",
                submitFileResult.ResultUrl,
                submitFileResult.ResultCode);

            // Verify MS-OFFICIALFILE requirement: MS-OFFICIALFILE_R213
            Site.CaptureRequirementIfAreEqual<SubmitFileResultCode?>(
                     SubmitFileResultCode.Success,
                     submitFileResult.ResultCode,
                     "MS-OFFICIALFILE",
                     213,
                     @"[In SubmitFile] [The protocol client sends a SubmitFileSoapIn request WSDL message, and the protocol server MUST respond with a SubmitFileSoapOut response WSDL message, as follows:]
[If implementation-specific errors occur while determining the storage location for the submission or while storing the file, the protocol server MUST set the ResultCode element to UnknownError and return.] Otherwise, , the protocol server MUST set the ResultCode element to Success [and SHOULD<16> set the ResultUrl element to a non-empty HTML encoded URL to retrieve the stored file.]");

            // Verify MS-OFFICIALFILE requirement: MS-OFFICIALFILE_R248
            Site.CaptureRequirementIfAreEqual<SubmitFileResultCode?>(
                     SubmitFileResultCode.Success,
                     submitFileResult.ResultCode,
                     "MS-OFFICIALFILE",
                     248,
                     @"[In SubmitFileResultCode] [If] The operation [SubmitFile] is successful. [SubmitFileResultCode] Value is Success.");

            if (Common.Common.IsRequirementEnabled(1067, this.Site))
            {
                Site.CaptureRequirementIfIsNotNull(
                         submitFileResult.ResultUrl,
                         "MS-OFFICIALFILE",
                         1067,
                         @"[In Appendix B: Product Behavior] Implementation does set the ResultCode element to Success and set the ResultUrl element to a non-empty HTML encoded URL to retrieve the stored file if implementation-specific errors doesn't occur while determining the storage location for the submission or while storing the file. (Microsoft SharePoint Server 2010 and above follow this behavior.)");
            }

            if (Common.Common.IsRequirementEnabled(1066, this.Site))
            {
                // Verify MS-OFFICIALFILE requirement: MS-OFFICIALFILE_R1066
                Site.CaptureRequirementIfIsNotNull(
                         submitFileResult.AdditionalInformation,
                         "MS-OFFICIALFILE",
                         1066,
                         @"[In Appendix B: Product Behavior] Implementation does set the ResultUrl element to a non-empty HTML encoded URL in the AdditionalInformation element to retrieve the stored file. <16> Section 3.1.4.6:  Office SharePoint Server 2007 returns the URL in the AdditionalInformation element.");
            }
        }