-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
267 changed files
with
67,784 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,8 @@ node_modules/ | |
|
||
**/dist-theme/ | ||
**/*.zip | ||
*.zip | ||
jar/ | ||
|
||
**/target/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
.idea | ||
target/ | ||
Test.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# 邮件拉取器 | ||
邮件拉取器,适配IMAP, POP3协议邮箱。支持将附件保存到OSS中。 | ||
|
||
## 逻辑详情 | ||
|
||
### getInboxEmails | ||
|
||
获取邮箱收件箱邮件列表 | ||
|
||
* 入参:int page 默认1, int pageSize 默认10 | ||
* 出参:`List<Email>` | ||
|
||
### getInboxEmailsWithConfig | ||
|
||
获取邮箱收件箱邮件列表,支持运行时配置参数 | ||
|
||
* 入参:int page 默认1, int pageSize 默认10, EmailConfig config | ||
* 出参:`List<Email>` | ||
|
||
### extractEmails | ||
|
||
提取邮件内容 | ||
* 入参:无 | ||
* 出参:`List<Email>` | ||
|
||
### extractEmailsWithConfig | ||
|
||
提取邮件内容,支持运行时配置参数 | ||
* 入参:EmailConfig config | ||
* 出参:`List<Email>` | ||
|
||
## 使用步骤说明 | ||
|
||
1. 应用引用依赖库 | ||
2. 配置应用配置参数 | ||
3. 逻辑调用示例截图 | ||
|
||
 | ||
|
||
|
||
## 应用演示链接 | ||
|
||
[使用了本依赖库的制品应用链接] | ||
https://dev-test430-qa.app.codewave.163.com/email |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
1 change: 1 addition & 0 deletions
1
EmailFetcher_fdddf/jar/nasl-metadata-maven-plugin-1.3.0/install.bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mvn install:install-file -Dfile="nasl-metadata-maven-plugin-1.3.0.jar" -DpomFile="pom.xml" |
1 change: 1 addition & 0 deletions
1
EmailFetcher_fdddf/jar/nasl-metadata-maven-plugin-1.3.0/install.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mvn install:install-file -Dfile="nasl-metadata-maven-plugin-1.3.0.jar" -DpomFile="pom.xml" |
Binary file added
BIN
+24.1 KB
EmailFetcher_fdddf/jar/nasl-metadata-maven-plugin-1.3.0/nasl-metadata-maven-plugin-1.3.0.jar
Binary file not shown.
74 changes: 74 additions & 0 deletions
74
EmailFetcher_fdddf/jar/nasl-metadata-maven-plugin-1.3.0/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.netease.lowcode</groupId> | ||
<artifactId>nasl-metadata-maven-plugin</artifactId> | ||
<version>1.3.0</version> | ||
<packaging>maven-plugin</packaging> | ||
|
||
<name>Nasl Metadata Maven Plugin</name> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-plugin-api</artifactId> | ||
<version>2.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-project</artifactId> | ||
<version>2.0.10</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven.plugin-tools</groupId> | ||
<artifactId>maven-plugin-annotations</artifactId> | ||
<version>3.2</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.codehaus.plexus</groupId> | ||
<artifactId>plexus-compiler-manager</artifactId> | ||
<version>2.8.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.codehaus.plexus</groupId> | ||
<artifactId>plexus-utils</artifactId> | ||
<version>3.0.8</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven.shared</groupId> | ||
<artifactId>maven-common-artifact-filters</artifactId> | ||
<version>3.0.1</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-aether-provider</artifactId> | ||
<version>3.3.9</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.eclipse.aether</groupId> | ||
<artifactId>aether-api</artifactId> | ||
<version>1.1.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-plugin-plugin</artifactId> | ||
<version>3.2</version> | ||
<configuration> | ||
<goalPrefix>nasl-metadata-maven-plugin</goalPrefix> | ||
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.2.9.RELEASE</version><!--与当前制品应用默认版本统一--> | ||
</parent> | ||
|
||
<groupId>fdddf</groupId> | ||
<artifactId>EmailFetcher</artifactId> | ||
<name>EmailFetcher</name> | ||
<description>邮件拉取工具,支持IMAP/POP3协议;支持邮件附件保存到OSS</description> | ||
<version>1.2.2</version> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<nasl.ide.version>3.3</nasl.ide.version> | ||
</properties> | ||
<dependencies> | ||
<!--本案例是本地系统引入nasl-metadata-collector-0.8.0.jar的方式。 | ||
若把nasl-metadata-collector-0.8.0.jar安装到自己的maven仓库, | ||
注意修改artifactId和groupId的情况下,不要使用<scope>system</scope>,会在发布时造成依赖中断。 | ||
不修改artifactId和groupId的情况下,nasl-metadata-maven-plugin会做特殊处理--> | ||
<dependency> | ||
<artifactId>nasl-metadata-collector</artifactId> | ||
<groupId>com.netease.lowcode</groupId> | ||
<version>0.8.0</version> | ||
<optional>true</optional> | ||
<scope>system</scope> | ||
<systemPath>${project.basedir}/jar/nasl-metadata-collector-0.8.0.jar</systemPath> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>fastjson</artifactId> | ||
<version>1.2.83</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<!-- https://mvnrepository.com/artifact/com.sun.mail/javax.mail --> | ||
<dependency> | ||
<groupId>com.sun.mail</groupId> | ||
<artifactId>javax.mail</artifactId> | ||
<version>1.6.2</version> | ||
</dependency> | ||
<!-- https://mvnrepository.com/artifact/commons-io/commons-io --> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.16.1</version> | ||
</dependency> | ||
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-s3 --> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-java-sdk-s3</artifactId> | ||
<version>1.12.440</version> | ||
</dependency> | ||
<!-- https://mvnrepository.com/artifact/com.aliyun.oss/aliyun-sdk-oss --> | ||
<dependency> | ||
<groupId>com.aliyun.oss</groupId> | ||
<artifactId>aliyun-sdk-oss</artifactId> | ||
<version>3.17.4</version> | ||
</dependency> | ||
<!--制品应用使用Springboot框架,父应用引用了的包,为了防止版本冲突,scope可设置为provided--> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.netease.lowcode</groupId> | ||
<artifactId>nasl-metadata-maven-plugin</artifactId> | ||
<version>1.3.0</version> | ||
<configuration> | ||
<jarWithDependencies>false</jarWithDependencies> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>archive</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>8</source><target>8</target></configuration></plugin> | ||
</plugins> | ||
</build> | ||
</project> |
80 changes: 80 additions & 0 deletions
80
EmailFetcher_fdddf/src/main/java/com/fdddf/emailfetcher/AmazonOSS.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.fdddf.emailfetcher; | ||
|
||
import com.amazonaws.AmazonServiceException; | ||
import com.amazonaws.auth.AWSStaticCredentialsProvider; | ||
import com.amazonaws.auth.BasicAWSCredentials; | ||
import com.amazonaws.client.builder.AwsClientBuilder; | ||
import com.amazonaws.services.s3.AmazonS3; | ||
import com.amazonaws.services.s3.AmazonS3ClientBuilder; | ||
import com.fdddf.emailfetcher.api.EmailExtractor; | ||
import org.apache.commons.io.FilenameUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.InputStream; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class AmazonOSS { | ||
protected final EmailConfig cfg; | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(EmailExtractor.class); | ||
|
||
public AmazonOSS(EmailConfig cfg) { | ||
this.cfg = cfg; | ||
} | ||
|
||
public List<String> saveAttachmentToOSS(Map<String, InputStream> attachments) { | ||
BasicAWSCredentials credentials = new BasicAWSCredentials(cfg.ossAccessKeyId, cfg.ossAccessKeySecret); | ||
AWSStaticCredentialsProvider provider = new AWSStaticCredentialsProvider(credentials); | ||
|
||
String endpoint = cfg.ossEndpoint; | ||
if (!endpoint.startsWith("http")) { | ||
endpoint = "https://" + endpoint; | ||
} | ||
String bucketDomain = cfg.ossBucketDomain; | ||
if (!bucketDomain.startsWith("http")) { | ||
bucketDomain = "https://" + bucketDomain; | ||
} | ||
|
||
AmazonS3 s3Client = AmazonS3ClientBuilder.standard() | ||
.withCredentials(provider) | ||
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration( | ||
endpoint, | ||
"")) | ||
.withPathStyleAccessEnabled(false) | ||
.withChunkedEncodingDisabled(true) | ||
.build(); | ||
|
||
List<String> savedAttachments = new ArrayList<>(); | ||
|
||
for (String filename : attachments.keySet()) { | ||
logger.info("will put attachment to oss: {}", filename); | ||
String objectName = FilenameUtils.getName(filename); | ||
if (cfg.ossFolder != null && !cfg.ossFolder.isEmpty()) { | ||
objectName = cfg.ossFolder + "/" + objectName; | ||
} | ||
|
||
try { | ||
if (s3Client.doesObjectExist(cfg.ossBucketName, objectName)) { | ||
savedAttachments.add(bucketDomain + "/" + objectName); | ||
continue; | ||
} | ||
s3Client.putObject(cfg.ossBucketName, objectName, attachments.get(filename), null); | ||
} catch (AmazonServiceException e) { | ||
logger.error("Caught an OSSException, which means your request made it to OSS, " | ||
+ "but was rejected with an error response for some reason.", e); | ||
e.printStackTrace(); | ||
continue; | ||
} | ||
|
||
savedAttachments.add(bucketDomain + "/" + objectName); | ||
} | ||
s3Client.shutdown(); | ||
|
||
return savedAttachments; | ||
} | ||
|
||
} | ||
|
8 changes: 8 additions & 0 deletions
8
EmailFetcher_fdddf/src/main/java/com/fdddf/emailfetcher/CustomFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.fdddf.emailfetcher; | ||
|
||
import javax.mail.Folder; | ||
import javax.mail.search.SearchTerm; | ||
|
||
public interface CustomFilter { | ||
public SearchTerm getCustomSearch(Folder folder); | ||
} |
Oops, something went wrong.