Tue, 10 Feb 2015 18:12:00 +0100
Import initial revisions of existing project AndroidCaldavSyncAdapater,
forked from upstream repository at 27e8a0f8495c92e0780d450bdf0c7cec77a03a55.
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.util.HashMap; |
michael@0 | 35 | import java.util.Map; |
michael@0 | 36 | |
michael@0 | 37 | import net.fortuna.ical4j.model.Date; |
michael@0 | 38 | import net.fortuna.ical4j.model.Property; |
michael@0 | 39 | import net.fortuna.ical4j.model.PropertyList; |
michael@0 | 40 | import net.fortuna.ical4j.model.ValidationException; |
michael@0 | 41 | import net.fortuna.ical4j.model.Validator; |
michael@0 | 42 | import net.fortuna.ical4j.model.property.Clazz; |
michael@0 | 43 | import net.fortuna.ical4j.model.property.Created; |
michael@0 | 44 | import net.fortuna.ical4j.model.property.Description; |
michael@0 | 45 | import net.fortuna.ical4j.model.property.DtStamp; |
michael@0 | 46 | import net.fortuna.ical4j.model.property.DtStart; |
michael@0 | 47 | import net.fortuna.ical4j.model.property.LastModified; |
michael@0 | 48 | import net.fortuna.ical4j.model.property.Method; |
michael@0 | 49 | import net.fortuna.ical4j.model.property.Organizer; |
michael@0 | 50 | import net.fortuna.ical4j.model.property.RecurrenceId; |
michael@0 | 51 | import net.fortuna.ical4j.model.property.Sequence; |
michael@0 | 52 | import net.fortuna.ical4j.model.property.Status; |
michael@0 | 53 | import net.fortuna.ical4j.model.property.Summary; |
michael@0 | 54 | import net.fortuna.ical4j.model.property.Uid; |
michael@0 | 55 | import net.fortuna.ical4j.model.property.Url; |
michael@0 | 56 | import net.fortuna.ical4j.util.CompatibilityHints; |
michael@0 | 57 | import net.fortuna.ical4j.util.PropertyValidator; |
michael@0 | 58 | |
michael@0 | 59 | /** |
michael@0 | 60 | * $Id$ [Apr 5, 2004] |
michael@0 | 61 | * |
michael@0 | 62 | * Defines an iCalendar VJOURNAL component. |
michael@0 | 63 | * |
michael@0 | 64 | * <pre> |
michael@0 | 65 | * 4.6.3 Journal Component |
michael@0 | 66 | * |
michael@0 | 67 | * Component Name: VJOURNAL |
michael@0 | 68 | * |
michael@0 | 69 | * Purpose: Provide a grouping of component properties that describe a |
michael@0 | 70 | * journal entry. |
michael@0 | 71 | * |
michael@0 | 72 | * Formal Definition: A "VJOURNAL" calendar component is defined by the |
michael@0 | 73 | * following notation: |
michael@0 | 74 | * |
michael@0 | 75 | * journalc = "BEGIN" ":" "VJOURNAL" CRLF |
michael@0 | 76 | * jourprop |
michael@0 | 77 | * "END" ":" "VJOURNAL" CRLF |
michael@0 | 78 | * |
michael@0 | 79 | * jourprop = *( |
michael@0 | 80 | * |
michael@0 | 81 | * ; the following are optional, |
michael@0 | 82 | * ; but MUST NOT occur more than once |
michael@0 | 83 | * |
michael@0 | 84 | * class / created / description / dtstart / dtstamp / |
michael@0 | 85 | * last-mod / organizer / recurid / seq / status / |
michael@0 | 86 | * summary / uid / url / |
michael@0 | 87 | * |
michael@0 | 88 | * ; the following are optional, |
michael@0 | 89 | * ; and MAY occur more than once |
michael@0 | 90 | * |
michael@0 | 91 | * attach / attendee / categories / comment / |
michael@0 | 92 | * contact / exdate / exrule / related / rdate / |
michael@0 | 93 | * rrule / rstatus / x-prop |
michael@0 | 94 | * |
michael@0 | 95 | * ) |
michael@0 | 96 | * </pre> |
michael@0 | 97 | * |
michael@0 | 98 | * Example 1 - Creating a journal associated with an event: |
michael@0 | 99 | * |
michael@0 | 100 | * <pre><code> |
michael@0 | 101 | * DtStart meetingDate = (DtStart) meeting.getProperties().getProperty( |
michael@0 | 102 | * Property.DTSTART); |
michael@0 | 103 | * |
michael@0 | 104 | * VJournal minutes = new VJournal(meetingDate.getTime(), |
michael@0 | 105 | * "Progress Meeting - Minutes"); |
michael@0 | 106 | * |
michael@0 | 107 | * // add timezone information.. |
michael@0 | 108 | * TzId tzParam = meetingDate.getParameters().getParmaeter(Parameter.TZID); |
michael@0 | 109 | * minutes.getProperties().getProperty(Property.DTSTART).getParameters().add( |
michael@0 | 110 | * tzParam); |
michael@0 | 111 | * |
michael@0 | 112 | * // add description.. |
michael@0 | 113 | * minutes.getProperties().add(new Description("1. Agenda.., 2. Action Items..")); |
michael@0 | 114 | * </code></pre> |
michael@0 | 115 | * |
michael@0 | 116 | * @author Ben Fortuna |
michael@0 | 117 | */ |
michael@0 | 118 | public class VJournal extends CalendarComponent { |
michael@0 | 119 | |
michael@0 | 120 | private static final long serialVersionUID = -7635140949183238830L; |
michael@0 | 121 | |
michael@0 | 122 | private final Map methodValidators = new HashMap(); |
michael@0 | 123 | { |
michael@0 | 124 | methodValidators.put(Method.ADD, new AddValidator()); |
michael@0 | 125 | methodValidators.put(Method.CANCEL, new CancelValidator()); |
michael@0 | 126 | methodValidators.put(Method.PUBLISH, new PublishValidator()); |
michael@0 | 127 | } |
michael@0 | 128 | |
michael@0 | 129 | /** |
michael@0 | 130 | * Default constructor. |
michael@0 | 131 | */ |
michael@0 | 132 | public VJournal() { |
michael@0 | 133 | super(VJOURNAL); |
michael@0 | 134 | getProperties().add(new DtStamp()); |
michael@0 | 135 | } |
michael@0 | 136 | |
michael@0 | 137 | /** |
michael@0 | 138 | * Constructor. |
michael@0 | 139 | * @param properties a list of properties |
michael@0 | 140 | */ |
michael@0 | 141 | public VJournal(final PropertyList properties) { |
michael@0 | 142 | super(VJOURNAL, properties); |
michael@0 | 143 | } |
michael@0 | 144 | |
michael@0 | 145 | /** |
michael@0 | 146 | * Constructs a new VJOURNAL instance associated with the specified time with the specified summary. |
michael@0 | 147 | * @param start the date the journal entry is associated with |
michael@0 | 148 | * @param summary the journal summary |
michael@0 | 149 | */ |
michael@0 | 150 | public VJournal(final Date start, final String summary) { |
michael@0 | 151 | this(); |
michael@0 | 152 | getProperties().add(new DtStart(start)); |
michael@0 | 153 | getProperties().add(new Summary(summary)); |
michael@0 | 154 | } |
michael@0 | 155 | |
michael@0 | 156 | /** |
michael@0 | 157 | * {@inheritDoc} |
michael@0 | 158 | */ |
michael@0 | 159 | public final void validate(final boolean recurse) |
michael@0 | 160 | throws ValidationException { |
michael@0 | 161 | |
michael@0 | 162 | if (!CompatibilityHints |
michael@0 | 163 | .isHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION)) { |
michael@0 | 164 | |
michael@0 | 165 | // From "4.8.4.7 Unique Identifier": |
michael@0 | 166 | // Conformance: The property MUST be specified in the "VEVENT", "VTODO", |
michael@0 | 167 | // "VJOURNAL" or "VFREEBUSY" calendar components. |
michael@0 | 168 | PropertyValidator.getInstance().assertOne(Property.UID, |
michael@0 | 169 | getProperties()); |
michael@0 | 170 | |
michael@0 | 171 | // From "4.8.7.2 Date/Time Stamp": |
michael@0 | 172 | // Conformance: This property MUST be included in the "VEVENT", "VTODO", |
michael@0 | 173 | // "VJOURNAL" or "VFREEBUSY" calendar components. |
michael@0 | 174 | PropertyValidator.getInstance().assertOne(Property.DTSTAMP, |
michael@0 | 175 | getProperties()); |
michael@0 | 176 | } |
michael@0 | 177 | |
michael@0 | 178 | /* |
michael@0 | 179 | * ; the following are optional, ; but MUST NOT occur more than once class / created / description / dtstart / |
michael@0 | 180 | * dtstamp / last-mod / organizer / recurid / seq / status / summary / uid / url / |
michael@0 | 181 | */ |
michael@0 | 182 | PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, |
michael@0 | 183 | getProperties()); |
michael@0 | 184 | PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, |
michael@0 | 185 | getProperties()); |
michael@0 | 186 | PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, |
michael@0 | 187 | getProperties()); |
michael@0 | 188 | PropertyValidator.getInstance().assertOneOrLess(Property.DTSTART, |
michael@0 | 189 | getProperties()); |
michael@0 | 190 | PropertyValidator.getInstance().assertOneOrLess(Property.DTSTAMP, |
michael@0 | 191 | getProperties()); |
michael@0 | 192 | PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, |
michael@0 | 193 | getProperties()); |
michael@0 | 194 | PropertyValidator.getInstance().assertOneOrLess(Property.ORGANIZER, |
michael@0 | 195 | getProperties()); |
michael@0 | 196 | PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, |
michael@0 | 197 | getProperties()); |
michael@0 | 198 | PropertyValidator.getInstance().assertOneOrLess(Property.SEQUENCE, |
michael@0 | 199 | getProperties()); |
michael@0 | 200 | PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, |
michael@0 | 201 | getProperties()); |
michael@0 | 202 | PropertyValidator.getInstance().assertOneOrLess(Property.SUMMARY, |
michael@0 | 203 | getProperties()); |
michael@0 | 204 | PropertyValidator.getInstance().assertOneOrLess(Property.UID, |
michael@0 | 205 | getProperties()); |
michael@0 | 206 | PropertyValidator.getInstance().assertOneOrLess(Property.URL, |
michael@0 | 207 | getProperties()); |
michael@0 | 208 | |
michael@0 | 209 | final Status status = (Status) getProperty(Property.STATUS); |
michael@0 | 210 | if (status != null && !Status.VJOURNAL_DRAFT.getValue().equals(status.getValue()) |
michael@0 | 211 | && !Status.VJOURNAL_FINAL.getValue().equals(status.getValue()) |
michael@0 | 212 | && !Status.VJOURNAL_CANCELLED.getValue().equals(status.getValue())) { |
michael@0 | 213 | throw new ValidationException("Status property [" |
michael@0 | 214 | + status.toString() + "] may not occur in VJOURNAL"); |
michael@0 | 215 | } |
michael@0 | 216 | |
michael@0 | 217 | /* |
michael@0 | 218 | * ; the following are optional, ; and MAY occur more than once attach / attendee / categories / comment / |
michael@0 | 219 | * contact / exdate / exrule / related / rdate / rrule / rstatus / x-prop |
michael@0 | 220 | */ |
michael@0 | 221 | |
michael@0 | 222 | if (recurse) { |
michael@0 | 223 | validateProperties(); |
michael@0 | 224 | } |
michael@0 | 225 | } |
michael@0 | 226 | |
michael@0 | 227 | /** |
michael@0 | 228 | * {@inheritDoc} |
michael@0 | 229 | */ |
michael@0 | 230 | protected Validator getValidator(Method method) { |
michael@0 | 231 | return (Validator) methodValidators.get(method); |
michael@0 | 232 | } |
michael@0 | 233 | |
michael@0 | 234 | /** |
michael@0 | 235 | * <pre> |
michael@0 | 236 | * Component/Property Presence |
michael@0 | 237 | * ------------------- ---------------------------------------------- |
michael@0 | 238 | * METHOD 1 MUST be "ADD" |
michael@0 | 239 | * VJOURNAL 1 |
michael@0 | 240 | * DESCRIPTION 1 Can be null. |
michael@0 | 241 | * DTSTAMP 1 |
michael@0 | 242 | * DTSTART 1 |
michael@0 | 243 | * ORGANIZER 1 |
michael@0 | 244 | * SEQUENCE 1 MUST be greater than 0 |
michael@0 | 245 | * UID 1 MUST match that of the original journal |
michael@0 | 246 | * |
michael@0 | 247 | * ATTACH 0+ |
michael@0 | 248 | * CATEGORIES 0 or 1 This property MAY contain a list of values |
michael@0 | 249 | * CLASS 0 or 1 |
michael@0 | 250 | * COMMENT 0 or 1 |
michael@0 | 251 | * CONTACT 0+ |
michael@0 | 252 | * CREATED 0 or 1 |
michael@0 | 253 | * EXDATE 0+ |
michael@0 | 254 | * EXRULE 0+ |
michael@0 | 255 | * LAST-MODIFIED 0 or 1 |
michael@0 | 256 | * RDATE 0+ |
michael@0 | 257 | * RELATED-TO 0+ |
michael@0 | 258 | * RRULE 0+ |
michael@0 | 259 | * STATUS 0 or 1 MAY be one of DRAFT/FINAL/CANCELLED |
michael@0 | 260 | * SUMMARY 0 or 1 Can be null |
michael@0 | 261 | * URL 0 or 1 |
michael@0 | 262 | * X-PROPERTY 0+ |
michael@0 | 263 | * |
michael@0 | 264 | * ATTENDEE 0 |
michael@0 | 265 | * RECURRENCE-ID 0 |
michael@0 | 266 | * |
michael@0 | 267 | * VALARM 0+ |
michael@0 | 268 | * VTIMEZONE 0 or 1 MUST be present if any date/time refers to |
michael@0 | 269 | * a timezone |
michael@0 | 270 | * X-COMPONENT 0+ |
michael@0 | 271 | * |
michael@0 | 272 | * VEVENT 0 |
michael@0 | 273 | * VFREEBUSY 0 |
michael@0 | 274 | * VTODO 0 |
michael@0 | 275 | * </pre> |
michael@0 | 276 | * |
michael@0 | 277 | */ |
michael@0 | 278 | private class AddValidator implements Validator { |
michael@0 | 279 | |
michael@0 | 280 | private static final long serialVersionUID = 1L; |
michael@0 | 281 | |
michael@0 | 282 | public void validate() throws ValidationException { |
michael@0 | 283 | PropertyValidator.getInstance().assertOne(Property.DESCRIPTION, getProperties()); |
michael@0 | 284 | PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties()); |
michael@0 | 285 | PropertyValidator.getInstance().assertOne(Property.DTSTART, getProperties()); |
michael@0 | 286 | PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties()); |
michael@0 | 287 | PropertyValidator.getInstance().assertOne(Property.SEQUENCE, getProperties()); |
michael@0 | 288 | PropertyValidator.getInstance().assertOne(Property.UID, getProperties()); |
michael@0 | 289 | |
michael@0 | 290 | PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties()); |
michael@0 | 291 | PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties()); |
michael@0 | 292 | PropertyValidator.getInstance().assertOneOrLess(Property.COMMENT, getProperties()); |
michael@0 | 293 | PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties()); |
michael@0 | 294 | PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties()); |
michael@0 | 295 | PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties()); |
michael@0 | 296 | PropertyValidator.getInstance().assertOneOrLess(Property.SUMMARY, getProperties()); |
michael@0 | 297 | PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties()); |
michael@0 | 298 | |
michael@0 | 299 | PropertyValidator.getInstance().assertNone(Property.ATTENDEE, getProperties()); |
michael@0 | 300 | PropertyValidator.getInstance().assertNone(Property.RECURRENCE_ID, getProperties()); |
michael@0 | 301 | } |
michael@0 | 302 | } |
michael@0 | 303 | |
michael@0 | 304 | /** |
michael@0 | 305 | * <pre> |
michael@0 | 306 | * Component/Property Presence |
michael@0 | 307 | * ------------------- --------------------------------------------- |
michael@0 | 308 | * METHOD 1 MUST be "CANCEL" |
michael@0 | 309 | * VJOURNAL 1+ All MUST have the same UID |
michael@0 | 310 | * DTSTAMP 1 |
michael@0 | 311 | * ORGANIZER 1 |
michael@0 | 312 | * SEQUENCE 1 |
michael@0 | 313 | * UID 1 MUST be the UID of the original REQUEST |
michael@0 | 314 | * |
michael@0 | 315 | * ATTACH 0+ |
michael@0 | 316 | * ATTENDEE 0+ |
michael@0 | 317 | * CATEGORIES 0 or 1 This property MAY contain a list of values |
michael@0 | 318 | * CLASS 0 or 1 |
michael@0 | 319 | * COMMENT 0 or 1 |
michael@0 | 320 | * CONTACT 0+ |
michael@0 | 321 | * CREATED 0 or 1 |
michael@0 | 322 | * DESCRIPTION 0 or 1 |
michael@0 | 323 | * DTSTART 0 or 1 |
michael@0 | 324 | * EXDATE 0+ |
michael@0 | 325 | * EXRULE 0+ |
michael@0 | 326 | * LAST-MODIFIED 0 or 1 |
michael@0 | 327 | * RDATE 0+ |
michael@0 | 328 | * RECURRENCE-ID 0 or 1 only if referring to an instance of a |
michael@0 | 329 | * recurring calendar component. Otherwise |
michael@0 | 330 | * it MUST NOT be present. |
michael@0 | 331 | * RELATED-TO 0+ |
michael@0 | 332 | * RRULE 0+ |
michael@0 | 333 | * STATUS 0 or 1 MAY be present, must be "CANCELLED" if |
michael@0 | 334 | * present |
michael@0 | 335 | * SUMMARY 0 or 1 |
michael@0 | 336 | * URL 0 or 1 |
michael@0 | 337 | * X-PROPERTY 0+ |
michael@0 | 338 | * |
michael@0 | 339 | * REQUEST-STATUS 0 |
michael@0 | 340 | * |
michael@0 | 341 | * VTIMEZONE 0+ MUST be present if any date/time refers to |
michael@0 | 342 | * a timezone |
michael@0 | 343 | * X-COMPONENT 0+ |
michael@0 | 344 | * VALARM 0 |
michael@0 | 345 | * VEVENT 0 |
michael@0 | 346 | * VFREEBUSY 0 |
michael@0 | 347 | * VTODO 0 |
michael@0 | 348 | * </pre> |
michael@0 | 349 | * |
michael@0 | 350 | */ |
michael@0 | 351 | private class CancelValidator implements Validator { |
michael@0 | 352 | |
michael@0 | 353 | private static final long serialVersionUID = 1L; |
michael@0 | 354 | |
michael@0 | 355 | public void validate() throws ValidationException { |
michael@0 | 356 | PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties()); |
michael@0 | 357 | PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties()); |
michael@0 | 358 | PropertyValidator.getInstance().assertOne(Property.SEQUENCE, getProperties()); |
michael@0 | 359 | PropertyValidator.getInstance().assertOne(Property.UID, getProperties()); |
michael@0 | 360 | |
michael@0 | 361 | PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties()); |
michael@0 | 362 | PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties()); |
michael@0 | 363 | PropertyValidator.getInstance().assertOneOrLess(Property.COMMENT, getProperties()); |
michael@0 | 364 | PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties()); |
michael@0 | 365 | PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, getProperties()); |
michael@0 | 366 | PropertyValidator.getInstance().assertOneOrLess(Property.DTSTART, getProperties()); |
michael@0 | 367 | PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties()); |
michael@0 | 368 | PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, getProperties()); |
michael@0 | 369 | PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties()); |
michael@0 | 370 | PropertyValidator.getInstance().assertOneOrLess(Property.SUMMARY, getProperties()); |
michael@0 | 371 | PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties()); |
michael@0 | 372 | |
michael@0 | 373 | PropertyValidator.getInstance().assertNone(Property.REQUEST_STATUS, getProperties()); |
michael@0 | 374 | } |
michael@0 | 375 | } |
michael@0 | 376 | |
michael@0 | 377 | /** |
michael@0 | 378 | * <pre> |
michael@0 | 379 | * Component/Property Presence |
michael@0 | 380 | * ------------------- ---------------------------------------------- |
michael@0 | 381 | * METHOD 1 MUST be "PUBLISH" |
michael@0 | 382 | * VJOURNAL 1+ |
michael@0 | 383 | * DESCRIPTION 1 Can be null. |
michael@0 | 384 | * DTSTAMP 1 |
michael@0 | 385 | * DTSTART 1 |
michael@0 | 386 | * ORGANIZER 1 |
michael@0 | 387 | * UID 1 |
michael@0 | 388 | * |
michael@0 | 389 | * ATTACH 0+ |
michael@0 | 390 | * CATEGORIES 0 or 1 This property MAY contain a list of values |
michael@0 | 391 | * CLASS 0 or 1 |
michael@0 | 392 | * COMMENT 0 or 1 |
michael@0 | 393 | * CONTACT 0+ |
michael@0 | 394 | * CREATED 0 or 1 |
michael@0 | 395 | * EXDATE 0+ |
michael@0 | 396 | * EXRULE 0+ |
michael@0 | 397 | * LAST-MODIFIED 0 or 1 |
michael@0 | 398 | * RDATE 0+ |
michael@0 | 399 | * RECURRENCE-ID 0 or 1 MUST only if referring to an instance of a |
michael@0 | 400 | * recurring calendar component. Otherwise |
michael@0 | 401 | * it MUST NOT be present. |
michael@0 | 402 | * RELATED-TO 0+ |
michael@0 | 403 | * RRULE 0+ |
michael@0 | 404 | * SEQUENCE 0 or 1 MUST echo the original SEQUENCE number. |
michael@0 | 405 | * MUST be present if non-zero. MAY be |
michael@0 | 406 | * present if zero. |
michael@0 | 407 | * STATUS 0 or 1 MAY be one of DRAFT/FINAL/CANCELLED |
michael@0 | 408 | * SUMMARY 0 or 1 Can be null |
michael@0 | 409 | * URL 0 or 1 |
michael@0 | 410 | * X-PROPERTY 0+ |
michael@0 | 411 | * |
michael@0 | 412 | * ATTENDEE 0 |
michael@0 | 413 | * |
michael@0 | 414 | * VALARM 0+ |
michael@0 | 415 | * VTIMEZONE 0+ MUST be present if any date/time refers to |
michael@0 | 416 | * a timezone |
michael@0 | 417 | * X-COMPONENT 0+ |
michael@0 | 418 | * |
michael@0 | 419 | * VEVENT 0 |
michael@0 | 420 | * VFREEBUSY 0 |
michael@0 | 421 | * VTODO 0 |
michael@0 | 422 | * </pre> |
michael@0 | 423 | * |
michael@0 | 424 | */ |
michael@0 | 425 | private class PublishValidator implements Validator { |
michael@0 | 426 | |
michael@0 | 427 | private static final long serialVersionUID = 1L; |
michael@0 | 428 | |
michael@0 | 429 | public void validate() throws ValidationException { |
michael@0 | 430 | PropertyValidator.getInstance().assertOne(Property.DESCRIPTION, getProperties()); |
michael@0 | 431 | PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties()); |
michael@0 | 432 | PropertyValidator.getInstance().assertOne(Property.DTSTART, getProperties()); |
michael@0 | 433 | PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties()); |
michael@0 | 434 | PropertyValidator.getInstance().assertOne(Property.UID, getProperties()); |
michael@0 | 435 | |
michael@0 | 436 | PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties()); |
michael@0 | 437 | PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties()); |
michael@0 | 438 | PropertyValidator.getInstance().assertOneOrLess(Property.COMMENT, getProperties()); |
michael@0 | 439 | PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties()); |
michael@0 | 440 | PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties()); |
michael@0 | 441 | PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, getProperties()); |
michael@0 | 442 | PropertyValidator.getInstance().assertOneOrLess(Property.SEQUENCE, getProperties()); |
michael@0 | 443 | PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties()); |
michael@0 | 444 | PropertyValidator.getInstance().assertOneOrLess(Property.SUMMARY, getProperties()); |
michael@0 | 445 | PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties()); |
michael@0 | 446 | |
michael@0 | 447 | PropertyValidator.getInstance().assertNone(Property.ATTENDEE, getProperties()); |
michael@0 | 448 | } |
michael@0 | 449 | } |
michael@0 | 450 | |
michael@0 | 451 | /** |
michael@0 | 452 | * @return the optional access classification property for a journal entry |
michael@0 | 453 | */ |
michael@0 | 454 | public final Clazz getClassification() { |
michael@0 | 455 | return (Clazz) getProperty(Property.CLASS); |
michael@0 | 456 | } |
michael@0 | 457 | |
michael@0 | 458 | /** |
michael@0 | 459 | * @return the optional creation-time property for a journal entry |
michael@0 | 460 | */ |
michael@0 | 461 | public final Created getCreated() { |
michael@0 | 462 | return (Created) getProperty(Property.CREATED); |
michael@0 | 463 | } |
michael@0 | 464 | |
michael@0 | 465 | /** |
michael@0 | 466 | * @return the optional description property for a journal entry |
michael@0 | 467 | */ |
michael@0 | 468 | public final Description getDescription() { |
michael@0 | 469 | return (Description) getProperty(Property.DESCRIPTION); |
michael@0 | 470 | } |
michael@0 | 471 | |
michael@0 | 472 | /** |
michael@0 | 473 | * Convenience method to pull the DTSTART out of the property list. |
michael@0 | 474 | * @return The DtStart object representation of the start Date |
michael@0 | 475 | */ |
michael@0 | 476 | public final DtStart getStartDate() { |
michael@0 | 477 | return (DtStart) getProperty(Property.DTSTART); |
michael@0 | 478 | } |
michael@0 | 479 | |
michael@0 | 480 | /** |
michael@0 | 481 | * @return the optional last-modified property for a journal entry |
michael@0 | 482 | */ |
michael@0 | 483 | public final LastModified getLastModified() { |
michael@0 | 484 | return (LastModified) getProperty(Property.LAST_MODIFIED); |
michael@0 | 485 | } |
michael@0 | 486 | |
michael@0 | 487 | /** |
michael@0 | 488 | * @return the optional organizer property for a journal entry |
michael@0 | 489 | */ |
michael@0 | 490 | public final Organizer getOrganizer() { |
michael@0 | 491 | return (Organizer) getProperty(Property.ORGANIZER); |
michael@0 | 492 | } |
michael@0 | 493 | |
michael@0 | 494 | /** |
michael@0 | 495 | * @return the optional date-stamp property |
michael@0 | 496 | */ |
michael@0 | 497 | public final DtStamp getDateStamp() { |
michael@0 | 498 | return (DtStamp) getProperty(Property.DTSTAMP); |
michael@0 | 499 | } |
michael@0 | 500 | |
michael@0 | 501 | /** |
michael@0 | 502 | * @return the optional sequence number property for a journal entry |
michael@0 | 503 | */ |
michael@0 | 504 | public final Sequence getSequence() { |
michael@0 | 505 | return (Sequence) getProperty(Property.SEQUENCE); |
michael@0 | 506 | } |
michael@0 | 507 | |
michael@0 | 508 | /** |
michael@0 | 509 | * @return the optional status property for a journal entry |
michael@0 | 510 | */ |
michael@0 | 511 | public final Status getStatus() { |
michael@0 | 512 | return (Status) getProperty(Property.STATUS); |
michael@0 | 513 | } |
michael@0 | 514 | |
michael@0 | 515 | /** |
michael@0 | 516 | * @return the optional summary property for a journal entry |
michael@0 | 517 | */ |
michael@0 | 518 | public final Summary getSummary() { |
michael@0 | 519 | return (Summary) getProperty(Property.SUMMARY); |
michael@0 | 520 | } |
michael@0 | 521 | |
michael@0 | 522 | /** |
michael@0 | 523 | * @return the optional URL property for a journal entry |
michael@0 | 524 | */ |
michael@0 | 525 | public final Url getUrl() { |
michael@0 | 526 | return (Url) getProperty(Property.URL); |
michael@0 | 527 | } |
michael@0 | 528 | |
michael@0 | 529 | /** |
michael@0 | 530 | * @return the optional recurrence identifier property for a journal entry |
michael@0 | 531 | */ |
michael@0 | 532 | public final RecurrenceId getRecurrenceId() { |
michael@0 | 533 | return (RecurrenceId) getProperty(Property.RECURRENCE_ID); |
michael@0 | 534 | } |
michael@0 | 535 | |
michael@0 | 536 | /** |
michael@0 | 537 | * Returns the UID property of this component if available. |
michael@0 | 538 | * @return a Uid instance, or null if no UID property exists |
michael@0 | 539 | */ |
michael@0 | 540 | public final Uid getUid() { |
michael@0 | 541 | return (Uid) getProperty(Property.UID); |
michael@0 | 542 | } |
michael@0 | 543 | } |