This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 53ca907a6f52a62af1227796337b8beb57217cb7 Author: RĂ©mi Kowalski <rkowal...@linagora.com> AuthorDate: Mon Sep 2 11:25:14 2019 +0200 JAMES-2813 extract SimpleMessageReindexingTaskDTO --- .../tools/indexer/SingleMessageReindexingTask.java | 54 +++-------------- .../indexer/SingleMessageReindexingTaskDTO.java | 67 ++++++++++++++++++++++ 2 files changed, 75 insertions(+), 46 deletions(-) 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 index 19b6ff0..57d45ec 100644 --- 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 @@ -20,69 +20,23 @@ package org.apache.mailbox.tools.indexer; import java.util.Optional; -import java.util.function.Function; import javax.inject.Inject; -import org.apache.james.json.DTOModule; import org.apache.james.mailbox.MessageUid; import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.model.MailboxId; -import org.apache.james.server.task.json.dto.TaskDTO; -import org.apache.james.server.task.json.dto.TaskDTOModule; import org.apache.james.task.Task; import org.apache.james.task.TaskExecutionDetails; import org.apache.james.task.TaskType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.annotation.JsonProperty; - public class SingleMessageReindexingTask implements Task { private static final Logger LOGGER = LoggerFactory.getLogger(SingleMessageReindexingTask.class); public static final TaskType MESSAGE_RE_INDEXING = TaskType.of("messageReIndexing"); - public static final Function<SingleMessageReindexingTask.Factory, TaskDTOModule<SingleMessageReindexingTask, SingleMessageReindexingTask.SingleMessageReindexingTaskDTO>> MODULE = (factory) -> - DTOModule - .forDomainObject(SingleMessageReindexingTask.class) - .convertToDTO(SingleMessageReindexingTask.SingleMessageReindexingTaskDTO.class) - .toDomainObjectConverter(factory::create) - .toDTOConverter(SingleMessageReindexingTask.SingleMessageReindexingTaskDTO::of) - .typeName(MESSAGE_RE_INDEXING.asString()) - .withFactory(TaskDTOModule::new); - - - public static class SingleMessageReindexingTaskDTO implements TaskDTO { - - private final String type; - private final String mailboxId; - private final long uid; - - private SingleMessageReindexingTaskDTO(@JsonProperty("type") String type, @JsonProperty("mailboxId") String mailboxId, @JsonProperty("uid") long uid) { - this.type = type; - this.mailboxId = mailboxId; - this.uid = uid; - } - - @Override - public String getType() { - return type; - } - - public String getMailboxId() { - return mailboxId; - } - - public long getUid() { - return uid; - } - - public static SingleMessageReindexingTaskDTO of(SingleMessageReindexingTask task, String type) { - return new SingleMessageReindexingTaskDTO(type, task.mailboxId.serialize(), task.uid.asLong()); - } - } - public static class AdditionalInformation implements TaskExecutionDetails.AdditionalInformation { private final MailboxId mailboxId; private final MessageUid uid; @@ -142,6 +96,14 @@ public class SingleMessageReindexingTask implements Task { } } + MailboxId getMailboxId() { + return mailboxId; + } + + MessageUid getUid() { + return uid; + } + @Override public TaskType type() { return MESSAGE_RE_INDEXING; diff --git a/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/SingleMessageReindexingTaskDTO.java b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/SingleMessageReindexingTaskDTO.java new file mode 100644 index 0000000..aee8514 --- /dev/null +++ b/mailbox/tools/indexer/src/main/java/org/apache/mailbox/tools/indexer/SingleMessageReindexingTaskDTO.java @@ -0,0 +1,67 @@ +/**************************************************************** + * 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.function.Function; + +import org.apache.james.json.DTOModule; +import org.apache.james.server.task.json.dto.TaskDTO; +import org.apache.james.server.task.json.dto.TaskDTOModule; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class SingleMessageReindexingTaskDTO implements TaskDTO { + + public static final Function<SingleMessageReindexingTask.Factory, TaskDTOModule<SingleMessageReindexingTask, SingleMessageReindexingTaskDTO>> MODULE = (factory) -> + DTOModule + .forDomainObject(SingleMessageReindexingTask.class) + .convertToDTO(SingleMessageReindexingTaskDTO.class) + .toDomainObjectConverter(factory::create) + .toDTOConverter(SingleMessageReindexingTaskDTO::of) + .typeName(SingleMessageReindexingTask.MESSAGE_RE_INDEXING.asString()) + .withFactory(TaskDTOModule::new); + + public static SingleMessageReindexingTaskDTO of(SingleMessageReindexingTask task, String type) { + return new SingleMessageReindexingTaskDTO(type, task.getMailboxId().serialize(), task.getUid().asLong()); + } + + private final String type; + private final String mailboxId; + private final long uid; + + private SingleMessageReindexingTaskDTO(@JsonProperty("type") String type, @JsonProperty("mailboxId") String mailboxId, @JsonProperty("uid") long uid) { + this.type = type; + this.mailboxId = mailboxId; + this.uid = uid; + } + + @Override + public String getType() { + return type; + } + + public String getMailboxId() { + return mailboxId; + } + + public long getUid() { + return uid; + } + +} --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org