コード例 #1
0
ファイル: aclentry.cs プロジェクト: mintwans/cpsc483
        //////////////////////////////////////////////////////////////////////
        /// <summary>parses the inner state of the element</summary>
        /// <param name="e">the extensionelement during the parsing process, xml node</param>
        /// <param name="parser">the atomFeedParser that called this</param>
        //////////////////////////////////////////////////////////////////////
        public override void Parse(ExtensionElementEventArgs e, AtomFeedParser parser)
        {
            Tracing.TraceCall("AclEntry:Parse is called:" + e);
            XmlNode node = e.ExtensionElement;
 
            if (String.Compare(node.NamespaceURI, AclNameTable.gAclNamespace, true) == 0)
            {
                // Parse a Role Element
                if (node.LocalName == AclNameTable.XmlAclRoleElement)
                {
                    this.Role = AclRole.parse(node);
                    e.DiscardEntry = true;
                }
                // Parse a Where Element
                else if (node.LocalName == AclNameTable.XmlAclScopeElement)
                {
                    this.Scope = AclScope.parse(node);
                    e.DiscardEntry = true;
                }
            }
        }
コード例 #2
0
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Tests the ACL extensions</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void CalendarACLTest()
        {
            Tracing.TraceMsg("Entering CalendarACLTest");

            AclQuery query = new AclQuery();
            CalendarService service = new CalendarService(this.ApplicationName);

            int iCount; 

            if (this.defaultCalendarUri != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                service.RequestFactory = this.factory; 

                query.Uri = new Uri(this.aclFeedUri);
                AclFeed aclFeed = service.Query(query);
                AclEntry newEntry = null;

                foreach (AclEntry e in aclFeed.Entries ) 
                {
                    if (e.Scope.Value.StartsWith(this.userName) == false)
                    {
                        e.Delete();
                    }
                }
                aclFeed = service.Query(query);

                iCount = aclFeed.Entries.Count;

                if (aclFeed != null)
                {
                    // create an entry
                    AclEntry entry = new AclEntry();
                    entry.Role = AclRole.ACL_CALENDAR_FREEBUSY;
                    AclScope scope = new AclScope();
                    scope.Type = AclScope.SCOPE_USER;
                    scope.Value = "*****@*****.**";
                    entry.Scope = scope;

                    newEntry = (AclEntry) aclFeed.Insert(entry);

                    Assert.AreEqual(newEntry.Role.Value, entry.Role.Value);
                    Assert.AreEqual(newEntry.Scope.Type, entry.Scope.Type);
                    Assert.AreEqual(newEntry.Scope.Value, entry.Scope.Value);
                }

                Tracing.TraceMsg("CalendarACLTest: done insering Acl:entry");


                iCount++;
                aclFeed = (AclFeed) service.Query(query);

                Tracing.TraceMsg("CalendarACLTest: done query after: Acl:entry");

                // update that entry

                if (newEntry != null)
                {
                    newEntry.Role = AclRole.ACL_CALENDAR_READ;
                    newEntry = (AclEntry) newEntry.Update();
                    Assert.AreEqual(AclRole.ACL_CALENDAR_READ.Value, newEntry.Role.Value);
                }

                Tracing.TraceMsg("CalendarACLTest: done updating Acl:entry");

                newEntry.Delete();
                iCount--;

                Tracing.TraceMsg("CalendarACLTest: done deleting Acl:entry");


                aclFeed = (AclFeed) service.Query(query);
                Assert.AreEqual(iCount, aclFeed.Entries.Count, "Feed should have one more entry, it has: " + aclFeed.Entries.Count); 


                service.Credentials = null; 
            }
        }
コード例 #3
0
ファイル: aclscope.cs プロジェクト: mintwans/cpsc483
        // end of accessor public string Type

        /// <summary>
        ///  parse method is called from the atom parser to populate an Transparency node
        /// </summary>
        /// <param name="node">the xmlnode to parser</param>
        /// <returns>Notifications object</returns>
        public static AclScope parse(XmlNode node)
        {
            AclScope scope = null;
            Tracing.TraceMsg("Parsing a gAcl:AclScope" + node);
            if (String.Compare(node.NamespaceURI, AclNameTable.gAclNamespace, true) == 0
                && String.Compare(node.LocalName, AclNameTable.XmlAclScopeElement) == 0)
            {
                scope = new AclScope();
                if (node.Attributes != null)
                {
                    if (node.Attributes[AclNameTable.XmlValue] != null)
                    {
                        scope.Value = node.Attributes[AclNameTable.XmlValue].Value;
                    }
                    if (node.Attributes[AclNameTable.XmlAttributeType] != null)
                    {
                        scope.Type = node.Attributes[AclNameTable.XmlAttributeType].Value;
                    }
                    Tracing.TraceMsg("AclScope parsed, value = " + scope.Value + ", type= " + scope.Type);
                }
            }
            return scope;
        }