/// <summary>  Constructor for a new instance of the Delete_Verify_WebContentViewer class  </summary>
        /// <param name="RequestSpecificValues">  All the necessary, non-global data specific to the current request  </param>
        /// <param name="StaticPage"> Static page info for this request </param>
        public Delete_Verify_WebContentViewer(RequestCache RequestSpecificValues, HTML_Based_Content StaticPage)
            : base(RequestSpecificValues, StaticPage)
        {
            // Pull the web content page
            if (RequestSpecificValues.Current_Mode.WebContentID.HasValue)
            {
                webContent = SobekEngineClient.WebContent.Get_HTML_Based_Content(RequestSpecificValues.Current_Mode.WebContentID.Value, true, RequestSpecificValues.Tracer);
            }

            // This should never occur, but just a double check
            if ((webContent == null) || (!webContent.WebContentID.HasValue))
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // Ensure there IS a logged on user
            RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Delete_Verify_WebContentViewer", "Validate user");
            if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn))
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // If the user was logged on, but did not have permissions, show an error message
            canDelete = true;
            deleted   = false;
            if (!webContent.Can_Delete(RequestSpecificValues.Current_User))
            {
                errorMessage = "ERROR: You do not have permission to delete this page";
                canDelete    = false;
            }
            else if (HttpContext.Current.Request.RequestType == "POST")
            {
                string save_value = HttpContext.Current.Request.Form["admin_delete_item"];

                // Better say "DELETE", or just send back to the item
                if ((save_value != null) && (String.Compare(save_value, "DELETE", StringComparison.OrdinalIgnoreCase) == 0))
                {
                    string entered_value = HttpContext.Current.Request.Form["admin_delete_confirm"];
                    if ((entered_value == null) || (entered_value.ToUpper() != "DELETE"))
                    {
                        errorMessage = "ERROR: To verify this deletion, type DELETE into the text box and press CONFIRM";
                    }
                    else
                    {
                        string deleteReason = "Requested via web application";


                        RestResponseMessage message = SobekEngineClient.WebContent.Delete_HTML_Based_Content(webContent.WebContentID.Value, RequestSpecificValues.Current_User.Full_Name, deleteReason, RequestSpecificValues.Tracer);

                        errorMessage = message.Message;
                        if ((message.ErrorTypeEnum != ErrorRestTypeEnum.Successful) && (String.IsNullOrEmpty(errorMessage)))
                        {
                            errorMessage = "Error encountered on SobekCM engine.";
                        }
                        else
                        {
                            errorMessage = "Successfully deleted this web content page.";

                            // Clear cached data here on the client
                            CachedDataManager.WebContent.Clear_All_Web_Content_Lists();
                            CachedDataManager.WebContent.Clear_All_Web_Content_Pages();
                            CachedDataManager.WebContent.Clear_Page_Details();
                            UI_ApplicationCache_Gateway.WebContent_Hierarchy_Clear();

                            deleted = true;
                        }
                    }
                }
            }
        }
