diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/ServiceObject.java b/src/main/java/microsoft/exchange/webservices/data/core/service/ServiceObject.java index 2c4d87ccc..04405a637 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/ServiceObject.java +++ b/src/main/java/microsoft/exchange/webservices/data/core/service/ServiceObject.java @@ -232,6 +232,10 @@ protected ServiceObject(ExchangeService service) throws Exception { this.propertyBag = new PropertyBag(this); } + protected ServiceObject() { + this.propertyBag = new PropertyBag(this); + } + /** * Gets the schema associated with this type of object. * @@ -391,18 +395,23 @@ public void load() throws Exception { * @return The value of specified property in this instance. * @throws Exception the exception */ - public Object getObjectFromPropertyDefinition( - PropertyDefinitionBase propertyDefinition) throws Exception { - PropertyDefinition propDef = (PropertyDefinition) propertyDefinition; + public Object getObjectFromPropertyDefinition(PropertyDefinitionBase propertyDefinition) throws Exception { + OutParam propertyValue = new OutParam(); - if (propDef != null) { - return this.getPropertyBag().getObjectFromPropertyDefinition(propDef); - } else { - // E14:226103 -- Other subclasses of PropertyDefinitionBase are not supported. - throw new UnsupportedOperationException(String.format( - "This operation isn't supported for property definition type %s.", - propertyDefinition.getType().getName())); - } + if (propertyDefinition instanceof PropertyDefinition) { + return getPropertyBag().getObjectFromPropertyDefinition((PropertyDefinition) propertyDefinition); + } + + if (propertyDefinition instanceof ExtendedPropertyDefinition) { + if (this.tryGetExtendedProperty(Object.class, (ExtendedPropertyDefinition) propertyDefinition, propertyValue)) { + return propertyValue; + } + } + + // E14:226103 -- Other subclasses of PropertyDefinitionBase are not supported. + throw new UnsupportedOperationException(String.format( + "This operation isn't supported for property definition type %s.", + propertyDefinition.getType().getName())); } /** @@ -449,18 +458,19 @@ public boolean tryGetProperty(PropertyDefinitionBase propertyDefinition, OutPara * @return true, if successful * @throws Exception the exception */ - public boolean tryGetProperty(Class cls, PropertyDefinitionBase propertyDefinition, - OutParam propertyValue) throws Exception { + public boolean tryGetProperty(Class cls, PropertyDefinitionBase propertyDefinition, OutParam propertyValue) throws Exception { + if (propertyDefinition instanceof PropertyDefinition) { + return getPropertyBag().tryGetPropertyType(cls, (PropertyDefinition) propertyDefinition, propertyValue); + } - PropertyDefinition propDef = (PropertyDefinition) propertyDefinition; - if (propDef != null) { - return this.getPropertyBag().tryGetPropertyType(cls, propDef, propertyValue); - } else { - // E14:226103 -- Other subclasses of PropertyDefinitionBase are not supported. - throw new UnsupportedOperationException(String.format( - "This operation isn't supported for property definition type %s.", - propertyDefinition.getType().getName())); + if (propertyDefinition instanceof ExtendedPropertyDefinition) { + return this.tryGetExtendedProperty(cls, (ExtendedPropertyDefinition) propertyDefinition, propertyValue); } + + // E14:226103 -- Other subclasses of PropertyDefinitionBase are not supported. + throw new UnsupportedOperationException(String.format( + "This operation isn't supported for property definition type %s.", + propertyDefinition.getType().getName())); } /** diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/folder/Folder.java b/src/main/java/microsoft/exchange/webservices/data/core/service/folder/Folder.java index 77849c1f2..996fbd52a 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/folder/Folder.java +++ b/src/main/java/microsoft/exchange/webservices/data/core/service/folder/Folder.java @@ -60,6 +60,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import java.io.Serializable; import java.util.ArrayList; import java.util.EnumSet; @@ -67,8 +68,9 @@ * Represents a generic folder. */ @ServiceObjectDefinition(xmlElementName = XmlElementNames.Folder) -public class Folder extends ServiceObject { +public class Folder extends ServiceObject implements Serializable { + private static final long serialVersionUID = -1821642181310536327L; private static final Log LOG = LogFactory.getLog(Folder.class); /**