001/* 002 * The MIT License 003 * Copyright (c) 2012 Microsoft Corporation 004 * 005 * Permission is hereby granted, free of charge, to any person obtaining a copy 006 * of this software and associated documentation files (the "Software"), to deal 007 * in the Software without restriction, including without limitation the rights 008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 009 * copies of the Software, and to permit persons to whom the Software is 010 * furnished to do so, subject to the following conditions: 011 * 012 * The above copyright notice and this permission notice shall be included in 013 * all copies or substantial portions of the Software. 014 * 015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 021 * THE SOFTWARE. 022 */ 023 024package microsoft.exchange.webservices.data.core.service.item; 025 026import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; 027import microsoft.exchange.webservices.data.core.ExchangeService; 028import microsoft.exchange.webservices.data.core.PropertySet; 029import microsoft.exchange.webservices.data.core.XmlElementNames; 030import microsoft.exchange.webservices.data.core.service.response.RemoveFromCalendar; 031import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; 032import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; 033import microsoft.exchange.webservices.data.misc.CalendarActionResults; 034import microsoft.exchange.webservices.data.property.complex.ItemAttachment; 035import microsoft.exchange.webservices.data.property.complex.ItemId; 036import org.apache.commons.logging.Log; 037import org.apache.commons.logging.LogFactory; 038 039/** 040 * Represents a meeting cancellation message. Properties available on meeting 041 * messages are defined in the MeetingMessageSchema class. 042 */ 043@ServiceObjectDefinition(xmlElementName = XmlElementNames.MeetingCancellation) 044public class MeetingCancellation extends MeetingMessage { 045 046 private static final Log LOG = LogFactory.getLog(MeetingCancellation.class); 047 048 /** 049 * Initializes a new instance of the class. 050 * 051 * @param parentAttachment The parent attachment. 052 * @throws Exception the exception 053 */ 054 public MeetingCancellation(ItemAttachment parentAttachment) 055 throws Exception { 056 super(parentAttachment); 057 } 058 059 /** 060 * Initializes a new instance of the class. 061 * 062 * @param service EWS service to which this object belongs. 063 * @throws Exception the exception 064 */ 065 public MeetingCancellation(ExchangeService service) throws Exception { 066 super(service); 067 } 068 069 /** 070 * Binds to an existing meeting cancellation message and loads the specified 071 * set of property. Calling this method results in a call to EWS. 072 * 073 * @param service The service to use to bind to the meeting cancellation 074 * message. 075 * @param id The Id of the meeting cancellation message to bind to. 076 * @param propertySet The set of property to load. 077 * @return A MeetingCancellation instance representing the meeting 078 * cancellation message corresponding to the specified Id. 079 */ 080 public static MeetingCancellation bind(ExchangeService service, ItemId id, 081 PropertySet propertySet) { 082 try { 083 return service.bindToItem(MeetingCancellation.class, id, 084 propertySet); 085 } catch (Exception e) { 086 LOG.error(e); 087 return null; 088 } 089 } 090 091 /** 092 * Binds to an existing meeting cancellation message and loads the specified 093 * set of property. Calling this method results in a call to EWS. 094 * 095 * @param service The service to use to bind to the meeting cancellation 096 * message. 097 * @param id The Id of the meeting cancellation message to bind to. 098 * @return A MeetingCancellation instance representing the meeting 099 * cancellation message corresponding to the specified Id. 100 */ 101 public static MeetingCancellation bind(ExchangeService service, ItemId id) { 102 return MeetingCancellation.bind(service, id, PropertySet 103 .getFirstClassProperties()); 104 } 105 106 /** 107 * Removes the meeting associated with the cancellation message from the 108 * user's calendar. 109 * 110 * @return A CalendarActionResults object containing the various item that 111 * were created or modified as a results of this operation. 112 * @throws ServiceLocalException the service local exception 113 * @throws Exception the exception 114 */ 115 public CalendarActionResults removeMeetingFromCalendar() 116 throws ServiceLocalException, Exception { 117 return new CalendarActionResults(new RemoveFromCalendar(this) 118 .internalCreate(null, null)); 119 } 120 121 /** 122 * Gets the minimum required server version. 123 * 124 * @return Earliest Exchange version in which this service object type is 125 * supported. 126 */ 127 @Override public ExchangeVersion getMinimumRequiredServerVersion() { 128 return ExchangeVersion.Exchange2007_SP1; 129 } 130}