Пример #2
0
        /// <summary> Constructor for a new instance of the Default_Metadata_AdminViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <remarks> Postback from handling a new project is handled here in the constructor </remarks>
        public Default_Metadata_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("Default_Metadata_AdminViewer.Constructor", String.Empty);

            // Set action message and entered values to nothing to start
            actionMessage = String.Empty;
            entered_code  = String.Empty;
            entered_base  = String.Empty;
            entered_name  = String.Empty;
            entered_desc  = String.Empty;

            // If the RequestSpecificValues.Current_User cannot edit this, go back
            if ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin))
            {
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.My_Sobek;
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // If this is a postback, handle any events first
            if (RequestSpecificValues.Current_Mode.isPostBack)
            {
                try
                {
                    // Pull the standard values
                    NameValueCollection form = HttpContext.Current.Request.Form;

                    string save_value   = form["admin_project_tosave"].ToUpper().Trim();
                    string delete_value = form["admin_project_delete"].ToUpper().Trim();
                    string code_value   = form["admin_project_code"].ToUpper().Trim();

                    // Was this a delete request?
                    if ((RequestSpecificValues.Current_User.Is_System_Admin) && (delete_value.Length > 0))
                    {
                        RequestSpecificValues.Tracer.Add_Trace("Default_Metadata_AdminViewer.Constructor", "Delete default metadata '" + delete_value + "'");

                        // Try to delete in the database
                        if (SobekCM_Database.Delete_Default_Metadata(delete_value, RequestSpecificValues.Tracer))
                        {
                            // Set the message
                            actionMessage = "Deleted default metadata '" + delete_value + "'";

                            // Look for the file to delete as well
                            string pmets_file = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "projects\\" + delete_value + ".pmets";
                            if (File.Exists(pmets_file))
                            {
                                try
                                {
                                    File.Delete(pmets_file);
                                }
                                catch
                                {
                                    actionMessage = "Deleted default metadata '" + delete_value + "' but failed to delete associated pmets file";
                                }
                            }
                        }
                        else
                        {
                            actionMessage = "Error encountered deleting default metadata '" + delete_value + "' from the database";
                        }



                        Engine_ApplicationCache_Gateway.RefreshCollectionAliases();
                    }
                    else if (save_value.Length > 0) // Or.. was this a save request
                    {
                        RequestSpecificValues.Tracer.Add_Trace("Default_Metadata_AdminViewer.Constructor", "Save default metadata '" + save_value + "'");

                        // Was this to save a new project (from the main page) or rename an existing (from the popup form)?
                        if (save_value == code_value)
                        {
                            entered_code = code_value;
                            entered_base = form["admin_project_base"].ToUpper().Trim();
                            entered_name = form["admin_project_name"].Trim().Replace("\"", "'");
                            entered_desc = form["admin_project_desc"].Trim().Replace("\"", "'");

                            if (entered_name.Length == 0)
                            {
                                entered_name = entered_code;
                            }
                            if (entered_desc.Length == 0)
                            {
                                entered_desc = entered_name;
                            }

                            // Ensure the code is valid first
                            bool result = entered_code.All(C => Char.IsLetterOrDigit(C) || C == '_');
                            if (!result)
                            {
                                actionMessage = "ERROR: Default metadata CODE must contain only letters and numbers";
                                entered_code  = entered_code.Replace("\"", "");
                            }
                            else if (entered_code.Length == 0)
                            {
                                actionMessage = "ERROR: Default metadata CODE is required";
                            }
                            else if (entered_code.Length > 20)
                            {
                                actionMessage = "ERROR: Default metadata CODE cannot be more than twenty characters long";
                                entered_code  = entered_code.Substring(0, 20);
                            }
                            else if (entered_name.Length > 50)
                            {
                                actionMessage = "ERROR: Default metadata NAME cannot be more than fifty characters long";
                                entered_name  = entered_name.Substring(0, 50);
                            }
                            else
                            {
                                // Save this new interface
                                if (SobekCM_Database.Save_Default_Metadata(entered_code.ToUpper(), entered_name, entered_desc, -1, RequestSpecificValues.Tracer))
                                {
                                    actionMessage = "Saved new default metadata <i>" + save_value + "</i>";

                                    entered_code = String.Empty;
                                    entered_base = String.Empty;
                                    entered_name = String.Empty;
                                    entered_desc = String.Empty;
                                }
                                else
                                {
                                    actionMessage = "Unable to save new default metadata <i>" + save_value + "</i>";
                                }

                                Engine_ApplicationCache_Gateway.RefreshCollectionAliases();

                                // Try to creating the PMETS file if there was a base PMETS code provided
                                try
                                {
                                    if (entered_base.Length > 0)
                                    {
                                        string pmets_file      = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "projects\\" + code_value + ".pmets";
                                        string base_pmets_file = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "projects\\" + entered_base + ".pmets";

                                        if (File.Exists(base_pmets_file))
                                        {
                                            File.Copy(base_pmets_file, pmets_file, true);
                                        }
                                    }
                                }
                                catch (Exception)
                                {
                                    actionMessage = "Error copying new default metadata METS to the project folder";
                                }
                            }
                        }
                        else
                        {
                            string edit_name        = form["form_project_name"].Trim().Replace("\"", "'");
                            string edit_description = form["form_project_desc"].Trim().Replace("\"", "'");

                            // Save this existing interface
                            if (SobekCM_Database.Save_Default_Metadata(save_value.ToUpper(), edit_name, edit_description, -1, RequestSpecificValues.Tracer))
                            {
                                actionMessage = "Renamed existing default metadata <i>" + save_value + "</i>";
                            }
                            else
                            {
                                actionMessage = "Unable to rename existing default metadata <i>" + save_value + "</i>";
                            }

                            Engine_ApplicationCache_Gateway.RefreshCollectionAliases();
                        }
                    }
                }
                catch (Exception)
                {
                    actionMessage = "Unknown exception occurred while processing your request";
                }
            }

            UI_ApplicationCache_Gateway.ResetDefaultMetadataTemplates();
        }
        /// <summary> Constructor for a new instance of the Builder_Folder_Mgmt_AdminViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Builder_Folder_Mgmt_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues)
        {
            // Verify this user can edit this
            bool allowEdit = (((!UI_ApplicationCache_Gateway.Settings.Servers.isHosted) && (RequestSpecificValues.Current_User.Is_System_Admin)) || (RequestSpecificValues.Current_User.Is_Host_Admin));

            if (!allowEdit)
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // Is there a folder specified?
            folderId = -1;
            if ((RequestSpecificValues.Current_Mode.Remaining_Url_Segments != null) && (RequestSpecificValues.Current_Mode.Remaining_Url_Segments.Length > 0))
            {
                if (String.Compare(RequestSpecificValues.Current_Mode.Remaining_Url_Segments[0], "new", StringComparison.OrdinalIgnoreCase) != 0)
                {
                    if (!Int32.TryParse(RequestSpecificValues.Current_Mode.Remaining_Url_Segments[0], out folderId))
                    {
                        folderId = -1;
                    }
                }
            }

            // Handle any post backs
            saved = false;
            if (RequestSpecificValues.Current_Mode.isPostBack)
            {
                try
                {
                    // Pull the standard values from the form
                    NameValueCollection form = HttpContext.Current.Request.Form;
                    string action_value      = form["admin_builder_folder_action"];

                    // Get the entered values
                    folderName             = form["admin_folder_name"];
                    failuresFolder         = form["admin_folder_error"];
                    inboundFolder          = form["admin_folder_network"];
                    processingFolder       = form["admin_folder_processing"];
                    performChecksum        = (form["admin_folder_checksum"] != null);
                    archiveTiffs           = (form["admin_folder_archive_tiff"] != null);
                    archiveAllFiles        = (form["admin_folder_archive_all"] != null);
                    allowDeletes           = (form["admin_folder_allow_delete"] != null);
                    allowFoldersNoMetadata = (form["admin_folder_no_metadata"] != null);
                    allowMetadataUpdates   = (form["admin_folder_allow_updates"] != null);

                    // Get the hidden values
                    bibIdRestrictions = form["admin_builder_folder_restrictions"];
                    moduleSetId       = Int32.Parse(form["admin_builder_folder_modulesetid"]);

                    // The folders should always end with a slash
                    if ((!String.IsNullOrWhiteSpace(failuresFolder)) && (failuresFolder.Length > 2) && (failuresFolder[failuresFolder.Length - 1] != '\\'))
                    {
                        failuresFolder = failuresFolder + "\\";
                    }
                    if ((!String.IsNullOrWhiteSpace(inboundFolder)) && (inboundFolder.Length > 2) && (inboundFolder[inboundFolder.Length - 1] != '\\'))
                    {
                        inboundFolder = inboundFolder + "\\";
                    }
                    if ((!String.IsNullOrWhiteSpace(processingFolder)) && (processingFolder.Length > 2) && (processingFolder[processingFolder.Length - 1] != '\\'))
                    {
                        processingFolder = processingFolder + "\\";
                    }

                    // Switch, depending on the request
                    if (!String.IsNullOrEmpty(action_value))
                    {
                        // Was this a CANCEL?
                        if (action_value == "cancel")
                        {
                            // Determine URL
                            string returnUrl = RequestSpecificValues.Current_Mode.Base_URL + "l/admin/settings/builder/folders";
                            RequestSpecificValues.Current_Mode.Request_Completed = true;
                            HttpContext.Current.Response.Redirect(returnUrl, false);
                            HttpContext.Current.ApplicationInstance.CompleteRequest();
                            return;
                        }

                        // Was this a DELETE/
                        if (action_value == "delete")
                        {
                            // Try to delete this folder
                            bool result = SobekCM_Database.Builder_Folder_Delete(folderId, RequestSpecificValues.Tracer);
                            if (!result)
                            {
                                actionMessage = "Unknown error encountered while trying to delete this folder";
                            }
                            else
                            {
                                // Clear settings to be pulled again
                                HttpContext.Current.Session["Admin_Settigs"] = null;

                                // Assign this to be used by the system
                                UI_ApplicationCache_Gateway.ResetSettings();

                                // Return to the folder list
                                string returnUrl = RequestSpecificValues.Current_Mode.Base_URL + "l/admin/settings/builder/folders";
                                RequestSpecificValues.Current_Mode.Request_Completed = true;
                                HttpContext.Current.Response.Redirect(returnUrl, false);
                                HttpContext.Current.ApplicationInstance.CompleteRequest();
                                return;
                            }
                        }

                        // Was this a SAVE?
                        if (action_value == "save")
                        {
                            // Perform some validations
                            List <string> errors = new List <string>();
                            if (String.IsNullOrWhiteSpace(folderName))
                            {
                                errors.Add("DESCRIPTIVE NAME is required and missing");
                            }
                            if (String.IsNullOrWhiteSpace(failuresFolder))
                            {
                                errors.Add("FAILURES FOLDER is required and missing");
                            }
                            if (String.IsNullOrWhiteSpace(inboundFolder))
                            {
                                errors.Add("INBOUND FOLDER is required and missing");
                            }
                            if (String.IsNullOrWhiteSpace(processingFolder))
                            {
                                errors.Add("PROCESSING FOLDER is required and missing");
                            }

                            // If there were error, prepare the error message and don't save
                            if (errors.Count > 0)
                            {
                                actionMessage = "ERROR: Some required fields are missing:<br /><br />";
                                foreach (string thisError in errors)
                                {
                                    actionMessage = actionMessage + "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; " + thisError + "<br />";
                                }
                            }
                            else
                            {
                                // Try to save this folder
                                bool result = SobekCM_Database.Builder_Folder_Edit(folderId, folderName, inboundFolder, failuresFolder, processingFolder, performChecksum, archiveTiffs, archiveAllFiles, allowDeletes, allowFoldersNoMetadata, bibIdRestrictions, moduleSetId, RequestSpecificValues.Tracer);
                                if (!result)
                                {
                                    actionMessage = "Unknown error encountered while saving folder to the database";
                                }
                                else
                                {
                                    // Successfully saved
                                    saved         = true;
                                    actionMessage = "Successfully saved builder folder changes.";

                                    // Clear settings to be pulled again
                                    HttpContext.Current.Session["Admin_Settigs"] = null;

                                    // Assign this to be used by the system
                                    UI_ApplicationCache_Gateway.ResetSettings();

                                    // Also, look to see if a warning might be suitable
                                    List <string> warnings = new List <string>();
                                    try
                                    {
                                        if (!Directory.Exists(failuresFolder))
                                        {
                                            warnings.Add("Can't verify existence of the FAILURES FOLDER");
                                        }
                                        if (!Directory.Exists(inboundFolder))
                                        {
                                            warnings.Add("Can't verify existence of the INBOUND FOLDER");
                                        }
                                        if (!Directory.Exists(processingFolder))
                                        {
                                            warnings.Add("Can't verify existence of the PROCESSING FOLDER");
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        warnings.Clear();
                                        warnings.Add("Exception caught while trying to verify folders.");
                                    }

                                    // Add warnings
                                    if (warnings.Count == 3)
                                    {
                                        // i.e., none of the folders could be verified
                                        actionMessage = actionMessage + "<br /><br />WARNING: Unable to verify existence of any of the folders.  This may be normal since the account under which the web runs does not necessarily need access to the builder folders.";
                                    }
                                    else if (warnings.Count > 0)
                                    {
                                        actionMessage = actionMessage + "<br /><br />WARNING: Unable to verify existence of some of the folders:<br /><br />";
                                        foreach (string thisWarning in warnings)
                                        {
                                            actionMessage = actionMessage + "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; " + thisWarning + "<br />";
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch
                {
                }
            }
            else // NOT A POST BACK
            {
                // Configure the values
                folderName             = String.Empty;
                failuresFolder         = String.Empty;
                inboundFolder          = String.Empty;
                processingFolder       = String.Empty;
                performChecksum        = false;
                archiveTiffs           = false;
                archiveAllFiles        = false;
                allowDeletes           = true;
                allowFoldersNoMetadata = true;
                bibIdRestrictions      = String.Empty;
                moduleSetId            = 10;

                // Is there a folder specified?
                if (folderId > 0)
                {
                    // Try to get this source folder
                    Builder_Source_Folder sourceFolder = SobekEngineClient.Builder.Get_Builder_Folder(folderId, RequestSpecificValues.Tracer);

                    if (sourceFolder != null)
                    {
                        // Set the values from the existing source folder
                        folderName             = sourceFolder.Folder_Name;
                        failuresFolder         = sourceFolder.Failures_Folder;
                        inboundFolder          = sourceFolder.Inbound_Folder;
                        processingFolder       = sourceFolder.Processing_Folder;
                        performChecksum        = sourceFolder.Perform_Checksum;
                        archiveTiffs           = sourceFolder.Archive_TIFFs;
                        archiveAllFiles        = sourceFolder.Archive_All_Files;
                        allowDeletes           = sourceFolder.Allow_Deletes;
                        allowFoldersNoMetadata = sourceFolder.Allow_Folders_No_Metadata;
                        allowMetadataUpdates   = sourceFolder.Allow_Metadata_Updates;
                        bibIdRestrictions      = sourceFolder.BibID_Roots_Restrictions;
                        moduleSetId            = sourceFolder.Builder_Module_Set.SetID;
                    }
                    else
                    {
                        folderId = -1;
                    }
                }
            }
        }
        /// <summary> Constructor for a new instance of the WebContent_Add_New_AdminViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <remarks> Postback from handling an edit or new aggregation is handled here in the constructor </remarks>
        public WebContent_Add_New_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("WebContent_Add_New_AdminViewer.Constructor", String.Empty);

            // Set some defaults
            actionMessage = String.Empty;


            // Ensure the user is the system admin or portal admin
            if ((RequestSpecificValues.Current_User == null) || ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin)))
            {
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.My_Sobek;
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // If this is posted back, look for the reset
            if (RequestSpecificValues.Current_Mode.isPostBack)
            {
                // Pull the standard values
                NameValueCollection form = HttpContext.Current.Request.Form;

                // Get the values from the form
                if (form["admin_webcontent_title"] != null)
                {
                    title = form["admin_webcontent_title"];
                }
                if (form["admin_webcontent_desc"] != null)
                {
                    description = form["admin_webcontent_desc"];
                }
                if (form["admin_webcontent_redirect"] != null)
                {
                    redirect_url = form["admin_webcontent_redirect"];
                }
                if (form["admin_webcontent_skin"] != null)
                {
                    webSkin = form["admin_webcontent_skin"];
                }
                inheritFromParent = form["admin_webcontent_inherit"] != null;

                // Get the level values from the form
                if ((form["admin_webcontent_level1"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level1"])))
                {
                    level1 = form["admin_webcontent_level1"];
                    if ((form["admin_webcontent_level2"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level2"])))
                    {
                        level2 = form["admin_webcontent_level2"];
                        if ((form["admin_webcontent_level3"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level3"])))
                        {
                            level3 = form["admin_webcontent_level3"];
                            if ((form["admin_webcontent_level4"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level4"])))
                            {
                                level4 = form["admin_webcontent_level4"];
                                if ((form["admin_webcontent_level5"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level5"])))
                                {
                                    level5 = form["admin_webcontent_level5"];
                                    if ((form["admin_webcontent_level6"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level6"])))
                                    {
                                        level6 = form["admin_webcontent_level6"];
                                        if ((form["admin_webcontent_level7"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level7"])))
                                        {
                                            level7 = form["admin_webcontent_level7"];
                                            if ((form["admin_webcontent_level8"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level8"])))
                                            {
                                                level8 = form["admin_webcontent_level8"];
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                // Perform validation
                actionMessage = String.Empty;
                if ((String.IsNullOrEmpty(title)) || (String.IsNullOrEmpty(level1)))
                {
                    actionMessage = "Error - required fields are missing<br />";
                    if (String.IsNullOrEmpty(title))
                    {
                        actionMessage = actionMessage + " &nbsp; &nbsp; &nbsp; TITLE is a required field.<br />";
                    }
                    if (String.IsNullOrEmpty(level1))
                    {
                        actionMessage = actionMessage + " &nbsp; &nbsp; &nbsp; LEVEL1 is a required field.<br />";
                    }
                }

                string save_value = HttpContext.Current.Request.Form["admin_webcontent_save"];
                if ((!String.IsNullOrEmpty(save_value)) && (save_value == "save"))
                {
                    // Just ensure everything is emptied out
                    if (String.IsNullOrEmpty(actionMessage))
                    {
                        // Build this web content page
                        HTML_Based_Content newContent = new HTML_Based_Content
                        {
                            WebContentID = -1,
                            Level1       = level1,
                            Level2       = level2,
                            Level3       = level3,
                            Level4       = level4,
                            Level5       = level5,
                            Level6       = level6,
                            Level7       = level7,
                            Level8       = level8,
                            Title        = title,
                            Description  = description,
                            Web_Skin     = webSkin,
                            Author       = RequestSpecificValues.Current_User.Full_Name,
                            Date         = DateTime.Now.ToShortDateString()
                        };

                        if (!String.IsNullOrEmpty(description))
                        {
                            newContent.Content = "<h2>" + title + "</h2>" + Environment.NewLine + "<p>" + description + "</p>";
                        }
                        else
                        {
                            newContent.Content = "<h2>" + title + "</h2>" + Environment.NewLine + "<p>New web content page text goes here.</p>";
                        }
                        newContent.ContentSource = newContent.Content;

                        // Call the engine endpoint to put this
                        RestResponseMessage msg = SobekEngineClient.WebContent.Add_HTML_Based_Content(newContent, RequestSpecificValues.Current_User.Full_Name, inheritFromParent, RequestSpecificValues.Tracer);

                        // Clear the hierarchy
                        CachedDataManager.WebContent.Clear_Hierarchy();
                        UI_ApplicationCache_Gateway.WebContent_Hierarchy_Clear();

                        // If successful, just send to it
                        if (msg != null)
                        {
                            if (msg.ErrorTypeEnum == ErrorRestTypeEnum.Successful)
                            {
                                if (String.IsNullOrEmpty(msg.URI))
                                {
                                    actionMessage = "Page added, but new URI was not returned";
                                }
                                else
                                {
                                    RequestSpecificValues.Current_Mode.Request_Completed = true;
                                    HttpContext.Current.Response.Redirect(msg.URI, false);
                                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                                    return;
                                }
                            }
                            else
                            {
                                actionMessage = "ERROR: " + msg.Message;
                            }
                        }
                        else
                        {
                            actionMessage = "ERROR: Exception deserializing the REST response message.";
                        }
                    }
                }
            }
            else
            {
                // Get any level filter information from the query string
                if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l1"]))
                {
                    level1 = HttpContext.Current.Request.QueryString["l1"];

                    if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l2"]))
                    {
                        level2 = HttpContext.Current.Request.QueryString["l2"];

                        if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l3"]))
                        {
                            level3 = HttpContext.Current.Request.QueryString["l3"];

                            if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l4"]))
                            {
                                level4 = HttpContext.Current.Request.QueryString["l4"];

                                if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l5"]))
                                {
                                    level5 = HttpContext.Current.Request.QueryString["l5"];
                                    if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l6"]))
                                    {
                                        level6 = HttpContext.Current.Request.QueryString["l6"];
                                        if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l7"]))
                                        {
                                            level7 = HttpContext.Current.Request.QueryString["l7"];
                                            if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l8"]))
                                            {
                                                level8 = HttpContext.Current.Request.QueryString["l8"];
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }