public static void Main(string[] args)
        {
            HydraServiceFedoraImpl hydraService = new HydraServiceFedoraImpl();
            //hydraService.DepositSet("Test set", null );

            //hydraService.DepositSimpleContentObject("Report", "test:2", "C:\\tmp\\Report.rtf", "application/rtf");

            //hydraService.DeleteObject("test:1", true);
        }
 public string AddContentObject(string ObjectName, string ParentID, string PIDFormat, string NamespaceFormat, string LabelFormat)
 {
     string _returnValue = string.Empty;
     string _objectLabel = LabelFormat.Replace("{objectname}", ObjectName);
     try
     {
         HydraServiceFedoraImpl ObjService = new HydraServiceFedoraImpl();
         ObjService.DepositSingletonSet(NamespaceFormat, _objectLabel, ParentID);
         _returnValue = ObjService.ObjectPID;
         return _returnValue;
     }
     catch (Exception ex)
     {
         _returnValue = ex.Message;
     }
     return _returnValue;
 }
示例#3
0
        private void UpdateRepositoryListSettings(string SiteName,string SiteUrl,string CurrentUser)
        {
            string _formatedSiteName = SiteName.Replace(@"\", "-");;
            _formatedSiteName = _formatedSiteName.Replace(" ", "-");

            string _defaultRootObject = "CLIF:" + _formatedSiteName;
            string _labelFormat = "{objectname}";
            string _namespaceFormat = "CLIF-" + _formatedSiteName + "-{listname}";
            string _pidFormat = "CLIF:" + _formatedSiteName + "-{listname}:{n}";

            //Create CLIF Root Folder
            HydraServiceFedoraImpl ObjService = new HydraServiceFedoraImpl();
            //if (ObjService.GetObjectHydra("CLIF:Root") == null)
            //{
            //    ObjService.ObjectPID = "CLIF:Root";
            //    ObjService.DepositSingletonSet("CLIF:Root", "CLIF:Root", null);
            //}

            //Create Site Root Folder for the current Site in Fedora
            ObjService = null;
            ObjService = new HydraServiceFedoraImpl();
            ObjService.ObjectPID = _defaultRootObject;
            ObjService.DepositSingletonSet(_defaultRootObject, "CLIF:" + _formatedSiteName,"CLIF:Root");

            ObjService = null;
            ObjService = new HydraServiceFedoraImpl();
            ObjService.DepositSingletonSet("CLIF-" + _formatedSiteName, "_private", _defaultRootObject);

            ObjService = null;
            ObjService = new HydraServiceFedoraImpl();
            string _archivePID=ObjService.DepositSingletonSet("CLIF-" + _formatedSiteName, "_archive", _defaultRootObject);

            using (SPSite ObjSite = new SPSite(SPHelper.GetRootUrl(SiteUrl)))
            {
                using (SPWeb ObjWeb = ObjSite.OpenWeb())
                {
                    SPList ObjList = ObjWeb.Lists["MySite Repository Settings"];
                    SPQuery ObjQuery = new SPQuery();
                    string _query = string.Format("<Where><Eq><FieldRef Name=\"Title\" /><Value Type=\"Text\">{0}</Value></Eq></Where>", SiteName);
                    ObjQuery.Query = _query;

                    //Getting list item collection
                    SPListItemCollection items = ObjList.GetItems(ObjQuery);
                    if (items.Count == 0)
                    {
                        SPItem _newItem = ObjList.Items.Add();
                        _newItem["Site Name"] = SiteName;
                        _newItem["Default Root Object"] = _defaultRootObject;
                        _newItem["Label Format"] = _labelFormat;
                        _newItem["Namespace Format"] = _namespaceFormat;
                        _newItem["PID Format"] = _pidFormat;
                        _newItem["Archive PID"] = _archivePID;
                        _newItem.Update();
                    }
                }
            }
        }
        public void btnYes_Clicked(Object sender, EventArgs e)
        {
            SPWeb ObjWeb = SPContext.Current.Web;
            ObjWeb.AllowUnsafeUpdates = true;
            SPList ObjList = ObjWeb.Lists[new Guid(_listId)];
            SPListItem item = ObjList.Items.GetItemById(Convert.ToInt32(_itemId));

            //Creating Archive Object List
            SPList ObjArchiveList = ObjWeb.Lists["Archive"];
            SPListItem _archive = ObjArchiveList.Items.Add();
            _archive["Title"] = item.Title;
            _archive["Created By"] = SPContext.Current.Web.CurrentUser;
            if (item["Persistent ID"] == null)
            {
                SPListItem settings = null;
                using (MySiteRepositorySettings ObjSettings = new MySiteRepositorySettings())
                {
                    settings = ObjSettings.GetRepositorySettings(SPContext.Current.Web.Title);

                    string _nameSpace = settings["Namespace Format"].ToString();

                    string _selectedDestinationPID = settings["Archive PID"].ToString();
                    //Add file to the repository --------------------------------------------------------------------------------
                    SPFile file = item.File;
                    if (file != null)
                    {
                        SPWeb spWeb = ObjWeb;

                        //MEtabasepath
                        //string METABASEPATH = "IIS://" + spWeb.Site.HostName + "/MimeMap";

                        //URL
                        //string url = spWeb.Url + '/' + file.Url;

                        //MimeType
                        string mimeType = MimeTypeHelper.GetContentType(file.Name);//MimeType.GetMimeTypeForExtension(METABASEPATH, Path.GetExtension(file.Name));

                        //Namespace
                        string nameSpace = ObjWeb.Title + "-" + ObjList.Title;

                        //Item Title
                        string itemTitle = item.Title.Trim().Length == 0 ? Path.GetFileNameWithoutExtension(item.Name.Trim()) : item.Title.Trim();

                        byte[] content = file.OpenBinary(SPOpenBinaryOptions.SkipVirusScan);
                        string author = "Unknown author";
                        if ((file.SourceFile != null) && !String.IsNullOrEmpty(file.SourceFile.Name))
                        {
                            author = file.SourceFile.Name.Trim();
                        }
                        else if ((file.Author != null) && !String.IsNullOrEmpty(file.Author.Name))
                        {
                            author = file.Author.Name.Trim();
                        }
                        _nameSpace = _nameSpace.Replace("{listname}", ObjList.Title.Replace(" ", ""));
                        HydraServiceFedoraImpl hydraService = new HydraServiceFedoraImpl();
                        _archive["Persistent ID"] = hydraService.DepositSimpleContentObject(_nameSpace, itemTitle, _selectedDestinationPID, content, mimeType, author, author);
                    }
                }
            }
            else
            {
                _archive["Persistent ID"] = item["Persistent ID"].ToString();
            }
            _archive["Document Library"] = ObjList.Title;
            _archive["Project Title"] = item["Project Title"];
            _archive["Content Subject"] = item["Content Subject"];
            _archive["Content MimeType"] = item["Content MimeType"];
            _archive["Content Coverage"] = item["Content Coverage"];
            _archive.Update();

            //Delete item from the "Project Documents" document library
            ObjList.Items.DeleteItemById(Convert.ToInt32(_itemId));
            ObjWeb.AllowUnsafeUpdates = false;
            Response.Redirect(ObjList.DefaultViewUrl);
        }