public static bool ShouldLog(COWTriggerAction operation)
        {
            switch (operation)
            {
            case COWTriggerAction.Create:
            case COWTriggerAction.Update:
                return(true);

            case COWTriggerAction.ItemBind:
            case COWTriggerAction.Submit:
            case COWTriggerAction.FolderBind:
                return(false);

            case COWTriggerAction.Copy:
                return(false);

            case COWTriggerAction.Move:
            case COWTriggerAction.MoveToDeletedItems:
            case COWTriggerAction.SoftDelete:
            case COWTriggerAction.HardDelete:
            case COWTriggerAction.DoneWithMessageDelete:
                return(true);

            default:
                throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "The specified item change operation ('{0}') is not supported by Calendar Logging.", new object[]
                {
                    operation
                }));
            }
        }
Exemplo n.º 2
0
 public bool ShouldLogGroupOperation(COWTriggerAction operation, StoreSession sourceSession, StoreObjectId sourceFolderId, StoreSession destinationSession, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds)
 {
     if (sourceSession != null && sourceFolderId != null && (this.IsDefaultFolder(sourceSession, sourceFolderId, DefaultFolderType.Conflicts) || this.IsDefaultFolder(sourceSession, sourceFolderId, DefaultFolderType.SyncIssues)))
     {
         ContactTracker.Tracer.TraceDebug((long)this.GetHashCode(), "ContactTracker.ShouldLogGroupOperation: SourceFolder is a Conflicts/SyncIssues folder.");
         return(false);
     }
     if (destinationSession != null && destinationFolderId != null && (this.IsDefaultFolder(destinationSession, destinationFolderId, DefaultFolderType.Conflicts) || this.IsDefaultFolder(destinationSession, destinationFolderId, DefaultFolderType.SyncIssues)))
     {
         ContactTracker.Tracer.TraceDebug((long)this.GetHashCode(), "ContactTracker.ShouldLogGroupOperation: DestinationFolder is a Conflicts/SyncIssues folder.");
         return(false);
     }
     ContactTracker.Tracer.TraceDebug <COWTriggerAction>((long)this.GetHashCode(), "ContactTracker.ShouldLogGroupOperation: Invoked for operation: {0}", operation);
     switch (operation)
     {
     case COWTriggerAction.Create:
     case COWTriggerAction.Update:
     case COWTriggerAction.Copy:
     case COWTriggerAction.Move:
     case COWTriggerAction.MoveToDeletedItems:
     case COWTriggerAction.SoftDelete:
     case COWTriggerAction.HardDelete:
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
0
 public bool ShouldLoadPropertiesForFurtherCheck(COWTriggerAction operation, string itemClass, StoreObjectId itemId, CoreItem item)
 {
     if (ObjectClass.IsContact(itemClass))
     {
         return(true);
     }
     ContactTracker.Tracer.TraceDebug <string, StoreObjectId>((long)this.GetHashCode(), "ContactTracker.ShouldLoadPropertiesForFurtherCheck: Skipping Item with Class - {0}, Id - {1}", itemClass, itemId);
     return(false);
 }
        internal static void AddMetadata(ICoreItem item, COWTriggerAction action, FolderChangeOperationFlags?folderChangeOperationFlags)
        {
            Dictionary <PropertyDefinition, object> metadata = CalendarLoggingHelper.GetMetadata(item, action, folderChangeOperationFlags);

            foreach (PropertyDefinition propertyDefinition in metadata.Keys)
            {
                item.PropertyBag[propertyDefinition] = metadata[propertyDefinition];
            }
        }
Exemplo n.º 5
0
 public bool ShouldLoadPropertiesForFurtherCheck(COWTriggerAction operation, string itemClass, StoreObjectId itemId, CoreItem item)
 {
     if (!ObjectClass.IsContact(itemClass))
     {
         return(false);
     }
     switch (operation)
     {
     case COWTriggerAction.Create:
     case COWTriggerAction.Update:
     case COWTriggerAction.Copy:
         return(Array.Exists <StorePropertyDefinition>(ContactEmailChangeLogger.TriggerProperties, (StorePropertyDefinition property) => item.PropertyBag.IsPropertyDirty(property)));
     }
     return(false);
 }
Exemplo n.º 6
0
 private void SaveItem(ICoreItem item, StoreSession session, COWTriggerAction operation)
 {
     item.SetEnableFullValidation(false);
     try
     {
         ConflictResolutionResult conflictResolutionResult = item.Save(SaveMode.FailOnAnyConflict);
         if (conflictResolutionResult.SaveStatus == SaveResult.IrresolvableConflict)
         {
             ExTraceGlobals.CalendarLoggingTracer.TraceWarning <int, ICoreItem, COWTriggerAction>((long)session.GetHashCode(), "Save Item for Calendar Logging failure ({0} conflicts, item {1}, operation {2}).", (conflictResolutionResult.PropertyConflicts == null) ? 0 : conflictResolutionResult.PropertyConflicts.Length, item, operation);
         }
     }
     catch (QuotaExceededException arg)
     {
         ExTraceGlobals.CalendarLoggingTracer.TraceWarning <QuotaExceededException, ICoreItem, COWTriggerAction>((long)session.GetHashCode(), "Save Item for Calendar Logging failure due to exceeded quota (exception {0}, item {1}, operation {2}).", arg, item, operation);
     }
 }
Exemplo n.º 7
0
 public bool ShouldLogGroupOperation(COWTriggerAction operation, StoreSession sourceSession, StoreObjectId sourceFolderId, StoreSession destinationSession, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds)
 {
     UcsTracker.Tracer.TraceDebug <COWTriggerAction>((long)this.GetHashCode(), "UcsTracker.ShouldLogGroupOperation: Invoked for operation: {0}", operation);
     switch (operation)
     {
     case COWTriggerAction.Create:
     case COWTriggerAction.Update:
     case COWTriggerAction.Copy:
     case COWTriggerAction.Move:
     case COWTriggerAction.MoveToDeletedItems:
     case COWTriggerAction.SoftDelete:
     case COWTriggerAction.HardDelete:
         return(true);
     }
     return(false);
 }
Exemplo n.º 8
0
 public bool ShouldLoadPropertiesForFurtherCheck(COWTriggerAction operation, string itemClass, StoreObjectId itemId, CoreItem item)
 {
     StorePropertyDefinition[] array;
     if (ObjectClass.IsContact(itemClass))
     {
         array = UcsTracker.ContactProperties;
     }
     else if (ObjectClass.IsDistributionList(itemClass))
     {
         array = UcsTracker.PdlProperties;
     }
     else
     {
         if (!ObjectClass.IsContactsFolder(itemClass))
         {
             UcsTracker.Tracer.TraceDebug <string, StoreObjectId>((long)this.GetHashCode(), "UcsTracker.ShouldLogContact: Skipping Item with Class - {0}, Id - {1}", itemClass, itemId);
             return(false);
         }
         array = UcsTracker.FolderProperties;
     }
     switch (operation)
     {
     case COWTriggerAction.Create:
     case COWTriggerAction.Update:
     case COWTriggerAction.Copy:
     case COWTriggerAction.Move:
     case COWTriggerAction.MoveToDeletedItems:
     case COWTriggerAction.SoftDelete:
     case COWTriggerAction.HardDelete:
     {
         bool flag = Array.Exists <StorePropertyDefinition>(array, (StorePropertyDefinition property) => item.PropertyBag.IsPropertyDirty(property));
         UcsTracker.Tracer.TraceDebug((long)this.GetHashCode(), "UcsTracker.ShouldLogContact: Operation {0} for item with Class - {1}, Id - {2} - will be logged: {3}", new object[]
             {
                 operation,
                 itemClass,
                 itemId,
                 flag
             });
         return(flag);
     }
     }
     UcsTracker.Tracer.TraceDebug <COWTriggerAction, string, StoreObjectId>((long)this.GetHashCode(), "UcsTracker.ShouldLogContact: Skipping Operation {0} for item with Class - {1}, Id - {2}", operation, itemClass, itemId);
     return(false);
 }
Exemplo n.º 9
0
 public bool ShouldLogGroupOperation(COWTriggerAction operation, StoreSession sourceSession, StoreObjectId sourceFolderId, StoreSession destinationSession, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds)
 {
     return(false);
 }
Exemplo n.º 10
0
        public bool SkipItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, bool onBeforeNotification, bool onDumpster, bool success, CallbackContext callbackContext)
        {
            Util.ThrowOnNullArgument(settings, "settings");
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            if (onDumpster)
            {
                return(true);
            }
            if (COWSettings.IsImapPoisonMessage(onBeforeNotification, operation, session, item))
            {
                return(true);
            }
            switch (operation)
            {
            case COWTriggerAction.Create:
            case COWTriggerAction.ItemBind:
            case COWTriggerAction.Submit:
                break;

            case COWTriggerAction.Update:
                return(!settings.LegalHoldEnabled());

            default:
                if (operation != COWTriggerAction.FolderBind)
                {
                    return(true);
                }
                break;
            }
            return(true);
        }
Exemplo n.º 11
0
        public void ItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, CoreFolder folder, bool onBeforeNotification, OperationResult result, CallbackContext callbackContext)
        {
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            EnumValidator.ThrowIfInvalid <OperationResult>(result, "result");
            Util.ThrowOnNullArgument(item, "item");
            MailboxSession mailboxSession = session as MailboxSession;
            ExDateTime     now            = ExDateTime.Now;

            try
            {
                item.PropertyBag.Load(COWSiteMailboxMessageDedup.PropsForMessageRemoval);
                if (item.Id != null && item.Id.ObjectId != null)
                {
                    StoreObjectId storeObjectId = item.PropertyBag.TryGetProperty(StoreObjectSchema.ParentItemId) as StoreObjectId;
                    if (storeObjectId != null)
                    {
                        using (CoreFolder coreFolder = CoreFolder.Bind(session, storeObjectId))
                        {
                            DeleteItemFlags deleteItemFlags = DeleteItemFlags.HardDelete | DeleteItemFlags.SuppressReadReceipt;
                            coreFolder.DeleteItems(deleteItemFlags, new StoreObjectId[]
                            {
                                item.Id.ObjectId
                            });
                        }
                        COWSiteMailboxMessageDedup.Tracer.TraceDebug <StoreObjectId, string, double>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.ItemOperation: deleting message {0} from site mailbox {1} used {2} milliseconds", itemId, mailboxSession.DisplayName, (ExDateTime.Now - now).TotalMilliseconds);
                    }
                }
            }
            catch (StoragePermanentException arg)
            {
                COWSiteMailboxMessageDedup.Tracer.TraceError <StoragePermanentException>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.ItemOperation: got store permanent exception: {0}", arg);
            }
            catch (StorageTransientException arg2)
            {
                COWSiteMailboxMessageDedup.Tracer.TraceError <StorageTransientException>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.ItemOperation: got store transient exception: {0}", arg2);
            }
            callbackContext.SiteMailboxMessageDedupState = COWProcessorState.Processed;
        }
