private bool Validate(StoreDriverDeliveryEventArgsImpl argsImpl) { WorkingSetAgent.tracer.TraceDebug((long)this.traceId, "WorkingSetAgent.Validate: entering"); if (!this.IsMessageInteresting(argsImpl)) { WorkingSetAgent.tracer.TraceDebug((long)this.traceId, "WorkingSetAgent.Validate: not a signal mail; exiting"); return(false); } if (argsImpl.MailboxSession == null) { WorkingSetAgent.tracer.TraceError((long)this.traceId, "WorkingSetAgent.Validate: MailboxSession is null; exiting"); return(false); } if (!WorkingSetUtils.IsWorkingSetAgentFeatureEnabled(argsImpl.MailboxOwner)) { WorkingSetAgent.tracer.TraceDebug((long)this.traceId, "WorkingSetAgent.Validate: received Signal mail while agent is disabled, throw Smtp response exception"); WorkingSet.ProcessingRejected.Increment(); argsImpl.MailRecipient.DsnRequested = DsnRequestedFlags.Never; throw new SmtpResponseException(WorkingSetAgent.UnprocessedSignalMailResponse, base.Name); } if (argsImpl.ReplayItem == null) { WorkingSetAgent.tracer.TraceDebug((long)this.traceId, "WorkingSetAgent.Validate: replay item is null; exiting"); return(false); } if (!this.IsAuthenticationSourceInternal(argsImpl.ReplayItem)) { WorkingSetAgent.tracer.TraceDebug((long)this.traceId, "WorkingSetAgent.Validate: signal mail is not from internal source; exiting"); return(false); } return(true); }
internal static StoreObjectId FindWorkingSetPartitionFolder(MailboxSession mailboxSession, string partitionName) { StoreObjectId result; using (Folder folder = WorkingSetUtils.SafeBindToWorkingSetFolder(mailboxSession)) { using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.None, null, null, new PropertyDefinition[] { FolderSchema.Id })) { queryResult.SeekToCondition(SeekReference.OriginBeginning, new ComparisonFilter(ComparisonOperator.Equal, FolderSchema.WorkingSetSourcePartitionInternal, partitionName)); object[][] rows = queryResult.GetRows(1); result = ((rows.Length > 0) ? ((VersionedId)rows[0][0]).ObjectId : null); } } return(result); }
public static void DeleteWorkingSetPartition(MailboxSession mailboxSession, string workingSetSourcePartitionInternal) { StoreObjectId storeObjectId = WorkingSetUtils.FindWorkingSetPartitionFolder(mailboxSession, workingSetSourcePartitionInternal); if (storeObjectId != null) { using (Folder folder = WorkingSetUtils.SafeBindToWorkingSetFolder(mailboxSession)) { AggregateOperationResult aggregateOperationResult = folder.DeleteObjects(DeleteItemFlags.HardDelete, new StoreId[] { storeObjectId }); if (aggregateOperationResult.OperationResult != OperationResult.Succeeded) { throw new ObjectNotFoundException(new LocalizedString(string.Format("Delete partition failed, partition {0} is not found", workingSetSourcePartitionInternal))); } WorkingSet.PartitionsDeleted.Increment(); return; } } throw new ObjectNotFoundException(new LocalizedString(string.Format("Delete partition failed, partition {0} is not found", workingSetSourcePartitionInternal))); }
internal static StoreObjectId GetWorkingSetPartitionFolderId(MailboxSession mailboxSession, string workingSetSourcePartition, string workingSetSourcePartitionInternal) { StoreObjectId result; using (Folder folder = WorkingSetUtils.SafeBindToWorkingSetFolder(mailboxSession)) { StoreObjectId storeObjectId = WorkingSetUtils.FindWorkingSetPartitionFolder(mailboxSession, workingSetSourcePartitionInternal); if (storeObjectId == null) { using (Folder folder2 = Folder.Create(mailboxSession, folder.StoreObjectId, StoreObjectType.Folder, workingSetSourcePartition, CreateMode.CreateNew)) { folder2[FolderSchema.WorkingSetSourcePartitionInternal] = workingSetSourcePartitionInternal; folder2.Save(); folder2.Load(); storeObjectId = folder2.StoreObjectId; WorkingSet.PartitionsCreated.Increment(); } } result = storeObjectId; } return(result); }