You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2018/10/15 06:28:24 UTC
[01/17] james-project git commit: JAMES-2155 Implements a JPA Sieve
Repository
Repository: james-project
Updated Branches:
refs/heads/master 02f8d6f73 -> 45d311c55
JAMES-2155 Implements a JPA Sieve Repository
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/d5d5c9cb
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/d5d5c9cb
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/d5d5c9cb
Branch: refs/heads/master
Commit: d5d5c9cb86dce4edda511b2a43a9e753ca777256
Parents: 02f8d6f
Author: Sebastian Górecki <go...@gmail.com>
Authored: Wed Sep 5 22:53:19 2018 +0200
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:15:22 2018 +0700
----------------------------------------------------------------------
.../james/backends/jpa/TransactionRunner.java | 18 +
server/container/guice/guice-common/pom.xml | 4 +
.../modules/data/SieveJPARepositoryModules.java | 37 ++
.../org/apache/james/JPAJamesServerMain.java | 8 +-
server/data/data-jpa/pom.xml | 8 +-
.../james/sieve/jpa/JPASieveRepository.java | 344 +++++++++++++++++++
.../james/sieve/jpa/model/JPASieveQuota.java | 97 ++++++
.../james/sieve/jpa/model/JPASieveScript.java | 200 +++++++++++
.../src/main/resources/META-INF/persistence.xml | 2 +
.../james/sieve/jpa/JpaSieveRepositoryTest.java | 50 +++
.../lib/AbstractSieveRepositoryTest.java | 7 +
11 files changed, 769 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/d5d5c9cb/backends-common/jpa/src/main/java/org/apache/james/backends/jpa/TransactionRunner.java
----------------------------------------------------------------------
diff --git a/backends-common/jpa/src/main/java/org/apache/james/backends/jpa/TransactionRunner.java b/backends-common/jpa/src/main/java/org/apache/james/backends/jpa/TransactionRunner.java
index dae6f2e..dd1e151 100644
--- a/backends-common/jpa/src/main/java/org/apache/james/backends/jpa/TransactionRunner.java
+++ b/backends-common/jpa/src/main/java/org/apache/james/backends/jpa/TransactionRunner.java
@@ -76,4 +76,22 @@ public class TransactionRunner {
}
}
+ public <T> void runAndHandleException(Consumer<EntityManager> runnable,
+ Function<PersistenceException, T> errorHandler) {
+ EntityManager entityManager = entityManagerFactory.createEntityManager();
+ EntityTransaction transaction = entityManager.getTransaction();
+ try {
+ transaction.begin();
+ runnable.accept(entityManager);
+ transaction.commit();
+ } catch (PersistenceException e) {
+ LOGGER.warn("Could not execute transaction", e);
+ if (transaction.isActive()) {
+ transaction.rollback();
+ }
+ errorHandler.apply(e);
+ } finally {
+ entityManager.close();
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/d5d5c9cb/server/container/guice/guice-common/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/pom.xml b/server/container/guice/guice-common/pom.xml
index b7bdd99..0559b85 100644
--- a/server/container/guice/guice-common/pom.xml
+++ b/server/container/guice/guice-common/pom.xml
@@ -51,6 +51,10 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>james-server-data-jpa</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>james-server-data-memory</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/d5d5c9cb/server/container/guice/guice-common/src/main/java/org/apache/james/modules/data/SieveJPARepositoryModules.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/data/SieveJPARepositoryModules.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/data/SieveJPARepositoryModules.java
new file mode 100644
index 0000000..2d984e3
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/data/SieveJPARepositoryModules.java
@@ -0,0 +1,37 @@
+/****************************************************************
+ * 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.modules.data;
+
+import org.apache.james.sieve.jpa.JPASieveRepository;
+import org.apache.james.sieverepository.api.SieveQuotaRepository;
+import org.apache.james.sieverepository.api.SieveRepository;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Scopes;
+
+public class SieveJPARepositoryModules extends AbstractModule {
+ @Override
+ protected void configure() {
+ bind(JPASieveRepository.class).in(Scopes.SINGLETON);
+
+ bind(SieveRepository.class).to(JPASieveRepository.class);
+ bind(SieveQuotaRepository.class).to(JPASieveRepository.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/d5d5c9cb/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
index 61eba68..6a5ba46 100644
--- a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
+++ b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
@@ -22,7 +22,7 @@ package org.apache.james;
import org.apache.james.modules.MailboxModule;
import org.apache.james.modules.activemq.ActiveMQQueueModule;
import org.apache.james.modules.data.JPADataModule;
-import org.apache.james.modules.data.SieveFileRepositoryModule;
+import org.apache.james.modules.data.SieveJPARepositoryModules;
import org.apache.james.modules.mailbox.DefaultEventModule;
import org.apache.james.modules.mailbox.JPAMailboxModule;
import org.apache.james.modules.mailbox.LuceneSearchMailboxModule;
@@ -69,7 +69,7 @@ public class JPAJamesServerMain {
new ProtocolHandlerModule(),
new SMTPServerModule(),
WEBADMIN);
-
+
public static final Module JPA_SERVER_MODULE = Modules.combine(
new ActiveMQQueueModule(),
new DefaultProcessorsConfigurationProviderModule(),
@@ -79,7 +79,7 @@ public class JPAJamesServerMain {
new MailboxModule(),
new NoJwtModule(),
new RawPostDequeueDecoratorModule(),
- new SieveFileRepositoryModule(),
+ new SieveJPARepositoryModules(),
new DefaultEventModule(),
new SpamAssassinListenerModule());
@@ -90,7 +90,7 @@ public class JPAJamesServerMain {
GuiceJamesServer server = GuiceJamesServer.forConfiguration(configuration)
.combineWith(JPA_SERVER_MODULE, PROTOCOLS,
- new JMXServerModule(),
+ new JMXServerModule(),
new LuceneSearchMailboxModule());
server.start();
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/d5d5c9cb/server/data/data-jpa/pom.xml
----------------------------------------------------------------------
diff --git a/server/data/data-jpa/pom.xml b/server/data/data-jpa/pom.xml
index cb0cd25..5d1c3ad 100644
--- a/server/data/data-jpa/pom.xml
+++ b/server/data/data-jpa/pom.xml
@@ -152,7 +152,9 @@
<artifactId>openjpa-maven-plugin</artifactId>
<version>${apache.openjpa.version}</version>
<configuration>
- <includes>org/apache/james/user/jpa/model/JPAUser.class,
+ <includes>org/apache/james/sieve/jpa/model/JPASieveQuota.class,
+ org/apache/james/sieve/jpa/model/JPASieveScript.class,
+ org/apache/james/user/jpa/model/JPAUser.class,
org/apache/james/rrt/jpa/model/JPARecipientRewrite.class,
org/apache/james/domainlist/jpa/model/JPADomain.class,
org/apache/james/mailrepository/jpa/JPAUrl.class</includes>
@@ -165,7 +167,9 @@
</property>
<property>
<name>metaDataFactory</name>
- <value>jpa(Types=org.apache.james.user.jpa.model.JPAUser;
+ <value>jpa(Types=org.apache.james.sieve.jpa.model.JPASieveQuota;
+ org.apache.james.sieve.jpa.model.JPASieveScript;
+ org.apache.james.user.jpa.model.JPAUser;
org.apache.james.rrt.jpa.model.JPARecipientRewrite;
org.apache.james.domainlist.jpa.model.JPADomain;
org.apache.james.mailrepository.jpa.JPAUrl)</value>
http://git-wip-us.apache.org/repos/asf/james-project/blob/d5d5c9cb/server/data/data-jpa/src/main/java/org/apache/james/sieve/jpa/JPASieveRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-jpa/src/main/java/org/apache/james/sieve/jpa/JPASieveRepository.java b/server/data/data-jpa/src/main/java/org/apache/james/sieve/jpa/JPASieveRepository.java
new file mode 100644
index 0000000..31c634a
--- /dev/null
+++ b/server/data/data-jpa/src/main/java/org/apache/james/sieve/jpa/JPASieveRepository.java
@@ -0,0 +1,344 @@
+/****************************************************************
+ * 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.sieve.jpa;
+
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.time.ZonedDateTime;
+import java.util.List;
+import java.util.Optional;
+import java.util.function.Function;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.NoResultException;
+import javax.persistence.PersistenceException;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.james.backends.jpa.TransactionRunner;
+import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaSize;
+import org.apache.james.sieve.jpa.model.JPASieveQuota;
+import org.apache.james.sieve.jpa.model.JPASieveScript;
+import org.apache.james.sieverepository.api.ScriptContent;
+import org.apache.james.sieverepository.api.ScriptName;
+import org.apache.james.sieverepository.api.ScriptSummary;
+import org.apache.james.sieverepository.api.SieveRepository;
+import org.apache.james.sieverepository.api.exception.DuplicateException;
+import org.apache.james.sieverepository.api.exception.IsActiveException;
+import org.apache.james.sieverepository.api.exception.QuotaExceededException;
+import org.apache.james.sieverepository.api.exception.QuotaNotFoundException;
+import org.apache.james.sieverepository.api.exception.ScriptNotFoundException;
+import org.apache.james.sieverepository.api.exception.StorageException;
+import org.apache.james.util.OptionalUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.github.fge.lambdas.Throwing;
+import com.google.common.collect.ImmutableList;
+
+public class JPASieveRepository implements SieveRepository {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(JPASieveRepository.class);
+ private static final String DEFAULT_SIEVE_QUOTA_USERNAME = "default.quota";
+
+ private final TransactionRunner transactionRunner;
+
+ @Inject
+ public JPASieveRepository(EntityManagerFactory entityManagerFactory) {
+ this.transactionRunner = new TransactionRunner(entityManagerFactory);
+ }
+
+ @Override
+ public void haveSpace(User user, ScriptName name, long size) throws QuotaExceededException, StorageException {
+ long usedSpace = findAllSieveScriptsForUser(user).stream()
+ .filter(sieveScript -> !sieveScript.getScriptName().equals(name.getValue()))
+ .mapToLong(JPASieveScript::getScriptSize)
+ .sum();
+
+ QuotaSize quota = limitToUser(user);
+ if (overQuotaAfterModification(usedSpace, size, quota)) {
+ throw new QuotaExceededException();
+ }
+ }
+
+ private QuotaSize limitToUser(User user) throws StorageException {
+ return OptionalUtils.orSuppliers(
+ Throwing.supplier(() -> findQuotaForUser(user.asString())).sneakyThrow(),
+ Throwing.supplier(() -> findQuotaForUser(DEFAULT_SIEVE_QUOTA_USERNAME)).sneakyThrow())
+ .map(JPASieveQuota::toQuotaSize)
+ .orElse(QuotaSize.unlimited());
+ }
+
+ private boolean overQuotaAfterModification(long usedSpace, long size, QuotaSize quota) {
+ return QuotaSize.size(usedSpace)
+ .add(size)
+ .isGreaterThan(quota);
+ }
+
+ @Override
+ public void putScript(User user, ScriptName name, ScriptContent content) throws StorageException, QuotaExceededException {
+ transactionRunner.runAndHandleException(Throwing.<EntityManager>consumer(entityManager -> {
+ try {
+ haveSpace(user, name, content.length());
+ JPASieveScript jpaSieveScript = JPASieveScript.builder()
+ .username(user.asString())
+ .scriptName(name.getValue())
+ .scriptContent(content)
+ .build();
+ entityManager.persist(jpaSieveScript);
+ } catch (QuotaExceededException | StorageException e) {
+ rollbackTransactionIfActive(entityManager.getTransaction());
+ throw e;
+ }
+ }).sneakyThrow(), throwStorageException("Unable to put script for user " + user.asString()));
+ }
+
+ @Override
+ public List<ScriptSummary> listScripts(User user) throws StorageException {
+ return findAllSieveScriptsForUser(user).stream()
+ .map(JPASieveScript::toSummary)
+ .collect(ImmutableList.toImmutableList());
+ }
+
+ private List<JPASieveScript> findAllSieveScriptsForUser(User user) throws StorageException {
+ return transactionRunner.runAndRetrieveResult(entityManager -> {
+ List<JPASieveScript> sieveScripts = entityManager.createNamedQuery("findAllByUsername", JPASieveScript.class)
+ .setParameter("username", user.asString()).getResultList();
+ return Optional.ofNullable(sieveScripts).orElse(ImmutableList.of());
+ }, throwStorageException("Unable to list scripts for user " + user.asString()));
+ }
+
+ @Override
+ public ZonedDateTime getActivationDateForActiveScript(User user) throws StorageException, ScriptNotFoundException {
+ Optional<JPASieveScript> script = findActiveSieveScript(user);
+ JPASieveScript activeSieveScript = script.orElseThrow(() -> new ScriptNotFoundException("Unable to find active script for user " + user.asString()));
+ return activeSieveScript.getActivationDateTime().toZonedDateTime();
+ }
+
+ @Override
+ public InputStream getActive(User user) throws ScriptNotFoundException, StorageException {
+ Optional<JPASieveScript> script = findActiveSieveScript(user);
+ JPASieveScript activeSieveScript = script.orElseThrow(() -> new ScriptNotFoundException("Unable to find active script for user " + user.asString()));
+ return IOUtils.toInputStream(activeSieveScript.getScriptContent(), StandardCharsets.UTF_8);
+ }
+
+ private Optional<JPASieveScript> findActiveSieveScript(User user) throws StorageException {
+ return transactionRunner.runAndRetrieveResult(
+ Throwing.<EntityManager, Optional<JPASieveScript>>function(entityManager -> findActiveSieveScript(user, entityManager)).sneakyThrow(),
+ throwStorageException("Unable to find active script for user " + user.asString()));
+ }
+
+ private Optional<JPASieveScript> findActiveSieveScript(User user, EntityManager entityManager) throws StorageException {
+ try {
+ JPASieveScript activeSieveScript = entityManager.createNamedQuery("findActiveByUsername", JPASieveScript.class)
+ .setParameter("username", user.asString()).getSingleResult();
+ return Optional.ofNullable(activeSieveScript);
+ } catch (NoResultException e) {
+ LOGGER.debug("Sieve script not found for user {}", user.asString());
+ return Optional.empty();
+ }
+ }
+
+ @Override
+ public void setActive(User user, ScriptName name) throws ScriptNotFoundException, StorageException {
+ transactionRunner.runAndHandleException(Throwing.<EntityManager>consumer(entityManager -> {
+ try {
+ if (SieveRepository.NO_SCRIPT_NAME.equals(name)) {
+ switchOffActiveScript(user, entityManager);
+ } else {
+ setActiveScript(user, name, entityManager);
+ }
+ } catch (StorageException | ScriptNotFoundException e) {
+ rollbackTransactionIfActive(entityManager.getTransaction());
+ throw e;
+ }
+ }).sneakyThrow(), throwStorageException("Unable to set active script " + name.getValue() + " for user " + user.asString()));
+ }
+
+ private void switchOffActiveScript(User user, EntityManager entityManager) throws StorageException {
+ Optional<JPASieveScript> activeSieveScript = findActiveSieveScript(user, entityManager);
+ activeSieveScript.ifPresent(JPASieveScript::deactivate);
+ }
+
+ private void setActiveScript(User user, ScriptName name, EntityManager entityManager) throws StorageException, ScriptNotFoundException {
+ JPASieveScript sieveScript = findSieveScript(user, name, entityManager)
+ .orElseThrow(() -> new ScriptNotFoundException("Unable to find script " + name.getValue() + " for user " + user.asString()));
+ findActiveSieveScript(user, entityManager).ifPresent(JPASieveScript::deactivate);
+ sieveScript.activate();
+ }
+
+ @Override
+ public InputStream getScript(User user, ScriptName name) throws ScriptNotFoundException, StorageException {
+ Optional<JPASieveScript> script = findSieveScript(user, name);
+ JPASieveScript sieveScript = script.orElseThrow(() -> new ScriptNotFoundException("Unable to find script " + name.getValue() + " for user " + user.asString()));
+ return IOUtils.toInputStream(sieveScript.getScriptContent(), StandardCharsets.UTF_8);
+ }
+
+ private Optional<JPASieveScript> findSieveScript(User user, ScriptName scriptName) throws StorageException {
+ return transactionRunner.runAndRetrieveResult(entityManager -> findSieveScript(user, scriptName, entityManager),
+ throwStorageException("Unable to find script " + scriptName.getValue() + " for user " + user.asString()));
+ }
+
+ private Optional<JPASieveScript> findSieveScript(User user, ScriptName scriptName, EntityManager entityManager) {
+ try {
+ JPASieveScript sieveScript = entityManager.createNamedQuery("findSieveScript", JPASieveScript.class)
+ .setParameter("username", user.asString())
+ .setParameter("scriptName", scriptName.getValue()).getSingleResult();
+ return Optional.ofNullable(sieveScript);
+ } catch (NoResultException e) {
+ LOGGER.debug("Sieve script not found for user {}", user.asString());
+ return Optional.empty();
+ }
+ }
+
+ @Override
+ public void deleteScript(User user, ScriptName name) throws ScriptNotFoundException, IsActiveException, StorageException {
+ transactionRunner.runAndHandleException(Throwing.<EntityManager>consumer(entityManager -> {
+ Optional<JPASieveScript> sieveScript = findSieveScript(user, name, entityManager);
+ if (!sieveScript.isPresent()) {
+ rollbackTransactionIfActive(entityManager.getTransaction());
+ throw new ScriptNotFoundException("Unable to find script " + name.getValue() + " for user " + user.asString());
+ }
+ JPASieveScript sieveScriptToRemove = sieveScript.get();
+ if (sieveScriptToRemove.isActive()) {
+ rollbackTransactionIfActive(entityManager.getTransaction());
+ throw new IsActiveException("Unable to delete active script " + name.getValue() + " for user " + user.asString());
+ }
+ entityManager.remove(sieveScriptToRemove);
+ }).sneakyThrow(), throwStorageException("Unable to delete script " + name.getValue() + " for user " + user.asString()));
+ }
+
+ @Override
+ public void renameScript(User user, ScriptName oldName, ScriptName newName) throws ScriptNotFoundException, DuplicateException, StorageException {
+ transactionRunner.runAndHandleException(Throwing.<EntityManager>consumer(entityManager -> {
+ Optional<JPASieveScript> sieveScript = findSieveScript(user, oldName, entityManager);
+ if (!sieveScript.isPresent()) {
+ rollbackTransactionIfActive(entityManager.getTransaction());
+ throw new ScriptNotFoundException("Unable to find script " + oldName.getValue() + " for user " + user.asString());
+ }
+
+ Optional<JPASieveScript> duplicatedSieveScript = findSieveScript(user, newName, entityManager);
+ if (duplicatedSieveScript.isPresent()) {
+ rollbackTransactionIfActive(entityManager.getTransaction());
+ throw new DuplicateException("Unable to rename script. Duplicate found " + newName.getValue() + " for user " + user.asString());
+ }
+
+ JPASieveScript sieveScriptToRename = sieveScript.get();
+ sieveScriptToRename.renameTo(newName);
+ }).sneakyThrow(), throwStorageException("Unable to rename script " + oldName.getValue() + " for user " + user.asString()));
+ }
+
+ private void rollbackTransactionIfActive(EntityTransaction transaction) {
+ if (transaction.isActive()) {
+ transaction.rollback();
+ }
+ }
+
+ @Override
+ public boolean hasDefaultQuota() throws StorageException {
+ Optional<JPASieveQuota> defaultQuota = findQuotaForUser(DEFAULT_SIEVE_QUOTA_USERNAME);
+ return defaultQuota.isPresent();
+ }
+
+ @Override
+ public QuotaSize getDefaultQuota() throws QuotaNotFoundException, StorageException {
+ JPASieveQuota jpaSieveQuota = findQuotaForUser(DEFAULT_SIEVE_QUOTA_USERNAME)
+ .orElseThrow(() -> new QuotaNotFoundException("Unable to find quota for default user"));
+ return QuotaSize.size(jpaSieveQuota.getSize());
+ }
+
+ @Override
+ public void setDefaultQuota(QuotaSize quota) throws StorageException {
+ setQuotaForUser(DEFAULT_SIEVE_QUOTA_USERNAME, quota);
+ }
+
+ @Override
+ public void removeQuota() throws QuotaNotFoundException, StorageException {
+ removeQuotaForUser(DEFAULT_SIEVE_QUOTA_USERNAME);
+ }
+
+ @Override
+ public boolean hasQuota(User user) throws StorageException {
+ Optional<JPASieveQuota> quotaForUser = findQuotaForUser(user.asString());
+ return quotaForUser.isPresent();
+ }
+
+ @Override
+ public QuotaSize getQuota(User user) throws QuotaNotFoundException, StorageException {
+ JPASieveQuota jpaSieveQuota = findQuotaForUser(user.asString())
+ .orElseThrow(() -> new QuotaNotFoundException("Unable to find quota for user " + user.asString()));
+ return QuotaSize.size(jpaSieveQuota.getSize());
+ }
+
+ @Override
+ public void setQuota(User user, QuotaSize quota) throws StorageException {
+ setQuotaForUser(user.asString(), quota);
+ }
+
+ @Override
+ public void removeQuota(User user) throws QuotaNotFoundException, StorageException {
+ removeQuotaForUser(user.asString());
+ }
+
+ private Optional<JPASieveQuota> findQuotaForUser(String username) throws StorageException {
+ return transactionRunner.runAndRetrieveResult(entityManager -> findQuotaForUser(username, entityManager),
+ throwStorageException("Unable to find quota for user " + username));
+ }
+
+ private <T> Function<PersistenceException, T> throwStorageException(String message) {
+ return Throwing.<PersistenceException, T>function(e -> {
+ throw new StorageException(message, e);
+ }).sneakyThrow();
+ }
+
+ private Optional<JPASieveQuota> findQuotaForUser(String username, EntityManager entityManager) {
+ try {
+ JPASieveQuota sieveQuota = entityManager.createNamedQuery("findByUsername", JPASieveQuota.class)
+ .setParameter("username", username).getSingleResult();
+ return Optional.of(sieveQuota);
+ } catch (NoResultException e) {
+ return Optional.empty();
+ }
+ }
+
+ private void setQuotaForUser(String username, QuotaSize quota) throws StorageException {
+ transactionRunner.runAndHandleException(Throwing.consumer(entityManager -> {
+ Optional<JPASieveQuota> sieveQuota = findQuotaForUser(username, entityManager);
+ if (sieveQuota.isPresent()) {
+ JPASieveQuota jpaSieveQuota = sieveQuota.get();
+ jpaSieveQuota.setSize(quota);
+ entityManager.merge(jpaSieveQuota);
+ } else {
+ JPASieveQuota jpaSieveQuota = new JPASieveQuota(username, quota.asLong());
+ entityManager.persist(jpaSieveQuota);
+ }
+ }), throwStorageException("Unable to set quota for user " + username));
+ }
+
+ private void removeQuotaForUser(String username) throws StorageException {
+ transactionRunner.runAndHandleException(Throwing.consumer(entityManager -> {
+ Optional<JPASieveQuota> quotaForUser = findQuotaForUser(username, entityManager);
+ quotaForUser.ifPresent(entityManager::remove);
+ }), throwStorageException("Unable to remove quota for user " + username));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/d5d5c9cb/server/data/data-jpa/src/main/java/org/apache/james/sieve/jpa/model/JPASieveQuota.java
----------------------------------------------------------------------
diff --git a/server/data/data-jpa/src/main/java/org/apache/james/sieve/jpa/model/JPASieveQuota.java b/server/data/data-jpa/src/main/java/org/apache/james/sieve/jpa/model/JPASieveQuota.java
new file mode 100644
index 0000000..9c5e097
--- /dev/null
+++ b/server/data/data-jpa/src/main/java/org/apache/james/sieve/jpa/model/JPASieveQuota.java
@@ -0,0 +1,97 @@
+/****************************************************************
+ * 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.sieve.jpa.model;
+
+import java.util.Objects;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+import org.apache.james.core.quota.QuotaSize;
+
+import com.google.common.base.MoreObjects;
+
+@Entity(name = "JamesSieveQuota")
+@Table(name = "JAMES_SIEVE_QUOTA")
+@NamedQueries({
+ @NamedQuery(name = "findByUsername", query = "SELECT sieveQuota FROM JamesSieveQuota sieveQuota WHERE sieveQuota.username=:username")
+})
+public class JPASieveQuota {
+
+ @Id
+ @Column(name = "USER_NAME", nullable = false, length = 100)
+ private String username;
+
+ @Column(name = "SIZE", nullable = false)
+ private long size;
+
+ /**
+ * @deprecated enhancement only
+ */
+ @Deprecated
+ protected JPASieveQuota() {
+ }
+
+ public JPASieveQuota(String username, long size) {
+ this.username = username;
+ this.size = size;
+ }
+
+ public long getSize() {
+ return size;
+ }
+
+ public void setSize(QuotaSize quotaSize) {
+ this.size = quotaSize.asLong();
+ }
+
+ public QuotaSize toQuotaSize() {
+ return QuotaSize.size(size);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ JPASieveQuota that = (JPASieveQuota) o;
+ return Objects.equals(username, that.username);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(username);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("username", username)
+ .add("size", size)
+ .toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/d5d5c9cb/server/data/data-jpa/src/main/java/org/apache/james/sieve/jpa/model/JPASieveScript.java
----------------------------------------------------------------------
diff --git a/server/data/data-jpa/src/main/java/org/apache/james/sieve/jpa/model/JPASieveScript.java b/server/data/data-jpa/src/main/java/org/apache/james/sieve/jpa/model/JPASieveScript.java
new file mode 100644
index 0000000..3f846ec
--- /dev/null
+++ b/server/data/data-jpa/src/main/java/org/apache/james/sieve/jpa/model/JPASieveScript.java
@@ -0,0 +1,200 @@
+/****************************************************************
+ * 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.sieve.jpa.model;
+
+import java.time.OffsetDateTime;
+import java.util.Objects;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.james.sieverepository.api.ScriptContent;
+import org.apache.james.sieverepository.api.ScriptName;
+import org.apache.james.sieverepository.api.ScriptSummary;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Preconditions;
+
+@Entity(name = "JamesSieveScript")
+@Table(name = "JAMES_SIEVE_SCRIPT")
+@NamedQueries({
+ @NamedQuery(name = "findAllByUsername", query = "SELECT sieveScript FROM JamesSieveScript sieveScript WHERE sieveScript.username=:username"),
+ @NamedQuery(name = "findActiveByUsername", query = "SELECT sieveScript FROM JamesSieveScript sieveScript WHERE sieveScript.username=:username AND sieveScript.isActive=true"),
+ @NamedQuery(name = "findSieveScript", query = "SELECT sieveScript FROM JamesSieveScript sieveScript WHERE sieveScript.username=:username AND sieveScript.scriptName=:scriptName")
+})
+public class JPASieveScript {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static ScriptSummary toSummary(JPASieveScript script) {
+ return new ScriptSummary(new ScriptName(script.getScriptName()), script.isActive());
+ }
+
+ public static class Builder {
+
+ private String username;
+ private String scriptName;
+ private String scriptContent;
+ private long scriptSize;
+ private boolean isActive;
+ private OffsetDateTime activationDateTime;
+
+ public Builder username(String username) {
+ Preconditions.checkNotNull(username);
+ this.username = username;
+ return this;
+ }
+
+ public Builder scriptName(String scriptName) {
+ Preconditions.checkNotNull(scriptName);
+ this.scriptName = scriptName;
+ return this;
+ }
+
+ public Builder scriptContent(ScriptContent scriptContent) {
+ Preconditions.checkNotNull(scriptContent);
+ this.scriptContent = scriptContent.getValue();
+ this.scriptSize = scriptContent.length();
+ return this;
+ }
+
+ public Builder isActive(boolean isActive) {
+ this.isActive = isActive;
+ return this;
+ }
+
+ public JPASieveScript build() {
+ Preconditions.checkState(StringUtils.isNotBlank(username), "'username' is mandatory");
+ Preconditions.checkState(StringUtils.isNotBlank(scriptName), "'scriptName' is mandatory");
+ this.activationDateTime = isActive ? OffsetDateTime.now() : null;
+ return new JPASieveScript(username, scriptName, scriptContent, scriptSize, isActive, activationDateTime);
+ }
+ }
+
+ @Id
+ private String uuid = UUID.randomUUID().toString();
+
+ @Column(name = "USER_NAME", nullable = false, length = 100)
+ private String username;
+
+ @Column(name = "SCRIPT_NAME", nullable = false, length = 255)
+ private String scriptName;
+
+ @Column(name = "SCRIPT_CONTENT", nullable = false, length = 1024)
+ private String scriptContent;
+
+ @Column(name = "SCRIPT_SIZE", nullable = false)
+ private long scriptSize;
+
+ @Column(name = "IS_ACTIVE", nullable = false)
+ private boolean isActive;
+
+ @Column(name = "ACTIVATION_DATE_TIME")
+ private OffsetDateTime activationDateTime;
+
+ /**
+ * @deprecated enhancement only
+ */
+ @Deprecated
+ protected JPASieveScript() {
+ }
+
+ private JPASieveScript(String username, String scriptName, String scriptContent, long scriptSize, boolean isActive, OffsetDateTime activationDateTime) {
+ this.username = username;
+ this.scriptName = scriptName;
+ this.scriptContent = scriptContent;
+ this.scriptSize = scriptSize;
+ this.isActive = isActive;
+ this.activationDateTime = activationDateTime;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getScriptName() {
+ return scriptName;
+ }
+
+ public String getScriptContent() {
+ return scriptContent;
+ }
+
+ public long getScriptSize() {
+ return scriptSize;
+ }
+
+ public boolean isActive() {
+ return isActive;
+ }
+
+ public OffsetDateTime getActivationDateTime() {
+ return activationDateTime;
+ }
+
+ public void activate() {
+ this.isActive = true;
+ this.activationDateTime = OffsetDateTime.now();
+ }
+
+ public void deactivate() {
+ this.isActive = false;
+ this.activationDateTime = null;
+ }
+
+ public void renameTo(ScriptName newName) {
+ this.scriptName = newName.getValue();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ JPASieveScript that = (JPASieveScript) o;
+ return Objects.equals(uuid, that.uuid);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(uuid);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("uuid", uuid)
+ .add("username", username)
+ .add("scriptName", scriptName)
+ .add("isActive", isActive)
+ .toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/d5d5c9cb/server/data/data-jpa/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/server/data/data-jpa/src/main/resources/META-INF/persistence.xml b/server/data/data-jpa/src/main/resources/META-INF/persistence.xml
index 0e43be9..1927b87 100644
--- a/server/data/data-jpa/src/main/resources/META-INF/persistence.xml
+++ b/server/data/data-jpa/src/main/resources/META-INF/persistence.xml
@@ -30,6 +30,8 @@
<class>org.apache.james.user.jpa.model.JPAUser</class>
<class>org.apache.james.rrt.jpa.model.JPARecipientRewrite</class>
<class>org.apache.james.mailrepository.jpa.JPAUrl</class>
+ <class>org.apache.james.sieve.jpa.model.JPASieveQuota</class>
+ <class>org.apache.james.sieve.jpa.model.JPASieveScript</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
http://git-wip-us.apache.org/repos/asf/james-project/blob/d5d5c9cb/server/data/data-jpa/src/test/java/org/apache/james/sieve/jpa/JpaSieveRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jpa/src/test/java/org/apache/james/sieve/jpa/JpaSieveRepositoryTest.java b/server/data/data-jpa/src/test/java/org/apache/james/sieve/jpa/JpaSieveRepositoryTest.java
new file mode 100644
index 0000000..660515c
--- /dev/null
+++ b/server/data/data-jpa/src/test/java/org/apache/james/sieve/jpa/JpaSieveRepositoryTest.java
@@ -0,0 +1,50 @@
+/****************************************************************
+ * 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.sieve.jpa;
+
+import org.apache.james.backends.jpa.JpaTestCluster;
+import org.apache.james.sieve.jpa.model.JPASieveQuota;
+import org.apache.james.sieve.jpa.model.JPASieveScript;
+import org.apache.james.sieverepository.api.SieveRepository;
+import org.apache.james.sieverepository.lib.AbstractSieveRepositoryTest;
+
+import org.junit.After;
+import org.junit.Before;
+
+public class JpaSieveRepositoryTest extends AbstractSieveRepositoryTest {
+
+ private static final JpaTestCluster JPA_TEST_CLUSTER = JpaTestCluster.create(JPASieveScript.class, JPASieveQuota.class);
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ JPA_TEST_CLUSTER.clear("JAMES_SIEVE_SCRIPT", "JAMES_SIEVE_QUOTA");
+ }
+
+ @Override
+ protected SieveRepository createSieveRepository() throws Exception {
+ return new JPASieveRepository(JPA_TEST_CLUSTER.getEntityManagerFactory());
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/d5d5c9cb/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java b/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
index 266d8b8..eaf9746 100644
--- a/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/sieverepository/lib/AbstractSieveRepositoryTest.java
@@ -345,6 +345,13 @@ public abstract class AbstractSieveRepositoryTest {
assertThat(sieveRepository.getQuota(USER)).isEqualTo(DEFAULT_QUOTA);
}
+ @Test
+ public void setQuotaShouldOverrideExistingQuota() throws Exception {
+ sieveRepository.setQuota(USER, USER_QUOTA);
+ sieveRepository.setQuota(USER, QuotaSize.size(USER_QUOTA.asLong() - 1));
+ assertThat(sieveRepository.getQuota(USER)).isEqualTo(QuotaSize.size(USER_QUOTA.asLong() - 1));
+ }
+
protected ScriptContent getScriptContent(InputStream inputStream) throws IOException {
return new ScriptContent(IOUtils.toString(inputStream, StandardCharsets.UTF_8));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[12/17] james-project git commit: JAMES-2555 Wrap reindexing into a
task
Posted by bt...@apache.org.
JAMES-2555 Wrap reindexing into a task
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/7c4f4d86
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/7c4f4d86
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/7c4f4d86
Branch: refs/heads/master
Commit: 7c4f4d86367d3fc61fcf4854280137551bd6d14b
Parents: 884b88f
Author: Benoit Tellier <bt...@linagora.com>
Authored: Thu Oct 11 16:22:57 2018 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:17:46 2018 +0700
----------------------------------------------------------------------
mailbox/api/pom.xml | 4 +
.../apache/james/mailbox/indexer/ReIndexer.java | 5 +-
.../tools/indexer/FullReindexingTask.java | 79 +++++++++
.../mailbox/tools/indexer/ReIndexerImpl.java | 131 +--------------
.../tools/indexer/ReIndexerPerformer.java | 168 +++++++++++++++++++
.../tools/indexer/ReprocessingContext.java | 53 ++++++
.../indexer/SingleMailboxReindexingTask.java | 88 ++++++++++
.../mailbox/tools/indexer/ThrowsReIndexer.java | 5 +-
.../indexer/CassandraReIndexerImplTest.java | 4 +-
.../tools/indexer/ReIndexerImplTest.java | 6 +-
.../cli/ReindexCommandIntegrationTest.java | 7 +-
.../adapter/mailbox/ReIndexerManagement.java | 11 +-
.../META-INF/org/apache/james/spring-server.xml | 3 +
13 files changed, 428 insertions(+), 136 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/7c4f4d86/mailbox/api/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/api/pom.xml b/mailbox/api/pom.xml
index 18578c1..56237b3 100644
--- a/mailbox/api/pom.xml
+++ b/mailbox/api/pom.xml
@@ -38,6 +38,10 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>james-server-task</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>james-server-util</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/7c4f4d86/mailbox/api/src/main/java/org/apache/james/mailbox/indexer/ReIndexer.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/indexer/ReIndexer.java b/mailbox/api/src/main/java/org/apache/james/mailbox/indexer/ReIndexer.java
index 302e01c..94304a7 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/indexer/ReIndexer.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/indexer/ReIndexer.java
@@ -21,11 +21,12 @@ package org.apache.james.mailbox.indexer;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.task.Task;
public interface ReIndexer {
- void reIndex(MailboxPath path) throws MailboxException;
+ Task reIndex(MailboxPath path) throws MailboxException;
- void reIndex() throws MailboxException;
+ Task reIndex() throws MailboxException;
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/7c4f4d86/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/FullReindexingTask.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/FullReindexingTask.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/FullReindexingTask.java
new file mode 100644
index 0000000..196c1d4
--- /dev/null
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/FullReindexingTask.java
@@ -0,0 +1,79 @@
+/****************************************************************
+ * 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.mailbox.tools.indexer;
+
+import java.util.Optional;
+
+import javax.inject.Inject;
+
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.task.Task;
+import org.apache.james.task.TaskExecutionDetails;
+
+public class FullReindexingTask implements Task {
+
+ public static final String FULL_RE_INDEXING = "FullReIndexing";
+
+ public static class AdditionalInformation implements TaskExecutionDetails.AdditionalInformation {
+ private final ReprocessingContext reprocessingContext;
+
+ AdditionalInformation(ReprocessingContext reprocessingContext) {
+ this.reprocessingContext = reprocessingContext;
+ }
+
+ public int getSuccessfullyReprocessMailCount() {
+ return reprocessingContext.successfullyReprocessedMailCount();
+ }
+
+ public int getFailedReprocessedMailCount() {
+ return reprocessingContext.failedReprocessingMailCount();
+ }
+ }
+
+ private final ReIndexerPerformer reIndexerPerformer;
+ private final AdditionalInformation additionalInformation;
+ private final ReprocessingContext reprocessingContext;
+
+ @Inject
+ public FullReindexingTask(ReIndexerPerformer reIndexerPerformer) {
+ this.reIndexerPerformer = reIndexerPerformer;
+ this.reprocessingContext = new ReprocessingContext();
+ this.additionalInformation = new AdditionalInformation(reprocessingContext);
+ }
+
+ @Override
+ public Result run() {
+ try {
+ return reIndexerPerformer.reIndex(reprocessingContext);
+ } catch (MailboxException e) {
+ return Result.PARTIAL;
+ }
+ }
+
+ @Override
+ public String type() {
+ return FULL_RE_INDEXING;
+ }
+
+ @Override
+ public Optional<TaskExecutionDetails.AdditionalInformation> details() {
+ return Optional.of(additionalInformation);
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/7c4f4d86/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java
index f239e32..415aacc 100644
--- a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java
@@ -19,33 +19,11 @@
package org.apache.mailbox.tools.indexer;
-import java.util.List;
-import java.util.Optional;
-
import javax.inject.Inject;
-import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MessageUid;
-import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.indexer.ReIndexer;
import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.model.MessageRange;
-import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
-import org.apache.james.mailbox.store.mail.MessageMapper;
-import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.apache.james.mailbox.store.mail.model.MailboxMessage;
-import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
-import org.apache.james.util.streams.Iterators;
-import org.apache.mailbox.tools.indexer.events.ImpactingEventType;
-import org.apache.mailbox.tools.indexer.events.ImpactingMessageEvent;
-import org.apache.mailbox.tools.indexer.registrations.GlobalRegistration;
-import org.apache.mailbox.tools.indexer.registrations.MailboxRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.github.fge.lambdas.Throwing;
-import com.google.common.collect.Lists;
+import org.apache.james.task.Task;
/**
* Note about live re-indexation handling :
@@ -61,114 +39,21 @@ import com.google.common.collect.Lists;
*/
public class ReIndexerImpl implements ReIndexer {
- private static final Logger LOGGER = LoggerFactory.getLogger(ReIndexerImpl.class);
-
- private static final int NO_LIMIT = 0;
- private static final int SINGLE_MESSAGE = 1;
-
- private final MailboxManager mailboxManager;
- private final ListeningMessageSearchIndex messageSearchIndex;
- private final MailboxSessionMapperFactory mailboxSessionMapperFactory;
+ private final ReIndexerPerformer reIndexerPerformer;
@Inject
- public ReIndexerImpl(MailboxManager mailboxManager,
- ListeningMessageSearchIndex messageSearchIndex,
- MailboxSessionMapperFactory mailboxSessionMapperFactory) {
- this.mailboxManager = mailboxManager;
- this.messageSearchIndex = messageSearchIndex;
- this.mailboxSessionMapperFactory = mailboxSessionMapperFactory;
+ public ReIndexerImpl(ReIndexerPerformer reIndexerPerformer) {
+ this.reIndexerPerformer = reIndexerPerformer;
}
@Override
- public void reIndex(MailboxPath path) throws MailboxException {
- MailboxSession mailboxSession = mailboxManager.createSystemSession(path.getUser());
- reIndex(path, mailboxSession);
+ public Task reIndex(MailboxPath path) {
+ return new SingleMailboxReindexingTask(reIndexerPerformer, path);
}
-
@Override
- public void reIndex() throws MailboxException {
- MailboxSession mailboxSession = mailboxManager.createSystemSession("re-indexing");
- LOGGER.info("Starting a full reindex");
- List<MailboxPath> mailboxPaths = mailboxManager.list(mailboxSession);
- GlobalRegistration globalRegistration = new GlobalRegistration();
- mailboxManager.addGlobalListener(globalRegistration, mailboxSession);
- try {
- handleFullReindexingIterations(mailboxPaths, globalRegistration);
- } finally {
- mailboxManager.removeGlobalListener(globalRegistration, mailboxSession);
- }
- LOGGER.info("Full reindex finished");
- }
-
- private void handleFullReindexingIterations(List<MailboxPath> mailboxPaths, GlobalRegistration globalRegistration) {
- for (MailboxPath mailboxPath : mailboxPaths) {
- Optional<MailboxPath> pathToIndex = globalRegistration.getPathToIndex(mailboxPath);
- if (pathToIndex.isPresent()) {
- try {
- reIndex(pathToIndex.get());
- } catch (Throwable e) {
- LOGGER.error("Error while proceeding to full reindexing on {}", pathToIndex.get(), e);
- }
- }
- }
- }
-
-
- private void reIndex(MailboxPath path, MailboxSession mailboxSession) throws MailboxException {
- MailboxRegistration mailboxRegistration = new MailboxRegistration(path);
- LOGGER.info("Intend to reindex {}",path);
- Mailbox mailbox = mailboxSessionMapperFactory.getMailboxMapper(mailboxSession).findMailboxByPath(path);
- messageSearchIndex.deleteAll(mailboxSession, mailbox);
- mailboxManager.addListener(path, mailboxRegistration, mailboxSession);
- try {
- Iterators.toStream(
- mailboxSessionMapperFactory.getMessageMapper(mailboxSession)
- .findInMailbox(mailbox, MessageRange.all(), MessageMapper.FetchType.Metadata, NO_LIMIT))
- .map(MailboxMessage::getUid)
- .forEach(uid -> handleMessageReIndexing(mailboxSession, mailboxRegistration, mailbox, uid));
- LOGGER.info("Finish to reindex {}", path);
- } finally {
- mailboxManager.removeListener(path, mailboxRegistration, mailboxSession);
- }
- }
-
- private void handleMessageReIndexing(MailboxSession mailboxSession, MailboxRegistration mailboxRegistration, Mailbox mailbox, MessageUid uid) {
- try {
- Optional<ImpactingMessageEvent> impactingMessageEvent = findMostRelevant(mailboxRegistration.getImpactingEvents(uid));
-
- Optional.of(uid)
- .filter(x -> !wasDeleted(impactingMessageEvent))
- .flatMap(Throwing.function(mUid -> fullyReadMessage(mailboxSession, mailbox, mUid)))
- .map(message -> messageUpdateRegardingEvents(message, impactingMessageEvent))
- .ifPresent(Throwing.consumer(message -> messageSearchIndex.add(mailboxSession, mailbox, message)));
- } catch (Exception e) {
- LOGGER.warn("ReIndexing failed for {} {}", mailbox.generateAssociatedPath(), uid, e);
- }
- }
-
- private Optional<ImpactingMessageEvent> findMostRelevant(List<ImpactingMessageEvent> messageEvents) {
- for (ImpactingMessageEvent impactingMessageEvent : messageEvents) {
- if (impactingMessageEvent.getType().equals(ImpactingEventType.Deletion)) {
- return Optional.of(impactingMessageEvent);
- }
- }
- return Lists.reverse(messageEvents).stream().findFirst();
- }
-
- private boolean wasDeleted(Optional<ImpactingMessageEvent> impactingMessageEvent) {
- return impactingMessageEvent.map(ImpactingMessageEvent::wasDeleted).orElse(false);
- }
-
- private MailboxMessage messageUpdateRegardingEvents(MailboxMessage message, Optional<ImpactingMessageEvent> impactingMessageEvent) {
- impactingMessageEvent.flatMap(ImpactingMessageEvent::newFlags).ifPresent(message::setFlags);
- return message;
- }
-
- private Optional<MailboxMessage> fullyReadMessage(MailboxSession mailboxSession, Mailbox mailbox, MessageUid mUid) throws MailboxException {
- return Iterators.toStream(mailboxSessionMapperFactory.getMessageMapper(mailboxSession)
- .findInMailbox(mailbox, MessageRange.one(mUid), MessageMapper.FetchType.Full, SINGLE_MESSAGE))
- .findFirst();
+ public Task reIndex() {
+ return new FullReindexingTask(reIndexerPerformer);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/7c4f4d86/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
new file mode 100644
index 0000000..e70b88d
--- /dev/null
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
@@ -0,0 +1,168 @@
+/****************************************************************
+ * 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.mailbox.tools.indexer;
+
+import java.util.List;
+import java.util.Optional;
+
+import javax.inject.Inject;
+
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.model.MessageRange;
+import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
+import org.apache.james.mailbox.store.mail.MessageMapper;
+import org.apache.james.mailbox.store.mail.model.Mailbox;
+import org.apache.james.mailbox.store.mail.model.MailboxMessage;
+import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
+import org.apache.james.task.Task;
+import org.apache.james.util.OptionalUtils;
+import org.apache.james.util.streams.Iterators;
+import org.apache.mailbox.tools.indexer.events.ImpactingEventType;
+import org.apache.mailbox.tools.indexer.events.ImpactingMessageEvent;
+import org.apache.mailbox.tools.indexer.registrations.GlobalRegistration;
+import org.apache.mailbox.tools.indexer.registrations.MailboxRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.github.fge.lambdas.Throwing;
+import com.google.common.collect.Lists;
+
+public class ReIndexerPerformer {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ReIndexerPerformer.class);
+
+ private static final int NO_LIMIT = 0;
+ private static final int SINGLE_MESSAGE = 1;
+
+ private final MailboxManager mailboxManager;
+ private final ListeningMessageSearchIndex messageSearchIndex;
+ private final MailboxSessionMapperFactory mailboxSessionMapperFactory;
+
+ @Inject
+ public ReIndexerPerformer(MailboxManager mailboxManager,
+ ListeningMessageSearchIndex messageSearchIndex,
+ MailboxSessionMapperFactory mailboxSessionMapperFactory) {
+ this.mailboxManager = mailboxManager;
+ this.messageSearchIndex = messageSearchIndex;
+ this.mailboxSessionMapperFactory = mailboxSessionMapperFactory;
+ }
+
+ public Task.Result reIndex(MailboxPath path, ReprocessingContext reprocessingContext) throws MailboxException {
+ MailboxSession mailboxSession = mailboxManager.createSystemSession(path.getUser());
+ return reIndex(path, mailboxSession, reprocessingContext);
+ }
+
+ public Task.Result reIndex(ReprocessingContext reprocessingContext) throws MailboxException {
+ MailboxSession mailboxSession = mailboxManager.createSystemSession("re-indexing");
+ LOGGER.info("Starting a full reindex");
+ List<MailboxPath> mailboxPaths = mailboxManager.list(mailboxSession);
+ GlobalRegistration globalRegistration = new GlobalRegistration();
+ mailboxManager.addGlobalListener(globalRegistration, mailboxSession);
+ try {
+ return handleFullReindexingIterations(mailboxPaths, globalRegistration, reprocessingContext);
+ } finally {
+ mailboxManager.removeGlobalListener(globalRegistration, mailboxSession);
+ LOGGER.info("Full reindex finished");
+ }
+ }
+
+ private Task.Result handleFullReindexingIterations(List<MailboxPath> mailboxPaths, GlobalRegistration globalRegistration,
+ ReprocessingContext reprocessingContext) {
+ return mailboxPaths.stream()
+ .map(globalRegistration::getPathToIndex)
+ .flatMap(OptionalUtils::toStream)
+ .map(path -> {
+ try {
+ return reIndex(path, reprocessingContext);
+ } catch (Throwable e) {
+ LOGGER.error("Error while proceeding to full reindexing on {}", path.asString(), e);
+ return Task.Result.PARTIAL;
+ }
+ })
+ .reduce(Task::combine)
+ .orElse(Task.Result.COMPLETED);
+ }
+
+ private Task.Result reIndex(MailboxPath path, MailboxSession mailboxSession, ReprocessingContext reprocessingContext) throws MailboxException {
+ MailboxRegistration mailboxRegistration = new MailboxRegistration(path);
+ LOGGER.info("Intend to reindex {}", path.asString());
+ Mailbox mailbox = mailboxSessionMapperFactory.getMailboxMapper(mailboxSession).findMailboxByPath(path);
+ messageSearchIndex.deleteAll(mailboxSession, mailbox);
+ mailboxManager.addListener(path, mailboxRegistration, mailboxSession);
+ try {
+ return Iterators.toStream(
+ mailboxSessionMapperFactory.getMessageMapper(mailboxSession)
+ .findInMailbox(mailbox, MessageRange.all(), MessageMapper.FetchType.Metadata, NO_LIMIT))
+ .map(MailboxMessage::getUid)
+ .map(uid -> handleMessageReIndexing(mailboxSession, mailboxRegistration, mailbox, uid))
+ .peek(reprocessingContext::updateAccordingToReprocessingResult)
+ .reduce(Task::combine)
+ .orElse(Task.Result.COMPLETED);
+ } finally {
+ LOGGER.info("Finish to reindex {}", path.asString());
+ mailboxManager.removeListener(path, mailboxRegistration, mailboxSession);
+ }
+ }
+
+ private Task.Result handleMessageReIndexing(MailboxSession mailboxSession, MailboxRegistration mailboxRegistration, Mailbox mailbox, MessageUid uid) {
+ try {
+ Optional<ImpactingMessageEvent> impactingMessageEvent = findMostRelevant(mailboxRegistration.getImpactingEvents(uid));
+
+ Optional.of(uid)
+ .filter(x -> !wasDeleted(impactingMessageEvent))
+ .flatMap(Throwing.function(mUid -> fullyReadMessage(mailboxSession, mailbox, mUid)))
+ .map(message -> messageUpdateRegardingEvents(message, impactingMessageEvent))
+ .ifPresent(Throwing.consumer(message -> messageSearchIndex.add(mailboxSession, mailbox, message)));
+ return Task.Result.COMPLETED;
+ } catch (Exception e) {
+ LOGGER.warn("ReIndexing failed for {} {}", mailbox.generateAssociatedPath(), uid, e);
+ return Task.Result.PARTIAL;
+ }
+ }
+
+ private Optional<ImpactingMessageEvent> findMostRelevant(List<ImpactingMessageEvent> messageEvents) {
+ for (ImpactingMessageEvent impactingMessageEvent : messageEvents) {
+ if (impactingMessageEvent.getType().equals(ImpactingEventType.Deletion)) {
+ return Optional.of(impactingMessageEvent);
+ }
+ }
+ return Lists.reverse(messageEvents).stream().findFirst();
+ }
+
+ private boolean wasDeleted(Optional<ImpactingMessageEvent> impactingMessageEvent) {
+ return impactingMessageEvent.map(ImpactingMessageEvent::wasDeleted).orElse(false);
+ }
+
+ private MailboxMessage messageUpdateRegardingEvents(MailboxMessage message, Optional<ImpactingMessageEvent> impactingMessageEvent) {
+ impactingMessageEvent.flatMap(ImpactingMessageEvent::newFlags).ifPresent(message::setFlags);
+ return message;
+ }
+
+ private Optional<MailboxMessage> fullyReadMessage(MailboxSession mailboxSession, Mailbox mailbox, MessageUid mUid) throws MailboxException {
+ return Iterators.toStream(mailboxSessionMapperFactory.getMessageMapper(mailboxSession)
+ .findInMailbox(mailbox, MessageRange.one(mUid), MessageMapper.FetchType.Full, SINGLE_MESSAGE))
+ .findFirst();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/7c4f4d86/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReprocessingContext.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReprocessingContext.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReprocessingContext.java
new file mode 100644
index 0000000..08417cf
--- /dev/null
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReprocessingContext.java
@@ -0,0 +1,53 @@
+/****************************************************************
+ * 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.mailbox.tools.indexer;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.james.task.Task;
+
+public class ReprocessingContext {
+ private final AtomicInteger successfullyReprocessedMails;
+ private final AtomicInteger failedReprocessingMails;
+
+ public ReprocessingContext() {
+ failedReprocessingMails = new AtomicInteger(0);
+ successfullyReprocessedMails = new AtomicInteger(0);
+ }
+
+ public void updateAccordingToReprocessingResult(Task.Result result) {
+ switch (result) {
+ case COMPLETED:
+ successfullyReprocessedMails.incrementAndGet();
+ break;
+ case PARTIAL:
+ failedReprocessingMails.incrementAndGet();
+ break;
+ }
+ }
+
+ public int successfullyReprocessedMailCount() {
+ return successfullyReprocessedMails.get();
+ }
+
+ public int failedReprocessingMailCount() {
+ return failedReprocessingMails.get();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/7c4f4d86/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/SingleMailboxReindexingTask.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/SingleMailboxReindexingTask.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/SingleMailboxReindexingTask.java
new file mode 100644
index 0000000..fc9f834
--- /dev/null
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/SingleMailboxReindexingTask.java
@@ -0,0 +1,88 @@
+/****************************************************************
+ * 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.mailbox.tools.indexer;
+
+import java.util.Optional;
+
+import javax.inject.Inject;
+
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.task.Task;
+import org.apache.james.task.TaskExecutionDetails;
+
+public class SingleMailboxReindexingTask implements Task {
+
+ public static final String MAILBOX_RE_INDEXING = "mailboxReIndexing";
+
+ public static class AdditionalInformation implements TaskExecutionDetails.AdditionalInformation {
+ private final MailboxPath mailboxPath;
+ private final ReprocessingContext reprocessingContext;
+
+ AdditionalInformation(MailboxPath mailboxPath, ReprocessingContext reprocessingContext) {
+ this.mailboxPath = mailboxPath;
+ this.reprocessingContext = reprocessingContext;
+ }
+
+ public String getMailboxPath() {
+ return mailboxPath.asString();
+ }
+
+ public int getSuccessfullyReprocessMailCount() {
+ return reprocessingContext.successfullyReprocessedMailCount();
+ }
+
+ public int getFailedReprocessedMailCount() {
+ return reprocessingContext.failedReprocessingMailCount();
+ }
+ }
+
+ private final ReIndexerPerformer reIndexerPerformer;
+ private final MailboxPath path;
+ private final AdditionalInformation additionalInformation;
+ private final ReprocessingContext reprocessingContext;
+
+ @Inject
+ public SingleMailboxReindexingTask(ReIndexerPerformer reIndexerPerformer, MailboxPath path) {
+ this.reIndexerPerformer = reIndexerPerformer;
+ this.path = path;
+ this.reprocessingContext = new ReprocessingContext();
+ this.additionalInformation = new AdditionalInformation(path, reprocessingContext);
+ }
+
+ @Override
+ public Result run() {
+ try {
+ return reIndexerPerformer.reIndex(path, reprocessingContext);
+ } catch (MailboxException e) {
+ return Result.PARTIAL;
+ }
+ }
+
+ @Override
+ public String type() {
+ return MAILBOX_RE_INDEXING;
+ }
+
+ @Override
+ public Optional<TaskExecutionDetails.AdditionalInformation> details() {
+ return Optional.of(additionalInformation);
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/7c4f4d86/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ThrowsReIndexer.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ThrowsReIndexer.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ThrowsReIndexer.java
index 462537b..6734795 100644
--- a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ThrowsReIndexer.java
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ThrowsReIndexer.java
@@ -22,16 +22,17 @@ package org.apache.mailbox.tools.indexer;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.indexer.ReIndexer;
import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.task.Task;
public class ThrowsReIndexer implements ReIndexer {
@Override
- public void reIndex(MailboxPath path) throws MailboxException {
+ public Task reIndex(MailboxPath path) throws MailboxException {
throw new MailboxException("Not implemented");
}
@Override
- public void reIndex() throws MailboxException {
+ public Task reIndex() throws MailboxException {
throw new MailboxException("Not implemented");
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/7c4f4d86/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/CassandraReIndexerImplTest.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/CassandraReIndexerImplTest.java b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/CassandraReIndexerImplTest.java
index 26f68cc..6c55478 100644
--- a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/CassandraReIndexerImplTest.java
+++ b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/CassandraReIndexerImplTest.java
@@ -64,7 +64,7 @@ public class CassandraReIndexerImplTest {
mailboxManager = CassandraMailboxManagerProvider.provideMailboxManager(cassandra.getConf(), cassandra.getTypesProvider());
MailboxSessionMapperFactory mailboxSessionMapperFactory = mailboxManager.getMapperFactory();
messageSearchIndex = mock(ListeningMessageSearchIndex.class);
- reIndexer = new ReIndexerImpl(mailboxManager, messageSearchIndex, mailboxSessionMapperFactory);
+ reIndexer = new ReIndexerImpl(new ReIndexerPerformer(mailboxManager, messageSearchIndex, mailboxSessionMapperFactory));
}
@Test
@@ -88,7 +88,7 @@ public class CassandraReIndexerImplTest {
.runSuccessfullyWithin(Duration.ofMinutes(10));
// When We re-index
- reIndexer.reIndex(INBOX);
+ reIndexer.reIndex(INBOX).run();
// The indexer is called for each message
verify(messageSearchIndex).deleteAll(any(MailboxSession.class), any(Mailbox.class));
http://git-wip-us.apache.org/repos/asf/james-project/blob/7c4f4d86/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
index 76f8a00..003601e 100644
--- a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
+++ b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
@@ -57,7 +57,7 @@ public class ReIndexerImplTest {
mailboxManager = new InMemoryIntegrationResources().createMailboxManager(new SimpleGroupMembershipResolver());
MailboxSessionMapperFactory mailboxSessionMapperFactory = mailboxManager.getMapperFactory();
messageSearchIndex = mock(ListeningMessageSearchIndex.class);
- reIndexer = new ReIndexerImpl(mailboxManager, messageSearchIndex, mailboxSessionMapperFactory);
+ reIndexer = new ReIndexerImpl(new ReIndexerPerformer(mailboxManager, messageSearchIndex, mailboxSessionMapperFactory));
}
@Test
@@ -69,7 +69,7 @@ public class ReIndexerImplTest {
MessageManager.AppendCommand.builder().build("header: value\r\n\r\nbody"),
systemSession);
- reIndexer.reIndex(INBOX);
+ reIndexer.reIndex(INBOX).run();
ArgumentCaptor<MailboxMessage> messageCaptor = ArgumentCaptor.forClass(MailboxMessage.class);
ArgumentCaptor<Mailbox> mailboxCaptor1 = ArgumentCaptor.forClass(Mailbox.class);
@@ -94,7 +94,7 @@ public class ReIndexerImplTest {
MessageManager.AppendCommand.builder().build("header: value\r\n\r\nbody"),
systemSession);
- reIndexer.reIndex();
+ reIndexer.reIndex().run();
ArgumentCaptor<MailboxMessage> messageCaptor = ArgumentCaptor.forClass(MailboxMessage.class);
ArgumentCaptor<Mailbox> mailboxCaptor1 = ArgumentCaptor.forClass(Mailbox.class);
ArgumentCaptor<Mailbox> mailboxCaptor2 = ArgumentCaptor.forClass(Mailbox.class);
http://git-wip-us.apache.org/repos/asf/james-project/blob/7c4f4d86/server/container/cli-integration/src/test/java/org/apache/james/cli/ReindexCommandIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/container/cli-integration/src/test/java/org/apache/james/cli/ReindexCommandIntegrationTest.java b/server/container/cli-integration/src/test/java/org/apache/james/cli/ReindexCommandIntegrationTest.java
index bccaa62..6d81781 100644
--- a/server/container/cli-integration/src/test/java/org/apache/james/cli/ReindexCommandIntegrationTest.java
+++ b/server/container/cli-integration/src/test/java/org/apache/james/cli/ReindexCommandIntegrationTest.java
@@ -19,8 +19,10 @@
package org.apache.james.cli;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import org.apache.james.GuiceJamesServer;
import org.apache.james.MemoryJmapTestRule;
@@ -29,6 +31,7 @@ import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
import org.apache.james.modules.server.JMXServerModule;
+import org.apache.james.task.Task;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -37,7 +40,7 @@ import org.junit.Test;
import com.google.inject.name.Names;
public class ReindexCommandIntegrationTest {
- public static final String USER = "user";
+ private static final String USER = "user";
private ReIndexer reIndexer;
@Rule
@@ -47,6 +50,8 @@ public class ReindexCommandIntegrationTest {
@Before
public void setUp() throws Exception {
reIndexer = mock(ReIndexer.class);
+ when(reIndexer.reIndex()).thenReturn(() -> Task.Result.COMPLETED);
+ when(reIndexer.reIndex(any(MailboxPath.class))).thenReturn(() -> Task.Result.COMPLETED);
guiceJamesServer = memoryJmap.jmapServer(new JMXServerModule(),
binder -> binder.bind(ListeningMessageSearchIndex.class).toInstance(mock(ListeningMessageSearchIndex.class)))
.overrideWith(binder -> binder.bind(ReIndexer.class)
http://git-wip-us.apache.org/repos/asf/james-project/blob/7c4f4d86/server/container/mailbox-jmx/src/main/java/org/apache/james/adapter/mailbox/ReIndexerManagement.java
----------------------------------------------------------------------
diff --git a/server/container/mailbox-jmx/src/main/java/org/apache/james/adapter/mailbox/ReIndexerManagement.java b/server/container/mailbox-jmx/src/main/java/org/apache/james/adapter/mailbox/ReIndexerManagement.java
index c5110a8..760b3d9 100644
--- a/server/container/mailbox-jmx/src/main/java/org/apache/james/adapter/mailbox/ReIndexerManagement.java
+++ b/server/container/mailbox-jmx/src/main/java/org/apache/james/adapter/mailbox/ReIndexerManagement.java
@@ -28,14 +28,18 @@ import javax.inject.Named;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.indexer.ReIndexer;
import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.task.TaskId;
+import org.apache.james.task.TaskManager;
import org.apache.james.util.MDCBuilder;
public class ReIndexerManagement implements ReIndexerManagementMBean {
- private ReIndexer reIndexer;
+ private final TaskManager taskManager;
+ private final ReIndexer reIndexer;
@Inject
- public void setReIndexer(@Named("reindexer") ReIndexer reIndexer) {
+ public ReIndexerManagement(TaskManager taskManager, @Named("reindexer") ReIndexer reIndexer) {
+ this.taskManager = taskManager;
this.reIndexer = reIndexer;
}
@@ -46,7 +50,8 @@ public class ReIndexerManagement implements ReIndexerManagementMBean {
.addContext(MDCBuilder.PROTOCOL, "CLI")
.addContext(MDCBuilder.ACTION, "reIndex")
.build()) {
- reIndexer.reIndex(new MailboxPath(namespace, user, name));
+ TaskId taskId = taskManager.submit(reIndexer.reIndex(new MailboxPath(namespace, user, name)));
+ taskManager.await(taskId);
} catch (IOException e) {
throw new RuntimeException(e);
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/7c4f4d86/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
----------------------------------------------------------------------
diff --git a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
index fa12ef6..aab5c34 100644
--- a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
+++ b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
@@ -287,6 +287,9 @@
<bean id="quotamanagermanagement" class="org.apache.james.adapter.mailbox.QuotaManagement"/>
<bean id="reindexermanagement" class="org.apache.james.adapter.mailbox.ReIndexerManagement"/>
<bean id="sievemanagerbean" class="org.apache.james.sieverepository.lib.SieveRepositoryManagement"/>
+
+
+ <bean id="taskManager" class="org.apache.james.task.MemoryTaskManager"/>
<!--
<bean id="james23importermanagement" class="org.apache.james.container.spring.tool.James23ImporterManagement" />
-->
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[13/17] james-project git commit: JAMES-2555 Visibility for
ReIndexerPerformer
Posted by bt...@apache.org.
JAMES-2555 Visibility for ReIndexerPerformer
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/f354e3c2
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/f354e3c2
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/f354e3c2
Branch: refs/heads/master
Commit: f354e3c28c5b9262eebd7f2d17ac105f1d9059f7
Parents: 7c4f4d8
Author: Benoit Tellier <bt...@linagora.com>
Authored: Mon Oct 15 10:01:22 2018 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:17:46 2018 +0700
----------------------------------------------------------------------
.../mailbox/tools/indexer/ReIndexerPerformer.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/f354e3c2/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
index e70b88d..c2d471d 100644
--- a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
@@ -48,7 +48,7 @@ import org.slf4j.LoggerFactory;
import com.github.fge.lambdas.Throwing;
import com.google.common.collect.Lists;
-public class ReIndexerPerformer {
+class ReIndexerPerformer {
private static final Logger LOGGER = LoggerFactory.getLogger(ReIndexerPerformer.class);
@@ -60,20 +60,20 @@ public class ReIndexerPerformer {
private final MailboxSessionMapperFactory mailboxSessionMapperFactory;
@Inject
- public ReIndexerPerformer(MailboxManager mailboxManager,
- ListeningMessageSearchIndex messageSearchIndex,
- MailboxSessionMapperFactory mailboxSessionMapperFactory) {
+ ReIndexerPerformer(MailboxManager mailboxManager,
+ ListeningMessageSearchIndex messageSearchIndex,
+ MailboxSessionMapperFactory mailboxSessionMapperFactory) {
this.mailboxManager = mailboxManager;
this.messageSearchIndex = messageSearchIndex;
this.mailboxSessionMapperFactory = mailboxSessionMapperFactory;
}
- public Task.Result reIndex(MailboxPath path, ReprocessingContext reprocessingContext) throws MailboxException {
+ Task.Result reIndex(MailboxPath path, ReprocessingContext reprocessingContext) throws MailboxException {
MailboxSession mailboxSession = mailboxManager.createSystemSession(path.getUser());
return reIndex(path, mailboxSession, reprocessingContext);
}
- public Task.Result reIndex(ReprocessingContext reprocessingContext) throws MailboxException {
+ Task.Result reIndex(ReprocessingContext reprocessingContext) throws MailboxException {
MailboxSession mailboxSession = mailboxManager.createSystemSession("re-indexing");
LOGGER.info("Starting a full reindex");
List<MailboxPath> mailboxPaths = mailboxManager.list(mailboxSession);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[09/17] james-project git commit: JAMES-2525 Reindent to improve
readability
Posted by bt...@apache.org.
JAMES-2525 Reindent to improve readability
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/bf8f52f0
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/bf8f52f0
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/bf8f52f0
Branch: refs/heads/master
Commit: bf8f52f0c666875323d687d84152faacf5a0fe4b
Parents: a9c9197
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Thu Oct 11 11:43:57 2018 +0200
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:17:08 2018 +0700
----------------------------------------------------------------------
.../blob/objectstorage/ObjectStorageBlobsDAO.java | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/bf8f52f0/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
index 1e0d12a..80a368a 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
@@ -70,14 +70,13 @@ public class ObjectStorageBlobsDAO implements BlobStore {
}
public CompletableFuture<ContainerName> createContainer(ContainerName name) {
- return CompletableFuture.supplyAsync(() -> blobStore.createContainerInLocation(DEFAULT_LOCATION,
- name.value())).thenApply(created -> {
- if (created) {
- return name;
- } else {
- throw new ObjectStoreException("Unable to create container " + name.value());
- }
- });
+ return CompletableFuture.supplyAsync(() -> blobStore.createContainerInLocation(DEFAULT_LOCATION, name.value()))
+ .thenApply(created -> {
+ if (created) {
+ return name;
+ } else {
+ throw new ObjectStoreException("Unable to create container " + name.value());
+ }});
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[11/17] james-project git commit: JAMES-2525 Reindent to improve
readibility
Posted by bt...@apache.org.
JAMES-2525 Reindent to improve readibility
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/e18abb64
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e18abb64
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e18abb64
Branch: refs/heads/master
Commit: e18abb642e994ae144e416a417dd21a35caae87a
Parents: 5898631
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Thu Oct 11 11:52:39 2018 +0200
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:17:08 2018 +0700
----------------------------------------------------------------------
.../objectstorage/SwiftKeystone2ConfigurationReader.java | 2 +-
.../objectstorage/SwiftKeystone3ConfigurationReader.java | 10 +++++-----
.../objectstorage/SwiftTmpAuthConfigurationReader.java | 6 +++---
3 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/e18abb64/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/SwiftKeystone2ConfigurationReader.java
----------------------------------------------------------------------
diff --git a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/SwiftKeystone2ConfigurationReader.java b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/SwiftKeystone2ConfigurationReader.java
index d2f1d03..09f41f0 100644
--- a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/SwiftKeystone2ConfigurationReader.java
+++ b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/SwiftKeystone2ConfigurationReader.java
@@ -61,7 +61,7 @@ public class SwiftKeystone2ConfigurationReader implements SwiftConfigurationRead
Identity identity = Identity.of(tenantName, userName);
Optional<Region> region = Optional.ofNullable(
- configuration.getString(OBJECTSTORAGE_SWIFT_REGION, null))
+ configuration.getString(OBJECTSTORAGE_SWIFT_REGION, null))
.map(Region::of);
return SwiftKeystone2ObjectStorage.configBuilder()
http://git-wip-us.apache.org/repos/asf/james-project/blob/e18abb64/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/SwiftKeystone3ConfigurationReader.java
----------------------------------------------------------------------
diff --git a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/SwiftKeystone3ConfigurationReader.java b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/SwiftKeystone3ConfigurationReader.java
index bc51a89..f661bb6 100644
--- a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/SwiftKeystone3ConfigurationReader.java
+++ b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/SwiftKeystone3ConfigurationReader.java
@@ -76,13 +76,13 @@ public class SwiftKeystone3ConfigurationReader implements SwiftConfigurationRead
IdentityV3 identity = readIdentity(configuration);
Optional<DomainId> domainScope = Optional.ofNullable(
- configuration.getString(OBJECTSTORAGE_SWIFT_KEYSTONE_3_DOMAIN_ID, null))
+ configuration.getString(OBJECTSTORAGE_SWIFT_KEYSTONE_3_DOMAIN_ID, null))
.map(DomainId::of);
Optional<Project> projectScope = readProjectScope(configuration);
Optional<Region> region = Optional.ofNullable(
- configuration.getString(OBJECTSTORAGE_SWIFT_REGION, null))
+ configuration.getString(OBJECTSTORAGE_SWIFT_REGION, null))
.map(Region::of);
return SwiftKeystone3ObjectStorage.configBuilder()
@@ -114,15 +114,15 @@ public class SwiftKeystone3ConfigurationReader implements SwiftConfigurationRead
private static Optional<Project> readProjectScope(Configuration configuration) {
Optional<ProjectName> projectName = Optional.ofNullable(
- configuration.getString(OBJECTSTORAGE_SWIFT_KEYSTONE_3_PROJECT_NAME, null))
+ configuration.getString(OBJECTSTORAGE_SWIFT_KEYSTONE_3_PROJECT_NAME, null))
.map(ProjectName::of);
Optional<DomainName> projectDomainName = Optional.ofNullable(
- configuration.getString(OBJECTSTORAGE_SWIFT_KEYSTONE_3_PROJECT_DOMAIN_NAME, null))
+ configuration.getString(OBJECTSTORAGE_SWIFT_KEYSTONE_3_PROJECT_DOMAIN_NAME, null))
.map(DomainName::of);
Optional<DomainId> projectDomainId = Optional.ofNullable(
- configuration.getString(OBJECTSTORAGE_SWIFT_KEYSTONE_3_PROJECT_DOMAIN_ID, null))
+ configuration.getString(OBJECTSTORAGE_SWIFT_KEYSTONE_3_PROJECT_DOMAIN_ID, null))
.map(DomainId::of);
return OptionalUtils.or(
http://git-wip-us.apache.org/repos/asf/james-project/blob/e18abb64/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/SwiftTmpAuthConfigurationReader.java
----------------------------------------------------------------------
diff --git a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/SwiftTmpAuthConfigurationReader.java b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/SwiftTmpAuthConfigurationReader.java
index 467fa42..3afd4a8 100644
--- a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/SwiftTmpAuthConfigurationReader.java
+++ b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/SwiftTmpAuthConfigurationReader.java
@@ -67,15 +67,15 @@ public class SwiftTmpAuthConfigurationReader implements SwiftConfigurationReader
Identity identity = Identity.of(tenantName, userName);
Optional<Region> region = Optional.ofNullable(
- configuration.getString(SwiftConfigurationReader.OBJECTSTORAGE_SWIFT_REGION, null))
+ configuration.getString(SwiftConfigurationReader.OBJECTSTORAGE_SWIFT_REGION, null))
.map(Region::of);
Optional<PassHeaderName> passHeaderName = Optional.ofNullable(
- configuration.getString(OBJECTSTORAGE_SWIFT_TEMPAUTH_PASS_HEADER_NAME, null))
+ configuration.getString(OBJECTSTORAGE_SWIFT_TEMPAUTH_PASS_HEADER_NAME, null))
.map(PassHeaderName::of);
Optional<UserHeaderName> userHeaderName = Optional.ofNullable(
- configuration.getString(OBJECTSTORAGE_SWIFT_TEMPAUTH_USER_HEADER_NAME, null))
+ configuration.getString(OBJECTSTORAGE_SWIFT_TEMPAUTH_USER_HEADER_NAME, null))
.map(UserHeaderName::of);
return SwiftTempAuthObjectStorage.configBuilder()
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[17/17] james-project git commit: JAMES-2555 Allow re-indexing of a
single message
Posted by bt...@apache.org.
JAMES-2555 Allow re-indexing of a single message
Note that message reIndexing allows one grokking the logs and fix a partially
failed re-indexing without going through the wall process yet-another-time.
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/45d311c5
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/45d311c5
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/45d311c5
Branch: refs/heads/master
Commit: 45d311c558affbda21282a54ae10ee84c42defc1
Parents: a873181
Author: Benoit Tellier <bt...@linagora.com>
Authored: Fri Oct 12 17:47:31 2018 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:20:00 2018 +0700
----------------------------------------------------------------------
.../apache/james/mailbox/indexer/ReIndexer.java | 3 +
.../mailbox/tools/indexer/ReIndexerImpl.java | 5 ++
.../tools/indexer/ReIndexerPerformer.java | 8 ++
.../indexer/SingleMessageReindexingTask.java | 85 ++++++++++++++++++++
.../mailbox/tools/indexer/ThrowsReIndexer.java | 6 ++
.../tools/indexer/ReIndexerImplTest.java | 21 +++++
6 files changed, 128 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/45d311c5/mailbox/api/src/main/java/org/apache/james/mailbox/indexer/ReIndexer.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/indexer/ReIndexer.java b/mailbox/api/src/main/java/org/apache/james/mailbox/indexer/ReIndexer.java
index 5ed156e..817307b 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/indexer/ReIndexer.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/indexer/ReIndexer.java
@@ -20,6 +20,7 @@
package org.apache.james.mailbox.indexer;
import org.apache.james.core.User;
+import org.apache.james.mailbox.MessageUid;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.task.Task;
@@ -32,4 +33,6 @@ public interface ReIndexer {
Task reIndex() throws MailboxException;
+ Task reIndex(MailboxPath path, MessageUid uid) throws MailboxException;
+
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/45d311c5/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java
index 8fd3786..c32c533 100644
--- a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java
@@ -22,6 +22,7 @@ package org.apache.mailbox.tools.indexer;
import javax.inject.Inject;
import org.apache.james.core.User;
+import org.apache.james.mailbox.MessageUid;
import org.apache.james.mailbox.indexer.ReIndexer;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.task.Task;
@@ -59,4 +60,8 @@ public class ReIndexerImpl implements ReIndexer {
return new UserReindexingTask(reIndexerPerformer, user);
}
+ @Override
+ public Task reIndex(MailboxPath path, MessageUid uid) {
+ return new SingleMessageReindexingTask(reIndexerPerformer, path, uid);
+ }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/45d311c5/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
index fb5bf89..625adda 100644
--- a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
@@ -101,6 +101,14 @@ class ReIndexerPerformer {
}
}
+ Task.Result handleMessageReIndexing(MailboxPath path, MessageUid uid) throws MailboxException {
+ MailboxSession mailboxSession = mailboxManager.createSystemSession(path.getUser());
+ Mailbox mailbox = mailboxSessionMapperFactory.getMailboxMapper(mailboxSession)
+ .findMailboxByPath(path);
+
+ return handleMessageReIndexing(mailboxSession, mailbox, uid);
+ }
+
private Task.Result reIndex(List<MailboxPath> mailboxPaths, MailboxSession mailboxSession, ReprocessingContext reprocessingContext) throws MailboxException {
return wrapInGlobalRegistration(mailboxSession,
globalRegistration -> handleMultiMailboxesReindexingIterations(mailboxPaths, globalRegistration, reprocessingContext));
http://git-wip-us.apache.org/repos/asf/james-project/blob/45d311c5/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/SingleMessageReindexingTask.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/SingleMessageReindexingTask.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/SingleMessageReindexingTask.java
new file mode 100644
index 0000000..501ee6f
--- /dev/null
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/SingleMessageReindexingTask.java
@@ -0,0 +1,85 @@
+/****************************************************************
+ * 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.mailbox.tools.indexer;
+
+import java.util.Optional;
+
+import javax.inject.Inject;
+
+import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.task.Task;
+import org.apache.james.task.TaskExecutionDetails;
+
+public class SingleMessageReindexingTask implements Task {
+
+ public static final String MESSAGE_RE_INDEXING = "messageReIndexing";
+
+ public static class AdditionalInformation implements TaskExecutionDetails.AdditionalInformation {
+ private final MailboxPath mailboxPath;
+ private final MessageUid uid;
+
+ AdditionalInformation(MailboxPath mailboxPath, MessageUid uid) {
+ this.mailboxPath = mailboxPath;
+ this.uid = uid;
+ }
+
+ public String getMailboxPath() {
+ return mailboxPath.asString();
+ }
+
+ public long getUid() {
+ return uid.asLong();
+ }
+ }
+
+ private final ReIndexerPerformer reIndexerPerformer;
+ private final MailboxPath path;
+ private final MessageUid uid;
+ private final AdditionalInformation additionalInformation;
+
+ @Inject
+ public SingleMessageReindexingTask(ReIndexerPerformer reIndexerPerformer, MailboxPath path, MessageUid uid) {
+ this.reIndexerPerformer = reIndexerPerformer;
+ this.path = path;
+ this.uid = uid;
+ this.additionalInformation = new AdditionalInformation(path, uid);
+ }
+
+ @Override
+ public Result run() {
+ try {
+ return reIndexerPerformer.handleMessageReIndexing(path, uid);
+ } catch (MailboxException e) {
+ return Result.PARTIAL;
+ }
+ }
+
+ @Override
+ public String type() {
+ return MESSAGE_RE_INDEXING;
+ }
+
+ @Override
+ public Optional<TaskExecutionDetails.AdditionalInformation> details() {
+ return Optional.of(additionalInformation);
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/45d311c5/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ThrowsReIndexer.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ThrowsReIndexer.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ThrowsReIndexer.java
index f0d86ae..5ffb02b 100644
--- a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ThrowsReIndexer.java
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ThrowsReIndexer.java
@@ -20,6 +20,7 @@
package org.apache.mailbox.tools.indexer;
import org.apache.james.core.User;
+import org.apache.james.mailbox.MessageUid;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.indexer.ReIndexer;
import org.apache.james.mailbox.model.MailboxPath;
@@ -41,4 +42,9 @@ public class ThrowsReIndexer implements ReIndexer {
public Task reIndex(User user) throws MailboxException {
throw new MailboxException("Not implemented");
}
+
+ @Override
+ public Task reIndex(MailboxPath path, MessageUid uid) throws MailboxException {
+ throw new MailboxException("Not implemented");
+ }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/45d311c5/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
index d1fed69..74e834a 100644
--- a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
+++ b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
@@ -133,4 +133,25 @@ public class ReIndexerImplTest {
assertThat(messageCaptor.getValue()).matches(message -> message.getMailboxId().equals(mailboxId)
&& message.getUid().equals(createdMessage.getUid()));
}
+
+ @Test
+ void messageReIndexShouldBeWellPerformed() throws Exception {
+ MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME);
+ MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
+ ComposedMessageId createdMessage = mailboxManager.getMailbox(INBOX, systemSession)
+ .appendMessage(
+ MessageManager.AppendCommand.builder().build("header: value\r\n\r\nbody"),
+ systemSession);
+
+ reIndexer.reIndex(INBOX, createdMessage.getUid()).run();
+ ArgumentCaptor<MailboxMessage> messageCaptor = ArgumentCaptor.forClass(MailboxMessage.class);
+ ArgumentCaptor<Mailbox> mailboxCaptor = ArgumentCaptor.forClass(Mailbox.class);
+
+ verify(messageSearchIndex).add(any(MailboxSession.class), mailboxCaptor.capture(), messageCaptor.capture());
+ verifyNoMoreInteractions(messageSearchIndex);
+
+ assertThat(mailboxCaptor.getValue()).matches(mailbox -> mailbox.getMailboxId().equals(mailboxId));
+ assertThat(messageCaptor.getValue()).matches(message -> message.getMailboxId().equals(mailboxId)
+ && message.getUid().equals(createdMessage.getUid()));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[08/17] james-project git commit: JAMES-2525 Rename test methods to
fit our standard
Posted by bt...@apache.org.
JAMES-2525 Rename test methods to fit our standard
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/5898631a
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5898631a
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5898631a
Branch: refs/heads/master
Commit: 5898631a6a5775dc9a9706144c4171752dd29e93
Parents: bf8f52f
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Thu Oct 11 11:48:14 2018 +0200
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:17:08 2018 +0700
----------------------------------------------------------------------
.../james/blob/objectstorage/ObjectStorageBlobsDAOTest.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/5898631a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java
index 4c04014..d5e101d 100644
--- a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java
+++ b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java
@@ -90,13 +90,14 @@ public class ObjectStorageBlobsDAOTest implements BlobStoreContract {
}
@Test
- void canCreateContainer() throws Exception {
+ void createContainerShouldMakeTheContainerToExist() throws Exception {
ContainerName containerName = ContainerName.of(UUID.randomUUID().toString());
testee.createContainer(containerName).get();
assertThat(blobStore.containerExists(containerName.value())).isTrue();
}
+
@Test
- void failsWithRuntimeExceptionOnCreateContainerTwice() throws Exception {
+ void createContainerShouldFailWithRuntimeExceptionWhenCreateContainerTwice() throws Exception {
ContainerName containerName = ContainerName.of(UUID.randomUUID().toString());
testee.createContainer(containerName).get();
assertThatThrownBy(() -> testee.createContainer(containerName).get())
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[06/17] james-project git commit: Fix checkstyle error
Posted by bt...@apache.org.
Fix checkstyle error
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/884b88f3
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/884b88f3
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/884b88f3
Branch: refs/heads/master
Commit: 884b88f3de58e7301bf943d744dee869b9cdf541
Parents: 787695d
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Thu Oct 11 16:20:44 2018 +0200
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:17:08 2018 +0700
----------------------------------------------------------------------
.../apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/884b88f3/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
index 80a368a..7422b55 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAO.java
@@ -76,7 +76,8 @@ public class ObjectStorageBlobsDAO implements BlobStore {
return name;
} else {
throw new ObjectStoreException("Unable to create container " + name.value());
- }});
+ }
+ });
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[14/17] james-project git commit: JAMES-2555 Simplify reIndexing: no
more needed message event tracking
Posted by bt...@apache.org.
JAMES-2555 Simplify reIndexing: no more needed message event tracking
Because we reindex a list of UID for a given mailbox, if:
- A new message arrive it will be handled by the normal indexing process
- A concurrently deleted message will be filtered out as it can not be retrieved from storage
- And we will read the latest applied flag value
Note that global event tracking is still needed for mailbox path renames.
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/9ff8a260
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/9ff8a260
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/9ff8a260
Branch: refs/heads/master
Commit: 9ff8a260ea27993c46eb660c64a8881d9cf9f4a8
Parents: f354e3c
Author: Benoit Tellier <bt...@linagora.com>
Authored: Fri Oct 12 16:59:03 2018 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:18:20 2018 +0700
----------------------------------------------------------------------
.../tools/indexer/ReIndexerPerformer.java | 33 +----
.../indexer/events/ImpactingMessageEvent.java | 144 -------------------
.../registrations/MailboxRegistration.java | 70 ---------
.../registrations/MailboxRegistrationTest.java | 107 --------------
4 files changed, 2 insertions(+), 352 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/9ff8a260/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
index c2d471d..ce88882 100644
--- a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
@@ -38,15 +38,11 @@ import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
import org.apache.james.task.Task;
import org.apache.james.util.OptionalUtils;
import org.apache.james.util.streams.Iterators;
-import org.apache.mailbox.tools.indexer.events.ImpactingEventType;
-import org.apache.mailbox.tools.indexer.events.ImpactingMessageEvent;
import org.apache.mailbox.tools.indexer.registrations.GlobalRegistration;
-import org.apache.mailbox.tools.indexer.registrations.MailboxRegistration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.fge.lambdas.Throwing;
-import com.google.common.collect.Lists;
class ReIndexerPerformer {
@@ -105,34 +101,27 @@ class ReIndexerPerformer {
}
private Task.Result reIndex(MailboxPath path, MailboxSession mailboxSession, ReprocessingContext reprocessingContext) throws MailboxException {
- MailboxRegistration mailboxRegistration = new MailboxRegistration(path);
LOGGER.info("Intend to reindex {}", path.asString());
Mailbox mailbox = mailboxSessionMapperFactory.getMailboxMapper(mailboxSession).findMailboxByPath(path);
messageSearchIndex.deleteAll(mailboxSession, mailbox);
- mailboxManager.addListener(path, mailboxRegistration, mailboxSession);
try {
return Iterators.toStream(
mailboxSessionMapperFactory.getMessageMapper(mailboxSession)
.findInMailbox(mailbox, MessageRange.all(), MessageMapper.FetchType.Metadata, NO_LIMIT))
.map(MailboxMessage::getUid)
- .map(uid -> handleMessageReIndexing(mailboxSession, mailboxRegistration, mailbox, uid))
+ .map(uid -> handleMessageReIndexing(mailboxSession, mailbox, uid))
.peek(reprocessingContext::updateAccordingToReprocessingResult)
.reduce(Task::combine)
.orElse(Task.Result.COMPLETED);
} finally {
LOGGER.info("Finish to reindex {}", path.asString());
- mailboxManager.removeListener(path, mailboxRegistration, mailboxSession);
}
}
- private Task.Result handleMessageReIndexing(MailboxSession mailboxSession, MailboxRegistration mailboxRegistration, Mailbox mailbox, MessageUid uid) {
+ private Task.Result handleMessageReIndexing(MailboxSession mailboxSession, Mailbox mailbox, MessageUid uid) {
try {
- Optional<ImpactingMessageEvent> impactingMessageEvent = findMostRelevant(mailboxRegistration.getImpactingEvents(uid));
-
Optional.of(uid)
- .filter(x -> !wasDeleted(impactingMessageEvent))
.flatMap(Throwing.function(mUid -> fullyReadMessage(mailboxSession, mailbox, mUid)))
- .map(message -> messageUpdateRegardingEvents(message, impactingMessageEvent))
.ifPresent(Throwing.consumer(message -> messageSearchIndex.add(mailboxSession, mailbox, message)));
return Task.Result.COMPLETED;
} catch (Exception e) {
@@ -141,24 +130,6 @@ class ReIndexerPerformer {
}
}
- private Optional<ImpactingMessageEvent> findMostRelevant(List<ImpactingMessageEvent> messageEvents) {
- for (ImpactingMessageEvent impactingMessageEvent : messageEvents) {
- if (impactingMessageEvent.getType().equals(ImpactingEventType.Deletion)) {
- return Optional.of(impactingMessageEvent);
- }
- }
- return Lists.reverse(messageEvents).stream().findFirst();
- }
-
- private boolean wasDeleted(Optional<ImpactingMessageEvent> impactingMessageEvent) {
- return impactingMessageEvent.map(ImpactingMessageEvent::wasDeleted).orElse(false);
- }
-
- private MailboxMessage messageUpdateRegardingEvents(MailboxMessage message, Optional<ImpactingMessageEvent> impactingMessageEvent) {
- impactingMessageEvent.flatMap(ImpactingMessageEvent::newFlags).ifPresent(message::setFlags);
- return message;
- }
-
private Optional<MailboxMessage> fullyReadMessage(MailboxSession mailboxSession, Mailbox mailbox, MessageUid mUid) throws MailboxException {
return Iterators.toStream(mailboxSessionMapperFactory.getMessageMapper(mailboxSession)
.findInMailbox(mailbox, MessageRange.one(mUid), MessageMapper.FetchType.Full, SINGLE_MESSAGE))
http://git-wip-us.apache.org/repos/asf/james-project/blob/9ff8a260/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/events/ImpactingMessageEvent.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/events/ImpactingMessageEvent.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/events/ImpactingMessageEvent.java
deleted file mode 100644
index 527f463..0000000
--- a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/events/ImpactingMessageEvent.java
+++ /dev/null
@@ -1,144 +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.mailbox.tools.indexer.events;
-
-import java.util.Objects;
-import java.util.Optional;
-
-import javax.mail.Flags;
-
-import org.apache.james.mailbox.MessageUid;
-import org.apache.james.mailbox.model.MailboxPath;
-
-public interface ImpactingMessageEvent extends ImpactingEvent {
-
- MessageUid getUid();
-
- Optional<Flags> newFlags();
-
- boolean wasDeleted();
-
- class FlagsMessageEvent implements ImpactingMessageEvent {
-
- private final MailboxPath mailboxPath;
- private final MessageUid uid;
- private final Flags flags;
-
- public FlagsMessageEvent(MailboxPath mailboxPath, MessageUid uid, Flags flags) {
- this.mailboxPath = mailboxPath;
- this.uid = uid;
- this.flags = flags;
- }
-
- @Override
- public MessageUid getUid() {
- return uid;
- }
-
- @Override
- public MailboxPath getMailboxPath() {
- return mailboxPath;
- }
-
- @Override
- public ImpactingEventType getType() {
- return ImpactingEventType.FlagsUpdate;
- }
-
- @Override
- public Optional<Flags> newFlags() {
- return Optional.of(flags);
- }
-
- @Override
- public boolean wasDeleted() {
- return false;
- }
-
- @Override
- public final boolean equals(Object o) {
- if (o instanceof FlagsMessageEvent) {
- FlagsMessageEvent that = (FlagsMessageEvent) o;
-
- return Objects.equals(this.mailboxPath, that.mailboxPath)
- && Objects.equals(this.uid, that.uid)
- && Objects.equals(this.flags, that.flags);
- }
- return false;
- }
-
- @Override
- public final int hashCode() {
- return Objects.hash(mailboxPath, uid, flags);
- }
- }
-
- class MessageDeletedEvent implements ImpactingMessageEvent {
-
- private final MailboxPath mailboxPath;
- private final MessageUid uid;
-
- public MessageDeletedEvent(MailboxPath mailboxPath, MessageUid uid) {
- this.mailboxPath = mailboxPath;
- this.uid = uid;
- }
-
- @Override
- public MessageUid getUid() {
- return uid;
- }
-
- @Override
- public MailboxPath getMailboxPath() {
- return mailboxPath;
- }
-
- @Override
- public ImpactingEventType getType() {
- return ImpactingEventType.Deletion;
- }
-
- @Override
- public Optional<Flags> newFlags() {
- return Optional.empty();
- }
-
- @Override
- public boolean wasDeleted() {
- return true;
- }
-
- @Override
- public final boolean equals(Object o) {
- if (o instanceof MessageDeletedEvent) {
- MessageDeletedEvent that = (MessageDeletedEvent) o;
-
- return Objects.equals(this.mailboxPath, that.mailboxPath)
- && Objects.equals(this.uid, that.uid);
- }
- return false;
- }
-
- @Override
- public final int hashCode() {
- return Objects.hash(mailboxPath, uid);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/9ff8a260/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/registrations/MailboxRegistration.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/registrations/MailboxRegistration.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/registrations/MailboxRegistration.java
deleted file mode 100644
index 251fde8..0000000
--- a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/registrations/MailboxRegistration.java
+++ /dev/null
@@ -1,70 +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.mailbox.tools.indexer.registrations;
-
-import java.util.List;
-
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
-import org.apache.james.mailbox.MessageUid;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.model.UpdatedFlags;
-import org.apache.mailbox.tools.indexer.events.ImpactingMessageEvent;
-import org.apache.mailbox.tools.indexer.events.ImpactingMessageEvent.FlagsMessageEvent;
-import org.apache.mailbox.tools.indexer.events.ImpactingMessageEvent.MessageDeletedEvent;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.Multimaps;
-
-public class MailboxRegistration implements MailboxListener {
-
- private final Multimap<MessageUid, ImpactingMessageEvent> impactingMessageEvents;
- private final MailboxPath mailboxPath;
-
- public MailboxRegistration(MailboxPath mailboxPath) {
- this.impactingMessageEvents = Multimaps.synchronizedMultimap(ArrayListMultimap.<MessageUid, ImpactingMessageEvent>create());
- this.mailboxPath = mailboxPath;
- }
-
- @Override
- public ListenerType getType() {
- return ListenerType.MAILBOX;
- }
-
- public List<ImpactingMessageEvent> getImpactingEvents(MessageUid uid) {
- return ImmutableList.copyOf(impactingMessageEvents.get(uid));
- }
-
- @Override
- public void event(Event event) {
- if (event instanceof FlagsUpdated) {
- for (UpdatedFlags updatedFlags : ((FlagsUpdated) event).getUpdatedFlags()) {
- impactingMessageEvents.put(updatedFlags.getUid(), new FlagsMessageEvent(mailboxPath, updatedFlags.getUid(), updatedFlags.getNewFlags()));
- }
- } else if (event instanceof Expunged) {
- for (MessageUid uid: ((Expunged) event).getUids()) {
- impactingMessageEvents.put(uid, new MessageDeletedEvent(mailboxPath, uid));
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/9ff8a260/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/registrations/MailboxRegistrationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/registrations/MailboxRegistrationTest.java b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/registrations/MailboxRegistrationTest.java
deleted file mode 100644
index 3b9bad2..0000000
--- a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/registrations/MailboxRegistrationTest.java
+++ /dev/null
@@ -1,107 +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.mailbox.tools.indexer.registrations;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.Date;
-import java.util.TreeMap;
-
-import javax.mail.Flags;
-
-import org.apache.james.mailbox.MailboxListener;
-import org.apache.james.mailbox.MessageUid;
-import org.apache.james.mailbox.mock.MockMailboxSession;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.model.MessageMetaData;
-import org.apache.james.mailbox.model.UpdatedFlags;
-import org.apache.james.mailbox.store.SimpleMessageMetaData;
-import org.apache.james.mailbox.store.event.EventFactory;
-import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
-import org.apache.james.mailbox.store.mail.model.MailboxMessage;
-import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
-import org.apache.mailbox.tools.indexer.events.ImpactingMessageEvent.FlagsMessageEvent;
-import org.apache.mailbox.tools.indexer.events.ImpactingMessageEvent.MessageDeletedEvent;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-
-public class MailboxRegistrationTest {
-
- public static final MailboxPath INBOX = MailboxPath.forUser("btellier@apache.org", "INBOX");
- private static final MessageUid UID = MessageUid.of(18);
- private static final int UID_VALIDITY = 45;
- private static final SimpleMailbox MAILBOX = new SimpleMailbox(INBOX, UID_VALIDITY);
- private static final int MOD_SEQ = 21;
- private static final int SIZE = 41;
- private static final Flags NEW_FLAGS = new Flags(Flags.Flag.ANSWERED);
- private MailboxRegistration mailboxRegistration;
- private EventFactory eventFactory;
- private MockMailboxSession session;
-
- @BeforeEach
- void setUp() {
- session = new MockMailboxSession("test");
- eventFactory = new EventFactory();
- mailboxRegistration = new MailboxRegistration(INBOX);
- }
-
- @Test
- void reportedEventsShouldBeInitiallyEmpty() {
- assertThat(mailboxRegistration.getImpactingEvents(UID)).isEmpty();
- }
-
-
- @Test
- void addedEventsShouldNotBeReported() {
- TreeMap<MessageUid, MessageMetaData> treeMap = new TreeMap<>();
- treeMap.put(UID, new SimpleMessageMetaData(UID, MOD_SEQ, new Flags(), SIZE, new Date(), new DefaultMessageId()));
- MailboxListener.MailboxEvent event = eventFactory.added(session, treeMap, MAILBOX, ImmutableMap.<MessageUid, MailboxMessage>of());
- mailboxRegistration.event(event);
- assertThat(mailboxRegistration.getImpactingEvents(UID)).isEmpty();
- }
-
- @Test
- void expungedEventsShouldBeReported() {
- TreeMap<MessageUid, MessageMetaData> treeMap = new TreeMap<>();
- treeMap.put(UID, new SimpleMessageMetaData(UID, MOD_SEQ, new Flags(), SIZE, new Date(), new DefaultMessageId()));
- MailboxListener.MailboxEvent event = eventFactory.expunged(session, treeMap, MAILBOX);
- mailboxRegistration.event(event);
- assertThat(mailboxRegistration.getImpactingEvents(UID)).containsExactly(new MessageDeletedEvent(INBOX, UID));
- }
-
- @Test
- void flagsEventsShouldBeReported() {
- MailboxListener.MailboxEvent event = eventFactory.flagsUpdated(session,
- Lists.newArrayList(UID),
- MAILBOX,
- Lists.newArrayList(UpdatedFlags.builder()
- .uid(UID)
- .modSeq(MOD_SEQ)
- .oldFlags(new Flags())
- .newFlags(NEW_FLAGS)
- .build()));
- mailboxRegistration.event(event);
- assertThat(mailboxRegistration.getImpactingEvents(UID)).containsExactly(new FlagsMessageEvent(INBOX, UID, NEW_FLAGS));
- }
-
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[07/17] james-project git commit: JAMES-2525 Keystone 3 should use
keystone3 API name
Posted by bt...@apache.org.
JAMES-2525 Keystone 3 should use keystone3 API name
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/a9c91974
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/a9c91974
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/a9c91974
Branch: refs/heads/master
Commit: a9c9197460c56ce2ef4c8366acec4bb79f6eb9a4
Parents: cb4adef
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Thu Oct 11 11:41:38 2018 +0200
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:17:08 2018 +0700
----------------------------------------------------------------------
.../blob/objectstorage/swift/SwiftKeystone3ObjectStorage.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/a9c91974/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone3ObjectStorage.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone3ObjectStorage.java b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone3ObjectStorage.java
index 13350ea..6262eb9 100644
--- a/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone3ObjectStorage.java
+++ b/server/blob/blob-objectstorage/src/main/java/org/apache/james/blob/objectstorage/swift/SwiftKeystone3ObjectStorage.java
@@ -40,7 +40,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
public class SwiftKeystone3ObjectStorage {
- public static final String AUTH_API_NAME = "keystone2";
+ public static final String AUTH_API_NAME = "keystone3";
private static final Iterable<Module> JCLOUDS_MODULES =
ImmutableSet.of(new SLF4JLoggingModule());
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[15/17] james-project git commit: JAMES-2555 Update documentation
accordingly
Posted by bt...@apache.org.
JAMES-2555 Update documentation accordingly
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/10a19a66
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/10a19a66
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/10a19a66
Branch: refs/heads/master
Commit: 10a19a66c6fb5091478e76aba9123d5579470c1f
Parents: 9ff8a26
Author: Benoit Tellier <bt...@linagora.com>
Authored: Fri Oct 12 17:05:58 2018 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:18:20 2018 +0700
----------------------------------------------------------------------
.../org/apache/mailbox/tools/indexer/ReIndexerImpl.java | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/10a19a66/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java
index 415aacc..0ef72c4 100644
--- a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java
@@ -29,13 +29,10 @@ import org.apache.james.task.Task;
* Note about live re-indexation handling :
*
* - Data races may arise... If you modify the stored value between the received event check and the index operation,
- * you have an inconsistent behavior.
+ * you have an inconsistent behavior (for mailbox renames).
*
- * This class is more about supporting changes in real time for future indexed values. If you change a flags / delete
- * mails for instance, you will see it in the indexed value !
- *
- * Why only care about updates and deletions ? Additions are already handled by the indexer that behaves normaly. We
- * should just "adapt" our indexed value to the latest value, if any. The normal indexer will take care of new stuff.
+ * A mechanism for tracking mailbox renames had been implemented, and is taken into account when starting re-indexing a mailbox.
+ * Note that if a mailbox is renamed during its re-indexation process, it will not be taken into account. (We just reduce the inconsistency window).
*/
public class ReIndexerImpl implements ReIndexer {
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[03/17] james-project git commit: JAMES-2562 JMAP should Handle
messages inlined messages with CID but without content disposition
Posted by bt...@apache.org.
JAMES-2562 JMAP should Handle messages inlined messages with CID but without content disposition
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/3bdf79b4
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/3bdf79b4
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/3bdf79b4
Branch: refs/heads/master
Commit: 3bdf79b4424993ed9af8ee0716f8ad0d70ac4807
Parents: d5d5c9c
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Fri Oct 12 17:38:25 2018 +0200
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:16:06 2018 +0700
----------------------------------------------------------------------
.../store/mail/model/impl/MessageParser.java | 6 +-
.../mail/model/impl/MessageParserTest.java | 7 ++
.../eml/noContentDispositionWithCID.eml | 23 +++++++
.../cucumber/GetMessagesMethodStepdefs.java | 7 +-
.../test/resources/cucumber/GetMessages.feature | 14 ++++
...oneInlinedImageWithoutContentDisposition.eml | 72 ++++++++++++++++++++
6 files changed, 127 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/3bdf79b4/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
index 7bb86c9..fc78eb4 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
@@ -190,7 +190,7 @@ public class MessageParser {
if (context == Context.BODY && isTextPart(part)) {
return false;
}
- return attachmentDispositionCriterion(part) || attachmentContentTypeCriterion(part);
+ return attachmentDispositionCriterion(part) || attachmentContentTypeCriterion(part) || hadCID(part);
}
private boolean isTextPart(Entity part) {
@@ -217,6 +217,10 @@ public class MessageParser {
.orElse(false);
}
+ private boolean hadCID(Entity part) {
+ return readHeader(part, CONTENT_ID, ContentIdField.class).isPresent();
+ }
+
private byte[] getBytes(Body body) throws IOException {
DefaultMessageWriter messageWriter = new DefaultMessageWriter();
ByteArrayOutputStream out = new ByteArrayOutputStream();
http://git-wip-us.apache.org/repos/asf/james-project/blob/3bdf79b4/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java
index ff2d9a2..abb864f 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/MessageParserTest.java
@@ -230,6 +230,13 @@ public class MessageParserTest {
}
@Test
+ public void getAttachmentsShouldConsiderNoContentDispositionAsAttachmentsWhenCID() throws Exception {
+ List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/noContentDispositionWithCID.eml"));
+
+ assertThat(attachments).hasSize(1);
+ }
+
+ @Test
public void getAttachmentsShouldRetrieveAttachmentsWhenNoCidForInlined() throws Exception {
List<MessageAttachment> attachments = testee.retrieveAttachments(ClassLoader.getSystemResourceAsStream("eml/oneInlinedAttachmentWithNoCid.eml"));
http://git-wip-us.apache.org/repos/asf/james-project/blob/3bdf79b4/mailbox/store/src/test/resources/eml/noContentDispositionWithCID.eml
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/resources/eml/noContentDispositionWithCID.eml b/mailbox/store/src/test/resources/eml/noContentDispositionWithCID.eml
new file mode 100644
index 0000000..fae090d
--- /dev/null
+++ b/mailbox/store/src/test/resources/eml/noContentDispositionWithCID.eml
@@ -0,0 +1,23 @@
+To: me@linagora.com
+From: Benoit Tellier <me...@linagora.com>
+Subject: Mail with text attachment
+Message-ID: <be...@any.com>
+Date: Thu, 13 Oct 2016 10:26:20 +0200
+MIME-Version: 1.0
+Content-Type: multipart/mixed;
+ boundary="------------4FD2D252DB453546C22C25B2"
+
+This is a multi-part message in MIME format.
+--------------4FD2D252DB453546C22C25B2
+Content-Type: text/plain; charset=utf-8
+Content-Transfer-Encoding: 7bit
+
+I'm the body!
+
+--------------4FD2D252DB453546C22C25B2
+Content-Type: text/plain; charset=UTF-8;
+ name="attachment.txt"
+Content-ID: <id>
+
+I'm a Schroedinger cat
+--------------4FD2D252DB453546C22C25B2--
http://git-wip-us.apache.org/repos/asf/james-project/blob/3bdf79b4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
index 13819e5..d3818d3 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java
@@ -335,10 +335,15 @@ public class GetMessagesMethodStepdefs {
}
@Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in the \"([^\"]*)\" mailbox with inlined attachments without content disposition$")
- public void appendMessageWithInlinedImageButNoContentDisposition(String username, String messageName, String mailbox) throws Exception {
+ public void appendMessageWithInlinedAttachmentButNoContentDisposition(String username, String messageName, String mailbox) throws Exception {
userStepdefs.execWithUser(username, () -> appendMessage(messageName, mailbox, "eml/inlinedWithoutContentDisposition.eml"));
}
+ @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in the \"([^\"]*)\" mailbox with inlined image without content disposition$")
+ public void appendMessageWithInlinedImageButNoContentDisposition(String username, String messageName, String mailbox) throws Exception {
+ userStepdefs.execWithUser(username, () -> appendMessage(messageName, mailbox, "eml/oneInlinedImageWithoutContentDisposition.eml"));
+ }
+
@Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in the \"([^\"]*)\" mailbox with inlined image without content ID$")
public void appendMessageWithInlinedImageButNoContentID(String username, String messageName, String mailbox) throws Exception {
userStepdefs.execWithUser(username, () -> appendMessage(messageName, mailbox, "eml/inlinedWithoutContentID.eml"));
http://git-wip-us.apache.org/repos/asf/james-project/blob/3bdf79b4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
index 7e79e5c..efd23d5 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
@@ -406,6 +406,20 @@ Feature: GetMessages method
|name |"encrypted.asc" |
|isInline |false |
+ Scenario: Retrieving message should be possible when message with inlined image but without content disposition
+ Given "alice@domain.tld" has a message "m1" in the "INBOX" mailbox with inlined image without content disposition
+ When "alice@domain.tld" ask for messages "m1"
+ Then no error is returned
+ And the list should contain 1 message
+ And the hasAttachment of the message is "true"
+ And the list of attachments of the message contains 1 attachments
+ And the first attachment is:
+ |key | value |
+ |type |"image/png" |
+ |cid |"14672787885774e5c4d4cee471352039@linagora.com" |
+ |name |"vlc.png" |
+ |isInline |false |
+
Scenario: Retrieving message should be possible when message with inlined attachment but without content ID
Given "alice@domain.tld" has a message "m1" in the "INBOX" mailbox with inlined image without content ID
When "alice@domain.tld" ask for messages "m1"
http://git-wip-us.apache.org/repos/asf/james-project/blob/3bdf79b4/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/oneInlinedImageWithoutContentDisposition.eml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/oneInlinedImageWithoutContentDisposition.eml b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/oneInlinedImageWithoutContentDisposition.eml
new file mode 100644
index 0000000..6e165cf
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/oneInlinedImageWithoutContentDisposition.eml
@@ -0,0 +1,72 @@
+Return-Path: <te...@linagora.com>
+MIME-Version: 1.0
+Content-Type: multipart/alternative;
+ boundary="=_78be9b39405e216b14ea426a30eef65c"
+Date: Thu, 30 Jun 2016 11:26:28 +0200
+From: Test <te...@linagora.com>
+To: test <te...@linagora.com>
+Subject: Mail with inlined image
+Message-ID: <e5...@linagora.com>
+X-Sender: test@linagora.com
+User-Agent: Roundcube Webmail/1.1.4
+
+--=_78be9b39405e216b14ea426a30eef65c
+Content-Transfer-Encoding: 7bit
+Content-Type: text/plain; charset=US-ASCII
+
+Inlined image:
+
+Signature.
+--=_78be9b39405e216b14ea426a30eef65c
+Content-Type: multipart/related;
+ boundary="=_09507e56cd9618e600636c7ef4ea9f8f"
+
+--=_09507e56cd9618e600636c7ef4ea9f8f
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/html; charset=UTF-8
+
+<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=
+=3DUTF-8" /></head><body style=3D'font-size: 10pt; font-family: Verdana,Gen=
+eva,sans-serif'>
+<p>Inlined image:</p>
+<p><img src=3D"cid:14672787885774e5c4d4cee471352039@linagora.com" alt=3D"" =
+width=3D"32" height=3D"32" /></p>
+<p>Signature.</p>
+</body></html>
+
+--=_09507e56cd9618e600636c7ef4ea9f8f
+Content-Transfer-Encoding: base64
+Content-ID: <14...@linagora.com>
+Content-Type: image/png;
+ name=vlc.png
+
+iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAFrUlEQVRYw8WWW2wc1RnHf+fMZS+z
+O7veXXZtr+M4Bl+IHNwrSau0ahEkNIloeCgttKoaJFT1oZUqRUJqEaqqPoAoSLRqK4FaISFUIVQQ
+IMETCBmqBpSGm9OIOKbEju11vNfZnZ29zUwfxiGUkta17PZIZ85I55zv+8///11G+L7P/3Oom704
+c2ff8R169ftCF2LBijz65cfs+zdjR2yGgSe+O5KciizOT2S9lBaF2bPCOtXIjB576mLpv7UlN/X5
+DWt/POKlXBd6LiQivql1e1/ajKlNAYhJ55AhgRaILpgaxGjd/D+R4JcPPahPpDgzHZ0bDbUdhGhi
+qzn+vJT425LfN3338eO9bQ3C/PDoFz0zPeLuOcaq0yYeCbFSrDI4XL529dRf9wBvbqsEyyuF/SP5
+q6RdK2HqPrZVJmMoVCtlkR/I3bHtMTA+dvVttuMQixlYdZuYEaVWbzCcH6Swunb9tgJ4/Mmnd5fr
+zlgmlabesDHjBg27SdKMU7HqjI2P773v4d8NbxsA56WH9l17lRa2bJuYmaTaBsNMU3Vcspk01tzJ
+UHb+2Ru3LQjN8385HP3jUZLXXI00hsipCWQIdno1eoUFxt+e5/RF/yDwhy1Pw9/fviuetRffmxh0
+B/pM0NugeiBjIMLQacOFBZgtKIVaenDyricXalsqgddsfj6mugOKCijgSXB18FTwlIBLLQRR4fZ7
+dnPflseA1ra/FgmBAPAB7yObPggJmgpRHdRu5+YtBfDrH92ihEXvQFiCFIHDS8r5l94FqCpEFFA7
+7QO/+uERdcsA2BO37g4fuXtKJLMoLsh2MEUXRAdkB9QuaIBMZbE/c9tk6is/2JAMG0I5lDa+VfKv
+kzuOPc/a0uvE63OolSV00USq4IYNHD1HWR9nSQwyFEvLd956cz8cfm1LAJz7YOn6G/bvpdjoMDT1
+dcqtHolYlFLTCdaajRHRqSyvkAspnD49y8iu0W8A920qDS+ceFxV3vjtt/2WkzlXdKOFL/ziJ4qi
+hEdHduK0OqTTfVRqdVLJBDWrjhmPsVYsYUTDnD+/iGFEef3kKWfk9CMP9HcLlhqJlSojn3vi1nue
+6W6Ige6ZZ78a++DEY3YRqr1hlosWe6cnKZXK5PODVCpVkonAecKMU65U6UuYLK8U6M9lmTs3z8Tk
+7kjx5da9o+0qmVSVdj2/ALy8oSCM1M4d9T1o+tBeXmGH9S6FSoN0doByrUHCTFCp1jDjBpVqjaQZ
+p1Spkc5kKFQa5HfuonbiTyhWCcsH14N0e+2WDWXB+Rfv0bXG4o0e4HjQ63bJvvoA/TM/o/nOcyTU
+DuVqGSORpNzoEo0nKdZbmDGD2vIcw933kU//mKE3HkW260HBAgyneOCVh7+p/UcJtFbh00q7POZp
+YHcuF5j4/AyRlRnUkyaG3o8fTROPxhASkp6N0i6Sb67QK9XRinBRBVUBRQWpQaRnTWQj3Wng5L8F
+oNfnjkiBQIVMEipl8D1AD05Lx0IpWaiAqoFUQWggVPAE9BRQ9IDahA5D/ZDqg2gCmc51Dn8cwD9J
+sPrq/TLkzB1SIqBEYWAHTF0DEQFeB7ze+hRBD3AVcOW6Yx96XfB7oAhIGfDZPbBrEsxBCKVBa84e
+smYfEVdkQHfXJnV/9TqMwJGUkAtBOg2tBnQc8Lrrtd8LnPl+0BakEpRiPQJmDlQJ0gDCAYMyBMK7
+8CnXLY8BZz8ZQPvvBzXdUz0VFDfoer4elNlEIqDLdz/CRA+EEmishECELveJXutyq8YPJBKaq2vO
+uzddEUCYMwdlEqS33u1k0GQ8Fbw6+CJwosh/DR5//eETnNOyIDPBfcS6LRW0zmvfAX7ziQCs99/b
+l5w+tG7lMgAxAEqPIJ8ueRMfK6mXVhkwhxYA+XB/HYS7+MI+9Uox8NQzyZ9PzbzwINs4zhYTP/3e
+0U38km3X+Aeuu0L8ysHGdwAAAABJRU5ErkJggg==
+--=_09507e56cd9618e600636c7ef4ea9f8f--
+
+--=_78be9b39405e216b14ea426a30eef65c--
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[16/17] james-project git commit: JAMES-2555 Allowing per-user
re-indexing
Posted by bt...@apache.org.
JAMES-2555 Allowing per-user re-indexing
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/a8731817
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/a8731817
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/a8731817
Branch: refs/heads/master
Commit: a87318174034b918115191dc90ddbe4a620952f3
Parents: 10a19a6
Author: Benoit Tellier <bt...@linagora.com>
Authored: Fri Oct 12 17:41:28 2018 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:19:39 2018 +0700
----------------------------------------------------------------------
.../apache/james/mailbox/indexer/ReIndexer.java | 3 +
.../mailbox/tools/indexer/ReIndexerImpl.java | 6 ++
.../tools/indexer/ReIndexerPerformer.java | 46 ++++++++--
.../mailbox/tools/indexer/ThrowsReIndexer.java | 6 ++
.../tools/indexer/UserReindexingTask.java | 88 ++++++++++++++++++++
.../tools/indexer/ReIndexerImplTest.java | 25 ++++++
6 files changed, 167 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/a8731817/mailbox/api/src/main/java/org/apache/james/mailbox/indexer/ReIndexer.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/indexer/ReIndexer.java b/mailbox/api/src/main/java/org/apache/james/mailbox/indexer/ReIndexer.java
index 94304a7..5ed156e 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/indexer/ReIndexer.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/indexer/ReIndexer.java
@@ -19,12 +19,15 @@
package org.apache.james.mailbox.indexer;
+import org.apache.james.core.User;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.task.Task;
public interface ReIndexer {
+ Task reIndex(User user) throws MailboxException;
+
Task reIndex(MailboxPath path) throws MailboxException;
Task reIndex() throws MailboxException;
http://git-wip-us.apache.org/repos/asf/james-project/blob/a8731817/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java
index 0ef72c4..8fd3786 100644
--- a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerImpl.java
@@ -21,6 +21,7 @@ package org.apache.mailbox.tools.indexer;
import javax.inject.Inject;
+import org.apache.james.core.User;
import org.apache.james.mailbox.indexer.ReIndexer;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.task.Task;
@@ -53,4 +54,9 @@ public class ReIndexerImpl implements ReIndexer {
return new FullReindexingTask(reIndexerPerformer);
}
+ @Override
+ public Task reIndex(User user) {
+ return new UserReindexingTask(reIndexerPerformer, user);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/a8731817/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
index ce88882..fb5bf89 100644
--- a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ReIndexerPerformer.java
@@ -21,15 +21,19 @@ package org.apache.mailbox.tools.indexer;
import java.util.List;
import java.util.Optional;
+import java.util.function.Function;
import javax.inject.Inject;
+import org.apache.james.core.User;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MessageUid;
import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxMetaData;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageRange;
+import org.apache.james.mailbox.model.search.MailboxQuery;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
import org.apache.james.mailbox.store.mail.MessageMapper;
import org.apache.james.mailbox.store.mail.model.Mailbox;
@@ -43,9 +47,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.fge.lambdas.Throwing;
+import com.google.common.collect.ImmutableList;
class ReIndexerPerformer {
-
private static final Logger LOGGER = LoggerFactory.getLogger(ReIndexerPerformer.class);
private static final int NO_LIMIT = 0;
@@ -73,18 +77,37 @@ class ReIndexerPerformer {
MailboxSession mailboxSession = mailboxManager.createSystemSession("re-indexing");
LOGGER.info("Starting a full reindex");
List<MailboxPath> mailboxPaths = mailboxManager.list(mailboxSession);
- GlobalRegistration globalRegistration = new GlobalRegistration();
- mailboxManager.addGlobalListener(globalRegistration, mailboxSession);
+
try {
- return handleFullReindexingIterations(mailboxPaths, globalRegistration, reprocessingContext);
+ return reIndex(mailboxPaths, mailboxSession, reprocessingContext);
} finally {
- mailboxManager.removeGlobalListener(globalRegistration, mailboxSession);
LOGGER.info("Full reindex finished");
}
}
- private Task.Result handleFullReindexingIterations(List<MailboxPath> mailboxPaths, GlobalRegistration globalRegistration,
- ReprocessingContext reprocessingContext) {
+ Task.Result reIndex(User user, ReprocessingContext reprocessingContext) throws MailboxException {
+ MailboxSession mailboxSession = mailboxManager.createSystemSession(user.asString());
+ LOGGER.info("Starting a reindex for user {}", user.asString());
+ List<MailboxPath> mailboxPaths = mailboxManager.search(MailboxQuery.privateMailboxesBuilder(mailboxSession)
+ .build(), mailboxSession)
+ .stream()
+ .map(MailboxMetaData::getPath)
+ .collect(ImmutableList.toImmutableList());
+
+ try {
+ return reIndex(mailboxPaths, mailboxSession, reprocessingContext);
+ } finally {
+ LOGGER.info("User {} reindex finished", user.asString());
+ }
+ }
+
+ private Task.Result reIndex(List<MailboxPath> mailboxPaths, MailboxSession mailboxSession, ReprocessingContext reprocessingContext) throws MailboxException {
+ return wrapInGlobalRegistration(mailboxSession,
+ globalRegistration -> handleMultiMailboxesReindexingIterations(mailboxPaths, globalRegistration, reprocessingContext));
+ }
+
+ private Task.Result handleMultiMailboxesReindexingIterations(List<MailboxPath> mailboxPaths, GlobalRegistration globalRegistration,
+ ReprocessingContext reprocessingContext) {
return mailboxPaths.stream()
.map(globalRegistration::getPathToIndex)
.flatMap(OptionalUtils::toStream)
@@ -136,4 +159,13 @@ class ReIndexerPerformer {
.findFirst();
}
+ private <T> T wrapInGlobalRegistration(MailboxSession session, Function<GlobalRegistration, T> function) throws MailboxException {
+ GlobalRegistration globalRegistration = new GlobalRegistration();
+ mailboxManager.addGlobalListener(globalRegistration, session);
+ try {
+ return function.apply(globalRegistration);
+ } finally {
+ mailboxManager.removeGlobalListener(globalRegistration, session);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/a8731817/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ThrowsReIndexer.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ThrowsReIndexer.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ThrowsReIndexer.java
index 6734795..f0d86ae 100644
--- a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ThrowsReIndexer.java
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/ThrowsReIndexer.java
@@ -19,6 +19,7 @@
package org.apache.mailbox.tools.indexer;
+import org.apache.james.core.User;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.indexer.ReIndexer;
import org.apache.james.mailbox.model.MailboxPath;
@@ -35,4 +36,9 @@ public class ThrowsReIndexer implements ReIndexer {
public Task reIndex() throws MailboxException {
throw new MailboxException("Not implemented");
}
+
+ @Override
+ public Task reIndex(User user) throws MailboxException {
+ throw new MailboxException("Not implemented");
+ }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/a8731817/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/UserReindexingTask.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/UserReindexingTask.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/UserReindexingTask.java
new file mode 100644
index 0000000..dab53e7
--- /dev/null
+++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/UserReindexingTask.java
@@ -0,0 +1,88 @@
+/****************************************************************
+ * 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.mailbox.tools.indexer;
+
+import java.util.Optional;
+
+import javax.inject.Inject;
+
+import org.apache.james.core.User;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.task.Task;
+import org.apache.james.task.TaskExecutionDetails;
+
+public class UserReindexingTask implements Task {
+
+ public static final String USER_RE_INDEXING = "userReIndexing";
+
+ public static class AdditionalInformation implements TaskExecutionDetails.AdditionalInformation {
+ private final ReprocessingContext reprocessingContext;
+ private final User user;
+
+ AdditionalInformation(ReprocessingContext reprocessingContext, User user) {
+ this.reprocessingContext = reprocessingContext;
+ this.user = user;
+ }
+
+ public int getSuccessfullyReprocessMailCount() {
+ return reprocessingContext.successfullyReprocessedMailCount();
+ }
+
+ public int getFailedReprocessedMailCount() {
+ return reprocessingContext.failedReprocessingMailCount();
+ }
+
+ public String getUser() {
+ return user.asString();
+ }
+ }
+
+ private final ReIndexerPerformer reIndexerPerformer;
+ private final User user;
+ private final AdditionalInformation additionalInformation;
+ private final ReprocessingContext reprocessingContext;
+
+ @Inject
+ public UserReindexingTask(ReIndexerPerformer reIndexerPerformer, User user) {
+ this.reIndexerPerformer = reIndexerPerformer;
+ this.user = user;
+ this.reprocessingContext = new ReprocessingContext();
+ this.additionalInformation = new AdditionalInformation(reprocessingContext, user);
+ }
+
+ @Override
+ public Result run() {
+ try {
+ return reIndexerPerformer.reIndex(user, reprocessingContext);
+ } catch (MailboxException e) {
+ return Result.PARTIAL;
+ }
+ }
+
+ @Override
+ public String type() {
+ return USER_RE_INDEXING;
+ }
+
+ @Override
+ public Optional<TaskExecutionDetails.AdditionalInformation> details() {
+ return Optional.of(additionalInformation);
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/a8731817/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
----------------------------------------------------------------------
diff --git a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
index 003601e..d1fed69 100644
--- a/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
+++ b/mailbox/tools/indexer/src/test/java/org/apache/mailbox/tools/indexer/ReIndexerImplTest.java
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
+import org.apache.james.core.User;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MessageManager;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
@@ -108,4 +109,28 @@ public class ReIndexerImplTest {
assertThat(messageCaptor.getValue()).matches(message -> message.getMailboxId().equals(mailboxId)
&& message.getUid().equals(createdMessage.getUid()));
}
+
+ @Test
+ void userReIndexShouldBeWellPerformed() throws Exception {
+ MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME);
+ MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get();
+ ComposedMessageId createdMessage = mailboxManager.getMailbox(INBOX, systemSession)
+ .appendMessage(
+ MessageManager.AppendCommand.builder().build("header: value\r\n\r\nbody"),
+ systemSession);
+
+ reIndexer.reIndex(User.fromUsername(USERNAME)).run();
+ ArgumentCaptor<MailboxMessage> messageCaptor = ArgumentCaptor.forClass(MailboxMessage.class);
+ ArgumentCaptor<Mailbox> mailboxCaptor1 = ArgumentCaptor.forClass(Mailbox.class);
+ ArgumentCaptor<Mailbox> mailboxCaptor2 = ArgumentCaptor.forClass(Mailbox.class);
+
+ verify(messageSearchIndex).deleteAll(any(MailboxSession.class), mailboxCaptor1.capture());
+ verify(messageSearchIndex).add(any(MailboxSession.class), mailboxCaptor2.capture(), messageCaptor.capture());
+ verifyNoMoreInteractions(messageSearchIndex);
+
+ assertThat(mailboxCaptor1.getValue()).matches(mailbox -> mailbox.getMailboxId().equals(mailboxId));
+ assertThat(mailboxCaptor2.getValue()).matches(mailbox -> mailbox.getMailboxId().equals(mailboxId));
+ assertThat(messageCaptor.getValue()).matches(message -> message.getMailboxId().equals(mailboxId)
+ && message.getUid().equals(createdMessage.getUid()));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[02/17] james-project git commit: JAMES-2562 Change some return types
to boolean instead of Boolean
Posted by bt...@apache.org.
JAMES-2562 Change some return types to boolean instead of Boolean
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/2610d11f
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/2610d11f
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/2610d11f
Branch: refs/heads/master
Commit: 2610d11f3757ac396ee9a9fbfad37aadba784c95
Parents: 3bdf79b
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Fri Oct 12 17:39:29 2018 +0200
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:16:06 2018 +0700
----------------------------------------------------------------------
.../james/mailbox/store/mail/model/impl/MessageParser.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/2610d11f/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
index fc78eb4..50b849d 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
@@ -201,7 +201,7 @@ public class MessageParser {
.orElse(false);
}
- private Boolean attachmentContentTypeCriterion(Entity part) {
+ private boolean attachmentContentTypeCriterion(Entity part) {
return getContentTypeField(part)
.map(ContentTypeField::getMimeType)
.map(dispositionType -> dispositionType.toLowerCase(Locale.US))
@@ -209,7 +209,7 @@ public class MessageParser {
.orElse(false);
}
- private Boolean attachmentDispositionCriterion(Entity part) {
+ private boolean attachmentDispositionCriterion(Entity part) {
return getContentDispositionField(part)
.map(ContentDispositionField::getDispositionType)
.map(dispositionType -> dispositionType.toLowerCase(Locale.US))
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[10/17] james-project git commit: JAMES-2525 Fix typo
Posted by bt...@apache.org.
JAMES-2525 Fix typo
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/787695d6
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/787695d6
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/787695d6
Branch: refs/heads/master
Commit: 787695d6008003a91a4e727f267c6c9530561652
Parents: e18abb6
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Thu Oct 11 11:55:01 2018 +0200
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:17:08 2018 +0700
----------------------------------------------------------------------
.../SwiftKeystone2ConfigurationReaderTest.java | 8 ++++----
.../SwiftTmpAuthConfigurationReaderTest.java | 12 ++++++------
2 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/787695d6/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/SwiftKeystone2ConfigurationReaderTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/SwiftKeystone2ConfigurationReaderTest.java b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/SwiftKeystone2ConfigurationReaderTest.java
index 2b6f81b..83ed3c9 100644
--- a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/SwiftKeystone2ConfigurationReaderTest.java
+++ b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/SwiftKeystone2ConfigurationReaderTest.java
@@ -97,7 +97,7 @@ class SwiftKeystone2ConfigurationReaderTest {
}
@Test
- void failToReadSwiftKeyston2ConfigurationWhenMissingEndpoint() throws Exception {
+ void failToReadSwiftKeystone2ConfigurationWhenMissingEndpoint() throws Exception {
PropertiesConfiguration configuration = new PropertiesConfiguration();
configuration.load(new StringReader(StringUtils.joinWith("\n",
CONFIG_CREDENTIALS,
@@ -110,7 +110,7 @@ class SwiftKeystone2ConfigurationReaderTest {
}
@Test
- void failToReadSwiftKeyston2ConfigurationWhenMissingCrendentials() throws Exception {
+ void failToReadSwiftKeystone2ConfigurationWhenMissingCrendentials() throws Exception {
PropertiesConfiguration configuration = new PropertiesConfiguration();
configuration.load(new StringReader(StringUtils.joinWith("\n",
CONFIG_ENDPOINT,
@@ -123,7 +123,7 @@ class SwiftKeystone2ConfigurationReaderTest {
}
@Test
- void failToReadSwiftKeyston2ConfigurationWhenMissingUserName() throws Exception {
+ void failToReadSwiftKeystone2ConfigurationWhenMissingUserName() throws Exception {
PropertiesConfiguration configuration = new PropertiesConfiguration();
configuration.load(new StringReader(StringUtils.joinWith("\n",
CONFIG_ENDPOINT,
@@ -136,7 +136,7 @@ class SwiftKeystone2ConfigurationReaderTest {
}
@Test
- void failToReadSwiftKeyston2ConfigurationWhenMissingTenantName() throws Exception {
+ void failToReadSwiftKeystone2ConfigurationWhenMissingTenantName() throws Exception {
PropertiesConfiguration configuration = new PropertiesConfiguration();
configuration.load(new StringReader(StringUtils.joinWith("\n",
CONFIG_ENDPOINT,
http://git-wip-us.apache.org/repos/asf/james-project/blob/787695d6/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/SwiftTmpAuthConfigurationReaderTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/SwiftTmpAuthConfigurationReaderTest.java b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/SwiftTmpAuthConfigurationReaderTest.java
index f5c2b7e..5eeb96e 100644
--- a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/SwiftTmpAuthConfigurationReaderTest.java
+++ b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/SwiftTmpAuthConfigurationReaderTest.java
@@ -86,7 +86,7 @@ class SwiftTmpAuthConfigurationReaderTest {
}
@Test
- void readKeystone2ConfigurationWithRegion() throws Exception {
+ void readTempAuthConfigurationWithRegion() throws Exception {
PropertiesConfiguration configuration = new PropertiesConfiguration();
configuration.load(new StringReader(StringUtils.joinWith("\n",
CONFIG_ENDPOINT,
@@ -107,7 +107,7 @@ class SwiftTmpAuthConfigurationReaderTest {
}
@Test
- void readKeystone2ConfigurationWithCustomTempAuthHeaders() throws Exception {
+ void readTempAuthConfigurationWithCustomTempAuthHeaders() throws Exception {
PropertiesConfiguration configuration = new PropertiesConfiguration();
configuration.load(new StringReader(StringUtils.joinWith("\n",
CONFIG_ENDPOINT,
@@ -130,7 +130,7 @@ class SwiftTmpAuthConfigurationReaderTest {
}
@Test
- void failToReadSwiftKeyston2ConfigurationWhenMissingEndpoint() throws Exception {
+ void failToReadSwiftTempAuthConfigurationWhenMissingEndpoint() throws Exception {
PropertiesConfiguration configuration = new PropertiesConfiguration();
configuration.load(new StringReader(StringUtils.joinWith("\n",
CONFIG_CREDENTIALS,
@@ -143,7 +143,7 @@ class SwiftTmpAuthConfigurationReaderTest {
}
@Test
- void failToReadSwiftKeyston2ConfigurationWhenMissingCrendentials() throws Exception {
+ void failToReadSwiftTempAuthConfigurationWhenMissingCrendentials() throws Exception {
PropertiesConfiguration configuration = new PropertiesConfiguration();
configuration.load(new StringReader(StringUtils.joinWith("\n",
CONFIG_ENDPOINT,
@@ -156,7 +156,7 @@ class SwiftTmpAuthConfigurationReaderTest {
}
@Test
- void failToReadSwiftKeyston2ConfigurationWhenMissingUserName() throws Exception {
+ void failToReadSwiftTempAuthConfigurationWhenMissingUserName() throws Exception {
PropertiesConfiguration configuration = new PropertiesConfiguration();
configuration.load(new StringReader(StringUtils.joinWith("\n",
CONFIG_ENDPOINT,
@@ -169,7 +169,7 @@ class SwiftTmpAuthConfigurationReaderTest {
}
@Test
- void failToReadSwiftKeyston2ConfigurationWhenMissingTenantName() throws Exception {
+ void failToReadSwiftTempAuthConfigurationWhenMissingTenantName() throws Exception {
PropertiesConfiguration configuration = new PropertiesConfiguration();
configuration.load(new StringReader(StringUtils.joinWith("\n",
CONFIG_ENDPOINT,
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[04/17] james-project git commit: JAMES-2561 Update Tika to last
official image 1.19.1
Posted by bt...@apache.org.
JAMES-2561 Update Tika to last official image 1.19.1
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/769ddfdb
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/769ddfdb
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/769ddfdb
Branch: refs/heads/master
Commit: 769ddfdb1d417485f47b6f5670b71c94ee9b8a04
Parents: 2610d11
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Wed Oct 10 17:23:20 2018 +0200
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:16:30 2018 +0700
----------------------------------------------------------------------
README.adoc | 4 ++--
dockerfiles/run/docker-compose.yml | 2 +-
.../src/main/java/org/apache/james/util/docker/Images.java | 2 +-
src/site/xdoc/server/config-elasticsearch.xml | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/769ddfdb/README.adoc
----------------------------------------------------------------------
diff --git a/README.adoc b/README.adoc
index 6aa0540..79b8685 100644
--- a/README.adoc
+++ b/README.adoc
@@ -223,7 +223,7 @@ You need a running *ElasticSearch* in docker. To achieve this run:
If you want to use all the JMAP search capabilities, you may also need to start Tika:
- $ docker run -d --name=tika linagora/docker-tikaserver:1.18-SNAPSHOT-plus-TIKA-2520
+ $ docker run -d --name=tika logicalspark/docker-tikaserver:1.19.1
You can find more explanation on the need of Tika in this page http://james.apache.org/server/config-elasticsearch.html
@@ -255,7 +255,7 @@ You can handle attachment text extraction before indexing in ElasticSearch. This
Run tika:
- $ docker run --name tika linagora/docker-tikaserver:1.18-SNAPSHOT-plus-TIKA-2520
+ $ docker run --name tika logicalspark/docker-tikaserver:1.19.1
Add a link for the tika container in the above command line:
http://git-wip-us.apache.org/repos/asf/james-project/blob/769ddfdb/dockerfiles/run/docker-compose.yml
----------------------------------------------------------------------
diff --git a/dockerfiles/run/docker-compose.yml b/dockerfiles/run/docker-compose.yml
index a85003c..af935b9 100644
--- a/dockerfiles/run/docker-compose.yml
+++ b/dockerfiles/run/docker-compose.yml
@@ -29,4 +29,4 @@ services:
- "9042:9042"
tika:
- image: linagora/docker-tikaserver:1.18-SNAPSHOT-plus-TIKA-2520
+ image: logicalspark/docker-tikaserver:1.19.1
http://git-wip-us.apache.org/repos/asf/james-project/blob/769ddfdb/server/testing/src/main/java/org/apache/james/util/docker/Images.java
----------------------------------------------------------------------
diff --git a/server/testing/src/main/java/org/apache/james/util/docker/Images.java b/server/testing/src/main/java/org/apache/james/util/docker/Images.java
index 78d57ad..2327655 100644
--- a/server/testing/src/main/java/org/apache/james/util/docker/Images.java
+++ b/server/testing/src/main/java/org/apache/james/util/docker/Images.java
@@ -24,6 +24,6 @@ public interface Images {
String RABBITMQ = "rabbitmq:3.7.7-management";
String ELASTICSEARCH = "elasticsearch:2.4.6";
String NGINX = "nginx:1.15.1";
- String TIKA = "linagora/docker-tikaserver:1.18-SNAPSHOT-plus-TIKA-2520";
+ String TIKA = "logicalspark/docker-tikaserver:1.19.1";
String SPAMASSASSIN = "dinkel/spamassassin:3.4.0";
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/769ddfdb/src/site/xdoc/server/config-elasticsearch.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/server/config-elasticsearch.xml b/src/site/xdoc/server/config-elasticsearch.xml
index 33600f1..f6d9ead 100644
--- a/src/site/xdoc/server/config-elasticsearch.xml
+++ b/src/site/xdoc/server/config-elasticsearch.xml
@@ -157,7 +157,7 @@
Note: You can launch a tika server using this command line:
- <code><pre>docker run --name tika logicalspark/docker-tikaserver:1.15rc2</pre></code>
+ <code><pre>docker run --name tika logicalspark/docker-tikaserver:1.19.1</pre></code>
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[05/17] james-project git commit: Fix Checkstyle errors and Eclipse
warnings
Posted by bt...@apache.org.
Fix Checkstyle errors and Eclipse warnings
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/cb4adef1
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/cb4adef1
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/cb4adef1
Branch: refs/heads/master
Commit: cb4adef1431b202c4490f484a26cd865aa996bf9
Parents: 769ddfd
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Thu Oct 11 11:40:04 2018 +0200
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Mon Oct 15 13:17:03 2018 +0700
----------------------------------------------------------------------
.../org/apache/james/blob/objectstorage/DockerSwiftContainer.java | 3 ++-
.../james/blob/objectstorage/ObjectStorageBlobsDAOTest.java | 1 -
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/cb4adef1/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftContainer.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftContainer.java b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftContainer.java
index b073eed..6822fee 100644
--- a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftContainer.java
+++ b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftContainer.java
@@ -43,7 +43,8 @@ public class DockerSwiftContainer {
private DockerSwift dockerSwift;
public DockerSwiftContainer() {
- this.swiftContainer = new GenericContainer<>(SWIFT_DOCKER_IMAGE)
+ this.swiftContainer = new GenericContainer<>(SWIFT_DOCKER_IMAGE);
+ this.swiftContainer
.withExposedPorts(KEYSTONE_ADMIN_PORT)
.withExposedPorts(SWIFT_PORT)
.withLogConsumer(DockerSwiftContainer::displayDockerLog)
http://git-wip-us.apache.org/repos/asf/james-project/blob/cb4adef1/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java
index 5dd3cbc..4c04014 100644
--- a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java
+++ b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/ObjectStorageBlobsDAOTest.java
@@ -21,7 +21,6 @@ package org.apache.james.blob.objectstorage;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.jupiter.api.Assertions.fail;
import java.util.UUID;
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org