Exemplo n.º 12
0
 public void GroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId destinationFolderId, StoreObjectId[] itemIds, GroupOperationResult result, bool onBeforeNotification, CallbackContext callbackContext)
 {
     EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
     EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags");
     if (settings.CurrentFolderId.Equals(dumpster.RecoverableItemsPurgesFolderId))
     {
         ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "Attempt to hard delete items in the dumpster purges folder");
         throw new RecoverableItemsAccessDeniedException("Purges");
     }
     if (settings.CurrentFolderId.Equals(dumpster.RecoverableItemsDiscoveryHoldsFolderId))
     {
         ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "Attempt to hard delete items in the dumpster discoveryholds folder");
         throw new RecoverableItemsAccessDeniedException("DiscoveryHolds");
     }
     if (COWTriggerAction.HardDelete == operation)
     {
         try
         {
             StoreObjectId storeObjectId;
             if (settings.IsOnlyInPlaceHoldEnabled())
             {
                 settings.Session.CowSession.CheckAndCreateDiscoveryHoldsFolder(callbackContext.SessionWithBestAccess);
                 storeObjectId = dumpster.RecoverableItemsDiscoveryHoldsFolderId;
             }
             else
             {
                 storeObjectId = dumpster.RecoverableItemsPurgesFolderId;
             }
             if (!settings.CurrentFolderId.Equals(storeObjectId))
             {
                 dumpster.MoveItemsToDumpster(callbackContext.SessionWithBestAccess, storeObjectId, itemIds);
             }
             return;
         }
         catch (DumpsterOperationException)
         {
             if (dumpster.Results.AnyPartialResultFailure())
             {
                 throw;
             }
             List <GroupOperationResult> partialResults = dumpster.Results.GetPartialResults();
             ExTraceGlobals.SessionTracer.TraceWarning <GroupOperationResult>((long)dumpster.StoreSession.GetHashCode(), "DumpsterOperationException during HardDelete and Partial success: leave the current results {0}", partialResults[partialResults.Count - 1]);
             return;
         }
     }
     dumpster.CopyItemsToDumpster(callbackContext.SessionWithBestAccess, dumpster.RecoverableItemsPurgesFolderId, itemIds, COWTriggerAction.DoneWithMessageDelete == operation);
 }
