コード例 #1
0
        /// <summary> Reloads the basic behavior information from the database into the
        /// digital resource, such as collections and thumbnails  </summary>
        /// <param name="Resource"> Incoming digital resource object </param>
        /// <returns> TRUE if processing can continue, FALSE if a critical error occurred which should stop all processing </returns>
        public override bool DoWork(Incoming_Digital_Resource Resource)
        {
            // Load the METS file
            if (!Resource.Load_METS())
            {
                OnError("Error reading most recent METS file from " + Resource.BibID + ":" + Resource.VID, Resource.BibID + ":" + Resource.VID, String.Empty, Resource.BuilderLogId);
                return(false);
            }

            // Add thumbnail, aggregation informaiton, and dark/access information from the database
            if (!Resource.NewPackage)
            {
                Engine_Database.Add_Minimum_Builder_Information(Resource.Metadata);
            }
            else
            {
                // Check for any access/restriction/embargo date in the RightsMD section
                RightsMD_Info rightsInfo = Resource.Metadata.Get_Metadata_Module(GlobalVar.PALMM_RIGHTSMD_METADATA_MODULE_KEY) as RightsMD_Info;
                if ((rightsInfo != null) && (rightsInfo.hasData))
                {
                    switch (rightsInfo.Access_Code)
                    {
                    case RightsMD_Info.AccessCode_Enum.Campus:
                        // Was there an embargo date?
                        if (rightsInfo.Has_Embargo_End)
                        {
                            if (DateTime.Compare(DateTime.Now, rightsInfo.Embargo_End) < 0)
                            {
                                Resource.Metadata.Behaviors.IP_Restriction_Membership = 1;
                            }
                        }
                        else
                        {
                            Resource.Metadata.Behaviors.IP_Restriction_Membership = 1;
                        }
                        break;

                    case RightsMD_Info.AccessCode_Enum.Private:
                        // Was there an embargo date?
                        if (rightsInfo.Has_Embargo_End)
                        {
                            if (DateTime.Compare(DateTime.Now, rightsInfo.Embargo_End) < 0)
                            {
                                Resource.Metadata.Behaviors.Dark_Flag = true;
                            }
                        }
                        else
                        {
                            Resource.Metadata.Behaviors.Dark_Flag = true;
                        }
                        break;
                    }
                }
            }

            return(true);
        }
コード例 #2
0
        /// <summary> Flag indicates if this active reader/writer will write an amdSec </summary>
        /// <param name="METS_Item"> Package with all the metadata to save</param>
        /// <param name="Options"> Dictionary of any options which this METS section writer may utilize</param>
        /// <returns> TRUE if the package has data to be written, otherwise fALSE </returns>
        public bool Include_amdSec(SobekCM_Item METS_Item, Dictionary <string, object> Options)
        {
            // Ensure this metadata module extension exists and has data
            RightsMD_Info rightsInfo = METS_Item.Get_Metadata_Module(GlobalVar.PALMM_RIGHTSMD_METADATA_MODULE_KEY)  as RightsMD_Info;

            if ((rightsInfo == null) || (!rightsInfo.hasData))
            {
                return(false);
            }
            return(true);
        }
コード例 #3
0
        /// <summary> Flag indicates if this active reader/writer needs to append schema reference information
        /// to the METS XML header by analyzing the contents of the digital resource item </summary>
        /// <param name="METS_Item"> Package with all the metadata to save</param>
        /// <returns> TRUE if the schema should be attached, otherwise fALSE </returns>
        public bool Schema_Reference_Required_Package(SobekCM_Item METS_Item)
        {
            RightsMD_Info rightsInfo = METS_Item.Get_Metadata_Module(GlobalVar.PALMM_RIGHTSMD_METADATA_MODULE_KEY) as RightsMD_Info;

            if (rightsInfo == null)
            {
                return(false);
            }

            return(rightsInfo.hasData);
        }
コード例 #4
0
        /// <summary> Map one or more data elements from the original METS-based object to the
        /// BriefItem object </summary>
        /// <param name="Original"> Original METS-based object </param>
        /// <param name="New"> New object to populate some data from the original </param>
        /// <returns> TRUE if successful, FALSE if an exception is encountered </returns>
        public bool MapToBriefItem(SobekCM_Item Original, BriefItemInfo New)
        {
            // Try to get the rights information from the object
            RightsMD_Info rightsInfo = Original.Get_Metadata_Module(GlobalVar.PALMM_RIGHTSMD_METADATA_MODULE_KEY) as RightsMD_Info;

            // Add eembargo date, if there is one
            if ((rightsInfo != null) && (rightsInfo.Has_Embargo_End))
            {
                New.Add_Description("Embargo Date", rightsInfo.Embargo_End.ToShortDateString());
            }

            return(true);
        }
