/// <summary>
 /// This method return all files in a collection.
 /// </summary>
 /// <param name="parentID">string</param>
 /// <returns>ContentObjectList</returns>
 public static ContentObjectList GetFilesInCollection(string parentID)
 {
     ContentObjectList contentObjList = new ContentObjectList();
     ResourceIndexClient resIndClient = new ResourceIndexClient();
     contentObjList = resIndClient.getSetChildrenObjects(parentID, false);
     return contentObjList;
 }
Esempio n. 2
0
        /// <summary>
        /// This method return files in an Object
        /// </summary>
        /// <param name="ObjectPID">string</param>
        /// <returns></returns>
        public ContentObjectList GetFiles(string ObjectPID)
        {
            string _parentId = ObjectPID;

            ResourceIndexClient ObjRIC = new ResourceIndexClient();
            ContentObjectList ObjCOL = new ContentObjectList();
            ObjCOL = ObjRIC.getSetChildrenObjects(_parentId,false);
            return ObjCOL;
        }
Esempio n. 3
0
        /// <summary>
        /// This method returns repository data in XML format.
        /// </summary>
        /// <param name="ObjectPID">string</param>
        /// <returns>XMLDocument</returns>
        public XmlDocument GetData(string ObjectPID)
        {
            string _parentId = ObjectPID;

            ResourceIndexClient ObjRIC = new ResourceIndexClient();
            ContentObjectList ObjCOL = new ContentObjectList();
            ObjCOL = ObjRIC.getSetChildrenObjects(_parentId, true);

            //Converting data to XML format
            XmlSerializer ObjXmlSerializer = new XmlSerializer(ObjCOL.GetType());

            StringWriter ObjStringWriter = new StringWriter();
            ObjXmlSerializer.Serialize(ObjStringWriter, ObjCOL);

            XmlDocument ObjXmldocument = new XmlDocument();
            ObjXmldocument.LoadXml(ObjStringWriter.ToString());
            return ObjXmldocument;
        }
        private ContentObjectList ParseResultByType(string content, int numOfCols, bool isCollectionType)
        {
            //Get the lines of the content
            string[] lines = content.Split('\n');
            int noOfLines = lines.Length;
            //If empty query
            if (noOfLines == 1)
            {
                return null;
            }
            else
            {
                ContentObject contentObj;
                contentObjList = new ContentObjectList();

                for (int i = 1; i < noOfLines - 1; i++)
                {
                    string[] tokens = lines[i].Split(',');

                    if (numOfCols == 4)
                    {
                        //Hard coded to deal with member/isCollection/label/mimetype format of result
                        string member = tokens[0].Substring(tokens[0].LastIndexOf('/') + 1);
                        string isCollection = tokens[1];
                        bool isCollectionBool = bool.Parse(isCollection);
                        string label = tokens[2];
                        string mimetype = tokens[3];

                        if (isCollectionBool == isCollectionType)
                        {
                            contentObj = new ContentObject(member, isCollectionBool, label, mimetype);
                            contentObjList.Add(contentObj);
                        }
                    }
                    if (numOfCols == 5)
                    {
                        //Hard coded to deal with member/isCollection/label/mimetype format of result
                        string member = tokens[0].Substring(tokens[0].LastIndexOf('/') + 1);
                        string subMember = tokens[1].Substring(tokens[1].LastIndexOf('/') + 1);
                        string isCollection = tokens[2];
                        bool isCollectionBool = bool.Parse(isCollection);
                        string label = tokens[3];
                        string mimetype = tokens[4];

                        if (isCollectionBool == isCollectionType)
                        {
                            contentObj = new ContentObject(subMember, isCollectionBool, label, mimetype);
                            contentObjList.Add(contentObj);
                        }
                    }

                }

                return contentObjList;
            }
        }
        /// <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);
                }
            }
        }
        public ContentObjectList ListContentObjects(String parentId)
        {
            _riClient = new ResourceIndexClient();
            _contentObjList = _riClient.getSetChildrenObjects(parentId);

            return _contentObjList;
        }