Exemplo n.º 13
0
        public bool SkipItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, bool onBeforeNotification, bool onDumpster, bool success, CallbackContext callbackContext)
        {
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            MailboxSession mailboxSession = session as MailboxSession;

            if (mailboxSession == null || !Utils.IsTeamMailbox(session) || !ClientInfo.MOMT.IsMatch(session.ClientInfoString))
            {
                return(true);
            }
            if (callbackContext.SiteMailboxMessageDedupState == COWProcessorState.DoNotProcess)
            {
                COWSiteMailboxMessageDedup.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.SkipItemOperation: skipping notification for item {0} because it should not be processed.", itemId);
                return(true);
            }
            if (callbackContext.SiteMailboxMessageDedupState == COWProcessorState.Processed)
            {
                COWSiteMailboxMessageDedup.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.SkipItemOperation: skipping notification for item {0} because it was already processed.", itemId);
                return(true);
            }
            if (callbackContext.SiteMailboxMessageDedupState == COWProcessorState.ProcessAfterSave)
            {
                return(onBeforeNotification);
            }
            if (onDumpster || item == null || operation != COWTriggerAction.Create)
            {
                callbackContext.SiteMailboxMessageDedupState = COWProcessorState.DoNotProcess;
                return(true);
            }
            if (!settings.IsSiteMailboxMessageDedupEnabled())
            {
                callbackContext.SiteMailboxMessageDedupState = COWProcessorState.DoNotProcess;
                COWSiteMailboxMessageDedup.Tracer.Information <string>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.SkipItemOperation: skipping message dedup for site mailbox {0} because the feature is disabled for the mailbox.", mailboxSession.DisplayName);
                return(true);
            }
            ExDateTime now  = ExDateTime.Now;
            bool       flag = false;

            try
            {
                flag = this.IsDuplicateMessageBySiteMailboxDrop(mailboxSession, item);
            }
            catch (StoragePermanentException arg)
            {
                COWSiteMailboxMessageDedup.Tracer.TraceError <StoragePermanentException>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.SkipItemOperation: got store permanent exception: {0}", arg);
            }
            catch (StorageTransientException arg2)
            {
                COWSiteMailboxMessageDedup.Tracer.TraceError <StorageTransientException>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.SkipItemOperation: got store transient exception: {0}", arg2);
            }
            if (flag)
            {
                callbackContext.SiteMailboxMessageDedupState = COWProcessorState.ProcessAfterSave;
            }
            else
            {
                callbackContext.SiteMailboxMessageDedupState = COWProcessorState.DoNotProcess;
            }
            COWSiteMailboxMessageDedup.Tracer.TraceDebug((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.SkipItemOperation: inspecting message {0} dragged & dropped to site mailbox {1} costed {2} milliseconds, and the result is {3}.", new object[]
            {
                itemId,
                mailboxSession.DisplayName,
                (ExDateTime.Now - now).TotalMilliseconds,
                callbackContext.SiteMailboxMessageDedupState
            });
            return(true);
        }
Exemplo n.º 14
0
 public void GroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId destinationFolderId, StoreObjectId[] itemIds, GroupOperationResult result, bool onBeforeNotification, CallbackContext callbackContext)
 {
     EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
     EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags");
 }
