Exemple #1
0
        void USFLDC_Redirection_Service()
        {
            String       aggregationCode;
            String       purl_handle;
            const string URL_ERROR = "http://guides.lib.usf.edu/content.php?pid=87781&sid=744350";

            try
            {
                purl_handle = HttpContext.Current.Request.RawUrl.Substring(2);
            }
            catch
            {
                purl_handle = "";
            }

            if (purl_handle == "m1" || purl_handle.StartsWith("m1."))
            {
                // Courtesy permanently moved redirect for former partner MCPL for the MCPLHPC (CID=M01)

                HttpContext.Current.Response.StatusCode = 301;
                HttpContext.Current.Response.Redirect("http://cdm16681.contentdm.oclc.org");
            }
            else if (purl_handle.Contains(".") && !purl_handle.Contains("browse") && !purl_handle.Contains("search"))
            {
                // item purl
                if (purl_handle.Contains("-ead"))
                {
                    // It is an EAD item purl

                    int    pos1 = purl_handle.IndexOf("-");
                    int    len  = pos1 - 4;
                    String doi  = "U29-" + int.Parse(purl_handle.Substring(4, len)).ToString("D5") + "-" + purl_handle.Substring(pos1 + 1, 3);
                    String url  = "http://dis.lib.usf.edu/aeon/eads/index.html?eadrequest=true&ead_id=" + doi;
                    HttpContext.Current.Response.StatusCode = 307;
                    HttpContext.Current.Response.Redirect(url, true);
                    return;
                }

                String packageid = SobekCM_Database.Get_BibID_VID_From_Identifier(purl_handle);

                if (packageid != null)
                {
                    packageid = packageid.ToUpper();
                    HttpContext.Current.Response.StatusCode = 307;
                    HttpContext.Current.Response.Redirect(packageid, true);
                }
                else
                {
                    HttpContext.Current.Response.StatusCode = 307;
                    HttpContext.Current.Response.Redirect(URL_ERROR);
                }
            }
            else if (purl_handle.Contains(".browse") || purl_handle.Contains(".search"))
            {
                // browse or search purl

                String purl_handle_original = purl_handle;
                int    pos1 = purl_handle.IndexOf(".");
                purl_handle = purl_handle.Substring(0, pos1);

                if (purl_handle.Length == 2)
                {
                    purl_handle = purl_handle.Substring(0, 1) + "0" + purl_handle.Substring(1);
                }

                aggregationCode = SobekCM_Database.Get_AggregationCode_From_CID(purl_handle.ToUpper());

                if (aggregationCode != null)
                {
                    string action = purl_handle_original.Contains(".browse") ? "/all" : "/advanced";

                    HttpContext.Current.Response.StatusCode = 307;
                    HttpContext.Current.Response.Redirect(aggregationCode.ToLower() + action, true);
                }
                else
                {
                    HttpContext.Current.Response.StatusCode = 307;
                    HttpContext.Current.Response.Redirect(URL_ERROR);
                }
            }
            else if (purl_handle.Length == 2 || purl_handle.Length == 3)
            {
                // collection purl

                if (purl_handle.Length == 2)
                {
                    purl_handle = purl_handle.Substring(0, 1) + "0" + purl_handle.Substring(1);
                }

                aggregationCode = SobekCM_Database.Get_AggregationCode_From_CID(purl_handle.ToUpper());

                if (aggregationCode != null)
                {
                    HttpContext.Current.Response.StatusCode = 307;
                    HttpContext.Current.Response.Redirect(aggregationCode.ToLower(), true);
                }
                else
                {
                    HttpContext.Current.Response.StatusCode = 307;
                    HttpContext.Current.Response.Redirect(URL_ERROR);
                }
            }
            else
            {
                HttpContext.Current.Response.StatusCode = 307;
                HttpContext.Current.Response.Redirect(URL_ERROR);
            }
        }