1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-14 03:32:22 -05:00

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
* @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();

View File

@ -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
*/

View File

@ -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<Condition> conditions;
protected final Operator operator;
protected final List<Condition> 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;

View File

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

View File

@ -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<FileAttachment> handleAttachments(XMLStreamReader reader, Item responseItem) throws XMLStreamException {
protected List<FileAttachment> handleAttachments(XMLStreamReader reader) throws XMLStreamException {
List<FileAttachment> attachments = new ArrayList<FileAttachment>();
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);

View File

@ -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<FieldUpdate> buildProperties() throws IOException {
protected Set<FieldUpdate> buildProperties() {
HashSet<FieldUpdate> list = new HashSet<FieldUpdate>();
for (Map.Entry<String, String> 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());

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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");
}
}