コード例 #1
0
        public virtual void SetiFolderPolicy(iFolderPolicy policy)
        {
            try
            {
                string accessID = GetAccessID();

                iFolderPolicy.SetPolicy(policy, accessID);
            }
            catch (Exception e)
            {
                SmartException.Throw(e);
            }
        }
コード例 #2
0
        /// <summary>
        /// Get the iFolder Policy
        /// </summary>
        /// <param name="ifolderID">The iFolder ID</param>
        /// <param name="accessID">The Access User ID</param>
        /// <param name="adminID">The logged in Admin ID</param>
        /// <returns>An iFolderPolicy Object</returns>
        public static iFolderPolicy GetPolicy(string ifolderID, string accessID, string adminID)
        {
            iFolderPolicy props = new iFolderPolicy();

            props.iFolderID = ifolderID;

            Store store = Store.GetStore();

            Collection c = store.GetCollectionByID(ifolderID);

            if (c == null)
            {
                throw new iFolderDoesNotExistException(ifolderID);
            }

            // impersonate
            iFolder.Impersonate(c, accessID);

            // disk space
            DiskSpaceQuota dsq = DiskSpaceQuota.Get(c);

            props.SpaceLimitEffective = dsq.Limit;
            props.SpaceAvailable      = dsq.AvailableSpace;
            props.SpaceUsed           = c.StorageSize;
            props.SpaceLimit          = DiskSpaceQuota.GetLimit(c);

            // no syncing (locked)
            //props.Locked = IsLocked(c);
            props.Locked = c.Disabled;

            // sync interval
            props.SyncInterval          = Simias.Policy.SyncInterval.GetInterval(c);
            props.SyncIntervalEffective = Simias.Policy.SyncInterval.Get(c).Interval;

            // to return the value of disable sharing policy for an iFolder
            props.SharingStatus = Simias.Policy.Sharing.GetStatus(c);

            // file types
            SystemPolicy.SplitFileTypes(FileTypeFilter.GetPatterns(c),
                                        out props.FileTypesIncludes, out props.FileTypesExcludes);

            SystemPolicy.SplitFileTypes(FileTypeFilter.Get(c, false).FilterList,
                                        out props.FileTypesIncludesEffective, out props.FileTypesExcludesEffective);

            // file size
            props.FileSizeLimit          = Simias.Policy.FileSizeFilter.GetLimit(c);
            props.FileSizeLimitEffective = Simias.Policy.FileSizeFilter.Get(c).Limit;
            props.AdminGroupRights       = iFolderUser.GetAdminRights(adminID, c.Owner.UserID);
            return(props);
        }
コード例 #3
0
        public virtual iFolderPolicy GetiFolderPolicy(string ifolderID)
        {
            iFolderPolicy result = null;

            try
            {
                string accessID = GetAccessID();
                result = iFolderPolicy.GetPolicy(ifolderID, accessID);
            }
            catch (Exception e)
            {
                SmartException.Throw(e);
            }

            return(result);
        }
