This class is used to specify the cell identifier.
Inheritance: BasicObject
Exemplo n.º 1
0
        private List <RevisionStoreObjectGroup> ParseObjectGroup(CellID objectGroupCellID, MSOneStorePackage package)
        {
            StorageIndexCellMapping         storageIndexCellMapping = package.FindStorageIndexCellMapping(objectGroupCellID);
            CellManifestDataElementData     cellManifest            = this.FindCellManifest(storageIndexCellMapping.CellMappingExtendedGUID);
            List <RevisionStoreObjectGroup> objectGroups            = new List <RevisionStoreObjectGroup>();

            package.CellManifests.Add(cellManifest);
            StorageIndexRevisionMapping revisionMapping =
                package.FindStorageIndexRevisionMapping(cellManifest.CellManifestCurrentRevision.CellManifestCurrentRevisionExtendedGUID);
            RevisionManifestDataElementData revisionManifest =
                this.FindRevisionManifestDataElement(revisionMapping.RevisionMappingExtendedGUID);

            package.RevisionManifests.Add(revisionManifest);
            RevisionManifestRootDeclare encryptionKeyRoot = revisionManifest.RevisionManifestRootDeclareList.Where(r => r.RootExtendedGUID.Equals(new ExGuid(3, Guid.Parse("4A3717F8-1C14-49E7-9526-81D942DE1741")))).SingleOrDefault();
            bool isEncryption = encryptionKeyRoot != null;

            foreach (RevisionManifestObjectGroupReferences objRef in revisionManifest.RevisionManifestObjectGroupReferencesList)
            {
                ObjectGroupDataElementData dataObject = objectGroupDataElements.Where(d => d.DataElementExtendedGUID.Equals(
                                                                                          objRef.ObjectGroupExtendedGUID)).Single().Data as ObjectGroupDataElementData;

                RevisionStoreObjectGroup objectGroup = RevisionStoreObjectGroup.CreateInstance(objRef.ObjectGroupExtendedGUID, dataObject, isEncryption);
                objectGroups.Add(objectGroup);
            }

            return(objectGroups);
        }
        /// <summary>
        /// This method is used to get cell manifest data element from a list of data element.
        /// </summary>
        /// <param name="dataElements">Specify the data element list.</param>
        /// <param name="manifestDataElementData">Specify the manifest data element.</param>
        /// <param name="cellIDMappings">Specify mapping of cell id.</param>
        /// <returns>Return the cell manifest data element.</returns>
        public static CellManifestDataElementData GetCellManifestDataElementData(List <DataElement> dataElements, StorageManifestDataElementData manifestDataElementData, Dictionary <CellID, ExGuid> cellIDMappings)
        {
            CellID cellID = new CellID(new ExGuid(1u, RootExGuid), new ExGuid(1u, CellSecondExGuid));

            foreach (StorageManifestRootDeclare kv in manifestDataElementData.StorageManifestRootDeclareList)
            {
                if (kv.RootExtendedGUID.Equals(new ExGuid(2u, RootExGuid)) && kv.CellID.Equals(cellID))
                {
                    if (!cellIDMappings.ContainsKey(kv.CellID))
                    {
                        throw new InvalidOperationException(string.Format("Cannot fin the Cell ID {0} in the cell id mapping", cellID.ToString()));
                    }

                    ExGuid cellMappingID = cellIDMappings[kv.CellID];

                    DataElement dataElement = dataElements.Find(element => element.DataElementExtendedGUID.Equals(cellMappingID));
                    if (dataElement == null)
                    {
                        throw new InvalidOperationException("Cannot find the  cell data element with ExGuid " + cellMappingID.GUID.ToString());
                    }

                    return(dataElement.GetData <CellManifestDataElementData>());
                }
            }

            throw new InvalidOperationException("Cannot find the CellManifestDataElement");
        }
        /// <summary>
        /// This method is used to find the Storage Index Cell Mapping matches the Cell ID.
        /// </summary>
        /// <param name="cellID">Specify the Cell ID.</param>
        /// <returns>Return the specific Storage Index Cell Mapping.</returns>
        public StorageIndexCellMapping FindStorageIndexCellMapping(CellID cellID)
        {
            StorageIndexCellMapping storageIndexCellMapping = null;

            if (this.StorageIndex != null)
            {
                storageIndexCellMapping = this.StorageIndex.StorageIndexCellMappingList.Where(s => s.CellID.Equals(cellID)).SingleOrDefault();
            }

            return(storageIndexCellMapping);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the CellID class, this is the copy constructor.
        /// </summary>
        /// <param name="cellId">Specify the CellID.</param>
        public CellID(CellID cellId)
        {
            if (cellId.ExtendGUID1 != null)
            {
                this.ExtendGUID1 = new ExGuid(cellId.ExtendGUID1);
            }

            if (cellId.ExtendGUID2 != null)
            {
                this.ExtendGUID2 = new ExGuid(cellId.ExtendGUID2);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the CellID class, this is the copy constructor.
        /// </summary>
        /// <param name="cellId">Specify the CellID.</param>
        public CellID(CellID cellId)
        {
            if (cellId.ExtendGUID1 != null)
            {
                this.ExtendGUID1 = new ExGuid(cellId.ExtendGUID1);
            }

            if (cellId.ExtendGUID2 != null)
            {
                this.ExtendGUID2 = new ExGuid(cellId.ExtendGUID2);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Used to de-serialize the items.
        /// </summary>
        /// <param name="byteArray">Byte array</param>
        /// <param name="currentIndex">Start position</param>
        /// <param name="lengthOfItems">The length of items</param>
        protected override void DeserializeItemsFromByteArray(byte[] byteArray, ref int currentIndex, int lengthOfItems)
        {
            int index = currentIndex;

            this.RootExtendedGUID = BasicObject.Parse <ExGuid>(byteArray, ref index);
            this.CellID           = BasicObject.Parse <CellID>(byteArray, ref index);

            if (index - currentIndex != lengthOfItems)
            {
                throw new StreamObjectParseErrorException(currentIndex, "StorageManifestRootDeclare", "Stream object over-parse error", null);
            }

            currentIndex = index;
        }
        /// <summary>
        /// This method is used to create the cell manifest data element.
        /// </summary>
        /// <param name="revisionId">Specify the revision GUID.</param>
        /// <param name="cellIDMapping">Input/output parameter to represent the mapping of cell manifest.</param>
        /// <returns>Return the cell manifest data element.</returns>
        public static DataElement CreateCellMainifestDataElement(ExGuid revisionId, ref Dictionary <CellID, ExGuid> cellIDMapping)
        {
            CellManifestDataElementData data = new CellManifestDataElementData();

            data.CellManifestCurrentRevision = new CellManifestCurrentRevision()
            {
                CellManifestCurrentRevisionExtendedGUID = new ExGuid(revisionId)
            };
            DataElement dataElement = new DataElement(DataElementType.CellManifestDataElementData, data);

            CellID cellID = new CellID(new ExGuid(1u, RootExGuid), new ExGuid(1u, CellSecondExGuid));

            cellIDMapping.Add(cellID, dataElement.DataElementExtendedGUID);
            return(dataElement);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Override the Equals method.
        /// </summary>
        /// <param name="obj">Specify the object.</param>
        /// <returns>Return true if equals, otherwise return false.</returns>
        public override bool Equals(object obj)
        {
            CellID another = obj as CellID;

            if (another == null)
            {
                return(false);
            }

            if (another.ExtendGUID1 != null && another.ExtendGUID2 != null && this.ExtendGUID1 != null && this.ExtendGUID2 != null)
            {
                return(another.ExtendGUID1.Equals(this.ExtendGUID1) && another.ExtendGUID2.Equals(this.ExtendGUID2));
            }

            return(false);
        }
Exemplo n.º 9
0
        public MSOneStorePackage Parse(DataElementPackage dataElementPackage)
        {
            MSOneStorePackage package = new MSOneStorePackage();

            storageIndexDataElements     = dataElementPackage.DataElements.Where(d => d.DataElementType == DataElementType.StorageIndexDataElementData).ToArray();
            storageManifestDataElements  = dataElementPackage.DataElements.Where(d => d.DataElementType == DataElementType.StorageManifestDataElementData).ToArray();
            cellManifestDataElements     = dataElementPackage.DataElements.Where(d => d.DataElementType == DataElementType.CellManifestDataElementData).ToArray();
            revisionManifestDataElements = dataElementPackage.DataElements.Where(d => d.DataElementType == DataElementType.RevisionManifestDataElementData).ToArray();
            objectGroupDataElements      = dataElementPackage.DataElements.Where(d => d.DataElementType == DataElementType.ObjectGroupDataElementData).ToArray();
            objectBlOBElements           = dataElementPackage.DataElements.Where(d => d.DataElementType == DataElementType.ObjectDataBLOBDataElementData).ToArray();

            package.StorageIndex    = storageIndexDataElements[0].Data as StorageIndexDataElementData;
            package.StorageManifest = storageManifestDataElements[0].Data as StorageManifestDataElementData;

            // Parse Header Cell
            CellID headerCellID = package.StorageManifest.StorageManifestRootDeclareList[0].CellID;
            StorageIndexCellMapping headerCellStorageIndexCellMapping = package.FindStorageIndexCellMapping(headerCellID);

            storageIndexHashTab.Add(headerCellID);

            if (headerCellStorageIndexCellMapping != null)
            {
                package.HeaderCellCellManifest = this.FindCellManifest(headerCellStorageIndexCellMapping.CellMappingExtendedGUID);
                StorageIndexRevisionMapping headerCellRevisionManifestMapping =
                    package.FindStorageIndexRevisionMapping(package.HeaderCellCellManifest.CellManifestCurrentRevision.CellManifestCurrentRevisionExtendedGUID);
                package.HeaderCellRevisionManifest = this.FindRevisionManifestDataElement(headerCellRevisionManifestMapping.RevisionMappingExtendedGUID);
                package.HeaderCell = this.ParseHeaderCell(package.HeaderCellRevisionManifest);

                // Parse Data root
                CellID dataRootCellID = package.StorageManifest.StorageManifestRootDeclareList[1].CellID;
                storageIndexHashTab.Add(dataRootCellID);
                package.DataRoot = this.ParseObjectGroup(dataRootCellID, package);
                // Parse other data
                foreach (StorageIndexCellMapping storageIndexCellMapping in package.StorageIndex.StorageIndexCellMappingList)
                {
                    if (storageIndexHashTab.Contains(storageIndexCellMapping.CellID) == false)
                    {
                        package.OtherFileNodeList.AddRange(this.ParseObjectGroup(storageIndexCellMapping.CellID, package));
                        storageIndexHashTab.Add(storageIndexCellMapping.CellID);
                    }
                }
            }
            return(package);
        }
 /// <summary>
 /// Initializes a new instance of the CellIDFilter class
 /// </summary>
 /// <param name="cellId">Specify the CellID.</param>
 public CellIDFilter(CellID cellId)
     : base(FilterType.CellIDFilter)
 {
     this.CellID = new CellID(cellId);
     this.QueryChangesFilterCellID = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.QueryChangesFilterCellID, this.CellID.SerializeToByteList().Count);
 }
        public void TestCase_S12_TC21_QueryChanges_CellID()
        {
            // Initialize the service on OneNote file.
            string fileUrl = Common.GetConfigurationPropertyValue("OneNoteFile", this.Site);
            this.InitializeContext(fileUrl, this.UserName01, this.Password01, this.Domain);

            // Query changes from the protocol server with Cell Id set to specified value.
            FsshttpbCellRequest cellRequestFirst = SharedTestSuiteHelper.CreateFsshttpbCellRequest();

            // Initialize a cell id defined in the MS-FSSHTTPD
            CellID cellId = new CellID(new ExGuid(1, new Guid("84DEFAB9-AAA3-4A0D-A3A8-520C77AC7073")), new ExGuid(1, new Guid("6F2A4665-42C8-46C7-BAB4-E28FDCE1E32B")));
            QueryChangesCellSubRequest queryChangeScope = SharedTestSuiteHelper.BuildFsshttpbQueryChangesSubRequest(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), 0, false, false, true, 0, true, true, 0, cellId, null, null, null);
            cellRequestFirst.AddSubRequest(queryChangeScope, null);
            CellSubRequestType cellSubRequest = SharedTestSuiteHelper.CreateCellSubRequest(SequenceNumberGenerator.GetCurrentToken(), cellRequestFirst.ToBase64());
            CellStorageResponse response = this.Adapter.CellStorageRequest(fileUrl, new SubRequestType[] { cellSubRequest });
            CellSubResponseType cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse<CellSubResponseType>(response, 0, 0, this.Site);
            this.Site.Assert.AreEqual<ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                "The first QueryChanges operation should succeed.");
            FsshttpbResponse queryResponseInScope = SharedTestSuiteHelper.ExtractFsshttpbResponse(cellSubResponse, this.Site);
            SharedTestSuiteHelper.ExpectMsfsshttpbSubResponseSucceed(queryResponseInScope, this.Site);

            // Query changes from the protocol server with Cell Id set to 0x0000.
            FsshttpbCellRequest cellRequestSecond = SharedTestSuiteHelper.CreateFsshttpbCellRequest();
            QueryChangesCellSubRequest queryChangeNoScope = SharedTestSuiteHelper.BuildFsshttpbQueryChangesSubRequest(SequenceNumberGenerator.GetCurrentFSSHTTPBSubRequestID(), 0, false, false, false, 0, true, true, 0, null, null, null, null);
            cellRequestSecond.AddSubRequest(queryChangeNoScope, null);
            cellSubRequest = SharedTestSuiteHelper.CreateCellSubRequest(SequenceNumberGenerator.GetCurrentToken(), cellRequestSecond.ToBase64());
            response = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { cellSubRequest });
            cellSubResponse = SharedTestSuiteHelper.ExtractSubResponse<CellSubResponseType>(response, 0, 0, this.Site);
            this.Site.Assert.AreEqual<ErrorCodeType>(
                ErrorCodeType.Success,
                SharedTestSuiteHelper.ConvertToErrorCodeType(cellSubResponse.ErrorCode, this.Site),
                "The second QueryChanges operation should succeed.");
            FsshttpbResponse queryResponseNoScope = SharedTestSuiteHelper.ExtractFsshttpbResponse(cellSubResponse, this.Site);

            bool isVerifiedR927 = queryResponseInScope.DataElementPackage.DataElements.Count < queryResponseNoScope.DataElementPackage.DataElements.Count;

            Site.Log.Add(
                LogEntryKind.Debug,
                "When query OneNote file with the Cell ID constrained equals 0x0000, the server responds data element count {0}",
                queryResponseNoScope.DataElementPackage.DataElements.Count);

            Site.Log.Add(
                LogEntryKind.Debug,
                "When query OneNote file with the Cell ID constrained does not equal 0x0000, the server responds data element count {0}",
                queryResponseInScope.DataElementPackage.DataElements.Count);

            Site.Log.Add(
                LogEntryKind.Debug,
                "Expect the data elements count is larger when query OneNote file with the Cell ID constrained does not equal 0x0000. Actually it {0}",
                isVerifiedR927 ? "does" : "does not");

            // Verify MS-FSSHTTPB requirement: MS-FSSHTTPB_R927
            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                Site.CaptureRequirementIfIsTrue(
                         isVerifiedR927,
                         "MS-FSSHTTPB",
                         927,
                         @"[In Query Changes] Cell ID (variable): If the Cell ID is 0x0000, no scoping restriction is specified.");
            }
            else
            {
                this.Site.Assert.IsTrue(isVerifiedR927, "[In Query Changes] Cell ID (variable): If the Cell ID is 0x0000, no scoping restriction is specified.");
            }
        }
        /// <summary>
        /// This method is used to get cell manifest data element from a list of data element.
        /// </summary>
        /// <param name="dataElements">Specify the data element list.</param>
        /// <param name="manifestDataElementData">Specify the manifest data element.</param>
        /// <param name="cellIDMappings">Specify mapping of cell id.</param>
        /// <returns>Return the cell manifest data element.</returns>
        public static CellManifestDataElementData GetCellManifestDataElementData(List<DataElement> dataElements, StorageManifestDataElementData manifestDataElementData, Dictionary<CellID, ExGuid> cellIDMappings)
        {
            CellID cellID = new CellID(new ExGuid(1u, RootExGuid), new ExGuid(1u, CellSecondExGuid));

            foreach (StorageManifestRootDeclare kv in manifestDataElementData.StorageManifestRootDeclareList)
            {
                if (kv.RootExtendedGUID.Equals(new ExGuid(2u, RootExGuid)) && kv.CellID.Equals(cellID))
                {
                    if (!cellIDMappings.ContainsKey(kv.CellID))
                    {
                        throw new InvalidOperationException(string.Format("Cannot fin the Cell ID {0} in the cell id mapping", cellID.ToString()));
                    }

                    ExGuid cellMappingID = cellIDMappings[kv.CellID];

                    DataElement dataElement = dataElements.Find(element => element.DataElementExtendedGUID.Equals(cellMappingID));
                    if (dataElement == null)
                    {
                        throw new InvalidOperationException("Cannot find the  cell data element with ExGuid " + cellMappingID.GUID.ToString());
                    }

                    return dataElement.GetData<CellManifestDataElementData>();
                }
            }

            throw new InvalidOperationException("Cannot find the CellManifestDataElement");
        }
        /// <summary>
        /// This method is used to create the cell manifest data element.
        /// </summary>
        /// <param name="revisionId">Specify the revision GUID.</param>
        /// <param name="cellIDMapping">Input/output parameter to represent the mapping of cell manifest.</param>
        /// <returns>Return the cell manifest data element.</returns>
        public static DataElement CreateCellMainifestDataElement(ExGuid revisionId, ref Dictionary<CellID, ExGuid> cellIDMapping)
        {
            CellManifestDataElementData data = new CellManifestDataElementData();
            data.CellManifestCurrentRevision = new CellManifestCurrentRevision() { CellManifestCurrentRevisionExtendedGUID = new ExGuid(revisionId) };
            DataElement dataElement = new DataElement(DataElementType.CellManifestDataElementData, data);

            CellID cellID = new CellID(new ExGuid(1u, RootExGuid), new ExGuid(1u, CellSecondExGuid));
            cellIDMapping.Add(cellID, dataElement.DataElementExtendedGUID);
            return dataElement;
        }
 /// <summary>
 /// Initializes a new instance of the CellIDFilter class
 /// </summary>
 /// <param name="cellId">Specify the CellID.</param>
 public CellIDFilter(CellID cellId)
     : base(FilterType.CellIDFilter)
 {
     this.CellID = new CellID(cellId);
     this.QueryChangesFilterCellID = new StreamObjectHeaderStart32bit(StreamObjectTypeHeaderStart.QueryChangesFilterCellID, this.CellID.SerializeToByteList().Count);
 }
        /// <summary>
        /// Used to de-serialize the items.
        /// </summary>
        /// <param name="byteArray">Byte array</param>
        /// <param name="currentIndex">Start position</param>
        /// <param name="lengthOfItems">The length of items</param>
        protected override void DeserializeItemsFromByteArray(byte[] byteArray, ref int currentIndex, int lengthOfItems)
        {
            int index = currentIndex;
            this.RootExtendedGUID = BasicObject.Parse<ExGuid>(byteArray, ref index);
            this.CellID = BasicObject.Parse<CellID>(byteArray, ref index);

            if (index - currentIndex != lengthOfItems)
            {
                throw new StreamObjectParseErrorException(currentIndex, "StorageManifestRootDeclare", "Stream object over-parse error", null);
            }

            currentIndex = index;
        }