View Javadoc
1   /**
2    * This file Copyright (c) 2003-2016 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   * @deprecated since 4.5, use jcr.Property instead.
55   */
56  public interface NodeData extends Cloneable {
57      int MULTIVALUE_UNDEFINED = -1;
58      int MULTIVALUE_TRUE = 1;
59      int MULTIVALUE_FALSE = 0;
60  
61      /**
62       * Returns the <code>value</code> of this <code>NodeData</code>. One of type:
63       * <ul>
64       * <li><code>PropertyType.STRING</code></li>
65       * <li><code>PropertyType.DATE</code></li>
66       * <li><code>PropertyType.SOFTLINK</code></li>
67       * <li><code>PropertyType.BINARY</code></li>
68       * <li><code>PropertyType.DOUBLE</code></li>
69       * <li><code>PropertyType.LONG</code></li>
70       * <li><code>PropertyType.BOOLEAN</code></li>
71       * </ul>
72       */
73      Value getValue();
74  
75      /**
76       * For multi-value properties.
77       * @return Value[]
78       */
79      Value[] getValues();
80  
81      /**
82       * Returns the <code>String</code> representation of the value: decodes like breaks with the specified regular
83       * expression.
84       * @param lineBreak , regular expression
85       */
86      String getString(String lineBreak);
87  
88      /**
89       * Returns the <code>String</code> representation of the value.
90       */
91      String getString();
92  
93      /**
94       * Returns the <code>long</code> representation of the value.
95       */
96      long getLong();
97  
98      /**
99       * Returns the <code>double</code> representation of the value.
100      */
101     double getDouble();
102 
103     /**
104      * Returns the <code>Calendar</code> representation of the value.
105      */
106     Calendar getDate();
107 
108     /**
109      * Returns the <code>boolean</code> representation of the value.
110      */
111     boolean getBoolean();
112 
113     /**
114      * Returns the <code>InputStream</code> representation of the value.
115      */
116     InputStream getStream();
117 
118     /**
119      * Returns the Content that this NodeData references (if its type is PropertyType.REFERENCE). If it is of type PATH
120      * or STRING it tries to resolve the node by using the path. The path can be relative or absolute. If the property
121      * type is STRING, it tries finally to get the node by using the value as an uuid.
122      * @throws javax.jcr.RepositoryException
123      */
124     Content getReferencedContent() throws RepositoryException, PathNotFoundException, RepositoryException;
125 
126     /**
127      * Same as {@link #getReferencedContent()} but achieves the referenced node from a different workspace.
128      */
129     Content getReferencedContent(String repositoryId) throws PathNotFoundException, RepositoryException;
130 
131     /**
132      * Returns the <code>type</code> of this <code>NodeData</code>. One of:
133      * <ul>
134      * <li><code>PropertyType.STRING</code></li>
135      * <li><code>PropertyType.DATE</code></li>
136      * <li><code>PropertyType.SOFTLINK</code></li>
137      * <li><code>PropertyType.BINARY</code></li>
138      * <li><code>PropertyType.DOUBLE</code></li>
139      * <li><code>PropertyType.LONG</code></li>
140      * <li><code>PropertyType.BOOLEAN</code></li>
141      * </ul>
142      * @return the type of the property
143      */
144     int getType();
145 
146     /**
147      * @return atom name
148      */
149     String getName();
150 
151     /**
152      * returns size in bytes.
153      * @return content length
154      */
155     long getContentLength();
156 
157     /**
158      * Access to property at the JCR level. Available only to be available, should not be used in normal circumstances!
159      */
160     Property getJCRProperty() throws PathNotFoundException;
161 
162     /**
163      * set value of type <code>String</code>.
164      * @param value , string to be set
165      * @throws javax.jcr.RepositoryException
166      */
167     void setValue(String value) throws RepositoryException, AccessDeniedException;
168 
169     /**
170      * set value of type <code>int</code>.
171      * @param value , int value to be set
172      * @throws javax.jcr.RepositoryException
173      */
174     void setValue(int value) throws RepositoryException, AccessDeniedException;
175 
176     /**
177      * set value of type <code>long</code>.
178      * @param value , long value to be set
179      * @throws javax.jcr.RepositoryException
180      */
181     void setValue(long value) throws RepositoryException, AccessDeniedException;
182 
183     /**
184      * set value of type <code>InputStream</code>.
185      * @param value , InputStream to be set
186      * @throws javax.jcr.RepositoryException
187      */
188     void setValue(InputStream value) throws RepositoryException, AccessDeniedException;
189 
190     /**
191      * set value of type <code>double</code>.
192      * @param value , double value to be set
193      * @throws javax.jcr.RepositoryException
194      */
195     void setValue(double value) throws RepositoryException, AccessDeniedException;
196 
197     /**
198      * set value of type <code>boolean</code>.
199      * @param value , boolean value to be set
200      * @throws javax.jcr.RepositoryException
201      */
202     void setValue(boolean value) throws RepositoryException, AccessDeniedException;
203 
204     /**
205      * set value of type <code>Calendar</code>.
206      * @param value , Calendar value to be set
207      * @throws javax.jcr.RepositoryException
208      */
209     void setValue(Calendar value) throws RepositoryException, AccessDeniedException;
210 
211     /**
212      * Sets a reference value.
213      */
214     void setValue(Content value) throws RepositoryException, AccessDeniedException;
215 
216     /**
217      * set value of type <code>Value</code>.
218      *
219      * @throws javax.jcr.RepositoryException
220      */
221     void setValue(Value value) throws RepositoryException, AccessDeniedException;
222 
223     /**
224      * set value of type <code>Value[]</code>.
225      *
226      * @throws javax.jcr.RepositoryException
227      */
228     void setValue(Value[] value) throws RepositoryException, AccessDeniedException;
229 
230     /**
231      * set attribute, available only if NodeData is of type <code>Binary</code>.
232      *
233      * @throws javax.jcr.RepositoryException
234      * @throws info.magnolia.cms.security.AccessDeniedException
235      * @throws UnsupportedOperationException if its not a Binary type
236      */
237     void setAttribute(String name, String value) throws RepositoryException, AccessDeniedException,
238         UnsupportedOperationException;
239 
240     /**
241      * set attribute, available only if NodeData is of type <code>Binary</code>.
242      *
243      * @throws javax.jcr.RepositoryException
244      * @throws info.magnolia.cms.security.AccessDeniedException
245      * @throws UnsupportedOperationException if its not a Binary type
246      */
247     void setAttribute(String name, Calendar value) throws RepositoryException, AccessDeniedException,
248         UnsupportedOperationException;
249 
250     /**
251      * get attribute, available only if NodeData is of type <code>Binary</code>.
252      *
253      * @return string value
254      */
255     String getAttribute(String name);
256 
257     /**
258      * get all attribute names.
259      * @return collection of attribute names
260      * @throws javax.jcr.RepositoryException
261      */
262     Collection<String> getAttributeNames() throws RepositoryException;
263 
264     /**
265      * checks if the atom exists in the repository.
266      */
267     boolean isExist();
268 
269     /**
270      * get a handle representing path relative to the content repository.
271      * @return String representing path (handle) of the content
272      */
273     String getHandle();
274 
275     /**
276      * Persists all changes to the repository if validation succeeds.
277      * @throws javax.jcr.RepositoryException
278      */
279     void save() throws RepositoryException;
280 
281     /**
282      * checks for the allowed access rights.
283      * @param permissions as defined in javax.jcr.Permission
284      * @return true is the current user has specified access on this node.
285      */
286     boolean isGranted(long permissions);
287 
288     /**
289      * Remove this path.
290      * @throws javax.jcr.RepositoryException
291      */
292     void delete() throws RepositoryException;
293 
294     /**
295      * Refreshes current node keeping all changes.
296      * @throws javax.jcr.RepositoryException
297      * @see javax.jcr.Node#refresh(boolean)
298      */
299     void refresh(boolean keepChanges) throws RepositoryException;
300 
301     /**
302      * for multi-value controls.
303      * @return
304      */
305     int isMultiValue();
306 
307     /**
308      * returns Parent node.
309      */
310     Content getParent() throws AccessDeniedException, ItemNotFoundException, javax.jcr.AccessDeniedException, RepositoryException;
311 
312     HierarchyManager getHierarchyManager();
313 
314 }