Exemplo n.º 15
0
        public bool SkipItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, bool onBeforeNotification, bool onDumpster, bool success, CallbackContext callbackContext)
        {
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            Util.ThrowOnNullArgument(callbackContext, "callbackContext");
            if (!WorkingSetPublisher.IsGroupWSPublishingEnabled())
            {
                COWGroupMessageWSPublishing.Tracer.Information((long)this.GetHashCode(), "COWGroupMessageWSPublishing.SkipItemOperation: skipping group message working set publishing as the feature is disabled.");
                return(true);
            }
            switch (callbackContext.COWGroupMessageWSPublishingState)
            {
            case COWProcessorState.Unknown:
                callbackContext.COWGroupMessageWSPublishingState = this.InspectNotification(operation, session, item, onBeforeNotification, onDumpster);
                COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId, COWProcessorState>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.SkipItemOperation: inspected item {0} and result is {1}.", itemId, callbackContext.COWGroupMessageWSPublishingState);
                return(true);

            case COWProcessorState.DoNotProcess:
                COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.SkipItemOperation: skipping notification for item {0} because it should not be processed.", itemId);
                return(true);

            case COWProcessorState.ProcessAfterSave:
                return(onBeforeNotification);

            case COWProcessorState.Processed:
                COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.SkipItemOperation: skipping notification for item {0} because it has already been processed.", itemId);
                return(true);

            default:
                return(true);
            }
        }
Exemplo n.º 16
0
 internal static bool ShouldLog(ICoreItem item, COWTriggerAction action)
 {
     return(item != null && ((item.StoreObjectId != null || action == COWTriggerAction.Create) && (item.IsDirty || action != COWTriggerAction.Update) && CalendarLoggingHelper.ShouldLog(action)) && CalendarLoggingHelper.IsCalendarItem(item));
 }
