-
Notifications
You must be signed in to change notification settings - Fork 566
Fix for internalGetAttachments, ExtendedProperty, MapiTypeConverterMapEntry #80
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,8 +17,6 @@ | |
| import java.util.List; | ||
| import java.util.Locale; | ||
| import java.util.TimeZone; | ||
| import java.util.concurrent.FutureTask; | ||
|
|
||
| import org.w3c.dom.Document; | ||
| import org.w3c.dom.Node; | ||
|
|
||
|
|
@@ -1552,10 +1550,13 @@ private ServiceResponseCollection<GetAttachmentResponse> internalGetAttachments( | |
| } | ||
| request.setBodyType(bodyType); | ||
|
|
||
| if (additionalProperties != null) | ||
| { | ||
| List propsArray = new ArrayList(); | ||
| propsArray.add(additionalProperties); | ||
|
|
||
| if (additionalProperties != null) { | ||
| for (PropertyDefinitionBase propertyDefinitionBase : additionalProperties) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use addAll() and Arrays.asList() instead of manually looping through and populating each element. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those methods cannot be used with Iterable<> as far as I know. The loop is fine, but add the properties from additionalProperties directly to the request instead of using an intermediary list which winds up populating the request anyway. |
||
| { | ||
| propsArray.add(propertyDefinitionBase); | ||
| } | ||
| request.getAdditionalProperties().addAll(propsArray); | ||
| } | ||
|
|
||
|
|
@@ -4460,3 +4461,4 @@ public boolean autodiscoverRedirectionUrlValidationCallback( | |
| } | ||
|
|
||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,10 +6,10 @@ | |
| **************************************************************************/ | ||
| package microsoft.exchange.webservices.data; | ||
|
|
||
| import java.lang.reflect.Array; | ||
| import java.text.DateFormat; | ||
| import java.text.ParseException; | ||
| import java.text.SimpleDateFormat; | ||
| import java.util.ArrayList; | ||
| import java.util.Date; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
@@ -190,29 +190,27 @@ protected Object ConvertToValueOrDefault(String stringValue) throws ServiceXmlDe | |
| * @throws microsoft.exchange.webservices.data.ArgumentException | ||
| * the argument exception | ||
| */ | ||
| private void validateValueAsArray(Object value) throws ArgumentException { | ||
|
|
||
| Array array = null; | ||
| if(value instanceof Array) | ||
| { | ||
| array = (Array) value; | ||
| } | ||
|
|
||
| if (array == null) { | ||
| throw new ArgumentException(String.format( | ||
| Strings.IncompatibleTypeForArray, value.getClass(), this | ||
| .getType())); | ||
| private void validateValueAsArray(Object value) throws ArgumentException | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like a good candidate for unit tests. |
||
| { | ||
| ArrayList array = null; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First thing is to handle value itself being null. Otherwise first reference of value later will throw. |
||
| if (value instanceof ArrayList) | ||
| { | ||
| array = (ArrayList) value; | ||
| } | ||
| if (array == null) | ||
| { | ||
| throw new ArgumentException(String.format(Strings.IncompatibleTypeForArray, value.getClass(), this.getType())); | ||
| } | ||
| else if (array.isEmpty()) | ||
| { | ||
| throw new ArgumentException(Strings.ArrayMustHaveAtLeastOneElement); | ||
| } | ||
| else if (array.get(0).getClass() != this.getType()) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we check the type for all the elements? |
||
| { | ||
| throw new ArgumentException(String.format(Strings.IncompatibleTypeForArray, value.getClass(), this.getType())); | ||
| } | ||
| } | ||
|
|
||
| } else if (getDim(array) != 1) { | ||
| throw new ArgumentException(Strings.ArrayMustHaveSingleDimension); | ||
| } else if (Array.getLength(array) == 0) { | ||
| throw new ArgumentException(Strings.ArrayMustHaveAtLeastOneElement); | ||
| } else if (array.getClass().getComponentType() != this.getType()) { | ||
| throw new ArgumentException(String.format( | ||
| Strings.IncompatibleTypeForArray, value.getClass(), this | ||
| .getType())); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Gets the dim. If `array' is an array object returns its dimensions; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix indentation.