/// <summary>
        /// <para>DeleteObject deletes a singular or a set of objects
        /// from Fedora. If we choose to Delete a parent set, the 
        /// children set objets will also be deleted</para>
        /// 
        /// </summary>
        /// <param name="objectPid">ObjectPid to be deleted</param>
        /// <param name="isCollection">isCollection bool (if it is a set or not)</param>
        public void DeleteObject(string objectPID, bool isCollection)
        {
            _fedoraManagement = new FedoraManagementSOAPImpl(_fedoraServer);

            //First we need to determine if it is a collection
            if (isCollection)
            {
                //Instantiates the ResourceIndexClient
                _riClient = new ResourceIndexClient();
                _contentObjList = _riClient.getRecursiveSetChildrenObjects(objectPID); //Gets all set children recursively...

                int noOfChildren = _contentObjList.Count;

                //For each contentObj in the contentObjList
                foreach (ContentObject contentObj in _contentObjList)
                {
                    if (contentObj.IsCollection)
                    {
                        //If the contentObj is a collection/set then we only need to delete the object dr
                        using (OperationContextScope scope = new OperationContextScope(_fedoraManagement.FedoraManagementProxy.InnerChannel))
                        {
                            //Purge the set object, and force it.
                            _fedoraManagement.purgeObject(contentObj.ObjectPID, "Object deleted by .NET Client", false, scope);
                        }
                    }

                    else
                    {
                        DeleteExternalContent(contentObj.ObjectPID, "content");

                        using (OperationContextScope scope = new OperationContextScope(_fedoraManagement.FedoraManagementProxy.InnerChannel))
                        {
                            //Purge the set object, and force it.
                            _fedoraManagement.purgeObject(contentObj.ObjectPID, "Object deleted by .NET Client", false, scope);
                        }
                    }
                }
                //We then need to get a list of 'all' the child objects...

                //Once we have list of the all the child objects, we need to delete them one by one..
            }
            else
            {
                DeleteExternalContent(objectPID, "content");

                using (OperationContextScope scope = new OperationContextScope(_fedoraManagement.FedoraManagementProxy.InnerChannel))
                {
                    //Purge the set object, and force it.
                    _fedoraManagement.purgeObject(objectPID, "Object deleted by .NET Client", false, scope);
                }
            }
        }
        /// <summary>
        ///     <para>This method will create an Hydra 'Implicit set object' with a fized (Singleton PID), and add three metadata datastreams:-
        ///     - descMetadata (for descriptive metadata) - Hydra suggests MODS XML
        ///     - contentMetadata (for content specific metadata)
        ///     - rightsMetadata (for rights specific metadata) - Loosely based on METS 
        ///     </para>
        ///     <para>For content model info - See http://www.fedora-commons.org/confluence/display/hydra/Hydra+content+models+and+disseminators</para>
        ///     <para>This method needs to be expanded to allow the setting of the metadata datastreams</para>
        /// </summary>
        /// <param name="nameSpace">Object namespace</param>
        /// <param name="label">Object label</param>
        /// <param name="parentID">Object parent (if it's a sub-set)</param>
        public string DepositSingletonSet(string nameSpace, string label, string parentID)
        {
            string objectPID = string.Empty;
            //Create a fedoraManagement client
            _fedoraManagement = new FedoraManagementSOAPImpl(_fedoraServer);

            //--------------------------------------------------//
            // Modified By Suresh Thampi on 04/01/2011
            if (_objectPID == string.Empty)
            {
                //objectPID = nameSpace + ":1";
                objectPID = GetNextPID(nameSpace);
            }
            else
            {
                objectPID = _objectPID;
            }
            //--------------------------------------------------//

            //Use the content factory to create a new object
            ContentFactory contentFactory = new ContentFactory(objectPID, label, "A", "fedoraAdmin");

            DateTime dt = DateTime.Now;
            string timestamp = String.Format("{0:yy-MM-dd}", dt);

            //Create a basic DC Datastream
            contentFactory.AddMetadataDatastream("DC", "Dublin Core Metadata", BuildSomeDC(label, "", "", "", "fedoraAdmin", timestamp, "", "text/xml", objectPID, "en", "", "", "", "", ""), "text/xml");

            //Create the RELS-EXT XML, this contains the content model membership relationships etc...
            RelationshipMetadata relsMetadata = new RelationshipMetadata(objectPID);
            relsMetadata.AddRelationship(relsMetadata.HAS_MODEL_REL, "hydra-cModel:implicitSet");
            relsMetadata.AddRelationship(relsMetadata.HAS_MODEL_REL, "hydra-cModel:commonMetadata");
            relsMetadata.IsCollection = true;

            //Set parentID if its defined...
            if (parentID != null)
            {
                relsMetadata.AddRelationship(relsMetadata.IS_MEMBER_REL, parentID);
            }

            //Creates the metadata datastream with the RelationshipsMetadata object created above
            contentFactory.AddMetadataDatastream("RELS-EXT", "RDF Statements about this object", relsMetadata, "application/rdf+xml");

            //Creates some sample DC - ***Need a MODS editor - Object model for insertion into objects***
            string descMetadata = BuildSomeDC(label, "", "", "", "fedoraAdmin", timestamp, "", "text/xml", objectPID, "en", "", "", "", "", "").Xml.ToString();

            //Creates a 'ManagedContentDatastream' for the descMetadata, using the sample DC created above
            contentFactory.AddManagedContentDatastream("descMetadata", "Descriptive metadata", "text/xml", 0, System.Text.Encoding.ASCII.GetBytes(descMetadata));
            // Creates a contentMetadata datastream...
            contentFactory.AddManagedContentDatastream("contentMetadata", "Content metadata", "text/xml", 0, System.Text.Encoding.ASCII.GetBytes("<adminMetadata />"));
            // Creates a rightsMetadata datastream...
            contentFactory.AddManagedContentDatastream("rightsMetadata", "Rights metadata", "text/xml", 0, System.Text.Encoding.ASCII.GetBytes("<rightsMetadata />"));

            //Once we have added all the datastreams, we can use the contentFactory.getContentAsByteArray() to get Byte[] rep of the FOXML object
            byte[] objectXML = contentFactory.GetContentAsByteArray();

            using (OperationContextScope scope = new OperationContextScope(_fedoraManagement.FedoraManagementProxy.InnerChannel))
            {
                try
                {
                    _fedoraManagement.ingest(objectXML, "info:fedora/fedora-system:FOXML-1.0", "Ingested by the .net hydra client", scope);  //Ingests into Fedora instance
                }
                catch (Exception ex)
                {
                    if (!ex.Message.Contains("ObjectExistsException"))
                    throw ex;
                }
            }
            return objectPID;
        }
        /// <summary>
        /// <para>This method creates a simple Hydra legal content object, with one
        /// binary content datastream.</para>
        /// <param>May be extended to enable flexible multiple DS ingests</param>
        /// </summary>
        /// <param name="nameSpace">Fedora namespace to be assigned to the document</param>
        /// <param name="label">Object label/filename</param>
        /// <param name="parentID">Object parent set if applicable</param>
        /// <param name="fileURL">Url to the file</param>
        /// <param name="mimeType">Content mimetype</param>
        /// <param name="ingestOwner">Id of the user assigned repository ownership rights over this document..if in doubt use fedoraAdmin</param>
        /// <param name="documentAuthor">Name of the person who authored the document ..e.g for copyright</param>
        public void DepositSimpleContentObject(string nameSpace, string label, string parentID, Uri fileURL, string mimeType, string ingestOwner, string documentAuthor)
        {
            _fedoraManagement = new FedoraManagementSOAPImpl(_fedoraServer);

            string objectPID;

            //Get the next available PID from fedora.
            objectPID = GetNextPID(nameSpace);
            //New instance of contentFactory with objectPID, label etc...
            _contentFactory = new ContentFactory(objectPID, label, "A", ingestOwner);
            AddNonContentStreams(label, parentID, mimeType, objectPID, documentAuthor);
            _contentFactory.AddManagedContentDatastream("content", "Document", mimeType, 0, fileURL.ToString());
            DoIngest();
        }
        /// <summary>
        /// <para>This method creates a simple Hydra legal content object, with one
        /// binary content datastream.</para>
        /// <param>May be extended to enable flexible multiple DS ingests</param>
        /// </summary>
        /// <param name="nameSpace">Fedora namespace to be assigned to the document</param>/// 
        /// <param name="label">Object label/filename</param>
        /// <param name="parentID">Object parent set if applicable</param>
        /// <param name="content">content to embed</param>
        /// <param name="mimeType">Content mimetype</param>
        /// <param name="ingestOwner">Id of the user assigned repository ownership rights over this document..if in doubt use fedoraAdmin</param>
        /// <param name="documentAuthor">Name of the person who authored the document ..e.g for copyright</param>      
        public string DepositSimpleContentObject(string nameSpace, string label, string parentID, byte[] content, string mimeType, string ingestOwner, string documentAuthor)
        {
            if (content.Length < 0)    // sometimes a zero length file is valid
                throw new OverflowException("Hydranet - unable to upload file invalid file size");

            if (content.Length > int.MaxValue)
                throw new OverflowException("Hydranet - unable to upload file (maximum size = 2gb)");

            _fedoraManagement = new FedoraManagementSOAPImpl(_fedoraServer);

            string objectPID;

            //Get the next available PID from fedora.
            objectPID = GetNextPID(nameSpace);
            //New instance of contentFactory with objectPID, label etc...
            _contentFactory = new ContentFactory(objectPID, label, "A", ingestOwner);
            AddNonContentStreams(label, parentID, mimeType, objectPID, documentAuthor);
            _contentFactory.AddManagedContentDatastream("content", "Document", mimeType, content.Length, content);
            DoIngest();
            return objectPID;
        }
        /// <summary>
        /// <para>This method creates a simple Hydra legal content object, with one
        /// binary content datastream.</para>
        /// <param>May be extended to enable flexible multiple DS ingests</param>
        /// </summary>
        /// <param name="nameSpace">Fedora namespace to be assigned to the document</param>
        /// <param name="label">Object label/filename</param>
        /// <param name="parentID">Object parent set if applicable</param>
        /// <param name="localFilePath">File path to the local file</param>
        /// <param name="mimeType">Content mimetype</param>
        /// <param name="ingestOwner">Id of the user assigned repository ownership rights over this document..if in doubt use fedoraAdmin</param>
        /// <param name="documentAuthor">Name of the person who authored the document ..e.g for copyright</param>/// 
        public void DepositSimpleContentObject(string nameSpace, string label, string parentID, string localFilePath, string mimeType, string ingestOwner, string documentAuthor)
        {
            _fedoraManagement = new FedoraManagementSOAPImpl(_fedoraServer);

            string objectPID;

            //Get the next available PID from fedora.
            objectPID = GetNextPID(nameSpace);
            //We do allow datastream versioning within Fedora, therefore we TimeStamp the target filename for easier verification
            string filename = TimeStampFilename(objectPID.Replace(":", "") + localFilePath.Substring(localFilePath.LastIndexOf('.')));
            long fileLength = 0;
            string contentLocation = UploadFile(localFilePath, filename, out fileLength); //Upload file to the FTP store

            if (fileLength < 0)    // sometimes a zero length file is valid
                throw new OverflowException("Hydranet - unable to upload file invalid file size");

            if (fileLength > int.MaxValue)
                throw new OverflowException("Hydranet - unable to upload file (maximum size = 2gb)");

            //New instance of contentFactory with objectPID, label etc...
            _contentFactory = new ContentFactory(objectPID, label, "A", ingestOwner);
            AddNonContentStreams(label, parentID, mimeType, objectPID, documentAuthor);
            _contentFactory.AddManagedContentDatastream("content", "Document", mimeType, (int)fileLength, contentLocation);
            DoIngest();
        }