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