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