Exemplo n.º 17
0
        public CowClientOperationSensitivity SkipGroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId sourceFolderId, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds, bool onBeforeNotification, bool onDumpster, CallbackContext callbackContext)
        {
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags");
            MailboxSession mailboxSession = sourceSession as MailboxSession;

            if (mailboxSession == null)
            {
                return(CowClientOperationSensitivity.Skip);
            }
            if (onBeforeNotification && (COWTriggerAction.Copy == operation || COWTriggerAction.HardDelete == operation || COWTriggerAction.Move == operation || COWTriggerAction.MoveToDeletedItems == operation || COWTriggerAction.SoftDelete == operation))
            {
                StoreObjectId auditsFolderId         = dumpster.AuditsFolderId;
                StoreObjectId adminAuditLogsFolderId = dumpster.AdminAuditLogsFolderId;
                if (settings.CurrentFolderId != null && (COWTriggerAction.HardDelete != operation || LogonType.SystemService != sourceSession.LogonType || !settings.IsMrmAction()))
                {
                    this.CheckAccessOnAuditFolders(mailboxSession, settings.CurrentFolderId, dumpster, false);
                }
                if (itemIds != null)
                {
                    foreach (StoreObjectId storeObjectId in itemIds)
                    {
                        if (storeObjectId != null)
                        {
                            if (storeObjectId.IsMessageId)
                            {
                                if (settings.CurrentFolderId == null && (COWTriggerAction.HardDelete != operation || LogonType.SystemService != sourceSession.LogonType || !settings.IsMrmAction()))
                                {
                                    StoreObjectId parentIdFromMessageId = IdConverter.GetParentIdFromMessageId(storeObjectId);
                                    if (parentIdFromMessageId.Equals(auditsFolderId))
                                    {
                                        throw new AccessDeniedException(ServerStrings.ExAuditsUpdateDenied);
                                    }
                                    if (parentIdFromMessageId.Equals(adminAuditLogsFolderId))
                                    {
                                        throw new AccessDeniedException(ServerStrings.ExAdminAuditLogsUpdateDenied);
                                    }
                                    if (dumpster.IsAuditFolder(parentIdFromMessageId))
                                    {
                                        throw new AccessDeniedException((auditsFolderId != null) ? ServerStrings.ExAuditsUpdateDenied : ServerStrings.ExAdminAuditLogsUpdateDenied);
                                    }
                                }
                            }
                            else if (storeObjectId.IsFolderId)
                            {
                                this.CheckAccessOnAuditFolders(mailboxSession, storeObjectId, dumpster, true);
                            }
                        }
                    }
                }
            }
            return(CowClientOperationSensitivity.Skip);
        }
Exemplo n.º 18
0
 public CowClientOperationSensitivity SkipGroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId sourceFolderId, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds, bool onBeforeNotification, bool onDumpster, CallbackContext callbackContext)
 {
     EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
     EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags");
     Util.ThrowOnNullArgument(settings, "settings");
     Util.ThrowOnNullArgument(sourceSession, "sourceSession");
     if (onDumpster)
     {
         return(CowClientOperationSensitivity.Skip);
     }
     if (!onBeforeNotification)
     {
         return(CowClientOperationSensitivity.Skip);
     }
     if (operation != COWTriggerAction.SoftDelete)
     {
         return(CowClientOperationSensitivity.Skip);
     }
     if (COWSession.IsDelegateSession(sourceSession))
     {
         return(CowClientOperationSensitivity.Capture);
     }
     return(CowClientOperationSensitivity.CaptureAndPerformOperation);
 }
Exemplo n.º 19
0
        public CowClientOperationSensitivity SkipGroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId sourceFolderId, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds, bool onBeforeNotification, bool onDumpster, CallbackContext callbackContext)
        {
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags");
            Util.ThrowOnNullArgument(settings, "settings");
            Util.ThrowOnNullArgument(sourceSession, "sourceSession");
            if (onDumpster)
            {
                return(CowClientOperationSensitivity.Skip);
            }
            if (!onBeforeNotification)
            {
                return(CowClientOperationSensitivity.Skip);
            }
            bool flag;

            if (!settings.HoldEnabled())
            {
                flag = true;
            }
            else
            {
                switch (operation)
                {
                case COWTriggerAction.Move:
                case COWTriggerAction.MoveToDeletedItems:
                {
                    Util.ThrowOnNullArgument(sourceSession, "sourceSession");
                    if (destinationSession == null)
                    {
                        flag = true;
                        ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "Destination session is null, meaning item moving to same mailbox, so don't keep a copy.");
                        goto IL_187;
                    }
                    Guid mailboxGuid  = destinationSession.MailboxGuid;
                    Guid mailboxGuid2 = sourceSession.MailboxGuid;
                    if (destinationSession.MailboxGuid == sourceSession.MailboxGuid)
                    {
                        flag = true;
                        ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "Mailbox guids are the same, meaning item moving to same mailbox, so don't keep a copy.");
                        goto IL_187;
                    }
                    if (destinationSession is MailboxSession && sourceSession is MailboxSession && string.Compare(((MailboxSession)sourceSession).MailboxOwner.LegacyDn, ((MailboxSession)destinationSession).MailboxOwner.LegacyDn, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        flag = true;
                        ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "MailboxOwner.LegacyDistinguishedName is the same, meaning same person owns both mailboxes (eg primary and archive), so don't keep a copy.");
                        goto IL_187;
                    }
                    flag = false;
                    ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "Item moving to a different mailbox owned by someone else. Keep a copy.");
                    goto IL_187;
                }

                case COWTriggerAction.HardDelete:
                    flag = (settings.IsMrmAction() && DumpsterFolderHelper.IsDumpsterFolder(callbackContext.SessionWithBestAccess, sourceFolderId));
                    goto IL_187;

                case COWTriggerAction.DoneWithMessageDelete:
                    flag = false;
                    goto IL_187;
                }
                flag = true;
            }
