/// <summary> /// Given an poBox object , it will return the value for a PolicyID , and PolicyTag . /// Only one value is returned /// </summary> public int GetValueForPolicyID(POBox.POBox poBox, string PolicyID, string PolicyTag) { int PolicyValue = -1; ICSList list = poBox.Search(PropertyTags.PolicyID, PolicyID, SearchOp.Equal); foreach (ShallowNode sn in list) { Simias.Policy.Policy tempPolicy = new Simias.Policy.Policy(poBox, sn); if (tempPolicy.IsSystemPolicy) { MultiValuedList mvl = tempPolicy.Properties.GetProperties(PolicyTag); if (mvl.Count > 0) { foreach (Property p in mvl) { if (p != null) { PolicyValue = (int)p.Value; break; } } } } } return(PolicyValue); }
/// <summary> /// Given an poBox object , it will return the rule for a PolicyID /// only one rule is returned /// </summary> public void GetRuleForPolicyID(POBox.POBox poBox, string PolicyID, ref Member member) { string RuleList = "RuleList"; Simias.Policy.Rule rule = null; ICSList list = poBox.Search(PropertyTags.PolicyID, PolicyID, SearchOp.Equal); foreach (ShallowNode sn in list) { Simias.Policy.Policy tempPolicy = new Simias.Policy.Policy(poBox, sn); if (tempPolicy.IsSystemPolicy) { MultiValuedList mvl = tempPolicy.Properties.GetProperties(RuleList); if (mvl.Count > 0) { foreach (Property p in mvl) { if (p != null) { rule = new Simias.Policy.Rule(p.Value); Property prop = new Property(PolicyID, rule.ToString()); prop.ServerOnlyProperty = true; member.Properties.ModifyProperty(prop); break; } } } } } return; }
public void ModifyProperty(string collectionID, string nodeID, string propertyName, string propertyType, string oldPropertyValue, string newPropertyValue, uint propertyFlags) { Store store = Store.GetStore(); Collection c = store.GetCollectionByID(collectionID); if (c != null) { Node n = c.GetNodeByID(nodeID); if (n != null) { MultiValuedList mvl = n.Properties.GetProperties(propertyName); foreach (Property p in mvl) { if ((p.Type.ToString() == propertyType) && (p.ToString() == oldPropertyValue)) { if ((propertyFlags & 0x0002000) == 0x00020000) { p.LocalProperty = true; } if ((propertyFlags & 0x0004000) == 0x00040000) { p.MultiValuedProperty = true; } p.SetPropertyValue(new Property(p.Name, p.Type, newPropertyValue)); c.Commit(n); break; } } } } }
/// <summary> /// Sets all of the Types tags specified on the collection as SubscriptionTypes. /// </summary> /// <param name="collection">Collection to get types from.</param> public void SetSubscriptionTypes(Collection collection) { // Clear off all of the current types. properties.DeleteNodeProperties(SubscriptionTypes); // Set each node type as subscription types. MultiValuedList mvl = collection.Properties.FindValues(PropertyTags.Types); foreach (Property p in mvl) { properties.AddNodeProperty(SubscriptionTypes, p.ValueString); } }
public void DeleteProperty(string collectionID, string nodeID, string propertyName, string propertyType, string propertyValue) { Store store = Store.GetStore(); Collection c = store.GetCollectionByID(collectionID); if (c != null) { Node n = c.GetNodeByID(nodeID); if (n != null) { MultiValuedList mvl = n.Properties.GetProperties(propertyName); foreach (Property p in mvl) { if ((p.Type.ToString() == propertyType) && (p.ToString() == propertyValue)) { p.DeleteProperty(); c.Commit(n); break; } } } } }
/// <summary> /// Get an iFolder User Details Object /// </summary> /// <param name="member">The Member Object</param> /// <param name="collection">The Collection Object</param> /// <param name="domain">The Domain Object</param> /// <returns>An iFolderUser Object</returns> protected iFolderUserDetails(Member member, Collection collection, Domain domain) : base(member, collection, domain) { if (member.HomeServer != null) { this.DetailHomeServer = (member.HomeServer.Name == null) ? string.Empty : member.HomeServer.Name; } else { this.DetailHomeServer = string.Empty; } if (member.NewHomeServer != null) { HostNode newHomeNode = HostNode.GetHostByID(domain.ID, member.NewHomeServer); if (newHomeNode != null) { this.DetailNewHomeServer = (newHomeNode.Name == null) ? string.Empty : newHomeNode.Name; } else { this.DetailNewHomeServer = string.Empty; } } else { this.DetailNewHomeServer = string.Empty; } int state = member.UserMoveState; switch (state) { case (int)Member.userMoveStates.PreProcessingFailed: DetailDataMoveStatus = "NOTELIGIBLE"; DataMovePercentage = 0; break; case (int)Member.userMoveStates.Nousermove: case (int)Member.userMoveStates.Initialized: DetailDataMoveStatus = "Initializing"; DetailDataMovePercentage = 0; break; case (int)Member.userMoveStates.UserDisabled: DetailDataMoveStatus = "Initialized"; DetailDataMovePercentage = 5; break; case (int)Member.userMoveStates.DataMoveStarted: DetailDataMoveStatus = "Moving iFolders"; DetailDataMovePercentage = 10; break; case (int)Member.userMoveStates.Reprovision: DetailDataMoveStatus = "Resetting Home"; DetailDataMovePercentage = 10; break; case (int)Member.userMoveStates.MoveCompleted: DetailDataMoveStatus = "Finalizing"; DetailDataMovePercentage = 15; break; default: DetailDataMovePercentage = 0; DetailDataMoveStatus = "Initializing"; break; } if (state < (int)Member.userMoveStates.DataMoveStarted) { DetailDataMovePercentage += 0; } else if (state > (int)Member.userMoveStates.DataMoveStarted) { DetailDataMovePercentage += 80; } else { Store stored = Store.GetStore(); long SpaceUsed = 0; long DataTransferred = 1; int iFolderMoveState = 0; // From catalog, get the total size of the collections owned by this user. // Then, check which iFolders are present on local machine, those which are not present are moved, minus them long TotalSpaceUsed = Catalog.GetSpaceUsedByOwnerID(member.UserID); HostNode LocalHostNode = HostNode.GetLocalHost(); bool LocalHostIsNewHome = false; bool LocalHostIsOldHome = false; bool ValidLocalHost = (LocalHostNode != null && !String.IsNullOrEmpty(LocalHostNode.Name)); if (ValidLocalHost && !String.IsNullOrEmpty(this.HomeServer) && String.Equals(this.HomeServer, LocalHostNode.Name)) { LocalHostIsOldHome = true; } if (ValidLocalHost && !String.IsNullOrEmpty(this.DetailNewHomeServer) && String.Equals(this.DetailNewHomeServer, LocalHostNode.Name)) { LocalHostIsNewHome = true; } // If localhost is where user is moving, then start with 0 and add all collections in local store as moved ones // If localhost is older home, then start with total data size and subtract collections which are not in local store DataTransferred = LocalHostIsNewHome ? 0 : (LocalHostIsOldHome ? TotalSpaceUsed : 0); ICSList collectionList = stored.GetCollectionsByOwner(member.UserID, domain.ID); foreach (ShallowNode sn in collectionList) { Collection iFolderCol = new Collection(stored, sn); //SpaceUsed += iFolderCol.StorageSize; iFolderMoveState = member.iFolderMoveState(domain.ID, false, iFolderCol.ID, 0, 0); if (iFolderMoveState > 1) { // This is almost non-reachable code. because when iFolderMoveState becomes 2, it means collection is // moved and in that case, the collection will not be present in local store, so store.getco..Owner // will not return the collection's ID. should not we remove this true codepath???? //it comes momentarily here only once.. DataTransferred += iFolderCol.StorageSize; } else { DataTransferred = LocalHostIsNewHome ? (DataTransferred + iFolderCol.StorageSize /* local server is new home for the user*/) : (DataTransferred - iFolderCol.StorageSize /* user is getting moved away from local server*/); } } if (TotalSpaceUsed != 0) { log.Debug("iFolderUserDetails: After total calculation, now size of data that already moved is {0} and total space used by user/allcolls is {1}", DataTransferred, TotalSpaceUsed); DetailDataMovePercentage += (int)((80 * DataTransferred) / TotalSpaceUsed); log.Debug("iFolderUserDetails: DataMovePercentage after calculation is :" + DetailDataMovePercentage); } else { DetailDataMovePercentage += 80; } } if (member.NewHomeServer != null) { HostNode newHomeNode = HostNode.GetHostByID(domain.ID, member.NewHomeServer); if (newHomeNode != null) { this.DetailNewHomeServer = (newHomeNode.Name == null) ? string.Empty : newHomeNode.Name; } else { this.DetailNewHomeServer = string.Empty; } } else { this.DetailNewHomeServer = string.Empty; } // sync interval this.SyncIntervalEffective = Simias.Policy.SyncInterval.Get(collection).Interval; // last login Member domainMember = domain.GetMemberByID(this.ID); Property p = domainMember.Properties.GetSingleProperty(PropertyTags.LastLoginTime); if (p != null) { this.LastLogin = (DateTime)p.Value; } // Get the DN property for the member if it exists. Property property = domainMember.Properties.GetSingleProperty("DN"); this.LdapContext = (property != null) ? property.ToString() : String.Empty; // Get the GroupType property for the member if it exists. Property Groupproperty = domainMember.Properties.GetSingleProperty("GroupType"); if (null == Groupproperty) { this.MemberType = 0; Property GOMproperty = domainMember.Properties.GetSingleProperty("UserGroups"); this.GroupOrMemberList = (GOMproperty != null) ? GOMproperty.ToString() : String.Empty; } else { if (String.Compare(Groupproperty.ToString().ToLower(), "global") == 0) { this.MemberType = 1; } else { this.MemberType = 2; } { // This braces is for adding members into group object and vice-versa string FullMembersList = ""; MultiValuedList mvl = member.Properties.GetProperties("MembersList"); if (mvl != null && mvl.Count > 0) { foreach (Property prop in mvl) { if (prop != null) { FullMembersList += prop.Value as string; FullMembersList += "; "; } } } this.GroupOrMemberList = FullMembersList; this.GroupDiskQuota = member.AggregateDiskQuota; this.SpaceUsedByGroup = iFolderUser.SpaceUsedByGroup(member.UserID); } } // Get the number of iFolders owned and shared by the user. CatalogEntry[] catalogEntries; catalogEntries = Catalog.GetAllEntriesByUserID(this.ID); foreach (CatalogEntry ce in catalogEntries) { if (ce.OwnerID == this.ID) { ++OwnediFolderCount; } else { ++SharediFolderCount; } } }
/// <summary> /// Extracts all the member policies from POBox and stores them as part of member object on master . No aggregation is done. /// </summary> public void ExtractMemberPolicies(string domainID, Member member, ShallowNode sn, bool OnMaster) { Store store = Store.GetStore(); Domain domain = store.GetDomain(domainID); string RuleList = "RuleList"; Simias.Policy.Rule rule = null; int Value = -1; bool committed = false; Property FileTypeProperty; Property EncProperty; Property SyncIntervalProperty; ICSList list; POBox.POBox poBox = POBox.POBox.FindPOBox(store, domainID, member.UserID); if (poBox == null) { return; } // First extract rule based policies // Extracting FileType policy list = poBox.Search(PropertyTags.PolicyID, Simias.Policy.FileTypeFilter.FileTypeFilterPolicyID, SearchOp.Equal); Simias.Policy.Policy tempPolicy = null; foreach (ShallowNode snl in list) { tempPolicy = new Simias.Policy.Policy(poBox, snl); if (tempPolicy.IsSystemPolicy) { MultiValuedList mvl = tempPolicy.Properties.GetProperties(RuleList); if (mvl.Count > 0) { log.Debug("mvl count for filetype filter is" + mvl.Count); foreach (Property p in mvl) { if (p != null) { rule = new Simias.Policy.Rule(p.Value); FileTypeProperty = new Property(Simias.Policy.FileTypeFilter.FileTypeFilterPolicyID, rule.ToString()); FileTypeProperty.ServerOnlyProperty = true; member.Properties.AddNodeProperty(FileTypeProperty); } } } } } GetRuleForPolicyID(poBox, Simias.Policy.DiskSpaceQuota.DiskSpaceQuotaPolicyID, ref member); GetRuleForPolicyID(poBox, Simias.Policy.FileSizeFilter.FileSizeFilterPolicyID, ref member); Value = GetValueForPolicyID(poBox, Simias.Policy.SecurityState.EncryptionStatePolicyID, Simias.Policy.SecurityState.StatusTag); if (Value != -1) { EncProperty = new Property(Simias.Policy.SecurityState.EncryptionStatePolicyID, Value); EncProperty.ServerOnlyProperty = true; member.Properties.ModifyProperty(EncProperty); } Value = GetValueForPolicyID(poBox, Simias.Policy.SyncInterval.SyncIntervalPolicyID, Simias.Policy.SyncInterval.IntervalTag); if (Value != -1) { SyncIntervalProperty = new Property(Simias.Policy.SyncInterval.SyncIntervalPolicyID, Value); SyncIntervalProperty.ServerOnlyProperty = true; member.Properties.ModifyProperty(SyncIntervalProperty); } if (OnMaster) { // User is provisioned on master so no need to call web-service domain.Commit(member); poBox.Commit(poBox.Delete()); log.Debug("Committed member's property(policy) on master successfully so deleting his POBox.. " + member.FN); } else { committed = CommitOnMaster(domainID, member, sn); if (committed == true) { log.Debug("Committed member's property(policy) on master successfully so deleting his POBox.. " + member.FN); poBox.Commit(poBox.Delete()); } else { log.Debug("Could not commit member's property(policy) on master so not deleting his POBox.. Next time it can be tried"); } } }