Exemple #1
0
 //TODO: need to organize this so that we don't have a lot of empty string for optionals, maybe using a container object instead
 public CascadeAttribute(string customTransformRule, string parent, string parentSection, string sourceProperty, string targetProperty, CascadeType type)
 {
     CustomTransformRule = customTransformRule;
     Parent         = parent;
     ParentSection  = parentSection;
     SourceProperty = sourceProperty;
     TargetProperty = targetProperty;
     Type           = type;
 }
Exemple #2
0
 private void PageSecurityChanged(DateTime eventTime, PageBE page, CascadeType cascade, params string[] path)
 {
     try {
         XUri     channel  = _channel.At(PAGES).At(path);
         XUri     resource = PageBL.GetUriCanonical(page).WithHost(_wikiid);
         string[] origin   = new string[] { PageBL.GetUriCanonical(page).AsServerUri().ToString(), XUri.Localhost + "/" + page.Title.AsUiUriPath() };
         Queue(eventTime, channel, resource, origin, new XDoc("deki-event")
               .Elem("channel", channel)
               .Elem("uri", PageBL.GetUriCanonical(page).AsServerUri().ToString())
               .Elem("pageid", page.ID)
               .Start("security")
               .Attr("cascade", cascade.ToString().ToLower())
               .End());
     } catch (Exception e) {
         _log.WarnExceptionMethodCall(e, "PageSecurityChanged", "event couldn't be created");
     }
 }
Exemple #3
0
        private string GetCascadeText(CascadeType type, bool isDeleteBehavior = false)
        {
            switch (type)
            {
            case CascadeType.Active:
                return("Active");

            case CascadeType.NoCascade:
                return("None");

            case CascadeType.UserOwned:
                return("Owner");

            case CascadeType.RemoveLink:
                return("Remove link");

            case CascadeType.Restrict:
                return("Restrict");

            default:
                return(isDeleteBehavior ? "All" : "Cascade");
            }
        }
Exemple #4
0
        /// <summary>
        /// This applies permissions in a set/replace approach synonymous with PUT
        /// </summary>
        /// <param name="targetPage">Page to apply permissions to</param>
        /// <param name="restriction">Optional restriction mask to apply to page (and optionally to child pages)</param>
        /// <param name="proposedGrants">List of grants to apply to page and child pages</param>
        /// <param name="cascade">
        /// NONE: Dont apply permissions. 
        /// ABSOLUTE: proposedGrants are applied to root page and child pages. All grants not in the proposedGrants list are removed.
        /// DELTAS: proposedGrants is applied exactly to the root page. Child pages get the differences between the proposedGrants and the grants of the root page thus preserving the grants they had.
        /// </param>
        public static void ReplacePagePermissions(PageBE targetPage, RoleBE restriction, IList<GrantBE> proposedGrants, CascadeType cascade) {
            //Perform validation of grants.

            // Make sure users and groups described in grants exist.
            // this populates user/group object within the grant.
            VerifyValidUsersAndGroups(proposedGrants);

            // Ensure a duplicate grant isn't given for the same role multiple times to a user/grant
            HashGrantsByTypeGranteeIdRoleId(proposedGrants);

            IList<GrantBE> currentGrants, proposedAddedGrants, proposedRemovedGrants;
            ulong userEffectiveRights = (ulong)GetUserPermissions(DekiContext.Current.User);

            switch(cascade) {
            case CascadeType.NONE:

                //No cascading to children. delta(current security of page, proposed security) is applied
                currentGrants = DbUtils.CurrentSession.Grants_GetByPage((uint)targetPage.ID);
                CompareGrantSets(currentGrants, proposedGrants, out proposedAddedGrants, out proposedRemovedGrants);
                ApplyPermissionChange(targetPage, false, userEffectiveRights, null, proposedAddedGrants, proposedRemovedGrants, currentGrants, restriction, true);
                break;
            case CascadeType.ABSOLUTE:

                //Cascade proposed security set to children.
                ApplyPermissionChange(targetPage, true, userEffectiveRights, proposedGrants, null, null, null, restriction, true);
                break;
            case CascadeType.DELTA:

                //Cascade delta(current security of page, proposed security) to page and children
                currentGrants = DbUtils.CurrentSession.Grants_GetByPage((uint)targetPage.ID);
                CompareGrantSets(currentGrants, proposedGrants, out proposedAddedGrants, out proposedRemovedGrants);
                // Note (arnec): even if proposed add & remove are empty, we have to call this method, since restriction may need to be set and propagated.
                ApplyPermissionChange(targetPage, true, userEffectiveRights, null, proposedAddedGrants, proposedRemovedGrants, currentGrants, restriction, true);
                break;
            }
        }
 /// <summary>
 /// 关联特性构造函数
 /// </summary>
 /// <param name="curFieldName">当前类字段</param>
 /// <param name="objField">关联类关联字段</param>
 /// <param name="associationType">关联对象类别</param>
 /// <param name="cascadeType">关联对象级联操作方式</param>
 public AssociationAttribute(string curFieldName, string objField, AssociationType associationType, CascadeType cascadeType)
 {
     this.CurField = curFieldName;
     this.ObjField = objField;
     this.AssType  = associationType;
     this.CasType  = cascadeType;
 }
Exemple #6
0
 public InverseAttribute(CascadeType cascadeType = CascadeType.AllDeleteOrphan)
 {
     Type = cascadeType;
 }
Exemple #7
0
 public Reference(Type referenceType, RelationType relationType, CascadeType cascadeType = CascadeType.CascadeNone)
 {
     ReferenceType = referenceType;
     RelationType  = relationType;
     CascadeType   = cascadeType;
 }
Exemple #8
0
 public void PageSecurityUpdated(DateTime eventTime, PageBE page, CascadeType cascade)
 {
     PageSecurityChanged(eventTime, page, cascade, SECURITY, UPDATE);
 }
 private void PageSecurityChanged(DateTime eventTime, PageBE page, CascadeType cascade, params string[] path) {
     try {
         XUri channel = _channel.At(PAGES).At(path);
         XUri resource = PageBL.GetUriCanonical(page).WithHost(_wikiid);
         string[] origin = new string[] { PageBL.GetUriCanonical(page).AsServerUri().ToString(), XUri.Localhost + "/" + page.Title.AsUiUriPath() };
         Queue(eventTime, channel, resource, origin, new XDoc("deki-event")
             .Elem("channel", channel)
             .Elem("uri", PageBL.GetUriCanonical(page).AsServerUri().ToString())
             .Elem("pageid", page.ID)
             .Start("security")
                 .Attr("cascade", cascade.ToString().ToLower())
             .End());
     } catch(Exception e) {
         _log.WarnExceptionMethodCall(e, "PageSecurityChanged", "event couldn't be created");
     }
 }
 public void PageSecurityUpdated(DateTime eventTime, PageBE page, CascadeType cascade) {
     PageSecurityChanged(eventTime, page, cascade, SECURITY, UPDATE);
 }