protected void Page_Load(object sender, EventArgs e)
        {
            string subject = Request["subject"];
            string predicate = Request["predicate"];
            string obj = Request["object"];
            string person = Request["person"];
            string expand = Request["expand"];
            string showDetails = Request["showdetails"];
            string callback = Request["callback"];

            Int64 nodeid = -1;
            if (subject != null && subject.Trim().Length > 0)
            {
                nodeid = Convert.ToInt64(subject);
            }
            else if (person != null && person.Trim().Length > 0)
            {
                nodeid = new DataIO().GetNodeId(Convert.ToInt32(person));
            }
            else
            {
                Response.Redirect(Profiles.Framework.Utilities.Root.Domain + "/ORNG/JSONLD/Test.htm");
            }

            Response.Clear();
            Response.Charset = "charset=UTF-8";
            Response.StatusCode = Convert.ToInt16("200");

            string URL = Profiles.Framework.Utilities.Root.Domain + "/Profile/Profile.aspx?Subject=" + nodeid;
            if (predicate != null)
                URL += "&Predicate=" + predicate;
            if (obj != null)
                URL += "&Object=" + obj;
            if (expand != null)
                URL += "&Expand=" + expand;
            if (showDetails != null)
                URL += "&ShowDetails=" + showDetails;
            URL = ORNGSettings.getSettings().ShindigURL + "/rest/jsonld?userId=" + HttpUtility.UrlEncode(URL);

            HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(URL);
            myReq.Accept = "application/json"; // "application/ld+json";
            String jsonProfiles = new StreamReader(myReq.GetResponse().GetResponseStream()).ReadToEnd();

            //WebClient client = new WebClient();
            //String jsonProfiles = client.DownloadString(URL);

            if (callback != null && callback.Length > 0)
            {
                Response.ContentType = "application/javascript";
                Response.Write(callback + "(" + jsonProfiles + ");");
            }
            else
            {
                Response.ContentType = "application/json";
                Response.Write(jsonProfiles);
            }
        }
