vttranlina commented on a change in pull request #551:
URL: https://github.com/apache/james-project/pull/551#discussion_r676395809



##########
File path: 
server/data/data-jmap/src/main/java/org/apache/james/jmap/api/model/Upload.scala
##########
@@ -19,49 +19,38 @@
 
 package org.apache.james.jmap.api.model
 
-import com.google.common.hash.Hashing
-import eu.timepit.refined.api.Refined
-import eu.timepit.refined.auto._
-import eu.timepit.refined.numeric.NonNegative
-import eu.timepit.refined.refineV
-import org.apache.james.jmap.api.model.Upload.Size
+import org.apache.james.blob.api.BlobId
+import org.apache.james.jmap.api.model.Size.Size
 import org.apache.james.mailbox.model.ContentType
-import org.slf4j.{Logger, LoggerFactory}
 
-import java.io.{ByteArrayInputStream, InputStream}
+import java.io.InputStream
 
 object Upload {
-  private val logger: Logger = LoggerFactory.getLogger(classOf[Upload])
-  type Size = Long Refined NonNegative
-  val Zero: Size = 0L
 
-  def sanitizeSize(value: Long): Size = {
-    val size: Either[String, Size] = refineV[NonNegative](value)
-    size.fold(e => {
-      logger.error(s"Encountered an invalid Upload size: $e")
-      Zero
-    },
-      refinedValue => refinedValue)
-  }
-
-  def from(metaData: UploadMetaData, content: Array[Byte]): Upload =
-    Upload(uploadId = metaData.getUploadId,
-      size = Upload.sanitizeSize(metaData.getSize),
-      contentType = metaData.getContentType,
-      content = new ByteArrayInputStream(content))
+  def from(metaData: UploadMetaData, content: InputStream): Upload =
+    Upload(uploadId = metaData.uploadId,
+      size = metaData.size,
+      contentType = metaData.contentType,
+      content = content)
 }
 
 case class Upload(uploadId: UploadId,
                   size: Size,
                   contentType: ContentType,
                   content: InputStream)
 
-object UploadHashContent {
-  def from(content: Array[Byte]): UploadHashContent =
-    UploadHashContent(Hashing.sha256.hashBytes(content).toString)
+case class UploadNotFoundException(uploadId: UploadId) extends 
RuntimeException(s"Upload not found $uploadId")
 
+object UploadMetaData {
+  def from(uploadId: UploadId, contentType: ContentType, size: Long, blobId: 
BlobId): UploadMetaData =
+    UploadMetaData(uploadId = uploadId,
+      contentType = contentType,
+      size = Size.sanitizeSize(size),

Review comment:
       I got the error `No such instance method`, when I use 
`Size.sanitizeSize(size)` in Java class. 
   weird




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to