View Javadoc
1   /**
2    * This file Copyright (c) 2003-2014 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
32   *
33   */
34  package info.magnolia.cms.core;
35  
36  import info.magnolia.cms.security.AccessDeniedException;
37  
38  import javax.jcr.ItemNotFoundException;
39  import javax.jcr.Value;
40  import javax.jcr.RepositoryException;
41  import javax.jcr.PathNotFoundException;
42  import javax.jcr.Property;
43  import java.util.Calendar;
44  import java.util.Collection;
45  import java.io.InputStream;
46  
47  
48  /**
49   * Represents a {@linkplain Content content} value object. If the node data does not have any value
50   * {@link #isExist()} returns false. As soon a value is set - null is not considered a value - the
51   * node data starts to exist. The various value read methods ({@link #getString()},
52   * {@link #getBoolean()}, ..) will always return a value (default or null)
53   *
54   * @version $Id$
55   *
56   * @deprecated since 4.5, use jcr.Property instead.
57   */
58  public interface NodeData extends Cloneable {
59      int MULTIVALUE_UNDEFINED = -1;
60      int MULTIVALUE_TRUE = 1;
61      int MULTIVALUE_FALSE = 0;
62  
63      /**
64       * Returns the <code>value</code> of this <code>NodeData</code>. One of type:
65       * <ul>
66       * <li><code>PropertyType.STRING</code></li>
67       * <li><code>PropertyType.DATE</code></li>
68       * <li><code>PropertyType.SOFTLINK</code></li>
69       * <li><code>PropertyType.BINARY</code></li>
70       * <li><code>PropertyType.DOUBLE</code></li>
71       * <li><code>PropertyType.LONG</code></li>
72       * <li><code>PropertyType.BOOLEAN</code></li>
73       * </ul>
74       * @return Value
75       */
76      Value getValue();
77  
78      /**
79       * For multi-value properties.
80       * @return Value[]
81       */
82      Value[] getValues();
83  
84      /**
85       * Returns the <code>String</code> representation of the value: decodes like breaks with the specified regular
86       * expression.
87       * @param lineBreak , regular expression
88       * @return String
89       */
90      String getString(String lineBreak);
91  
92      /**
93       * Returns the <code>String</code> representation of the value.
94       * @return String
95       */
96      String getString();
97  
98      /**
99       * Returns the <code>long</code> representation of the value.
100      * @return long
101      */
102     long getLong();
103 
104     /**
105      * Returns the <code>double</code> representation of the value.
106      * @return double
107      */
108     double getDouble();
109 
110     /**
111      * Returns the <code>Calendar</code> representation of the value.
112      * @return Calendar
113      */
114     Calendar getDate();
115 
116     /**
117      * Returns the <code>boolean</code> representation of the value.
118      * @return boolean
119      */
120     boolean getBoolean();
121 
122     /**
123      * Returns the <code>InputStream</code> representation of the value.
124      * @return boolean
125      */
126     InputStream getStream();
127 
128     /**
129      * Returns the Content that this NodeData references (if its type is PropertyType.REFERENCE). If it is of type PATH
130      * or STRING it tries to resolve the node by using the path. The path can be relative or absolute. If the property
131      * type is STRING, it tries finally to get the node by using the value as an uuid.
132      * @throws javax.jcr.RepositoryException
133      */
134     Content getReferencedContent() throws RepositoryException, PathNotFoundException, RepositoryException;
135 
136     /**
137      * Same as {@link #getReferencedContent()} but achieves the referenced node from a different workspace.
138      */
139     Content getReferencedContent(String repositoryId) throws PathNotFoundException, RepositoryException;
140 
141     /**
142      * Returns the <code>type</code> of this <code>NodeData</code>. One of:
143      * <ul>
144      * <li><code>PropertyType.STRING</code></li>
145      * <li><code>PropertyType.DATE</code></li>
146      * <li><code>PropertyType.SOFTLINK</code></li>
147      * <li><code>PropertyType.BINARY</code></li>
148      * <li><code>PropertyType.DOUBLE</code></li>
149      * <li><code>PropertyType.LONG</code></li>
150      * <li><code>PropertyType.BOOLEAN</code></li>
151      * </ul>
152      * @return PropertyType
153      */
154     int getType();
155 
156     /**
157      * @return atom name
158      */
159     String getName();
160 
161     /**
162      * returns size in bytes.
163      * @return content length
164      */
165     long getContentLength();
166 
167     /**
168      * Access to property at the JCR level. Available only to be available, should not be used in normal circumstances!
169      * @return Property
170      * @throws PathNotFoundException
171      */
172     Property getJCRProperty() throws PathNotFoundException;
173 
174     /**
175      * set value of type <code>String</code>.
176      * @param value , string to be set
177      * @throws javax.jcr.RepositoryException
178      */
179     void setValue(String value) throws RepositoryException, AccessDeniedException;
180 
181     /**
182      * set value of type <code>int</code>.
183      * @param value , int value to be set
184      * @throws javax.jcr.RepositoryException
185      */
186     void setValue(int value) throws RepositoryException, AccessDeniedException;
187 
188     /**
189      * set value of type <code>long</code>.
190      * @param value , long value to be set
191      * @throws javax.jcr.RepositoryException
192      */
193     void setValue(long value) throws RepositoryException, AccessDeniedException;
194 
195     /**
196      * set value of type <code>InputStream</code>.
197      * @param value , InputStream to be set
198      * @throws javax.jcr.RepositoryException
199      */
200     void setValue(InputStream value) throws RepositoryException, AccessDeniedException;
201 
202     /**
203      * set value of type <code>double</code>.
204      * @param value , double value to be set
205      * @throws javax.jcr.RepositoryException
206      */
207     void setValue(double value) throws RepositoryException, AccessDeniedException;
208 
209     /**
210      * set value of type <code>boolean</code>.
211      * @param value , boolean value to be set
212      * @throws javax.jcr.RepositoryException
213      */
214     void setValue(boolean value) throws RepositoryException, AccessDeniedException;
215 
216     /**
217      * set value of type <code>Calendar</code>.
218      * @param value , Calendar value to be set
219      * @throws javax.jcr.RepositoryException
220      */
221     void setValue(Calendar value) throws RepositoryException, AccessDeniedException;
222 
223     /**
224      * Sets a reference value.
225      */
226     void setValue(Content value) throws RepositoryException, AccessDeniedException;
227 
228     /**
229      * set value of type <code>Value</code>.
230      * @param value
231      * @throws javax.jcr.RepositoryException
232      */
233     void setValue(Value value) throws RepositoryException, AccessDeniedException;
234 
235     /**
236      * set value of type <code>Value[]</code>.
237      * @param value
238      * @throws javax.jcr.RepositoryException
239      */
240     void setValue(Value[] value) throws RepositoryException, AccessDeniedException;
241 
242     /**
243      * set attribute, available only if NodeData is of type <code>Binary</code>.
244      * @param name
245      * @param value
246      * @throws javax.jcr.RepositoryException
247      * @throws info.magnolia.cms.security.AccessDeniedException
248      * @throws UnsupportedOperationException if its not a Binary type
249      */
250     void setAttribute(String name, String value) throws RepositoryException, AccessDeniedException,
251         UnsupportedOperationException;
252 
253     /**
254      * set attribute, available only if NodeData is of type <code>Binary</code>.
255      * @param name
256      * @param value
257      * @throws javax.jcr.RepositoryException
258      * @throws info.magnolia.cms.security.AccessDeniedException
259      * @throws UnsupportedOperationException if its not a Binary type
260      */
261     void setAttribute(String name, Calendar value) throws RepositoryException, AccessDeniedException,
262         UnsupportedOperationException;
263 
264     /**
265      * get attribute, available only if NodeData is of type <code>Binary</code>.
266      * @param name
267      * @return string value
268      */
269     String getAttribute(String name);
270 
271     /**
272      * get all attribute names.
273      * @return collection of attribute names
274      * @throws javax.jcr.RepositoryException
275      */
276     Collection<String> getAttributeNames() throws RepositoryException;
277 
278     /**
279      * checks if the atom exists in the repository.
280      * @return boolean
281      */
282     boolean isExist();
283 
284     /**
285      * get a handle representing path relative to the content repository.
286      * @return String representing path (handle) of the content
287      */
288     String getHandle();
289 
290     /**
291      * Persists all changes to the repository if validation succeeds.
292      * @throws javax.jcr.RepositoryException
293      */
294     void save() throws RepositoryException;
295 
296     /**
297      * checks for the allowed access rights.
298      * @param permissions as defined in javax.jcr.Permission
299      * @return true is the current user has specified access on this node.
300      */
301     boolean isGranted(long permissions);
302 
303     /**
304      * Remove this path.
305      * @throws javax.jcr.RepositoryException
306      */
307     void delete() throws RepositoryException;
308 
309     /**
310      * Refreshes current node keeping all changes.
311      * @throws javax.jcr.RepositoryException
312      * @see javax.jcr.Node#refresh(boolean)
313      */
314     void refresh(boolean keepChanges) throws RepositoryException;
315 
316     /**
317      * for multi-value controls.
318      * @return
319      */
320     int isMultiValue();
321 
322     /**
323      * returns Parent node.
324      */
325     Content getParent() throws AccessDeniedException, ItemNotFoundException, javax.jcr.AccessDeniedException, RepositoryException;
326 
327     HierarchyManager getHierarchyManager();
328 
329 }