Пример #2
0
        public EditPersonalGadget(XmlDocument pagedata, List <ModuleParams> moduleparams, XmlNamespaceManager pagenamespaces)
            : base(pagedata, moduleparams, pagenamespaces)
        {
            SessionManagement sm = new SessionManagement();

            base.BaseData = pagedata;

            data = new Profiles.ORNG.Utilities.DataIO();
            Profiles.Edit.Utilities.DataIO    editdata = new Profiles.Edit.Utilities.DataIO();
            Profiles.Profile.Utilities.DataIO propdata = new Profiles.Profile.Utilities.DataIO();

            if (Request.QueryString["subject"] != null)
            {
                this.SubjectID = Convert.ToInt64(Request.QueryString["subject"]);
            }
            else if (base.GetRawQueryStringItem("subject") != null)
            {
                this.SubjectID = Convert.ToInt64(base.GetRawQueryStringItem("subject"));
            }
            else
            {
                Response.Redirect("~/search");
            }

            this.PredicateURI    = Request.QueryString["predicateuri"].Replace("!", "#");
            this.PropertyListXML = propdata.GetPropertyList(this.BaseData, base.PresentationXML, this.PredicateURI, false, true, false);
            litBackLink.Text     = "<a href='" + Root.Domain + "/edit/" + this.SubjectID.ToString() + "'>Edit Menu</a> &gt; <b>" + PropertyListXML.SelectSingleNode("PropertyList/PropertyGroup/Property/@Label").Value + "</b>";


            //create a new network triple request.
            base.RDFTriple = new RDFTriple(this.SubjectID, editdata.GetStoreNode(this.PredicateURI));

            base.RDFTriple.Expand      = true;
            base.RDFTriple.ShowDetails = true;
            base.GetDataByURI();//This will reset the data to a Network.

            // Profiles OpenSocial Extension by UCSF
            uri    = this.BaseData.SelectSingleNode("rdf:RDF/rdf:Description/@rdf:about", base.Namespaces).Value;
            uri    = uri.Substring(0, uri.IndexOf(Convert.ToString(this.SubjectID)) + Convert.ToString(this.SubjectID).Length);
            appId  = Convert.ToInt32(base.GetModuleParamString("AppId"));
            om     = OpenSocialManager.GetOpenSocialManager(uri, Page, true);
            gadget = om.AddGadget(appId, base.GetModuleParamString("View"), base.GetModuleParamString("OptParams"));

            securityOptions.Subject        = this.SubjectID;
            securityOptions.PredicateURI   = this.PredicateURI;
            securityOptions.PrivacyCode    = Convert.ToInt32(this.PropertyListXML.SelectSingleNode("PropertyList/PropertyGroup/Property/@ViewSecurityGroup").Value);
            securityOptions.SecurityGroups = new XmlDataDocument();
            securityOptions.SecurityGroups.LoadXml(base.PresentationXML.DocumentElement.LastChild.OuterXml);

            hasGadget = Convert.ToInt32(this.PropertyListXML.SelectSingleNode("PropertyList/PropertyGroup/Property/@NumberOfConnections").Value) > 0;
        }
        public EditPersonalGadget(XmlDocument pagedata, List<ModuleParams> moduleparams, XmlNamespaceManager pagenamespaces)
            : base(pagedata, moduleparams, pagenamespaces)
        {
            SessionManagement sm = new SessionManagement();
            base.BaseData = pagedata;

            data = new Profiles.ORNG.Utilities.DataIO();
            Profiles.Edit.Utilities.DataIO editdata = new Profiles.Edit.Utilities.DataIO();
            Profiles.Profile.Utilities.DataIO propdata = new Profiles.Profile.Utilities.DataIO();

            if (Request.QueryString["subject"] != null)
                this.SubjectID = Convert.ToInt64(Request.QueryString["subject"]);
            else if (base.GetRawQueryStringItem("subject") != null)
                this.SubjectID = Convert.ToInt64(base.GetRawQueryStringItem("subject"));
            else
                Response.Redirect("~/search");

            this.PredicateURI = Request.QueryString["predicateuri"].Replace("!", "#");
            this.PropertyListXML = propdata.GetPropertyList(this.BaseData, base.PresentationXML, this.PredicateURI, false, true, false);
            litBackLink.Text = "<a href='" + Root.Domain + "/edit/" + this.SubjectID.ToString() + "'>Edit Menu</a> &gt; <b>" + PropertyListXML.SelectSingleNode("PropertyList/PropertyGroup/Property/@Label").Value + "</b>";

            //create a new network triple request.
            base.RDFTriple = new RDFTriple(this.SubjectID, editdata.GetStoreNode(this.PredicateURI));

            base.RDFTriple.Expand = true;
            base.RDFTriple.ShowDetails = true;
            base.GetDataByURI();//This will reset the data to a Network.

            // Profiles OpenSocial Extension by UCSF
            uri = this.BaseData.SelectSingleNode("rdf:RDF/rdf:Description/@rdf:about", base.Namespaces).Value;
            uri = uri.Substring(0, uri.IndexOf(Convert.ToString(this.SubjectID)) + Convert.ToString(this.SubjectID).Length);
            appId = Convert.ToInt32(base.GetModuleParamString("AppId"));
            om = OpenSocialManager.GetOpenSocialManager(uri, Page, true);
            if (om.IsEnabled())
            {
                gadget = om.AddOntologyGadget(appId, base.GetModuleParamString("View"), base.GetModuleParamString("OptParams"));
            }

            securityOptions.Subject = this.SubjectID;
            securityOptions.PredicateURI = this.PredicateURI;
            securityOptions.PrivacyCode = Convert.ToInt32(this.PropertyListXML.SelectSingleNode("PropertyList/PropertyGroup/Property/@ViewSecurityGroup").Value);
            securityOptions.SecurityGroups = new XmlDataDocument();
            securityOptions.SecurityGroups.LoadXml(base.PresentationXML.DocumentElement.LastChild.OuterXml);

            hasGadget = Convert.ToInt32(this.PropertyListXML.SelectSingleNode("PropertyList/PropertyGroup/Property/@NumberOfConnections").Value) > 0;
        }
Пример #4
0
 private void UpdateSecuritySetting(string securitygroup)
 {
     // maybe be able to make this more general purpose
     if (this.PredicateURI.StartsWith(Profiles.ORNG.Utilities.OpenSocialManager.ORNG_ONTOLOGY_PREFIX))
     {
         Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();
         if ("0".Equals(securitygroup))
         {
             data.RemovePersonalGadget(this.Subject, this.PredicateURI);
         }
         else
         {
             data.AddPersonalGadget(this.Subject, this.PredicateURI);
         }
     }
     else if (!"0".Equals(securitygroup))
     {
         Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
         data.UpdateSecuritySetting(this.Subject, data.GetStoreNode(this.PredicateURI), Convert.ToInt32(securitygroup));
     }
     //Framework.Utilities.Cache.AlterDependency(this.Subject.ToString());
 }
