diff --git a/src/java/davmail/caldav/CaldavConnection.java b/src/java/davmail/caldav/CaldavConnection.java index bd02ad66..9a66197c 100644 --- a/src/java/davmail/caldav/CaldavConnection.java +++ b/src/java/davmail/caldav/CaldavConnection.java @@ -1421,9 +1421,8 @@ public class CaldavConnection extends AbstractConnection { * * @param subFolder sub folder path * @return folder path - * @throws IOException on error */ - public String getFolderPath(String subFolder) throws IOException { + public String getFolderPath(String subFolder) { int endIndex; if (isFolder()) { endIndex = getPathLength(); diff --git a/src/java/davmail/exchange/DoubleDotInputStream.java b/src/java/davmail/exchange/DoubleDotInputStream.java index d81d7be7..431ce136 100644 --- a/src/java/davmail/exchange/DoubleDotInputStream.java +++ b/src/java/davmail/exchange/DoubleDotInputStream.java @@ -27,7 +27,7 @@ import java.io.PushbackInputStream; * A line with a single dot means end of stream */ public class DoubleDotInputStream extends PushbackInputStream { - int[] buffer = new int[4]; + final int[] buffer = new int[4]; int index = -1; /** @@ -40,7 +40,6 @@ public class DoubleDotInputStream extends PushbackInputStream { /** * Push current byte to buffer and read next byte. * - * @param currentByte current byte * @return next byte * @throws IOException on error */ diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index e99be5d0..3b1365a0 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -631,9 +631,9 @@ public abstract class ExchangeSession { * Attribute condition. */ public abstract static class AttributeCondition implements Condition { - protected String attributeName; - protected Operator operator; - protected String value; + protected final String attributeName; + protected final Operator operator; + protected final String value; protected AttributeCondition(String attributeName, Operator operator, String value) { this.attributeName = attributeName; @@ -650,8 +650,8 @@ public abstract class ExchangeSession { * Multiple condition. */ public abstract static class MultiCondition implements Condition { - protected Operator operator; - protected List conditions; + protected final Operator operator; + protected final List conditions; protected MultiCondition(Operator operator, Condition... conditions) { this.operator = operator; @@ -690,7 +690,7 @@ public abstract class ExchangeSession { * Not condition. */ public abstract static class NotCondition implements Condition { - protected Condition condition; + protected final Condition condition; protected NotCondition(Condition condition) { this.condition = condition; @@ -706,8 +706,8 @@ public abstract class ExchangeSession { * Single search filter condition. */ public abstract static class MonoCondition implements Condition { - protected String attributeName; - protected Operator operator; + protected final String attributeName; + protected final Operator operator; protected MonoCondition(String attributeName, Operator operator) { this.attributeName = attributeName; diff --git a/src/java/davmail/exchange/dav/DavExchangeSession.java b/src/java/davmail/exchange/dav/DavExchangeSession.java index 61ac223c..6cda8a00 100644 --- a/src/java/davmail/exchange/dav/DavExchangeSession.java +++ b/src/java/davmail/exchange/dav/DavExchangeSession.java @@ -589,7 +589,7 @@ public class DavExchangeSession extends ExchangeSession { super(folderPath, itemName, properties, etag, noneMatch); } - protected List buildProperties() throws IOException { + protected List buildProperties() { ArrayList list = new ArrayList(); for (Map.Entry entry : entrySet()) { String key = entry.getKey(); diff --git a/src/java/davmail/exchange/ews/EWSMethod.java b/src/java/davmail/exchange/ews/EWSMethod.java index e54e99c0..adf230be 100644 --- a/src/java/davmail/exchange/ews/EWSMethod.java +++ b/src/java/davmail/exchange/ews/EWSMethod.java @@ -484,6 +484,11 @@ public abstract class EWSMethod extends PostMethod { return result; } + /** + * Get file attachment by file name + * @param attachmentName attachment name + * @return attachment + */ public FileAttachment getAttachmentByName(String attachmentName) { FileAttachment result = null; if (attachments != null) { @@ -600,8 +605,8 @@ public abstract class EWSMethod extends PostMethod { addExtendedPropertyValue(reader, responseItem); } else if (tagLocalName.endsWith("MimeContent")) { handleMimeContent(reader, responseItem); - } else if (tagLocalName.equals("Attachments")) { - responseItem.attachments = handleAttachments(reader, responseItem); + } else if ("Attachments".equals(tagLocalName)) { + responseItem.attachments = handleAttachments(reader); } else { if (tagLocalName.endsWith("Id")) { value = getAttributeValue(reader, "Id"); @@ -620,31 +625,31 @@ public abstract class EWSMethod extends PostMethod { return responseItem; } - protected List handleAttachments(XMLStreamReader reader, Item responseItem) throws XMLStreamException { + protected List handleAttachments(XMLStreamReader reader) throws XMLStreamException { List attachments = new ArrayList(); while (reader.hasNext() && !(isEndTag(reader, "Attachments"))) { int event = reader.next(); if (event == XMLStreamConstants.START_ELEMENT) { String tagLocalName = reader.getLocalName(); - if (tagLocalName.equals("FileAttachment")) { - attachments.add(handleFileAttachment(reader, responseItem)); + if ("FileAttachment".equals(tagLocalName)) { + attachments.add(handleFileAttachment(reader)); } } } return attachments; } - protected FileAttachment handleFileAttachment(XMLStreamReader reader, Item responseItem) throws XMLStreamException { + protected FileAttachment handleFileAttachment(XMLStreamReader reader) throws XMLStreamException { FileAttachment fileAttachment = new FileAttachment(); while (reader.hasNext() && !(isEndTag(reader, "FileAttachment"))) { int event = reader.next(); if (event == XMLStreamConstants.START_ELEMENT) { String tagLocalName = reader.getLocalName(); - if (tagLocalName.equals("AttachmentId")) { + if ("AttachmentId".equals(tagLocalName)) { fileAttachment.attachmentId = getAttributeValue(reader, "Id"); - } else if (tagLocalName.equals("Name")) { + } else if ("Name".equals(tagLocalName)) { fileAttachment.name = getTagContent(reader); - } else if (tagLocalName.equals("ContentType")) { + } else if ("ContentType".equals(tagLocalName)) { fileAttachment.contentType = getTagContent(reader); } } @@ -713,7 +718,7 @@ public abstract class EWSMethod extends PostMethod { } } - protected String getAttributeValue(XMLStreamReader reader, String attributeName) throws XMLStreamException { + protected String getAttributeValue(XMLStreamReader reader, String attributeName) { for (int i = 0; i < reader.getAttributeCount(); i++) { if (attributeName.equals(reader.getAttributeLocalName(i))) { return reader.getAttributeValue(i); diff --git a/src/java/davmail/exchange/ews/EwsExchangeSession.java b/src/java/davmail/exchange/ews/EwsExchangeSession.java index fad2e7f8..8807976a 100644 --- a/src/java/davmail/exchange/ews/EwsExchangeSession.java +++ b/src/java/davmail/exchange/ews/EwsExchangeSession.java @@ -27,7 +27,6 @@ import org.apache.commons.codec.binary.Base64; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.URIException; import org.apache.commons.httpclient.methods.HeadMethod; import javax.imageio.ImageIO; @@ -52,8 +51,8 @@ public class EwsExchangeSession extends ExchangeSession { } protected static class FolderPath { - protected String parentPath; - protected String folderName; + protected final String parentPath; + protected final String folderName; protected FolderPath(String folderPath) { int slashIndex = folderPath.lastIndexOf('/'); @@ -235,7 +234,7 @@ public class EwsExchangeSession extends ExchangeSession { return getItemMethod.getMimeContent(); } - protected Message buildMessage(EWSMethod.Item response) throws URIException, DavMailException { + protected Message buildMessage(EWSMethod.Item response) throws DavMailException { Message message = new Message(); // get item id @@ -395,7 +394,7 @@ public class EwsExchangeSession extends ExchangeSession { } protected static class IsNullCondition implements ExchangeSession.Condition, SearchExpression { - protected String attributeName; + protected final String attributeName; protected IsNullCondition(String attributeName) { this.attributeName = attributeName; @@ -647,7 +646,7 @@ public class EwsExchangeSession extends ExchangeSession { // item id ItemId itemId; - protected Contact(EWSMethod.Item response) throws URIException, DavMailException { + protected Contact(EWSMethod.Item response) throws DavMailException { itemId = new ItemId(response); permanentUrl = response.get(Field.get("permanenturl").getResponseName()); @@ -672,7 +671,7 @@ public class EwsExchangeSession extends ExchangeSession { super(folderPath, itemName, properties, etag, noneMatch); } - protected Set buildProperties() throws IOException { + protected Set buildProperties() { HashSet list = new HashSet(); for (Map.Entry entry : entrySet()) { if ("photo".equals(entry.getKey())) { @@ -793,7 +792,7 @@ public class EwsExchangeSession extends ExchangeSession { // item id ItemId itemId; - protected Event(EWSMethod.Item response) throws URIException { + protected Event(EWSMethod.Item response) { itemId = new ItemId(response); permanentUrl = response.get(Field.get("permanenturl").getResponseName()); diff --git a/src/java/davmail/exchange/ews/ExtendedFieldURI.java b/src/java/davmail/exchange/ews/ExtendedFieldURI.java index 994d3e5e..3d7f81e2 100644 --- a/src/java/davmail/exchange/ews/ExtendedFieldURI.java +++ b/src/java/davmail/exchange/ews/ExtendedFieldURI.java @@ -38,7 +38,7 @@ public class ExtendedFieldURI implements FieldURI { protected String propertySetId; protected String propertyName; protected int propertyId; - protected PropertyType propertyType; + protected final PropertyType propertyType; /** * Create extended field uri. diff --git a/src/java/davmail/exchange/ews/FieldUpdate.java b/src/java/davmail/exchange/ews/FieldUpdate.java index 8148bb76..f50a0022 100644 --- a/src/java/davmail/exchange/ews/FieldUpdate.java +++ b/src/java/davmail/exchange/ews/FieldUpdate.java @@ -25,8 +25,8 @@ import java.io.Writer; * Field update */ public class FieldUpdate { - FieldURI fieldURI; - String value; + final FieldURI fieldURI; + final String value; /** * Create field update with value. diff --git a/src/java/davmail/exchange/ews/IndexedFieldURI.java b/src/java/davmail/exchange/ews/IndexedFieldURI.java index e5e6fadb..7d47e4a8 100644 --- a/src/java/davmail/exchange/ews/IndexedFieldURI.java +++ b/src/java/davmail/exchange/ews/IndexedFieldURI.java @@ -22,8 +22,8 @@ package davmail.exchange.ews; * Indexed FieldURI */ public class IndexedFieldURI implements FieldURI { - protected String fieldURI; - protected String fieldIndex; + protected final String fieldURI; + protected final String fieldIndex; /** * Create indexed field uri. diff --git a/src/java/davmail/exchange/ews/ItemId.java b/src/java/davmail/exchange/ews/ItemId.java index 2779e220..9a013c0b 100644 --- a/src/java/davmail/exchange/ews/ItemId.java +++ b/src/java/davmail/exchange/ews/ItemId.java @@ -26,7 +26,7 @@ import java.io.Writer; */ public class ItemId { protected final String id; - protected String changeKey; + protected final String changeKey; /** * Create Item id. diff --git a/src/java/davmail/exchange/ews/TwoOperandExpression.java b/src/java/davmail/exchange/ews/TwoOperandExpression.java index 19307deb..5231c338 100644 --- a/src/java/davmail/exchange/ews/TwoOperandExpression.java +++ b/src/java/davmail/exchange/ews/TwoOperandExpression.java @@ -28,9 +28,9 @@ public class TwoOperandExpression implements SearchExpression { IsEqualTo, IsNotEqualTo, IsGreaterThan, IsGreaterThanOrEqualTo, IsLessThan, IsLessThanOrEqualTo } - protected Operator operator; - protected FieldURI fieldURI; - protected String value; + protected final Operator operator; + protected final FieldURI fieldURI; + protected final String value; /** * Create two operand expression. diff --git a/src/test/davmail/AbstractDavMailTestCase.java b/src/test/davmail/AbstractDavMailTestCase.java index 7a9f2da9..96331336 100644 --- a/src/test/davmail/AbstractDavMailTestCase.java +++ b/src/test/davmail/AbstractDavMailTestCase.java @@ -21,7 +21,6 @@ package davmail; import davmail.exchange.ExchangeSession; import davmail.http.DavGatewaySSLProtocolSocketFactory; import junit.framework.TestCase; -import org.apache.log4j.Level; import java.io.File; import java.io.IOException; @@ -65,9 +64,9 @@ public class AbstractDavMailTestCase extends TestCase { Settings.setProperty("davmail.server", "true"); // enable WIRE debug log - // Settings.setLoggingLevel("httpclient.wire", Level.DEBUG); + //Settings.setLoggingLevel("httpclient.wire", Level.DEBUG); // enable EWS support - Settings.setProperty("davmail.enableEws", "true"); + Settings.setProperty("davmail.enableEws", "false"); } }