Beispiel #1
0
            /// <summary>
            /// This method is used to build intermediate node object from an list of object group data element.
            /// </summary>
            /// <param name="objectGroupList">Specify the list of object group data elements.</param>
            /// <param name="dataObj">Specify the object group object.</param>
            /// <param name="intermediateGuid">Specify the intermediate extended GUID.</param>
            /// <returns>Return the intermediate node object.</returns>
            public LeafNodeObject Build(List <ObjectGroupDataElementData> objectGroupList, ObjectGroupObjectData dataObj, ExGuid intermediateGuid)
            {
                LeafNodeObject         node     = null;
                IntermediateNodeObject rootNode = null;

                int index = 0;

                if (StreamObject.TryGetCurrent <LeafNodeObject>(dataObj.Data.Content.ToArray(), ref index, out node))
                {
                    if (dataObj.ObjectExGUIDArray == null)
                    {
                        throw new InvalidOperationException("Failed to build intermediate node because the object extend GUID array does not exist.");
                    }

                    node.ExGuid = intermediateGuid;

                    // Contain a single Data Node Object.
                    if (dataObj.ObjectExGUIDArray.Count.DecodedValue == 1u)
                    {
                        ObjectGroupObjectDeclare dataNodeDeclare;
                        ObjectGroupObjectData    dataNodeData = this.FindByExGuid(objectGroupList, dataObj.ObjectExGUIDArray.Content[0], out dataNodeDeclare);
                        BinaryItem data = dataNodeData.Data;

                        node.DataNodeObjectData         = new DataNodeObjectData(data.Content.ToArray(), 0, (int)data.Length.DecodedValue);
                        node.DataNodeObjectData.ExGuid  = dataObj.ObjectExGUIDArray.Content[0];
                        node.IntermediateNodeObjectList = null;

                        if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
                        {
                            MsfsshttpdCapture.VerifyObjectGroupObjectDataForDataNodeObject(dataNodeData, dataNodeDeclare, objectGroupList, SharedContext.Current.Site);
                        }
                    }
                    else
                    {
                        // Contain a list of LeafNodeObjectData
                        node.IntermediateNodeObjectList = new List <LeafNodeObject>();
                        node.DataNodeObjectData         = null;
                        foreach (ExGuid extGuid in dataObj.ObjectExGUIDArray.Content)
                        {
                            ObjectGroupObjectDeclare intermediateDeclare;
                            ObjectGroupObjectData    intermediateData = this.FindByExGuid(objectGroupList, extGuid, out intermediateDeclare);
                            node.IntermediateNodeObjectList.Add(new IntermediateNodeObjectBuilder().Build(objectGroupList, intermediateData, extGuid));

                            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
                            {
                                MsfsshttpdCapture.VerifyObjectGroupObjectDataForIntermediateNode(intermediateData, intermediateDeclare, objectGroupList, SharedContext.Current.Site);
                            }
                        }
                    }
                }
                else if (StreamObject.TryGetCurrent <IntermediateNodeObject>(dataObj.Data.Content.ToArray(), ref index, out rootNode))
                {
                    // In Sub chunking for larger than 1MB zip file, MOSS2010 could return IntermediateNodeObject.
                    // For easy further process, the rootNode will be replaced by intermediate node instead.
                    node = new LeafNodeObject();
                    node.IntermediateNodeObjectList = new List <LeafNodeObject>();
                    node.DataSize           = rootNode.DataSize;
                    node.ExGuid             = rootNode.ExGuid;
                    node.Signature          = rootNode.Signature;
                    node.DataNodeObjectData = null;
                    foreach (ExGuid extGuid in dataObj.ObjectExGUIDArray.Content)
                    {
                        ObjectGroupObjectDeclare intermediateDeclare;
                        ObjectGroupObjectData    intermediateData = this.FindByExGuid(objectGroupList, extGuid, out intermediateDeclare);
                        node.IntermediateNodeObjectList.Add(new IntermediateNodeObjectBuilder().Build(objectGroupList, intermediateData, extGuid));

                        if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
                        {
                            MsfsshttpdCapture.VerifyObjectGroupObjectDataForIntermediateNode(intermediateData, intermediateDeclare, objectGroupList, SharedContext.Current.Site);
                        }
                    }
                }
                else
                {
                    throw new InvalidOperationException("In the ObjectGroupDataElement cannot only contain the IntermediateNodeObject or IntermediateNodeOBject.");
                }

                return(node);
            }