Пример #5
0
        private void DrawProfilesModule()
        {
            List <GenericListItem> gli = new List <GenericListItem>();
            bool canedit = false;

            Profile.Utilities.DataIO    data = new Profiles.Profile.Utilities.DataIO();
            List <List <SecurityItem> > si   = new List <List <SecurityItem> >();
            List <SecurityItem>         singlesi;

            this.Dropdown     = new List <GenericListItem>();
            this.PropertyList = data.GetPropertyList(this.BaseData, base.PresentationXML, "", true, true, false);

            this.Subject = Convert.ToInt64(Request.QueryString["subject"]);

            this.SecurityGroups = new XmlDocument();
            this.SecurityGroups.LoadXml(base.PresentationXML.DocumentElement.LastChild.OuterXml);

            litBackLink.Text = "<b>Edit Menu</b>";

            Profiles.ORNG.Utilities.DataIO orngData = new Profiles.ORNG.Utilities.DataIO();

            foreach (XmlNode group in this.PropertyList.SelectNodes("//PropertyList/PropertyGroup"))
            {
                singlesi = new List <SecurityItem>();

                foreach (XmlNode node in group.SelectNodes("Property"))
                {
                    if (node.SelectSingleNode("@EditExisting").Value == "false" &&
                        node.SelectSingleNode("@EditAddExisting").Value == "false" &&
                        node.SelectSingleNode("@EditAddNew").Value == "false" &&
                        node.SelectSingleNode("@EditDelete").Value == "false")
                    {
                        canedit = false;
                    }
                    else
                    {
                        canedit = true;
                    }

                    // treat ORNG items as "special", because they may not be available and they may be turned off
                    if (node.SelectSingleNode("@URI").Value.StartsWith(Profiles.ORNG.Utilities.OpenSocialManager.ORNG_ONTOLOGY_PREFIX))
                    {
                        GadgetSpec spec = OpenSocialManager.GetGadgetByPropertyURI(node.SelectSingleNode("@URI").Value);
                        if (spec != null && spec.RequiresRegitration() && !orngData.IsRegistered(this.Subject, spec.GetAppId()))
                        {
                            singlesi.Add(new SecurityItem(node.ParentNode.SelectSingleNode("@Label").Value, node.SelectSingleNode("@Label").Value,
                                                          node.SelectSingleNode("@URI").Value,
                                                          Convert.ToInt32(node.SelectSingleNode("@NumberOfConnections").Value),
                                                          Convert.ToInt32(node.SelectSingleNode("@ViewSecurityGroup").Value),
                                                          "Unavailable",
                                                          node.SelectSingleNode("@ObjectType").Value, canedit));
                            continue;
                        }
                        else if (spec != null && "0".Equals(node.SelectSingleNode("@NumberOfConnections").Value))
                        {
                            singlesi.Add(new SecurityItem(node.ParentNode.SelectSingleNode("@Label").Value, node.SelectSingleNode("@Label").Value,
                                                          node.SelectSingleNode("@URI").Value,
                                                          Convert.ToInt32(node.SelectSingleNode("@NumberOfConnections").Value),
                                                          Convert.ToInt32(node.SelectSingleNode("@ViewSecurityGroup").Value),
                                                          "Hidden",
                                                          node.SelectSingleNode("@ObjectType").Value, canedit));
                            continue;
                        }
                    }

                    singlesi.Add(new SecurityItem(node.ParentNode.SelectSingleNode("@Label").Value, node.SelectSingleNode("@Label").Value,
                                                  node.SelectSingleNode("@URI").Value,
                                                  Convert.ToInt32(node.SelectSingleNode("@NumberOfConnections").Value),
                                                  Convert.ToInt32(node.SelectSingleNode("@ViewSecurityGroup").Value),
                                                  this.SecurityGroups.SelectSingleNode("SecurityGroupList/SecurityGroup[@ID='" + node.SelectSingleNode("@ViewSecurityGroup").Value + "']/@Label").Value,
                                                  node.SelectSingleNode("@ObjectType").Value, canedit));
                }
                si.Add(singlesi);
            }

            foreach (XmlNode securityitem in this.SecurityGroups.SelectNodes("SecurityGroupList/SecurityGroup"))
            {
                this.Dropdown.Add(new GenericListItem(securityitem.SelectSingleNode("@Label").Value,
                                                      securityitem.SelectSingleNode("@ID").Value));

                gli.Add(new GenericListItem(securityitem.SelectSingleNode("@Label").Value, securityitem.SelectSingleNode("@Description").Value));
            }
            gli.Add(new GenericListItem("Unavailable", "This feature depends on automatically collected data that we do not have for your Profile."));

            repPropertyGroups.DataSource = si;
            repPropertyGroups.DataBind();

            BuildSecurityKey(gli);

            // OpenSocial.  Allows gadget developers to show test gadgets if you have them installed
            string            uri = this.BaseData.SelectSingleNode("rdf:RDF/rdf:Description/@rdf:about", base.Namespaces).Value;
            OpenSocialManager om  = OpenSocialManager.GetOpenSocialManager(uri, Page, true);

            if (om.IsVisible())
            {
                litGadget.Visible = true;
                string sandboxDivs = "";
                foreach (PreparedGadget gadget in om.GetSandboxGadgets())
                {
                    sandboxDivs += "<div id='" + gadget.GetChromeId() + "' class='gadgets-gadget-parent'></div>";
                }
                litGadget.Text = sandboxDivs;
                om.LoadAssets();
            }
        }
 private void UpdateSecuritySetting(string securitygroup)
 {
     // maybe be able to make this more general purpose
     if (this.PredicateURI.StartsWith(Profiles.ORNG.Utilities.OpenSocialManager.ORNG_ONTOLOGY_PREFIX))
     {
         Profiles.ORNG.Utilities.DataIO data = new Profiles.ORNG.Utilities.DataIO();
         if ("0".Equals(securitygroup))
         {
             data.RemovePersonalGadget(this.Subject, this.PredicateURI);
         }
         else
         {
             data.AddPersonalGadget(this.Subject, this.PredicateURI);
         }
     }
     else if (!"0".Equals(securitygroup))
     {
         Edit.Utilities.DataIO data = new Profiles.Edit.Utilities.DataIO();
         data.UpdateSecuritySetting(this.Subject, data.GetStoreNode(this.PredicateURI), Convert.ToInt32(securitygroup));
     }
     //Framework.Utilities.Cache.AlterDependency(this.Subject.ToString());
 }
        private void DrawProfilesModule()
        {
            List<GenericListItem> gli = new List<GenericListItem>();
            bool canedit = false;
            Profile.Utilities.DataIO data = new Profiles.Profile.Utilities.DataIO();
            List<List<SecurityItem>> si = new List<List<SecurityItem>>();
            List<SecurityItem> singlesi;
            this.Dropdown = new List<GenericListItem>();
            this.PropertyList = data.GetPropertyList(this.BaseData, base.PresentationXML, "", true, true, false);

            this.Subject = Convert.ToInt64(Request.QueryString["subject"]);

            this.SecurityGroups = new XmlDocument();
            this.SecurityGroups.LoadXml(base.PresentationXML.DocumentElement.LastChild.OuterXml);

            litBackLink.Text = "<b>Edit Menu</b>";

            Profiles.ORNG.Utilities.DataIO orngData = new Profiles.ORNG.Utilities.DataIO();

            foreach (XmlNode group in this.PropertyList.SelectNodes("//PropertyList/PropertyGroup"))
            {
                singlesi = new List<SecurityItem>();

                foreach (XmlNode node in group.SelectNodes("Property"))
                {
                    if (node.SelectSingleNode("@EditExisting").Value == "false"
                        && node.SelectSingleNode("@EditAddExisting").Value == "false"
                        && node.SelectSingleNode("@EditAddNew").Value == "false"
                        && node.SelectSingleNode("@EditDelete").Value == "false")
                    {
                        canedit = false;
                    }
                    else
                    {
                        canedit = true;
                    }

                    string objecttype = string.Empty;
                    switch (node.SelectSingleNode("@ObjectType").Value)
                    {
                        case "1":
                            objecttype = "Literal";
                            break;
                        case "0":
                            objecttype = "Entity";
                            break;
                    }

                    string editlink = "<a class=listTableLink href=\"" + Root.Domain + "/edit/default.aspx?subject=" + this.Subject.ToString() + "&predicateuri=" + node.SelectSingleNode("@URI").Value.Replace("#", "!") + "&module=DisplayItemToEdit&ObjectType=" + objecttype + "\" >" + node.SelectSingleNode("@Label").Value + "</a>";

                    singlesi.Add(new SecurityItem(node.ParentNode.SelectSingleNode("@Label").Value, node.SelectSingleNode("@Label").Value,
                        node.SelectSingleNode("@URI").Value,
                        Convert.ToInt32(node.SelectSingleNode("@NumberOfConnections").Value),
                        Convert.ToInt32(node.SelectSingleNode("@ViewSecurityGroup").Value),
                        this.SecurityGroups.SelectSingleNode("SecurityGroupList/SecurityGroup[@ID='" + node.SelectSingleNode("@ViewSecurityGroup").Value + "']/@Label").Value,
                        node.SelectSingleNode("@ObjectType").Value, canedit, editlink));
                }
                si.Add(singlesi);
            }

            // add one for "Not Added"
            gli.Add(new GenericListItem("Not Added", "This item has not been added to your Profile page."));
            foreach (XmlNode securityitem in this.SecurityGroups.SelectNodes("SecurityGroupList/SecurityGroup"))
            {
                this.Dropdown.Add(new GenericListItem(securityitem.SelectSingleNode("@Label").Value,
                    securityitem.SelectSingleNode("@ID").Value));

                gli.Add(new GenericListItem(securityitem.SelectSingleNode("@Label").Value, securityitem.SelectSingleNode("@Description").Value));
            }

            repPropertyGroups.DataSource = si;
            repPropertyGroups.DataBind();

            BuildSecurityKey(gli);
        }