import a folder full of EML files to James#69
import a folder full of EML files to James#69ilkerceng wants to merge 27 commits intoapache:masterfrom ilkerceng:master
Conversation
|
We tend to prefix our commit names by tickets: Moreover, you need to review this history. Does your changesets makes sens alone? I would encourage you to keep maximum 2/3 commits for this. eg: commit 1 : Add capability to MailboxManagement One commit is also OK You can do that with |
| CREATEMAILBOX("CreateMailbox", "namespace", "user", "name"), | ||
| LISTUSERMAILBOXES("ListUserMailboxes", "user"), | ||
| DELETEMAILBOX("DeleteMailbox", "namespace", "user", "name"), | ||
| IMPORTEMLFILETOMAILBOX("importemlfiletomailbox", "namespace", "user", "name", "path"), |
There was a problem hiding this comment.
IMPORTEMLFILETOMAILBOX("importEmlFileToMailbox", "namespace", "user", "name", "path")
Snake case makes it easier to read for end user
| String user = "user@domain"; | ||
| String namespace = "#private"; | ||
| String name = "INBOX.test"; | ||
| String emlpath = ClassLoader.getSystemResource("eml/frnog.eml").getFile(); |
There was a problem hiding this comment.
You don't need a real path here. "my/path/to/file.eml" will also work.
| } | ||
|
|
||
| @Test | ||
| public void lookupImportEmlFileToMailboxShouldReturnEnumValue() { |
There was a problem hiding this comment.
Add one breakline before isEqualTo
| assertThat(inMemoryMapperFactory.getMessageMapper(session).countMessagesInMailbox(mailbox)).isEqualTo(0); | ||
| Iterator<MailboxMessage> iterator = inMemoryMapperFactory.getMessageMapper(session).findInMailbox(mailbox, | ||
| MessageRange.all(), null, 1); | ||
| assertFalse(iterator.hasNext()); |
There was a problem hiding this comment.
asserThat(iterator.hasNext()).isFalse();
chibenwa
left a comment
There was a problem hiding this comment.
Very good proposition! Congratulation!
| mailboxProbe.deleteMailbox(arguments[1], arguments[2], arguments[3]); | ||
| break; | ||
| case IMPORTEMLFILETOMAILBOX: | ||
| mailboxProbe.importEmlFileToMailBox(arguments[1], arguments[2], arguments[3], arguments[4]); |
There was a problem hiding this comment.
Sorry it's mailbox and not mailBox. Could you please fix this case issue?
There was a problem hiding this comment.
i have fixed it as Maibox.
| } | ||
|
|
||
| @Override | ||
| public void importEmlFileToMailBox(String namespace, String user, String name, String emlpath) { |
There was a problem hiding this comment.
Could you please fix this case issue?
There was a problem hiding this comment.
i have fixed it as Maibox.
There was a problem hiding this comment.
It should be:
mailboxManagerManagement.importEmlFileToMailbox(namespace, user, name, emlpath);
| } | ||
|
|
||
| @Test | ||
| public void lookupImportEmlFileToMailboxShouldReturnEnumValue() { |
There was a problem hiding this comment.
Maybe we can get the name of the command shorter... Maybe importEml is enough...
I 'm thinking to poor admins...
There was a problem hiding this comment.
hmm, what is your last decision for that :) should i change the name "importEmlFileToMailbox" as importEml for all occurences
| session = mailboxManager.createSystemSession(user, log); | ||
| mailboxManager.startProcessingRequest(session); | ||
| MessageManager messageManager = mailboxManager.getMailbox(new MailboxPath(namespace, user, name), session); | ||
| InputStream emlFileResourceAsStream = new FileInputStream(emlpath); |
There was a problem hiding this comment.
i have changed it as emlFileAsStream
| MessageManager messageManager = mailboxManager.getMailbox(new MailboxPath(namespace, user, name), session); | ||
| InputStream emlFileResourceAsStream = new FileInputStream(emlpath); | ||
| ComposedMessageId composedMessageId = messageManager.appendMessage(emlFileResourceAsStream, new Date(), | ||
| session, false, new Flags()); |
There was a problem hiding this comment.
What does false means? We tend to extract values to constant to give them a name.
I believe, if it is isRecent then it should be true.
There was a problem hiding this comment.
yep it is isRecent, i have changed isRecent as true.
| mailboxManagerManagement.importEmlFileToMailBox(MailboxConstants.USER_NAMESPACE, USER, "name", emlpath); | ||
|
|
||
| assertThat(inMemoryMapperFactory.getMessageMapper(session).countMessagesInMailbox(mailbox)).isEqualTo(1); | ||
| Iterator<MailboxMessage> iterator = inMemoryMapperFactory.getMessageMapper(session).findInMailbox(mailbox, |
There was a problem hiding this comment.
Here what is null? Your fetch type? Use FetchType.Full instead.
Extract 1 in a constant named limit
There was a problem hiding this comment.
i have changed it as MessageMapper.FetchType.Full, added LIMIT as a constant for 1
| mailboxManagerManagement.importEmlFileToMailBox(MailboxConstants.USER_NAMESPACE, USER, "name", "wrong_path" + emlpath); | ||
|
|
||
| assertThat(inMemoryMapperFactory.getMessageMapper(session).countMessagesInMailbox(mailbox)).isEqualTo(0); | ||
| Iterator<MailboxMessage> iterator = inMemoryMapperFactory.getMessageMapper(session).findInMailbox(mailbox, |
There was a problem hiding this comment.
sorry but what you mean with "Idem here"?
There was a problem hiding this comment.
I mean I have the same comment than above:
Here what is null? Your fetch type? Use FetchType.Full instead.
Extract 1 in a constant named limit
| } | ||
|
|
||
| @Override | ||
| public void importEmlFileToMailBox(String namespace, String user, String name, String emlpath) { |
There was a problem hiding this comment.
It should be:
mailboxManagerManagement.importEmlFileToMailbox(namespace, user, name, emlpath);
| CREATEMAILBOX("CreateMailbox", "namespace", "user", "name"), | ||
| LISTUSERMAILBOXES("ListUserMailboxes", "user"), | ||
| DELETEMAILBOX("DeleteMailbox", "namespace", "user", "name"), | ||
| IMPORTEMLFILETOMAILBOX("ImportEmlFileToMailbox", "namespace", "user", "name", "path"), |
There was a problem hiding this comment.
It should be :
IMPORTEML("ImportEml", "namespace", "user", "name", "path"),
For end user readability
| mailboxManagerManagement.importEmlFileToMailBox(MailboxConstants.USER_NAMESPACE, USER, "name", "wrong_path" + emlpath); | ||
|
|
||
| assertThat(inMemoryMapperFactory.getMessageMapper(session).countMessagesInMailbox(mailbox)).isEqualTo(0); | ||
| Iterator<MailboxMessage> iterator = inMemoryMapperFactory.getMessageMapper(session).findInMailbox(mailbox, |
There was a problem hiding this comment.
I mean I have the same comment than above:
Here what is null? Your fetch type? Use FetchType.Full instead.
Extract 1 in a constant named limit
|
mr. @chibenwa
|
| return subscriptionManager.subscriptions(mailboxSession); | ||
| } | ||
|
|
||
| //TODO: ilker: impelement this |
There was a problem hiding this comment.
Could you please do it then ?
| checkString(namespace, "mailbox path namespace"); | ||
| checkString(user, "mailbox path user"); | ||
| checkString(name, "mailbox name"); | ||
| checkString(emlpath, "email file path name"); |
There was a problem hiding this comment.
I would remove the checkString private method and do:
Preconditions.checkArgument(!Strings.isNullOrEmpty(namespace), "namespace can't be null or empty");
using Strings from Guava: https://google.github.io/guava/releases/18.0/api/docs/com/google/common/base/Strings.html
IMPORTEMLFILETOMAILBOX is added to executeCommand function
IMPORTEMLFILETOMAILBOX("importemlfiletomailbox", "namespace", "user", "name", "path"),
lookupImportEmlFileToMailboxShouldReturnEnumValue test function is added
importEmlFileToMailBox function declaration added to MailboxProbe interface
importEmlFileToMailBox is implemented checking if arguments correctly given
indentation has corrected.
indentations has corrected
UnitTest is added to control if file is not found
indentations has corrected
…CmdType to camel case
…led, LIMIT is added as a constant for the maximal limit of returned
importEmlFileToMailbox functions is added to MailboxProbeImpl.java note: will be implemented.
|
This has just been merged. Could you please close the pull request? This will avoid asking this to the Apache INFRA team... Thanks again for your contribution. |
|
I also thank you so much. |
https://issues.apache.org/jira/browse/JAMES-2081
implemented necessary codes, corrected indentations, added tests.