Tue, 10 Feb 2015 19:38:00 +0100
Upgrade embedded ical4j from ancient whatever to upstream version 1.0.6.
michael@0 | 1 | /** |
michael@0 | 2 | * Copyright (c) 2012, Ben Fortuna |
michael@0 | 3 | * All rights reserved. |
michael@0 | 4 | * |
michael@0 | 5 | * Redistribution and use in source and binary forms, with or without |
michael@0 | 6 | * modification, are permitted provided that the following conditions |
michael@0 | 7 | * are met: |
michael@0 | 8 | * |
michael@0 | 9 | * o Redistributions of source code must retain the above copyright |
michael@0 | 10 | * notice, this list of conditions and the following disclaimer. |
michael@0 | 11 | * |
michael@0 | 12 | * o Redistributions in binary form must reproduce the above copyright |
michael@0 | 13 | * notice, this list of conditions and the following disclaimer in the |
michael@0 | 14 | * documentation and/or other materials provided with the distribution. |
michael@0 | 15 | * |
michael@0 | 16 | * o Neither the name of Ben Fortuna nor the names of any other contributors |
michael@0 | 17 | * may be used to endorse or promote products derived from this software |
michael@0 | 18 | * without specific prior written permission. |
michael@0 | 19 | * |
michael@0 | 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
michael@0 | 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
michael@0 | 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
michael@0 | 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
michael@0 | 24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
michael@0 | 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
michael@0 | 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
michael@0 | 27 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
michael@0 | 28 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
michael@0 | 29 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
michael@0 | 30 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 31 | */ |
michael@0 | 32 | package net.fortuna.ical4j.model.component; |
michael@0 | 33 | |
michael@0 | 34 | import java.io.IOException; |
michael@0 | 35 | import java.net.URISyntaxException; |
michael@0 | 36 | import java.text.ParseException; |
michael@0 | 37 | import java.util.HashMap; |
michael@0 | 38 | import java.util.Iterator; |
michael@0 | 39 | import java.util.Map; |
michael@0 | 40 | |
michael@0 | 41 | import net.fortuna.ical4j.model.Component; |
michael@0 | 42 | import net.fortuna.ical4j.model.ComponentList; |
michael@0 | 43 | import net.fortuna.ical4j.model.Date; |
michael@0 | 44 | import net.fortuna.ical4j.model.Dur; |
michael@0 | 45 | import net.fortuna.ical4j.model.Property; |
michael@0 | 46 | import net.fortuna.ical4j.model.PropertyList; |
michael@0 | 47 | import net.fortuna.ical4j.model.ValidationException; |
michael@0 | 48 | import net.fortuna.ical4j.model.Validator; |
michael@0 | 49 | import net.fortuna.ical4j.model.property.Clazz; |
michael@0 | 50 | import net.fortuna.ical4j.model.property.Completed; |
michael@0 | 51 | import net.fortuna.ical4j.model.property.Created; |
michael@0 | 52 | import net.fortuna.ical4j.model.property.Description; |
michael@0 | 53 | import net.fortuna.ical4j.model.property.DtStamp; |
michael@0 | 54 | import net.fortuna.ical4j.model.property.DtStart; |
michael@0 | 55 | import net.fortuna.ical4j.model.property.Due; |
michael@0 | 56 | import net.fortuna.ical4j.model.property.Duration; |
michael@0 | 57 | import net.fortuna.ical4j.model.property.Geo; |
michael@0 | 58 | import net.fortuna.ical4j.model.property.LastModified; |
michael@0 | 59 | import net.fortuna.ical4j.model.property.Location; |
michael@0 | 60 | import net.fortuna.ical4j.model.property.Method; |
michael@0 | 61 | import net.fortuna.ical4j.model.property.Organizer; |
michael@0 | 62 | import net.fortuna.ical4j.model.property.PercentComplete; |
michael@0 | 63 | import net.fortuna.ical4j.model.property.Priority; |
michael@0 | 64 | import net.fortuna.ical4j.model.property.RecurrenceId; |
michael@0 | 65 | import net.fortuna.ical4j.model.property.Sequence; |
michael@0 | 66 | import net.fortuna.ical4j.model.property.Status; |
michael@0 | 67 | import net.fortuna.ical4j.model.property.Summary; |
michael@0 | 68 | import net.fortuna.ical4j.model.property.Uid; |
michael@0 | 69 | import net.fortuna.ical4j.model.property.Url; |
michael@0 | 70 | import net.fortuna.ical4j.util.CompatibilityHints; |
michael@0 | 71 | import net.fortuna.ical4j.util.ComponentValidator; |
michael@0 | 72 | import net.fortuna.ical4j.util.PropertyValidator; |
michael@0 | 73 | import net.fortuna.ical4j.util.Strings; |
michael@0 | 74 | |
michael@0 | 75 | import org.apache.commons.lang.ObjectUtils; |
michael@0 | 76 | import org.apache.commons.lang.builder.HashCodeBuilder; |
michael@0 | 77 | |
michael@0 | 78 | /** |
michael@0 | 79 | * $Id$ [Apr 5, 2004] |
michael@0 | 80 | * |
michael@0 | 81 | * Defines an iCalendar VTODO component. |
michael@0 | 82 | * |
michael@0 | 83 | * <pre> |
michael@0 | 84 | * 4.6.2 To-do Component |
michael@0 | 85 | * |
michael@0 | 86 | * Component Name: VTODO |
michael@0 | 87 | * |
michael@0 | 88 | * Purpose: Provide a grouping of calendar properties that describe a |
michael@0 | 89 | * to-do. |
michael@0 | 90 | * |
michael@0 | 91 | * Formal Definition: A "VTODO" calendar component is defined by the |
michael@0 | 92 | * following notation: |
michael@0 | 93 | * |
michael@0 | 94 | * todoc = "BEGIN" ":" "VTODO" CRLF |
michael@0 | 95 | * todoprop *alarmc |
michael@0 | 96 | * "END" ":" "VTODO" CRLF |
michael@0 | 97 | * |
michael@0 | 98 | * todoprop = *( |
michael@0 | 99 | * |
michael@0 | 100 | * ; the following are optional, |
michael@0 | 101 | * ; but MUST NOT occur more than once |
michael@0 | 102 | * |
michael@0 | 103 | * class / completed / created / description / dtstamp / |
michael@0 | 104 | * dtstart / geo / last-mod / location / organizer / |
michael@0 | 105 | * percent / priority / recurid / seq / status / |
michael@0 | 106 | * summary / uid / url / |
michael@0 | 107 | * |
michael@0 | 108 | * ; either 'due' or 'duration' may appear in |
michael@0 | 109 | * ; a 'todoprop', but 'due' and 'duration' |
michael@0 | 110 | * ; MUST NOT occur in the same 'todoprop' |
michael@0 | 111 | * |
michael@0 | 112 | * due / duration / |
michael@0 | 113 | * |
michael@0 | 114 | * ; the following are optional, |
michael@0 | 115 | * ; and MAY occur more than once |
michael@0 | 116 | * attach / attendee / categories / comment / contact / |
michael@0 | 117 | * exdate / exrule / rstatus / related / resources / |
michael@0 | 118 | * rdate / rrule / x-prop |
michael@0 | 119 | * |
michael@0 | 120 | * ) |
michael@0 | 121 | * </pre> |
michael@0 | 122 | * |
michael@0 | 123 | * Example 1 - Creating a todo of two (2) hour duration starting tomorrow: |
michael@0 | 124 | * |
michael@0 | 125 | * <pre><code> |
michael@0 | 126 | * java.util.Calendar cal = java.util.Calendar.getInstance(); |
michael@0 | 127 | * // tomorrow.. |
michael@0 | 128 | * cal.add(java.util.Calendar.DAY_OF_MONTH, 1); |
michael@0 | 129 | * cal.set(java.util.Calendar.HOUR_OF_DAY, 11); |
michael@0 | 130 | * cal.set(java.util.Calendar.MINUTE, 00); |
michael@0 | 131 | * |
michael@0 | 132 | * VToDo documentation = new VEvent(cal.getTime(), 1000 * 60 * 60 * 2, |
michael@0 | 133 | * "Document calendar component usage"); |
michael@0 | 134 | * |
michael@0 | 135 | * // add timezone information.. |
michael@0 | 136 | * VTimeZone tz = VTimeZone.getDefault(); |
michael@0 | 137 | * TzId tzParam = new TzId(tz.getProperties().getProperty(Property.TZID) |
michael@0 | 138 | * .getValue()); |
michael@0 | 139 | * documentation.getProperties().getProperty(Property.DTSTART).getParameters() |
michael@0 | 140 | * .add(tzParam); |
michael@0 | 141 | * </code></pre> |
michael@0 | 142 | * |
michael@0 | 143 | * @author Ben Fortuna |
michael@0 | 144 | */ |
michael@0 | 145 | public class VToDo extends CalendarComponent { |
michael@0 | 146 | |
michael@0 | 147 | private static final long serialVersionUID = -269658210065896668L; |
michael@0 | 148 | |
michael@0 | 149 | private final Map methodValidators = new HashMap(); |
michael@0 | 150 | { |
michael@0 | 151 | methodValidators.put(Method.ADD, new AddValidator()); |
michael@0 | 152 | methodValidators.put(Method.CANCEL, new CancelValidator()); |
michael@0 | 153 | methodValidators.put(Method.COUNTER, new CounterValidator()); |
michael@0 | 154 | methodValidators.put(Method.DECLINE_COUNTER, new DeclineCounterValidator()); |
michael@0 | 155 | methodValidators.put(Method.PUBLISH, new PublishValidator()); |
michael@0 | 156 | methodValidators.put(Method.REFRESH, new RefreshValidator()); |
michael@0 | 157 | methodValidators.put(Method.REPLY, new ReplyValidator()); |
michael@0 | 158 | methodValidators.put(Method.REQUEST, new RequestValidator()); |
michael@0 | 159 | } |
michael@0 | 160 | |
michael@0 | 161 | private ComponentList alarms = new ComponentList(); |
michael@0 | 162 | |
michael@0 | 163 | /** |
michael@0 | 164 | * Default constructor. |
michael@0 | 165 | */ |
michael@0 | 166 | public VToDo() { |
michael@0 | 167 | super(VTODO); |
michael@0 | 168 | getProperties().add(new DtStamp()); |
michael@0 | 169 | } |
michael@0 | 170 | |
michael@0 | 171 | /** |
michael@0 | 172 | * Constructor. |
michael@0 | 173 | * @param properties a list of properties |
michael@0 | 174 | */ |
michael@0 | 175 | public VToDo(final PropertyList properties) { |
michael@0 | 176 | super(VTODO, properties); |
michael@0 | 177 | } |
michael@0 | 178 | |
michael@0 | 179 | /** |
michael@0 | 180 | * Constructs a new VTODO instance starting at the specified time with the specified summary. |
michael@0 | 181 | * @param start the start date of the new todo |
michael@0 | 182 | * @param summary the todo summary |
michael@0 | 183 | */ |
michael@0 | 184 | public VToDo(final Date start, final String summary) { |
michael@0 | 185 | this(); |
michael@0 | 186 | getProperties().add(new DtStart(start)); |
michael@0 | 187 | getProperties().add(new Summary(summary)); |
michael@0 | 188 | } |
michael@0 | 189 | |
michael@0 | 190 | /** |
michael@0 | 191 | * Constructs a new VTODO instance starting and ending at the specified times with the specified summary. |
michael@0 | 192 | * @param start the start date of the new todo |
michael@0 | 193 | * @param due the due date of the new todo |
michael@0 | 194 | * @param summary the todo summary |
michael@0 | 195 | */ |
michael@0 | 196 | public VToDo(final Date start, final Date due, final String summary) { |
michael@0 | 197 | this(); |
michael@0 | 198 | getProperties().add(new DtStart(start)); |
michael@0 | 199 | getProperties().add(new Due(due)); |
michael@0 | 200 | getProperties().add(new Summary(summary)); |
michael@0 | 201 | } |
michael@0 | 202 | |
michael@0 | 203 | /** |
michael@0 | 204 | * Constructs a new VTODO instance starting at the specified times, for the specified duration, with the specified |
michael@0 | 205 | * summary. |
michael@0 | 206 | * @param start the start date of the new todo |
michael@0 | 207 | * @param duration the duration of the new todo |
michael@0 | 208 | * @param summary the todo summary |
michael@0 | 209 | */ |
michael@0 | 210 | public VToDo(final Date start, final Dur duration, final String summary) { |
michael@0 | 211 | this(); |
michael@0 | 212 | getProperties().add(new DtStart(start)); |
michael@0 | 213 | getProperties().add(new Duration(duration)); |
michael@0 | 214 | getProperties().add(new Summary(summary)); |
michael@0 | 215 | } |
michael@0 | 216 | |
michael@0 | 217 | /** |
michael@0 | 218 | * Returns the list of alarms for this todo. |
michael@0 | 219 | * @return a component list |
michael@0 | 220 | */ |
michael@0 | 221 | public final ComponentList getAlarms() { |
michael@0 | 222 | return alarms; |
michael@0 | 223 | } |
michael@0 | 224 | |
michael@0 | 225 | /** |
michael@0 | 226 | * {@inheritDoc} |
michael@0 | 227 | */ |
michael@0 | 228 | public final String toString() { |
michael@0 | 229 | final StringBuffer buffer = new StringBuffer(); |
michael@0 | 230 | buffer.append(BEGIN); |
michael@0 | 231 | buffer.append(':'); |
michael@0 | 232 | buffer.append(getName()); |
michael@0 | 233 | buffer.append(Strings.LINE_SEPARATOR); |
michael@0 | 234 | buffer.append(getProperties()); |
michael@0 | 235 | buffer.append(getAlarms()); |
michael@0 | 236 | buffer.append(END); |
michael@0 | 237 | buffer.append(':'); |
michael@0 | 238 | buffer.append(getName()); |
michael@0 | 239 | buffer.append(Strings.LINE_SEPARATOR); |
michael@0 | 240 | return buffer.toString(); |
michael@0 | 241 | } |
michael@0 | 242 | |
michael@0 | 243 | /** |
michael@0 | 244 | * {@inheritDoc} |
michael@0 | 245 | */ |
michael@0 | 246 | public final void validate(final boolean recurse) |
michael@0 | 247 | throws ValidationException { |
michael@0 | 248 | |
michael@0 | 249 | // validate that getAlarms() only contains VAlarm components |
michael@0 | 250 | final Iterator iterator = getAlarms().iterator(); |
michael@0 | 251 | while (iterator.hasNext()) { |
michael@0 | 252 | final Component component = (Component) iterator.next(); |
michael@0 | 253 | if (!(component instanceof VAlarm)) { |
michael@0 | 254 | throw new ValidationException("Component [" |
michael@0 | 255 | + component.getName() + "] may not occur in VTODO"); |
michael@0 | 256 | } |
michael@0 | 257 | ((VAlarm) component).validate(recurse); |
michael@0 | 258 | } |
michael@0 | 259 | |
michael@0 | 260 | if (!CompatibilityHints |
michael@0 | 261 | .isHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION)) { |
michael@0 | 262 | |
michael@0 | 263 | // From "4.8.4.7 Unique Identifier": |
michael@0 | 264 | // Conformance: The property MUST be specified in the "VEVENT", "VTODO", |
michael@0 | 265 | // "VJOURNAL" or "VFREEBUSY" calendar components. |
michael@0 | 266 | PropertyValidator.getInstance().assertOne(Property.UID, |
michael@0 | 267 | getProperties()); |
michael@0 | 268 | |
michael@0 | 269 | // From "4.8.7.2 Date/Time Stamp": |
michael@0 | 270 | // Conformance: This property MUST be included in the "VEVENT", "VTODO", |
michael@0 | 271 | // "VJOURNAL" or "VFREEBUSY" calendar components. |
michael@0 | 272 | PropertyValidator.getInstance().assertOne(Property.DTSTAMP, |
michael@0 | 273 | getProperties()); |
michael@0 | 274 | } |
michael@0 | 275 | |
michael@0 | 276 | /* |
michael@0 | 277 | * ; the following are optional, ; but MUST NOT occur more than once class / completed / created / description / |
michael@0 | 278 | * dtstamp / dtstart / geo / last-mod / location / organizer / percent / priority / recurid / seq / status / |
michael@0 | 279 | * summary / uid / url / |
michael@0 | 280 | */ |
michael@0 | 281 | PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, |
michael@0 | 282 | getProperties()); |
michael@0 | 283 | PropertyValidator.getInstance().assertOneOrLess(Property.COMPLETED, |
michael@0 | 284 | getProperties()); |
michael@0 | 285 | PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, |
michael@0 | 286 | getProperties()); |
michael@0 | 287 | PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, |
michael@0 | 288 | getProperties()); |
michael@0 | 289 | PropertyValidator.getInstance().assertOneOrLess(Property.DTSTAMP, |
michael@0 | 290 | getProperties()); |
michael@0 | 291 | PropertyValidator.getInstance().assertOneOrLess(Property.DTSTART, |
michael@0 | 292 | getProperties()); |
michael@0 | 293 | PropertyValidator.getInstance().assertOneOrLess(Property.GEO, |
michael@0 | 294 | getProperties()); |
michael@0 | 295 | PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, |
michael@0 | 296 | getProperties()); |
michael@0 | 297 | PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION, |
michael@0 | 298 | getProperties()); |
michael@0 | 299 | PropertyValidator.getInstance().assertOneOrLess(Property.ORGANIZER, |
michael@0 | 300 | getProperties()); |
michael@0 | 301 | PropertyValidator.getInstance().assertOneOrLess( |
michael@0 | 302 | Property.PERCENT_COMPLETE, getProperties()); |
michael@0 | 303 | PropertyValidator.getInstance().assertOneOrLess(Property.PRIORITY, |
michael@0 | 304 | getProperties()); |
michael@0 | 305 | PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, |
michael@0 | 306 | getProperties()); |
michael@0 | 307 | PropertyValidator.getInstance().assertOneOrLess(Property.SEQUENCE, |
michael@0 | 308 | getProperties()); |
michael@0 | 309 | PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, |
michael@0 | 310 | getProperties()); |
michael@0 | 311 | PropertyValidator.getInstance().assertOneOrLess(Property.SUMMARY, |
michael@0 | 312 | getProperties()); |
michael@0 | 313 | PropertyValidator.getInstance().assertOneOrLess(Property.UID, |
michael@0 | 314 | getProperties()); |
michael@0 | 315 | PropertyValidator.getInstance().assertOneOrLess(Property.URL, |
michael@0 | 316 | getProperties()); |
michael@0 | 317 | |
michael@0 | 318 | final Status status = (Status) getProperty(Property.STATUS); |
michael@0 | 319 | if (status != null && !Status.VTODO_NEEDS_ACTION.getValue().equals(status.getValue()) |
michael@0 | 320 | && !Status.VTODO_COMPLETED.getValue().equals(status.getValue()) |
michael@0 | 321 | && !Status.VTODO_IN_PROCESS.getValue().equals(status.getValue()) |
michael@0 | 322 | && !Status.VTODO_CANCELLED.getValue().equals(status.getValue())) { |
michael@0 | 323 | throw new ValidationException("Status property [" |
michael@0 | 324 | + status.toString() + "] may not occur in VTODO"); |
michael@0 | 325 | } |
michael@0 | 326 | |
michael@0 | 327 | /* |
michael@0 | 328 | * ; either 'due' or 'duration' may appear in ; a 'todoprop', but 'due' and 'duration' ; MUST NOT occur in the |
michael@0 | 329 | * same 'todoprop' due / duration / |
michael@0 | 330 | */ |
michael@0 | 331 | try { |
michael@0 | 332 | PropertyValidator.getInstance().assertNone(Property.DUE, |
michael@0 | 333 | getProperties()); |
michael@0 | 334 | } |
michael@0 | 335 | catch (ValidationException ve) { |
michael@0 | 336 | PropertyValidator.getInstance().assertNone(Property.DURATION, |
michael@0 | 337 | getProperties()); |
michael@0 | 338 | } |
michael@0 | 339 | |
michael@0 | 340 | /* |
michael@0 | 341 | * ; the following are optional, ; and MAY occur more than once attach / attendee / categories / comment / |
michael@0 | 342 | * contact / exdate / exrule / rstatus / related / resources / rdate / rrule / x-prop |
michael@0 | 343 | */ |
michael@0 | 344 | |
michael@0 | 345 | if (recurse) { |
michael@0 | 346 | validateProperties(); |
michael@0 | 347 | } |
michael@0 | 348 | } |
michael@0 | 349 | |
michael@0 | 350 | /** |
michael@0 | 351 | * {@inheritDoc} |
michael@0 | 352 | */ |
michael@0 | 353 | protected Validator getValidator(Method method) { |
michael@0 | 354 | return (Validator) methodValidators.get(method); |
michael@0 | 355 | } |
michael@0 | 356 | |
michael@0 | 357 | /** |
michael@0 | 358 | * <pre> |
michael@0 | 359 | * Component/Property Presence |
michael@0 | 360 | * ------------------- ---------------------------------------------- |
michael@0 | 361 | * METHOD 1 MUST be "ADD" |
michael@0 | 362 | * VTODO 1 |
michael@0 | 363 | * DTSTAMP 1 |
michael@0 | 364 | * ORGANIZER 1 |
michael@0 | 365 | * PRIORITY 1 |
michael@0 | 366 | * SEQUENCE 1 MUST be greater than 0 |
michael@0 | 367 | * SUMMARY 1 Can be null. |
michael@0 | 368 | * UID 1 MUST match that of the original to-do |
michael@0 | 369 | * |
michael@0 | 370 | * ATTACH 0+ |
michael@0 | 371 | * ATTENDEE 0+ |
michael@0 | 372 | * CATEGORIES 0 or 1 This property may contain a list of |
michael@0 | 373 | * values |
michael@0 | 374 | * CLASS 0 or 1 |
michael@0 | 375 | * COMMENT 0 or 1 |
michael@0 | 376 | * CONTACT 0+ |
michael@0 | 377 | * CREATED 0 or 1 |
michael@0 | 378 | * DESCRIPTION 0 or 1 Can be null |
michael@0 | 379 | * DTSTART 0 or 1 |
michael@0 | 380 | * DUE 0 or 1 If present DURATION MUST NOT be present |
michael@0 | 381 | * DURATION 0 or 1 If present DUE MUST NOT be present |
michael@0 | 382 | * EXDATE 0+ |
michael@0 | 383 | * EXRULE 0+ |
michael@0 | 384 | * GEO 0 or 1 |
michael@0 | 385 | * LAST-MODIFIED 0 or 1 |
michael@0 | 386 | * LOCATION 0 or 1 |
michael@0 | 387 | * PERCENT-COMPLETE 0 or 1 |
michael@0 | 388 | * RDATE 0+ |
michael@0 | 389 | * RELATED-TO 0+ |
michael@0 | 390 | * RESOURCES 0 or 1 This property may contain a list of |
michael@0 | 391 | * values |
michael@0 | 392 | * RRULE 0+ |
michael@0 | 393 | * STATUS 0 or 1 MAY be one of COMPLETED/NEEDS ACTION/IN- |
michael@0 | 394 | * PROCESS |
michael@0 | 395 | * URL 0 or 1 |
michael@0 | 396 | * X-PROPERTY 0+ |
michael@0 | 397 | * |
michael@0 | 398 | * RECURRENCE-ID 0 |
michael@0 | 399 | * REQUEST-STATUS 0 |
michael@0 | 400 | * |
michael@0 | 401 | * VALARM 0+ |
michael@0 | 402 | * VTIMEZONE 0+ MUST be present if any date/time refers |
michael@0 | 403 | * to a timezone |
michael@0 | 404 | * X-COMPONENT 0+ |
michael@0 | 405 | * |
michael@0 | 406 | * VEVENT 0 |
michael@0 | 407 | * VJOURNAL 0 |
michael@0 | 408 | * VFREEBUSY 0 |
michael@0 | 409 | * </pre> |
michael@0 | 410 | * |
michael@0 | 411 | */ |
michael@0 | 412 | private class AddValidator implements Validator { |
michael@0 | 413 | |
michael@0 | 414 | private static final long serialVersionUID = 1L; |
michael@0 | 415 | |
michael@0 | 416 | public void validate() throws ValidationException { |
michael@0 | 417 | PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties()); |
michael@0 | 418 | PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties()); |
michael@0 | 419 | PropertyValidator.getInstance().assertOne(Property.PRIORITY, getProperties()); |
michael@0 | 420 | PropertyValidator.getInstance().assertOne(Property.SEQUENCE, getProperties()); |
michael@0 | 421 | PropertyValidator.getInstance().assertOne(Property.SUMMARY, getProperties()); |
michael@0 | 422 | PropertyValidator.getInstance().assertOne(Property.UID, getProperties()); |
michael@0 | 423 | |
michael@0 | 424 | PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties()); |
michael@0 | 425 | PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties()); |
michael@0 | 426 | PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties()); |
michael@0 | 427 | PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, getProperties()); |
michael@0 | 428 | PropertyValidator.getInstance().assertOneOrLess(Property.DTSTART, getProperties()); |
michael@0 | 429 | PropertyValidator.getInstance().assertOneOrLess(Property.DUE, getProperties()); |
michael@0 | 430 | PropertyValidator.getInstance().assertOneOrLess(Property.DURATION, getProperties()); |
michael@0 | 431 | PropertyValidator.getInstance().assertOneOrLess(Property.GEO, getProperties()); |
michael@0 | 432 | PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties()); |
michael@0 | 433 | PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION, getProperties()); |
michael@0 | 434 | PropertyValidator.getInstance().assertOneOrLess(Property.PERCENT_COMPLETE, getProperties()); |
michael@0 | 435 | PropertyValidator.getInstance().assertOneOrLess(Property.RESOURCES, getProperties()); |
michael@0 | 436 | PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties()); |
michael@0 | 437 | PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties()); |
michael@0 | 438 | |
michael@0 | 439 | PropertyValidator.getInstance().assertNone(Property.RECURRENCE_ID, getProperties()); |
michael@0 | 440 | PropertyValidator.getInstance().assertNone(Property.REQUEST_STATUS, getProperties()); |
michael@0 | 441 | |
michael@0 | 442 | for (final Iterator i = getAlarms().iterator(); i.hasNext();) { |
michael@0 | 443 | final VAlarm alarm = (VAlarm) i.next(); |
michael@0 | 444 | alarm.validate(Method.ADD); |
michael@0 | 445 | } |
michael@0 | 446 | } |
michael@0 | 447 | } |
michael@0 | 448 | |
michael@0 | 449 | /** |
michael@0 | 450 | * <pre> |
michael@0 | 451 | * Component/Property Presence |
michael@0 | 452 | * ------------------- --------------------------------------------- |
michael@0 | 453 | * METHOD 1 MUST be "CANCEL" |
michael@0 | 454 | * VTODO 1 |
michael@0 | 455 | * ATTENDEE 0+ include all "Attendees" being removed from |
michael@0 | 456 | * the todo. MUST include all "Attendees" if |
michael@0 | 457 | * the entire todo is cancelled. |
michael@0 | 458 | * UID 1 MUST echo original UID |
michael@0 | 459 | * DTSTAMP 1 |
michael@0 | 460 | * ORGANIZER 1 |
michael@0 | 461 | * SEQUENCE 1 |
michael@0 | 462 | * |
michael@0 | 463 | * ATTACH 0+ |
michael@0 | 464 | * CATEGORIES 0 or 1 This property MAY contain a list of values |
michael@0 | 465 | * CLASS 0 or 1 |
michael@0 | 466 | * COMMENT 0 or 1 |
michael@0 | 467 | * CONTACT 0+ |
michael@0 | 468 | * CREATED 0 or 1 |
michael@0 | 469 | * DESCRIPTION 0 or 1 |
michael@0 | 470 | * DTSTART 0 or 1 |
michael@0 | 471 | * DUE 0 or 1 If present DURATION MUST NOT be present |
michael@0 | 472 | * DURATION 0 or 1 If present DUE MUST NOT be present |
michael@0 | 473 | * EXDATE 0+ |
michael@0 | 474 | * EXRULE 0+ |
michael@0 | 475 | * GEO 0 or 1 |
michael@0 | 476 | * LAST-MODIFIED 0 or 1 |
michael@0 | 477 | * LOCATION 0 or 1 |
michael@0 | 478 | * PERCENT-COMPLETE 0 or 1 |
michael@0 | 479 | * RDATE 0+ |
michael@0 | 480 | * RECURRENCE-ID 0 or 1 MUST only if referring to one or more |
michael@0 | 481 | * instances of a recurring calendar |
michael@0 | 482 | * component. Otherwise it MUST NOT be |
michael@0 | 483 | * present. |
michael@0 | 484 | * RELATED-TO 0+ |
michael@0 | 485 | * RESOURCES 0 or 1 This property MAY contain a list of values |
michael@0 | 486 | * RRULE 0+ |
michael@0 | 487 | * PRIORITY 0 or 1 |
michael@0 | 488 | * STATUS 0 or 1 If present it MUST be set to "CANCELLED". |
michael@0 | 489 | * MUST NOT be used if purpose is to remove |
michael@0 | 490 | * "ATTENDEES" rather than cancel the entire |
michael@0 | 491 | * VTODO. |
michael@0 | 492 | * URL 0 or 1 |
michael@0 | 493 | * X-PROPERTY 0+ |
michael@0 | 494 | * |
michael@0 | 495 | * REQUEST-STATUS 0 |
michael@0 | 496 | * |
michael@0 | 497 | * VTIMEZONE 0 or 1 MUST be present if any date/time refers to |
michael@0 | 498 | * a timezone |
michael@0 | 499 | * X-COMPONENT 0+ |
michael@0 | 500 | * |
michael@0 | 501 | * VALARM 0 |
michael@0 | 502 | * VEVENT 0 |
michael@0 | 503 | * VFREEBUSY 0 |
michael@0 | 504 | * </pre> |
michael@0 | 505 | * |
michael@0 | 506 | */ |
michael@0 | 507 | private class CancelValidator implements Validator { |
michael@0 | 508 | |
michael@0 | 509 | private static final long serialVersionUID = 1L; |
michael@0 | 510 | |
michael@0 | 511 | public void validate() throws ValidationException { |
michael@0 | 512 | PropertyValidator.getInstance().assertOne(Property.UID, getProperties()); |
michael@0 | 513 | PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties()); |
michael@0 | 514 | PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties()); |
michael@0 | 515 | PropertyValidator.getInstance().assertOne(Property.SEQUENCE, getProperties()); |
michael@0 | 516 | |
michael@0 | 517 | PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties()); |
michael@0 | 518 | PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties()); |
michael@0 | 519 | PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties()); |
michael@0 | 520 | PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, getProperties()); |
michael@0 | 521 | PropertyValidator.getInstance().assertOneOrLess(Property.DTSTART, getProperties()); |
michael@0 | 522 | PropertyValidator.getInstance().assertOneOrLess(Property.DUE, getProperties()); |
michael@0 | 523 | PropertyValidator.getInstance().assertOneOrLess(Property.DURATION, getProperties()); |
michael@0 | 524 | PropertyValidator.getInstance().assertOneOrLess(Property.GEO, getProperties()); |
michael@0 | 525 | PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties()); |
michael@0 | 526 | PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION, getProperties()); |
michael@0 | 527 | PropertyValidator.getInstance().assertOneOrLess(Property.PERCENT_COMPLETE, getProperties()); |
michael@0 | 528 | PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, getProperties()); |
michael@0 | 529 | PropertyValidator.getInstance().assertOneOrLess(Property.RESOURCES, getProperties()); |
michael@0 | 530 | PropertyValidator.getInstance().assertOneOrLess(Property.PRIORITY, getProperties()); |
michael@0 | 531 | PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties()); |
michael@0 | 532 | PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties()); |
michael@0 | 533 | |
michael@0 | 534 | PropertyValidator.getInstance().assertNone(Property.REQUEST_STATUS, getProperties()); |
michael@0 | 535 | |
michael@0 | 536 | ComponentValidator.assertNone(Component.VALARM, getAlarms()); |
michael@0 | 537 | } |
michael@0 | 538 | } |
michael@0 | 539 | |
michael@0 | 540 | /** |
michael@0 | 541 | * <pre> |
michael@0 | 542 | * Component/Property Presence |
michael@0 | 543 | * ------------------- ---------------------------------------------- |
michael@0 | 544 | * METHOD 1 MUST be "COUNTER" |
michael@0 | 545 | * VTODO 1 |
michael@0 | 546 | * ATTENDEE 1+ |
michael@0 | 547 | * DTSTAMP 1 |
michael@0 | 548 | * ORGANIZER 1 |
michael@0 | 549 | * PRIORITY 1 |
michael@0 | 550 | * SUMMARY 1 Can be null |
michael@0 | 551 | * UID 1 |
michael@0 | 552 | * |
michael@0 | 553 | * ATTACH 0+ |
michael@0 | 554 | * CATEGORIES 0 or 1 This property MAY contain a list of values |
michael@0 | 555 | * CLASS 0 or 1 |
michael@0 | 556 | * COMMENT 0 or 1 |
michael@0 | 557 | * CONTACT 0+ |
michael@0 | 558 | * CREATED 0 or 1 |
michael@0 | 559 | * DESCRIPTION 0 or 1 Can be null |
michael@0 | 560 | * DTSTART 0 or 1 |
michael@0 | 561 | * DUE 0 or 1 If present DURATION MUST NOT be present |
michael@0 | 562 | * DURATION 0 or 1 If present DUE MUST NOT be present |
michael@0 | 563 | * EXDATE 0+ |
michael@0 | 564 | * EXRULE 0+ |
michael@0 | 565 | * GEO 0 or 1 |
michael@0 | 566 | * LAST-MODIFIED 0 or 1 |
michael@0 | 567 | * LOCATION 0 or 1 |
michael@0 | 568 | * PERCENT-COMPLETE 0 or 1 |
michael@0 | 569 | * RDATE 0+ |
michael@0 | 570 | * RECURRENCE-ID 0 or 1 MUST only 3.5if referring to an instance of a |
michael@0 | 571 | * recurring calendar component. Otherwise it |
michael@0 | 572 | * MUST NOT be present. |
michael@0 | 573 | * RELATED-TO 0+ |
michael@0 | 574 | * REQUEST-STATUS 0+ |
michael@0 | 575 | * RESOURCES 0 or 1 This property MAY contain a list of values |
michael@0 | 576 | * RRULE 0 or 1 |
michael@0 | 577 | * SEQUENCE 0 or 1 MUST echo the original SEQUENCE number. |
michael@0 | 578 | * MUST be present if non-zero. MAY be present |
michael@0 | 579 | * if zero. |
michael@0 | 580 | * STATUS 0 or 1 MAY be one of COMPLETED/NEEDS ACTION/IN- |
michael@0 | 581 | * PROCESS/CANCELLED |
michael@0 | 582 | * URL 0 or 1 |
michael@0 | 583 | * X-PROPERTY 0+ |
michael@0 | 584 | * |
michael@0 | 585 | * |
michael@0 | 586 | * VALARM 0+ |
michael@0 | 587 | * VTIMEZONE 0 or 1 MUST be present if any date/time refers to |
michael@0 | 588 | * a timezone |
michael@0 | 589 | * X-COMPONENT 0+ |
michael@0 | 590 | * |
michael@0 | 591 | * VEVENT 0 |
michael@0 | 592 | * VFREEBUSY 0 |
michael@0 | 593 | * </pre> |
michael@0 | 594 | * |
michael@0 | 595 | */ |
michael@0 | 596 | private class CounterValidator implements Validator { |
michael@0 | 597 | |
michael@0 | 598 | private static final long serialVersionUID = 1L; |
michael@0 | 599 | |
michael@0 | 600 | public void validate() throws ValidationException { |
michael@0 | 601 | PropertyValidator.getInstance().assertOneOrMore(Property.ATTENDEE, getProperties()); |
michael@0 | 602 | |
michael@0 | 603 | PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties()); |
michael@0 | 604 | PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties()); |
michael@0 | 605 | PropertyValidator.getInstance().assertOne(Property.PRIORITY, getProperties()); |
michael@0 | 606 | PropertyValidator.getInstance().assertOne(Property.SUMMARY, getProperties()); |
michael@0 | 607 | PropertyValidator.getInstance().assertOne(Property.UID, getProperties()); |
michael@0 | 608 | |
michael@0 | 609 | PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties()); |
michael@0 | 610 | PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties()); |
michael@0 | 611 | PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties()); |
michael@0 | 612 | PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, getProperties()); |
michael@0 | 613 | PropertyValidator.getInstance().assertOneOrLess(Property.DTSTART, getProperties()); |
michael@0 | 614 | PropertyValidator.getInstance().assertOneOrLess(Property.DUE, getProperties()); |
michael@0 | 615 | PropertyValidator.getInstance().assertOneOrLess(Property.DURATION, getProperties()); |
michael@0 | 616 | PropertyValidator.getInstance().assertOneOrLess(Property.GEO, getProperties()); |
michael@0 | 617 | PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties()); |
michael@0 | 618 | PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION, getProperties()); |
michael@0 | 619 | PropertyValidator.getInstance().assertOneOrLess(Property.PERCENT_COMPLETE, getProperties()); |
michael@0 | 620 | PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, getProperties()); |
michael@0 | 621 | PropertyValidator.getInstance().assertOneOrLess(Property.RESOURCES, getProperties()); |
michael@0 | 622 | PropertyValidator.getInstance().assertOneOrLess(Property.RRULE, getProperties()); |
michael@0 | 623 | PropertyValidator.getInstance().assertOneOrLess(Property.SEQUENCE, getProperties()); |
michael@0 | 624 | PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties()); |
michael@0 | 625 | PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties()); |
michael@0 | 626 | |
michael@0 | 627 | for (final Iterator i = getAlarms().iterator(); i.hasNext();) { |
michael@0 | 628 | final VAlarm alarm = (VAlarm) i.next(); |
michael@0 | 629 | alarm.validate(Method.COUNTER); |
michael@0 | 630 | } |
michael@0 | 631 | } |
michael@0 | 632 | } |
michael@0 | 633 | |
michael@0 | 634 | /** |
michael@0 | 635 | * <pre> |
michael@0 | 636 | * Component/Property Presence |
michael@0 | 637 | * ------------------- --------------------------------------------- |
michael@0 | 638 | * METHOD 1 MUST be "DECLINECOUNTER" |
michael@0 | 639 | * |
michael@0 | 640 | * VTODO 1 |
michael@0 | 641 | * ATTENDEE 1+ MUST for all attendees |
michael@0 | 642 | * DTSTAMP 1 |
michael@0 | 643 | * ORGANIZER 1 |
michael@0 | 644 | * SEQUENCE 1 MUST echo the original SEQUENCE number |
michael@0 | 645 | * UID 1 MUST echo original UID |
michael@0 | 646 | * ATTACH 0+ |
michael@0 | 647 | * CATEGORIES 0 or 1 This property may contain a list of values |
michael@0 | 648 | * CLASS 0 or 1 |
michael@0 | 649 | * COMMENT 0 or 1 |
michael@0 | 650 | * CONTACT 0+ |
michael@0 | 651 | * CREATED 0 or 1 |
michael@0 | 652 | * DESCRIPTION 0 or 1 |
michael@0 | 653 | * DTSTART 0 or 1 |
michael@0 | 654 | * DUE 0 or 1 If present DURATION MUST NOT be present |
michael@0 | 655 | * DURATION 0 or 1 If present DUE MUST NOT be present |
michael@0 | 656 | * EXDATE 0+ |
michael@0 | 657 | * EXRULE 0+ |
michael@0 | 658 | * GEO 0 or 1 |
michael@0 | 659 | * LAST-MODIFIED 0 or 1 |
michael@0 | 660 | * LOCATION 0 or 1 |
michael@0 | 661 | * PERCENT-COMPLETE 0 or 1 |
michael@0 | 662 | * PRIORITY 0 or 1 |
michael@0 | 663 | * RDATE 0+ |
michael@0 | 664 | * RECURRENCE-ID 0 or 1 MUST only if referring to an instance of a |
michael@0 | 665 | * recurring calendar component. Otherwise |
michael@0 | 666 | * it MUST NOT be present. |
michael@0 | 667 | * RELATED-TO 0+ |
michael@0 | 668 | * REQUEST-STATUS 0+ |
michael@0 | 669 | * RESOURCES 0 or 1 This property MAY contain a list of values |
michael@0 | 670 | * RRULE 0+ |
michael@0 | 671 | * STATUS 0 or 1 MAY be one of COMPLETED/NEEDS ACTION/IN- |
michael@0 | 672 | * PROCESS |
michael@0 | 673 | * URL 0 or 1 |
michael@0 | 674 | * X-PROPERTY 0+ |
michael@0 | 675 | * |
michael@0 | 676 | * VTIMEZONE 0+ MUST be present if any date/time refers to |
michael@0 | 677 | * a timezone |
michael@0 | 678 | * X-COMPONENT 0+ |
michael@0 | 679 | * |
michael@0 | 680 | * VALARM 0 |
michael@0 | 681 | * VEVENT 0 |
michael@0 | 682 | * VFREEBUSY 0 |
michael@0 | 683 | * </pre> |
michael@0 | 684 | * |
michael@0 | 685 | */ |
michael@0 | 686 | private class DeclineCounterValidator implements Validator { |
michael@0 | 687 | |
michael@0 | 688 | private static final long serialVersionUID = 1L; |
michael@0 | 689 | |
michael@0 | 690 | public void validate() throws ValidationException { |
michael@0 | 691 | PropertyValidator.getInstance().assertOneOrMore(Property.ATTENDEE, getProperties()); |
michael@0 | 692 | |
michael@0 | 693 | PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties()); |
michael@0 | 694 | PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties()); |
michael@0 | 695 | PropertyValidator.getInstance().assertOne(Property.SEQUENCE, getProperties()); |
michael@0 | 696 | PropertyValidator.getInstance().assertOne(Property.UID, getProperties()); |
michael@0 | 697 | |
michael@0 | 698 | PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties()); |
michael@0 | 699 | PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties()); |
michael@0 | 700 | PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties()); |
michael@0 | 701 | PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, getProperties()); |
michael@0 | 702 | PropertyValidator.getInstance().assertOneOrLess(Property.DTSTART, getProperties()); |
michael@0 | 703 | PropertyValidator.getInstance().assertOneOrLess(Property.DUE, getProperties()); |
michael@0 | 704 | PropertyValidator.getInstance().assertOneOrLess(Property.DURATION, getProperties()); |
michael@0 | 705 | PropertyValidator.getInstance().assertOneOrLess(Property.GEO, getProperties()); |
michael@0 | 706 | PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties()); |
michael@0 | 707 | PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION, getProperties()); |
michael@0 | 708 | PropertyValidator.getInstance().assertOneOrLess(Property.PERCENT_COMPLETE, getProperties()); |
michael@0 | 709 | PropertyValidator.getInstance().assertOneOrLess(Property.PRIORITY, getProperties()); |
michael@0 | 710 | PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, getProperties()); |
michael@0 | 711 | PropertyValidator.getInstance().assertOneOrLess(Property.RESOURCES, getProperties()); |
michael@0 | 712 | PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties()); |
michael@0 | 713 | PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties()); |
michael@0 | 714 | |
michael@0 | 715 | ComponentValidator.assertNone(Component.VALARM, getAlarms()); |
michael@0 | 716 | } |
michael@0 | 717 | } |
michael@0 | 718 | |
michael@0 | 719 | /** |
michael@0 | 720 | * <pre> |
michael@0 | 721 | * Component/Property Presence |
michael@0 | 722 | * ------------------- ---------------------------------------------- |
michael@0 | 723 | * METHOD 1 MUST be "PUBLISH" |
michael@0 | 724 | * VTODO 1+ |
michael@0 | 725 | * DTSTAMP 1 |
michael@0 | 726 | * DTSTART 1 |
michael@0 | 727 | * ORGANIZER 1 |
michael@0 | 728 | * PRIORITY 1 |
michael@0 | 729 | * SEQUENCE 0 or 1 MUST be present if value is greater than |
michael@0 | 730 | * 0, MAY be present if 0 |
michael@0 | 731 | * SUMMARY 1 Can be null. |
michael@0 | 732 | * UID 1 |
michael@0 | 733 | * |
michael@0 | 734 | * ATTACH 0+ |
michael@0 | 735 | * CATEGORIES 0 or 1 This property may contain a list of values |
michael@0 | 736 | * CLASS 0 or 1 |
michael@0 | 737 | * COMMENT 0 or 1 |
michael@0 | 738 | * CONTACT 0+ |
michael@0 | 739 | * CREATED 0 or 1 |
michael@0 | 740 | * DESCRIPTION 0 or 1 Can be null |
michael@0 | 741 | * DUE 0 or 1 If present DURATION MUST NOT be present |
michael@0 | 742 | * DURATION 0 or 1 If present DUE MUST NOT be present |
michael@0 | 743 | * EXDATE 0+ |
michael@0 | 744 | * EXRULE 0+ |
michael@0 | 745 | * GEO 0 or 1 |
michael@0 | 746 | * LAST-MODIFIED 0 or 1 |
michael@0 | 747 | * LOCATION 0 or 1 |
michael@0 | 748 | * PERCENT-COMPLETE 0 or 1 |
michael@0 | 749 | * RDATE 0+ |
michael@0 | 750 | * RECURRENCE-ID 0 or 1 MUST only if referring to an instance of a |
michael@0 | 751 | * recurring calendar component. Otherwise |
michael@0 | 752 | * it MUST NOT be present. |
michael@0 | 753 | * |
michael@0 | 754 | * RELATED-TO 0+ |
michael@0 | 755 | * RESOURCES 0 or 1 This property may contain a list of values |
michael@0 | 756 | * RRULE 0+ |
michael@0 | 757 | * STATUS 0 or 1 MAY be one of COMPLETED/NEEDS ACTION/IN- |
michael@0 | 758 | * PROCESS/CANCELLED |
michael@0 | 759 | * URL 0 or 1 |
michael@0 | 760 | * X-PROPERTY 0+ |
michael@0 | 761 | * |
michael@0 | 762 | * ATTENDEE 0 |
michael@0 | 763 | * REQUEST-STATUS 0 |
michael@0 | 764 | * |
michael@0 | 765 | * VTIMEZONE 0+ MUST be present if any date/time refers to |
michael@0 | 766 | * a timezone |
michael@0 | 767 | * VALARM 0+ |
michael@0 | 768 | * X-COMPONENT 0+ |
michael@0 | 769 | * |
michael@0 | 770 | * VFREEBUSY 0 |
michael@0 | 771 | * VEVENT 0 |
michael@0 | 772 | * VJOURNAL 0 |
michael@0 | 773 | * </pre> |
michael@0 | 774 | * |
michael@0 | 775 | */ |
michael@0 | 776 | private class PublishValidator implements Validator { |
michael@0 | 777 | |
michael@0 | 778 | private static final long serialVersionUID = 1L; |
michael@0 | 779 | |
michael@0 | 780 | public void validate() throws ValidationException { |
michael@0 | 781 | PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties()); |
michael@0 | 782 | |
michael@0 | 783 | if (!CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION)) { |
michael@0 | 784 | PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties()); |
michael@0 | 785 | PropertyValidator.getInstance().assertOne(Property.PRIORITY, getProperties()); |
michael@0 | 786 | } |
michael@0 | 787 | |
michael@0 | 788 | PropertyValidator.getInstance().assertOne(Property.SUMMARY, getProperties()); |
michael@0 | 789 | PropertyValidator.getInstance().assertOne(Property.UID, getProperties()); |
michael@0 | 790 | |
michael@0 | 791 | // DTSTART: RFC2446 conflicts with RCF2445.. |
michael@0 | 792 | PropertyValidator.getInstance().assertOneOrLess(Property.DTSTART, getProperties()); |
michael@0 | 793 | PropertyValidator.getInstance().assertOneOrLess(Property.SEQUENCE, getProperties()); |
michael@0 | 794 | PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties()); |
michael@0 | 795 | PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties()); |
michael@0 | 796 | PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties()); |
michael@0 | 797 | PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, getProperties()); |
michael@0 | 798 | PropertyValidator.getInstance().assertOneOrLess(Property.DUE, getProperties()); |
michael@0 | 799 | PropertyValidator.getInstance().assertOneOrLess(Property.DURATION, getProperties()); |
michael@0 | 800 | PropertyValidator.getInstance().assertOneOrLess(Property.GEO, getProperties()); |
michael@0 | 801 | PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties()); |
michael@0 | 802 | PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION, getProperties()); |
michael@0 | 803 | PropertyValidator.getInstance().assertOneOrLess(Property.PERCENT_COMPLETE, getProperties()); |
michael@0 | 804 | PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, getProperties()); |
michael@0 | 805 | PropertyValidator.getInstance().assertOneOrLess(Property.RESOURCES, getProperties()); |
michael@0 | 806 | PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties()); |
michael@0 | 807 | PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties()); |
michael@0 | 808 | |
michael@0 | 809 | PropertyValidator.getInstance().assertNone(Property.ATTENDEE, getProperties()); |
michael@0 | 810 | PropertyValidator.getInstance().assertNone(Property.REQUEST_STATUS, getProperties()); |
michael@0 | 811 | |
michael@0 | 812 | for (final Iterator i = getAlarms().iterator(); i.hasNext();) { |
michael@0 | 813 | final VAlarm alarm = (VAlarm) i.next(); |
michael@0 | 814 | alarm.validate(Method.PUBLISH); |
michael@0 | 815 | } |
michael@0 | 816 | } |
michael@0 | 817 | } |
michael@0 | 818 | |
michael@0 | 819 | /** |
michael@0 | 820 | * <pre> |
michael@0 | 821 | * Component/Property Presence |
michael@0 | 822 | * ------------------- --------------------------------------------- |
michael@0 | 823 | * METHOD 1 MUST be "REFRESH" |
michael@0 | 824 | * VTODO 1 |
michael@0 | 825 | * ATTENDEE 1 |
michael@0 | 826 | * DTSTAMP 1 |
michael@0 | 827 | * UID 1 MUST echo original UID |
michael@0 | 828 | * |
michael@0 | 829 | * RECURRENCE-ID 0 or 1 MUST only if referring to an instance of a |
michael@0 | 830 | * Recurring calendar component. Otherwise it |
michael@0 | 831 | * MUST NOT be present |
michael@0 | 832 | * X-PROPERTY 0+ |
michael@0 | 833 | * |
michael@0 | 834 | * ATTACH 0 |
michael@0 | 835 | * CATEGORIES 0 |
michael@0 | 836 | * CLASS 0 |
michael@0 | 837 | * COMMENT 0 |
michael@0 | 838 | * CONTACT 0 |
michael@0 | 839 | * CREATED 0 |
michael@0 | 840 | * DESCRIPTION 0 |
michael@0 | 841 | * DTSTART 0 |
michael@0 | 842 | * DUE 0 |
michael@0 | 843 | * DURATION 0 |
michael@0 | 844 | * EXDATE 0 |
michael@0 | 845 | * EXRULE 0 |
michael@0 | 846 | * GEO 0 |
michael@0 | 847 | * LAST-MODIFIED 0 |
michael@0 | 848 | * LOCATION 0 |
michael@0 | 849 | * ORGANIZER 0 |
michael@0 | 850 | * PERCENT-COMPLETE 0 |
michael@0 | 851 | * PRIORITY 0 |
michael@0 | 852 | * RDATE 0 |
michael@0 | 853 | * RELATED-TO 0 |
michael@0 | 854 | * REQUEST-STATUS 0 |
michael@0 | 855 | * RESOURCES 0 |
michael@0 | 856 | * RRULE 0 |
michael@0 | 857 | * SEQUENCE 0 |
michael@0 | 858 | * STATUS 0 |
michael@0 | 859 | * URL 0 |
michael@0 | 860 | * |
michael@0 | 861 | * X-COMPONENT 0+ |
michael@0 | 862 | * |
michael@0 | 863 | * VALARM 0 |
michael@0 | 864 | * VEVENT 0 |
michael@0 | 865 | * VFREEBUSY 0 |
michael@0 | 866 | * VTIMEZONE 0 |
michael@0 | 867 | * </pre> |
michael@0 | 868 | * |
michael@0 | 869 | */ |
michael@0 | 870 | private class RefreshValidator implements Validator { |
michael@0 | 871 | |
michael@0 | 872 | private static final long serialVersionUID = 1L; |
michael@0 | 873 | |
michael@0 | 874 | public void validate() throws ValidationException { |
michael@0 | 875 | PropertyValidator.getInstance().assertOne(Property.ATTENDEE, getProperties()); |
michael@0 | 876 | PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties()); |
michael@0 | 877 | PropertyValidator.getInstance().assertOne(Property.UID, getProperties()); |
michael@0 | 878 | |
michael@0 | 879 | PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, getProperties()); |
michael@0 | 880 | |
michael@0 | 881 | PropertyValidator.getInstance().assertNone(Property.ATTACH, getProperties()); |
michael@0 | 882 | PropertyValidator.getInstance().assertNone(Property.CATEGORIES, getProperties()); |
michael@0 | 883 | PropertyValidator.getInstance().assertNone(Property.CLASS, getProperties()); |
michael@0 | 884 | PropertyValidator.getInstance().assertNone(Property.CONTACT, getProperties()); |
michael@0 | 885 | PropertyValidator.getInstance().assertNone(Property.CREATED, getProperties()); |
michael@0 | 886 | PropertyValidator.getInstance().assertNone(Property.DESCRIPTION, getProperties()); |
michael@0 | 887 | PropertyValidator.getInstance().assertNone(Property.DTSTART, getProperties()); |
michael@0 | 888 | PropertyValidator.getInstance().assertNone(Property.DUE, getProperties()); |
michael@0 | 889 | PropertyValidator.getInstance().assertNone(Property.DURATION, getProperties()); |
michael@0 | 890 | PropertyValidator.getInstance().assertNone(Property.EXDATE, getProperties()); |
michael@0 | 891 | PropertyValidator.getInstance().assertNone(Property.EXRULE, getProperties()); |
michael@0 | 892 | PropertyValidator.getInstance().assertNone(Property.GEO, getProperties()); |
michael@0 | 893 | PropertyValidator.getInstance().assertNone(Property.LAST_MODIFIED, getProperties()); |
michael@0 | 894 | PropertyValidator.getInstance().assertNone(Property.LOCATION, getProperties()); |
michael@0 | 895 | PropertyValidator.getInstance().assertNone(Property.ORGANIZER, getProperties()); |
michael@0 | 896 | PropertyValidator.getInstance().assertNone(Property.PERCENT_COMPLETE, getProperties()); |
michael@0 | 897 | PropertyValidator.getInstance().assertNone(Property.PRIORITY, getProperties()); |
michael@0 | 898 | PropertyValidator.getInstance().assertNone(Property.RDATE, getProperties()); |
michael@0 | 899 | PropertyValidator.getInstance().assertNone(Property.RELATED_TO, getProperties()); |
michael@0 | 900 | PropertyValidator.getInstance().assertNone(Property.REQUEST_STATUS, getProperties()); |
michael@0 | 901 | PropertyValidator.getInstance().assertNone(Property.RESOURCES, getProperties()); |
michael@0 | 902 | PropertyValidator.getInstance().assertNone(Property.RRULE, getProperties()); |
michael@0 | 903 | PropertyValidator.getInstance().assertNone(Property.SEQUENCE, getProperties()); |
michael@0 | 904 | PropertyValidator.getInstance().assertNone(Property.STATUS, getProperties()); |
michael@0 | 905 | PropertyValidator.getInstance().assertNone(Property.URL, getProperties()); |
michael@0 | 906 | |
michael@0 | 907 | ComponentValidator.assertNone(Component.VALARM, getAlarms()); |
michael@0 | 908 | } |
michael@0 | 909 | } |
michael@0 | 910 | |
michael@0 | 911 | /** |
michael@0 | 912 | * <pre> |
michael@0 | 913 | * Component/Property Presence |
michael@0 | 914 | * ------------------- --------------------------------------------- |
michael@0 | 915 | * METHOD 1 MUST be "REPLY" |
michael@0 | 916 | * VTODO 1+ All component MUST have the same UID |
michael@0 | 917 | * ATTENDEE 1+ |
michael@0 | 918 | * DTSTAMP 1 |
michael@0 | 919 | * ORGANIZER 1 |
michael@0 | 920 | * UID 1 MUST must be the address of the replying |
michael@0 | 921 | * attendee |
michael@0 | 922 | * REQUEST-STATUS 0+ |
michael@0 | 923 | * ATTACH 0+ |
michael@0 | 924 | * CATEGORIES 0 or 1 This property may contain a list of values |
michael@0 | 925 | * CLASS 0 or 1 |
michael@0 | 926 | * COMMENT 0 or 1 |
michael@0 | 927 | * CONTACT 0+ |
michael@0 | 928 | * CREATED 0 or 1 |
michael@0 | 929 | * DESCRIPTION 0 or 1 |
michael@0 | 930 | * DTSTART 0 or 1 |
michael@0 | 931 | * DUE 0 or 1 If present DURATION MUST NOT be present |
michael@0 | 932 | * DURATION 0 or 1 If present DUE MUST NOT be present |
michael@0 | 933 | * EXDATE 0+ |
michael@0 | 934 | * EXRULE 0+ |
michael@0 | 935 | * GEO 0 or 1 |
michael@0 | 936 | * LAST-MODIFIED 0 or 1 |
michael@0 | 937 | * LOCATION 0 or 1 |
michael@0 | 938 | * PERCENT-COMPLETE 0 or 1 |
michael@0 | 939 | * PRIORITY 0 or 1 |
michael@0 | 940 | * RDATE 0+ |
michael@0 | 941 | * RELATED-TO 0+ |
michael@0 | 942 | * RESOURCES 0 or 1 This property may contain a list of values |
michael@0 | 943 | * RRULE 0+ |
michael@0 | 944 | * RECURRENCE-ID 0 or 1 MUST only if referring to an instance of a |
michael@0 | 945 | * Recurring calendar component. Otherwise it |
michael@0 | 946 | * MUST NOT be present |
michael@0 | 947 | * SEQUENCE 0 or 1 MUST be the sequence number of |
michael@0 | 948 | * the original REQUEST if greater than 0. |
michael@0 | 949 | * MAY be present if 0. |
michael@0 | 950 | * STATUS 0 or 1 |
michael@0 | 951 | * SUMMARY 0 or 1 Can be null |
michael@0 | 952 | * URL 0 or 1 |
michael@0 | 953 | * X-PROPERTY 0+ |
michael@0 | 954 | * |
michael@0 | 955 | * VTIMEZONE 0 or 1 MUST be present if any date/time refers to |
michael@0 | 956 | * a timezone |
michael@0 | 957 | * X-COMPONENT 0+ |
michael@0 | 958 | * |
michael@0 | 959 | * VALARM 0 |
michael@0 | 960 | * VEVENT 0 |
michael@0 | 961 | * VFREEBUSY 0 |
michael@0 | 962 | * </pre> |
michael@0 | 963 | * |
michael@0 | 964 | */ |
michael@0 | 965 | private class ReplyValidator implements Validator { |
michael@0 | 966 | |
michael@0 | 967 | private static final long serialVersionUID = 1L; |
michael@0 | 968 | |
michael@0 | 969 | public void validate() throws ValidationException { |
michael@0 | 970 | PropertyValidator.getInstance().assertOneOrMore(Property.ATTENDEE, getProperties()); |
michael@0 | 971 | |
michael@0 | 972 | PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties()); |
michael@0 | 973 | PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties()); |
michael@0 | 974 | PropertyValidator.getInstance().assertOne(Property.UID, getProperties()); |
michael@0 | 975 | |
michael@0 | 976 | PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties()); |
michael@0 | 977 | PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties()); |
michael@0 | 978 | PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties()); |
michael@0 | 979 | PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, getProperties()); |
michael@0 | 980 | PropertyValidator.getInstance().assertOneOrLess(Property.DTSTART, getProperties()); |
michael@0 | 981 | PropertyValidator.getInstance().assertOneOrLess(Property.DUE, getProperties()); |
michael@0 | 982 | PropertyValidator.getInstance().assertOneOrLess(Property.DURATION, getProperties()); |
michael@0 | 983 | PropertyValidator.getInstance().assertOneOrLess(Property.GEO, getProperties()); |
michael@0 | 984 | PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties()); |
michael@0 | 985 | PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION, getProperties()); |
michael@0 | 986 | PropertyValidator.getInstance().assertOneOrLess(Property.PERCENT_COMPLETE, getProperties()); |
michael@0 | 987 | PropertyValidator.getInstance().assertOneOrLess(Property.PRIORITY, getProperties()); |
michael@0 | 988 | PropertyValidator.getInstance().assertOneOrLess(Property.RESOURCES, getProperties()); |
michael@0 | 989 | PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, getProperties()); |
michael@0 | 990 | PropertyValidator.getInstance().assertOneOrLess(Property.SEQUENCE, getProperties()); |
michael@0 | 991 | PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties()); |
michael@0 | 992 | PropertyValidator.getInstance().assertOneOrLess(Property.SUMMARY, getProperties()); |
michael@0 | 993 | PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties()); |
michael@0 | 994 | |
michael@0 | 995 | ComponentValidator.assertNone(Component.VALARM, getAlarms()); |
michael@0 | 996 | } |
michael@0 | 997 | } |
michael@0 | 998 | |
michael@0 | 999 | /** |
michael@0 | 1000 | * <pre> |
michael@0 | 1001 | * Component/Property Presence |
michael@0 | 1002 | * ------------------- ---------------------------------------------- |
michael@0 | 1003 | * METHOD 1 MUST be "REQUEST" |
michael@0 | 1004 | * VTODO 1+ All components must have the same UID |
michael@0 | 1005 | * ATTENDEE 1+ |
michael@0 | 1006 | * DTSTAMP 1 |
michael@0 | 1007 | * DTSTART 1 |
michael@0 | 1008 | * ORGANIZER 1 |
michael@0 | 1009 | * PRIORITY 1 |
michael@0 | 1010 | * SEQUENCE 0 or 1 MUST be present if value is greater than |
michael@0 | 1011 | * 0, MAY be present if 0 |
michael@0 | 1012 | * SUMMARY 1 Can be null. |
michael@0 | 1013 | * UID 1 |
michael@0 | 1014 | * |
michael@0 | 1015 | * ATTACH 0+ |
michael@0 | 1016 | * CATEGORIES 0 or 1 This property may contain a list of |
michael@0 | 1017 | * values |
michael@0 | 1018 | * CLASS 0 or 1 |
michael@0 | 1019 | * COMMENT 0 or 1 |
michael@0 | 1020 | * CONTACT 0+ |
michael@0 | 1021 | * CREATED 0 or 1 |
michael@0 | 1022 | * DESCRIPTION 0 or 1 Can be null |
michael@0 | 1023 | * DUE 0 or 1 If present DURATION MUST NOT be present |
michael@0 | 1024 | * DURATION 0 or 1 If present DUE MUST NOT be present |
michael@0 | 1025 | * EXDATE 0+ |
michael@0 | 1026 | * EXRULE 0+ |
michael@0 | 1027 | * GEO 0 or 1 |
michael@0 | 1028 | * LAST-MODIFIED 0 or 1 |
michael@0 | 1029 | * LOCATION 0 or 1 |
michael@0 | 1030 | * PERCENT-COMPLETE 0 or 1 |
michael@0 | 1031 | * RDATE 0+ |
michael@0 | 1032 | * RECURRENCE-ID 0 or 1 present if referring to an instance of a |
michael@0 | 1033 | * recurring calendar component. Otherwise |
michael@0 | 1034 | * it MUST NOT be present. |
michael@0 | 1035 | * RELATED-TO 0+ |
michael@0 | 1036 | * RESOURCES 0 or 1 This property may contain a list of |
michael@0 | 1037 | * values |
michael@0 | 1038 | * RRULE 0+ |
michael@0 | 1039 | * STATUS 0 or 1 MAY be one of COMPLETED/NEEDS ACTION/IN- |
michael@0 | 1040 | * PROCESS |
michael@0 | 1041 | * URL 0 or 1 |
michael@0 | 1042 | * X-PROPERTY 0+ |
michael@0 | 1043 | * |
michael@0 | 1044 | * REQUEST-STATUS 0 |
michael@0 | 1045 | * |
michael@0 | 1046 | * VALARM 0+ |
michael@0 | 1047 | * |
michael@0 | 1048 | * VTIMEZONE 0+ MUST be present if any date/time refers |
michael@0 | 1049 | * to a timezone |
michael@0 | 1050 | * X-COMPONENT 0+ |
michael@0 | 1051 | * |
michael@0 | 1052 | * VEVENT 0 |
michael@0 | 1053 | * VFREEBUSY 0 |
michael@0 | 1054 | * VJOURNAL 0 |
michael@0 | 1055 | * </pre> |
michael@0 | 1056 | * |
michael@0 | 1057 | */ |
michael@0 | 1058 | private class RequestValidator implements Validator { |
michael@0 | 1059 | |
michael@0 | 1060 | private static final long serialVersionUID = 1L; |
michael@0 | 1061 | |
michael@0 | 1062 | public void validate() throws ValidationException { |
michael@0 | 1063 | PropertyValidator.getInstance().assertOneOrMore(Property.ATTENDEE, getProperties()); |
michael@0 | 1064 | |
michael@0 | 1065 | PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties()); |
michael@0 | 1066 | PropertyValidator.getInstance().assertOne(Property.DTSTART, getProperties()); |
michael@0 | 1067 | PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties()); |
michael@0 | 1068 | PropertyValidator.getInstance().assertOne(Property.PRIORITY, getProperties()); |
michael@0 | 1069 | PropertyValidator.getInstance().assertOne(Property.SUMMARY, getProperties()); |
michael@0 | 1070 | PropertyValidator.getInstance().assertOne(Property.UID, getProperties()); |
michael@0 | 1071 | |
michael@0 | 1072 | PropertyValidator.getInstance().assertOneOrLess(Property.SEQUENCE, getProperties()); |
michael@0 | 1073 | PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties()); |
michael@0 | 1074 | PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties()); |
michael@0 | 1075 | PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties()); |
michael@0 | 1076 | PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, getProperties()); |
michael@0 | 1077 | PropertyValidator.getInstance().assertOneOrLess(Property.DUE, getProperties()); |
michael@0 | 1078 | PropertyValidator.getInstance().assertOneOrLess(Property.DURATION, getProperties()); |
michael@0 | 1079 | PropertyValidator.getInstance().assertOneOrLess(Property.GEO, getProperties()); |
michael@0 | 1080 | PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties()); |
michael@0 | 1081 | PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION, getProperties()); |
michael@0 | 1082 | PropertyValidator.getInstance().assertOneOrLess(Property.PERCENT_COMPLETE, getProperties()); |
michael@0 | 1083 | PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, getProperties()); |
michael@0 | 1084 | PropertyValidator.getInstance().assertOneOrLess(Property.RESOURCES, getProperties()); |
michael@0 | 1085 | PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties()); |
michael@0 | 1086 | PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties()); |
michael@0 | 1087 | |
michael@0 | 1088 | PropertyValidator.getInstance().assertNone(Property.REQUEST_STATUS, getProperties()); |
michael@0 | 1089 | |
michael@0 | 1090 | for (final Iterator i = getAlarms().iterator(); i.hasNext();) { |
michael@0 | 1091 | final VAlarm alarm = (VAlarm) i.next(); |
michael@0 | 1092 | alarm.validate(Method.REQUEST); |
michael@0 | 1093 | } |
michael@0 | 1094 | } |
michael@0 | 1095 | } |
michael@0 | 1096 | |
michael@0 | 1097 | /** |
michael@0 | 1098 | * @return the optional access classification property |
michael@0 | 1099 | */ |
michael@0 | 1100 | public final Clazz getClassification() { |
michael@0 | 1101 | return (Clazz) getProperty(Property.CLASS); |
michael@0 | 1102 | } |
michael@0 | 1103 | |
michael@0 | 1104 | /** |
michael@0 | 1105 | * @return the optional date completed property |
michael@0 | 1106 | */ |
michael@0 | 1107 | public final Completed getDateCompleted() { |
michael@0 | 1108 | return (Completed) getProperty(Property.COMPLETED); |
michael@0 | 1109 | } |
michael@0 | 1110 | |
michael@0 | 1111 | /** |
michael@0 | 1112 | * @return the optional creation-time property |
michael@0 | 1113 | */ |
michael@0 | 1114 | public final Created getCreated() { |
michael@0 | 1115 | return (Created) getProperty(Property.CREATED); |
michael@0 | 1116 | } |
michael@0 | 1117 | |
michael@0 | 1118 | /** |
michael@0 | 1119 | * @return the optional description property |
michael@0 | 1120 | */ |
michael@0 | 1121 | public final Description getDescription() { |
michael@0 | 1122 | return (Description) getProperty(Property.DESCRIPTION); |
michael@0 | 1123 | } |
michael@0 | 1124 | |
michael@0 | 1125 | /** |
michael@0 | 1126 | * Convenience method to pull the DTSTART out of the property list. |
michael@0 | 1127 | * @return The DtStart object representation of the start Date |
michael@0 | 1128 | */ |
michael@0 | 1129 | public final DtStart getStartDate() { |
michael@0 | 1130 | return (DtStart) getProperty(Property.DTSTART); |
michael@0 | 1131 | } |
michael@0 | 1132 | |
michael@0 | 1133 | /** |
michael@0 | 1134 | * @return the optional geographic position property |
michael@0 | 1135 | */ |
michael@0 | 1136 | public final Geo getGeographicPos() { |
michael@0 | 1137 | return (Geo) getProperty(Property.GEO); |
michael@0 | 1138 | } |
michael@0 | 1139 | |
michael@0 | 1140 | /** |
michael@0 | 1141 | * @return the optional last-modified property |
michael@0 | 1142 | */ |
michael@0 | 1143 | public final LastModified getLastModified() { |
michael@0 | 1144 | return (LastModified) getProperty(Property.LAST_MODIFIED); |
michael@0 | 1145 | } |
michael@0 | 1146 | |
michael@0 | 1147 | /** |
michael@0 | 1148 | * @return the optional location property |
michael@0 | 1149 | */ |
michael@0 | 1150 | public final Location getLocation() { |
michael@0 | 1151 | return (Location) getProperty(Property.LOCATION); |
michael@0 | 1152 | } |
michael@0 | 1153 | |
michael@0 | 1154 | /** |
michael@0 | 1155 | * @return the optional organizer property |
michael@0 | 1156 | */ |
michael@0 | 1157 | public final Organizer getOrganizer() { |
michael@0 | 1158 | return (Organizer) getProperty(Property.ORGANIZER); |
michael@0 | 1159 | } |
michael@0 | 1160 | |
michael@0 | 1161 | /** |
michael@0 | 1162 | * @return the optional percentage complete property |
michael@0 | 1163 | */ |
michael@0 | 1164 | public final PercentComplete getPercentComplete() { |
michael@0 | 1165 | return (PercentComplete) getProperty(Property.PERCENT_COMPLETE); |
michael@0 | 1166 | } |
michael@0 | 1167 | |
michael@0 | 1168 | /** |
michael@0 | 1169 | * @return the optional priority property |
michael@0 | 1170 | */ |
michael@0 | 1171 | public final Priority getPriority() { |
michael@0 | 1172 | return (Priority) getProperty(Property.PRIORITY); |
michael@0 | 1173 | } |
michael@0 | 1174 | |
michael@0 | 1175 | /** |
michael@0 | 1176 | * @return the optional date-stamp property |
michael@0 | 1177 | */ |
michael@0 | 1178 | public final DtStamp getDateStamp() { |
michael@0 | 1179 | return (DtStamp) getProperty(Property.DTSTAMP); |
michael@0 | 1180 | } |
michael@0 | 1181 | |
michael@0 | 1182 | /** |
michael@0 | 1183 | * @return the optional sequence number property |
michael@0 | 1184 | */ |
michael@0 | 1185 | public final Sequence getSequence() { |
michael@0 | 1186 | return (Sequence) getProperty(Property.SEQUENCE); |
michael@0 | 1187 | } |
michael@0 | 1188 | |
michael@0 | 1189 | /** |
michael@0 | 1190 | * @return the optional status property |
michael@0 | 1191 | */ |
michael@0 | 1192 | public final Status getStatus() { |
michael@0 | 1193 | return (Status) getProperty(Property.STATUS); |
michael@0 | 1194 | } |
michael@0 | 1195 | |
michael@0 | 1196 | /** |
michael@0 | 1197 | * @return the optional summary property |
michael@0 | 1198 | */ |
michael@0 | 1199 | public final Summary getSummary() { |
michael@0 | 1200 | return (Summary) getProperty(Property.SUMMARY); |
michael@0 | 1201 | } |
michael@0 | 1202 | |
michael@0 | 1203 | /** |
michael@0 | 1204 | * @return the optional URL property |
michael@0 | 1205 | */ |
michael@0 | 1206 | public final Url getUrl() { |
michael@0 | 1207 | return (Url) getProperty(Property.URL); |
michael@0 | 1208 | } |
michael@0 | 1209 | |
michael@0 | 1210 | /** |
michael@0 | 1211 | * @return the optional recurrence identifier property |
michael@0 | 1212 | */ |
michael@0 | 1213 | public final RecurrenceId getRecurrenceId() { |
michael@0 | 1214 | return (RecurrenceId) getProperty(Property.RECURRENCE_ID); |
michael@0 | 1215 | } |
michael@0 | 1216 | |
michael@0 | 1217 | /** |
michael@0 | 1218 | * @return the optional Duration property |
michael@0 | 1219 | */ |
michael@0 | 1220 | public final Duration getDuration() { |
michael@0 | 1221 | return (Duration) getProperty(Property.DURATION); |
michael@0 | 1222 | } |
michael@0 | 1223 | |
michael@0 | 1224 | /** |
michael@0 | 1225 | * @return the optional due property |
michael@0 | 1226 | */ |
michael@0 | 1227 | public final Due getDue() { |
michael@0 | 1228 | return (Due) getProperty(Property.DUE); |
michael@0 | 1229 | } |
michael@0 | 1230 | |
michael@0 | 1231 | /** |
michael@0 | 1232 | * Returns the UID property of this component if available. |
michael@0 | 1233 | * @return a Uid instance, or null if no UID property exists |
michael@0 | 1234 | */ |
michael@0 | 1235 | public final Uid getUid() { |
michael@0 | 1236 | return (Uid) getProperty(Property.UID); |
michael@0 | 1237 | } |
michael@0 | 1238 | |
michael@0 | 1239 | /** |
michael@0 | 1240 | * {@inheritDoc} |
michael@0 | 1241 | */ |
michael@0 | 1242 | public boolean equals(final Object arg0) { |
michael@0 | 1243 | if (arg0 instanceof VToDo) { |
michael@0 | 1244 | return super.equals(arg0) |
michael@0 | 1245 | && ObjectUtils.equals(alarms, ((VToDo) arg0).getAlarms()); |
michael@0 | 1246 | } |
michael@0 | 1247 | return super.equals(arg0); |
michael@0 | 1248 | } |
michael@0 | 1249 | |
michael@0 | 1250 | /** |
michael@0 | 1251 | * {@inheritDoc} |
michael@0 | 1252 | */ |
michael@0 | 1253 | public int hashCode() { |
michael@0 | 1254 | return new HashCodeBuilder().append(getName()).append(getProperties()) |
michael@0 | 1255 | .append(getAlarms()).toHashCode(); |
michael@0 | 1256 | } |
michael@0 | 1257 | |
michael@0 | 1258 | /** |
michael@0 | 1259 | * Overrides default copy method to add support for copying alarm sub-components. |
michael@0 | 1260 | * @return a copy of the instance |
michael@0 | 1261 | * @throws ParseException where an error occurs parsing data |
michael@0 | 1262 | * @throws IOException where an error occurs reading data |
michael@0 | 1263 | * @throws URISyntaxException where an invalid URI is encountered |
michael@0 | 1264 | * @see net.fortuna.ical4j.model.Component#copy() |
michael@0 | 1265 | */ |
michael@0 | 1266 | public Component copy() throws ParseException, IOException, URISyntaxException { |
michael@0 | 1267 | final VToDo copy = (VToDo) super.copy(); |
michael@0 | 1268 | copy.alarms = new ComponentList(alarms); |
michael@0 | 1269 | return copy; |
michael@0 | 1270 | } |
michael@0 | 1271 | } |