You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2021/04/27 02:53:46 UTC
[james-project] 05/06: JAMES-3434 Refactoring:
EmailSubmissionSetMethod should not rely on nested clases
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch 3.6.x
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 0ae5c195e46ca6d89cd491f1229f457e5b97b4e0
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Apr 16 22:51:41 2021 +0700
JAMES-3434 Refactoring: EmailSubmissionSetMethod should not rely on nested clases
---
.../jmap/method/EmailSubmissionSetMethod.scala | 55 +++++++++++-----------
1 file changed, 27 insertions(+), 28 deletions(-)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala
index 544f13b..14904b3 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/EmailSubmissionSetMethod.scala
@@ -36,7 +36,7 @@ import org.apache.james.jmap.core.{ClientId, Id, Invocation, Properties, ServerI
import org.apache.james.jmap.json.{EmailSubmissionSetSerializer, ResponseSerializer}
import org.apache.james.jmap.mail.EmailSubmissionSet.EmailSubmissionCreationId
import org.apache.james.jmap.mail.{EmailSubmissionAddress, EmailSubmissionCreationRequest, EmailSubmissionCreationResponse, EmailSubmissionId, EmailSubmissionSetRequest, EmailSubmissionSetResponse, Envelope}
-import org.apache.james.jmap.method.EmailSubmissionSetMethod.{LOGGER, MAIL_METADATA_USERNAME_ATTRIBUTE}
+import org.apache.james.jmap.method.EmailSubmissionSetMethod.{CreationFailure, CreationResult, CreationResults, CreationSuccess, LOGGER, MAIL_METADATA_USERNAME_ATTRIBUTE}
import org.apache.james.jmap.routes.{ProcessingContext, SessionSupplier}
import org.apache.james.lifecycle.api.{LifecycleUtil, Startable}
import org.apache.james.mailbox.model.{FetchGroup, MessageResult}
@@ -62,31 +62,6 @@ object EmailSubmissionSetMethod {
val noRecipients: SetErrorType = "noRecipients"
val forbiddenFrom: SetErrorType = "forbiddenFrom"
val forbiddenMailFrom: SetErrorType = "forbiddenMailFrom"
-}
-
-case class EmailSubmissionCreationParseException(setError: SetError) extends Exception
-case class NoRecipientException() extends Exception
-case class ForbiddenFromException(from: String) extends Exception
-case class ForbiddenMailFromException(from: List[String]) extends Exception
-
-case class MessageMimeMessageSource(id: String, message: MessageResult) extends MimeMessageSource {
- override def getSourceId: String = id
-
- override def getInputStream: InputStream = message.getFullContent.getInputStream
-
- override def getMessageSize: Long = message.getFullContent.size()
-}
-
-class EmailSubmissionSetMethod @Inject()(serializer: EmailSubmissionSetSerializer,
- messageIdManager: MessageIdManager,
- mailQueueFactory: MailQueueFactory[_ <: MailQueue],
- canSendFrom: CanSendFrom,
- emailSetMethod: EmailSetMethod,
- val metricFactory: MetricFactory,
- val sessionSupplier: SessionSupplier) extends MethodRequiringAccountId[EmailSubmissionSetRequest] with Startable {
- override val methodName: MethodName = MethodName("EmailSubmission/set")
- override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE, EMAIL_SUBMISSION)
- var queue: MailQueue = _
sealed trait CreationResult {
def emailSubmissionCreationId: EmailSubmissionCreationId
@@ -127,9 +102,33 @@ class EmailSubmissionSetMethod @Inject()(serializer: EmailSubmissionSetSerialize
}
.toMap
}
+}
+
+case class EmailSubmissionCreationParseException(setError: SetError) extends Exception
+case class NoRecipientException() extends Exception
+case class ForbiddenFromException(from: String) extends Exception
+case class ForbiddenMailFromException(from: List[String]) extends Exception
+
+case class MessageMimeMessageSource(id: String, message: MessageResult) extends MimeMessageSource {
+ override def getSourceId: String = id
+
+ override def getInputStream: InputStream = message.getFullContent.getInputStream
+
+ override def getMessageSize: Long = message.getFullContent.size()
+}
+
+class EmailSubmissionSetMethod @Inject()(serializer: EmailSubmissionSetSerializer,
+ messageIdManager: MessageIdManager,
+ mailQueueFactory: MailQueueFactory[_ <: MailQueue],
+ canSendFrom: CanSendFrom,
+ emailSetMethod: EmailSetMethod,
+ val metricFactory: MetricFactory,
+ val sessionSupplier: SessionSupplier) extends MethodRequiringAccountId[EmailSubmissionSetRequest] with Startable {
+ override val methodName: MethodName = MethodName("EmailSubmission/set")
+ override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE, EMAIL_SUBMISSION)
+ var queue: MailQueue = _
- def init: Unit =
- queue = mailQueueFactory.createQueue(SPOOL)
+ def init: Unit = queue = mailQueueFactory.createQueue(SPOOL)
@PreDestroy def dispose: Unit =
Try(queue.close())
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org