This class specifies the base class for file chunking.
        /// <summary>
        /// This method is used to create the instance of AbstractChunking.
        /// </summary>
        /// <param name="fileContent">The content of the file.</param>
        /// <param name="chunkingMethod">The type of chunking methods.</param>
        /// <returns>The instance of AbstractChunking.</returns>
        public static AbstractChunking CreateChunkingInstance(byte[] fileContent, ChunkingMethod chunkingMethod)
        {
            AbstractChunking chunking = null;

            switch (chunkingMethod)
            {
            case ChunkingMethod.RDCAnalysis:
                chunking = new RDCAnalysisChunking(fileContent);
                break;

            case ChunkingMethod.SimpleAlgorithm:
                chunking = new SimpleChunking(fileContent);
                break;

            case ChunkingMethod.ZipAlgorithm:
                chunking = new ZipFilesChunking(fileContent);
                break;

            default:
                throw new InvalidOperationException("Cannot support the chunking type" + chunkingMethod.ToString());
            }

            return(chunking);
        }
Пример #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);
            }