コード例 #5
0
        /// <summary> Writes the amdSec for the entire package to the text writer </summary>
        /// <param name="Output_Stream">Stream to which the formatted text is written </param>
        /// <param name="METS_Item">Package with all the metadata to save</param>
        /// <param name="Options"> Dictionary of any options which this METS section writer may utilize</param>
        /// <returns>TRUE if successful, otherwise FALSE </returns>
        public bool Write_amdSec(TextWriter Output_Stream, SobekCM_Item METS_Item, Dictionary <string, object> Options)
        {
            // Ensure this metadata module extension exists and has data
            RightsMD_Info rightsInfo = METS_Item.Get_Metadata_Module(GlobalVar.PALMM_RIGHTSMD_METADATA_MODULE_KEY) as RightsMD_Info;

            if ((rightsInfo == null) || (!rightsInfo.hasData))
            {
                return(true);
            }

            if (!String.IsNullOrEmpty(rightsInfo.Version_Statement))
            {
                Output_Stream.WriteLine("<rightsmd:versionStatement>" + XML_Writing_Base_Type.Convert_String_To_XML_Safe_Static(rightsInfo.Version_Statement) + "</rightsmd:versionStatement>");
            }
            if (!String.IsNullOrEmpty(rightsInfo.Copyright_Statement))
            {
                Output_Stream.WriteLine("<rightsmd:copyrightStatement>" + XML_Writing_Base_Type.Convert_String_To_XML_Safe_Static(rightsInfo.Copyright_Statement) + "</rightsmd:copyrightStatement>");
            }
            if (rightsInfo.Access_Code != RightsMD_Info.AccessCode_Enum.NOT_SPECIFIED)
            {
                Output_Stream.Write("<rightsmd:accessCode>");
                switch (rightsInfo.Access_Code)
                {
                case RightsMD_Info.AccessCode_Enum.Public:
                    Output_Stream.Write("public");
                    break;

                case RightsMD_Info.AccessCode_Enum.Private:
                    Output_Stream.Write("private");
                    break;

                case RightsMD_Info.AccessCode_Enum.Campus:
                    Output_Stream.Write("campus");
                    break;
                }
                Output_Stream.WriteLine("</rightsmd:accessCode>");
            }
            if (rightsInfo.Has_Embargo_End)
            {
                string encoded_date = rightsInfo.Embargo_End.Year + "-" + rightsInfo.Embargo_End.Month.ToString().PadLeft(2, '0') + "-" + rightsInfo.Embargo_End.Day.ToString().PadLeft(2, '0');

                Output_Stream.WriteLine("<rightsmd:embargoEnd>" + encoded_date + "</rightsmd:embargoEnd>");
            }

            return(true);
        }
