Skip to content

Add CondStore#87

Open
alex-yxw wants to merge 2 commits intoyahoo:masterfrom
alex-yxw:condstore
Open

Add CondStore#87
alex-yxw wants to merge 2 commits intoyahoo:masterfrom
alex-yxw:condstore

Conversation

@alex-yxw
Copy link
Contributor

Description

a. added the UNCHANGEDSINCE STORE modifier.
b. added the MODIFIED response code that is used with an OK response
to the STORE command. (It can also be used in a NO response.)
c. added the CHANGEDSINCE FETCH modifier.
d. added a new MODSEQ search criterion.
e. defined an additional CONDSTORE parameter to SELECT/EXAMINE
commands.
f. added VANISHED UID FETCH modifier

Motivation and Context

Store command can send additional UNCHANGEDSINCE parameter, Store response can be parsed with MODIFIED response code, , Fetch command can send additional CHANGEDSINCE and Vanished parameter, Search command can send with MODSEQ parameter, and Select/Examine command can send additional CONDSTORE parameter, when CONDSTORE is supported. To support client to send that parameter added new classes.

How Has This Been Tested?

Added unit tests to verify

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Major release (change is NOT backward compatible with prior release)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@alex-yxw
Copy link
Contributor Author

@fansu @jui8wang

@fansu fansu self-requested a review March 4, 2020 19:19
@alex-yxw alex-yxw force-pushed the condstore branch 5 times, most recently from 3989ee1 to 962b00e Compare March 7, 2020 00:44
Copy link
Contributor

@nituyahoo nituyahoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments, not fully reviewed let us discuss first

if (handled) {
resps[i] = null;
} else {
ir.reset(); // default back the parsing index
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if nomodseq and mailboxid is specified multiple times?

Copy link
Contributor Author

@alex-yxw alex-yxw Mar 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We won't, based on RFC, we should always have one NoModSeq to indicate whether we support CondStore or not. Also, you can only have one MailBox Id for each folder. You can confirm with Ray about this.

* @return the array of MessageNumberSet
* @throws ImapAsyncClientException will not throw
*/
public static MessageNumberSet[] buildMessageNumberSets(@Nullable final String msgNumbers) throws ImapAsyncClientException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this parsing available in the imap client by sun?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that is the reason why Ray created MessageNumberSet.java.

int i = 0; // msgset index
try {
for (final String element : msgSetStrs) {
if (element.contains(":")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can there we whitespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, extra space is not allowed. I add test cases for that.

s.append(RECENT);
} else if (sf[0] == Flags.Flag.SEEN) {
s.append(SEEN);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if sf[0] does not match any of the above?

please discuss

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on RFC, we currently only support above system flags; otherwise, it will count as user flag.

}
} else { // user flag == 1
s.append(uf[0]);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if sf and uf is not specified?

Copy link
Contributor Author

@alex-yxw alex-yxw Mar 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on getUserFlags(), it will try to find it in the HashMap. If it doesn't create the flag, it will add the flag into user flag. Since there is only one flag and the flag can only be user flag or system flag. As long as it is not system flag, it will count as user flag. You can check buildFlagString() created by Ray inside the same file to confirm the implementation flow.

* @param items the data items
* @param changedSince changed since the given modification sequence
*/
public UidFetchCommand(@Nonnull final MessageNumberSet[] msgsets, @Nonnull final String items, @Nonnull final Long changedSince) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does uid fetch need message number set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on rfc, we need a way to store message numbers or uids, so we use MessageNumberSet to store them and send it via uid fetch command.

* @param action whether to replace, add or remove the flags
* @param unchangedSince unchanged since the given modification sequence
*/
public UidStoreFlagsCommand(@Nonnull final MessageNumberSet[] msgsets, @Nonnull final Flags flags, @Nonnull final FlagsAction action,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does uid store require msg set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on rfc, we need a way to store message numbers or uids, so we use MessageNumberSet to store them and send it via uid store command.

* @throws ImapAsyncClientException when target class to covert to is not supported
*/
@Nonnull
public <T> T readValue(@Nonnull final IMAPResponse[] content, @Nonnull final Class<T> valueType, @Nonnull final FetchItem[] extensionItems)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only fetch result?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, only fetch command can have extension items. Therefore, only fetch result can have extension items as well.

@alex-yxw alex-yxw force-pushed the condstore branch 5 times, most recently from 1fdecff to 92c6795 Compare March 19, 2020 17:02
@nvsnvikram
Copy link
Contributor

Sorry, I didn't know about this pull request. Can you rebase and let me know? I will try to take a look soon. @fansu and @jui8wang , please do a final review and let me know.

More test cases for MessageNumberSet

null out mailboxinfo, try catch outside for string message number set, stringbuilder for formatter, constant mapper with parsing exception, fix version and developer name

Update UT for exception, follow mailbox pattern

Fix exception throw java docs for UT

Fix javadoc check style for UT

Address Fan's comment

Undo style fix

Update checkstyle_suppressions.xml

Update version

Remove reduant null and add test cases for null

Update FailureType typo

Update version

Add new test cases for parsing bad string to cover branch. Remove constant length for condstore string

Remove constant string length for unchange since

Update version
public final class ExtendedModifiedSinceTerm extends SearchTerm {

/** The name of the metadata item. */
private final Flags entryName;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know any servers that support modified since for specific flags?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried the following example from RFC 4551 and it works for yahoo mail and gmail:
Example 15:
C: a SEARCH MODSEQ "/flags/\draft" all 620162338

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YuanxinWang , Are you sure? Yahoo/Aol does not even support CONDSTORE. Supporting individual flag modseq would be quite hard even for Gmail. Let me know if you want to do a hangout and show me what you tried.

@tolikbotov
Copy link

Hello. Are there any plans to merge this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants