You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by st...@apache.org on 2005/04/24 19:06:54 UTC
svn commit: r164488 - in
/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core:
NodeImpl.java PropertyImpl.java
Author: stefan
Date: Sun Apr 24 10:06:51 2005
New Revision: 164488
URL: http://svn.apache.org/viewcvs?rev=164488&view=rev
Log:
some cleaning up in NodeImpl & PropertyImpl as suggested by angela (JCR-114)
Modified:
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java?rev=164488&r1=164487&r2=164488&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeImpl.java Sun Apr 24 10:06:51 2005
@@ -440,7 +440,9 @@
// create a new property state
PropertyState propState;
try {
- propState = stateMgr.createTransientPropertyState(parentUUID, name, ItemState.STATUS_NEW);
+ propState =
+ stateMgr.createTransientPropertyState(parentUUID, name,
+ ItemState.STATUS_NEW);
propState.setType(type);
propState.setMultiValued(def.isMultiple());
propState.setDefinitionId(def.unwrap().getId());
@@ -454,7 +456,8 @@
propState.setValues(defValues);
}
} catch (ItemStateException ise) {
- String msg = "failed to add property " + name + " to " + safeGetJCRPath();
+ String msg = "failed to add property " + name + " to "
+ + safeGetJCRPath();
log.debug(msg);
throw new RepositoryException(msg, ise);
}
@@ -470,8 +473,10 @@
return prop;
}
- protected synchronized NodeImpl createChildNode(QName name, NodeDefinitionImpl def,
- NodeTypeImpl nodeType, String uuid)
+ protected synchronized NodeImpl createChildNode(QName name,
+ NodeDefinitionImpl def,
+ NodeTypeImpl nodeType,
+ String uuid)
throws RepositoryException {
String parentUUID = ((NodeState) state).getUUID();
// create a new node state
@@ -480,10 +485,13 @@
if (uuid == null) {
uuid = UUID.randomUUID().toString(); // version 4 uuid
}
- nodeState = stateMgr.createTransientNodeState(uuid, nodeType.getQName(), parentUUID, ItemState.STATUS_NEW);
+ nodeState =
+ stateMgr.createTransientNodeState(uuid, nodeType.getQName(),
+ parentUUID, ItemState.STATUS_NEW);
nodeState.setDefinitionId(def.unwrap().getId());
} catch (ItemStateException ise) {
- String msg = "failed to add child node " + name + " to " + safeGetJCRPath();
+ String msg = "failed to add child node " + name + " to "
+ + safeGetJCRPath();
log.debug(msg);
throw new RepositoryException(msg, ise);
}
@@ -515,7 +523,8 @@
NodeDefinition[] nda = nodeType.getAutoCreatedNodeDefinitions();
for (int i = 0; i < nda.length; i++) {
NodeDefinitionImpl nd = (NodeDefinitionImpl) nda[i];
- node.createChildNode(nd.getQName(), nd, (NodeTypeImpl) nd.getDefaultPrimaryType(), null);
+ node.createChildNode(nd.getQName(), nd,
+ (NodeTypeImpl) nd.getDefaultPrimaryType(), null);
}
return node;
@@ -542,9 +551,11 @@
try {
qName = QName.fromJCRName(propName, session.getNamespaceResolver());
} catch (IllegalNameException ine) {
- throw new RepositoryException("invalid property name: " + propName, ine);
+ throw new RepositoryException("invalid property name: "
+ + propName, ine);
} catch (UnknownPrefixException upe) {
- throw new RepositoryException("invalid property name: " + propName, upe);
+ throw new RepositoryException("invalid property name: "
+ + propName, upe);
}
removeChildProperty(qName);
}
@@ -555,7 +566,8 @@
// remove the property entry
if (!thisState.removePropertyEntry(propName)) {
- String msg = "failed to remove property " + propName + " of " + safeGetJCRPath();
+ String msg = "failed to remove property " + propName + " of "
+ + safeGetJCRPath();
log.debug(msg);
throw new RepositoryException(msg);
}
@@ -565,15 +577,18 @@
itemMgr.getItem(propId).setRemoved();
}
- protected void removeChildNode(QName nodeName, int index) throws RepositoryException {
+ protected void removeChildNode(QName nodeName, int index)
+ throws RepositoryException {
// modify the state of 'this', i.e. the parent node
NodeState thisState = (NodeState) getOrCreateTransientItemState();
if (index == 0) {
index = 1;
}
- NodeState.ChildNodeEntry entry = thisState.getChildNodeEntry(nodeName, index);
+ NodeState.ChildNodeEntry entry =
+ thisState.getChildNodeEntry(nodeName, index);
if (entry == null) {
- String msg = "failed to remove child " + nodeName + " of " + safeGetJCRPath();
+ String msg = "failed to remove child " + nodeName + " of "
+ + safeGetJCRPath();
log.debug(msg);
throw new RepositoryException(msg);
}
@@ -585,14 +600,16 @@
// remove child entry
if (!thisState.removeChildNodeEntry(nodeName, index)) {
- String msg = "failed to remove child " + nodeName + " of " + safeGetJCRPath();
+ String msg = "failed to remove child " + nodeName + " of "
+ + safeGetJCRPath();
log.debug(msg);
throw new RepositoryException(msg);
}
}
protected void onRedefine(NodeDefId defId) throws RepositoryException {
- NodeDefinitionImpl newDef = session.getNodeTypeManager().getNodeDefinition(defId);
+ NodeDefinitionImpl newDef =
+ session.getNodeTypeManager().getNodeDefinition(defId);
// modify the state of 'this', i.e. the target node
NodeState thisState = (NodeState) getOrCreateTransientItemState();
// set id of new definition
@@ -622,7 +639,8 @@
ArrayList tmp = new ArrayList(thisState.getChildNodeEntries());
// remove from tail to avoid problems with same-name siblings
for (int i = tmp.size() - 1; i >= 0; i--) {
- NodeState.ChildNodeEntry entry = (NodeState.ChildNodeEntry) tmp.get(i);
+ NodeState.ChildNodeEntry entry =
+ (NodeState.ChildNodeEntry) tmp.get(i);
removeChildNode(entry.getName(), entry.getIndex());
}
@@ -630,7 +648,8 @@
// use temp array to avoid ConcurrentModificationException
tmp = new ArrayList(thisState.getPropertyEntries());
for (int i = 0; i < tmp.size(); i++) {
- NodeState.PropertyEntry entry = (NodeState.PropertyEntry) tmp.get(i);
+ NodeState.PropertyEntry entry =
+ (NodeState.PropertyEntry) tmp.get(i);
removeChildProperty(entry.getName());
}
}
@@ -659,7 +678,9 @@
QName nodeName;
Path parentPath;
try {
- nodePath = Path.create(getPrimaryPath(), relPath, session.getNamespaceResolver(), true);
+ nodePath =
+ Path.create(getPrimaryPath(), relPath,
+ session.getNamespaceResolver(), true);
if (nodePath.getNameElement().getIndex() != 0) {
String msg = "illegal subscript specified: " + nodePath;
log.debug(msg);
@@ -668,7 +689,8 @@
nodeName = nodePath.getNameElement().getName();
parentPath = nodePath.getAncestor(1);
} catch (MalformedPathException e) {
- String msg = "failed to resolve path " + relPath + " relative to " + safeGetJCRPath();
+ String msg = "failed to resolve path " + relPath + " relative to "
+ + safeGetJCRPath();
log.debug(msg);
throw new RepositoryException(msg, e);
}
@@ -688,7 +710,8 @@
// make sure that parent node is checked-out
if (!parentNode.internalIsCheckedOut()) {
- String msg = safeGetJCRPath() + ": cannot add a child to a checked-in node";
+ String msg = safeGetJCRPath()
+ + ": cannot add a child to a checked-in node";
log.debug(msg);
throw new VersionException(msg);
}
@@ -700,13 +723,17 @@
return parentNode.internalAddChildNode(nodeName, nodeType, uuid);
}
- protected NodeImpl internalAddChildNode(QName nodeName, NodeTypeImpl nodeType)
- throws ItemExistsException, ConstraintViolationException, RepositoryException {
+ protected NodeImpl internalAddChildNode(QName nodeName,
+ NodeTypeImpl nodeType)
+ throws ItemExistsException, ConstraintViolationException,
+ RepositoryException {
return internalAddChildNode(nodeName, nodeType, null);
}
- protected NodeImpl internalAddChildNode(QName nodeName, NodeTypeImpl nodeType, String uuid)
- throws ItemExistsException, ConstraintViolationException, RepositoryException {
+ protected NodeImpl internalAddChildNode(QName nodeName,
+ NodeTypeImpl nodeType, String uuid)
+ throws ItemExistsException, ConstraintViolationException,
+ RepositoryException {
Path nodePath;
try {
nodePath = Path.create(getPrimaryPath(), nodeName, true);
@@ -1191,6 +1218,36 @@
}
/**
+ * Checks various pre-conditions that are common to all
+ * <code>setProperty()</code> methods. The checks performed are:
+ * <ul>
+ * <li>this node must be checked-out</li>
+ * <li>this node must not be locked by somebody else</li>
+ * </ul>
+ * Note that certain checks are performed by the respective
+ * <code>Property.setValue()</code> methods.
+ *
+ * @throws VersionException if this node is not checked-out
+ * @throws LockException if this node is locked by somebody else
+ * @throws RepositoryException if another error occurs
+ *
+ * @see javax.jcr.Node#setProperty
+ */
+ protected void checkSetProperty()
+ throws VersionException, LockException, RepositoryException {
+ // make sure this node is checked-out
+ if (!internalIsCheckedOut()) {
+ String msg = safeGetJCRPath()
+ + ": cannot set property of a checked-in node";
+ log.debug(msg);
+ throw new VersionException(msg);
+ }
+
+ // check lock status
+ checkLock();
+ }
+
+ /**
* Sets the internal value of a property without checking any constraints.
* <p/>
* Note that no type conversion is being performed, i.e. it's the caller's
@@ -1478,11 +1535,12 @@
* @throws ValueFormatException
* @throws VersionException
* @throws LockException
+ * @throws ConstraintViolationException
* @throws RepositoryException
*/
public PropertyImpl setProperty(QName name, Value[] values)
throws ValueFormatException, VersionException, LockException,
- RepositoryException {
+ ConstraintViolationException, RepositoryException {
int type;
if (values == null || values.length == 0
@@ -1506,24 +1564,17 @@
* @throws ValueFormatException
* @throws VersionException
* @throws LockException
+ * @throws ConstraintViolationException
* @throws RepositoryException
*/
public PropertyImpl setProperty(QName name, Value[] values, int type)
throws ValueFormatException, VersionException, LockException,
- RepositoryException {
+ ConstraintViolationException, RepositoryException {
// check state of this instance
sanityCheck();
- // make sure this node is checked-out
- if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath()
- + ": cannot set property of a checked-in node";
- log.debug(msg);
- throw new VersionException(msg);
- }
-
- // check lock status
- checkLock();
+ // check pre-conditions for setting property
+ checkSetProperty();
BitSet status = new BitSet();
PropertyImpl prop = getOrCreateProperty(name, type, true, status);
@@ -1551,24 +1602,17 @@
* @throws ValueFormatException
* @throws VersionException
* @throws LockException
+ * @throws ConstraintViolationException
* @throws RepositoryException
*/
public PropertyImpl setProperty(QName name, Value value)
throws ValueFormatException, VersionException, LockException,
- RepositoryException {
+ ConstraintViolationException, RepositoryException {
// check state of this instance
sanityCheck();
- // make sure this node is checked-out
- if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath()
- + ": cannot set property of a checked-in node";
- log.debug(msg);
- throw new VersionException(msg);
- }
-
- // check lock status
- checkLock();
+ // check pre-conditions for setting property
+ checkSetProperty();
int type = PropertyType.UNDEFINED;
if (value != null) {
@@ -1842,15 +1886,8 @@
// check state of this instance
sanityCheck();
- // make sure this node is checked-out
- if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
- log.debug(msg);
- throw new VersionException(msg);
- }
-
- // check lock status
- checkLock();
+ // check pre-conditions for setting property
+ checkSetProperty();
BitSet status = new BitSet();
PropertyImpl prop = getOrCreateProperty(name, type, true, status);
@@ -1893,15 +1930,8 @@
// check state of this instance
sanityCheck();
- // make sure this node is checked-out
- if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
- log.debug(msg);
- throw new VersionException(msg);
- }
-
- // check lock status
- checkLock();
+ // check pre-conditions for setting property
+ checkSetProperty();
BitSet status = new BitSet();
PropertyImpl prop = getOrCreateProperty(name, type, true, status);
@@ -1944,15 +1974,8 @@
// check state of this instance
sanityCheck();
- // make sure this node is checked-out
- if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
- log.debug(msg);
- throw new VersionException(msg);
- }
-
- // check lock status
- checkLock();
+ // check pre-conditions for setting property
+ checkSetProperty();
BitSet status = new BitSet();
PropertyImpl prop = getOrCreateProperty(name, type, false, status);
@@ -1982,15 +2005,8 @@
// check state of this instance
sanityCheck();
- // make sure this node is checked-out
- if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
- log.debug(msg);
- throw new VersionException(msg);
- }
-
- // check lock status
- checkLock();
+ // check pre-conditions for setting property
+ checkSetProperty();
BitSet status = new BitSet();
PropertyImpl prop = getOrCreateProperty(name, type, false, status);
@@ -2033,15 +2049,8 @@
// check state of this instance
sanityCheck();
- // make sure this node is checked-out
- if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
- log.debug(msg);
- throw new VersionException(msg);
- }
-
- // check lock status
- checkLock();
+ // check pre-conditions for setting property
+ checkSetProperty();
BitSet status = new BitSet();
PropertyImpl prop = getOrCreateProperty(name, PropertyType.BINARY, false, status);
@@ -2067,15 +2076,8 @@
// check state of this instance
sanityCheck();
- // make sure this node is checked-out
- if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
- log.debug(msg);
- throw new VersionException(msg);
- }
-
- // check lock status
- checkLock();
+ // check pre-conditions for setting property
+ checkSetProperty();
BitSet status = new BitSet();
PropertyImpl prop = getOrCreateProperty(name, PropertyType.BOOLEAN, false, status);
@@ -2101,15 +2103,8 @@
// check state of this instance
sanityCheck();
- // make sure this node is checked-out
- if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
- log.debug(msg);
- throw new VersionException(msg);
- }
-
- // check lock status
- checkLock();
+ // check pre-conditions for setting property
+ checkSetProperty();
BitSet status = new BitSet();
PropertyImpl prop = getOrCreateProperty(name, PropertyType.DOUBLE, false, status);
@@ -2135,15 +2130,8 @@
// check state of this instance
sanityCheck();
- // make sure this node is checked-out
- if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
- log.debug(msg);
- throw new VersionException(msg);
- }
-
- // check lock status
- checkLock();
+ // check pre-conditions for setting property
+ checkSetProperty();
BitSet status = new BitSet();
PropertyImpl prop = getOrCreateProperty(name, PropertyType.LONG, false, status);
@@ -2169,15 +2157,8 @@
// check state of this instance
sanityCheck();
- // make sure this node is checked-out
- if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
- log.debug(msg);
- throw new VersionException(msg);
- }
-
- // check lock status
- checkLock();
+ // check pre-conditions for setting property
+ checkSetProperty();
BitSet status = new BitSet();
PropertyImpl prop = getOrCreateProperty(name, PropertyType.DATE, false, status);
@@ -2203,15 +2184,8 @@
// check state of this instance
sanityCheck();
- // make sure this node is checked-out
- if (!internalIsCheckedOut()) {
- String msg = safeGetJCRPath() + ": cannot set property of a checked-in node";
- log.debug(msg);
- throw new VersionException(msg);
- }
-
- // check lock status
- checkLock();
+ // check pre-conditions for setting property
+ checkSetProperty();
BitSet status = new BitSet();
PropertyImpl prop = getOrCreateProperty(name, PropertyType.REFERENCE, false, status);
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java?rev=164488&r1=164487&r2=164488&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyImpl.java Sun Apr 24 10:06:51 2005
@@ -172,6 +172,63 @@
}
/**
+ * Checks various pre-conditions that are common to all
+ * <code>setValue()</code> methods. The checks performed are:
+ * <ul>
+ * <li>parent node must be checked-out</li>
+ * <li>property must not be protected</li>
+ * <li>parent node must not be locked by somebody else</li>
+ * <li>property must be multi-valued when set to an array of values
+ * (and vice versa)</li>
+ * </ul>
+ *
+ * @param multipleValues flag indicating whether the property is about to
+ * be set to an array of values
+ * @throws ValueFormatException if a single-valued property is set to an
+ * array of values (and vice versa)
+ * @throws VersionException if the parent node is not checked-out
+ * @throws LockException if the parent node is locked by somebody else
+ * @throws ConstraintViolationException if the property is protected
+ * @throws RepositoryException if another error occurs
+ *
+ * @see javax.jcr.Property#setValue
+ */
+ protected void checkSetValue(boolean multipleValues)
+ throws ValueFormatException, VersionException,
+ LockException, ConstraintViolationException,
+ RepositoryException {
+ // verify that parent node is checked-out
+ if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
+ throw new VersionException(
+ "cannot set the value of a property of a checked-in node "
+ + safeGetJCRPath());
+ }
+
+ // check protected flag
+ if (definition.isProtected()) {
+ throw new ConstraintViolationException(
+ "cannot set the value of a protected property "
+ + safeGetJCRPath());
+ }
+
+ // check multi-value flag
+ if (multipleValues) {
+ if (!definition.isMultiple()) {
+ throw new ValueFormatException(safeGetJCRPath()
+ + " is not multi-valued");
+ }
+ } else {
+ if (definition.isMultiple()) {
+ throw new ValueFormatException(safeGetJCRPath()
+ + " is multi-valued and can therefore only be set to an array of values");
+ }
+ }
+
+ // check lock status
+ ((NodeImpl) getParent()).checkLock();
+ }
+
+ /**
* @param values
* @param type
* @throws ConstraintViolationException
@@ -231,26 +288,20 @@
*
* @param name
* @throws ValueFormatException
+ * @throws VersionException
+ * @throws LockException
+ * @throws ConstraintViolationException
* @throws RepositoryException
*/
- public void setValue(QName name) throws ValueFormatException, RepositoryException {
+ public void setValue(QName name)
+ throws ValueFormatException, VersionException,
+ LockException, ConstraintViolationException,
+ RepositoryException {
// check state of this instance
sanityCheck();
- // verify that parent node is checked-out
- if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
- throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
- }
-
- // check protected flag
- if (definition.isProtected()) {
- throw new ConstraintViolationException("cannot set the value of a protected property " + safeGetJCRPath());
- }
-
- // check multi-value flag
- if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be set to an array of values");
- }
+ // check pre-conditions for setting property value
+ checkSetValue(false);
// check type according to definition of this property
int reqType = definition.getRequiredType();
@@ -284,26 +335,20 @@
*
* @param names
* @throws ValueFormatException
+ * @throws VersionException
+ * @throws LockException
+ * @throws ConstraintViolationException
* @throws RepositoryException
*/
- public void setValue(QName[] names) throws ValueFormatException, RepositoryException {
+ public void setValue(QName[] names)
+ throws ValueFormatException, VersionException,
+ LockException, ConstraintViolationException,
+ RepositoryException {
// check state of this instance
sanityCheck();
- // verify that parent node is checked-out
- if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
- throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
- }
-
- // check protected flag
- if (definition.isProtected()) {
- throw new ConstraintViolationException("cannot set the value of a protected property " + safeGetJCRPath());
- }
-
- // check multi-value flag
- if (!definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is not multi-valued");
- }
+ // check pre-conditions for setting property value
+ checkSetValue(true);
// check type according to definition of this property
int reqType = definition.getRequiredType();
@@ -376,7 +421,8 @@
// check multi-value flag
if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be retrieved as an array of values");
+ throw new ValueFormatException(safeGetJCRPath()
+ + " is multi-valued and can therefore only be retrieved as an array of values");
}
PropertyState state = (PropertyState) getItemState();
@@ -393,7 +439,8 @@
// check multi-value flag
if (!definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is not multi-valued");
+ throw new ValueFormatException(safeGetJCRPath()
+ + " is not multi-valued");
}
PropertyState state = (PropertyState) getItemState();
@@ -414,7 +461,8 @@
// check multi-value flag
if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be retrieved as an array of values");
+ throw new ValueFormatException(safeGetJCRPath()
+ + " is multi-valued and can therefore only be retrieved as an array of values");
}
PropertyState state = (PropertyState) getItemState();
@@ -438,7 +486,8 @@
// check multi-value flag
if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be retrieved as an array of values");
+ throw new ValueFormatException(safeGetJCRPath()
+ + " is multi-valued and can therefore only be retrieved as an array of values");
}
return getValue().getString();
@@ -453,7 +502,8 @@
// check multi-value flag
if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be retrieved as an array of values");
+ throw new ValueFormatException(safeGetJCRPath()
+ + " is multi-valued and can therefore only be retrieved as an array of values");
}
return getValue().getStream();
@@ -468,7 +518,8 @@
// check multi-value flag
if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be retrieved as an array of values");
+ throw new ValueFormatException(safeGetJCRPath()
+ + " is multi-valued and can therefore only be retrieved as an array of values");
}
PropertyState state = (PropertyState) getItemState();
@@ -490,7 +541,8 @@
// check multi-value flag
if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be retrieved as an array of values");
+ throw new ValueFormatException(safeGetJCRPath()
+ + " is multi-valued and can therefore only be retrieved as an array of values");
}
// avoid unnecessary object creation if possible
@@ -513,7 +565,8 @@
// check multi-value flag
if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be retrieved as an array of values");
+ throw new ValueFormatException(safeGetJCRPath()
+ + " is multi-valued and can therefore only be retrieved as an array of values");
}
// avoid unnecessary object creation if possible
@@ -536,7 +589,8 @@
// check multi-value flag
if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be retrieved as an array of values");
+ throw new ValueFormatException(safeGetJCRPath()
+ + " is multi-valued and can therefore only be retrieved as an array of values");
}
// avoid unnecessary object creation if possible
@@ -559,7 +613,8 @@
// check multi-value flag
if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be retrieved as an array of values");
+ throw new ValueFormatException(safeGetJCRPath()
+ + " is multi-valued and can therefore only be retrieved as an array of values");
}
PropertyState state = (PropertyState) getItemState();
@@ -583,23 +638,8 @@
// check state of this instance
sanityCheck();
- // verify that parent node is checked-out
- if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
- throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
- }
-
- // check lock status
- ((NodeImpl) getParent()).checkLock();
-
- // check protected flag
- if (definition.isProtected()) {
- throw new ConstraintViolationException("cannot set the value of a protected property " + safeGetJCRPath());
- }
-
- // check multi-value flag
- if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be set to an array of values");
- }
+ // check pre-conditions for setting property value
+ checkSetValue(false);
// check type according to definition of this property
int reqType = definition.getRequiredType();
@@ -634,23 +674,8 @@
// check state of this instance
sanityCheck();
- // verify that parent node is checked-out
- if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
- throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
- }
-
- // check protected flag
- if (definition.isProtected()) {
- throw new ConstraintViolationException("cannot set the value of a protected property " + safeGetJCRPath());
- }
-
- // check multi-value flag
- if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be set to an array of values");
- }
-
- // check lock status
- ((NodeImpl) getParent()).checkLock();
+ // check pre-conditions for setting property value
+ checkSetValue(false);
// check type according to definition of this property
int reqType = definition.getRequiredType();
@@ -680,23 +705,8 @@
// check state of this instance
sanityCheck();
- // verify that parent node is checked-out
- if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
- throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
- }
-
- // check protected flag
- if (definition.isProtected()) {
- throw new ConstraintViolationException("cannot set the value of a protected property " + safeGetJCRPath());
- }
-
- // check multi-value flag
- if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be set to an array of values");
- }
-
- // check lock status
- ((NodeImpl) getParent()).checkLock();
+ // check pre-conditions for setting property value
+ checkSetValue(false);
// check type according to definition of this property
int reqType = definition.getRequiredType();
@@ -737,23 +747,8 @@
// check state of this instance
sanityCheck();
- // verify that parent node is checked-out
- if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
- throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
- }
-
- // check protected flag
- if (definition.isProtected()) {
- throw new ConstraintViolationException("cannot set the value of a protected property " + safeGetJCRPath());
- }
-
- // check multi-value flag
- if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be set to an array of values");
- }
-
- // check lock status
- ((NodeImpl) getParent()).checkLock();
+ // check pre-conditions for setting property value
+ checkSetValue(false);
// check type according to definition of this property
int reqType = definition.getRequiredType();
@@ -787,23 +782,8 @@
// check state of this instance
sanityCheck();
- // verify that parent node is checked-out
- if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
- throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
- }
-
- // check protected flag
- if (definition.isProtected()) {
- throw new ConstraintViolationException("cannot set the value of a protected property " + safeGetJCRPath());
- }
-
- // check multi-value flag
- if (!definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is not multi-valued");
- }
-
- // check lock status
- ((NodeImpl) getParent()).checkLock();
+ // check pre-conditions for setting property value
+ checkSetValue(true);
// check type according to definition of this property
int reqType = definition.getRequiredType();
@@ -844,23 +824,8 @@
// check state of this instance
sanityCheck();
- // verify that parent node is checked-out
- if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
- throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
- }
-
- // check protected flag
- if (definition.isProtected()) {
- throw new ConstraintViolationException("cannot set the value of a protected property " + safeGetJCRPath());
- }
-
- // check multi-value flag
- if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be set to an array of values");
- }
-
- // check lock status
- ((NodeImpl) getParent()).checkLock();
+ // check pre-conditions for setting property value
+ checkSetValue(false);
// check type according to definition of this property
int reqType = definition.getRequiredType();
@@ -890,23 +855,8 @@
// check state of this instance
sanityCheck();
- // verify that parent node is checked-out
- if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
- throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
- }
-
- // check protected flag
- if (definition.isProtected()) {
- throw new ConstraintViolationException("cannot set the value of a protected property " + safeGetJCRPath());
- }
-
- // check multi-value flag
- if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued");
- }
-
- // check lock status
- ((NodeImpl) getParent()).checkLock();
+ // check pre-conditions for setting property value
+ checkSetValue(false);
// check type according to definition of this property
int reqType = definition.getRequiredType();
@@ -947,23 +897,8 @@
// check state of this instance
sanityCheck();
- // verify that parent node is checked-out
- if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
- throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
- }
-
- // check protected flag
- if (definition.isProtected()) {
- throw new ConstraintViolationException("cannot set the value of a protected property " + safeGetJCRPath());
- }
-
- // check multi-value flag
- if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be set to an array of values");
- }
-
- // check lock status
- ((NodeImpl) getParent()).checkLock();
+ // check pre-conditions for setting property value
+ checkSetValue(false);
// check type according to definition of this property
int reqType = definition.getRequiredType();
@@ -993,25 +928,8 @@
// check state of this instance
sanityCheck();
- // verify that parent node is checked-out
- if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
- String msg = "cannot set the value of a property of a checked-in node " + safeGetJCRPath();
- log.debug(msg);
- throw new VersionException(msg);
- }
-
- // check protected flag
- if (definition.isProtected()) {
- throw new ConstraintViolationException("cannot set the value of a protected property " + safeGetJCRPath());
- }
-
- // check multi-value flag
- if (definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be set to an array of values");
- }
-
- // check lock status
- ((NodeImpl) getParent()).checkLock();
+ // check pre-conditions for setting property value
+ checkSetValue(false);
// check type according to definition of this property
int reqType = definition.getRequiredType();
@@ -1049,23 +967,8 @@
// check state of this instance
sanityCheck();
- // verify that parent node is checked-out
- if (!((NodeImpl) getParent()).internalIsCheckedOut()) {
- throw new VersionException("cannot set the value of a property of a checked-in node " + safeGetJCRPath());
- }
-
- // check protected flag
- if (definition.isProtected()) {
- throw new ConstraintViolationException("cannot set the value of a protected property " + safeGetJCRPath());
- }
-
- // check multi-value flag
- if (!definition.isMultiple()) {
- throw new ValueFormatException(safeGetJCRPath() + " is not multi-valued");
- }
-
- // check lock status
- ((NodeImpl) getParent()).checkLock();
+ // check pre-conditions for setting property value
+ checkSetValue(true);
if (values != null) {
// check type of values