IL_187:
            if (flag)
            {
                return(CowClientOperationSensitivity.Skip);
            }
            if (COWSession.IsDelegateSession(sourceSession))
            {
                return(CowClientOperationSensitivity.Capture);
            }
            return(CowClientOperationSensitivity.CaptureAndPerformOperation);
        }
Exemplo n.º 20
0
 public bool SkipItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, bool onBeforeNotification, bool onDumpster, bool success, CallbackContext callbackContext)
 {
     EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
     EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
     return(true);
 }
Exemplo n.º 21
0
 public bool SkipItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, bool onBeforeNotification, bool onDumpster, bool success, CallbackContext callbackContext)
 {
     EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
     EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
     if (onBeforeNotification && COWTriggerAction.Update == operation)
     {
         if (settings.CurrentFolderId != null)
         {
             if (settings.CurrentFolderId.Equals(dumpster.AuditsFolderId))
             {
                 throw new AccessDeniedException(ServerStrings.ExAuditsUpdateDenied);
             }
             if (settings.CurrentFolderId.Equals(dumpster.AdminAuditLogsFolderId))
             {
                 throw new AccessDeniedException(ServerStrings.ExAdminAuditLogsUpdateDenied);
             }
             if (dumpster.IsAuditFolder(settings.CurrentFolderId))
             {
                 throw new AccessDeniedException((dumpster.AuditsFolderId != null) ? ServerStrings.ExAuditsUpdateDenied : ServerStrings.ExAdminAuditLogsUpdateDenied);
             }
         }
         else if (itemId != null)
         {
             StoreObjectId parentIdFromMessageId = IdConverter.GetParentIdFromMessageId(itemId);
             if (parentIdFromMessageId.Equals(dumpster.AuditsFolderId))
             {
                 throw new AccessDeniedException(ServerStrings.ExAuditsUpdateDenied);
             }
             if (parentIdFromMessageId.Equals(dumpster.AdminAuditLogsFolderId))
             {
                 throw new AccessDeniedException(ServerStrings.ExAdminAuditLogsUpdateDenied);
             }
             if (dumpster.IsAuditFolder(settings.CurrentFolderId))
             {
                 throw new AccessDeniedException((dumpster.AuditsFolderId != null) ? ServerStrings.ExAuditsUpdateDenied : ServerStrings.ExAdminAuditLogsUpdateDenied);
             }
         }
     }
     return(true);
 }
Exemplo n.º 22
0
        public void ItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, CoreFolder folder, bool onBeforeNotification, OperationResult result, CallbackContext callbackContext)
        {
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <OperationResult>(result, "result");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            StoreObjectId storeObjectId = ((ICoreObject)item).StoreObjectId;

            if (storeObjectId is OccurrenceStoreObjectId)
            {
                return;
            }
            if (onBeforeNotification)
            {
                List <string> legallyDirtyProperties = item.GetLegallyDirtyProperties();
                if (legallyDirtyProperties != null && legallyDirtyProperties.Count > 0)
                {
                    COWSettings.AddMetadata(settings, item, operation);
                    if (state == COWTriggerActionState.Save)
                    {
                        StoreObjectId destinationFolderId;
                        if (settings.IsOnlyInPlaceHoldEnabled())
                        {
                            settings.Session.CowSession.CheckAndCreateDiscoveryHoldsFolder(callbackContext.SessionWithBestAccess);
                            destinationFolderId = dumpster.RecoverableItemsDiscoveryHoldsFolderId;
                        }
                        else
                        {
                            destinationFolderId = dumpster.RecoverableItemsVersionsFolderId;
                        }
                        StoreObjectId copyOnWriteGeneratedId = dumpster.CopyItemToDumpster(callbackContext.SessionWithBestAccess, destinationFolderId, item);
                        dumpster.Results.CopyOnWriteGeneratedId = copyOnWriteGeneratedId;
                        return;
                    }
                }
            }
            else if (operation == COWTriggerAction.Update && state == COWTriggerActionState.Save && result == OperationResult.Failed)
            {
                dumpster.RollbackItemVersion(callbackContext.SessionWithBestAccess, item, dumpster.Results.CopyOnWriteGeneratedId);
                dumpster.Results.CopyOnWriteGeneratedId = null;
            }
        }
Exemplo n.º 23
0
 public void ItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, CoreFolder folder, bool onBeforeNotification, OperationResult result, CallbackContext callbackContext)
 {
     EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
     EnumValidator.ThrowIfInvalid <OperationResult>(result, "result");
     EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
 }
Exemplo n.º 24
0
        public void GroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId destinationFolderId, StoreObjectId[] itemIds, GroupOperationResult result, bool onBeforeNotification, CallbackContext callbackContext)
        {
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags");
            int num = 0;

            if (itemIds != null)
            {
                foreach (StoreObjectId storeObjectId in itemIds)
                {
                    if (!(storeObjectId is OccurrenceStoreObjectId))
                    {
                        num++;
                    }
                }
            }
            if (itemIds == null || num == itemIds.Length)
            {
                dumpster.MoveItemsToDumpster(callbackContext.SessionWithBestAccess, dumpster.RecoverableItemsDeletionsFolderId, itemIds);
                return;
            }
            if (num > 0)
            {
                StoreObjectId[] array = new StoreObjectId[num];
                num = 0;
                foreach (StoreObjectId storeObjectId2 in itemIds)
                {
                    if (!(storeObjectId2 is OccurrenceStoreObjectId))
                    {
                        array[num] = storeObjectId2;
                        num++;
                    }
                }
                dumpster.MoveItemsToDumpster(callbackContext.SessionWithBestAccess, dumpster.RecoverableItemsDeletionsFolderId, array);
            }
        }
Exemplo n.º 25
0
 public CowClientOperationSensitivity SkipGroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId sourceFolderId, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds, bool onBeforeNotification, bool onDumpster, CallbackContext callbackContext)
 {
     EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
     EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags");
     return(CowClientOperationSensitivity.Skip);
 }
Exemplo n.º 26
0
        private static Dictionary <PropertyDefinition, object> GetMetadata(ICoreItem item, COWTriggerAction action, FolderChangeOperationFlags?folderChangeOperationFlags)
        {
            Dictionary <PropertyDefinition, object> dictionary = new Dictionary <PropertyDefinition, object>(6);

            item.PropertyBag.Load(CalendarLoggingHelper.RequiredOriginalProperties);
            switch (action)
            {
            case COWTriggerAction.MoveToDeletedItems:
            case COWTriggerAction.SoftDelete:
            case COWTriggerAction.HardDelete:
                if (folderChangeOperationFlags != null)
                {
                    dictionary.Add(InternalSchema.ClientIntent, CalendarLoggingHelper.GetClientIntentFromFolderChangeOperationFlags(folderChangeOperationFlags.Value, item.PropertyBag.GetValueOrDefault <string>(InternalSchema.CalendarLogTriggerAction, string.Empty), item.PropertyBag.GetValueOrDefault <ClientIntentFlags>(InternalSchema.ClientIntent, ClientIntentFlags.None)));
                }
                break;
            }
            dictionary.Add(InternalSchema.OriginalFolderId, item.PropertyBag.GetValueOrDefault <object>(InternalSchema.ParentEntryId, Array <byte> .Empty));
            dictionary.Add(InternalSchema.OriginalCreationTime, item.PropertyBag.GetValueOrDefault <object>(InternalSchema.CreationTime, ExDateTime.MinValue));
            dictionary.Add(InternalSchema.OriginalEntryId, item.PropertyBag.GetValueOrDefault <object>(InternalSchema.EntryId, Array <byte> .Empty));
            dictionary.Add(InternalSchema.ItemVersion, item.PropertyBag.GetValueOrDefault <int>(InternalSchema.ItemVersion, 0) + 1);
            dictionary.Add(InternalSchema.ChangeList, item.LocationIdentifierHelperInstance.ChangeBuffer);
            return(dictionary);
        }