コード例 #6
0
        private void Finish_Building_Item(SobekCM_Item Package_To_Finalize, DataSet DatabaseInfo, bool Multiple, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Finish_Building_Item", "Load the data from the database into the resource object");

            if ((DatabaseInfo == null) || (DatabaseInfo.Tables[2] == null) || (DatabaseInfo.Tables[2].Rows.Count == 0))
            {
                Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Finish_Building_Item", "Invalid data from the database, either not enough tables, or no rows in Tables[2]");
            }
            else
            {
                // Copy over some basic values
                DataRow mainItemRow = DatabaseInfo.Tables[2].Rows[0];
                Package_To_Finalize.Behaviors.Set_Primary_Identifier(mainItemRow["Primary_Identifier_Type"].ToString(), mainItemRow["Primary_Identifier"].ToString());
                Package_To_Finalize.Behaviors.GroupTitle = mainItemRow["GroupTitle"].ToString();
                Package_To_Finalize.Behaviors.GroupType  = mainItemRow["GroupType"].ToString();
                Package_To_Finalize.Web.File_Root        = mainItemRow["File_Location"].ToString();
                Package_To_Finalize.Web.AssocFilePath    = mainItemRow["File_Location"] + "\\" + Package_To_Finalize.VID + "\\";
                Package_To_Finalize.Behaviors.IP_Restriction_Membership = Convert.ToInt16(mainItemRow["IP_Restriction_Mask"]);
                Package_To_Finalize.Behaviors.CheckOut_Required         = Convert.ToBoolean(mainItemRow["CheckoutRequired"]);
                Package_To_Finalize.Behaviors.Text_Searchable           = Convert.ToBoolean(mainItemRow["TextSearchable"]);
                Package_To_Finalize.Web.ItemID  = Convert.ToInt32(mainItemRow["ItemID"]);
                Package_To_Finalize.Web.GroupID = Convert.ToInt32(mainItemRow["GroupID"]);
                Package_To_Finalize.Behaviors.Suppress_Endeca = Convert.ToBoolean(mainItemRow["SuppressEndeca"]);
                //Package_To_Finalize.Behaviors.Expose_Full_Text_For_Harvesting = Convert.ToBoolean(mainItemRow["SuppressEndeca"]);
                Package_To_Finalize.Tracking.Internal_Comments = mainItemRow["Comments"].ToString();
                Package_To_Finalize.Behaviors.Dark_Flag        = Convert.ToBoolean(mainItemRow["Dark"]);
                Package_To_Finalize.Tracking.Born_Digital      = Convert.ToBoolean(mainItemRow["Born_Digital"]);
                Package_To_Finalize.Behaviors.Main_Thumbnail   = mainItemRow["MainThumbnail"].ToString();
                //Package_To_Finalize.Divisions.Page_Count = Convert.ToInt32(mainItemRow["Pages"]);
                if (mainItemRow["Disposition_Advice"] != DBNull.Value)
                {
                    Package_To_Finalize.Tracking.Disposition_Advice = Convert.ToInt16(mainItemRow["Disposition_Advice"]);
                }
                else
                {
                    Package_To_Finalize.Tracking.Disposition_Advice = -1;
                }
                if (mainItemRow["Material_Received_Date"] != DBNull.Value)
                {
                    Package_To_Finalize.Tracking.Material_Received_Date = Convert.ToDateTime(mainItemRow["Material_Received_Date"]);
                }
                else
                {
                    Package_To_Finalize.Tracking.Material_Received_Date = null;
                }
                if (mainItemRow["Material_Recd_Date_Estimated"] != DBNull.Value)
                {
                    Package_To_Finalize.Tracking.Material_Rec_Date_Estimated = Convert.ToBoolean(mainItemRow["Material_Recd_Date_Estimated"]);
                }
                if (DatabaseInfo.Tables[2].Columns.Contains("Tracking_Box"))
                {
                    if (mainItemRow["Tracking_Box"] != DBNull.Value)
                    {
                        Package_To_Finalize.Tracking.Tracking_Box = mainItemRow["Tracking_Box"].ToString();
                    }
                }
                if (mainItemRow["CitationSet"] != DBNull.Value)
                {
                    Package_To_Finalize.Behaviors.CitationSet = mainItemRow["CitationSet"].ToString();
                }

                // Set more of the sobekcm web portions in the item
                Package_To_Finalize.Web.Set_BibID_VID(Package_To_Finalize.BibID, Package_To_Finalize.VID);
                Package_To_Finalize.Web.Image_Root = Engine_ApplicationCache_Gateway.Settings.Servers.Image_URL;
                if (Multiple)
                {
                    Package_To_Finalize.Web.Siblings = 2;
                }

                // Set the serial hierarchy from the database (if multiple)
                if ((Multiple) && (mainItemRow["Level1_Text"].ToString().Length > 0))
                {
                    Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Finish_Building_Item", "Assigning serial hierarchy from the database info");

                    bool found = false;

                    // Get the values from the database first
                    string level1_text  = mainItemRow["Level1_Text"].ToString();
                    string level2_text  = mainItemRow["Level2_Text"].ToString();
                    string level3_text  = mainItemRow["Level3_Text"].ToString();
                    int    level1_index = Convert.ToInt32(mainItemRow["Level1_Index"]);
                    int    level2_index = Convert.ToInt32(mainItemRow["Level2_Index"]);
                    int    level3_index = Convert.ToInt32(mainItemRow["Level3_Index"]);

                    // Does this match the enumeration
                    if (level1_text.ToUpper().Trim() == Package_To_Finalize.Bib_Info.Series_Part_Info.Enum1.ToUpper().Trim())
                    {
                        // Copy the database values to the enumeration portion
                        Package_To_Finalize.Bib_Info.Series_Part_Info.Enum1       = level1_text;
                        Package_To_Finalize.Bib_Info.Series_Part_Info.Enum1_Index = level1_index;
                        Package_To_Finalize.Bib_Info.Series_Part_Info.Enum2       = level2_text;
                        Package_To_Finalize.Bib_Info.Series_Part_Info.Enum2_Index = level2_index;
                        Package_To_Finalize.Bib_Info.Series_Part_Info.Enum3       = level3_text;
                        Package_To_Finalize.Bib_Info.Series_Part_Info.Enum3_Index = level3_index;
                        found = true;
                    }

                    // Does this match the chronology
                    if ((!found) && (level1_text.ToUpper().Trim() == Package_To_Finalize.Bib_Info.Series_Part_Info.Year.ToUpper().Trim()))
                    {
                        // Copy the database values to the chronology portion
                        Package_To_Finalize.Bib_Info.Series_Part_Info.Year        = level1_text;
                        Package_To_Finalize.Bib_Info.Series_Part_Info.Year_Index  = level1_index;
                        Package_To_Finalize.Bib_Info.Series_Part_Info.Month       = level2_text;
                        Package_To_Finalize.Bib_Info.Series_Part_Info.Month_Index = level2_index;
                        Package_To_Finalize.Bib_Info.Series_Part_Info.Day         = level3_text;
                        Package_To_Finalize.Bib_Info.Series_Part_Info.Day_Index   = level3_index;
                        found = true;
                    }

                    if (!found)
                    {
                        // No match.  If it is numeric, move it to the chronology, otherwise, enumeration
                        bool charFound = level1_text.Trim().Any(ThisChar => !Char.IsNumber(ThisChar));

                        if (charFound)
                        {
                            // Copy the database values to the enumeration portion
                            Package_To_Finalize.Bib_Info.Series_Part_Info.Enum1       = level1_text;
                            Package_To_Finalize.Bib_Info.Series_Part_Info.Enum1_Index = level1_index;
                            Package_To_Finalize.Bib_Info.Series_Part_Info.Enum2       = level2_text;
                            Package_To_Finalize.Bib_Info.Series_Part_Info.Enum2_Index = level2_index;
                            Package_To_Finalize.Bib_Info.Series_Part_Info.Enum3       = level3_text;
                            Package_To_Finalize.Bib_Info.Series_Part_Info.Enum3_Index = level3_index;
                        }
                        else
                        {
                            // Copy the database values to the chronology portion
                            Package_To_Finalize.Bib_Info.Series_Part_Info.Year        = level1_text;
                            Package_To_Finalize.Bib_Info.Series_Part_Info.Year_Index  = level1_index;
                            Package_To_Finalize.Bib_Info.Series_Part_Info.Month       = level2_text;
                            Package_To_Finalize.Bib_Info.Series_Part_Info.Month_Index = level2_index;
                            Package_To_Finalize.Bib_Info.Series_Part_Info.Day         = level3_text;
                            Package_To_Finalize.Bib_Info.Series_Part_Info.Day_Index   = level3_index;
                        }
                    }

                    // Copy the database values to the simple serial portion (used to actually determine serial heirarchy)
                    Package_To_Finalize.Behaviors.Serial_Info.Clear();
                    Package_To_Finalize.Behaviors.Serial_Info.Add_Hierarchy(1, level1_index, level1_text);
                    if (level2_text.Length > 0)
                    {
                        Package_To_Finalize.Behaviors.Serial_Info.Add_Hierarchy(2, level2_index, level2_text);
                        if (level3_text.Length > 0)
                        {
                            Package_To_Finalize.Behaviors.Serial_Info.Add_Hierarchy(3, level3_index, level3_text);
                        }
                    }
                }

                // See if this can be described
                bool can_describe = false;
                foreach (DataRow thisRow in DatabaseInfo.Tables[1].Rows)
                {
                    int thisAggregationValue = Convert.ToInt16(thisRow["Items_Can_Be_Described"]);
                    if (thisAggregationValue == 0)
                    {
                        can_describe = false;
                        break;
                    }
                    if (thisAggregationValue == 2)
                    {
                        can_describe = true;
                    }
                }
                Package_To_Finalize.Behaviors.Can_Be_Described = can_describe;

                // Look for rights information to add
                if (mainItemRow["EmbargoEnd"] != DBNull.Value)
                {
                    try
                    {
                        DateTime embargoEnd     = DateTime.Parse(mainItemRow["EmbargoEnd"].ToString());
                        string   origAccessCode = mainItemRow["Original_AccessCode"].ToString();

                        // Is there already a RightsMD module in the item?
                        // Ensure this metadata module extension exists
                        RightsMD_Info rightsInfo = Package_To_Finalize.Get_Metadata_Module(GlobalVar.PALMM_RIGHTSMD_METADATA_MODULE_KEY) as RightsMD_Info;
                        if (rightsInfo == null)
                        {
                            rightsInfo = new RightsMD_Info();
                            Package_To_Finalize.Add_Metadata_Module(GlobalVar.PALMM_RIGHTSMD_METADATA_MODULE_KEY, rightsInfo);
                        }

                        // Add the data
                        rightsInfo.Access_Code_String = origAccessCode;
                        rightsInfo.Embargo_End        = embargoEnd;
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            // Look for user descriptions
            Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Finish_Building_Item", "Look for user descriptions (or tags)");
            foreach (DataRow thisRow in DatabaseInfo.Tables[0].Rows)
            {
                string   first_name = thisRow["FirstName"].ToString();
                string   nick_name  = thisRow["NickName"].ToString();
                string   last_name  = thisRow["LastName"].ToString();
                int      userid     = Convert.ToInt32(thisRow["UserID"]);
                string   tag        = thisRow["Description_Tag"].ToString();
                int      tagid      = Convert.ToInt32(thisRow["TagID"]);
                DateTime dateAdded  = Convert.ToDateTime(thisRow["Date_Modified"]);

                if (nick_name.Length > 0)
                {
                    Package_To_Finalize.Behaviors.Add_User_Tag(userid, nick_name + " " + last_name, tag, dateAdded, tagid);
                }
                else
                {
                    Package_To_Finalize.Behaviors.Add_User_Tag(userid, first_name + " " + last_name, tag, dateAdded, tagid);
                }
            }

            // Look for ticklers
            Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Finish_Building_Item", "Load ticklers from the database info");
            foreach (DataRow thisRow in DatabaseInfo.Tables[3].Rows)
            {
                Package_To_Finalize.Behaviors.Add_Tickler(thisRow["MetadataValue"].ToString().Trim());
            }

            // Set the aggregations in the package to the aggregation links from the database
            Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Finish_Building_Item", "Load the aggregations from the database info");
            Package_To_Finalize.Behaviors.Clear_Aggregations();
            foreach (DataRow thisRow in DatabaseInfo.Tables[1].Rows)
            {
                if (!Convert.ToBoolean(thisRow["impliedLink"]))
                {
                    string code = thisRow["Code"].ToString();
                    if (String.Compare(code, "all", StringComparison.OrdinalIgnoreCase) != 0)
                    {
                        Package_To_Finalize.Behaviors.Add_Aggregation(code, thisRow["Name"].ToString(), thisRow["Type"].ToString());
                    }
                }
            }

            // If no collections, add some regardless of whether it was IMPLIED
            if (Package_To_Finalize.Behaviors.Aggregation_Count == 0)
            {
                foreach (DataRow thisRow in DatabaseInfo.Tables[1].Rows)
                {
                    string code = thisRow["Code"].ToString();
                    if (String.Compare(code, "all", StringComparison.OrdinalIgnoreCase) != 0)
                    {
                        Package_To_Finalize.Behaviors.Add_Aggregation(code, thisRow["Name"].ToString(), thisRow["Type"].ToString());
                    }
                }
            }

            // Make sure no icons were retained from the METS file itself
            Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Finish_Building_Item", "Load the wordmarks/icons from the database info");
            Package_To_Finalize.Behaviors.Clear_Wordmarks();

            // Add the icons from the database information
            foreach (DataRow iconRow in DatabaseInfo.Tables[5].Rows)
            {
                string image = iconRow[0].ToString();
                string link  = iconRow[1].ToString().Replace("&", "&amp;").Replace("\"", "&quot;");
                string code  = iconRow[2].ToString();
                string name  = iconRow[3].ToString();
                if (name.Length == 0)
                {
                    name = code.Replace("&", "&amp;").Replace("\"", "&quot;");
                }

                string html;
                if (link.Length == 0)
                {
                    html = "<img class=\"SobekItemWordmark\" src=\"<%BASEURL%>design/wordmarks/" + image + "\" title=\"" + name + "\" alt=\"" + name + "\" />";
                }
                else
                {
                    if (link[0] == '?')
                    {
                        html = "<a href=\"" + link + "\"><img class=\"SobekItemWordmark\" src=\"<%BASEURL%>design/wordmarks/" + image + "\" alt=\"" + name + "\" /></a>";
                    }
                    else
                    {
                        html = "<a href=\"" + link + "\" target=\"_blank\"><img class=\"SobekItemWordmark\" src=\"<%BASEURL%>design/wordmarks/" + image + "\" alt=\"" + name + "\" /></a>";
                    }
                }

                Wordmark_Info newIcon = new Wordmark_Info {
                    HTML = html, Link = link, Title = name, Code = code
                };
                Package_To_Finalize.Behaviors.Add_Wordmark(newIcon);
            }

            // Make sure no web skins were retained from the METS file itself
            Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Finish_Building_Item", "Load the web skins from the database info");
            Package_To_Finalize.Behaviors.Clear_Web_Skins();

            // Add the web skins from the database
            foreach (DataRow skinRow in DatabaseInfo.Tables[6].Rows)
            {
                Package_To_Finalize.Behaviors.Add_Web_Skin(skinRow[0].ToString().ToUpper());
            }

            // Add the key/value settings
            foreach (DataRow settingRow in DatabaseInfo.Tables[7].Rows)
            {
                Package_To_Finalize.Behaviors.Settings.Add(new Tuple <string, string>(settingRow["Setting_Key"].ToString(), settingRow["Setting_Value"].ToString()));
            }

            Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Finish_Building_Item", "Set the views from a combination of the METS and the database info");

            // Make sure no views were retained from the METS file itself
            Package_To_Finalize.Behaviors.Clear_Views();

            // If there is no PURL, add one based on how SobekCM operates
            if (Package_To_Finalize.Bib_Info.Location.PURL.Length == 0)
            {
                Package_To_Finalize.Bib_Info.Location.PURL = Engine_ApplicationCache_Gateway.Settings.Servers.System_Base_URL + Package_To_Finalize.BibID + "/" + Package_To_Finalize.VID;
            }

            // If this is a newspaper, and there is no datecreated, see if we
            // can make one from the  serial hierarchy
            if (Package_To_Finalize.Behaviors.GroupType.ToUpper() == "NEWSPAPER")
            {
                if ((Package_To_Finalize.Bib_Info.Origin_Info.Date_Created.Length == 0) && (Package_To_Finalize.Bib_Info.Origin_Info.Date_Issued.Length == 0))
                {
                    // Is the serial hierarchy three deep?
                    if (Package_To_Finalize.Behaviors.hasSerialInformation)
                    {
                        if (Package_To_Finalize.Behaviors.Serial_Info.Count == 3)
                        {
                            int year;

                            if (Int32.TryParse(Package_To_Finalize.Behaviors.Serial_Info[0].Display, out year))
                            {
                                int day;
                                if (Int32.TryParse(Package_To_Finalize.Behaviors.Serial_Info[2].Display, out day))
                                {
                                    if ((year > 0) && (year < DateTime.Now.Year + 2) && (day > 0) && (day <= 31))
                                    {
                                        // Is the month a number?
                                        int month;
                                        if (Int32.TryParse(Package_To_Finalize.Behaviors.Serial_Info[1].Display, out month))
                                        {
                                            try
                                            {
                                                // Do it this way since hopefully that will work for localization issues
                                                DateTime date = new DateTime(year, month, day);
                                                Package_To_Finalize.Bib_Info.Origin_Info.Date_Created = date.ToShortDateString();
                                            }
                                            catch
                                            {
                                                // If this is an invalid date, catch the error and do nothing
                                            }
                                        }
                                        else
                                        {
                                            Package_To_Finalize.Bib_Info.Origin_Info.Date_Created = Package_To_Finalize.Behaviors.Serial_Info[1].Display + " " + day + ", " + year;
                                        }
                                    }
                                }
                            }
                        }
                        else if (Package_To_Finalize.Behaviors.Serial_Info.Count == 2)
                        {
                            int year;
                            if (Int32.TryParse(Package_To_Finalize.Behaviors.Serial_Info[0].Display, out year))
                            {
                                if ((year > 0) && (year < DateTime.Now.Year + 2) && (Package_To_Finalize.Behaviors.Serial_Info[1].Display.Length > 0))
                                {
                                    Package_To_Finalize.Bib_Info.Origin_Info.Date_Created = Package_To_Finalize.Behaviors.Serial_Info[1].Display + " " + year;
                                }
                            }
                        }
                    }
                }
            }

            // Check to see which views were present from the database, and build the list
            foreach (DataRow viewRow in DatabaseInfo.Tables[4].Rows)
            {
                string viewType  = viewRow[0].ToString();
                string attribute = viewRow[1].ToString();
                string label     = viewRow[2].ToString();
                float  menuOrder = float.Parse(viewRow[3].ToString());
                bool   exclude   = bool.Parse(viewRow[4].ToString());

                Package_To_Finalize.Behaviors.Add_View(viewType, label, attribute, menuOrder, exclude);
            }

            // IF this is dark, add no other views
            if (Package_To_Finalize.Behaviors.Dark_Flag)
            {
                return;
            }

            // We will continue to set the static page count
            // Step through each page and set the static page count
            Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Finish_Building_Item", "Set the static page count");
            pageseq = 0;
            List <Page_TreeNode> pages_encountered = new List <Page_TreeNode>();

            foreach (abstract_TreeNode rootNode in Package_To_Finalize.Divisions.Physical_Tree.Roots)
            {
                recurse_through_nodes(rootNode, pages_encountered);
            }
            Package_To_Finalize.Web.Static_PageCount = pages_encountered.Count;

            Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Finish_Building_Item", "Done merging the database information with the resource object");
        }
コード例 #7
0
        /// <summary> Reads the amdSec at the current position in the XmlTextReader and associates it with the
        /// entire package  </summary>
        /// <param name="Input_XmlReader"> Open XmlReader from which to read the metadata </param>
        /// <param name="Return_Package"> Package into which to read the metadata</param>
        /// <param name="Options"> Dictionary of any options which this METS section reader may utilize</param>
        /// <returns> TRUE if successful, otherwise FALSE</returns>
        public bool Read_amdSec(XmlReader Input_XmlReader, SobekCM_Item Return_Package, Dictionary <string, object> Options)
        {
            // Ensure this metadata module extension exists
            RightsMD_Info rightsInfo = Return_Package.Get_Metadata_Module(GlobalVar.PALMM_RIGHTSMD_METADATA_MODULE_KEY) as RightsMD_Info;

            if (rightsInfo == null)
            {
                rightsInfo = new RightsMD_Info();
                Return_Package.Add_Metadata_Module(GlobalVar.PALMM_RIGHTSMD_METADATA_MODULE_KEY, rightsInfo);
            }

            // Loop through reading each XML node
            do
            {
                // If this is the end of this section, return
                if ((Input_XmlReader.NodeType == XmlNodeType.EndElement) && ((Input_XmlReader.Name == "METS:mdWrap") || (Input_XmlReader.Name == "mdWrap")))
                {
                    return(true);
                }

                // get the right division information based on node type
                if (Input_XmlReader.NodeType == XmlNodeType.Element)
                {
                    string name = Input_XmlReader.Name.ToLower();
                    if (name.IndexOf("rightsmd:") == 0)
                    {
                        name = name.Substring(9);
                    }

                    switch (name)
                    {
                    case "versionstatement":
                        Input_XmlReader.Read();
                        if ((Input_XmlReader.NodeType == XmlNodeType.Text) && (Input_XmlReader.Value.Trim().Length > 0))
                        {
                            rightsInfo.Version_Statement = Input_XmlReader.Value.Trim();
                        }
                        break;

                    case "copyrightstatement":
                        Input_XmlReader.Read();
                        if ((Input_XmlReader.NodeType == XmlNodeType.Text) && (Input_XmlReader.Value.Trim().Length > 0))
                        {
                            rightsInfo.Copyright_Statement = Input_XmlReader.Value.Trim();
                        }
                        break;

                    case "accesscode":
                        Input_XmlReader.Read();
                        if ((Input_XmlReader.NodeType == XmlNodeType.Text) && (Input_XmlReader.Value.Trim().Length > 0))
                        {
                            rightsInfo.Access_Code = RightsMD_Info.AccessCode_Enum.NOT_SPECIFIED;
                            switch (Input_XmlReader.Value.Trim().ToLower())
                            {
                            case "public":
                                rightsInfo.Access_Code = RightsMD_Info.AccessCode_Enum.Public;
                                break;

                            case "private":
                                rightsInfo.Access_Code = RightsMD_Info.AccessCode_Enum.Private;
                                break;

                            case "campus":
                                rightsInfo.Access_Code = RightsMD_Info.AccessCode_Enum.Campus;
                                break;
                            }
                        }
                        break;

                    case "embargoend":
                        Input_XmlReader.Read();
                        if ((Input_XmlReader.NodeType == XmlNodeType.Text) && (Input_XmlReader.Value.Trim().Length > 0))
                        {
                            DateTime convertedDate;
                            if (DateTime.TryParse(Input_XmlReader.Value, out convertedDate))
                            {
                                rightsInfo.Embargo_End = convertedDate;
                            }
                        }
                        break;
                    }
                }
            } while (Input_XmlReader.Read());

            return(true);
        }
コード例 #8
0
        /// <summary> Constructor for a new instance of the Edit_Item_Permissions_MySobekViewer class  </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Edit_Item_Permissions_MySobekViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues)
        {
            // If no user then that is an error
            if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn))
            {
                RequestSpecificValues.Current_Mode.Mode        = Display_Mode_Enum.Aggregation;
                RequestSpecificValues.Current_Mode.Aggregation = String.Empty;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // Ensure BibID and VID provided
            RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Validate provided bibid / vid");
            if ((String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.BibID)) || (String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.VID)))
            {
                RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "BibID or VID was not provided!");
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.Error;
                RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : BibID/VID missing in item file upload request";
                return;
            }

            RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Try to pull this sobek complete item");
            currentItem = SobekEngineClient.Items.Get_Sobek_Item(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Current_Mode.VID, RequestSpecificValues.Current_User.UserID, RequestSpecificValues.Tracer);
            if (currentItem == null)
            {
                RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Unable to build complete item");
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.Error;
                RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : Unable to build complete item";
                return;
            }

            bool userCanEditItem = RequestSpecificValues.Current_User.Can_Edit_This_Item(currentItem.BibID, currentItem.Bib_Info.SobekCM_Type_String, currentItem.Bib_Info.Source.Code, currentItem.Bib_Info.HoldingCode, currentItem.Behaviors.Aggregation_Code_List);

            if (!userCanEditItem)
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
            }

            // Start by setting the values by the item (good the first time user comes here)
            ipRestrictionMask  = currentItem.Behaviors.IP_Restriction_Membership;
            isDark             = currentItem.Behaviors.Dark_Flag;
            restrictedSelected = (ipRestrictionMask > 0);


            // Is there already a RightsMD module in the item?
            // Ensure this metadata module extension exists
            RightsMD_Info rightsInfo = currentItem.Get_Metadata_Module(GlobalVar.PALMM_RIGHTSMD_METADATA_MODULE_KEY) as RightsMD_Info;

            if ((rightsInfo != null) && (rightsInfo.Has_Embargo_End))
            {
                embargoDate = rightsInfo.Embargo_End;
            }


            // Is this a postback?
            if (RequestSpecificValues.Current_Mode.isPostBack)
            {
                // Get the restriction mask and isDark flag
                if (HttpContext.Current.Request.Form["restrictionMask"] != null)
                {
                    ipRestrictionMask = short.Parse(HttpContext.Current.Request.Form["restrictionMask"]);
                    isDark            = bool.Parse(HttpContext.Current.Request.Form["isDark"]);
                }

                // Look for embargo date
                if (HttpContext.Current.Request.Form["embargoDateBox"] != null)
                {
                    string   embargoText = HttpContext.Current.Request.Form["embargoDateBox"];
                    DateTime embargoDateNew;
                    if (DateTime.TryParse(embargoText, out embargoDateNew))
                    {
                        embargoDate = embargoDateNew;
                    }
                }

                // If this was restrcted, there will be some checkboxes to determine ip restriction mask
                short checked_mask = 0;

                // Determine the IP restriction mask
                foreach (IP_Restriction_Range thisRange in UI_ApplicationCache_Gateway.IP_Restrictions.IpRanges)
                {
                    // Is this check box checked?
                    if (HttpContext.Current.Request.Form["range" + thisRange.RangeID] != null)
                    {
                        checked_mask += ((short)Math.Pow(2, (thisRange.RangeID - 1)));
                    }
                }


                // Handle any request from the internal header for the item
                if (HttpContext.Current.Request.Form["permissions_action"] != null)
                {
                    // Pull the action value
                    string action = HttpContext.Current.Request.Form["permissions_action"].Trim();

                    // Is this to change accessibility?
                    if ((action == "public") || (action == "private") || (action == "restricted") || (action == "dark"))
                    {
                        switch (action)
                        {
                        case "public":
                            ipRestrictionMask  = 0;
                            isDark             = false;
                            restrictedSelected = false;
                            break;

                        case "private":
                            ipRestrictionMask  = -1;
                            isDark             = false;
                            restrictedSelected = false;
                            break;

                        case "restricted":
                            ipRestrictionMask  = short.Parse(HttpContext.Current.Request.Form["selectRestrictionMask"]);
                            restrictedSelected = true;
                            isDark             = false;
                            break;

                        case "dark":
                            isDark             = true;
                            restrictedSelected = false;
                            break;
                        }
                    }
                }

                // Was the SAVE button pushed?
                if (HttpContext.Current.Request.Form["behaviors_request"] != null)
                {
                    string behaviorRequest = HttpContext.Current.Request.Form["behaviors_request"];
                    if (behaviorRequest == "save")
                    {
                        currentItem.Behaviors.IP_Restriction_Membership = ipRestrictionMask;
                        currentItem.Behaviors.Dark_Flag = isDark;

                        if (checked_mask > 0)
                        {
                            ipRestrictionMask = checked_mask;
                        }

                        // Save this to the database
                        if (SobekCM_Item_Database.Set_Item_Visibility(currentItem.Web.ItemID, ipRestrictionMask, isDark, embargoDate, RequestSpecificValues.Current_User.UserName))
                        {
                            // Update the web.config
                            Resource_Web_Config_Writer.Update_Web_Config(currentItem.Source_Directory, currentItem.Behaviors.Dark_Flag, ipRestrictionMask, currentItem.Behaviors.Main_Thumbnail);

                            // Remove the cached item
                            CachedDataManager.Items.Remove_Digital_Resource_Object(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer);

                            // Also clear the engine
                            SobekEngineClient.Items.Clear_Item_Cache(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer);

                            // Also clear any searches or browses ( in the future could refine this to only remove those
                            // that are impacted by this save... but this is good enough for now )
                            CachedDataManager.Clear_Search_Results_Browses();
                        }
                        RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display;
                        UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                    }
                }
            }
        }