microsoft.exchange.webservices.data.CreateRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of exchange-ws-api Show documentation
Show all versions of exchange-ws-api Show documentation
The source came from http://archive.msdn.microsoft.com/ewsjavaapi
Support for Maven has been added.
The newest version!
/**************************************************************************
* copyright file="CreateRequest.java" company="Microsoft"
* Copyright (c) Microsoft Corporation. All rights reserved.
*
* Defines the CreateRequest.java.
**************************************************************************/
package microsoft.exchange.webservices.data;
import java.util.Collection;
/***
* Represents an abstract Create request.
*
* @param
* The type of the service object.
* @param
* The type of the response.
*/
abstract class CreateRequest
extends MultiResponseServiceRequest {
/** The parent folder id. */
private FolderId parentFolderId;
/** The objects. */
private Collection objects;
/**
* * Initializes a new instance.
*
* @param service
* The service.
* @param errorHandlingMode
* Indicates how errors should be handled.
* @throws Exception
*/
protected CreateRequest(ExchangeService service,
ServiceErrorHandling errorHandlingMode)
throws Exception {
super(service, errorHandlingMode);
}
/**
* Validates the request.
*
* @throws Exception
* the exception
*/
@Override
protected void validate() throws Exception {
super.validate();
if (this.getParentFolderId() != null) {
this.getParentFolderId().validate(
this.getService().getRequestedServerVersion());
}
}
/**
* Gets the expected response message count.
*
* @return the expected response message count
*/
@Override
protected int getExpectedResponseMessageCount() {
return EwsUtilities.getEnumeratedObjectCount(this.objects.iterator());
}
/***
* Gets the name of the parent folder XML element.
*
* @return The name of the parent folder XML element.
*/
protected abstract String getParentFolderXmlElementName();
/***
* Gets the name of the object collection XML element.
*
* @return The name of the object collection XML element.
*/
protected abstract String getObjectCollectionXmlElementName();
/*
* (non-Javadoc)
*
* @see
* microsoft.exchange.webservices.ServiceRequestBase#writeElementsToXml(
* microsoft.exchange.webservices.EwsServiceXmlWriter)
*/
@Override
protected void writeElementsToXml(EwsServiceXmlWriter writer)
throws Exception {
if (this.parentFolderId != null) {
writer.writeStartElement(XmlNamespace.Messages, this
.getParentFolderXmlElementName());
this.getParentFolderId().writeToXml(writer);
writer.writeEndElement();
}
writer.writeStartElement(XmlNamespace.Messages, this
.getObjectCollectionXmlElementName());
if (null != this.objects) {
for (ServiceObject obj : this.objects) {
obj.writeToXml(writer);
}
}
writer.writeEndElement();
}
/**
* * Gets the service objects.
*
* @return Iterator
*/
protected Iterable getObjects() {
return this.objects;
}
/***
* Sets the service objects.
*
* @param value
* Iterator
*/
protected void setObjects(Collection value) {
this.objects = value;
}
/***
* Gets the parent folder id.
*
* @return FolderId.
*/
public FolderId getParentFolderId() {
return this.parentFolderId;
}
/***
* Sets the parent folder id.
*
* @param value
* FolderId.
*/
public void setParentFolderId(FolderId value) {
this.parentFolderId = value;
}
}