1 18 19 package sync4j.exchange.items.calendar.manager; 20 21 import java.io.IOException ; 22 23 import sync4j.exchange.items.calendar.dao.CalendarDAO; 24 import sync4j.exchange.items.calendar.model.Calendar; 25 import sync4j.exchange.DataAccessException; 26 import sync4j.exchange.xml.XmlParser; 27 import java.util.Date ; 28 29 37 public class CalendarManager { 38 39 41 43 CalendarDAO cd = null ; 44 45 47 public CalendarManager(String exchangeServerHost , 48 int exchangeServerPort) 49 throws DataAccessException { 50 51 this.cd = new CalendarDAO (exchangeServerHost , 52 exchangeServerPort); 53 54 } 55 56 58 69 public Calendar[] getAllCalendars(String username , 70 String credentials , 71 String exchangeFolder ) 72 throws DataAccessException { 73 74 return this.cd.getCalendars(username , 75 credentials , 76 new String [0] , 77 exchangeFolder ); 78 } 79 80 92 public Calendar getCalendarTwin(Calendar calendar , 93 String username , 94 String credentials , 95 String exchangeFolder) 96 throws DataAccessException { 97 98 Calendar[] calendars = null; 99 100 Date dateStart = null; 101 Date dateEnd = null; 102 103 try { 104 105 dateStart = XmlParser.pdiToDate(calendar.getDtStart (). 106 getPropertyValueAsString()); 107 dateEnd = XmlParser.pdiToDate(calendar.getDtEnd (). 108 getPropertyValueAsString()); 109 110 } catch (Exception e) { 111 throw new DataAccessException(e.getMessage()); 112 } 113 114 String location = calendar.getLocation(). 115 getPropertyValueAsString(); 116 117 String [] fields = { 118 CalendarDAO.TAG_DATESTART , 119 CalendarDAO.TAG_DATEEND , 120 CalendarDAO.TAG_LOCATION 121 }; 122 123 Object [] values = { 124 dateStart, 125 dateEnd, 126 location 127 }; 128 129 calendars = this.cd.getCalendars(username, 130 credentials, 131 fields, 132 values, 133 exchangeFolder); 134 135 if (calendars == null || !(calendars.length > 0)) { 136 return null; 137 } 138 139 return calendars[0]; 140 } 141 142 143 155 public Calendar[] getCalendars(String username , 156 String credentials , 157 String [] ids , 158 String exchangeFolder ) 159 throws DataAccessException { 160 161 return this.cd.getCalendars(username , 162 credentials , 163 ids , 164 exchangeFolder ); 165 166 } 167 168 179 public Calendar getCalendarById(String username , 180 String credentials , 181 String id , 182 String exchangeFolder ) 183 throws DataAccessException { 184 185 Calendar[] calendars = null; 186 187 calendars = this.cd.getCalendars(username , 188 credentials , 189 new String [] {id} , 190 exchangeFolder); 191 192 if (calendars == null || !(calendars.length > 0)) { 193 return null; 194 } 195 196 return calendars[0]; 197 198 } 199 200 212 public Calendar setCalendar(Calendar calendar , 213 String username , 214 String credentials , 215 String exchangeFolder 216 ) 217 throws DataAccessException { 218 219 return this.cd.setCalendar(calendar , 220 username , 221 credentials , 222 exchangeFolder ); 223 224 } 225 226 236 public void removeCalendar(Calendar calendar , 237 String username , 238 String principal , 239 String exchangeFolder ) 240 throws DataAccessException { 241 242 this.cd.removeCalendar(calendar, username, principal, exchangeFolder); 243 244 } 245 246 } 247 | Popular Tags |