/// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="nameSpace">namespace for the new object</param>
        /// <param name="label">label for the new object</param>
        /// <param name="ingestOwner">name of the object owner</param>
        /// <param name="reservedPID">(optional) if the first generated PID ends with this string forces a second attempt to create a PID for the new object</param>
        public HydraServiceFedoraExt(string nameSpace, string label, string ingestOwner, string reservedPID)
            : base()
        {
            //Default Language Code - Suresh Thampi
               _languageCode = "en";
               _source = "unknown";
               _subject = "unknown";

            _fedoraManagement = new FedoraManagementSOAPImpl(_fedoraServer);
            _label = label;

            //--------------------------------------------------//
            // Modified By Suresh Thampi on 04/01/2011
            //--------------------------------------------------//
            if (base.ObjectPID != string.Empty)
            {
                _objectPID = base.ObjectPID;
            }
            else
            {
                //Get the next available PID from fedora.
                _objectPID = GetNextPID(nameSpace);
                //--------------------------------------------------//
                if (!String.IsNullOrEmpty(reservedPID))
                {
                    if (_objectPID.EndsWith(reservedPID))    // this PID is reserved so lets start with the next
                        _objectPID = GetNextPID(nameSpace);
                }
            }

            //New instance of contentFactory with objectPID, label etc...
            _contentFactory = new ContentFactory(_objectPID, _label, "A", ingestOwner);
        }
        /// <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();
        }