Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchResponseBuilder.java URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchResponseBuilder.java?rev=1092137&r1=1092136&r2=1092137&view=diff ============================================================================== --- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchResponseBuilder.java (original) +++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchResponseBuilder.java Thu Apr 14 11:21:11 2011 @@ -93,34 +93,29 @@ public final class FetchResponseBuilder } public FetchResponse build() { - final FetchResponse result = new FetchResponse(msn, flags, uid, - internalDate, size, envelope, body, bodystructure, elements); + final FetchResponse result = new FetchResponse(msn, flags, uid, internalDate, size, envelope, body, bodystructure, elements); return result; } - public FetchResponse build(FetchData fetch, MessageResult result, MessageManager mailbox, - ImapSession session, boolean useUids) throws MessageRangeException, - ParseException, MailboxException { + public FetchResponse build(FetchData fetch, MessageResult result, MessageManager mailbox, ImapSession session, boolean useUids) throws MessageRangeException, ParseException, MailboxException { final SelectedMailbox selected = session.getSelected(); final long resultUid = result.getUid(); final int resultMsn = selected.msn(resultUid); - - if (resultMsn == SelectedMailbox.NO_SUCH_MESSAGE) throw new MessageRangeException("No such message found with uid " + resultUid); - + + if (resultMsn == SelectedMailbox.NO_SUCH_MESSAGE) + throw new MessageRangeException("No such message found with uid " + resultUid); + reset(resultMsn); - //setMsn(resultMsn); + // setMsn(resultMsn); // Check if this fetch will cause the "SEEN" flag to be set on this - // message - // If so, update the flags, and ensure that a flags response is included - // in the response. - final MailboxSession mailboxSession = ImapSessionUtils - .getMailboxSession(session); + // message. If so, update the flags, and ensure that a flags response is + // included in the response. + final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session); 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); + mailbox.setFlags(new Flags(Flags.Flag.SEEN), true, false, MessageRange.one(resultUid), mailboxSession); resultFlags.add(Flags.Flag.SEEN); ensureFlagsResponse = true; } @@ -149,19 +144,16 @@ public final class FetchResponseBuilder // Only create when needed if (fetch.isBody() || fetch.isBodyStructure()) { - final MimeDescriptor descriptor = result - .getMimeDescriptor(); + final MimeDescriptor descriptor = result.getMimeDescriptor(); // BODY response if (fetch.isBody()) { - body = new MimeDescriptorStructure(false, descriptor, - envelopeBuilder); + body = new MimeDescriptorStructure(false, descriptor, envelopeBuilder); } // BODYSTRUCTURE response if (fetch.isBodyStructure()) { - bodystructure = new MimeDescriptorStructure(true, descriptor, - envelopeBuilder); + bodystructure = new MimeDescriptorStructure(true, descriptor, envelopeBuilder); } } // UID response @@ -174,8 +166,7 @@ public final class FetchResponseBuilder this.elements = new ArrayList<FetchResponse.BodyElement>(); for (Iterator<BodyFetchElement> iterator = elements.iterator(); iterator.hasNext();) { BodyFetchElement fetchElement = iterator.next(); - final FetchResponse.BodyElement element = bodyFetch(result, - fetchElement); + final FetchResponse.BodyElement element = bodyFetch(result, fetchElement); if (element != null) { this.elements.add(element); } @@ -183,8 +174,7 @@ public final class FetchResponseBuilder return build(); } - private FetchResponse.Envelope buildEnvelope(final MessageResult result) - throws MailboxException, ParseException { + private FetchResponse.Envelope buildEnvelope(final MessageResult result) throws MailboxException, ParseException { return envelopeBuilder.buildEnvelope(result); } @@ -196,9 +186,7 @@ public final class FetchResponseBuilder this.internalDate = internalDate; } - private FetchResponse.BodyElement bodyFetch( - final MessageResult messageResult, BodyFetchElement fetchElement) - throws MailboxException { + private FetchResponse.BodyElement bodyFetch(final MessageResult messageResult, BodyFetchElement fetchElement) throws MailboxException { final Long firstOctet = fetchElement.getFirstOctet(); final Long numberOfOctets = fetchElement.getNumberOfOctets(); @@ -207,53 +195,46 @@ public final class FetchResponseBuilder final int[] path = fetchElement.getPath(); final Collection<String> names = fetchElement.getFieldNames(); final boolean isBase = (path == null || path.length == 0); - final FetchResponse.BodyElement fullResult = bodyContent(messageResult, - name, specifier, path, names, isBase); - final FetchResponse.BodyElement result = wrapIfPartialFetch(firstOctet, - numberOfOctets, fullResult); + final FetchResponse.BodyElement fullResult = bodyContent(messageResult, name, specifier, path, names, isBase); + final FetchResponse.BodyElement result = wrapIfPartialFetch(firstOctet, numberOfOctets, fullResult); return result; } - private FetchResponse.BodyElement bodyContent( - final MessageResult messageResult, final String name, - final int specifier, final int[] path, final Collection<String> names, - final boolean isBase) throws MailboxException { + private FetchResponse.BodyElement bodyContent(final MessageResult messageResult, final String name, final int specifier, final int[] path, final Collection<String> names, final boolean isBase) throws MailboxException { final FetchResponse.BodyElement fullResult; switch (specifier) { - case BodyFetchElement.CONTENT: - fullResult = content(messageResult, name, path, isBase); - break; - - case BodyFetchElement.HEADER_FIELDS: - fullResult = fields(messageResult, name, path, names, isBase); - break; - - case BodyFetchElement.HEADER_NOT_FIELDS: - fullResult = fieldsNot(messageResult, name, path, names, isBase); - break; - - case BodyFetchElement.MIME: - fullResult = mimeHeaders(messageResult, name, path, isBase); - break; - case BodyFetchElement.HEADER: - fullResult = headers(messageResult, name, path, isBase); - break; - - case BodyFetchElement.TEXT: - fullResult = text(messageResult, name, path, isBase); - break; - - default: - fullResult = null; - break; + case BodyFetchElement.CONTENT: + fullResult = content(messageResult, name, path, isBase); + break; + + case BodyFetchElement.HEADER_FIELDS: + fullResult = fields(messageResult, name, path, names, isBase); + break; + + case BodyFetchElement.HEADER_NOT_FIELDS: + fullResult = fieldsNot(messageResult, name, path, names, isBase); + break; + + case BodyFetchElement.MIME: + fullResult = mimeHeaders(messageResult, name, path, isBase); + break; + case BodyFetchElement.HEADER: + fullResult = headers(messageResult, name, path, isBase); + break; + + case BodyFetchElement.TEXT: + fullResult = text(messageResult, name, path, isBase); + break; + + default: + fullResult = null; + break; } return fullResult; } - private FetchResponse.BodyElement wrapIfPartialFetch(final Long firstOctet, - final Long numberOfOctets, - final FetchResponse.BodyElement fullResult) { + private FetchResponse.BodyElement wrapIfPartialFetch(final Long firstOctet, final Long numberOfOctets, final FetchResponse.BodyElement fullResult) { final FetchResponse.BodyElement result; if (firstOctet == null) { result = fullResult; @@ -265,15 +246,12 @@ public final class FetchResponseBuilder numberOfOctetsAsLong = numberOfOctets.longValue(); } final long firstOctetAsLong = firstOctet.longValue(); - result = new PartialFetchBodyElement(fullResult, firstOctetAsLong, - numberOfOctetsAsLong); + result = new PartialFetchBodyElement(fullResult, firstOctetAsLong, numberOfOctetsAsLong); } return result; } - private FetchResponse.BodyElement text(final MessageResult messageResult, - String name, final int[] path, final boolean isBase) - throws MailboxException { + private FetchResponse.BodyElement text(final MessageResult messageResult, String name, final int[] path, final boolean isBase) throws MailboxException { final FetchResponse.BodyElement result; final Content body; if (isBase) { @@ -286,9 +264,7 @@ public final class FetchResponseBuilder return result; } - private FetchResponse.BodyElement mimeHeaders( - final MessageResult messageResult, String name, final int[] path, - final boolean isBase) throws MailboxException { + private FetchResponse.BodyElement mimeHeaders(final MessageResult messageResult, String name, final int[] path, final boolean isBase) throws MailboxException { final FetchResponse.BodyElement result; final Iterator<MessageResult.Header> headers = getMimeHeaders(messageResult, path, isBase); List<MessageResult.Header> lines = MessageResultUtils.getAll(headers); @@ -296,9 +272,7 @@ public final class FetchResponseBuilder return result; } - private FetchResponse.BodyElement headers( - final MessageResult messageResult, String name, final int[] path, - final boolean isBase) throws MailboxException { + private FetchResponse.BodyElement headers(final MessageResult messageResult, String name, final int[] path, final boolean isBase) throws MailboxException { final FetchResponse.BodyElement result; final Iterator<MessageResult.Header> headers = getHeaders(messageResult, path, isBase); List<MessageResult.Header> lines = MessageResultUtils.getAll(headers); @@ -306,9 +280,7 @@ public final class FetchResponseBuilder return result; } - private FetchResponse.BodyElement fieldsNot( - final MessageResult messageResult, String name, final int[] path, - Collection<String> names, final boolean isBase) throws MailboxException { + private FetchResponse.BodyElement fieldsNot(final MessageResult messageResult, String name, final int[] path, Collection<String> names, final boolean isBase) throws MailboxException { final FetchResponse.BodyElement result; final Iterator<MessageResult.Header> headers = getHeaders(messageResult, path, isBase); List<MessageResult.Header> lines = MessageResultUtils.getNotMatching(names, headers); @@ -316,9 +288,7 @@ public final class FetchResponseBuilder return result; } - private FetchResponse.BodyElement fields(final MessageResult messageResult, - String name, final int[] path, Collection<String> names, - final boolean isBase) throws MailboxException { + private FetchResponse.BodyElement fields(final MessageResult messageResult, String name, final int[] path, Collection<String> names, final boolean isBase) throws MailboxException { final FetchResponse.BodyElement result; final Iterator<MessageResult.Header> headers = getHeaders(messageResult, path, isBase); List<MessageResult.Header> lines = MessageResultUtils.getMatching(names, headers); @@ -326,9 +296,7 @@ public final class FetchResponseBuilder return result; } - private Iterator<MessageResult.Header> getHeaders(final MessageResult messageResult, - final int[] path, final boolean isBase) - throws MailboxException { + private Iterator<MessageResult.Header> getHeaders(final MessageResult messageResult, final int[] path, final boolean isBase) throws MailboxException { final Iterator<MessageResult.Header> headers; if (isBase) { headers = messageResult.headers(); @@ -339,16 +307,13 @@ public final class FetchResponseBuilder return headers; } - private Iterator<MessageResult.Header> getMimeHeaders(final MessageResult messageResult, - final int[] path, final boolean isBase) throws MailboxException { + private Iterator<MessageResult.Header> getMimeHeaders(final MessageResult messageResult, final int[] path, final boolean isBase) throws MailboxException { MessageResult.MimePath mimePath = new MimePathImpl(path); final Iterator<MessageResult.Header> headers = messageResult.iterateMimeHeaders(mimePath); return headers; } - private FetchResponse.BodyElement content( - final MessageResult messageResult, String name, final int[] path, - final boolean isBase) throws MailboxException { + private FetchResponse.BodyElement content(final MessageResult messageResult, String name, final int[] path, final boolean isBase) throws MailboxException { final FetchResponse.BodyElement result; final Content full; if (isBase) {
Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/HeaderBodyElement.java URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/HeaderBodyElement.java?rev=1092137&r1=1092136&r2=1092137&view=diff ============================================================================== --- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/HeaderBodyElement.java (original) +++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/HeaderBodyElement.java Thu Apr 14 11:21:11 2011 @@ -52,24 +52,27 @@ final class HeaderBodyElement implements /* * (non-Javadoc) - * @see org.apache.james.imap.message.response.FetchResponse.BodyElement#getName() + * + * @see + * org.apache.james.imap.message.response.FetchResponse.BodyElement#getName + * () */ public String getName() { return name; } - private long calculateSize(List<MessageResult.Header> headers) { final int result; if (headers.isEmpty()) { - // even if the headers are empty we need to include the headers body seperator + // even if the headers are empty we need to include the headers body + // seperator // See IMAP-294 result = ImapConstants.LINE_END.length(); } else { int count = 0; for (final Iterator<MessageResult.Header> it = headers.iterator(); it.hasNext();) { MessageResult.Header header = it.next(); - count += header.size() + ImapConstants.LINE_END.length(); + count += header.size() + ImapConstants.LINE_END.length(); } result = count + ImapConstants.LINE_END.length(); } @@ -78,7 +81,9 @@ final class HeaderBodyElement implements /* * (non-Javadoc) - * @see org.apache.james.imap.message.response.FetchResponse.BodyElement#size() + * + * @see + * org.apache.james.imap.message.response.FetchResponse.BodyElement#size() */ public long size() { return size; @@ -86,7 +91,10 @@ final class HeaderBodyElement implements /* * (non-Javadoc) - * @see org.apache.james.imap.message.response.FetchResponse.BodyElement#writeTo(java.nio.channels.WritableByteChannel) + * + * @see + * org.apache.james.imap.message.response.FetchResponse.BodyElement#writeTo + * (java.nio.channels.WritableByteChannel) */ public void writeTo(WritableByteChannel channel) throws IOException { ByteBuffer endLine = ByteBuffer.wrap(ImapConstants.LINE_END.getBytes()); @@ -104,7 +112,9 @@ final class HeaderBodyElement implements /* * (non-Javadoc) - * @see org.apache.james.imap.message.response.FetchResponse.BodyElement#getInputStream() + * + * @see org.apache.james.imap.message.response.FetchResponse.BodyElement# + * getInputStream() */ public InputStream getInputStream() throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MessageResultUtils.java URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MessageResultUtils.java?rev=1092137&r1=1092136&r2=1092137&view=diff ============================================================================== --- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MessageResultUtils.java (original) +++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MessageResultUtils.java Thu Apr 14 11:21:11 2011 @@ -61,8 +61,7 @@ public class MessageResultUtils { * their natural order * @throws MessagingException */ - public static List<MessageResult.Header> getMatching(final String[] names, final Iterator<MessageResult.Header> iterator) - throws MailboxException { + public static List<MessageResult.Header> getMatching(final String[] names, final Iterator<MessageResult.Header> iterator) throws MailboxException { final List<MessageResult.Header> results = new ArrayList<MessageResult.Header>(20); if (iterator != null) { while (iterator.hasNext()) { @@ -95,15 +94,12 @@ public class MessageResultUtils { * their natural order * @throws MessagingException */ - public static List<MessageResult.Header> getMatching(final Collection<String> names, - final Iterator<MessageResult.Header> iterator) throws MailboxException { + public static List<MessageResult.Header> getMatching(final Collection<String> names, final Iterator<MessageResult.Header> iterator) throws MailboxException { final List<MessageResult.Header> result = matching(names, iterator, false); return result; } - private static List<MessageResult.Header> matching(final Collection<String> names, - final Iterator<MessageResult.Header> iterator, boolean not) - throws MailboxException { + private static List<MessageResult.Header> matching(final Collection<String> names, final Iterator<MessageResult.Header> iterator, boolean not) throws MailboxException { final List<MessageResult.Header> results = new ArrayList<MessageResult.Header>(names.size()); if (iterator != null) { while (iterator.hasNext()) { @@ -118,8 +114,7 @@ public class MessageResultUtils { return results; } - private static boolean contains(final Collection<String> names, - MessageResult.Header header) throws MailboxException { + private static boolean contains(final Collection<String> names, MessageResult.Header header) throws MailboxException { boolean match = false; final String headerName = header.getName(); if (headerName != null) { @@ -146,8 +141,7 @@ public class MessageResultUtils { * their natural order * @throws MessagingException */ - public static List<MessageResult.Header> getNotMatching(final Collection<String> names, - final Iterator<MessageResult.Header> iterator) throws MailboxException { + public static List<MessageResult.Header> getNotMatching(final Collection<String> names, final Iterator<MessageResult.Header> iterator) throws MailboxException { final List<MessageResult.Header> result = matching(names, iterator, true); return result; } @@ -160,12 +154,11 @@ public class MessageResultUtils { * @param iterator * <code>Iterator</code> of <code>MessageResult.Header</code>'s, * not null - * @return <code>MessageResult.Header</code>, or null if the header does - * not exist + * @return <code>MessageResult.Header</code>, or null if the header does not + * exist * @throws MessagingException */ - public static MessageResult.Header getMatching(final String name, - final Iterator<MessageResult.Header> iterator) throws MailboxException { + public static MessageResult.Header getMatching(final String name, final Iterator<MessageResult.Header> iterator) throws MailboxException { MessageResult.Header result = null; if (name != null) { while (iterator.hasNext()) { @@ -188,11 +181,11 @@ public class MessageResultUtils { * header names, not null * @param iterator * {@link MessageResult.Header} <code>Iterator</code> - * @return <code>List</code> of <code>@MessageResult.Header</code>'s, in their natural order + * @return <code>List</code> of <code>@MessageResult.Header</code>'s, in + * their natural order * @throws MessagingException */ - public static List<MessageResult.Header> getNotMatching(final String[] names, - final Iterator<MessageResult.Header> iterator) throws MailboxException { + public static List<MessageResult.Header> getNotMatching(final String[] names, final Iterator<MessageResult.Header> iterator) throws MailboxException { final List<MessageResult.Header> results = new ArrayList<MessageResult.Header>(20); if (iterator != null) { while (iterator.hasNext()) { Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MimeDescriptorStructure.java URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MimeDescriptorStructure.java?rev=1092137&r1=1092136&r2=1092137&view=diff ============================================================================== --- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MimeDescriptorStructure.java (original) +++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MimeDescriptorStructure.java Thu Apr 14 11:21:11 2011 @@ -56,9 +56,7 @@ final class MimeDescriptorStructure impl private final Envelope envelope; - public MimeDescriptorStructure(final boolean allowExtensions, - MimeDescriptor descriptor, EnvelopeBuilder builder) - throws MailboxException, ParseException { + public MimeDescriptorStructure(final boolean allowExtensions, MimeDescriptor descriptor, EnvelopeBuilder builder) throws MailboxException, ParseException { super(); this.descriptor = descriptor; parameters = createParameters(descriptor); @@ -76,29 +74,24 @@ final class MimeDescriptorStructure impl embeddedMessageStructure = null; envelope = null; } else { - embeddedMessageStructure = new MimeDescriptorStructure( - allowExtensions, embeddedMessage, builder); + embeddedMessageStructure = new MimeDescriptorStructure(allowExtensions, embeddedMessage, builder); envelope = builder.buildEnvelope(embeddedMessage); } } - private static List<Structure> createParts(final boolean allowExtensions, - final MimeDescriptor descriptor, final EnvelopeBuilder builder) - throws MailboxException, ParseException { + private static List<Structure> createParts(final boolean allowExtensions, final MimeDescriptor descriptor, final EnvelopeBuilder builder) throws MailboxException, ParseException { final List<Structure> results = new ArrayList<Structure>(); for (Iterator<MimeDescriptor> it = descriptor.parts(); it.hasNext();) { final MimeDescriptor partDescriptor = it.next(); - results.add(new MimeDescriptorStructure(allowExtensions, - partDescriptor, builder)); + results.add(new MimeDescriptorStructure(allowExtensions, partDescriptor, builder)); } return results; } - private static List<String> createParameters(MimeDescriptor descriptor) - throws MailboxException { + private static List<String> createParameters(MimeDescriptor descriptor) throws MailboxException { final List<String> results = new ArrayList<String>(); - // TODO: consider revising this - for (Map.Entry<String, String> entry:descriptor.contentTypeParameters().entrySet()) { + // TODO: consider revising this + for (Map.Entry<String, String> entry : descriptor.contentTypeParameters().entrySet()) { results.add(entry.getKey()); results.add(entry.getValue()); } Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/PartialFetchBodyElement.java URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/PartialFetchBodyElement.java?rev=1092137&r1=1092136&r2=1092137&view=diff ============================================================================== --- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/PartialFetchBodyElement.java (original) +++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/PartialFetchBodyElement.java Thu Apr 14 11:21:11 2011 @@ -39,8 +39,7 @@ final class PartialFetchBodyElement impl private final String name; - public PartialFetchBodyElement(final BodyElement delegate, - final long firstOctet, final long numberOfOctets) { + public PartialFetchBodyElement(final BodyElement delegate, final long firstOctet, final long numberOfOctets) { super(); this.delegate = delegate; this.firstOctet = firstOctet; @@ -67,16 +66,15 @@ final class PartialFetchBodyElement impl } public void writeTo(WritableByteChannel channel) throws IOException { - PartialWritableByteChannel partialChannel = new PartialWritableByteChannel( - channel, firstOctet, size()); + PartialWritableByteChannel partialChannel = new PartialWritableByteChannel(channel, firstOctet, size()); delegate.writeTo(partialChannel); } public InputStream getInputStream() throws IOException { return new LimitingInputStream(delegate.getInputStream(), firstOctet, size()); } - - private final class LimitingInputStream extends FilterInputStream { + + private final class LimitingInputStream extends FilterInputStream { private long pos = 0; private long length; private long offset; @@ -84,20 +82,23 @@ final class PartialFetchBodyElement impl public LimitingInputStream(InputStream in, long offset, long length) { super(in); this.length = length; - this.offset = offset; + this.offset = offset; } - + /** - * Check if the offset was reached. If not move the wrapped {@link InputStream} to the needed offset + * Check if the offset was reached. If not move the wrapped + * {@link InputStream} to the needed offset + * * @throws IOException */ private void checkOffset() throws IOException { if (offset > -1) { - // first try to skip on the InputStream as it is mostly faster the calling read in a loop + // first try to skip on the InputStream as it is mostly faster + // the calling read in a loop try { offset -= in.skip(offset); } catch (IOException e) { - // maybe because skip is not supported + // maybe because skip is not supported } while (offset > 0) { // consume the stream till we reach the offset @@ -107,9 +108,10 @@ final class PartialFetchBodyElement impl offset = -1; } } - + /* * (non-Javadoc) + * * @see java.io.FilterInputStream#read() */ public int read() throws IOException { @@ -123,6 +125,7 @@ final class PartialFetchBodyElement impl /* * (non-Javadoc) + * * @see java.io.FilterInputStream#read(byte[]) */ public int read(byte b[]) throws IOException { @@ -131,12 +134,13 @@ final class PartialFetchBodyElement impl /* * (non-Javadoc) + * * @see java.io.FilterInputStream#read(byte[], int, int) */ public int read(byte b[], int off, int len) throws IOException { checkOffset(); - if (pos >= length) { + if (pos >= length) { return -1; } @@ -147,11 +151,10 @@ final class PartialFetchBodyElement impl return super.read(b, off, readLimit); } - - int i = super.read(b, off, len); + int i = super.read(b, off, len); pos += i; return i; - + } /** @@ -163,10 +166,11 @@ final class PartialFetchBodyElement impl /* * (non-Javadoc) + * * @see java.io.FilterInputStream#available() */ public int available() throws IOException { - // Correctly calculate in available bytes + // Correctly calculate in available bytes. // See IMAP-295 checkOffset(); int i = in.available(); Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/PartialWritableByteChannel.java URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/PartialWritableByteChannel.java?rev=1092137&r1=1092136&r2=1092137&view=diff ============================================================================== --- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/PartialWritableByteChannel.java (original) +++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/PartialWritableByteChannel.java Thu Apr 14 11:21:11 2011 @@ -36,8 +36,7 @@ class PartialWritableByteChannel impleme private long bytesWritten; - public PartialWritableByteChannel(final WritableByteChannel delegate, - final long firstOctet, final long numberOfOctets) { + public PartialWritableByteChannel(final WritableByteChannel delegate, final long firstOctet, final long numberOfOctets) { super(); this.delegate = delegate; this.firstOctet = firstOctet; @@ -55,20 +54,17 @@ class PartialWritableByteChannel impleme } else { final int remainingBytesToIgnore = (int) bytesToIgnore; src.position(src.position() + remainingBytesToIgnore); - result = writeRemaining(src, numberOfOctets) - + remainingBytesToIgnore; + result = writeRemaining(src, numberOfOctets) + remainingBytesToIgnore; } } else { - final long bytesToWrite = numberOfOctets - bytesWritten - + firstOctet; + final long bytesToWrite = numberOfOctets - bytesWritten + firstOctet; result = writeRemaining(src, bytesToWrite); } bytesWritten += result; return result; } - private int writeRemaining(ByteBuffer src, final long bytesToWrite) - throws IOException { + private int writeRemaining(ByteBuffer src, final long bytesToWrite) throws IOException { final int remaining = src.remaining(); final int result; if (bytesToWrite <= 0) { Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/main/DefaultImapProcessorFactory.java URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/main/DefaultImapProcessorFactory.java?rev=1092137&r1=1092136&r2=1092137&view=diff ============================================================================== --- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/main/DefaultImapProcessorFactory.java (original) +++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/main/DefaultImapProcessorFactory.java Thu Apr 14 11:21:11 2011 @@ -42,23 +42,19 @@ public class DefaultImapProcessorFactory public static final ImapProcessor createDefaultProcessor(final MailboxManager mailboxManager, final SubscriptionManager subscriptionManager, int batchSize) { return createXListSupportingProcessor(mailboxManager, subscriptionManager, null, batchSize); } - + public static final ImapProcessor createXListSupportingProcessor(final MailboxManager mailboxManager, final SubscriptionManager subscriptionManager, MailboxTyper mailboxTyper) { - return createXListSupportingProcessor(mailboxManager, subscriptionManager, mailboxTyper, ImapConstants.DEFAULT_BATCH_SIZE); + return createXListSupportingProcessor(mailboxManager, subscriptionManager, mailboxTyper, ImapConstants.DEFAULT_BATCH_SIZE); } - + public static final ImapProcessor createXListSupportingProcessor(final MailboxManager mailboxManager, final SubscriptionManager subscriptionManager, MailboxTyper mailboxTyper, int batchSize) { final StatusResponseFactory statusResponseFactory = new UnpooledStatusResponseFactory(); - final UnknownRequestProcessor unknownRequestImapProcessor = new UnknownRequestProcessor( - statusResponseFactory); - final ImapProcessor imap4rev1Chain = DefaultProcessorChain - .createDefaultChain(unknownRequestImapProcessor, - mailboxManager, subscriptionManager, statusResponseFactory, mailboxTyper, batchSize); - final ImapProcessor result = new ImapResponseMessageProcessor( - imap4rev1Chain); + final UnknownRequestProcessor unknownRequestImapProcessor = new UnknownRequestProcessor(statusResponseFactory); + final ImapProcessor imap4rev1Chain = DefaultProcessorChain.createDefaultChain(unknownRequestImapProcessor, mailboxManager, subscriptionManager, statusResponseFactory, mailboxTyper, batchSize); + final ImapProcessor result = new ImapResponseMessageProcessor(imap4rev1Chain); return result; } - + private MailboxManager mailboxManager; public final MailboxManager getMailboxManager() { @@ -85,7 +81,7 @@ public class DefaultImapProcessorFactory public ImapProcessor buildImapProcessor() { return createDefaultProcessor(mailboxManager, subscriptionManager); } - + private MailboxTyper mailboxTyper; public MailboxTyper getMailboxTyper() { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
