MAILBOX-364 Move event related classes in the event package of mailbox-api
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/df5d678c Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/df5d678c Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/df5d678c Branch: refs/heads/master Commit: df5d678cd43319ba7afca9baabcfc27b338b1898 Parents: 4270f4f Author: Benoit Tellier <[email protected]> Authored: Wed Jan 23 17:58:23 2019 +0700 Committer: Benoit Tellier <[email protected]> Committed: Fri Jan 25 10:54:50 2019 +0700 ---------------------------------------------------------------------- .../java/org/apache/james/mailbox/Event.java | 83 --- .../apache/james/mailbox/MailboxListener.java | 582 ------------------ .../apache/james/mailbox/MessageMoveEvent.java | 152 ----- .../org/apache/james/mailbox/events/Event.java | 83 +++ .../apache/james/mailbox/events/EventBus.java | 3 - .../james/mailbox/events/EventDeadLetters.java | 2 - .../james/mailbox/events/MailboxListener.java | 583 +++++++++++++++++++ .../james/mailbox/events/MessageMoveEvent.java | 153 +++++ .../org/apache/james/mailbox/EventTest.java | 1 + .../james/mailbox/MailboxListenerTest.java | 2 + .../james/mailbox/MailboxManagerStressTest.java | 1 + .../james/mailbox/MailboxManagerTest.java | 2 + .../james/mailbox/MessageMoveEventTest.java | 3 +- .../mailbox/events/ErrorHandlingContract.java | 2 - .../mailbox/events/EventBusTestFixture.java | 2 - .../events/EventDeadLettersContract.java | 2 - .../james/mailbox/events/GroupContract.java | 2 - .../james/mailbox/events/KeyContract.java | 2 - .../james/mailbox/model/MessageMovesTest.java | 2 +- .../james/mailbox/util/EventCollector.java | 4 +- .../CacheInvalidatingMailboxListener.java | 4 +- .../MailboxOperationLoggingListener.java | 4 +- .../james/mailbox/events/InVMEventBus.java | 2 - .../mailbox/events/MemoryEventDeadLetters.java | 2 - .../mailbox/events/delivery/EventDelivery.java | 4 +- .../events/delivery/InVmEventDelivery.java | 4 +- .../events/delivery/InVmEventDeliveryTest.java | 2 +- .../james/mailbox/events/EventDispatcher.java | 2 - .../mailbox/events/GroupConsumerRetry.java | 1 - .../james/mailbox/events/GroupRegistration.java | 2 - .../events/GroupRegistrationHandler.java | 1 - .../mailbox/events/KeyRegistrationHandler.java | 2 - .../mailbox/events/MailboxListenerExecutor.java | 2 - .../mailbox/events/MailboxListenerRegistry.java | 2 - .../james/mailbox/events/RabbitMQEventBus.java | 2 - .../events/MailboxListenerRegistryTest.java | 1 - .../mailbox/events/RabbitMQEventBusTest.java | 2 - .../james/event/json/EventSerializer.scala | 7 +- .../event/json/AddedSerializationTest.java | 2 +- .../event/json/ExpungedSerializationTest.java | 2 +- .../json/FlagsUpdatedSerializationTest.java | 2 +- ...MailboxACLUpdatedEventSerializationTest.java | 2 +- .../json/MailboxAddedSerializationTest.java | 2 +- .../json/MailboxDeletionSerializationTest.java | 2 +- .../json/MailboxRenamedSerializationTest.java | 2 +- .../json/MessageMoveEventSerializationTest.java | 4 +- ...QuotaUsageUpdatedEventSerializationTest.java | 2 +- .../james/event/json/SerializerFixture.java | 2 +- .../QuotaThresholdCrossingListener.java | 4 +- .../QuotaThresholdConfigurationChangesTest.java | 2 +- .../QuotaThresholdListenersTestSystem.java | 2 +- .../QuotaThresholdMailingIntegrationTest.java | 2 +- .../ElasticSearchQuotaMailboxListener.java | 4 +- .../json/QuotaRatioToElasticSearchJson.java | 2 +- .../ElasticSearchQuotaMailboxListenerTest.java | 2 +- .../json/QuotaRatioToElasticSearchJsonTest.java | 4 +- .../spamassassin/SpamAssassinListener.java | 4 +- .../spamassassin/SpamAssassinListenerTest.java | 4 +- .../mailbox/store/StoreMessageManager.java | 2 +- .../james/mailbox/store/event/EventFactory.java | 6 +- .../store/event/MailboxAnnotationListener.java | 4 +- .../mailbox/store/event/SpamEventListener.java | 2 +- .../quota/ListeningCurrentQuotaUpdater.java | 4 +- .../search/ListeningMessageSearchIndex.java | 6 +- .../AbstractMessageIdManagerSideEffectTest.java | 4 +- .../event/MailboxAnnotationListenerTest.java | 4 +- .../quota/ListeningCurrentQuotaUpdaterTest.java | 4 +- .../james/imap/processor/IdleProcessor.java | 4 +- .../processor/base/SelectedMailboxImpl.java | 4 +- .../base/MailboxEventAnalyserTest.java | 4 +- .../processor/base/SelectedMailboxImplTest.java | 2 +- .../modules/mailbox/CassandraMailboxModule.java | 2 +- .../modules/mailbox/CassandraQuotaModule.java | 2 +- .../mailbox/ElasticSearchMailboxModule.java | 2 +- .../ElasticSearchQuotaSearcherModule.java | 2 +- .../james/modules/mailbox/JPAMailboxModule.java | 2 +- .../james/modules/mailbox/JpaQuotaModule.java | 2 +- .../mailbox/LuceneSearchMailboxModule.java | 2 +- .../modules/mailbox/DefaultEventModule.java | 2 +- .../modules/mailbox/MailboxListenerFactory.java | 2 +- .../modules/mailbox/MailboxListenersLoader.java | 2 +- .../mailbox/MailboxListenersLoaderImpl.java | 2 +- .../modules/mailbox/NoopMailboxListener.java | 4 +- .../mailbox/MailboxListenersLoaderImplTest.java | 2 +- .../modules/mailbox/MemoryMailboxModule.java | 2 +- .../modules/mailbox/MemoryQuotaModule.java | 2 +- .../java/org/apache/james/jmap/JMAPModule.java | 2 +- .../org/apache/james/utils/JmapGuiceProbe.java | 2 +- .../integration/SetMessagesMethodTest.java | 4 +- .../methods/integration/SpamAssassinModule.java | 2 +- .../event/PropagateLookupRightListener.java | 4 +- .../event/PropagateLookupRightListenerTest.java | 2 +- 92 files changed, 917 insertions(+), 945 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java b/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java deleted file mode 100644 index bb26f1e..0000000 --- a/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ -package org.apache.james.mailbox; - -import java.util.Objects; -import java.util.UUID; - -import org.apache.james.core.User; - -import com.google.common.base.MoreObjects; -import com.google.common.base.Preconditions; - -public interface Event { - - class EventId { - public static EventId of(UUID uuid) { - return new EventId(uuid); - } - - public static EventId random() { - return new EventId(UUID.randomUUID()); - } - - public static EventId of(String serialized) { - return of(UUID.fromString(serialized)); - } - - private final UUID id; - - private EventId(UUID id) { - Preconditions.checkNotNull(id); - this.id = id; - } - - public UUID getId() { - return id; - } - - @Override - public final boolean equals(Object o) { - if (o instanceof EventId) { - EventId eventId = (EventId) o; - - return Objects.equals(this.id, eventId.id); - } - return false; - } - - @Override - public final int hashCode() { - return Objects.hash(id); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("id", id) - .toString(); - } - } - - User getUser(); - - boolean isNoop(); - - EventId getEventId(); -} http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java deleted file mode 100644 index 98607f1..0000000 --- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java +++ /dev/null @@ -1,582 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ - -package org.apache.james.mailbox; - -import java.time.Instant; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.SortedMap; - -import org.apache.james.core.User; -import org.apache.james.core.quota.QuotaCount; -import org.apache.james.core.quota.QuotaSize; -import org.apache.james.mailbox.acl.ACLDiff; -import org.apache.james.mailbox.events.Group; -import org.apache.james.mailbox.model.MailboxId; -import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MessageMetaData; -import org.apache.james.mailbox.model.Quota; -import org.apache.james.mailbox.model.QuotaRoot; -import org.apache.james.mailbox.model.UpdatedFlags; - -import com.github.steveash.guavate.Guavate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - - -/** - * Listens to <code>Mailbox</code> events.<br> - * Note that listeners may be removed asynchronously. - */ -public interface MailboxListener { - - interface GroupMailboxListener extends MailboxListener { - Group getDefaultGroup(); - } - - enum ExecutionMode { - SYNCHRONOUS, - ASYNCHRONOUS - } - - default ExecutionMode getExecutionMode() { - return ExecutionMode.SYNCHRONOUS; - } - - /** - * Informs this listener about the given event. - * - * @param event not null - */ - void event(Event event) throws Exception; - - interface QuotaEvent extends Event { - QuotaRoot getQuotaRoot(); - } - - class QuotaUsageUpdatedEvent implements QuotaEvent { - private final EventId eventId; - private final User user; - private final QuotaRoot quotaRoot; - private final Quota<QuotaCount> countQuota; - private final Quota<QuotaSize> sizeQuota; - private final Instant instant; - - public QuotaUsageUpdatedEvent(EventId eventId, User user, QuotaRoot quotaRoot, Quota<QuotaCount> countQuota, Quota<QuotaSize> sizeQuota, Instant instant) { - this.eventId = eventId; - this.user = user; - this.quotaRoot = quotaRoot; - this.countQuota = countQuota; - this.sizeQuota = sizeQuota; - this.instant = instant; - } - - @Override - public boolean isNoop() { - return false; - } - - @Override - public User getUser() { - return user; - } - - public Quota<QuotaCount> getCountQuota() { - return countQuota; - } - - public Quota<QuotaSize> getSizeQuota() { - return sizeQuota; - } - - @Override - public QuotaRoot getQuotaRoot() { - return quotaRoot; - } - - public Instant getInstant() { - return instant; - } - - @Override - public EventId getEventId() { - return eventId; - } - - @Override - public final boolean equals(Object o) { - if (o instanceof QuotaUsageUpdatedEvent) { - QuotaUsageUpdatedEvent that = (QuotaUsageUpdatedEvent) o; - - return Objects.equals(this.eventId, that.eventId) - && Objects.equals(this.user, that.user) - && Objects.equals(this.quotaRoot, that.quotaRoot) - && Objects.equals(this.countQuota, that.countQuota) - && Objects.equals(this.sizeQuota, that.sizeQuota) - && Objects.equals(this.instant, that.instant); - } - return false; - } - - @Override - public final int hashCode() { - return Objects.hash(eventId, user, quotaRoot, countQuota, sizeQuota, instant); - } - - } - - /** - * A mailbox event. - */ - abstract class MailboxEvent implements Event { - protected final MailboxPath path; - protected final MailboxId mailboxId; - protected final User user; - protected final MailboxSession.SessionId sessionId; - protected final EventId eventId; - - public MailboxEvent(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, EventId eventId) { - this.user = user; - this.path = path; - this.mailboxId = mailboxId; - this.sessionId = sessionId; - this.eventId = eventId; - } - - /** - * Gets the {@link User} in which's context the {@link MailboxEvent} - * happened - * - * @return user - */ - @Override - public User getUser() { - return user; - } - - @Override - public EventId getEventId() { - return eventId; - } - - /** - * Gets the sessionId in which's context the {@link MailboxEvent} - * happened - * - * @return sessionId - */ - public MailboxSession.SessionId getSessionId() { - return sessionId; - } - - /** - * Return the path of the Mailbox this event belongs to. - * - * @return path - */ - public MailboxPath getMailboxPath() { - return path; - } - - /** - * Return the id of the Mailbox this event belongs to. - * - * @return mailboxId - */ - public MailboxId getMailboxId() { - return mailboxId; - } - } - - /** - * Indicates that mailbox has been deleted. - */ - class MailboxDeletion extends MailboxEvent { - private final QuotaRoot quotaRoot; - private final QuotaCount deletedMessageCount; - private final QuotaSize totalDeletedSize; - - public MailboxDeletion(MailboxSession.SessionId sessionId, User user, MailboxPath path, QuotaRoot quotaRoot, QuotaCount deletedMessageCount, QuotaSize totalDeletedSize, - MailboxId mailboxId, EventId eventId) { - super(sessionId, user, path, mailboxId, eventId); - this.quotaRoot = quotaRoot; - this.deletedMessageCount = deletedMessageCount; - this.totalDeletedSize = totalDeletedSize; - } - - @Override - public boolean isNoop() { - return false; - } - - public QuotaRoot getQuotaRoot() { - return quotaRoot; - } - - public QuotaCount getDeletedMessageCount() { - return deletedMessageCount; - } - - public QuotaSize getTotalDeletedSize() { - return totalDeletedSize; - } - - @Override - public final boolean equals(Object o) { - if (o instanceof MailboxDeletion) { - MailboxDeletion that = (MailboxDeletion) o; - - return Objects.equals(this.eventId, that.eventId) - && Objects.equals(this.sessionId, that.sessionId) - && Objects.equals(this.user, that.user) - && Objects.equals(this.path, that.path) - && Objects.equals(this.mailboxId, that.mailboxId) - && Objects.equals(this.quotaRoot, that.quotaRoot) - && Objects.equals(this.deletedMessageCount, that.deletedMessageCount) - && Objects.equals(this.totalDeletedSize, that.totalDeletedSize); - } - return false; - } - - @Override - public final int hashCode() { - return Objects.hash(eventId, sessionId, user, path, mailboxId, quotaRoot, deletedMessageCount, totalDeletedSize); - } - } - - /** - * Indicates that a mailbox has been Added. - */ - class MailboxAdded extends MailboxEvent { - - public MailboxAdded(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, EventId eventId) { - super(sessionId, user, path, mailboxId, eventId); - } - - @Override - public boolean isNoop() { - return false; - } - - @Override - public final boolean equals(Object o) { - if (o instanceof MailboxAdded) { - MailboxAdded that = (MailboxAdded) o; - - return Objects.equals(this.eventId, that.eventId) - && Objects.equals(this.sessionId, that.sessionId) - && Objects.equals(this.user, that.user) - && Objects.equals(this.path, that.path) - && Objects.equals(this.mailboxId, that.mailboxId); - } - return false; - } - - @Override - public final int hashCode() { - return Objects.hash(eventId, sessionId, user, path, mailboxId); - } - } - - /** - * Indicates that a mailbox has been renamed. - */ - class MailboxRenamed extends MailboxEvent { - private final MailboxPath newPath; - - public MailboxRenamed(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, MailboxPath newPath, EventId eventId) { - super(sessionId, user, path, mailboxId, eventId); - this.newPath = newPath; - } - - @Override - public boolean isNoop() { - return newPath.equals(path); - } - - /** - * Gets the new name for this mailbox. - * - * @return name, not null - */ - public MailboxPath getNewPath() { - return newPath; - } - - @Override - public final boolean equals(Object o) { - if (o instanceof MailboxRenamed) { - MailboxRenamed that = (MailboxRenamed) o; - - return Objects.equals(this.eventId, that.eventId) - && Objects.equals(this.sessionId, that.sessionId) - && Objects.equals(this.user, that.user) - && Objects.equals(this.path, that.path) - && Objects.equals(this.mailboxId, that.mailboxId) - && Objects.equals(this.newPath, that.newPath); - } - return false; - } - - @Override - public final int hashCode() { - return Objects.hash(eventId, sessionId, user, path, mailboxId, newPath); - } - } - - - /** - * A mailbox event related to updated ACL - */ - class MailboxACLUpdated extends MailboxEvent { - private final ACLDiff aclDiff; - - public MailboxACLUpdated(MailboxSession.SessionId sessionId, User user, MailboxPath path, ACLDiff aclDiff, MailboxId mailboxId, EventId eventId) { - super(sessionId, user, path, mailboxId, eventId); - this.aclDiff = aclDiff; - } - - public ACLDiff getAclDiff() { - return aclDiff; - } - - @Override - public boolean isNoop() { - return aclDiff.getNewACL().equals(aclDiff.getOldACL()); - } - - @Override - public final boolean equals(Object o) { - if (o instanceof MailboxACLUpdated) { - MailboxACLUpdated that = (MailboxACLUpdated) o; - - return Objects.equals(this.eventId, that.eventId) - && Objects.equals(this.sessionId, that.sessionId) - && Objects.equals(this.user, that.user) - && Objects.equals(this.path, that.path) - && Objects.equals(this.aclDiff, that.aclDiff) - && Objects.equals(this.mailboxId, that.mailboxId); - } - return false; - } - - @Override - public final int hashCode() { - return Objects.hash(eventId, sessionId, user, path, aclDiff, mailboxId); - } - - } - - /** - * A mailbox event related to a message. - */ - abstract class MessageEvent extends MailboxEvent { - - public MessageEvent(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, EventId eventId) { - super(sessionId, user, path, mailboxId, eventId); - } - - /** - * Gets the message UIDs for the subject of this event. - * - * @return message uids - */ - public abstract Collection<MessageUid> getUids(); - } - - abstract class MetaDataHoldingEvent extends MessageEvent { - - public MetaDataHoldingEvent(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, EventId eventId) { - super(sessionId, user, path, mailboxId, eventId); - } - - /** - * Return the flags which were set for the affected message - * - * @return flags - */ - public abstract MessageMetaData getMetaData(MessageUid uid); - - } - - class Expunged extends MetaDataHoldingEvent { - private final Map<MessageUid, MessageMetaData> expunged; - - public Expunged(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, Map<MessageUid, MessageMetaData> uids, EventId eventId) { - super(sessionId, user, path, mailboxId, eventId); - this.expunged = ImmutableMap.copyOf(uids); - } - - @Override - public Collection<MessageUid> getUids() { - return expunged.keySet(); - } - - /** - * Return the flags which were set for the added message - * - * @return flags - */ - @Override - public MessageMetaData getMetaData(MessageUid uid) { - return expunged.get(uid); - } - - public Map<MessageUid, MessageMetaData> getExpunged() { - return expunged; - } - - @Override - public boolean isNoop() { - return expunged.isEmpty(); - } - - @Override - public final boolean equals(Object o) { - if (o instanceof Expunged) { - Expunged that = (Expunged) o; - - return Objects.equals(this.eventId, that.eventId) - && Objects.equals(this.sessionId, that.sessionId) - && Objects.equals(this.user, that.user) - && Objects.equals(this.path, that.path) - && Objects.equals(this.mailboxId, that.mailboxId) - && Objects.equals(this.expunged, that.expunged); - } - return false; - } - - @Override - public final int hashCode() { - return Objects.hash(eventId, sessionId, user, path, mailboxId, expunged); - } - } - - /** - * A mailbox event related to updated flags - */ - class FlagsUpdated extends MessageEvent { - private final List<MessageUid> uids; - private final List<UpdatedFlags> updatedFlags; - - public FlagsUpdated(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, List<UpdatedFlags> updatedFlags, - EventId eventId) { - super(sessionId, user, path, mailboxId, eventId); - this.updatedFlags = ImmutableList.copyOf(updatedFlags); - this.uids = updatedFlags.stream() - .map(UpdatedFlags::getUid) - .collect(Guavate.toImmutableList()); - } - - @Override - public Collection<MessageUid> getUids() { - return uids; - } - - public List<UpdatedFlags> getUpdatedFlags() { - return updatedFlags; - } - - @Override - public boolean isNoop() { - return updatedFlags.isEmpty(); - } - - @Override - public final boolean equals(Object o) { - if (o instanceof FlagsUpdated) { - FlagsUpdated that = (FlagsUpdated) o; - - return Objects.equals(this.eventId, that.eventId) - && Objects.equals(this.sessionId, that.sessionId) - && Objects.equals(this.user, that.user) - && Objects.equals(this.path, that.path) - && Objects.equals(this.mailboxId, that.mailboxId) - && Objects.equals(this.uids, that.uids) - && Objects.equals(this.updatedFlags, that.updatedFlags); - } - return false; - } - - @Override - public final int hashCode() { - return Objects.hash(eventId, sessionId, user, path, mailboxId, uids, updatedFlags); - } - } - - /** - * A mailbox event related to added message - */ - class Added extends MetaDataHoldingEvent { - private final Map<MessageUid, MessageMetaData> added; - - public Added(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, - SortedMap<MessageUid, MessageMetaData> uids, EventId eventId) { - super(sessionId, user, path, mailboxId, eventId); - this.added = ImmutableMap.copyOf(uids); - } - - /** - * Return the flags which were set for the added message - * - * @return flags - */ - public MessageMetaData getMetaData(MessageUid uid) { - return added.get(uid); - } - - @Override - public Collection<MessageUid> getUids() { - return added.keySet(); - } - - public Map<MessageUid, MessageMetaData> getAdded() { - return added; - } - - @Override - public boolean isNoop() { - return added.isEmpty(); - } - - @Override - public final boolean equals(Object o) { - if (o instanceof Added) { - Added that = (Added) o; - - return Objects.equals(this.eventId, that.eventId) - && Objects.equals(this.sessionId, that.sessionId) - && Objects.equals(this.user, that.user) - && Objects.equals(this.path, that.path) - && Objects.equals(this.mailboxId, that.mailboxId) - && Objects.equals(this.added, that.added); - } - return false; - } - - @Override - public final int hashCode() { - return Objects.hash(eventId, sessionId, user, path, mailboxId, added); - } - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/main/java/org/apache/james/mailbox/MessageMoveEvent.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MessageMoveEvent.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MessageMoveEvent.java deleted file mode 100644 index 8b72378..0000000 --- a/mailbox/api/src/main/java/org/apache/james/mailbox/MessageMoveEvent.java +++ /dev/null @@ -1,152 +0,0 @@ -/**************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one * - * or more contributor license agreements. See the NOTICE file * - * distributed with this work for additional information * - * regarding copyright ownership. The ASF licenses this file * - * to you under the Apache License, Version 2.0 (the * - * "License"); you may not use this file except in compliance * - * with the License. You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, * - * software distributed under the License is distributed on an * - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * - * KIND, either express or implied. See the License for the * - * specific language governing permissions and limitations * - * under the License. * - ****************************************************************/ -package org.apache.james.mailbox; - -import java.util.Collection; -import java.util.Objects; -import java.util.Optional; - -import org.apache.james.core.User; -import org.apache.james.mailbox.model.MailboxId; -import org.apache.james.mailbox.model.MessageId; -import org.apache.james.mailbox.model.MessageMoves; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; - -public class MessageMoveEvent implements Event { - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private ImmutableList.Builder<MessageId> messageIds; - private User user; - private MessageMoves messageMoves; - private Optional<EventId> eventId; - - private Builder() { - messageIds = ImmutableList.builder(); - eventId = Optional.empty(); - } - - public Builder session(MailboxSession session) { - this.user = session.getUser(); - return this; - } - - public Builder user(User user) { - this.user = user; - return this; - } - - public Builder messageMoves(MessageMoves messageMoves) { - this.messageMoves = messageMoves; - return this; - } - - public Builder messageId(MessageId messageId) { - this.messageIds.add(messageId); - return this; - } - - public Builder eventId(EventId eventId) { - this.eventId = Optional.of(eventId); - return this; - } - - public Builder messageId(Iterable<MessageId> messageIds) { - this.messageIds.addAll(messageIds); - return this; - } - - public MessageMoveEvent build() { - Preconditions.checkNotNull(user, "'user' is mandatory"); - Preconditions.checkNotNull(messageMoves, "'messageMoves' is mandatory"); - - return new MessageMoveEvent(eventId.orElse(EventId.random()), user, messageMoves, messageIds.build()); - } - } - - private final EventId eventId; - private final User user; - private final MessageMoves messageMoves; - private final Collection<MessageId> messageIds; - - @VisibleForTesting - MessageMoveEvent(EventId eventId, User user, MessageMoves messageMoves, Collection<MessageId> messageIds) { - this.eventId = eventId; - this.user = user; - this.messageMoves = messageMoves; - this.messageIds = messageIds; - } - - @Override - public boolean isNoop() { - return messageIds.isEmpty(); - } - - public Collection<MessageId> getMessageIds() { - return messageIds; - } - - @Override - public EventId getEventId() { - return eventId; - } - - @Override - public User getUser() { - return user; - } - - public MessageMoves getMessageMoves() { - return messageMoves; - } - - public boolean isMoveTo(MailboxId mailboxId) { - return messageMoves.addedMailboxIds() - .contains(mailboxId); - } - - public boolean isMoveFrom(MailboxId mailboxId) { - return messageMoves.removedMailboxIds() - .contains(mailboxId); - } - - @Override - public final boolean equals(Object o) { - if (o instanceof MessageMoveEvent) { - MessageMoveEvent that = (MessageMoveEvent) o; - - return Objects.equals(this.eventId, that.eventId) - && Objects.equals(this.user, that.user) - && Objects.equals(this.messageMoves, that.messageMoves) - && Objects.equals(this.messageIds, that.messageIds); - } - return false; - } - - @Override - public final int hashCode() { - return Objects.hash(eventId, user, messageMoves, messageIds); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/main/java/org/apache/james/mailbox/events/Event.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/events/Event.java b/mailbox/api/src/main/java/org/apache/james/mailbox/events/Event.java new file mode 100644 index 0000000..ff01b03 --- /dev/null +++ b/mailbox/api/src/main/java/org/apache/james/mailbox/events/Event.java @@ -0,0 +1,83 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ +package org.apache.james.mailbox.events; + +import java.util.Objects; +import java.util.UUID; + +import org.apache.james.core.User; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Preconditions; + +public interface Event { + + class EventId { + public static EventId of(UUID uuid) { + return new EventId(uuid); + } + + public static EventId random() { + return new EventId(UUID.randomUUID()); + } + + public static EventId of(String serialized) { + return of(UUID.fromString(serialized)); + } + + private final UUID id; + + private EventId(UUID id) { + Preconditions.checkNotNull(id); + this.id = id; + } + + public UUID getId() { + return id; + } + + @Override + public final boolean equals(Object o) { + if (o instanceof EventId) { + EventId eventId = (EventId) o; + + return Objects.equals(this.id, eventId.id); + } + return false; + } + + @Override + public final int hashCode() { + return Objects.hash(id); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("id", id) + .toString(); + } + } + + User getUser(); + + boolean isNoop(); + + EventId getEventId(); +} http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventBus.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventBus.java b/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventBus.java index 2333736..0b319f7 100644 --- a/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventBus.java +++ b/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventBus.java @@ -21,9 +21,6 @@ package org.apache.james.mailbox.events; import java.util.Set; -import org.apache.james.mailbox.Event; -import org.apache.james.mailbox.MailboxListener; - import com.google.common.collect.ImmutableSet; import reactor.core.publisher.Mono; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventDeadLetters.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventDeadLetters.java b/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventDeadLetters.java index 5c0057c..ed3dee5 100644 --- a/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventDeadLetters.java +++ b/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventDeadLetters.java @@ -19,8 +19,6 @@ package org.apache.james.mailbox.events; -import org.apache.james.mailbox.Event; - import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/main/java/org/apache/james/mailbox/events/MailboxListener.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/events/MailboxListener.java b/mailbox/api/src/main/java/org/apache/james/mailbox/events/MailboxListener.java new file mode 100644 index 0000000..dbd44cf --- /dev/null +++ b/mailbox/api/src/main/java/org/apache/james/mailbox/events/MailboxListener.java @@ -0,0 +1,583 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.mailbox.events; + +import java.time.Instant; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.SortedMap; + +import org.apache.james.core.User; +import org.apache.james.core.quota.QuotaCount; +import org.apache.james.core.quota.QuotaSize; +import org.apache.james.mailbox.MailboxSession; +import org.apache.james.mailbox.MessageUid; +import org.apache.james.mailbox.acl.ACLDiff; +import org.apache.james.mailbox.model.MailboxId; +import org.apache.james.mailbox.model.MailboxPath; +import org.apache.james.mailbox.model.MessageMetaData; +import org.apache.james.mailbox.model.Quota; +import org.apache.james.mailbox.model.QuotaRoot; +import org.apache.james.mailbox.model.UpdatedFlags; + +import com.github.steveash.guavate.Guavate; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + + +/** + * Listens to <code>Mailbox</code> events.<br> + * Note that listeners may be removed asynchronously. + */ +public interface MailboxListener { + + interface GroupMailboxListener extends MailboxListener { + Group getDefaultGroup(); + } + + enum ExecutionMode { + SYNCHRONOUS, + ASYNCHRONOUS + } + + default ExecutionMode getExecutionMode() { + return ExecutionMode.SYNCHRONOUS; + } + + /** + * Informs this listener about the given event. + * + * @param event not null + */ + void event(Event event) throws Exception; + + interface QuotaEvent extends Event { + QuotaRoot getQuotaRoot(); + } + + class QuotaUsageUpdatedEvent implements QuotaEvent { + private final EventId eventId; + private final User user; + private final QuotaRoot quotaRoot; + private final Quota<QuotaCount> countQuota; + private final Quota<QuotaSize> sizeQuota; + private final Instant instant; + + public QuotaUsageUpdatedEvent(EventId eventId, User user, QuotaRoot quotaRoot, Quota<QuotaCount> countQuota, Quota<QuotaSize> sizeQuota, Instant instant) { + this.eventId = eventId; + this.user = user; + this.quotaRoot = quotaRoot; + this.countQuota = countQuota; + this.sizeQuota = sizeQuota; + this.instant = instant; + } + + @Override + public boolean isNoop() { + return false; + } + + @Override + public User getUser() { + return user; + } + + public Quota<QuotaCount> getCountQuota() { + return countQuota; + } + + public Quota<QuotaSize> getSizeQuota() { + return sizeQuota; + } + + @Override + public QuotaRoot getQuotaRoot() { + return quotaRoot; + } + + public Instant getInstant() { + return instant; + } + + @Override + public EventId getEventId() { + return eventId; + } + + @Override + public final boolean equals(Object o) { + if (o instanceof QuotaUsageUpdatedEvent) { + QuotaUsageUpdatedEvent that = (QuotaUsageUpdatedEvent) o; + + return Objects.equals(this.eventId, that.eventId) + && Objects.equals(this.user, that.user) + && Objects.equals(this.quotaRoot, that.quotaRoot) + && Objects.equals(this.countQuota, that.countQuota) + && Objects.equals(this.sizeQuota, that.sizeQuota) + && Objects.equals(this.instant, that.instant); + } + return false; + } + + @Override + public final int hashCode() { + return Objects.hash(eventId, user, quotaRoot, countQuota, sizeQuota, instant); + } + + } + + /** + * A mailbox event. + */ + abstract class MailboxEvent implements Event { + protected final MailboxPath path; + protected final MailboxId mailboxId; + protected final User user; + protected final MailboxSession.SessionId sessionId; + protected final EventId eventId; + + public MailboxEvent(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, EventId eventId) { + this.user = user; + this.path = path; + this.mailboxId = mailboxId; + this.sessionId = sessionId; + this.eventId = eventId; + } + + /** + * Gets the {@link User} in which's context the {@link MailboxEvent} + * happened + * + * @return user + */ + @Override + public User getUser() { + return user; + } + + @Override + public EventId getEventId() { + return eventId; + } + + /** + * Gets the sessionId in which's context the {@link MailboxEvent} + * happened + * + * @return sessionId + */ + public MailboxSession.SessionId getSessionId() { + return sessionId; + } + + /** + * Return the path of the Mailbox this event belongs to. + * + * @return path + */ + public MailboxPath getMailboxPath() { + return path; + } + + /** + * Return the id of the Mailbox this event belongs to. + * + * @return mailboxId + */ + public MailboxId getMailboxId() { + return mailboxId; + } + } + + /** + * Indicates that mailbox has been deleted. + */ + class MailboxDeletion extends MailboxEvent { + private final QuotaRoot quotaRoot; + private final QuotaCount deletedMessageCount; + private final QuotaSize totalDeletedSize; + + public MailboxDeletion(MailboxSession.SessionId sessionId, User user, MailboxPath path, QuotaRoot quotaRoot, QuotaCount deletedMessageCount, QuotaSize totalDeletedSize, + MailboxId mailboxId, EventId eventId) { + super(sessionId, user, path, mailboxId, eventId); + this.quotaRoot = quotaRoot; + this.deletedMessageCount = deletedMessageCount; + this.totalDeletedSize = totalDeletedSize; + } + + @Override + public boolean isNoop() { + return false; + } + + public QuotaRoot getQuotaRoot() { + return quotaRoot; + } + + public QuotaCount getDeletedMessageCount() { + return deletedMessageCount; + } + + public QuotaSize getTotalDeletedSize() { + return totalDeletedSize; + } + + @Override + public final boolean equals(Object o) { + if (o instanceof MailboxDeletion) { + MailboxDeletion that = (MailboxDeletion) o; + + return Objects.equals(this.eventId, that.eventId) + && Objects.equals(this.sessionId, that.sessionId) + && Objects.equals(this.user, that.user) + && Objects.equals(this.path, that.path) + && Objects.equals(this.mailboxId, that.mailboxId) + && Objects.equals(this.quotaRoot, that.quotaRoot) + && Objects.equals(this.deletedMessageCount, that.deletedMessageCount) + && Objects.equals(this.totalDeletedSize, that.totalDeletedSize); + } + return false; + } + + @Override + public final int hashCode() { + return Objects.hash(eventId, sessionId, user, path, mailboxId, quotaRoot, deletedMessageCount, totalDeletedSize); + } + } + + /** + * Indicates that a mailbox has been Added. + */ + class MailboxAdded extends MailboxEvent { + + public MailboxAdded(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, EventId eventId) { + super(sessionId, user, path, mailboxId, eventId); + } + + @Override + public boolean isNoop() { + return false; + } + + @Override + public final boolean equals(Object o) { + if (o instanceof MailboxAdded) { + MailboxAdded that = (MailboxAdded) o; + + return Objects.equals(this.eventId, that.eventId) + && Objects.equals(this.sessionId, that.sessionId) + && Objects.equals(this.user, that.user) + && Objects.equals(this.path, that.path) + && Objects.equals(this.mailboxId, that.mailboxId); + } + return false; + } + + @Override + public final int hashCode() { + return Objects.hash(eventId, sessionId, user, path, mailboxId); + } + } + + /** + * Indicates that a mailbox has been renamed. + */ + class MailboxRenamed extends MailboxEvent { + private final MailboxPath newPath; + + public MailboxRenamed(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, MailboxPath newPath, EventId eventId) { + super(sessionId, user, path, mailboxId, eventId); + this.newPath = newPath; + } + + @Override + public boolean isNoop() { + return newPath.equals(path); + } + + /** + * Gets the new name for this mailbox. + * + * @return name, not null + */ + public MailboxPath getNewPath() { + return newPath; + } + + @Override + public final boolean equals(Object o) { + if (o instanceof MailboxRenamed) { + MailboxRenamed that = (MailboxRenamed) o; + + return Objects.equals(this.eventId, that.eventId) + && Objects.equals(this.sessionId, that.sessionId) + && Objects.equals(this.user, that.user) + && Objects.equals(this.path, that.path) + && Objects.equals(this.mailboxId, that.mailboxId) + && Objects.equals(this.newPath, that.newPath); + } + return false; + } + + @Override + public final int hashCode() { + return Objects.hash(eventId, sessionId, user, path, mailboxId, newPath); + } + } + + + /** + * A mailbox event related to updated ACL + */ + class MailboxACLUpdated extends MailboxEvent { + private final ACLDiff aclDiff; + + public MailboxACLUpdated(MailboxSession.SessionId sessionId, User user, MailboxPath path, ACLDiff aclDiff, MailboxId mailboxId, EventId eventId) { + super(sessionId, user, path, mailboxId, eventId); + this.aclDiff = aclDiff; + } + + public ACLDiff getAclDiff() { + return aclDiff; + } + + @Override + public boolean isNoop() { + return aclDiff.getNewACL().equals(aclDiff.getOldACL()); + } + + @Override + public final boolean equals(Object o) { + if (o instanceof MailboxACLUpdated) { + MailboxACLUpdated that = (MailboxACLUpdated) o; + + return Objects.equals(this.eventId, that.eventId) + && Objects.equals(this.sessionId, that.sessionId) + && Objects.equals(this.user, that.user) + && Objects.equals(this.path, that.path) + && Objects.equals(this.aclDiff, that.aclDiff) + && Objects.equals(this.mailboxId, that.mailboxId); + } + return false; + } + + @Override + public final int hashCode() { + return Objects.hash(eventId, sessionId, user, path, aclDiff, mailboxId); + } + + } + + /** + * A mailbox event related to a message. + */ + abstract class MessageEvent extends MailboxEvent { + + public MessageEvent(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, EventId eventId) { + super(sessionId, user, path, mailboxId, eventId); + } + + /** + * Gets the message UIDs for the subject of this event. + * + * @return message uids + */ + public abstract Collection<MessageUid> getUids(); + } + + abstract class MetaDataHoldingEvent extends MessageEvent { + + public MetaDataHoldingEvent(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, EventId eventId) { + super(sessionId, user, path, mailboxId, eventId); + } + + /** + * Return the flags which were set for the affected message + * + * @return flags + */ + public abstract MessageMetaData getMetaData(MessageUid uid); + + } + + class Expunged extends MetaDataHoldingEvent { + private final Map<MessageUid, MessageMetaData> expunged; + + public Expunged(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, Map<MessageUid, MessageMetaData> uids, EventId eventId) { + super(sessionId, user, path, mailboxId, eventId); + this.expunged = ImmutableMap.copyOf(uids); + } + + @Override + public Collection<MessageUid> getUids() { + return expunged.keySet(); + } + + /** + * Return the flags which were set for the added message + * + * @return flags + */ + @Override + public MessageMetaData getMetaData(MessageUid uid) { + return expunged.get(uid); + } + + public Map<MessageUid, MessageMetaData> getExpunged() { + return expunged; + } + + @Override + public boolean isNoop() { + return expunged.isEmpty(); + } + + @Override + public final boolean equals(Object o) { + if (o instanceof Expunged) { + Expunged that = (Expunged) o; + + return Objects.equals(this.eventId, that.eventId) + && Objects.equals(this.sessionId, that.sessionId) + && Objects.equals(this.user, that.user) + && Objects.equals(this.path, that.path) + && Objects.equals(this.mailboxId, that.mailboxId) + && Objects.equals(this.expunged, that.expunged); + } + return false; + } + + @Override + public final int hashCode() { + return Objects.hash(eventId, sessionId, user, path, mailboxId, expunged); + } + } + + /** + * A mailbox event related to updated flags + */ + class FlagsUpdated extends MessageEvent { + private final List<MessageUid> uids; + private final List<UpdatedFlags> updatedFlags; + + public FlagsUpdated(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, List<UpdatedFlags> updatedFlags, + EventId eventId) { + super(sessionId, user, path, mailboxId, eventId); + this.updatedFlags = ImmutableList.copyOf(updatedFlags); + this.uids = updatedFlags.stream() + .map(UpdatedFlags::getUid) + .collect(Guavate.toImmutableList()); + } + + @Override + public Collection<MessageUid> getUids() { + return uids; + } + + public List<UpdatedFlags> getUpdatedFlags() { + return updatedFlags; + } + + @Override + public boolean isNoop() { + return updatedFlags.isEmpty(); + } + + @Override + public final boolean equals(Object o) { + if (o instanceof FlagsUpdated) { + FlagsUpdated that = (FlagsUpdated) o; + + return Objects.equals(this.eventId, that.eventId) + && Objects.equals(this.sessionId, that.sessionId) + && Objects.equals(this.user, that.user) + && Objects.equals(this.path, that.path) + && Objects.equals(this.mailboxId, that.mailboxId) + && Objects.equals(this.uids, that.uids) + && Objects.equals(this.updatedFlags, that.updatedFlags); + } + return false; + } + + @Override + public final int hashCode() { + return Objects.hash(eventId, sessionId, user, path, mailboxId, uids, updatedFlags); + } + } + + /** + * A mailbox event related to added message + */ + class Added extends MetaDataHoldingEvent { + private final Map<MessageUid, MessageMetaData> added; + + public Added(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, + SortedMap<MessageUid, MessageMetaData> uids, EventId eventId) { + super(sessionId, user, path, mailboxId, eventId); + this.added = ImmutableMap.copyOf(uids); + } + + /** + * Return the flags which were set for the added message + * + * @return flags + */ + public MessageMetaData getMetaData(MessageUid uid) { + return added.get(uid); + } + + @Override + public Collection<MessageUid> getUids() { + return added.keySet(); + } + + public Map<MessageUid, MessageMetaData> getAdded() { + return added; + } + + @Override + public boolean isNoop() { + return added.isEmpty(); + } + + @Override + public final boolean equals(Object o) { + if (o instanceof Added) { + Added that = (Added) o; + + return Objects.equals(this.eventId, that.eventId) + && Objects.equals(this.sessionId, that.sessionId) + && Objects.equals(this.user, that.user) + && Objects.equals(this.path, that.path) + && Objects.equals(this.mailboxId, that.mailboxId) + && Objects.equals(this.added, that.added); + } + return false; + } + + @Override + public final int hashCode() { + return Objects.hash(eventId, sessionId, user, path, mailboxId, added); + } + } + +} http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/main/java/org/apache/james/mailbox/events/MessageMoveEvent.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/events/MessageMoveEvent.java b/mailbox/api/src/main/java/org/apache/james/mailbox/events/MessageMoveEvent.java new file mode 100644 index 0000000..494f9ae --- /dev/null +++ b/mailbox/api/src/main/java/org/apache/james/mailbox/events/MessageMoveEvent.java @@ -0,0 +1,153 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ +package org.apache.james.mailbox.events; + +import java.util.Collection; +import java.util.Objects; +import java.util.Optional; + +import org.apache.james.core.User; +import org.apache.james.mailbox.MailboxSession; +import org.apache.james.mailbox.model.MailboxId; +import org.apache.james.mailbox.model.MessageId; +import org.apache.james.mailbox.model.MessageMoves; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; + +public class MessageMoveEvent implements Event { + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private ImmutableList.Builder<MessageId> messageIds; + private User user; + private MessageMoves messageMoves; + private Optional<EventId> eventId; + + private Builder() { + messageIds = ImmutableList.builder(); + eventId = Optional.empty(); + } + + public Builder session(MailboxSession session) { + this.user = session.getUser(); + return this; + } + + public Builder user(User user) { + this.user = user; + return this; + } + + public Builder messageMoves(MessageMoves messageMoves) { + this.messageMoves = messageMoves; + return this; + } + + public Builder messageId(MessageId messageId) { + this.messageIds.add(messageId); + return this; + } + + public Builder eventId(EventId eventId) { + this.eventId = Optional.of(eventId); + return this; + } + + public Builder messageId(Iterable<MessageId> messageIds) { + this.messageIds.addAll(messageIds); + return this; + } + + public MessageMoveEvent build() { + Preconditions.checkNotNull(user, "'user' is mandatory"); + Preconditions.checkNotNull(messageMoves, "'messageMoves' is mandatory"); + + return new MessageMoveEvent(eventId.orElse(EventId.random()), user, messageMoves, messageIds.build()); + } + } + + private final EventId eventId; + private final User user; + private final MessageMoves messageMoves; + private final Collection<MessageId> messageIds; + + @VisibleForTesting + MessageMoveEvent(EventId eventId, User user, MessageMoves messageMoves, Collection<MessageId> messageIds) { + this.eventId = eventId; + this.user = user; + this.messageMoves = messageMoves; + this.messageIds = messageIds; + } + + @Override + public boolean isNoop() { + return messageIds.isEmpty(); + } + + public Collection<MessageId> getMessageIds() { + return messageIds; + } + + @Override + public EventId getEventId() { + return eventId; + } + + @Override + public User getUser() { + return user; + } + + public MessageMoves getMessageMoves() { + return messageMoves; + } + + public boolean isMoveTo(MailboxId mailboxId) { + return messageMoves.addedMailboxIds() + .contains(mailboxId); + } + + public boolean isMoveFrom(MailboxId mailboxId) { + return messageMoves.removedMailboxIds() + .contains(mailboxId); + } + + @Override + public final boolean equals(Object o) { + if (o instanceof MessageMoveEvent) { + MessageMoveEvent that = (MessageMoveEvent) o; + + return Objects.equals(this.eventId, that.eventId) + && Objects.equals(this.user, that.user) + && Objects.equals(this.messageMoves, that.messageMoves) + && Objects.equals(this.messageIds, that.messageIds); + } + return false; + } + + @Override + public final int hashCode() { + return Objects.hash(eventId, user, messageMoves, messageIds); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/EventTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/EventTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/EventTest.java index 62e6399..94530c6 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/EventTest.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/EventTest.java @@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.UUID; +import org.apache.james.mailbox.events.Event; import org.junit.jupiter.api.Test; import nl.jqno.equalsverifier.EqualsVerifier; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxListenerTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxListenerTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxListenerTest.java index 9db71ba..57957ac 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxListenerTest.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxListenerTest.java @@ -32,6 +32,8 @@ import org.apache.james.core.User; import org.apache.james.core.quota.QuotaCount; import org.apache.james.core.quota.QuotaSize; import org.apache.james.mailbox.acl.ACLDiff; +import org.apache.james.mailbox.events.Event; +import org.apache.james.mailbox.events.MailboxListener; import org.apache.james.mailbox.model.MailboxACL; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.MessageMetaData; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java index 12dcce1..97e0103 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java @@ -33,6 +33,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.apache.james.mailbox.events.EventBus; import org.apache.james.mailbox.events.MailboxIdRegistrationKey; +import org.apache.james.mailbox.events.MailboxListener; import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.model.ComposedMessageId; import org.apache.james.mailbox.model.MailboxId; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java index 8a3d351..9681936 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java @@ -37,6 +37,8 @@ import org.apache.james.mailbox.MailboxManager.MailboxCapabilities; import org.apache.james.mailbox.MessageManager.AppendCommand; import org.apache.james.mailbox.events.EventBus; import org.apache.james.mailbox.events.MailboxIdRegistrationKey; +import org.apache.james.mailbox.events.MailboxListener; +import org.apache.james.mailbox.events.MessageMoveEvent; import org.apache.james.mailbox.exception.AnnotationException; import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.exception.TooLongMailboxNameException; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/MessageMoveEventTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MessageMoveEventTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MessageMoveEventTest.java index db85d82..ad422d8 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/MessageMoveEventTest.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MessageMoveEventTest.java @@ -22,8 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.apache.james.core.User; -import org.apache.james.mailbox.MailboxSession; -import org.apache.james.mailbox.MailboxSessionUtil; +import org.apache.james.mailbox.events.MessageMoveEvent; import org.apache.james.mailbox.model.MessageMoves; import org.apache.james.mailbox.model.TestId; import org.apache.james.mailbox.model.TestMessageId; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java index be4b7ef..3bc1304 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java @@ -36,8 +36,6 @@ import java.util.List; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.james.mailbox.Event; -import org.apache.james.mailbox.MailboxListener; import org.apache.james.mailbox.util.EventCollector; import org.assertj.core.api.SoftAssertions; import org.junit.jupiter.api.Test; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java index e93c96c..798d765 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java @@ -27,8 +27,6 @@ import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import org.apache.james.core.User; -import org.apache.james.mailbox.Event; -import org.apache.james.mailbox.MailboxListener; import org.apache.james.mailbox.MailboxSession; import org.apache.james.mailbox.model.MailboxConstants; import org.apache.james.mailbox.model.MailboxId; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventDeadLettersContract.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventDeadLettersContract.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventDeadLettersContract.java index e2282a1..aef0100 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventDeadLettersContract.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventDeadLettersContract.java @@ -31,8 +31,6 @@ import java.util.stream.IntStream; import java.util.stream.Stream; import org.apache.james.core.User; -import org.apache.james.mailbox.Event; -import org.apache.james.mailbox.MailboxListener; import org.apache.james.mailbox.MailboxSession; import org.apache.james.mailbox.model.MailboxConstants; import org.apache.james.mailbox.model.MailboxPath; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java index 159094b..491fa88 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java @@ -43,8 +43,6 @@ import static org.mockito.Mockito.when; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.james.core.User; -import org.apache.james.mailbox.Event; -import org.apache.james.mailbox.MailboxListener; import org.apache.james.mailbox.MailboxSession; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.TestId; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java index 26ece3b..b457e6d 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java @@ -45,8 +45,6 @@ import java.time.Duration; import java.util.concurrent.CountDownLatch; import org.apache.james.core.User; -import org.apache.james.mailbox.Event; -import org.apache.james.mailbox.MailboxListener; import org.apache.james.mailbox.MailboxSession; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.TestId; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMovesTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMovesTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMovesTest.java index 3a76147..8787db5 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMovesTest.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMovesTest.java @@ -19,7 +19,7 @@ package org.apache.james.mailbox.model; -import org.apache.james.mailbox.MessageMoveEvent; +import org.apache.james.mailbox.events.MessageMoveEvent; import org.junit.jupiter.api.Test; import nl.jqno.equalsverifier.EqualsVerifier; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/util/EventCollector.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/util/EventCollector.java b/mailbox/api/src/test/java/org/apache/james/mailbox/util/EventCollector.java index f2f3c42..392cc95 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/util/EventCollector.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/util/EventCollector.java @@ -22,9 +22,9 @@ package org.apache.james.mailbox.util; import java.util.ArrayList; import java.util.List; -import org.apache.james.mailbox.Event; -import org.apache.james.mailbox.MailboxListener; +import org.apache.james.mailbox.events.Event; import org.apache.james.mailbox.events.Group; +import org.apache.james.mailbox.events.MailboxListener; public class EventCollector implements MailboxListener.GroupMailboxListener { private static class EventCollectorGroup extends Group {} http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java ---------------------------------------------------------------------- diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java index e3f38c8..7e39cc0 100644 --- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java +++ b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java @@ -1,9 +1,9 @@ package org.apache.james.mailbox.caching; -import org.apache.james.mailbox.Event; -import org.apache.james.mailbox.MailboxListener; +import org.apache.james.mailbox.events.Event; import org.apache.james.mailbox.events.EventBus; import org.apache.james.mailbox.events.Group; +import org.apache.james.mailbox.events.MailboxListener; import org.apache.james.mailbox.exception.MailboxException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/MailboxOperationLoggingListener.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/MailboxOperationLoggingListener.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/MailboxOperationLoggingListener.java index 660a748..26537a3 100644 --- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/MailboxOperationLoggingListener.java +++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/MailboxOperationLoggingListener.java @@ -23,9 +23,9 @@ import static org.apache.james.mailbox.cassandra.GhostMailbox.MAILBOX_ID; import static org.apache.james.mailbox.cassandra.GhostMailbox.MAILBOX_NAME; import static org.apache.james.mailbox.cassandra.GhostMailbox.TYPE; -import org.apache.james.mailbox.Event; -import org.apache.james.mailbox.MailboxListener; +import org.apache.james.mailbox.events.Event; import org.apache.james.mailbox.events.Group; +import org.apache.james.mailbox.events.MailboxListener; /** * See https://issues.apache.org/jira/browse/MAILBOX-322 for reading about the Ghost mailbox bug. http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/InVMEventBus.java ---------------------------------------------------------------------- diff --git a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/InVMEventBus.java b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/InVMEventBus.java index 5da4adb..ae58755 100644 --- a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/InVMEventBus.java +++ b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/InVMEventBus.java @@ -24,8 +24,6 @@ import java.util.concurrent.ConcurrentHashMap; import javax.inject.Inject; -import org.apache.james.mailbox.Event; -import org.apache.james.mailbox.MailboxListener; import org.apache.james.mailbox.events.delivery.EventDelivery; import org.apache.james.mailbox.events.delivery.EventDelivery.PermanentFailureHandler.StoreToDeadLetters; import org.apache.james.mailbox.events.delivery.EventDelivery.Retryer.BackoffRetryer; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/MemoryEventDeadLetters.java ---------------------------------------------------------------------- diff --git a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/MemoryEventDeadLetters.java b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/MemoryEventDeadLetters.java index 122763a..45fff05 100644 --- a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/MemoryEventDeadLetters.java +++ b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/MemoryEventDeadLetters.java @@ -19,8 +19,6 @@ package org.apache.james.mailbox.events; -import org.apache.james.mailbox.Event; - import com.google.common.base.Preconditions; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/EventDelivery.java ---------------------------------------------------------------------- diff --git a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/EventDelivery.java b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/EventDelivery.java index e34cb31..c30a709 100644 --- a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/EventDelivery.java +++ b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/EventDelivery.java @@ -24,10 +24,10 @@ import static org.apache.james.mailbox.events.delivery.EventDelivery.Retryer.NO_ import java.time.Duration; -import org.apache.james.mailbox.Event; -import org.apache.james.mailbox.MailboxListener; +import org.apache.james.mailbox.events.Event; import org.apache.james.mailbox.events.EventDeadLetters; import org.apache.james.mailbox.events.Group; +import org.apache.james.mailbox.events.MailboxListener; import org.apache.james.mailbox.events.RetryBackoffConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java ---------------------------------------------------------------------- diff --git a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java index f0b1b1e..6cdbe28 100644 --- a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java +++ b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java @@ -25,9 +25,9 @@ import java.io.Closeable; import javax.inject.Inject; -import org.apache.james.mailbox.Event; -import org.apache.james.mailbox.MailboxListener; +import org.apache.james.mailbox.events.Event; import org.apache.james.mailbox.events.EventBus; +import org.apache.james.mailbox.events.MailboxListener; import org.apache.james.metrics.api.MetricFactory; import org.apache.james.metrics.api.TimeMetric; import org.apache.james.util.MDCBuilder; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/InVmEventDeliveryTest.java ---------------------------------------------------------------------- diff --git a/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/InVmEventDeliveryTest.java b/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/InVmEventDeliveryTest.java index dc122f6..08d22c9 100644 --- a/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/InVmEventDeliveryTest.java +++ b/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/InVmEventDeliveryTest.java @@ -31,7 +31,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; -import org.apache.james.mailbox.MailboxListener; +import org.apache.james.mailbox.events.MailboxListener; import org.apache.james.mailbox.events.MemoryEventDeadLetters; import org.apache.james.mailbox.events.RetryBackoffConfiguration; import org.apache.james.mailbox.events.delivery.EventDelivery.DeliveryOption; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/EventDispatcher.java ---------------------------------------------------------------------- diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/EventDispatcher.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/EventDispatcher.java index f1cc7d3..e6f6e1d 100644 --- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/EventDispatcher.java +++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/EventDispatcher.java @@ -29,8 +29,6 @@ import java.util.Set; import org.apache.commons.lang3.tuple.Pair; import org.apache.james.event.json.EventSerializer; -import org.apache.james.mailbox.Event; -import org.apache.james.mailbox.MailboxListener; import org.apache.james.util.MDCBuilder; import org.apache.james.util.MDCStructuredLogger; import org.apache.james.util.StructuredLogger; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupConsumerRetry.java ---------------------------------------------------------------------- diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupConsumerRetry.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupConsumerRetry.java index 9171436..1087d9a 100644 --- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupConsumerRetry.java +++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupConsumerRetry.java @@ -25,7 +25,6 @@ import static org.apache.james.backend.rabbitmq.Constants.EMPTY_ROUTING_KEY; import static org.apache.james.mailbox.events.GroupRegistration.RETRY_COUNT; import static org.apache.james.mailbox.events.RabbitMQEventBus.MAILBOX_EVENT; -import org.apache.james.mailbox.Event; import org.apache.james.util.MDCStructuredLogger; import org.apache.james.util.StructuredLogger; import org.slf4j.Logger; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java ---------------------------------------------------------------------- diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java index 5a9bdf0..426ae46 100644 --- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java +++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java @@ -32,8 +32,6 @@ import java.util.Objects; import java.util.Optional; import org.apache.james.event.json.EventSerializer; -import org.apache.james.mailbox.Event; -import org.apache.james.mailbox.MailboxListener; import org.apache.james.util.MDCBuilder; import com.github.fge.lambdas.Throwing; http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistrationHandler.java ---------------------------------------------------------------------- diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistrationHandler.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistrationHandler.java index 1950aab..05f4e09 100644 --- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistrationHandler.java +++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistrationHandler.java @@ -23,7 +23,6 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.james.event.json.EventSerializer; -import org.apache.james.mailbox.MailboxListener; import com.rabbitmq.client.Connection; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
