")
email.getEmailContents.foreach {
case emailContent: ArrayEmailContent =>
- emailContent.getContent.foreach(content => sb.append("").append(content).append(" |
"))
+ if (emailContent.getContent != null) {
+ emailContent.getContent.foreach(content => sb.append("").append(content).append(" |
"))
+ }
case emailContent: StringEmailContent =>
sb.append("").append(emailContent.getContent).append(" |
")
}
@@ -45,4 +51,13 @@ class MultiEmailContentGenerator extends AbstractEmailContentGenerator with Logg
email.setContent(sb.toString)
}
+ protected def setHtmlContent(email: MultiContentEmail): Unit = {
+ email.getEmailContents.foreach {
+ case emailContent: StringEmailContent =>
+ if (emailContent.getContent != null) {
+ email.setContent(emailContent.getContent)
+ }
+ }
+ }
+
}
\ No newline at end of file
diff --git a/dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/emailcontent/parser/AbstractEmailContentParser.scala b/dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/emailcontent/parser/AbstractEmailContentParser.scala
index 2bbcb6c217..92bfaec8f6 100644
--- a/dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/emailcontent/parser/AbstractEmailContentParser.scala
+++ b/dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/emailcontent/parser/AbstractEmailContentParser.scala
@@ -26,7 +26,7 @@ import org.apache.linkis.common.io.resultset.ResultSetReader
import org.apache.linkis.common.io.{MetaData, Record}
import org.apache.linkis.common.utils.Utils
import org.apache.linkis.storage.LineRecord
-import org.apache.linkis.storage.resultset.ResultSetReader
+import org.apache.linkis.storage.resultset.ResultSetReaderFactory
import org.apache.commons.io.IOUtils
abstract class AbstractEmailContentParser[T] extends EmailContentParser {
@@ -41,8 +41,8 @@ abstract class AbstractEmailContentParser[T] extends EmailContentParser {
case _ =>
}
- protected def getResultSetReader(fsPathStore: FsPathStoreEmailContent): ResultSetReader[_ <: MetaData, _ <: Record] = {
- val reader = ResultSetReader.getResultSetReader(fsPathStore.getFsPath.getSchemaPath)
+ protected def getResultSetReader(fsPathStore: FsPathStoreEmailContent): ResultSetReader[_, _ ] = {
+ val reader = ResultSetReaderFactory.getResultSetReader(fsPathStore.getFsPath.getSchemaPath)
reader.getMetaData
reader
}
diff --git a/dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/emailcontent/parser/HtmlEmailContentParser.scala b/dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/emailcontent/parser/HtmlEmailContentParser.scala
index cab083f70c..d2b5520d88 100644
--- a/dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/emailcontent/parser/HtmlEmailContentParser.scala
+++ b/dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/emailcontent/parser/HtmlEmailContentParser.scala
@@ -16,12 +16,40 @@
package com.webank.wedatasphere.dss.appconn.sendemail.emailcontent.parser
-import com.webank.wedatasphere.dss.appconn.sendemail.email.domain.MultiContentEmail
+import com.webank.wedatasphere.dss.appconn.sendemail.email.domain.{CsvAttachment, MultiContentEmail, PngAttachment}
+import com.webank.wedatasphere.dss.appconn.sendemail.emailcontent.HtmlItem
import com.webank.wedatasphere.dss.appconn.sendemail.emailcontent.domain.HtmlEmailContent
+import org.apache.linkis.server.JSONUtils
+
+import java.nio.charset.StandardCharsets
+import java.util.Base64
+import scala.sys.error
object HtmlEmailContentParser extends AbstractEmailContentParser[HtmlEmailContent] {
override protected def parseEmailContent(emailContent: HtmlEmailContent,
multiContentEmail: MultiContentEmail): Unit = {
- getFirstLineRecord(emailContent).foreach(emailContent.setContent)
+ getFirstLineRecord(emailContent).foreach(htmlStr =>
+ emailContent.getFileType match {
+ case "html" =>
+ val htmlItems: Array[HtmlItem] = JSONUtils.gson.fromJson(htmlStr, classOf[Array[HtmlItem]])
+ htmlItems.foreach {
+ case htmlItem: HtmlItem =>
+ if (htmlItem.getFileType.equals("attachment") && htmlItem.getContentType.equals("csv")) {
+ val csvName = htmlItem.getFileName
+ val csvContent = htmlItem.getContent
+ val csvContentBytes = csvContent.getBytes
+ val csvBase64BaseContent = new String(Base64.getEncoder.encode(csvContentBytes), StandardCharsets.UTF_8)
+ multiContentEmail.addAttachment(new CsvAttachment(csvName, csvBase64BaseContent))
+ } else if (htmlItem.getContentType.equals("image") && htmlItem.getFileType.equals("inline")) {
+ multiContentEmail.addAttachment(new PngAttachment(htmlItem.getContentId, htmlItem.getContent))
+ } else if (htmlItem.getContentType.equals("html")) {
+ emailContent.setContent(htmlItem.getContent)
+ } else {
+ error("unknow content type: " + emailContent.getFileType)
+ }
+ }
+ case _ =>
+ }
+ )
}
}
diff --git a/dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/emailcontent/parser/PictureEmailContentParser.scala b/dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/emailcontent/parser/PictureEmailContentParser.scala
index 5162486081..6a39b16a14 100644
--- a/dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/emailcontent/parser/PictureEmailContentParser.scala
+++ b/dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/emailcontent/parser/PictureEmailContentParser.scala
@@ -17,36 +17,82 @@
package com.webank.wedatasphere.dss.appconn.sendemail.emailcontent.parser
import java.awt.image.BufferedImage
-import java.io.{ByteArrayInputStream, ByteArrayOutputStream}
-import java.util.{Base64, UUID}
+import java.io.{ByteArrayInputStream, ByteArrayOutputStream, InputStream}
+import java.util
+import java.util.{Base64, Iterator, UUID}
-import com.webank.wedatasphere.dss.appconn.sendemail.email.domain.{AbstractEmail, MultiContentEmail, PngAttachment}
+import com.webank.wedatasphere.dss.appconn.sendemail.email.domain.{AbstractEmail, MultiContentEmail, PdfAttachment, PngAttachment}
import com.webank.wedatasphere.dss.appconn.sendemail.emailcontent.domain.PictureEmailContent
import org.apache.linkis.common.conf.Configuration
-import javax.imageio.ImageIO
+import javax.imageio.{ImageIO, ImageReader}
import org.apache.commons.codec.binary.Base64OutputStream
import com.webank.wedatasphere.dss.appconn.sendemail.conf.SendEmailAppConnConfiguration._
+import com.webank.wedatasphere.dss.appconn.sendemail.exception.EmailSendFailedException
+import javax.imageio.stream.ImageInputStream
+import org.apache.commons.io.IOUtils
+import org.apache.linkis.common.utils.Utils
object PictureEmailContentParser extends AbstractEmailContentParser[PictureEmailContent] {
override protected def parseEmailContent(emailContent: PictureEmailContent,
multiContentEmail: MultiContentEmail): Unit = {
getFirstLineRecord(emailContent).foreach { imageStr =>
- val decoder = Base64.getDecoder
- val byteArr = decoder.decode(imageStr)
- val inputStream = new ByteArrayInputStream(byteArr)
- val image = ImageIO.read(inputStream)
- val contents = generateImage(image, multiContentEmail)
- emailContent.setContent(contents)
+ emailContent.getFileType match {
+ case "checkData" =>
+ //对于邮件校验数据不进行处理
+ case "pdf" =>
+ val pdfUUID: String = UUID.randomUUID.toString
+ val pdfName = pdfUUID + ".pdf"
+ val decoder = Base64.getDecoder
+ val byteArr = decoder.decode(imageStr)
+ multiContentEmail.addAttachment(new PdfAttachment(pdfName, Base64.getEncoder.encodeToString(byteArr)))
+ case _ =>
+ var inputStream: ByteArrayInputStream = null
+ Utils.tryFinally({
+ val decoder = Base64.getDecoder
+ val byteArr = decoder.decode(imageStr)
+ if (CHECK_EMAIL_IMAGE_SWITCH.getValue) {
+ checkImageSize(byteArr)
+ }
+ inputStream = new ByteArrayInputStream(byteArr)
+ val image = ImageIO.read(inputStream)
+ val contents = generateImage(image, multiContentEmail)
+ emailContent.setContent(contents)
+ })(IOUtils.closeQuietly(inputStream))
+
+ }
}
}
+ protected def checkImageSize(byteArr: Array[Byte]): Unit = {
+ var reader: ImageReader = null
+ val inputStream: InputStream = new ByteArrayInputStream(byteArr)
+ var imageInputStream: ImageInputStream = null
+ Utils.tryFinally({
+ imageInputStream = ImageIO.createImageInputStream(inputStream)
+ val imageReaders: util.Iterator[ImageReader] = ImageIO.getImageReaders(imageInputStream)
+ if (!imageReaders.hasNext) throw new EmailSendFailedException(80002,"Unsupported image format!")
+ reader = imageReaders.next
+ reader.setInput(imageInputStream)
+ val height = reader.getHeight(0)
+ val width = reader.getWidth(0)
+ if ((height * width) > EMAIL_IMAGE_MAXSIZE.getValue) {
+ throw new EmailSendFailedException(80002, "too large picture size :" + (height * width) + ", expect max picture size is :" + EMAIL_IMAGE_MAXSIZE.getValue)
+ }
+ })({
+ if (reader != null) reader.dispose()
+ IOUtils.closeQuietly(imageInputStream)
+ IOUtils.closeQuietly(inputStream)
+ })
+
+ }
+
protected def generateImage(bufferedImage: BufferedImage, email: AbstractEmail): Array[String] = {
val imageUUID: String = UUID.randomUUID.toString
val width: Int = bufferedImage.getWidth
val height: Int = bufferedImage.getHeight
// 只支持修改visualis图片大小,后续如果有新增其他类型的邮件需要修改图片大小,需要在if中加上该邮件类型
- val imagesCuts = if (email.getEmailType.contains("visualis") && height > EMAIL_IMAGE_HEIGHT.getValue) {
+ val imagesCuts = if (height > EMAIL_IMAGE_HEIGHT.getValue) {
val numOfCut = Math.ceil(height.toDouble / EMAIL_IMAGE_HEIGHT.getValue).toInt
val realHeight = height / numOfCut
(0 until numOfCut).map(i => bufferedImage.getSubimage(0, i * realHeight, width, realHeight)).toArray
@@ -62,8 +108,7 @@ object PictureEmailContentParser extends AbstractEmailContentParser[PictureEmail
var iHeight = image.getHeight
var iWidth = image.getWidth
-
- if (email.getEmailType.contains("visualis") && iWidth > EMAIL_IMAGE_WIDTH.getValue) {
+ if (iWidth > EMAIL_IMAGE_WIDTH.getValue) {
iHeight = ((EMAIL_IMAGE_WIDTH.getValue.toDouble / iWidth.toDouble) * iHeight.toDouble).toInt
iWidth = EMAIL_IMAGE_WIDTH.getValue
}
diff --git a/dss-appconn/appconns/dss-sso-appconn/pom.xml b/dss-appconn/appconns/dss-sso-appconn/pom.xml
index e17d4ae5f4..492f72f572 100644
--- a/dss-appconn/appconns/dss-sso-appconn/pom.xml
+++ b/dss-appconn/appconns/dss-sso-appconn/pom.xml
@@ -21,7 +21,7 @@
dss
com.webank.wedatasphere.dss
- 1.1.1
+ 1.1.2
../../../pom.xml
4.0.0
diff --git a/dss-appconn/appconns/dss-workflow-appconn/pom.xml b/dss-appconn/appconns/dss-workflow-appconn/pom.xml
index 937ba44ee8..58d501e912 100644
--- a/dss-appconn/appconns/dss-workflow-appconn/pom.xml
+++ b/dss-appconn/appconns/dss-workflow-appconn/pom.xml
@@ -21,7 +21,7 @@
dss
com.webank.wedatasphere.dss
- 1.1.1
+ 1.1.2
../../../pom.xml
4.0.0
diff --git a/dss-appconn/appconns/dss-workflow-appconn/src/main/java/com/webank/wedatasphere/dss/appconn/workflow/opertion/WorkflowRefCopyOperation.java b/dss-appconn/appconns/dss-workflow-appconn/src/main/java/com/webank/wedatasphere/dss/appconn/workflow/opertion/WorkflowRefCopyOperation.java
index 28d8a97812..2a6740f373 100644
--- a/dss-appconn/appconns/dss-workflow-appconn/src/main/java/com/webank/wedatasphere/dss/appconn/workflow/opertion/WorkflowRefCopyOperation.java
+++ b/dss-appconn/appconns/dss-workflow-appconn/src/main/java/com/webank/wedatasphere/dss/appconn/workflow/opertion/WorkflowRefCopyOperation.java
@@ -16,6 +16,7 @@
package com.webank.wedatasphere.dss.appconn.workflow.opertion;
+import com.webank.wedatasphere.dss.common.utils.RpcAskUtils;
import com.webank.wedatasphere.dss.orchestrator.common.ref.OrchestratorRefConstant;
import com.webank.wedatasphere.dss.sender.service.DSSSenderServiceFactory;
import com.webank.wedatasphere.dss.standard.app.development.operation.AbstractDevelopmentOperation;
@@ -28,6 +29,7 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.Optional;
public class WorkflowRefCopyOperation
@@ -45,10 +47,15 @@ public RefJobContentResponseRef copyRef(ThirdlyRequestRef.CopyWitContextRequestR
//插入version
String version = workflowCopyRequestRef.getNewVersion();
String description = (String) workflowCopyRequestRef.getRefJobContent().get(OrchestratorRefConstant.ORCHESTRATION_DESCRIPTION);
+ Long targetProjectId = workflowCopyRequestRef.getRefProjectId();
+ Optional