Exemplo n.º 27
0
        private COWProcessorState InspectNotification(COWTriggerAction operation, StoreSession session, CoreItem item, bool onBeforeNotification, bool onDumpster)
        {
            if (onDumpster)
            {
                return(COWProcessorState.DoNotProcess);
            }
            if (operation != COWTriggerAction.Create)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: not an Create operation.");
                return(COWProcessorState.DoNotProcess);
            }
            if (!onBeforeNotification)
            {
                return(COWProcessorState.DoNotProcess);
            }
            if (item == null)
            {
                return(COWProcessorState.Unknown);
            }
            if (item.Id != null)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: ItemId is non-null, so this is not a new item. Do not process.");
                return(COWProcessorState.DoNotProcess);
            }
            MailboxSession mailboxSession = session as MailboxSession;

            if (mailboxSession == null)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: not a mailbox session. Do not process.");
                return(COWProcessorState.DoNotProcess);
            }
            int?num = mailboxSession.Mailbox.TryGetProperty(MailboxSchema.MailboxTypeDetail) as int?;

            if (num == null)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: mailbox type not found. Try to inspect later.");
                return(COWProcessorState.Unknown);
            }
            if (!StoreSession.IsGroupMailbox(num.Value))
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: Mailbox isn't a GroupMailbox. Do not process.");
                return(COWProcessorState.DoNotProcess);
            }
            string valueOrDefault = item.PropertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, string.Empty);

            if (string.IsNullOrEmpty(valueOrDefault))
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: item class not found. Try to inspect later.");
                return(COWProcessorState.Unknown);
            }
            if (!ObjectClass.IsMessage(valueOrDefault, false))
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: item class is not a message. Do not process.");
                return(COWProcessorState.DoNotProcess);
            }
            if (ObjectClass.IsMeetingForwardNotification(valueOrDefault))
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: item class is meeting forward notification. Do not process.");
                return(COWProcessorState.DoNotProcess);
            }
            if (ObjectClass.IsMeetingResponse(valueOrDefault))
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: item class is meeting response. Do not process.");
                return(COWProcessorState.DoNotProcess);
            }
            bool flag  = ClientInfo.OWA.IsMatch(mailboxSession.ClientInfoString);
            bool flag2 = ClientInfo.HubTransport.IsMatch(mailboxSession.ClientInfoString);

            if (!flag && !flag2)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: This isn't either a post or a delivery. Do not process.");
                return(COWProcessorState.DoNotProcess);
            }
            StoreObjectId storeObjectId = item.PropertyBag.TryGetProperty(StoreObjectSchema.ParentItemId) as StoreObjectId;

            if (storeObjectId == null)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: parent folder id not found. Try to inspect later.");
                return(COWProcessorState.Unknown);
            }
            StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox);

            if (defaultFolderId == null)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: inbox folder id not found. Try to inspect later.");
                return(COWProcessorState.Unknown);
            }
            if (!storeObjectId.Equals(defaultFolderId))
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug((long)this.GetHashCode(), "COWGroupMessageWSPublishing.InspectNotification: This message isn't located on the inbox folder. Do not process.");
                return(COWProcessorState.DoNotProcess);
            }
            return(COWProcessorState.ProcessAfterSave);
        }
Exemplo n.º 28
0
 internal static bool ShouldLogInitialCheck(StoreObjectId itemId, COWTriggerAction operation)
 {
     Util.ThrowOnNullArgument(itemId, "itemId");
     return(CalendarLoggingHelper.ShouldLog(operation) && (itemId.ObjectType == StoreObjectType.Unknown || CalendarLoggingHelper.IsCalendarItem(itemId)));
 }
Exemplo n.º 29
0
        public void ItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, CoreFolder folder, bool onBeforeNotification, OperationResult result, CallbackContext callbackContext)
        {
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            EnumValidator.ThrowIfInvalid <OperationResult>(result, "result");
            Util.ThrowOnNullArgument(item, "item");
            Util.ThrowOnNullArgument(callbackContext, "callbackContext");
            if (callbackContext.COWGroupMessageWSPublishingState != COWProcessorState.ProcessAfterSave)
            {
                COWGroupMessageWSPublishing.Tracer.TraceError <COWProcessorState>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: Skipping working set publishing because the state doesn't indicate processing is needed: {0}", callbackContext.COWGroupMessageWSPublishingState);
                return;
            }
            if (onBeforeNotification)
            {
                COWGroupMessageWSPublishing.Tracer.TraceError((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: Skipping working set publishing because we should only publish after saving");
                return;
            }
            if (result != OperationResult.Succeeded)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug <OperationResult>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: Skipping working set publishing of message because the operation wasn't successful: {0}", result);
                return;
            }
            MailboxSession mailboxSession = session as MailboxSession;

            if (mailboxSession == null)
            {
                COWGroupMessageWSPublishing.Tracer.TraceError <OperationResult>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: Skipping working set publishing the session is not a mailbox session", result);
                return;
            }
            if (mailboxSession.MailboxOwner == null || mailboxSession.MailboxOwner.MailboxInfo == null)
            {
                COWGroupMessageWSPublishing.Tracer.TraceError <OperationResult>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: Skipping working set publishing, the session does not contain the mailbox info", result);
                return;
            }
            string    displayName = mailboxSession.DisplayName;
            string    groupId     = mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString();
            Exception ex          = this.groupWSPublisher.PublishGroupPost(item, displayName, groupId);

            if (ex == null)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: working set publishing of message {0} from group mailbox successful", itemId);
            }
            else
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId, string>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: working set publishing of message {0} from group mailbox failed. Error: {1}", itemId, ex.ToString());
            }
            callbackContext.COWGroupMessageWSPublishingState = COWProcessorState.Processed;
        }
Exemplo n.º 30
0
 internal static bool IsDeleteOperation(COWTriggerAction operation)
 {
     return(operation == COWTriggerAction.SoftDelete || operation == COWTriggerAction.HardDelete);
 }