Beispiel #2
0
            /// <summary>
            /// This method is used to build a root node object from an object group data element list with the specified root extended GUID.
            /// </summary>
            /// <param name="objectGroupList">Specify the object group data element list.</param>
            /// <param name="rootExGuid">Specify the root extended GUID.</param>
            /// <returns>Return a root node object build from the object group data element list.</returns>
            private IntermediateNodeObject Build(List <ObjectGroupDataElementData> objectGroupList, ExGuid rootExGuid)
            {
                ObjectGroupObjectDeclare rootDeclare;
                ObjectGroupObjectData    root = this.FindByExGuid(objectGroupList, rootExGuid, out rootDeclare);

                if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
                {
                    MsfsshttpdCapture.VerifyObjectCount(root, SharedContext.Current.Site);
                }

                int index = 0;
                IntermediateNodeObject rootNode = null;

                if (StreamObject.TryGetCurrent <IntermediateNodeObject>(root.Data.Content.ToArray(), ref index, out rootNode))
                {
                    rootNode.ExGuid = rootExGuid;

                    foreach (ExGuid extGuid in root.ObjectExGUIDArray.Content)
                    {
                        ObjectGroupObjectDeclare intermediateDeclare;
                        ObjectGroupObjectData    intermediateData = this.FindByExGuid(objectGroupList, extGuid, out intermediateDeclare);
                        rootNode.IntermediateNodeObjectList.Add(new LeafNodeObject.IntermediateNodeObjectBuilder().Build(objectGroupList, intermediateData, extGuid));

                        // Capture the intermediate related requirements
                        if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
                        {
                            MsfsshttpdCapture.VerifyObjectGroupObjectDataForIntermediateNode(intermediateData, intermediateDeclare, objectGroupList, SharedContext.Current.Site);
                            MsfsshttpdCapture.VerifyLeafNodeObject(rootNode.IntermediateNodeObjectList.Last(), SharedContext.Current.Site);
                        }
                    }

                    if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
                    {
                        // Capture the root node related requirements.
                        MsfsshttpdCapture.VerifyObjectGroupObjectDataForRootNode(root, rootDeclare, objectGroupList, SharedContext.Current.Site);
                        MsfsshttpdCapture.VerifyIntermediateNodeObject(rootNode, SharedContext.Current.Site);
                    }
                }
                else
                {
                    // If there is only one object in the file, SharePoint Server 2010 does not return the Root Node Object, but an Intermediate Node Object at the beginning.
                    // At this case, we will add the root node object for the further parsing.
                    rootNode        = new IntermediateNodeObject();
                    rootNode.ExGuid = rootExGuid;

                    rootNode.IntermediateNodeObjectList.Add(new LeafNodeObject.IntermediateNodeObjectBuilder().Build(objectGroupList, root, rootExGuid));
                    rootNode.DataSize          = new DataSizeObject();
                    rootNode.DataSize.DataSize = (ulong)rootNode.IntermediateNodeObjectList.Sum(o => (float)o.DataSize.DataSize);
                }

                // Capture all the signature related requirements.
                if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
                {
                    AbstractChunking chunking = ChunkingFactory.CreateChunkingInstance(rootNode);

                    if (chunking != null)
                    {
                        chunking.AnalyzeChunking(rootNode, SharedContext.Current.Site);
                    }
                }

                return(rootNode);
            }