You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by md...@apache.org on 2011/09/01 13:52:13 UTC
svn commit: r1164026 [2/11] - in
/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi:
./ config/ hierarchy/ lock/ nodetype/ observation/ operation/ query/
security/ state/ util/ version/ xml/
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java?rev=1164026&r1=1164025&r2=1164026&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java Thu Sep 1 11:52:08 2011
@@ -27,15 +27,13 @@ import javax.jcr.RepositoryException;
* <code>NamespaceStorage</code>...
*/
public interface NamespaceStorage {
+ Map<String, String> getRegisteredNamespaces() throws RepositoryException;
+ String getPrefix(String uri) throws NamespaceException, RepositoryException;
+ String getURI(String prefix) throws NamespaceException, RepositoryException;
+ void registerNamespace(String prefix, String uri) throws NamespaceException, UnsupportedRepositoryOperationException,
+ AccessDeniedException, RepositoryException;
- public Map<String, String> getRegisteredNamespaces() throws RepositoryException;
-
- public String getPrefix(String uri) throws NamespaceException, RepositoryException;
-
- public String getURI(String prefix) throws NamespaceException, RepositoryException;
-
- public void registerNamespace(String prefix, String uri) throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException;
-
- public void unregisterNamespace(String uri) throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException;
+ void unregisterNamespace(String uri) throws NamespaceException, UnsupportedRepositoryOperationException,
+ AccessDeniedException, RepositoryException;
}
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=1164026&r1=1164025&r2=1164026&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java Thu Sep 1 11:52:08 2011
@@ -90,8 +90,7 @@ import java.util.List;
* <code>NodeImpl</code>...
*/
public class NodeImpl extends ItemImpl implements Node {
-
- private static Logger log = LoggerFactory.getLogger(NodeImpl.class);
+ private static final Logger log = LoggerFactory.getLogger(NodeImpl.class);
protected NodeImpl(SessionImpl session, NodeState state, ItemLifeCycleListener[] listeners) {
super(session, state, listeners);
@@ -101,11 +100,13 @@ public class NodeImpl extends ItemImpl i
// should not occur. Since nodetypes are defined by the 'server'
// its not possible to determine a fallback nodetype that is
// always available.
- throw new IllegalArgumentException("Unknown nodetype " + LogUtil.saveGetJCRName(nodeTypeName, session.getNameResolver()));
+ throw new IllegalArgumentException("Unknown nodetype " +
+ LogUtil.saveGetJCRName(nodeTypeName, session.getNameResolver()));
}
}
//---------------------------------------------------------------< Item >---
+
/**
* @see Item#getName()
*/
@@ -140,18 +141,15 @@ public class NodeImpl extends ItemImpl i
}
//---------------------------------------------------------------< Node >---
- /**
- * @see Node#addNode(String)
- */
- public Node addNode(String relPath) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, RepositoryException {
+
+ @Override
+ public Node addNode(String relPath) throws RepositoryException {
// validation performed in subsequent method
return addNode(relPath, null);
}
- /**
- * @see Node#addNode(String, String)
- */
- public Node addNode(String relPath, String primaryNodeTypeName) throws ItemExistsException, PathNotFoundException, NoSuchNodeTypeException, LockException, VersionException, ConstraintViolationException, RepositoryException {
+ @Override
+ public Node addNode(String relPath, String primaryNodeTypeName) throws RepositoryException {
checkIsWritable();
// build path object and retrieve parent node
Path nodePath = getPath(relPath).getNormalizedPath();
@@ -180,18 +178,14 @@ public class NodeImpl extends ItemImpl i
// get names objects for node and nt
Name nodeName = nodePath.getName();
- Name ntName = (primaryNodeTypeName == null) ? null : getQName(primaryNodeTypeName);
+ Name ntName = primaryNodeTypeName == null ? null : getQName(primaryNodeTypeName);
// create new node (including validation checks)
return parentNode.createNode(nodeName, ntName);
}
- /**
- * @see Node#orderBefore(String, String)
- */
- public synchronized void orderBefore(String srcChildRelPath,
- String destChildRelPath)
- throws UnsupportedRepositoryOperationException, VersionException, ConstraintViolationException, ItemNotFoundException, LockException, RepositoryException {
+ @Override
+ public synchronized void orderBefore(String srcChildRelPath, String destChildRelPath) throws RepositoryException {
checkIsWritable();
if (!getPrimaryNodeType().hasOrderableChildNodes()) {
@@ -220,10 +214,8 @@ public class NodeImpl extends ItemImpl i
session.getSessionItemStateManager().execute(op);
}
- /**
- * @see Node#setProperty(String, Value)
- */
- public Property setProperty(String name, Value value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ @Override
+ public Property setProperty(String name, Value value) throws RepositoryException {
// validation performed in subsequent method
int type = PropertyType.UNDEFINED;
if (value != null) {
@@ -232,17 +224,18 @@ public class NodeImpl extends ItemImpl i
return setProperty(name, value, type);
}
- /**
- * @see Node#setProperty(String, javax.jcr.Value, int)
- */
- public Property setProperty(String name, Value value, int type) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ @Override
+ public Property setProperty(String name, Value value, int type) throws RepositoryException {
checkIsWritable();
Name propName = getQName(name);
Property prop;
if (hasProperty(propName)) {
// property already exists: pass call to property
prop = getProperty(propName);
- Value v = (type == PropertyType.UNDEFINED) ? value : ValueHelper.convert(value, type, session.getValueFactory());
+ Value v = type == PropertyType.UNDEFINED
+ ? value
+ : ValueHelper.convert(value, type, session.getValueFactory());
+
prop.setValue(v);
} else {
if (value == null) {
@@ -255,10 +248,8 @@ public class NodeImpl extends ItemImpl i
return prop;
}
- /**
- * @see Node#setProperty(String, Value[])
- */
- public Property setProperty(String name, Value[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ @Override
+ public Property setProperty(String name, Value[] values) throws RepositoryException {
// validation performed in subsequent method
int type;
if (values == null || values.length == 0 || values[0] == null) {
@@ -269,17 +260,18 @@ public class NodeImpl extends ItemImpl i
return setProperty(name, values, type);
}
- /**
- * @see Node#setProperty(String, Value[], int)
- */
- public Property setProperty(String name, Value[] values, int type) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ @Override
+ public Property setProperty(String name, Value[] values, int type) throws RepositoryException {
checkIsWritable();
Name propName = getQName(name);
Property prop;
if (hasProperty(propName)) {
// property already exists: pass call to property
prop = getProperty(propName);
- Value[] vs = (type == PropertyType.UNDEFINED) ? values : ValueHelper.convert(values, type, session.getValueFactory());
+ Value[] vs = type == PropertyType.UNDEFINED
+ ? values
+ : ValueHelper.convert(values, type, session.getValueFactory());
+
prop.setValue(vs);
} else {
if (values == null) {
@@ -293,18 +285,14 @@ public class NodeImpl extends ItemImpl i
return prop;
}
- /**
- * @see Node#setProperty(String, String[])
- */
- public Property setProperty(String name, String[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ @Override
+ public Property setProperty(String name, String[] values) throws RepositoryException {
// validation performed in subsequent method
return setProperty(name, values, PropertyType.UNDEFINED);
}
- /**
- * @see Node#setProperty(String, String[], int)
- */
- public Property setProperty(String name, String[] values, int type) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ @Override
+ public Property setProperty(String name, String[] values, int type) throws RepositoryException {
// validation performed in subsequent method
Value[] vs;
if (type == PropertyType.UNDEFINED) {
@@ -315,88 +303,68 @@ public class NodeImpl extends ItemImpl i
return setProperty(name, vs, type);
}
- /**
- * @see Node#setProperty(String, String)
- */
- public Property setProperty(String name, String value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ @Override
+ public Property setProperty(String name, String value) throws RepositoryException {
// validation performed in subsequent method
- Value v = (value == null) ? null : session.getValueFactory().createValue(value, PropertyType.STRING);
+ Value v = value == null ? null : session.getValueFactory().createValue(value, PropertyType.STRING);
return setProperty(name, v, PropertyType.UNDEFINED);
}
- /**
- * @see Node#setProperty(String, String, int)
- */
- public Property setProperty(String name, String value, int type) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ @Override
+ public Property setProperty(String name, String value, int type) throws RepositoryException {
// validation performed in subsequent method
- Value v = (value == null) ? null : session.getValueFactory().createValue(value, type);
+ Value v = value == null ? null : session.getValueFactory().createValue(value, type);
return setProperty(name, v, type);
}
- /**
- * @see Node#setProperty(String, InputStream)
- */
- public Property setProperty(String name, InputStream value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ @Override
+ public Property setProperty(String name, InputStream value) throws RepositoryException {
// validation performed in subsequent method
- Value v = (value == null ? null : session.getValueFactory().createValue(value));
+ Value v = value == null ? null : session.getValueFactory().createValue(value);
return setProperty(name, v, PropertyType.BINARY);
}
- /**
- * @see javax.jcr.Node#setProperty(String, Binary)
- */
+ @Override
public Property setProperty(String name, Binary value) throws RepositoryException {
// validation performed in subsequent method
- Value v = (value == null ? null : session.getValueFactory().createValue(value));
+ Value v = value == null ? null : session.getValueFactory().createValue(value);
return setProperty(name, v, PropertyType.BINARY);
}
- /**
- * @see Node#setProperty(String, boolean)
- */
- public Property setProperty(String name, boolean value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ @Override
+ public Property setProperty(String name, boolean value) throws RepositoryException {
// validation performed in subsequent method
return setProperty(name, session.getValueFactory().createValue(value), PropertyType.BOOLEAN);
}
- /**
- * @see Node#setProperty(String, double)
- */
- public Property setProperty(String name, double value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ @Override
+ public Property setProperty(String name, double value) throws RepositoryException {
// validation performed in subsequent method
return setProperty(name, session.getValueFactory().createValue(value), PropertyType.DOUBLE);
}
- /**
- * @see javax.jcr.Node#setProperty(String, BigDecimal)
- */
+ @Override
public Property setProperty(String name, BigDecimal value) throws RepositoryException {
// validation performed in subsequent method
- Value v = (value == null ? null : session.getValueFactory().createValue(value));
+ Value v = value == null ? null : session.getValueFactory().createValue(value);
return setProperty(name, v, PropertyType.DECIMAL);
}
- /**
- * @see Node#setProperty(String, long)
- */
- public Property setProperty(String name, long value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ @Override
+ public Property setProperty(String name, long value) throws RepositoryException {
// validation performed in subsequent method
return setProperty(name, session.getValueFactory().createValue(value), PropertyType.LONG);
}
- /**
- * @see Node#setProperty(String, Calendar)
- */
- public Property setProperty(String name, Calendar value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ @Override
+ public Property setProperty(String name, Calendar value) throws RepositoryException {
// validation performed in subsequent method
- Value v = (value == null ? null : session.getValueFactory().createValue(value));
+ Value v = value == null ? null : session.getValueFactory().createValue(value);
return setProperty(name, v, PropertyType.DATE);
}
- /**
- * @see Node#setProperty(String, Node)
- */
- public Property setProperty(String name, Node value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ @Override
+ public Property setProperty(String name, Node value) throws RepositoryException {
// duplicate check to make sure, property can be written before value
// validation below.
checkIsWritable();
@@ -410,10 +378,8 @@ public class NodeImpl extends ItemImpl i
return setProperty(name, v, PropertyType.REFERENCE);
}
- /**
- * @see Node#getNode(String)
- */
- public Node getNode(String relPath) throws PathNotFoundException, RepositoryException {
+ @Override
+ public Node getNode(String relPath) throws RepositoryException {
checkStatus();
NodeEntry nodeEntry = resolveRelativeNodePath(relPath);
if (nodeEntry == null) {
@@ -426,9 +392,7 @@ public class NodeImpl extends ItemImpl i
}
}
- /**
- * @see Node#getNodes()
- */
+ @Override
public NodeIterator getNodes() throws RepositoryException {
checkStatus();
// NOTE: Don't use a class derived from TraversingElementVisitor to traverse
@@ -446,28 +410,22 @@ public class NodeImpl extends ItemImpl i
}
}
- /**
- * @see Node#getNodes(String)
- */
+ @Override
public NodeIterator getNodes(String namePattern) throws RepositoryException {
checkStatus();
return ChildrenCollectorFilter.collectChildNodes(this, namePattern);
}
- /**
- * @see javax.jcr.Node#getNodes(String[])
- */
+ @Override
public NodeIterator getNodes(String[] nameGlobs) throws RepositoryException {
checkStatus();
return ChildrenCollectorFilter.collectChildNodes(this, nameGlobs);
}
- /**
- * @see Node#getProperty(String)
- */
- public Property getProperty(String relPath) throws PathNotFoundException, RepositoryException {
+ @Override
+ public Property getProperty(String relPath) throws RepositoryException {
checkStatus();
PropertyEntry entry = resolveRelativePropertyPath(relPath);
if (entry == null) {
@@ -482,9 +440,7 @@ public class NodeImpl extends ItemImpl i
}
}
- /**
- * @see Node#getProperties()
- */
+ @Override
public PropertyIterator getProperties() throws RepositoryException {
checkStatus();
try {
@@ -500,9 +456,7 @@ public class NodeImpl extends ItemImpl i
}
}
- /**
- * @see Node#getProperties(String)
- */
+ @Override
public PropertyIterator getProperties(String namePattern) throws RepositoryException {
checkStatus();
@@ -512,17 +466,15 @@ public class NodeImpl extends ItemImpl i
/**
* @see javax.jcr.Node#getProperties(String)
*/
- public PropertyIterator getProperties(String[] nameGlobs)
- throws RepositoryException {
+ @Override
+ public PropertyIterator getProperties(String[] nameGlobs) throws RepositoryException {
checkStatus();
return ChildrenCollectorFilter.collectProperties(this, nameGlobs);
}
- /**
- * @see Node#getPrimaryItem()
- */
- public Item getPrimaryItem() throws ItemNotFoundException, RepositoryException {
+ @Override
+ public Item getPrimaryItem() throws RepositoryException {
checkStatus();
String name = getPrimaryNodeType().getPrimaryItemName();
if (name == null) {
@@ -537,10 +489,8 @@ public class NodeImpl extends ItemImpl i
}
}
- /**
- * @see Node#getUUID()
- */
- public String getUUID() throws UnsupportedRepositoryOperationException, RepositoryException {
+ @Override
+ public String getUUID() throws RepositoryException {
checkStatus();
String uuid = getNodeState().getUniqueID();
if (uuid == null || !isNodeType(NameConstants.MIX_REFERENCEABLE)) {
@@ -550,17 +500,13 @@ public class NodeImpl extends ItemImpl i
return uuid;
}
- /**
- * @see Node#getIdentifier()
- */
+ @Override
public String getIdentifier() throws RepositoryException {
checkStatus();
return session.getIdFactory().toJcrIdentifier(getNodeEntry().getId());
}
- /**
- * @see Node#getIndex()
- */
+ @Override
public int getIndex() throws RepositoryException {
checkStatus();
int index = getNodeEntry().getIndex();
@@ -570,23 +516,17 @@ public class NodeImpl extends ItemImpl i
return index;
}
- /**
- * @see Node#getReferences()
- */
+ @Override
public PropertyIterator getReferences() throws RepositoryException {
return getReferences(null);
}
- /**
- * @see javax.jcr.Node#getReferences(String)
- */
+ @Override
public PropertyIterator getReferences(String name) throws RepositoryException {
return getReferences(name, false);
}
- /**
- * @see javax.jcr.Node#getWeakReferences()
- */
+ @Override
public PropertyIterator getWeakReferences() throws RepositoryException {
return getWeakReferences(null);
}
@@ -594,26 +534,23 @@ public class NodeImpl extends ItemImpl i
/**
* @see javax.jcr.Node#getWeakReferences()
*/
+ @Override
public PropertyIterator getWeakReferences(String name) throws RepositoryException {
return getReferences(name, true);
}
- /**
- * @see Node#hasNode(String)
- */
+ @Override
public boolean hasNode(String relPath) throws RepositoryException {
checkStatus();
NodeEntry nodeEntry = resolveRelativeNodePath(relPath);
- return (nodeEntry != null) && getItemManager().itemExists(nodeEntry);
+ return nodeEntry != null && getItemManager().itemExists(nodeEntry);
}
- /**
- * @see Node#hasProperty(String)
- */
+ @Override
public boolean hasProperty(String relPath) throws RepositoryException {
checkStatus();
PropertyEntry childEntry = resolveRelativePropertyPath(relPath);
- return (childEntry != null) && getItemManager().itemExists(childEntry);
+ return childEntry != null && getItemManager().itemExists(childEntry);
}
/**
@@ -627,33 +564,25 @@ public class NodeImpl extends ItemImpl i
return getNodeEntry().hasPropertyEntry(propertyName);
}
- /**
- * @see Node#hasNodes()
- */
+ @Override
public boolean hasNodes() throws RepositoryException {
checkStatus();
return getItemManager().hasChildNodes(getNodeEntry());
}
- /**
- * @see Node#hasProperties()
- */
+ @Override
public boolean hasProperties() throws RepositoryException {
checkStatus();
return getItemManager().hasChildProperties(getNodeEntry());
}
- /**
- * @see Node#getPrimaryNodeType()
- */
+ @Override
public NodeType getPrimaryNodeType() throws RepositoryException {
checkStatus();
return session.getNodeTypeManager().getNodeType(getPrimaryNodeTypeName());
}
- /**
- * @see javax.jcr.Node#setPrimaryType(String)
- */
+ @Override
public void setPrimaryType(String nodeTypeName) throws RepositoryException {
checkStatus();
@@ -672,7 +601,8 @@ public class NodeImpl extends ItemImpl i
NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
NodeType nt = ntMgr.getNodeType(ntName);
if (nt.isMixin() || nt.isAbstract()) {
- throw new ConstraintViolationException("Cannot change the primary type: '" + nodeTypeName + "' is a mixin type or abstract.");
+ throw new ConstraintViolationException("Cannot change the primary type: '" + nodeTypeName +
+ "' is a mixin type or abstract.");
}
// perform the operation
@@ -680,9 +610,7 @@ public class NodeImpl extends ItemImpl i
session.getSessionItemStateManager().execute(op);
}
- /**
- * @see Node#getMixinNodeTypes()
- */
+ @Override
public NodeType[] getMixinNodeTypes() throws RepositoryException {
checkStatus();
Name[] mixinNames = getNodeState().getMixinTypeNames();
@@ -693,9 +621,7 @@ public class NodeImpl extends ItemImpl i
return nta;
}
- /**
- * @see Node#isNodeType(String)
- */
+ @Override
public boolean isNodeType(String nodeTypeName) throws RepositoryException {
checkStatus();
// try shortcut first (avoids parsing of name)
@@ -706,11 +632,8 @@ public class NodeImpl extends ItemImpl i
return isNodeType(getQName(nodeTypeName));
}
- /**
- * @see Node#addMixin(String)
- */
- public void addMixin(String mixinName) throws NoSuchNodeTypeException,
- VersionException, ConstraintViolationException, LockException, RepositoryException {
+ @Override
+ public void addMixin(String mixinName) throws RepositoryException {
checkIsWritable();
Name mixinQName = getQName(mixinName);
@@ -729,17 +652,15 @@ public class NodeImpl extends ItemImpl i
}
}
- /**
- * @see Node#removeMixin(String)
- */
- public void removeMixin(String mixinName) throws NoSuchNodeTypeException,
- VersionException, ConstraintViolationException, LockException, RepositoryException {
+ @Override
+ public void removeMixin(String mixinName) throws RepositoryException {
checkIsWritable();
Name ntName = getQName(mixinName);
List<Name> mixinValue = getMixinTypes();
// remove name of target mixin
if (!mixinValue.remove(ntName)) {
- throw new NoSuchNodeTypeException("Cannot remove mixin '" + mixinName + "': Nodetype is not present on this node.");
+ throw new NoSuchNodeTypeException("Cannot remove mixin '" + mixinName +
+ "': Nodetype is not present on this node.");
}
// mix:referenceable needs additional assertion: the mixin cannot be
@@ -750,16 +671,15 @@ public class NodeImpl extends ItemImpl i
if (!entRemaining.includesNodeType(NameConstants.MIX_REFERENCEABLE)) {
PropertyIterator iter = getReferences();
if (iter.hasNext()) {
- throw new ConstraintViolationException("Mixin type " + mixinName + " can not be removed: the node is being referenced through at least one property of type REFERENCE");
+ throw new ConstraintViolationException("Mixin type " + mixinName +
+ " can not be removed: the node is being referenced through at least one property of type REFERENCE");
}
}
}
- /*
- * mix:lockable: the mixin cannot be removed if the node is currently
- * locked even if the editing session is the lock holder.
- */
- if (mixin.isNodeType((NameConstants.MIX_LOCKABLE))) {
+ // mix:lockable: the mixin cannot be removed if the node is currently
+ // locked even if the editing session is the lock holder.
+ if (mixin.isNodeType(NameConstants.MIX_LOCKABLE)) {
EffectiveNodeType entRemaining = getRemainingENT(mixinValue);
if (!entRemaining.includesNodeType(NameConstants.MIX_LOCKABLE) && isLocked()) {
throw new ConstraintViolationException(mixinName + " can not be removed: the node is locked.");
@@ -818,14 +738,13 @@ public class NodeImpl extends ItemImpl i
*/
private EffectiveNodeType getRemainingENT(List<Name> remainingMixins)
throws ConstraintViolationException, NoSuchNodeTypeException {
+
Name[] allRemaining = remainingMixins.toArray(new Name[remainingMixins.size() + 1]);
allRemaining[remainingMixins.size()] = getPrimaryNodeTypeName();
return session.getEffectiveNodeTypeProvider().getEffectiveNodeType(allRemaining);
}
- /**
- * @see Node#canAddMixin(String)
- */
+ @Override
public boolean canAddMixin(String mixinName) throws RepositoryException {
if (!isWritable()) {
// shortcut: repository does not support writing anyway.
@@ -849,19 +768,15 @@ public class NodeImpl extends ItemImpl i
}
}
- /**
- * @see Node#getDefinition()
- */
+ @Override
public NodeDefinition getDefinition() throws RepositoryException {
checkStatus();
QNodeDefinition qnd = getNodeState().getDefinition();
return session.getNodeTypeManager().getNodeDefinition(qnd);
}
- /**
- * @see Node#checkin()
- */
- public Version checkin() throws VersionException, UnsupportedRepositoryOperationException, InvalidItemStateException, LockException, RepositoryException {
+ @Override
+ public Version checkin() throws RepositoryException {
checkIsVersionable();
checkHasPendingChanges();
checkIsLocked();
@@ -875,23 +790,21 @@ public class NodeImpl extends ItemImpl i
}
}
- /**
- * @see Node#checkout()
- */
- public void checkout() throws UnsupportedRepositoryOperationException, LockException, RepositoryException {
+ @Override
+ public void checkout() throws RepositoryException {
checkIsVersionable();
checkIsLocked();
- if (!isCheckedOut()) {
+ if (isCheckedOut()) {
+ // nothing to do
+ log.debug("Node " + safeGetJCRPath() + " is already checked out.");
+ } else {
if (session.isSupportedOption(Repository.OPTION_ACTIVITIES_SUPPORTED)) {
NodeImpl activity = (NodeImpl) session.getWorkspace().getVersionManager().getActivity();
- NodeId activityId = (activity == null) ? null : activity.getNodeState().getNodeId();
+ NodeId activityId = activity == null ? null : activity.getNodeState().getNodeId();
session.getVersionStateManager().checkout(getNodeState(), activityId);
} else {
session.getVersionStateManager().checkout(getNodeState());
}
- } else {
- // nothing to do
- log.debug("Node " + safeGetJCRPath() + " is already checked out.");
}
}
@@ -899,33 +812,29 @@ public class NodeImpl extends ItemImpl i
checkIsVersionable();
checkHasPendingChanges();
checkIsLocked();
- if (!isCheckedOut()) {
- checkout();
- return getBaseVersion();
- } else {
+ if (isCheckedOut()) {
NodeEntry newVersion;
if (session.isSupportedOption(Repository.OPTION_ACTIVITIES_SUPPORTED)) {
NodeImpl activity = (NodeImpl) session.getWorkspace().getVersionManager().getActivity();
- NodeId activityId = (activity == null) ? null : activity.getNodeState().getNodeId();
+ NodeId activityId = activity == null ? null : activity.getNodeState().getNodeId();
newVersion = session.getVersionStateManager().checkpoint(getNodeState(), activityId);
} else {
newVersion = session.getVersionStateManager().checkpoint(getNodeState());
}
return (Version) getItemManager().getItem(newVersion);
+ } else {
+ checkout();
+ return getBaseVersion();
}
}
- /**
- * @see Node#doneMerge(Version)
- */
- public void doneMerge(Version version) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException {
+ @Override
+ public void doneMerge(Version version) throws RepositoryException {
resolveMergeConflict(version, true);
}
- /**
- * @see Node#cancelMerge(Version)
- */
- public void cancelMerge(Version version) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException {
+ @Override
+ public void cancelMerge(Version version) throws RepositoryException {
resolveMergeConflict(version, false);
}
@@ -939,7 +848,7 @@ public class NodeImpl extends ItemImpl i
* @throws UnsupportedRepositoryOperationException
* @throws RepositoryException
*/
- private void resolveMergeConflict(Version version, boolean done) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException {
+ private void resolveMergeConflict(Version version, boolean done) throws RepositoryException {
checkIsVersionable();
checkHasPendingChanges();
checkIsLocked();
@@ -969,10 +878,8 @@ public class NodeImpl extends ItemImpl i
session.getVersionStateManager().resolveMergeConflict(getNodeState(), versionState, done);
}
- /**
- * @see Node#update(String)
- */
- public void update(String srcWorkspaceName) throws NoSuchWorkspaceException, AccessDeniedException, LockException, InvalidItemStateException, RepositoryException {
+ @Override
+ public void update(String srcWorkspaceName) throws RepositoryException {
checkIsWritable();
checkSessionHasPendingChanges();
@@ -993,10 +900,8 @@ public class NodeImpl extends ItemImpl i
((WorkspaceImpl)session.getWorkspace()).getUpdatableItemStateManager().execute(op);
}
- /**
- * @see Node#merge(String, boolean)
- */
- public NodeIterator merge(String srcWorkspace, boolean bestEffort) throws NoSuchWorkspaceException, AccessDeniedException, VersionException, LockException, InvalidItemStateException, RepositoryException {
+ @Override
+ public NodeIterator merge(String srcWorkspace, boolean bestEffort) throws RepositoryException {
return session.getWorkspace().getVersionManager().merge(getPath(), srcWorkspace, bestEffort);
}
@@ -1009,10 +914,8 @@ public class NodeImpl extends ItemImpl i
return session.getWorkspace().getVersionManager().merge(getPath(), srcWorkspace, bestEffort, isShallow);
}
- /**
- * @see Node#getCorrespondingNodePath(String)
- */
- public String getCorrespondingNodePath(String workspaceName) throws ItemNotFoundException, NoSuchWorkspaceException, AccessDeniedException, RepositoryException {
+ @Override
+ public String getCorrespondingNodePath(String workspaceName) throws RepositoryException {
checkStatus();
SessionImpl srcSession = null;
try {
@@ -1031,10 +934,11 @@ public class NodeImpl extends ItemImpl i
// otherwise access referenceable ancestor and calculate correspond. path.
String correspondingPath;
if (referenceableNode.getDepth() == Path.ROOT_DEPTH) {
- if (!srcSession.getItemManager().nodeExists(getQPath())) {
- throw new ItemNotFoundException("No corresponding path found in workspace " + workspaceName + "(" + safeGetJCRPath() + ")");
- } else {
+ if (srcSession.getItemManager().nodeExists(getQPath())) {
correspondingPath = getPath();
+ } else {
+ throw new ItemNotFoundException("No corresponding path found in workspace " + workspaceName +
+ '(' + safeGetJCRPath() + ')');
}
} else {
// get corresponding ancestor
@@ -1046,10 +950,11 @@ public class NodeImpl extends ItemImpl i
Path p = referenceableNode.getQPath().computeRelativePath(getQPath());
// use prefix mappings of srcSession
String relPath = session.getPathResolver().getJCRPath(p);
- if (!correspNode.hasNode(relPath)) {
- throw new ItemNotFoundException("No corresponding path found in workspace " + workspaceName + "(" + safeGetJCRPath() + ")");
- } else {
+ if (correspNode.hasNode(relPath)) {
correspondingPath = correspNode.getNode(relPath).getPath();
+ } else {
+ throw new ItemNotFoundException("No corresponding path found in workspace " + workspaceName +
+ '(' + safeGetJCRPath() + ')');
}
}
}
@@ -1062,40 +967,29 @@ public class NodeImpl extends ItemImpl i
}
}
- /**
- * @see Node#isCheckedOut()
- */
+ @Override
public boolean isCheckedOut() throws RepositoryException {
checkStatus();
// shortcut: if state is new, its ancestor must be checkout
- if (isNew()) {
- return true;
- }
- return session.getVersionStateManager().isCheckedOut(getNodeState());
+ return isNew() || session.getVersionStateManager().isCheckedOut(getNodeState());
}
- /**
- * @see Node#restore(String, boolean)
- */
- public void restore(String versionName, boolean removeExisting) throws VersionException, ItemExistsException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
+ @Override
+ public void restore(String versionName, boolean removeExisting) throws RepositoryException {
checkSessionHasPendingChanges();
// check for version-enabled and lock are performed with subsequent calls.
Version v = getVersionHistory().getVersion(versionName);
restore(this, null, v, removeExisting);
}
- /**
- * @see Node#restore(Version, boolean)
- */
- public void restore(Version version, boolean removeExisting) throws VersionException, ItemExistsException, UnsupportedRepositoryOperationException, LockException, RepositoryException {
+ @Override
+ public void restore(Version version, boolean removeExisting) throws RepositoryException {
checkSessionHasPendingChanges();
restore(this, null, version, removeExisting);
}
- /**
- * @see Node#restore(Version, String, boolean)
- */
- public void restore(Version version, String relPath, boolean removeExisting) throws PathNotFoundException, ItemExistsException, VersionException, ConstraintViolationException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
+ @Override
+ public void restore(Version version, String relPath, boolean removeExisting) throws RepositoryException {
checkSessionHasPendingChanges();
// additional checks are performed with subsequent calls.
@@ -1110,12 +1004,13 @@ public class NodeImpl extends ItemImpl i
if (itemMgr.nodeExists(parentPath)) {
Node parent = itemMgr.getNode(parentPath);
Path relQPath = parentPath.computeRelativePath(nPath);
- NodeImpl parentNode = ((NodeImpl)parent);
+ NodeImpl parentNode = (NodeImpl) parent;
// call the restore
restore(parentNode, relQPath, version, removeExisting);
} else if (itemMgr.propertyExists(parentPath)) {
// the item at parentParentPath is Property
- throw new ConstraintViolationException("Cannot restore to a parent presenting a property (relative path = '" + relPath + "'");
+ throw new ConstraintViolationException("Cannot restore to a parent presenting a property " +
+ "(relative path = '" + relPath + '\'');
} else {
// although the node itself must not exist, is direct ancestor must.
throw new PathNotFoundException("Cannot restore to relative path '" + relPath + ": Ancestor does not exist.");
@@ -1123,10 +1018,8 @@ public class NodeImpl extends ItemImpl i
}
}
- /**
- * @see Node#restoreByLabel(String, boolean)
- */
- public void restoreByLabel(String versionLabel, boolean removeExisting) throws VersionException, ItemExistsException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
+ @Override
+ public void restoreByLabel(String versionLabel, boolean removeExisting) throws RepositoryException {
checkSessionHasPendingChanges();
// check for version-enabled and lock are performed with subsequent calls.
@@ -1153,7 +1046,9 @@ public class NodeImpl extends ItemImpl i
* @throws InvalidItemStateException
* @throws RepositoryException
*/
- private void restore(NodeImpl targetNode, Path relQPath, Version version, boolean removeExisting) throws PathNotFoundException, ItemExistsException, VersionException, ConstraintViolationException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
+ private void restore(NodeImpl targetNode, Path relQPath, Version version, boolean removeExisting)
+ throws RepositoryException {
+
if (relQPath == null) {
/* restore target already exists. */
// target must be versionable
@@ -1171,8 +1066,8 @@ public class NodeImpl extends ItemImpl i
targetNode.checkIsWritable();
targetNode.checkIsLocked();
} else {
- /* If no node exists at relPath then a VersionException is thrown if
- the parent node is not checked out. */
+ // If no node exists at relPath then a VersionException is thrown if
+ // the parent node is not checked out.
if (!targetNode.isCheckedOut()) {
throw new VersionException("Parent " + targetNode.safeGetJCRPath()
+ " for non-existing restore target '"
@@ -1187,58 +1082,46 @@ public class NodeImpl extends ItemImpl i
session.getVersionStateManager().restore(targetNode.getNodeState(), relQPath, versionState, removeExisting);
}
- /**
- * @see Node#getVersionHistory()
- */
- public VersionHistory getVersionHistory() throws UnsupportedRepositoryOperationException, RepositoryException {
+ @Override
+ public VersionHistory getVersionHistory() throws RepositoryException {
checkIsVersionable();
return (VersionHistory) getProperty(NameConstants.JCR_VERSIONHISTORY).getNode();
}
- /**
- * @see Node#getBaseVersion()
- */
- public Version getBaseVersion() throws UnsupportedRepositoryOperationException, RepositoryException {
+ @Override
+ public Version getBaseVersion() throws RepositoryException {
checkIsVersionable();
return (Version) getProperty(NameConstants.JCR_BASEVERSION).getNode();
}
- /**
- * @see Node#lock(boolean, boolean)
- */
- public Lock lock(boolean isDeep, boolean isSessionScoped) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
+ @Override
+ public Lock lock(boolean isDeep, boolean isSessionScoped) throws RepositoryException {
return lock(isDeep, isSessionScoped, Long.MAX_VALUE, null);
}
- public Lock lock(boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerHint) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
+ public Lock lock(boolean isDeep, boolean isSessionScoped, long timeoutHint, String ownerHint) throws RepositoryException {
checkIsLockable();
checkHasPendingChanges();
return session.getLockStateManager().lock(getNodeState(), isDeep, isSessionScoped, timeoutHint, ownerHint);
}
- /**
- * @see Node#getLock()
- */
- public Lock getLock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, RepositoryException {
+ @Override
+ public Lock getLock() throws RepositoryException {
// lock can be inherited from a parent > do not check for node being lockable.
checkStatus();
return session.getLockStateManager().getLock(getNodeState());
}
- /**
- * @see javax.jcr.Node#unlock()
- */
- public void unlock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException {
+ @Override
+ public void unlock() throws RepositoryException {
checkIsLockable();
checkHasPendingChanges();
session.getLockStateManager().unlock(getNodeState());
}
- /**
- * @see javax.jcr.Node#holdsLock()
- */
+ @Override
public boolean holdsLock() throws RepositoryException {
// lock can be inherited from a parent > do not check for node being lockable.
checkStatus();
@@ -1247,22 +1130,18 @@ public class NodeImpl extends ItemImpl i
return false;
} else {
LockStateManager lMgr = session.getLockStateManager();
- return (lMgr.isLocked(getNodeState()) && lMgr.getLock(getNodeState()).getNode().isSame(this));
+ return lMgr.isLocked(getNodeState()) && lMgr.getLock(getNodeState()).getNode().isSame(this);
}
}
- /**
- * @see javax.jcr.Node#isLocked()
- */
+ @Override
public boolean isLocked() throws RepositoryException {
// lock can be inherited from a parent > do not check for node being lockable.
checkStatus();
return session.getLockStateManager().isLocked(getNodeState());
}
- /**
- * @see javax.jcr.Node#followLifecycleTransition(String)
- */
+ @Override
public void followLifecycleTransition(String transition) throws RepositoryException {
session.checkSupportedOption(Repository.OPTION_LIFECYCLE_SUPPORTED);
@@ -1270,9 +1149,7 @@ public class NodeImpl extends ItemImpl i
throw new UnsupportedRepositoryOperationException("JCR-1104");
}
- /**
- * @see javax.jcr.Node#getAllowedLifecycleTransistions()
- */
+ @Override
public String[] getAllowedLifecycleTransistions() throws RepositoryException {
session.checkSupportedOption(Repository.OPTION_LIFECYCLE_SUPPORTED);
@@ -1280,32 +1157,26 @@ public class NodeImpl extends ItemImpl i
throw new UnsupportedRepositoryOperationException("JCR-1104");
}
- /**
- * @see javax.jcr.Node#getSharedSet()
- */
+ @Override
public NodeIterator getSharedSet() throws RepositoryException {
// TODO: implementation missing
throw new UnsupportedRepositoryOperationException("JCR-1104");
}
- /**
- * @see javax.jcr.Node#removeShare()
- */
+ @Override
public void removeShare() throws RepositoryException {
// TODO: implementation missing
throw new UnsupportedRepositoryOperationException("JCR-1104");
}
- /**
- * @see javax.jcr.Node#removeSharedSet()
- */
+ @Override
public void removeSharedSet() throws RepositoryException {
throw new UnsupportedRepositoryOperationException("JCR-1104");
}
//--------------------------------------------------------< public impl >---
+
/**
- *
* @param qName
* @return
* @throws RepositoryException
@@ -1328,11 +1199,14 @@ public class NodeImpl extends ItemImpl i
}
// check effective node type
- EffectiveNodeType effnt = session.getEffectiveNodeTypeProvider().getEffectiveNodeType(getNodeState().getNodeTypeNames());
+ EffectiveNodeType effnt = session.getEffectiveNodeTypeProvider().getEffectiveNodeType(getNodeState()
+ .getNodeTypeNames());
+
return effnt.includesNodeType(qName);
}
//-----------------------------------------------------------< ItemImpl >---
+
/**
* @see ItemImpl#getName()
*/
@@ -1348,6 +1222,7 @@ public class NodeImpl extends ItemImpl i
//------------------------------------------------------< check methods >---
+
/**
* Checks if this nodes session has pending changes.
*
@@ -1359,11 +1234,10 @@ public class NodeImpl extends ItemImpl i
}
/**
- *
* @throws InvalidItemStateException
* @throws RepositoryException
*/
- private void checkHasPendingChanges() throws InvalidItemStateException, RepositoryException {
+ private void checkHasPendingChanges() throws RepositoryException {
if (hasPendingChanges()) {
String msg = "Node has pending changes: " + getPath();
log.debug(msg);
@@ -1384,7 +1258,7 @@ public class NodeImpl extends ItemImpl i
* @throws UnsupportedRepositoryOperationException if this node is not lockable.
* @throws RepositoryException if another error occurs.
*/
- private void checkIsLockable() throws UnsupportedRepositoryOperationException, RepositoryException {
+ private void checkIsLockable() throws RepositoryException {
checkStatus();
if (!isNodeType(NameConstants.MIX_LOCKABLE)) {
String msg = "Unable to perform locking operation on non-lockable node: " + getPath();
@@ -1399,7 +1273,7 @@ public class NodeImpl extends ItemImpl i
* @throws LockException if this node is locked by somebody else.
* @throws RepositoryException if some other error occurs.
*/
- void checkIsLocked() throws LockException, RepositoryException {
+ void checkIsLocked() throws RepositoryException {
if (isNew()) {
// if this node is new, no checks must be performed.
return;
@@ -1414,7 +1288,7 @@ public class NodeImpl extends ItemImpl i
* @throws UnsupportedRepositoryOperationException
* @throws RepositoryException
*/
- private void checkIsVersionable() throws UnsupportedRepositoryOperationException, RepositoryException {
+ private void checkIsVersionable() throws RepositoryException {
checkStatus();
if (!isNodeType(NameConstants.MIX_VERSIONABLE)) {
String msg = "Unable to perform versioning operation on non versionable node: " + getPath();
@@ -1424,6 +1298,7 @@ public class NodeImpl extends ItemImpl i
}
//---------------------------------------------< private implementation >---
+
/**
* Create a new <code>NodeState</code> and subsequently retrieves the
* corresponding <code>Node</code> object.
@@ -1439,10 +1314,7 @@ public class NodeImpl extends ItemImpl i
* @throws LockException
* @throws RepositoryException
*/
- private synchronized Node createNode(Name nodeName, Name nodeTypeName)
- throws ItemExistsException, NoSuchNodeTypeException, VersionException,
- ConstraintViolationException, LockException, RepositoryException {
-
+ private synchronized Node createNode(Name nodeName, Name nodeTypeName) throws RepositoryException {
QNodeDefinition definition = session.getItemDefinitionProvider().getQNodeDefinition(getNodeState().getAllNodeTypeNames(), nodeName, nodeTypeName);
if (nodeTypeName == null) {
// use default node type
@@ -1461,14 +1333,13 @@ public class NodeImpl extends ItemImpl i
// TODO: protected due to usage within VersionImpl, VersionHistoryImpl (check for alternatives)
/**
- *
* @param nodeName
* @param index
* @return
* @throws PathNotFoundException
* @throws RepositoryException
*/
- protected Node getNode(Name nodeName, int index) throws PathNotFoundException, RepositoryException {
+ protected Node getNode(Name nodeName, int index) throws RepositoryException {
checkStatus();
try {
NodeEntry nEntry = getNodeEntry().getNodeEntry(nodeName, index);
@@ -1482,14 +1353,13 @@ public class NodeImpl extends ItemImpl i
}
/**
- *
* @param qName
* @return
* @throws PathNotFoundException
* @throws RepositoryException
*/
// TODO: protected due to usage within VersionImpl, VersionHistoryImpl (check for alternatives)
- protected Property getProperty(Name qName) throws PathNotFoundException, RepositoryException {
+ protected Property getProperty(Name qName) throws RepositoryException {
checkStatus();
try {
PropertyEntry pEntry = getNodeEntry().getPropertyEntry(qName, true);
@@ -1513,8 +1383,7 @@ public class NodeImpl extends ItemImpl i
* could be found.
* @throws RepositoryException if another error occurs.
*/
- private Property createProperty(Name qName, Value value, int type)
- throws ConstraintViolationException, RepositoryException {
+ private Property createProperty(Name qName, Value value, int type) throws RepositoryException {
QPropertyDefinition def = getApplicablePropertyDefinition(qName, type, false);
int targetType = def.getRequiredType();
if (targetType == PropertyType.UNDEFINED) {
@@ -1541,8 +1410,7 @@ public class NodeImpl extends ItemImpl i
* @throws ConstraintViolationException
* @throws RepositoryException
*/
- private Property createProperty(Name qName, Value[] values, int type)
- throws ConstraintViolationException, RepositoryException {
+ private Property createProperty(Name qName, Value[] values, int type) throws RepositoryException {
QPropertyDefinition def = getApplicablePropertyDefinition(qName, type, true);
int targetType = def.getRequiredType();
// make sure, the final type is not set to undefined
@@ -1571,7 +1439,6 @@ public class NodeImpl extends ItemImpl i
}
/**
- *
* @param qName
* @param type
* @param def
@@ -1581,16 +1448,15 @@ public class NodeImpl extends ItemImpl i
* @throws ConstraintViolationException
* @throws RepositoryException
*/
- private Property createProperty(Name qName, int type, QPropertyDefinition def,
- QValue[] qvs)
- throws ConstraintViolationException, RepositoryException {
+ private Property createProperty(Name qName, int type, QPropertyDefinition def, QValue[] qvs)
+ throws RepositoryException {
+
Operation op = AddProperty.create(getNodeState(), qName, type, def, qvs);
session.getSessionItemStateManager().execute(op);
return getProperty(qName);
}
/**
- *
* @param jcrName
* @return
* @throws RepositoryException
@@ -1613,7 +1479,6 @@ public class NodeImpl extends ItemImpl i
}
/**
- *
* @param name
* @param weak
* @return
@@ -1621,13 +1486,12 @@ public class NodeImpl extends ItemImpl i
*/
private LazyItemIterator getReferences(String name, boolean weak) throws RepositoryException {
checkStatus();
- Name propName = (name == null) ? null : getQName(name);
+ Name propName = name == null ? null : getQName(name);
Iterator<PropertyId> itr = getNodeState().getNodeReferences(propName, weak);
return new LazyItemIterator(getItemManager(), session.getHierarchyManager(), itr);
}
/**
- *
* @param mixinName
* @return
* @throws NoSuchNodeTypeException
@@ -1681,7 +1545,6 @@ public class NodeImpl extends ItemImpl i
}
/**
- *
* @param relativePath
* @return
* @throws RepositoryException
@@ -1824,10 +1687,9 @@ public class NodeImpl extends ItemImpl i
* could be found
* @throws RepositoryException if another error occurs
*/
- private QPropertyDefinition getApplicablePropertyDefinition(Name propertyName,
- int type,
- boolean multiValued)
- throws ConstraintViolationException, RepositoryException {
+ private QPropertyDefinition getApplicablePropertyDefinition(Name propertyName, int type, boolean multiValued)
+ throws RepositoryException {
+
return session.getItemDefinitionProvider().getQPropertyDefinition(getNodeState().getAllNodeTypeNames(), propertyName, type, multiValued);
}
}
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java?rev=1164026&r1=1164025&r2=1164026&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/PropertyImpl.java Thu Sep 1 11:52:08 2011
@@ -54,18 +54,15 @@ import org.slf4j.LoggerFactory;
* <code>PropertyImpl</code>...
*/
public class PropertyImpl extends ItemImpl implements Property {
-
- private static Logger log = LoggerFactory.getLogger(PropertyImpl.class);
-
- public static final int UNDEFINED_PROPERTY_LENGTH = -1;
+ private static final Logger log = LoggerFactory.getLogger(PropertyImpl.class);
public PropertyImpl(SessionImpl session, PropertyState state, ItemLifeCycleListener[] listeners) {
super(session, state, listeners);
- // NOTE: JCR value(s) will be read (and converted from the internal value
- // representation) on demand.
+ // NOTE: JCR value(s) will be read (and converted from the internal value representation) on demand.
}
//-----------------------------------------------------< Item interface >---
+
/**
* @see Item#getName()
*/
@@ -100,33 +97,30 @@ public class PropertyImpl extends ItemIm
}
//-------------------------------------------------< Property interface >---
- /**
- * @see Property#setValue(javax.jcr.Value)
- */
- public void setValue(Value value) throws ValueFormatException, VersionException, LockException, RepositoryException {
+
+ @Override
+ public void setValue(Value value) throws RepositoryException {
checkIsWritable(false);
- int valueType = (value != null) ? value.getType() : PropertyType.UNDEFINED;
+ int valueType = value != null ? value.getType() : PropertyType.UNDEFINED;
int reqType = getRequiredType(valueType);
setValue(value, reqType);
}
- /**
- * @see Property#setValue(javax.jcr.Value[])
- */
- public void setValue(Value[] values) throws ValueFormatException, VersionException, LockException, RepositoryException {
+ @Override
+ public void setValue(Value[] values) throws RepositoryException {
checkIsWritable(true);
// assert equal types for all values entries
int valueType = PropertyType.UNDEFINED;
if (values != null) {
- for (int i = 0; i < values.length; i++) {
- if (values[i] == null) {
+ for (Value value : values) {
+ if (value == null) {
// skip null values as those will be purged later
continue;
}
if (valueType == PropertyType.UNDEFINED) {
- valueType = values[i].getType();
- } else if (valueType != values[i].getType()) {
- String msg = "Inhomogeneous type of values (" + safeGetJCRPath() + ")";
+ valueType = value.getType();
+ } else if (valueType != value.getType()) {
+ String msg = "Inhomogeneous type of values (" + safeGetJCRPath() + ')';
log.debug(msg);
throw new ValueFormatException(msg);
}
@@ -135,8 +129,9 @@ public class PropertyImpl extends ItemIm
int targetType = getDefinition().getRequiredType();
if (targetType == PropertyType.UNDEFINED) {
- targetType = (valueType == PropertyType.UNDEFINED) ? PropertyType.STRING : valueType;
+ targetType = valueType == PropertyType.UNDEFINED ? PropertyType.STRING : valueType;
}
+
// convert to internal values of correct type
QValue[] qValues = null;
if (values != null) {
@@ -146,10 +141,8 @@ public class PropertyImpl extends ItemIm
setInternalValues(qValues, targetType);
}
- /**
- * @see Property#setValue(String)
- */
- public void setValue(String value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ @Override
+ public void setValue(String value) throws RepositoryException {
checkIsWritable(false);
int reqType = getRequiredType(PropertyType.STRING);
if (value == null) {
@@ -159,10 +152,8 @@ public class PropertyImpl extends ItemIm
}
}
- /**
- * @see Property#setValue(String[])
- */
- public void setValue(String[] values) throws ValueFormatException, VersionException, LockException, RepositoryException {
+ @Override
+ public void setValue(String[] values) throws RepositoryException {
checkIsWritable(true);
int reqType = getRequiredType(PropertyType.STRING);
@@ -174,13 +165,13 @@ public class PropertyImpl extends ItemIm
String string = values[i];
QValue qValue = null;
if (string != null) {
- if (reqType != PropertyType.STRING) {
+ if (reqType == PropertyType.STRING) {
+ // no type conversion required
+ qValue = session.getQValueFactory().create(string, PropertyType.STRING);
+ } else {
// type conversion required
Value v = ValueHelper.convert(string, reqType, session.getValueFactory());
qValue = ValueFormat.getQValue(v, session.getNamePathResolver(), session.getQValueFactory());
- } else {
- // no type conversion required
- qValue = session.getQValueFactory().create(string, PropertyType.STRING);
}
}
qValues[i] = qValue;
@@ -189,10 +180,8 @@ public class PropertyImpl extends ItemIm
setInternalValues(qValues, reqType);
}
- /**
- * @see Property#setValue(InputStream)
- */
- public void setValue(InputStream value) throws ValueFormatException, VersionException, LockException, RepositoryException {
+ @Override
+ public void setValue(InputStream value) throws RepositoryException {
checkIsWritable(false);
int reqType = getRequiredType(PropertyType.BINARY);
if (value == null) {
@@ -202,9 +191,7 @@ public class PropertyImpl extends ItemIm
}
}
- /**
- * @see Property#setValue(Binary)
- */
+ @Override
public void setValue(Binary value) throws RepositoryException {
checkIsWritable(false);
int reqType = getRequiredType(PropertyType.BINARY);
@@ -215,37 +202,29 @@ public class PropertyImpl extends ItemIm
}
}
- /**
- * @see Property#setValue(long)
- */
- public void setValue(long value) throws ValueFormatException, VersionException, LockException, RepositoryException {
+ @Override
+ public void setValue(long value) throws RepositoryException {
checkIsWritable(false);
int reqType = getRequiredType(PropertyType.LONG);
setValue(session.getValueFactory().createValue(value), reqType);
}
- /**
- * @see Property#setValue(double)
- */
- public void setValue(double value) throws ValueFormatException, VersionException, LockException, RepositoryException {
+ @Override
+ public void setValue(double value) throws RepositoryException {
checkIsWritable(false);
int reqType = getRequiredType(PropertyType.DOUBLE);
setValue(session.getValueFactory().createValue(value), reqType);
}
- /**
- * @see Property#setValue(BigDecimal)
- */
+ @Override
public void setValue(BigDecimal value) throws RepositoryException {
checkIsWritable(false);
int reqType = getRequiredType(PropertyType.DECIMAL);
setValue(session.getValueFactory().createValue(value), reqType);
}
- /**
- * @see Property#setValue(Calendar)
- */
- public void setValue(Calendar value) throws ValueFormatException, VersionException, LockException, RepositoryException {
+ @Override
+ public void setValue(Calendar value) throws RepositoryException {
checkIsWritable(false);
int reqType = getRequiredType(PropertyType.DATE);
if (value == null) {
@@ -255,19 +234,15 @@ public class PropertyImpl extends ItemIm
}
}
- /**
- * @see Property#setValue(boolean)
- */
- public void setValue(boolean value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ @Override
+ public void setValue(boolean value) throws RepositoryException {
checkIsWritable(false);
int reqType = getRequiredType(PropertyType.BOOLEAN);
setValue(session.getValueFactory().createValue(value), reqType);
}
- /**
- * @see Property#setValue(Node)
- */
- public void setValue(Node value) throws ValueFormatException, VersionException, LockException, RepositoryException {
+ @Override
+ public void setValue(Node value) throws RepositoryException {
checkIsWritable(false);
int reqType = getRequiredType(PropertyType.REFERENCE);
if (value == null) {
@@ -279,18 +254,14 @@ public class PropertyImpl extends ItemIm
}
}
- /**
- * @see Property#getValue()
- */
- public Value getValue() throws ValueFormatException, RepositoryException {
+ @Override
+ public Value getValue() throws RepositoryException {
QValue value = getQValue();
return ValueFormat.getJCRValue(value, session.getNamePathResolver(), session.getJcrValueFactory());
}
- /**
- * @see Property#getValues()
- */
- public Value[] getValues() throws ValueFormatException, RepositoryException {
+ @Override
+ public Value[] getValues() throws RepositoryException {
QValue[] qValues = getQValues();
Value[] values = new Value[qValues.length];
for (int i = 0; i < qValues.length; i++) {
@@ -299,66 +270,48 @@ public class PropertyImpl extends ItemIm
return values;
}
- /**
- * @see Property#getString()
- */
- public String getString() throws ValueFormatException, RepositoryException {
+ @Override
+ public String getString() throws RepositoryException {
return getValue().getString();
}
- /**
- * @see Property#getStream()
- */
- public InputStream getStream() throws ValueFormatException, RepositoryException {
+ @Override
+ public InputStream getStream() throws RepositoryException {
return getValue().getStream();
}
- /**
- * @see Property#getBinary()
- */
+ @Override
public Binary getBinary() throws RepositoryException {
return getValue().getBinary();
}
- /**
- * @see Property#getLong()
- */
- public long getLong() throws ValueFormatException, RepositoryException {
+ @Override
+ public long getLong() throws RepositoryException {
return getValue().getLong();
}
- /**
- * @see Property#getDouble()
- */
- public double getDouble() throws ValueFormatException, RepositoryException {
+ @Override
+ public double getDouble() throws RepositoryException {
return getValue().getDouble();
}
- /**
- * @see Property#getDecimal()
- */
+ @Override
public BigDecimal getDecimal() throws RepositoryException {
return getValue().getDecimal();
}
- /**
- * @see Property#getDate()
- */
- public Calendar getDate() throws ValueFormatException, RepositoryException {
+ @Override
+ public Calendar getDate() throws RepositoryException {
return getValue().getDate();
}
- /**
- * @see Property#getBoolean()
- */
- public boolean getBoolean() throws ValueFormatException, RepositoryException {
+ @Override
+ public boolean getBoolean() throws RepositoryException {
return getValue().getBoolean();
}
- /**
- * @see Property#getNode()
- */
- public Node getNode() throws ValueFormatException, RepositoryException {
+ @Override
+ public Node getNode() throws RepositoryException {
Value value = getValue();
switch (value.getType()) {
case PropertyType.REFERENCE:
@@ -370,7 +323,7 @@ public class PropertyImpl extends ItemIm
String path = value.getString();
Path p = session.getPathResolver().getQPath(path);
try {
- return (p.isAbsolute()) ? session.getNode(path) : getParent().getNode(path);
+ return p.isAbsolute() ? session.getNode(path) : getParent().getNode(path);
} catch (PathNotFoundException e) {
throw new ItemNotFoundException(path);
}
@@ -386,7 +339,7 @@ public class PropertyImpl extends ItemIm
Value pathValue = ValueHelper.convert(value, PropertyType.PATH, session.getValueFactory());
p = session.getPathResolver().getQPath(pathValue.getString());
try {
- return (p.isAbsolute()) ? session.getNode(pathValue.getString()) : getParent().getNode(pathValue.getString());
+ return p.isAbsolute() ? session.getNode(pathValue.getString()) : getParent().getNode(pathValue.getString());
} catch (PathNotFoundException e1) {
throw new ItemNotFoundException(pathValue.getString());
}
@@ -397,9 +350,7 @@ public class PropertyImpl extends ItemIm
}
}
- /**
- * @see Property#getProperty()
- */
+ @Override
public Property getProperty() throws RepositoryException {
Value value = getValue();
Value pathValue = ValueHelper.convert(value, PropertyType.PATH, session.getValueFactory());
@@ -412,23 +363,19 @@ public class PropertyImpl extends ItemIm
throw new ValueFormatException("Property value cannot be converted to a PATH");
}
try {
- return (absolute) ? session.getProperty(path) : getParent().getProperty(path);
+ return absolute ? session.getProperty(path) : getParent().getProperty(path);
} catch (PathNotFoundException e) {
throw new ItemNotFoundException(path);
}
}
- /**
- * @see Property#getLength
- */
- public long getLength() throws ValueFormatException, RepositoryException {
+ @Override
+ public long getLength() throws RepositoryException {
return getLength(getQValue());
}
- /**
- * @see Property#getLengths
- */
- public long[] getLengths() throws ValueFormatException, RepositoryException {
+ @Override
+ public long[] getLengths() throws RepositoryException {
QValue[] values = getQValues();
long[] lengths = new long[values.length];
for (int i = 0; i < values.length; i++) {
@@ -458,18 +405,14 @@ public class PropertyImpl extends ItemIm
return length;
}
- /**
- * @see javax.jcr.Property#getDefinition()
- */
+ @Override
public PropertyDefinition getDefinition() throws RepositoryException {
checkStatus();
QPropertyDefinition qpd = getPropertyState().getDefinition();
return session.getNodeTypeManager().getPropertyDefinition(qpd);
}
- /**
- * @see javax.jcr.Property#getType()
- */
+ @Override
public int getType() throws RepositoryException {
checkStatus();
return getPropertyState().getType();
@@ -479,11 +422,13 @@ public class PropertyImpl extends ItemIm
*
* @return true if the definition indicates that this Property is multivalued.
*/
+ @Override
public boolean isMultiple() {
return getPropertyState().isMultiValued();
}
//-----------------------------------------------------------< ItemImpl >---
+
/**
* Returns the Name defined with this <code>PropertyState</code>
*
@@ -497,6 +442,7 @@ public class PropertyImpl extends ItemIm
}
//------------------------------------------------------< check methods >---
+
/**
*
* @param multiValues
@@ -538,7 +484,7 @@ public class PropertyImpl extends ItemIm
* @throws ValueFormatException
* @throws RepositoryException
*/
- private QValue getQValue() throws ValueFormatException, RepositoryException {
+ private QValue getQValue() throws RepositoryException {
checkStatus();
if (isMultiple()) {
throw new ValueFormatException(safeGetJCRPath() + " is multi-valued and can therefore only be retrieved as an array of values");
@@ -553,7 +499,7 @@ public class PropertyImpl extends ItemIm
* @throws ValueFormatException
* @throws RepositoryException
*/
- private QValue[] getQValues() throws ValueFormatException, RepositoryException {
+ private QValue[] getQValues() throws RepositoryException {
checkStatus();
if (!isMultiple()) {
throw new ValueFormatException(safeGetJCRPath() + " is not multi-valued and can therefore only be retrieved as single value");
@@ -579,13 +525,13 @@ public class PropertyImpl extends ItemIm
}
QValue qValue;
- if (requiredType != value.getType()) {
+ if (requiredType == value.getType()) {
+ // no type conversion required
+ qValue = ValueFormat.getQValue(value, session.getNamePathResolver(), session.getQValueFactory());
+ } else {
// type conversion required
Value v = ValueHelper.convert(value, requiredType, session.getValueFactory());
qValue = ValueFormat.getQValue(v, session.getNamePathResolver(), session.getQValueFactory());
- } else {
- // no type conversion required
- qValue = ValueFormat.getQValue(value, session.getNamePathResolver(), session.getQValueFactory());
}
setInternalValues(new QValue[]{qValue}, requiredType);
}
@@ -597,7 +543,7 @@ public class PropertyImpl extends ItemIm
* @throws ConstraintViolationException
* @throws RepositoryException
*/
- private void setInternalValues(QValue[] qValues, int valueType) throws ConstraintViolationException, RepositoryException {
+ private void setInternalValues(QValue[] qValues, int valueType) throws RepositoryException {
// check for null value
if (qValues == null) {
// setting a property to null removes it automatically
@@ -625,7 +571,7 @@ public class PropertyImpl extends ItemIm
* @throws ValueFormatException
* @throws RepositoryException
*/
- static void checkValidReference(Node value, int propertyType, NameResolver resolver) throws ValueFormatException, RepositoryException {
+ static void checkValidReference(Node value, int propertyType, NameResolver resolver) throws RepositoryException {
if (propertyType == PropertyType.REFERENCE) {
String jcrName = resolver.getJCRName(NameConstants.MIX_REFERENCEABLE);
if (!value.isNodeType(jcrName)) {
Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java?rev=1164026&r1=1164025&r2=1164026&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java (original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/RepositoryImpl.java Thu Sep 1 11:52:08 2011
@@ -56,13 +56,12 @@ import org.slf4j.LoggerFactory;
* <code>RepositoryImpl</code>...
*/
public class RepositoryImpl extends AbstractRepository implements Referenceable {
+ private static final Logger log = LoggerFactory.getLogger(RepositoryImpl.class);
- private static Logger log = LoggerFactory.getLogger(RepositoryImpl.class);
-
- // configuration of the repository
+ /** configuration of the repository */
private final RepositoryConfig config;
private final Map<String, Value[]> descriptors;
- private Reference reference = null;
+ private Reference reference;
private RepositoryImpl(RepositoryConfig config) throws RepositoryException {
this.config = config;
@@ -71,10 +70,13 @@ public class RepositoryImpl extends Abst
// expected to contain Name or Path values.
ValueFactory vf = ValueFactoryImpl.getInstance();
NamePathResolver resolver = new DefaultNamePathResolver(new NamespaceResolver() {
- public String getURI(String prefix) throws NamespaceException {
+ @Override
+ public String getURI(String prefix) {
return prefix;
}
- public String getPrefix(String uri) throws NamespaceException {
+
+ @Override
+ public String getPrefix(String uri) {
return uri;
}
});
@@ -99,6 +101,7 @@ public class RepositoryImpl extends Abst
/**
* @see Repository#getDescriptorKeys()
*/
+ @Override
public String[] getDescriptorKeys() {
return descriptors.keySet().toArray(new String[descriptors.keySet().size()]);
}
@@ -106,10 +109,11 @@ public class RepositoryImpl extends Abst
/**
* @see Repository#getDescriptor(String)
*/
+ @Override
public String getDescriptor(String key) {
Value v = getDescriptorValue(key);
try {
- return (v == null) ? null : v.getString();
+ return v == null ? null : v.getString();
} catch (RepositoryException e) {
log.error("corrupt descriptor value: " + key, e);
return null;
@@ -119,35 +123,39 @@ public class RepositoryImpl extends Abst
/**
* @see Repository#getDescriptorValue(String)
*/
+ @Override
public Value getDescriptorValue(String key) {
Value[] vs = getDescriptorValues(key);
- return (vs == null || vs.length != 1) ? null : vs[0];
+ return vs == null || vs.length != 1 ? null : vs[0];
}
/**
* @see Repository#getDescriptorValues(String)
*/
+ @Override
public Value[] getDescriptorValues(String key) {
- if (!descriptors.containsKey(key)) {
- return null;
- } else {
+ if (descriptors.containsKey(key)) {
return descriptors.get(key);
+ } else {
+ return null;
}
}
/**
* @see Repository#isSingleValueDescriptor(String)
*/
+ @Override
public boolean isSingleValueDescriptor(String key) {
Value[] vs = descriptors.get(key);
- return (vs != null && vs.length == 1);
+ return vs != null && vs.length == 1;
}
/**
* @see Repository#login(javax.jcr.Credentials, String)
*/
- public Session login(Credentials credentials, String workspaceName) throws LoginException, NoSuchWorkspaceException, RepositoryException {
+ @Override
+ public Session login(Credentials credentials, String workspaceName) throws RepositoryException {
SessionInfo info = config.getRepositoryService().obtain(credentials, workspaceName);
try {
if (info instanceof XASessionInfo) {
@@ -162,9 +170,8 @@ public class RepositoryImpl extends Abst
}
//------------------------------------------------------< Referenceable >---
- /**
- * @see Referenceable#getReference()
- */
+
+ @Override
public Reference getReference() throws NamingException {
if (config instanceof Referenceable) {
Referenceable confref = (Referenceable)config;
@@ -218,11 +225,12 @@ public class RepositoryImpl extends Abst
* </pre>
*/
public static class Factory implements ObjectFactory {
-
public static final String RCF = RepositoryImpl.class.getName() + ".factory";
public static final String RCC = RepositoryImpl.class.getName() + ".class";
- public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment) throws Exception {
+ @Override
+ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment)
+ throws Exception {
Object res = null;
if (obj instanceof Reference) {
@@ -235,13 +243,13 @@ public class RepositoryImpl extends Abst
if (rfac == null || !(rfac instanceof StringRefAddr)) {
throw new Exception("Address type " + RCF + " missing or of wrong class: " + rfac);
}
- String configFactoryClassName = (String)((StringRefAddr)rfac).getContent();
+ String configFactoryClassName = (String) rfac.getContent();
RefAddr rclas = ref.get(RCC);
if (rclas == null || !(rclas instanceof StringRefAddr)) {
throw new Exception("Address type " + RCC + " missing or of wrong class: " + rclas);
}
- String repositoryConfigClassName = (String)((StringRefAddr)rclas).getContent();
+ String repositoryConfigClassName = (String) rclas.getContent();
Object rof = Class.forName(configFactoryClassName).newInstance();