Java源码示例:microsoft.exchange.webservices.data.core.PropertySet
示例1
/**
* Loads from XML.
*
* @param reader the reader
* @throws Exception the exception
*/
protected void loadFromXml(EwsServiceXmlReader reader) throws Exception {
reader.readStartElement(XmlNamespace.Types, XmlElementNames.Resolution);
reader.readStartElement(XmlNamespace.Types, XmlElementNames.Mailbox);
this.mailbox.loadFromXml(reader, XmlElementNames.Mailbox);
reader.read();
if (reader.isStartElement(XmlNamespace.Types, XmlElementNames.Contact)) {
this.contact = new Contact(this.owner.getSession());
this.contact.loadFromXml(reader, true /* clearPropertyBag */,
PropertySet.FirstClassProperties,
false /* summaryPropertiesOnly */);
reader.readEndElement(XmlNamespace.Types,
XmlElementNames.Resolution);
} else {
reader.ensureCurrentNodeIsEndElement(XmlNamespace.Types,
XmlElementNames.Resolution);
}
}
示例2
/**
* Gets the property set or the default.
*
* @return PropertySet
*/
public PropertySet getPropertySetOrDefault() {
if (this.getPropertySet() == null) {
return PropertySet.getFirstClassProperties();
} else {
return this.getPropertySet();
}
}
示例3
/**
* Writes XML elements.
*
* @param writer the writer
* @throws XMLStreamException the XML stream exception
* @throws ServiceXmlSerializationException the service xml serialization exception
*/
@Override
protected void writeElementsToXml(EwsServiceXmlWriter writer)
throws XMLStreamException, ServiceXmlSerializationException {
if ((this.getBodyType() != null)
|| this.getAdditionalProperties().size() > 0) {
writer.writeStartElement(XmlNamespace.Messages,
XmlElementNames.AttachmentShape);
if (this.getBodyType() != null) {
writer.writeElementValue(XmlNamespace.Types,
XmlElementNames.BodyType, this.getBodyType());
}
if (this.getAdditionalProperties().size() > 0) {
PropertySet.writeAdditionalPropertiesToXml(writer, this.getAdditionalProperties().iterator());
}
writer.writeEndElement(); // AttachmentShape
}
writer.writeStartElement(XmlNamespace.Messages,
XmlElementNames.AttachmentIds);
for (Attachment attachment : this.getAttachments()) {
writer.writeStartElement(XmlNamespace.Types,
XmlElementNames.AttachmentId);
writer
.writeAttributeValue(XmlAttributeNames.Id, attachment
.getId());
writer.writeEndElement();
}
writer.writeEndElement();
}
示例4
/**
* Writes the attribute to XML.
*
* @param writer the writer
* @throws ServiceXmlSerializationException the service xml serialization exception
*/
@Override
protected void writeAttributesToXml(EwsServiceXmlWriter writer)
throws ServiceXmlSerializationException {
writer.writeAttributeValue(XmlAttributeNames.ReturnFullContactData,
this.returnFullContactData);
String searchScope = null;
if (searchScopeMap.getMember().containsKey(searchLocation)) {
searchScope = searchScopeMap.getMember().get(searchLocation);
}
EwsUtilities
.ewsAssert((!(searchScope == null || searchScope.isEmpty())),
"ResolveNameRequest.WriteAttributesToXml",
"The specified search location cannot be mapped to an EWS search scope.");
String propertySet = null;
if (this.getContactDataPropertySet() != null) {
//((PropertyBag)PropertySet.getDefaultPropertySetDictionary( ).getMember()).tryGetValue(this.contactDataPropertySet.getBasePropertySet(), propertySet);
if (PropertySet.getDefaultPropertySetMap().getMember()
.containsKey(this.getContactDataPropertySet().getBasePropertySet())) {
propertySet = PropertySet.getDefaultPropertySetMap().getMember()
.get(this.getContactDataPropertySet().getBasePropertySet());
}
}
if (!this.getService().getExchange2007CompatibilityMode()) {
writer.writeAttributeValue(XmlAttributeNames.
SearchScope, searchScope);
}
if (!(propertySet == null)) {
writer.writeAttributeValue(XmlAttributeNames.ContactDataShape, propertySet);
}
}
示例5
/**
* Initializes a new instance of the GetFolderResponse class.
*
* @param folder The folder.
* @param propertySet The property set from the request.
*/
public GetFolderResponse(Folder folder, PropertySet propertySet) {
super();
this.folder = folder;
this.propertySet = propertySet;
EwsUtilities
.ewsAssert(this.propertySet != null, "GetFolderResponse.ctor", "PropertySet should not be null");
}
示例6
/**
* Initializes a new instance of the class.
*
* @param item the item
* @param propertySet the property set
*/
public GetItemResponse(Item item, PropertySet propertySet) {
super();
this.item = item;
this.propertySet = propertySet;
EwsUtilities.ewsAssert(this.propertySet != null, "GetItemResponse.ctor", "PropertySet should not be null");
}
示例7
/**
* Initializes a new instance of the FindFolderResponse class.
*
* @param propertySet The property set from, the request.
*/
public FindFolderResponse(PropertySet propertySet) {
super();
this.propertySet = propertySet;
EwsUtilities.ewsAssert(this.propertySet != null, "FindFolderResponse.ctor",
"PropertySet should not be null");
}
示例8
/**
* Initializes a new instance of the FindItemResponse class.
*
* @param isGrouped if set to true if grouped.
* @param propertySet The property Set
*/
public FindItemResponse(boolean isGrouped, PropertySet propertySet) {
super();
this.isGrouped = isGrouped;
this.propertySet = propertySet;
EwsUtilities
.ewsAssert(this.propertySet != null, "FindItemResponse.ctor", "PropertySet should not be null");
}
示例9
/**
* Read item from XML.
*
* @param reader the reader
* @param propertySet the property set
* @param destinationList the list in which to add the read item
* @throws XMLStreamException the XML stream exception
* @throws ServiceXmlDeserializationException the service xml deserialization exception
* @throws Exception the exception
*/
private void internalReadItemsFromXml(EwsServiceXmlReader reader,
PropertySet propertySet, List<TItem> destinationList)
throws XMLStreamException, ServiceXmlDeserializationException,
Exception {
EwsUtilities.ewsAssert(destinationList != null, "FindItemResponse.InternalReadItemsFromXml",
"destinationList is null.");
reader.readStartElement(XmlNamespace.Types, XmlElementNames.Items);
if (!reader.isEmptyElement()) {
do {
reader.read();
if (reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) {
Item item = EwsUtilities.createEwsObjectFromXmlElementName(
Item.class, reader.getService(), reader
.getLocalName());
if (item == null) {
reader.skipCurrentElement();
} else {
item.loadFromXml(reader, true, /* clearPropertyBag */
propertySet, true /* summaryPropertiesOnly */);
destinationList.add((TItem) item);
}
}
} while (!reader.isEndElement(XmlNamespace.Types,
XmlElementNames.Items));
} else {
reader.read();
}
}
示例10
/**
* The property definition for the Id of this object.
*
* @param propertySet the property set
* @throws Exception the exception
*/
@Override
protected void internalLoad(PropertySet propertySet) throws Exception {
this.throwIfThisIsNew();
this.throwIfThisIsAttachment();
ArrayList<Item> itemArry = new ArrayList<Item>();
itemArry.add(this);
this.getService().internalLoadPropertiesForItems(itemArry, propertySet,
ServiceErrorHandling.ThrowOnError);
}
示例11
/**
* Loads the specified set of property on the object.
*
* @param propertySet The property to load.
* @throws Exception the exception
*/
@Override
protected void internalLoad(PropertySet propertySet) throws Exception {
this.throwIfThisIsNew();
this.getService().loadPropertiesForFolder(this, propertySet);
}
示例12
/**
* Fills the internal message queue if such queue is empty. This is due to
* the fact that per single session there may be multiple messages retrieved
* from the email server (see FETCH_SIZE).
*/
protected void fillMessageQueueIfNecessary(ProcessContext context) throws ProcessException {
if (this.messageQueue.isEmpty()) {
ExchangeService service = this.initializeIfNecessary(context);
boolean deleteOnRead = context.getProperty(SHOULD_DELETE_MESSAGES).getValue().equals("true");
boolean markAsRead = context.getProperty(SHOULD_MARK_READ).getValue().equals("true");
try {
//Get Folder
Folder folder = getFolder(service);
ItemView view = new ItemView(messageQueue.remainingCapacity());
view.getOrderBy().add(ItemSchema.DateTimeReceived, SortDirection.Ascending);
SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
FindItemsResults<Item> findResults = service.findItems(folder.getId(), sf, view);
if(findResults == null || findResults.getItems().size()== 0){
return;
}
service.loadPropertiesForItems(findResults, PropertySet.FirstClassProperties);
for (Item item : findResults) {
EmailMessage ewsMessage = (EmailMessage) item;
messageQueue.add(parseMessage(ewsMessage));
if(deleteOnRead){
ewsMessage.delete(DeleteMode.HardDelete);
} else if(markAsRead){
ewsMessage.setIsRead(true);
ewsMessage.update(ConflictResolutionMode.AlwaysOverwrite);
}
}
service.close();
} catch (Exception e) {
throw new ProcessException("Failed retrieving new messages from EWS.", e);
}
}
}
示例13
/**
* Initializes a new instance of the class.
*
* @param propertySet the property set
*/
protected SyncResponse(PropertySet propertySet) {
super();
this.propertySet = propertySet;
EwsUtilities.ewsAssert(this.propertySet != null, "SyncResponse.ctor", "PropertySet should not be null");
}
示例14
/**
* Fills the internal message queue if such queue is empty. This is due to
* the fact that per single session there may be multiple messages retrieved
* from the email server (see FETCH_SIZE).
*/
protected void fillMessageQueueIfNecessary(ProcessContext context) throws ProcessException {
if (this.messageQueue.isEmpty()) {
ExchangeService service = this.initializeIfNecessary(context);
boolean deleteOnRead = context.getProperty(SHOULD_DELETE_MESSAGES).getValue().equals("true");
boolean markAsRead = context.getProperty(SHOULD_MARK_READ).getValue().equals("true");
String includeHeaders = context.getProperty(INCLUDE_EMAIL_HEADERS).getValue();
String excludeHeaders = context.getProperty(EXCLUDE_EMAIL_HEADERS).getValue();
List<String> includeHeadersList = null;
List<String> excludeHeadersList = null;
if (!StringUtils.isEmpty(includeHeaders)) {
includeHeadersList = Arrays.asList(includeHeaders.split(","));
}
if (!StringUtils.isEmpty(excludeHeaders)) {
excludeHeadersList = Arrays.asList(excludeHeaders.split(","));
}
try {
//Get Folder
Folder folder = getFolder(service);
ItemView view = new ItemView(messageQueue.remainingCapacity());
view.getOrderBy().add(ItemSchema.DateTimeReceived, SortDirection.Ascending);
SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
FindItemsResults<Item> findResults = service.findItems(folder.getId(), sf, view);
if(findResults == null || findResults.getItems().size()== 0){
return;
}
service.loadPropertiesForItems(findResults, PropertySet.FirstClassProperties);
for (Item item : findResults) {
EmailMessage ewsMessage = (EmailMessage) item;
messageQueue.add(parseMessage(ewsMessage,includeHeadersList,excludeHeadersList));
if(deleteOnRead){
ewsMessage.delete(DeleteMode.HardDelete);
} else if(markAsRead){
ewsMessage.setIsRead(true);
ewsMessage.update(ConflictResolutionMode.AlwaysOverwrite);
}
}
service.close();
} catch (Exception e) {
throw new ProcessException("Failed retrieving new messages from EWS.", e);
}
}
}
示例15
/**
* Load from xml.
*
* @param reader the reader
* @param clearPropertyBag the clear property bag
* @param requestedPropertySet the requested property set
* @param summaryPropertiesOnly the summary property only
* @throws Exception the exception
*/
public void loadFromXml(EwsServiceXmlReader reader, boolean clearPropertyBag,
PropertySet requestedPropertySet, boolean summaryPropertiesOnly) throws Exception {
this.getPropertyBag().loadFromXml(reader, clearPropertyBag,
requestedPropertySet, summaryPropertiesOnly);
}
示例16
/**
* Binds to an existing meeting response and loads the specified set of
* property. Calling this method results in a call to EWS.
*
* @param service The service to use to bind to the meeting response.
* @param id The Id of the meeting response to bind to.
* @param propertySet The set of property to load.
* @return A MeetingResponse instance representing the meeting response
* corresponding to the specified Id.
*/
public static MeetingResponse bind(ExchangeService service, ItemId id,
PropertySet propertySet) {
try {
return service.bindToItem(MeetingResponse.class, id, propertySet);
} catch (Exception e) {
LOG.error(e);
return null;
}
}
示例17
/**
* Binds to an existing appointment and loads its first class property.
* Calling this method results in a call to EWS.
*
* @param service the service
* @param recurringMasterId the recurring master id
* @param occurenceIndex the occurence index
* @param propertySet the property set
* @return An Appointment instance representing the appointment
* corresponding to the specified Id.
* @throws Exception the exception
*/
public static Appointment bindToOccurrence(ExchangeService service,
ItemId recurringMasterId, int occurenceIndex,
PropertySet propertySet) throws Exception {
AppointmentOccurrenceId occurenceId = new AppointmentOccurrenceId(
recurringMasterId.getUniqueId(), occurenceIndex);
return Appointment.bind(service, occurenceId, propertySet);
}
示例18
/**
* Binds to the master appointment of a recurring series and loads its first
* class property. Calling this method results in a call to EWS.
*
* @param service the service
* @param occurrenceId the occurrence id
* @param propertySet the property set
* @return An Appointment instance representing the appointment
* corresponding to the specified Id.
* @throws Exception the exception
*/
public static Appointment bindToRecurringMaster(ExchangeService service,
ItemId occurrenceId, PropertySet propertySet) throws Exception {
RecurringAppointmentMasterId recurringMasterId =
new RecurringAppointmentMasterId(
occurrenceId.getUniqueId());
return Appointment.bind(service, recurringMasterId, propertySet);
}
示例19
/**
* Binds to an existing meeting cancellation message and loads the specified
* set of property. Calling this method results in a call to EWS.
*
* @param service The service to use to bind to the meeting cancellation
* message.
* @param id The Id of the meeting cancellation message to bind to.
* @param propertySet The set of property to load.
* @return A MeetingCancellation instance representing the meeting
* cancellation message corresponding to the specified Id.
*/
public static MeetingCancellation bind(ExchangeService service, ItemId id,
PropertySet propertySet) {
try {
return service.bindToItem(MeetingCancellation.class, id,
propertySet);
} catch (Exception e) {
LOG.error(e);
return null;
}
}
示例20
/**
* Binds to an existing meeting response and loads the specified set of
* property. Calling this method results in a call to EWS.
*
* @param service The service to use to bind to the meeting request.
* @param id The Id of the meeting request to bind to.
* @param propertySet The set of property to load.
* @return A MeetingResponse instance representing the meeting request
* corresponding to the specified Id.
*/
public static MeetingRequest bind(ExchangeService service, ItemId id,
PropertySet propertySet) {
try {
return service.bindToItem(MeetingRequest.class, id, propertySet);
} catch (Exception e) {
LOG.error(e);
return null;
}
}
示例21
/**
* Gets the property set. PropertySet determines which property will be
* loaded on found item. If PropertySet is null, all first class property
* are loaded on found item.
*
* @return the property set
*/
public PropertySet getPropertySet() {
return propertySet;
}
示例22
/**
* Sets the property set. PropertySet determines which property will be
* loaded on found item. If PropertySet is null, all first class property
* are loaded on found item.
*
* @param propertySet The property set
*/
public void setPropertySet(PropertySet propertySet) {
this.propertySet = propertySet;
}
示例23
/**
* Gets the property set.
*
* @return the property set
*/
public PropertySet getPropertySet() {
return this.propertySet;
}
示例24
/**
* Sets the property set.
*
* @param propertySet the new property set
*/
public void setPropertySet(PropertySet propertySet) {
this.propertySet = propertySet;
}
示例25
/**
* Gets or sets the property set. <value>The property set.</value>
*
* @return the property set
*/
public PropertySet getPropertySet() {
return this.propertySet;
}
示例26
/**
* Sets the property set.
*
* @param value the new property set
*/
public void setPropertySet(PropertySet value) {
this.propertySet = value;
}
示例27
/**
* Gets or sets the property set. <value>The property set.</value>
*
* @return the property set
*/
public PropertySet getPropertySet() {
return this.propertySet;
}
示例28
/**
* Sets the property set.
*
* @param propertySet the new property set
*/
public void setPropertySet(PropertySet propertySet) {
this.propertySet = propertySet;
}
示例29
/**
* Gets or sets the PropertySet for Contact Data
* <p/>
* The PropertySet
*/
public void setContactDataPropertySet(PropertySet propertySet) {
this.contactDataPropertySet = propertySet;
}
示例30
/**
* Gets or sets the PropertySet for Contact Data
*
* @return The PropertySet
*/
public PropertySet getContactDataPropertySet() {
return this.contactDataPropertySet;
}