src/net/fortuna/ical4j/model/property/Organizer.java

changeset 4
45d57ecba757
equal deleted inserted replaced
-1:000000000000 0:72128d7cc9e7
1 /**
2 * Copyright (c) 2012, Ben Fortuna
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * o Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * o Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * o Neither the name of Ben Fortuna nor the names of any other contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 package net.fortuna.ical4j.model.property;
33
34 import java.net.URI;
35 import java.net.URISyntaxException;
36
37 import net.fortuna.ical4j.model.Parameter;
38 import net.fortuna.ical4j.model.ParameterList;
39 import net.fortuna.ical4j.model.Property;
40 import net.fortuna.ical4j.model.PropertyFactoryImpl;
41 import net.fortuna.ical4j.model.ValidationException;
42 import net.fortuna.ical4j.util.ParameterValidator;
43 import net.fortuna.ical4j.util.Strings;
44 import net.fortuna.ical4j.util.Uris;
45
46 /**
47 * $Id$
48 *
49 * Created: [Apr 6, 2004]
50 *
51 * Defines an ORGANIZER iCalendar component property.
52 *
53 * <pre>
54 * 4.8.4.3 Organizer
55 *
56 * Property Name: ORGANIZER
57 *
58 * Purpose: The property defines the organizer for a calendar component.
59 *
60 * Value Type: CAL-ADDRESS
61 *
62 * Property Parameters: Non-standard, language, common name, directory
63 * entry reference, sent by property parameters can be specified on this
64 * property.
65 *
66 * Conformance: This property MUST be specified in an iCalendar object
67 * that specifies a group scheduled calendar entity. This property MUST
68 * be specified in an iCalendar object that specifies the publication of
69 * a calendar user's busy time. This property MUST NOT be specified in
70 * an iCalendar object that specifies only a time zone definition or
71 * that defines calendar entities that are not group scheduled entities,
72 * but are entities only on a single user's calendar.
73 *
74 * Description: The property is specified within the &quot;VEVENT&quot;, &quot;VTODO&quot;,
75 * &quot;VJOURNAL calendar components to specify the organizer of a group
76 * scheduled calendar entity. The property is specified within the
77 * &quot;VFREEBUSY&quot; calendar component to specify the calendar user
78 * requesting the free or busy time. When publishing a &quot;VFREEBUSY&quot;
79 * calendar component, the property is used to specify the calendar that
80 * the published busy time came from.
81 *
82 * The property has the property parameters CN, for specifying the
83 * common or display name associated with the &quot;Organizer&quot;, DIR, for
84 * specifying a pointer to the directory information associated with the
85 * &quot;Organizer&quot;, SENT-BY, for specifying another calendar user that is
86 * acting on behalf of the &quot;Organizer&quot;. The non-standard parameters may
87 * also be specified on this property. If the LANGUAGE property
88 * parameter is specified, the identified language applies to the CN
89 * parameter value.
90 *
91 * Format Definition: The property is defined by the following notation:
92 *
93 * organizer = &quot;ORGANIZER&quot; orgparam &quot;:&quot;
94 * cal-address CRLF
95 *
96 * orgparam = *(
97 *
98 * ; the following are optional,
99 * ; but MUST NOT occur more than once
100 *
101 * (&quot;;&quot; cnparam) / (&quot;;&quot; dirparam) / (&quot;;&quot; sentbyparam) /
102 * (&quot;;&quot; languageparam) /
103 *
104 * ; the following is optional,
105 * ; and MAY occur more than once
106 *
107 * (&quot;;&quot; xparam)
108 *
109 * )
110 *
111 * Example: The following is an example of this property:
112 *
113 * ORGANIZER;CN=John Smith:MAILTO:jsmith@host1.com
114 *
115 * The following is an example of this property with a pointer to the
116 * directory information associated with the organizer:
117 *
118 * ORGANIZER;CN=JohnSmith;DIR=&quot;ldap://host.com:6666/o=3DDC%20Associ
119 * ates,c=3DUS??(cn=3DJohn%20Smith)&quot;:MAILTO:jsmith@host1.com
120 *
121 * The following is an example of this property used by another calendar
122 * user who is acting on behalf of the organizer, with responses
123 * intended to be sent back to the organizer, not the other calendar
124 * user:
125 *
126 * ORGANIZER;SENT-BY=&quot;MAILTO:jane_doe@host.com&quot;:
127 * MAILTO:jsmith@host1.com
128 * </pre>
129 *
130 * @author Ben Fortuna
131 */
132 public class Organizer extends Property {
133
134 private static final long serialVersionUID = -5216965653165090725L;
135
136 private URI calAddress;
137
138 /**
139 * Default constructor.
140 */
141 public Organizer() {
142 super(ORGANIZER, PropertyFactoryImpl.getInstance());
143 }
144
145 /**
146 * Constructs a new instance with the specified value.
147 * @param value an organizer URI
148 * @throws URISyntaxException where the specified value is not a valid URI
149 */
150 public Organizer(String value) throws URISyntaxException {
151 super(ORGANIZER, PropertyFactoryImpl.getInstance());
152 setValue(value);
153 }
154
155 /**
156 * @param aList a list of parameters for this component
157 * @param aValue a value string for this component
158 * @throws URISyntaxException where the specified value string is not a valid uri
159 */
160 public Organizer(final ParameterList aList, final String aValue)
161 throws URISyntaxException {
162 super(ORGANIZER, aList, PropertyFactoryImpl.getInstance());
163 setValue(aValue);
164 }
165
166 /**
167 * @param aUri a URI representation of a calendar address
168 */
169 public Organizer(final URI aUri) {
170 super(ORGANIZER, PropertyFactoryImpl.getInstance());
171 calAddress = aUri;
172 }
173
174 /**
175 * @param aList a list of parameters for this component
176 * @param aUri a URI representation of a calendar address
177 */
178 public Organizer(final ParameterList aList, final URI aUri) {
179 super(ORGANIZER, aList, PropertyFactoryImpl.getInstance());
180 calAddress = aUri;
181 }
182
183 /**
184 * {@inheritDoc}
185 */
186 public final void validate() throws ValidationException {
187
188 /*
189 * ; the following are optional, ; but MUST NOT occur more than once (";" cnparam) / (";" dirparam) / (";"
190 * sentbyparam) / (";" languageparam) /
191 */
192 ParameterValidator.getInstance().assertOneOrLess(Parameter.CN,
193 getParameters());
194 ParameterValidator.getInstance().assertOneOrLess(Parameter.DIR,
195 getParameters());
196 ParameterValidator.getInstance().assertOneOrLess(Parameter.SENT_BY,
197 getParameters());
198 ParameterValidator.getInstance().assertOneOrLess(Parameter.LANGUAGE,
199 getParameters());
200
201 /* schedulestatus added for CalDAV scheduling
202 */
203 ParameterValidator.getInstance().assertOneOrLess(Parameter.SCHEDULE_STATUS,
204 getParameters());
205
206 /*
207 * ; the following is optional, ; and MAY occur more than once (";" xparam)
208 */
209 }
210
211 /**
212 * @return Returns the calAddress.
213 */
214 public final URI getCalAddress() {
215 return calAddress;
216 }
217
218 /**
219 * {@inheritDoc}
220 */
221 public final void setValue(final String aValue) throws URISyntaxException {
222 calAddress = Uris.create(aValue);
223 }
224
225 /**
226 * {@inheritDoc}
227 */
228 public final String getValue() {
229 return Uris.decode(Strings.valueOf(getCalAddress()));
230 }
231
232 /**
233 * @param calAddress The calAddress to set.
234 */
235 public final void setCalAddress(final URI calAddress) {
236 this.calAddress = calAddress;
237 }
238 }

mercurial