Fixes from audit

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1200 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-07-19 09:22:42 +00:00
parent 179a5304d6
commit 2c63a6b72a
12 changed files with 44 additions and 43 deletions

View File

@ -1421,9 +1421,8 @@ public class CaldavConnection extends AbstractConnection {
* *
* @param subFolder sub folder path * @param subFolder sub folder path
* @return folder path * @return folder path
* @throws IOException on error
*/ */
public String getFolderPath(String subFolder) throws IOException { public String getFolderPath(String subFolder) {
int endIndex; int endIndex;
if (isFolder()) { if (isFolder()) {
endIndex = getPathLength(); endIndex = getPathLength();

View File

@ -27,7 +27,7 @@ import java.io.PushbackInputStream;
* A line with a single dot means end of stream * A line with a single dot means end of stream
*/ */
public class DoubleDotInputStream extends PushbackInputStream { public class DoubleDotInputStream extends PushbackInputStream {
int[] buffer = new int[4]; final int[] buffer = new int[4];
int index = -1; int index = -1;
/** /**
@ -40,7 +40,6 @@ public class DoubleDotInputStream extends PushbackInputStream {
/** /**
* Push current byte to buffer and read next byte. * Push current byte to buffer and read next byte.
* *
* @param currentByte current byte
* @return next byte * @return next byte
* @throws IOException on error * @throws IOException on error
*/ */

View File

@ -631,9 +631,9 @@ public abstract class ExchangeSession {
* Attribute condition. * Attribute condition.
*/ */
public abstract static class AttributeCondition implements Condition { public abstract static class AttributeCondition implements Condition {
protected String attributeName; protected final String attributeName;
protected Operator operator; protected final Operator operator;
protected String value; protected final String value;
protected AttributeCondition(String attributeName, Operator operator, String value) { protected AttributeCondition(String attributeName, Operator operator, String value) {
this.attributeName = attributeName; this.attributeName = attributeName;
@ -650,8 +650,8 @@ public abstract class ExchangeSession {
* Multiple condition. * Multiple condition.
*/ */
public abstract static class MultiCondition implements Condition { public abstract static class MultiCondition implements Condition {
protected Operator operator; protected final Operator operator;
protected List<Condition> conditions; protected final List<Condition> conditions;
protected MultiCondition(Operator operator, Condition... conditions) { protected MultiCondition(Operator operator, Condition... conditions) {
this.operator = operator; this.operator = operator;
@ -690,7 +690,7 @@ public abstract class ExchangeSession {
* Not condition. * Not condition.
*/ */
public abstract static class NotCondition implements Condition { public abstract static class NotCondition implements Condition {
protected Condition condition; protected final Condition condition;
protected NotCondition(Condition condition) { protected NotCondition(Condition condition) {
this.condition = condition; this.condition = condition;
@ -706,8 +706,8 @@ public abstract class ExchangeSession {
* Single search filter condition. * Single search filter condition.
*/ */
public abstract static class MonoCondition implements Condition { public abstract static class MonoCondition implements Condition {
protected String attributeName; protected final String attributeName;
protected Operator operator; protected final Operator operator;
protected MonoCondition(String attributeName, Operator operator) { protected MonoCondition(String attributeName, Operator operator) {
this.attributeName = attributeName; this.attributeName = attributeName;

View File

@ -589,7 +589,7 @@ public class DavExchangeSession extends ExchangeSession {
super(folderPath, itemName, properties, etag, noneMatch); super(folderPath, itemName, properties, etag, noneMatch);
} }
protected List<DavConstants> buildProperties() throws IOException { protected List<DavConstants> buildProperties() {
ArrayList<DavConstants> list = new ArrayList<DavConstants>(); ArrayList<DavConstants> list = new ArrayList<DavConstants>();
for (Map.Entry<String, String> entry : entrySet()) { for (Map.Entry<String, String> entry : entrySet()) {
String key = entry.getKey(); String key = entry.getKey();

View File

@ -484,6 +484,11 @@ public abstract class EWSMethod extends PostMethod {
return result; return result;
} }
/**
* Get file attachment by file name
* @param attachmentName attachment name
* @return attachment
*/
public FileAttachment getAttachmentByName(String attachmentName) { public FileAttachment getAttachmentByName(String attachmentName) {
FileAttachment result = null; FileAttachment result = null;
if (attachments != null) { if (attachments != null) {
@ -600,8 +605,8 @@ public abstract class EWSMethod extends PostMethod {
addExtendedPropertyValue(reader, responseItem); addExtendedPropertyValue(reader, responseItem);
} else if (tagLocalName.endsWith("MimeContent")) { } else if (tagLocalName.endsWith("MimeContent")) {
handleMimeContent(reader, responseItem); handleMimeContent(reader, responseItem);
} else if (tagLocalName.equals("Attachments")) { } else if ("Attachments".equals(tagLocalName)) {
responseItem.attachments = handleAttachments(reader, responseItem); responseItem.attachments = handleAttachments(reader);
} else { } else {
if (tagLocalName.endsWith("Id")) { if (tagLocalName.endsWith("Id")) {
value = getAttributeValue(reader, "Id"); value = getAttributeValue(reader, "Id");
@ -620,31 +625,31 @@ public abstract class EWSMethod extends PostMethod {
return responseItem; return responseItem;
} }
protected List<FileAttachment> handleAttachments(XMLStreamReader reader, Item responseItem) throws XMLStreamException { protected List<FileAttachment> handleAttachments(XMLStreamReader reader) throws XMLStreamException {
List<FileAttachment> attachments = new ArrayList<FileAttachment>(); List<FileAttachment> attachments = new ArrayList<FileAttachment>();
while (reader.hasNext() && !(isEndTag(reader, "Attachments"))) { while (reader.hasNext() && !(isEndTag(reader, "Attachments"))) {
int event = reader.next(); int event = reader.next();
if (event == XMLStreamConstants.START_ELEMENT) { if (event == XMLStreamConstants.START_ELEMENT) {
String tagLocalName = reader.getLocalName(); String tagLocalName = reader.getLocalName();
if (tagLocalName.equals("FileAttachment")) { if ("FileAttachment".equals(tagLocalName)) {
attachments.add(handleFileAttachment(reader, responseItem)); attachments.add(handleFileAttachment(reader));
} }
} }
} }
return attachments; return attachments;
} }
protected FileAttachment handleFileAttachment(XMLStreamReader reader, Item responseItem) throws XMLStreamException { protected FileAttachment handleFileAttachment(XMLStreamReader reader) throws XMLStreamException {
FileAttachment fileAttachment = new FileAttachment(); FileAttachment fileAttachment = new FileAttachment();
while (reader.hasNext() && !(isEndTag(reader, "FileAttachment"))) { while (reader.hasNext() && !(isEndTag(reader, "FileAttachment"))) {
int event = reader.next(); int event = reader.next();
if (event == XMLStreamConstants.START_ELEMENT) { if (event == XMLStreamConstants.START_ELEMENT) {
String tagLocalName = reader.getLocalName(); String tagLocalName = reader.getLocalName();
if (tagLocalName.equals("AttachmentId")) { if ("AttachmentId".equals(tagLocalName)) {
fileAttachment.attachmentId = getAttributeValue(reader, "Id"); fileAttachment.attachmentId = getAttributeValue(reader, "Id");
} else if (tagLocalName.equals("Name")) { } else if ("Name".equals(tagLocalName)) {
fileAttachment.name = getTagContent(reader); fileAttachment.name = getTagContent(reader);
} else if (tagLocalName.equals("ContentType")) { } else if ("ContentType".equals(tagLocalName)) {
fileAttachment.contentType = getTagContent(reader); 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++) { for (int i = 0; i < reader.getAttributeCount(); i++) {
if (attributeName.equals(reader.getAttributeLocalName(i))) { if (attributeName.equals(reader.getAttributeLocalName(i))) {
return reader.getAttributeValue(i); return reader.getAttributeValue(i);

View File

@ -27,7 +27,6 @@ import org.apache.commons.codec.binary.Base64;
import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.methods.HeadMethod; import org.apache.commons.httpclient.methods.HeadMethod;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
@ -52,8 +51,8 @@ public class EwsExchangeSession extends ExchangeSession {
} }
protected static class FolderPath { protected static class FolderPath {
protected String parentPath; protected final String parentPath;
protected String folderName; protected final String folderName;
protected FolderPath(String folderPath) { protected FolderPath(String folderPath) {
int slashIndex = folderPath.lastIndexOf('/'); int slashIndex = folderPath.lastIndexOf('/');
@ -235,7 +234,7 @@ public class EwsExchangeSession extends ExchangeSession {
return getItemMethod.getMimeContent(); return getItemMethod.getMimeContent();
} }
protected Message buildMessage(EWSMethod.Item response) throws URIException, DavMailException { protected Message buildMessage(EWSMethod.Item response) throws DavMailException {
Message message = new Message(); Message message = new Message();
// get item id // get item id
@ -395,7 +394,7 @@ public class EwsExchangeSession extends ExchangeSession {
} }
protected static class IsNullCondition implements ExchangeSession.Condition, SearchExpression { protected static class IsNullCondition implements ExchangeSession.Condition, SearchExpression {
protected String attributeName; protected final String attributeName;
protected IsNullCondition(String attributeName) { protected IsNullCondition(String attributeName) {
this.attributeName = attributeName; this.attributeName = attributeName;
@ -647,7 +646,7 @@ public class EwsExchangeSession extends ExchangeSession {
// item id // item id
ItemId itemId; ItemId itemId;
protected Contact(EWSMethod.Item response) throws URIException, DavMailException { protected Contact(EWSMethod.Item response) throws DavMailException {
itemId = new ItemId(response); itemId = new ItemId(response);
permanentUrl = response.get(Field.get("permanenturl").getResponseName()); permanentUrl = response.get(Field.get("permanenturl").getResponseName());
@ -672,7 +671,7 @@ public class EwsExchangeSession extends ExchangeSession {
super(folderPath, itemName, properties, etag, noneMatch); super(folderPath, itemName, properties, etag, noneMatch);
} }
protected Set<FieldUpdate> buildProperties() throws IOException { protected Set<FieldUpdate> buildProperties() {
HashSet<FieldUpdate> list = new HashSet<FieldUpdate>(); HashSet<FieldUpdate> list = new HashSet<FieldUpdate>();
for (Map.Entry<String, String> entry : entrySet()) { for (Map.Entry<String, String> entry : entrySet()) {
if ("photo".equals(entry.getKey())) { if ("photo".equals(entry.getKey())) {
@ -793,7 +792,7 @@ public class EwsExchangeSession extends ExchangeSession {
// item id // item id
ItemId itemId; ItemId itemId;
protected Event(EWSMethod.Item response) throws URIException { protected Event(EWSMethod.Item response) {
itemId = new ItemId(response); itemId = new ItemId(response);
permanentUrl = response.get(Field.get("permanenturl").getResponseName()); permanentUrl = response.get(Field.get("permanenturl").getResponseName());

View File

@ -38,7 +38,7 @@ public class ExtendedFieldURI implements FieldURI {
protected String propertySetId; protected String propertySetId;
protected String propertyName; protected String propertyName;
protected int propertyId; protected int propertyId;
protected PropertyType propertyType; protected final PropertyType propertyType;
/** /**
* Create extended field uri. * Create extended field uri.

View File

@ -25,8 +25,8 @@ import java.io.Writer;
* Field update * Field update
*/ */
public class FieldUpdate { public class FieldUpdate {
FieldURI fieldURI; final FieldURI fieldURI;
String value; final String value;
/** /**
* Create field update with value. * Create field update with value.

View File

@ -22,8 +22,8 @@ package davmail.exchange.ews;
* Indexed FieldURI * Indexed FieldURI
*/ */
public class IndexedFieldURI implements FieldURI { public class IndexedFieldURI implements FieldURI {
protected String fieldURI; protected final String fieldURI;
protected String fieldIndex; protected final String fieldIndex;
/** /**
* Create indexed field uri. * Create indexed field uri.

View File

@ -26,7 +26,7 @@ import java.io.Writer;
*/ */
public class ItemId { public class ItemId {
protected final String id; protected final String id;
protected String changeKey; protected final String changeKey;
/** /**
* Create Item id. * Create Item id.

View File

@ -28,9 +28,9 @@ public class TwoOperandExpression implements SearchExpression {
IsEqualTo, IsNotEqualTo, IsGreaterThan, IsGreaterThanOrEqualTo, IsLessThan, IsLessThanOrEqualTo IsEqualTo, IsNotEqualTo, IsGreaterThan, IsGreaterThanOrEqualTo, IsLessThan, IsLessThanOrEqualTo
} }
protected Operator operator; protected final Operator operator;
protected FieldURI fieldURI; protected final FieldURI fieldURI;
protected String value; protected final String value;
/** /**
* Create two operand expression. * Create two operand expression.

View File

@ -21,7 +21,6 @@ package davmail;
import davmail.exchange.ExchangeSession; import davmail.exchange.ExchangeSession;
import davmail.http.DavGatewaySSLProtocolSocketFactory; import davmail.http.DavGatewaySSLProtocolSocketFactory;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.log4j.Level;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -65,9 +64,9 @@ public class AbstractDavMailTestCase extends TestCase {
Settings.setProperty("davmail.server", "true"); Settings.setProperty("davmail.server", "true");
// enable WIRE debug log // enable WIRE debug log
// Settings.setLoggingLevel("httpclient.wire", Level.DEBUG); //Settings.setLoggingLevel("httpclient.wire", Level.DEBUG);
// enable EWS support // enable EWS support
Settings.setProperty("davmail.enableEws", "true"); Settings.setProperty("davmail.enableEws", "false");
} }
} }