コード例 #4
0
        public virtual bool GetSharingPolicy(string iFolderID)
        {
            //return base.GetDisableSharingPolicy ( iFolderID );
            iFolder       ifolder              = base.GetiFolder(iFolderID);
            UserPolicy    userPolicy           = UserPolicy.GetPolicy(ifolder.OwnerID);
            SystemPolicy  systemPolicy         = SystemPolicy.GetPolicy();
            iFolderPolicy ifolderPolicy        = iFolderPolicy.GetPolicy(iFolderID, GetAccessID());
            int           iFolderSharingStatus = ifolderPolicy.SharingStatus;
            int           UserSharingStatus    = userPolicy.SharingStatus;
            int           GroupSharingStatus   = UserPolicy.GetUserGroupSharingPolicy(ifolder.OwnerID);
            int           SystemSharingStatus  = systemPolicy.SharingStatus;

            if (((SystemSharingStatus & (int)Share.EnforcedSharing) == (int)Share.EnforcedSharing))
            {
                /// If on system level or user level, enforcement of policy is there, it means the iFolder must not be shared
                if ((SystemSharingStatus & (int)Share.Sharing) == (int)Share.Sharing)
                {
                    return(true);
                }
                return(false);
            }
            else if (((GroupSharingStatus & (int)Share.EnforcedSharing) == (int)Share.EnforcedSharing))
            {
                if ((GroupSharingStatus & (int)Share.Sharing) == (int)Share.Sharing)
                {
                    return(true);
                }
                return(false);
            }
            else if (((UserSharingStatus & (int)Share.EnforcedSharing) == (int)Share.EnforcedSharing))
            {
                if ((UserSharingStatus & (int)Share.Sharing) == (int)Share.Sharing)
                {
                    return(true);
                }
                return(false);
            }
            else
            {
                if (iFolderSharingStatus != 0)
                {
                    if ((iFolderSharingStatus & (int)Share.Sharing) == (int)Share.Sharing || iFolderSharingStatus == 0)
                    {
                        /// it means, on iFolder Details page, admin had unchecked the box so sharing is enabled now
                        return(true);
                    }
                    if ((iFolderSharingStatus & (int)Share.DisableSharing) == (int)Share.DisableSharing)
                    {
                        /// it means, on iFolder Details page, admin had checked the box so sharing is disabled
                        return(false);
                    }
                }
                else
                {
                    /// no iFolder level policy present , now if current user is not an owner , then check for system level policy
                    /// if current user is owner of the iFolder, then check for user level and then for system level

                    if ((UserSharingStatus & (int)Share.Sharing) == (int)Share.Sharing)
                    {
                        /// it means, on User Details page, admin had unchecked the box so sharing is enabled now
                        return(true);
                    }
                    if ((UserSharingStatus & (int)Share.DisableSharing) == (int)Share.DisableSharing)
                    {
                        /// it means, on User Details page, admin had checked the box so sharing is disabled
                        return(false);
                    }

                    /// check for Group level policy as there was no user level or ifolder level policy applied
                    /// No policy found on iFolder level or User level, no enforcement also, so follow group level
                    if ((GroupSharingStatus & (int)Share.DisableSharing) == (int)Share.DisableSharing)
                    {
                        return(false);
                    }
                    if ((GroupSharingStatus & (int)Share.Sharing) == (int)Share.Sharing)
                    {
                        return(true);
                    }

                    /// check for system level policy as there was no user level or ifolder level policy applied
                    /// No policy found on iFolder level or User level, no enforcement also, so follow system level
                    if ((SystemSharingStatus & (int)Share.DisableSharing) == (int)Share.DisableSharing)
                    {
                        return(false);
                    }
                    if ((SystemSharingStatus & (int)Share.Sharing) == (int)Share.Sharing || SystemSharingStatus == 0)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #5
0
        /// <summary>
        /// Set the iFolder Policy
        /// </summary>
        /// <param name="props">The iFolderPolicy Object</param>
        /// <param name="accessID">The Access User ID</param>
        public static void SetPolicy(iFolderPolicy props, string accessID)
        {
            Store store = Store.GetStore();

            Collection c = store.GetCollectionByID(props.iFolderID);

            if (c == null)
            {
                throw new iFolderDoesNotExistException(props.iFolderID);
            }

            // impersonate
            iFolder.Impersonate(c, accessID);

            // NOTE: always unlock the collection so other policy properties
            // can be modified
            if (c.IsLockedByName(lockName))
            {
                c.Unlock(lockName);
            }

            // disk space
            if (props.SpaceLimit >= -1)
            {
                DiskSpaceQuota.Set(c, props.SpaceLimit);
            }

            // sync interval
            if (props.SyncInterval >= 0)
            {
                Simias.Policy.SyncInterval.Set(c, props.SyncInterval);
            }

            // to set the value for disable sharing policy for this iFolder
            if (props.SharingStatus >= 0)
            {
                Simias.Policy.Sharing.Set(c, props.SharingStatus);
            }

            // file types
            if ((props.FileTypesExcludes != null) || (props.FileTypesIncludes != null))
            {
                FileTypeFilter.Set(c, SystemPolicy.CombineFileTypes(
                                       props.FileTypesIncludes, props.FileTypesExcludes));
            }

            // file size
            if (props.FileSizeLimit >= 0)
            {
                Simias.Policy.FileSizeFilter.Set(c, props.FileSizeLimit);
            }

            // no syncing (locked)
            // NOTE: re-lock the collection (see the beginning of the method)
            // if a lock was requested
            //if (props.Locked)
            {
                //	c.Lock(lockName);
                c.Disabled = props.Locked;
                c.Commit();
            }
        }
コード例 #6
0
 public override void SetiFolderPolicy(iFolderPolicy policy)
 {
     base.SetiFolderPolicy(policy);
 }