fetch.setFlags(true); fetch.setInternalDate(true); fetch.setSize(true); } else if ("FULL".equalsIgnoreCase(name)) { fetch.setFlags(true); fetch.setInternalDate(true); fetch.setSize(true); fetch.setEnvelope(true); fetch.setBody(true); } else if ("ALL".equalsIgnoreCase(name)) { fetch.setFlags(true); fetch.setInternalDate(true); fetch.setSize(true); fetch.setEnvelope(true); } else if ("FLAGS".equalsIgnoreCase(name)) { fetch.setFlags(true); } else if ("RFC822.SIZE".equalsIgnoreCase(name)) { fetch.setSize(true); } else if ("ENVELOPE".equalsIgnoreCase(name)) { fetch.setEnvelope(true); } else if ("INTERNALDATE".equalsIgnoreCase(name)) { fetch.setInternalDate(true); } else if ("BODY".equalsIgnoreCase(name)) { fetch.setBody(true); } else if ("BODYSTRUCTURE".equalsIgnoreCase(name)) { fetch.setBodyStructure(true); } else if ("UID".equalsIgnoreCase(name)) { fetch.setUid(true); } else if ("RFC822".equalsIgnoreCase(name)) {
boolean ensureFlagsResponse = false; final Flags resultFlags = result.getFlags(); if (fetch.isSetSeen() && !resultFlags.contains(Flags.Flag.SEEN)) { mailbox.setFlags(new Flags(Flags.Flag.SEEN), MessageManager.FlagsUpdateMode.ADD, MessageRange.one(resultUid), mailboxSession); resultFlags.add(Flags.Flag.SEEN); if (fetch.isFlags() || ensureFlagsResponse) { if (selected.isRecent(resultUid)) { resultFlags.add(Flags.Flag.RECENT); if (fetch.isInternalDate()) { setInternalDate(result.getInternalDate()); if (fetch.isSize()) { setSize(result.getSize()); if (fetch.isEnvelope()) { this.envelope = buildEnvelope(result); Collection<BodyFetchElement> elements = fetch.getBodyElements(); this.elements = new ArrayList<>(); for (BodyFetchElement fetchElement : elements) { if (fetch.isBody() || fetch.isBodyStructure()) { if (fetch.isBody() && this.elements.isEmpty()) { body = new MimeDescriptorStructure(false, result.getMimeDescriptor(), envelopeBuilder); if (fetch.isBodyStructure()) {
final Long changedSince = fetch.getChangedSince(); final boolean vanished = fetch.getVanished(); if (vanished && !EnableProcessor.getEnabledCapabilities(session).contains(ImapConstants.SUPPORTS_QRESYNC)) { taggedBad(command, tag, responder, HumanReadableText.QRESYNC_NOT_ENABLED); if (fetch.getChangedSince() != -1 || fetch.isModSeq()) { fetch.setUid(true);
protected FetchGroup getFetchGroup(FetchData fetch) { FetchGroupImpl result = new FetchGroupImpl(); if (fetch.isEnvelope()) { result.or(FetchGroup.HEADERS); if (fetch.isBody() || fetch.isBodyStructure()) { result.or(FetchGroup.MIME_DESCRIPTOR); Collection<BodyFetchElement> bodyElements = fetch.getBodyElements(); if (bodyElements != null) { for (final Iterator<BodyFetchElement> it = bodyElements.iterator(); it.hasNext();) {
FetchData fetch = new FetchData(); fetch.setChangedSince(request.number(true)); fetch.setVanished(true); break; default:
@Test public void testShouldParseZeroAndLength() throws Exception { IdRange[] ranges = { new IdRange(1) }; FetchData data = new FetchData(); data.add(new BodyFetchElement("BODY[]", BodyFetchElement.CONTENT, null, null, new Long(0), new Long(100)), false); check("1 (BODY[]<0.100>)\r\n", ranges, false, data, "A01"); }
if (fetch.isModSeq() && result.getModSeq() <= fetch.getChangedSince()) { continue;
public FetchRequest(ImapCommand command, boolean useUids, IdRange[] idSet, FetchData fetch, String tag) { super(tag, command); this.useUids = useUids; this.idSet = idSet; this.fetch = fetch; if (useUids) { fetch.setUid(true); } }
@Override protected ImapMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, boolean useUids, ImapSession session) throws DecodingException { IdRange[] idSet = request.parseIdRange(session); FetchData fetch = fetchRequest(request); // Check if we have VANISHED and and UID FETCH as its only allowed there // // See RFC5162 3.2. VANISHED UID FETCH Modifier if (fetch.getVanished() && !useUids) { throw new DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "VANISHED only allowed in UID FETCH"); } request.eol(); return new FetchRequest(command, useUids, idSet, fetch, tag); }
boolean ensureFlagsResponse = false; final Flags resultFlags = result.getFlags(); if (fetch.isSetSeen() && !resultFlags.contains(Flags.Flag.SEEN)) { mailbox.setFlags(new Flags(Flags.Flag.SEEN), true, false, MessageRange.one(resultUid), mailboxSession); resultFlags.add(Flags.Flag.SEEN); if (fetch.isFlags() || ensureFlagsResponse) { if (selected.isRecent(resultUid)) { resultFlags.add(Flags.Flag.RECENT); if (fetch.isInternalDate()) { setInternalDate(result.getInternalDate()); if (fetch.isSize()) { setSize(result.getSize()); if (fetch.isEnvelope()) { this.envelope = buildEnvelope(result); Collection<BodyFetchElement> elements = fetch.getBodyElements(); this.elements = new ArrayList<FetchResponse.BodyElement>(); for (Iterator<BodyFetchElement> iterator = elements.iterator(); iterator.hasNext();) { if (fetch.isBody() || fetch.isBodyStructure()) { if (fetch.isBody() && this.elements.isEmpty()) { body = new MimeDescriptorStructure(false, result.getMimeDescriptor(), envelopeBuilder); if (fetch.isBodyStructure()) {
final Long changedSince = fetch.getChangedSince(); final boolean vanished = fetch.getVanished(); if (vanished && !EnableProcessor.getEnabledCapabilities(session).contains(ImapConstants.SUPPORTS_QRESYNC)) { taggedBad(command, tag, responder, HumanReadableText.QRESYNC_NOT_ENABLED); if (fetch.getChangedSince() != -1 || fetch.isModSeq()) { fetch.setUid(true);
protected FetchGroup getFetchGroup(FetchData fetch) { FetchGroupImpl result = new FetchGroupImpl(); if (fetch.isEnvelope()) { result.or(FetchGroup.HEADERS); if (fetch.isBody() || fetch.isBodyStructure()) { result.or(FetchGroup.MIME_DESCRIPTOR); Collection<BodyFetchElement> bodyElements = fetch.getBodyElements(); if (bodyElements != null) { for (BodyFetchElement element : bodyElements) {
FetchData fetch = new FetchData(); fetch.setChangedSince(request.number(true)); fetch.setVanished(true); default: break;
@Test public void testShouldParseNonZeroAndLength() throws Exception { IdRange[] ranges = { new IdRange(1) }; FetchData data = new FetchData(); data.add(new BodyFetchElement("BODY[]", BodyFetchElement.CONTENT, null, null, new Long(20), new Long(12342348)), false); check("1 (BODY[]<20.12342348>)\r\n", ranges, false, data, "A01"); }
public FetchRequest(final ImapCommand command, final boolean useUids, final IdRange[] idSet, final FetchData fetch, String tag) { super(tag, command); this.useUids = useUids; this.idSet = idSet; this.fetch = fetch; if (useUids) { fetch.setUid(true); } }
/** * @see * org.apache.james.imap.decode.parser.AbstractUidCommandParser#decode(org.apache.james.imap.api.ImapCommand, * org.apache.james.imap.decode.ImapRequestLineReader, java.lang.String, * boolean, org.apache.james.imap.api.process.ImapSession) */ protected ImapMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, boolean useUids, ImapSession session) throws DecodingException { IdRange[] idSet = request.parseIdRange(session); FetchData fetch = fetchRequest(request); // Check if we have VANISHED and and UID FETCH as its only allowed there // // See RFC5162 3.2. VANISHED UID FETCH Modifier if (fetch.getVanished() && !useUids) { throw new DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "VANISHED only allowed in UID FETCH"); } request.eol(); final ImapMessage result = new FetchRequest(command, useUids, idSet, fetch, tag); return result; }
fetch.setFlags(true); fetch.setInternalDate(true); fetch.setSize(true); } else if ("FULL".equalsIgnoreCase(name)) { fetch.setFlags(true); fetch.setInternalDate(true); fetch.setSize(true); fetch.setEnvelope(true); fetch.setBody(true); } else if ("ALL".equalsIgnoreCase(name)) { fetch.setFlags(true); fetch.setInternalDate(true); fetch.setSize(true); fetch.setEnvelope(true); } else if ("FLAGS".equalsIgnoreCase(name)) { fetch.setFlags(true); } else if ("RFC822.SIZE".equalsIgnoreCase(name)) { fetch.setSize(true); } else if ("ENVELOPE".equalsIgnoreCase(name)) { fetch.setEnvelope(true); } else if ("INTERNALDATE".equalsIgnoreCase(name)) { fetch.setInternalDate(true); } else if ("BODY".equalsIgnoreCase(name)) { fetch.setBody(true); } else if ("BODYSTRUCTURE".equalsIgnoreCase(name)) { fetch.setBodyStructure(true); } else if ("UID".equalsIgnoreCase(name)) { fetch.setUid(true); } else if ("RFC822".equalsIgnoreCase(name)) {