Skip to content
Snippets Groups Projects
Commit 8e133430 authored by Bunyamin Aslan's avatar Bunyamin Aslan
Browse files

adding gitlab file

parent 8cafb8c3
No related branches found
No related tags found
No related merge requests found
Pipeline #1241 passed
cache:
paths:
- .m2/
mvn:cleanpackage:
image: maven:3.5.3-jdk-8
script: mvn -Dmaven.repo.local=../.m2 -q clean package -e
......@@ -22,7 +22,7 @@ public class Attachment {
*
* @param file_path obj.
*/
public Attachment(String file_path) {
public Attachment(final String file_path) {
this.filename = parsePath(file_path);
this.datasource = new FileDataSource(file_path);
}
......@@ -33,7 +33,7 @@ public class Attachment {
* @param path obj.
* @return filename.
*/
private String parsePath(String path) {
private String parsePath(final String path) {
String[] s = path.split("/");
return s[s.length - 1];
}
......
......@@ -32,6 +32,9 @@ public class MailRetriever {
private final MongoCollection mongo_collection;
private final GridFSBucket bucket;
/**
* Constructor. Connection to db.
*/
public MailRetriever() {
int db_port = 27017;
String db_host = "127.0.0.1";
......@@ -63,11 +66,11 @@ public class MailRetriever {
/**
* download doc.odt attachment in attachments/retrieving/ folder.
*
* @param mail
* @throws FileNotFoundException
* @throws IOException
* @param mail obj.
* @throws FileNotFoundException exc.
* @throws IOException exc.
*/
public void downloadAttachment(Document mail)
public void downloadAttachment(final Document mail)
throws FileNotFoundException, IOException {
ArrayList<Document> body = (ArrayList<Document>) mail.get("BODY");
ObjectId fileid = (ObjectId) body.get(1).get("FILE-ID");
......
......@@ -9,7 +9,6 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.Properties;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
......@@ -50,7 +49,7 @@ public class MailSender {
*
* @param content_message obj.
*/
public void setContent_message(String content_message) {
public void setContentMessage(final String content_message) {
this.content_message = content_message;
}
......@@ -59,7 +58,7 @@ public class MailSender {
*
* @param sender obj.
*/
public void setSender(InternetAddress sender) {
public void setSender(final InternetAddress sender) {
this.sender = sender;
}
......@@ -68,7 +67,7 @@ public class MailSender {
*
* @param att obj.
*/
public void addAttachment(Attachment att) {
public void addAttachment(final Attachment att) {
this.content_attachments.add(att);
}
......@@ -77,7 +76,7 @@ public class MailSender {
*
* @param recipient obj.
*/
public void addRecipient(InternetAddress recipient) {
public void addRecipient(final InternetAddress recipient) {
this.recipients.add(recipient);
}
......@@ -94,14 +93,14 @@ public class MailSender {
*
* @param subj obj.
*/
public void setSubject(String subj) {
public void setSubject(final String subj) {
this.subject = subj;
}
/**
* send mail.
*
* @throws MessagingException
* @throws MessagingException exc.
*/
public void sendMail() throws MessagingException {
MimeMessage mail = new MimeMessage(session);
......
......@@ -18,16 +18,27 @@ import org.bson.Document;
*/
public class Main {
/**
* private constructor.
*/
private Main() {
}
public static void main(String[] args)
/**
* Mail.
*
* @param args obj.
* @throws AddressException exc.
* @throws MessagingException exc.
* @throws IOException exc.
*/
public static void main(final String[] args)
throws AddressException, MessagingException, IOException {
Server.launchServer("./", "./");
MailSender mail_sender = new MailSender();
//Simple mail from bob to alice
mail_sender.setContent_message("This is the content of the "
mail_sender.setContentMessage("This is the content of the "
+ "first message\n\nPS: post scriptum.");
mail_sender.setSubject("This is the subject of the mail number 1");
mail_sender.setSender(new InternetAddress("bob@gmail.com"));
......@@ -36,7 +47,7 @@ public class Main {
//Mail with attachemt from bob to alice and smith
mail_sender.resetMail();
mail_sender.setContent_message("This is the content of the "
mail_sender.setContentMessage("This is the content of the "
+ "second message\n\nPS: post scriptum.");
mail_sender.setSubject("This is the subject of the mail number 2");
mail_sender.setSender(new InternetAddress("bob@gmail.com"));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment