You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2015/09/02 12:17:52 UTC
svn commit: r1700753 [2/2] - in
/jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr:
delegate/ lock/ query/ security/ session/ session/operation/ version/
Modified: jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java?rev=1700753&r1=1700752&r2=1700753&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java (original)
+++ jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/NodeImpl.java Wed Sep 2 10:17:51 2015
@@ -35,6 +35,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.jcr.AccessDeniedException;
import javax.jcr.Binary;
@@ -113,8 +114,9 @@ public class NodeImpl<T extends NodeDele
*/
private static final Logger LOG = LoggerFactory.getLogger(NodeImpl.class);
+ @CheckForNull
public static NodeImpl<? extends NodeDelegate> createNodeOrNull(
- NodeDelegate delegate, SessionContext context)
+ @CheckForNull NodeDelegate delegate, @Nonnull SessionContext context)
throws RepositoryException {
if (delegate != null) {
return createNode(delegate, context);
@@ -123,8 +125,9 @@ public class NodeImpl<T extends NodeDele
}
}
+ @Nonnull
public static NodeImpl<? extends NodeDelegate> createNode(
- NodeDelegate delegate, SessionContext context)
+ @Nonnull NodeDelegate delegate, @Nonnull SessionContext context)
throws RepositoryException {
PropertyDelegate pd = delegate.getPropertyOrNull(JCR_PRIMARYTYPE);
String type = pd != null ? pd.getString() : null;
@@ -162,6 +165,7 @@ public class NodeImpl<T extends NodeDele
@Nonnull
public Node getParent() throws RepositoryException {
return perform(new NodeOperation<Node>(dlg, "getParent") {
+ @Nonnull
@Override
public Node perform() throws RepositoryException {
if (node.isRoot()) {
@@ -182,7 +186,8 @@ public class NodeImpl<T extends NodeDele
*/
@Override
public boolean isNew() {
- return safePerform(new NodeOperation<Boolean>(dlg, "isNew") {
+ return sessionDelegate.safePerform(new NodeOperation<Boolean>(dlg, "isNew") {
+ @Nonnull
@Override
public Boolean perform() {
return node.exists() && node.getStatus() == Status.NEW;
@@ -195,7 +200,8 @@ public class NodeImpl<T extends NodeDele
*/
@Override
public boolean isModified() {
- return safePerform(new NodeOperation<Boolean>(dlg, "isModified") {
+ return sessionDelegate.safePerform(new NodeOperation<Boolean>(dlg, "isModified") {
+ @Nonnull
@Override
public Boolean perform() {
return node.exists() && node.getStatus() == Status.MODIFIED;
@@ -208,15 +214,14 @@ public class NodeImpl<T extends NodeDele
*/
@Override
public void remove() throws RepositoryException {
- perform(new ItemWriteOperation<Void>("remove") {
+ sessionDelegate.performVoid(new ItemWriteOperation("remove") {
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
if (dlg.isRoot()) {
throw new RepositoryException("Cannot remove the root node");
}
dlg.remove();
- return null;
}
@Override
@@ -255,6 +260,7 @@ public class NodeImpl<T extends NodeDele
checkIndexOnName(relPath);
return perform(new ItemWriteOperation<Node>("addNode") {
+ @Nonnull
@Override
public Node perform() throws RepositoryException {
String oakName = PathUtils.getName(oakPath);
@@ -303,9 +309,9 @@ public class NodeImpl<T extends NodeDele
@Override
public void orderBefore(final String srcChildRelPath, final String destChildRelPath) throws RepositoryException {
- perform(new ItemWriteOperation<Void>("orderBefore") {
+ sessionDelegate.performVoid(new ItemWriteOperation("orderBefore") {
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
getEffectiveNodeType().checkOrderableChildNodes();
String oakSrcChildRelPath = getOakPathOrThrowNotFound(srcChildRelPath);
String oakDestChildRelPath = null;
@@ -313,7 +319,7 @@ public class NodeImpl<T extends NodeDele
oakDestChildRelPath = getOakPathOrThrowNotFound(destChildRelPath);
}
dlg.orderBefore(oakSrcChildRelPath, oakDestChildRelPath);
- return null;
+
}
});
}
@@ -526,6 +532,7 @@ public class NodeImpl<T extends NodeDele
public Node getNode(String relPath) throws RepositoryException {
final String oakPath = getOakPathOrThrowNotFound(relPath);
return perform(new NodeOperation<Node>(dlg, "getNode") {
+ @Nonnull
@Override
public Node perform() throws RepositoryException {
NodeDelegate nd = node.getChild(oakPath);
@@ -542,6 +549,7 @@ public class NodeImpl<T extends NodeDele
@Nonnull
public NodeIterator getNodes() throws RepositoryException {
return perform(new NodeOperation<NodeIterator>(dlg, "getNodes") {
+ @Nonnull
@Override
public NodeIterator perform() throws RepositoryException {
Iterator<NodeDelegate> children = node.getChildren();
@@ -572,6 +580,7 @@ public class NodeImpl<T extends NodeDele
public NodeIterator getNodes(final String namePattern)
throws RepositoryException {
return perform(new NodeOperation<NodeIterator>(dlg, "getNodes") {
+ @Nonnull
@Override
public NodeIterator perform() throws RepositoryException {
Iterator<NodeDelegate> children = Iterators.filter(
@@ -592,6 +601,7 @@ public class NodeImpl<T extends NodeDele
@Nonnull
public NodeIterator getNodes(final String[] nameGlobs) throws RepositoryException {
return perform(new NodeOperation<NodeIterator>(dlg, "getNodes") {
+ @Nonnull
@Override
public NodeIterator perform() throws RepositoryException {
Iterator<NodeDelegate> children = Iterators.filter(
@@ -613,6 +623,7 @@ public class NodeImpl<T extends NodeDele
public Property getProperty(String relPath) throws RepositoryException {
final String oakPath = getOakPathOrThrowNotFound(relPath);
return perform(new NodeOperation<PropertyImpl>(dlg, "getProperty") {
+ @Nonnull
@Override
public PropertyImpl perform() throws RepositoryException {
PropertyDelegate pd = node.getPropertyOrNull(oakPath);
@@ -630,6 +641,7 @@ public class NodeImpl<T extends NodeDele
@Nonnull
public PropertyIterator getProperties() throws RepositoryException {
return perform(new NodeOperation<PropertyIterator>(dlg, "getProperties") {
+ @Nonnull
@Override
public PropertyIterator perform() throws RepositoryException {
Iterator<PropertyDelegate> properties = node.getProperties();
@@ -644,6 +656,7 @@ public class NodeImpl<T extends NodeDele
@Nonnull
public PropertyIterator getProperties(final String namePattern) throws RepositoryException {
return perform(new NodeOperation<PropertyIterator>(dlg, "getProperties") {
+ @Nonnull
@Override
public PropertyIterator perform() throws RepositoryException {
Iterator<PropertyDelegate> properties = Iterators.filter(
@@ -664,6 +677,7 @@ public class NodeImpl<T extends NodeDele
@Nonnull
public PropertyIterator getProperties(final String[] nameGlobs) throws RepositoryException {
return perform(new NodeOperation<PropertyIterator>(dlg, "getProperties") {
+ @Nonnull
@Override
public PropertyIterator perform() throws RepositoryException {
Iterator<PropertyDelegate> propertyNames = Iterators.filter(
@@ -687,6 +701,7 @@ public class NodeImpl<T extends NodeDele
@Nonnull
public Item getPrimaryItem() throws RepositoryException {
return perform(new NodeOperation<Item>(dlg, "getPrimaryItem") {
+ @Nonnull
@Override
public Item perform() throws RepositoryException {
// TODO: avoid nested calls
@@ -715,6 +730,7 @@ public class NodeImpl<T extends NodeDele
@Nonnull
public String getUUID() throws RepositoryException {
return perform(new NodeOperation<String>(dlg, "getUUID") {
+ @Nonnull
@Override
public String perform() throws RepositoryException {
// TODO: avoid nested calls
@@ -731,6 +747,7 @@ public class NodeImpl<T extends NodeDele
public String getIdentifier() throws RepositoryException {
// TODO: name mapping for path identifiers
return perform(new NodeOperation<String>(dlg, "getIdentifier") {
+ @Nonnull
@Override
public String perform() throws RepositoryException {
return node.getIdentifier();
@@ -746,6 +763,7 @@ public class NodeImpl<T extends NodeDele
private PropertyIterator internalGetReferences(final String name, final boolean weak) throws RepositoryException {
return perform(new NodeOperation<PropertyIterator>(dlg, "internalGetReferences") {
+ @Nonnull
@Override
public PropertyIterator perform() throws InvalidItemStateException {
IdentifierManager idManager = sessionDelegate.getIdManager();
@@ -802,6 +820,7 @@ public class NodeImpl<T extends NodeDele
try {
final String oakPath = getOakPathOrThrow(relPath);
return perform(new NodeOperation<Boolean>(dlg, "hasNode") {
+ @Nonnull
@Override
public Boolean perform() throws RepositoryException {
return node.getChild(oakPath) != null;
@@ -817,6 +836,7 @@ public class NodeImpl<T extends NodeDele
try {
final String oakPath = getOakPathOrThrow(relPath);
return perform(new NodeOperation<Boolean>(dlg, "hasProperty") {
+ @Nonnull
@Override
public Boolean perform() throws RepositoryException {
return node.getPropertyOrNull(oakPath) != null;
@@ -835,6 +855,7 @@ public class NodeImpl<T extends NodeDele
@Override
public boolean hasProperties() throws RepositoryException {
return perform(new NodeOperation<Boolean>(dlg, "hasProperties") {
+ @Nonnull
@Override
public Boolean perform() throws RepositoryException {
return node.getPropertyCount() != 0;
@@ -849,6 +870,7 @@ public class NodeImpl<T extends NodeDele
@Nonnull
public NodeType getPrimaryNodeType() throws RepositoryException {
return perform(new NodeOperation<NodeType>(dlg, "getPrimaryNodeType") {
+ @Nonnull
@Override
public NodeType perform() throws RepositoryException {
Tree tree = node.getTree();
@@ -878,6 +900,7 @@ public class NodeImpl<T extends NodeDele
@Nonnull
public NodeType[] getMixinNodeTypes() throws RepositoryException {
return perform(new NodeOperation<NodeType[]>(dlg, "getMixinNodeTypes") {
+ @Nonnull
@Override
public NodeType[] perform() throws RepositoryException {
Tree tree = node.getTree();
@@ -911,6 +934,7 @@ public class NodeImpl<T extends NodeDele
public boolean isNodeType(String nodeTypeName) throws RepositoryException {
final String oakName = getOakName(nodeTypeName);
return perform(new NodeOperation<Boolean>(dlg, "isNodeType") {
+ @Nonnull
@Override
public Boolean perform() throws RepositoryException {
return getNodeTypeManager().isNodeType(node.getTree(), oakName);
@@ -920,7 +944,7 @@ public class NodeImpl<T extends NodeDele
@Override
public void setPrimaryType(final String nodeTypeName) throws RepositoryException {
- perform(new ItemWriteOperation<Void>("setPrimaryType") {
+ sessionDelegate.performVoid(new ItemWriteOperation("setPrimaryType") {
@Override
public void checkPreconditions() throws RepositoryException {
super.checkPreconditions();
@@ -930,9 +954,8 @@ public class NodeImpl<T extends NodeDele
}
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
internalSetPrimaryType(nodeTypeName);
- return null;
}
});
}
@@ -940,7 +963,7 @@ public class NodeImpl<T extends NodeDele
@Override
public void addMixin(String mixinName) throws RepositoryException {
final String oakTypeName = getOakName(checkNotNull(mixinName));
- perform(new ItemWriteOperation<Void>("addMixin") {
+ sessionDelegate.performVoid(new ItemWriteOperation("addMixin") {
@Override
public void checkPreconditions() throws RepositoryException {
super.checkPreconditions();
@@ -950,9 +973,8 @@ public class NodeImpl<T extends NodeDele
}
}
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
dlg.addMixin(oakTypeName);
- return null;
}
});
}
@@ -960,7 +982,7 @@ public class NodeImpl<T extends NodeDele
@Override
public void removeMixin(final String mixinName) throws RepositoryException {
final String oakTypeName = getOakName(checkNotNull(mixinName));
- perform(new ItemWriteOperation<Void>("removeMixin") {
+ sessionDelegate.performVoid(new ItemWriteOperation("removeMixin") {
@Override
public void checkPreconditions() throws RepositoryException {
super.checkPreconditions();
@@ -980,9 +1002,8 @@ public class NodeImpl<T extends NodeDele
}
}
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
dlg.removeMixin(oakTypeName);
- return null;
}
});
}
@@ -991,6 +1012,7 @@ public class NodeImpl<T extends NodeDele
public boolean canAddMixin(String mixinName) throws RepositoryException {
final String oakTypeName = getOakName(mixinName);
return perform(new NodeOperation<Boolean>(dlg, "canAddMixin") {
+ @Nonnull
@Override
public Boolean perform() throws RepositoryException {
PropertyState prop = PropertyStates.createProperty(JCR_MIXINTYPES, singleton(oakTypeName), NAMES);
@@ -1007,6 +1029,7 @@ public class NodeImpl<T extends NodeDele
@Nonnull
public NodeDefinition getDefinition() throws RepositoryException {
return perform(new NodeOperation<NodeDefinition>(dlg, "getDefinition") {
+ @Nonnull
@Override
public NodeDefinition perform() throws RepositoryException {
NodeDelegate parent = node.getParent();
@@ -1024,6 +1047,7 @@ public class NodeImpl<T extends NodeDele
@Nonnull
public String getCorrespondingNodePath(final String workspaceName) throws RepositoryException {
return toJcrPath(perform(new ItemOperation<String>(dlg, "getCorrespondingNodePath") {
+ @Nonnull
@Override
public String perform() throws RepositoryException {
checkValidWorkspace(workspaceName);
@@ -1039,9 +1063,9 @@ public class NodeImpl<T extends NodeDele
@Override
public void update(final String srcWorkspace) throws RepositoryException {
- perform(new ItemWriteOperation<Void>("update") {
+ sessionDelegate.performVoid(new ItemWriteOperation("update") {
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
checkValidWorkspace(srcWorkspace);
// check for pending changes
@@ -1054,7 +1078,6 @@ public class NodeImpl<T extends NodeDele
if (!srcWorkspace.equals(sessionDelegate.getWorkspaceName())) {
throw new UnsupportedRepositoryOperationException("OAK-118: Node.update");
}
- return null;
}
});
}
@@ -1222,15 +1245,14 @@ public class NodeImpl<T extends NodeDele
@Override
public void removeSharedSet() throws RepositoryException {
- perform(new ItemWriteOperation<Void>("removeSharedSet") {
+ sessionDelegate.performVoid(new ItemWriteOperation("removeSharedSet") {
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
// TODO: avoid nested calls
NodeIterator sharedSet = getSharedSet();
while (sharedSet.hasNext()) {
sharedSet.nextNode().removeShare();
}
- return null;
}
});
}
@@ -1330,6 +1352,7 @@ public class NodeImpl<T extends NodeDele
"Cannot set property. Node is checked in.");
}
}
+ @Nonnull
@Override
public Property perform() throws RepositoryException {
return new PropertyImpl(
@@ -1365,6 +1388,7 @@ public class NodeImpl<T extends NodeDele
"Cannot set property. Node is checked in.");
}
}
+ @Nonnull
@Override
public Property perform() throws RepositoryException {
return new PropertyImpl(
@@ -1400,6 +1424,7 @@ public class NodeImpl<T extends NodeDele
throws RepositoryException {
final String oakName = getOakName(checkNotNull(jcrName));
return perform(new ItemWriteOperation<Property>("internalRemoveProperty") {
+ @Nonnull
@Override
public Property perform() throws RepositoryException {
PropertyDelegate property = dlg.getPropertyOrNull(oakName);
@@ -1449,9 +1474,9 @@ public class NodeImpl<T extends NodeDele
return;
}
- perform(new ItemWriteOperation<Void>("rename") {
+ sessionDelegate.performVoid(new ItemWriteOperation("rename") {
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
Node parent = getParent();
String beforeName = null;
@@ -1481,7 +1506,6 @@ public class NodeImpl<T extends NodeDele
// restore position within siblings
parent.orderBefore(newName, beforeName);
}
- return null;
}
});
}
@@ -1517,7 +1541,7 @@ public class NodeImpl<T extends NodeDele
for (String mixinName : mixinNames) {
oakTypeNames.add(getOakName(checkNotNull(mixinName)));
}
- perform(new ItemWriteOperation<Void>("setMixins") {
+ sessionDelegate.performVoid(new ItemWriteOperation("setMixins") {
@Override
public void checkPreconditions() throws RepositoryException {
super.checkPreconditions();
@@ -1535,9 +1559,8 @@ public class NodeImpl<T extends NodeDele
}
}
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
dlg.setMixins(oakTypeNames);
- return null;
}
});
}
Modified: jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/PropertyImpl.java?rev=1700753&r1=1700752&r2=1700753&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/PropertyImpl.java (original)
+++ jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/PropertyImpl.java Wed Sep 2 10:17:51 2015
@@ -71,6 +71,7 @@ public class PropertyImpl extends ItemIm
@Nonnull
public Node getParent() throws RepositoryException {
return perform(new PropertyOperation<Node>(dlg, "getParent") {
+ @Nonnull
@Override
public Node perform() throws RepositoryException {
NodeDelegate parent = property.getParent();
@@ -85,7 +86,8 @@ public class PropertyImpl extends ItemIm
@Override
public boolean isNew() {
- return safePerform(new PropertyOperation<Boolean>(dlg, "isNew") {
+ return sessionDelegate.safePerform(new PropertyOperation<Boolean>(dlg, "isNew") {
+ @Nonnull
@Override
public Boolean perform() {
return property.getStatus() == Status.NEW;
@@ -95,7 +97,8 @@ public class PropertyImpl extends ItemIm
@Override
public boolean isModified() {
- return safePerform(new PropertyOperation<Boolean>(dlg, "isModified") {
+ return sessionDelegate.safePerform(new PropertyOperation<Boolean>(dlg, "isModified") {
+ @Nonnull
@Override
public Boolean perform() {
return property.getStatus() == Status.MODIFIED;
@@ -105,11 +108,10 @@ public class PropertyImpl extends ItemIm
@Override
public void remove() throws RepositoryException {
- perform(new ItemWriteOperation<Void>("remove") {
+ sessionDelegate.performVoid(new ItemWriteOperation("remove") {
@Override
- public Void perform() {
+ public void performVoid() {
dlg.remove();
- return null;
}
@Override
@@ -233,6 +235,7 @@ public class PropertyImpl extends ItemIm
@Nonnull
public Value getValue() throws RepositoryException {
return perform(new PropertyOperation<Value>(dlg, "getValue") {
+ @Nonnull
@Override
public Value perform() throws RepositoryException {
return ValueFactoryImpl.createValue(
@@ -245,6 +248,7 @@ public class PropertyImpl extends ItemIm
@Nonnull
public Value[] getValues() throws RepositoryException {
return perform(new PropertyOperation<List<Value>>(dlg, "getValues") {
+ @Nonnull
@Override
public List<Value> perform() throws RepositoryException {
return ValueFactoryImpl.createValues(
@@ -303,6 +307,7 @@ public class PropertyImpl extends ItemIm
@Nonnull
public Node getNode() throws RepositoryException {
return perform(new PropertyOperation<Node>(dlg, "getNode") {
+ @Nonnull
@Override
public Node perform() throws RepositoryException {
// TODO: avoid nested calls
@@ -356,6 +361,7 @@ public class PropertyImpl extends ItemIm
@Nonnull
public Property getProperty() throws RepositoryException {
return perform(new PropertyOperation<Property>(dlg, "getProperty") {
+ @Nonnull
@Override
public Property perform() throws RepositoryException {
// TODO: avoid nested calls
@@ -392,6 +398,7 @@ public class PropertyImpl extends ItemIm
@Nonnull
public PropertyDefinition getDefinition() throws RepositoryException {
return perform(new PropertyOperation<PropertyDefinition>(dlg, "getDefinition") {
+ @Nonnull
@Override
public PropertyDefinition perform() throws RepositoryException {
return getNodeTypeManager().getDefinition(
@@ -404,6 +411,7 @@ public class PropertyImpl extends ItemIm
@Override
public int getType() throws RepositoryException {
return perform(new PropertyOperation<Integer>(dlg, "getType") {
+ @Nonnull
@Override
public Integer perform() throws RepositoryException {
return property.getPropertyState().getType().tag();
@@ -414,6 +422,7 @@ public class PropertyImpl extends ItemIm
@Override
public boolean isMultiple() throws RepositoryException {
return perform(new PropertyOperation<Boolean>(dlg, "isMultiple") {
+ @Nonnull
@Override
public Boolean perform() throws RepositoryException {
return property.getPropertyState().isArray();
@@ -440,9 +449,9 @@ public class PropertyImpl extends ItemIm
private void internalSetValue(@Nonnull final Value value)
throws RepositoryException {
- perform(new ItemWriteOperation<Void>("internalSetValue") {
+ sessionDelegate.performVoid(new ItemWriteOperation("internalSetValue") {
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
Type<?> type = dlg.getPropertyState().getType();
if (type.isArray()) {
throw new ValueFormatException(
@@ -452,7 +461,6 @@ public class PropertyImpl extends ItemIm
Value converted = ValueHelper.convert(
value, type.tag(), getValueFactory());
dlg.setState(createSingleState(dlg.getName(), converted, type));
- return null;
}
@Override
@@ -468,9 +476,9 @@ public class PropertyImpl extends ItemIm
LOG.warn("Large multi valued property [{}] detected ({} values).",dlg.getPath(), values.length);
}
- perform(new ItemWriteOperation<Void>("internalSetValue") {
+ sessionDelegate.performVoid(new ItemWriteOperation("internalSetValue") {
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
Type<?> type = dlg.getPropertyState().getType();
if (!type.isArray()) {
throw new ValueFormatException(
@@ -486,7 +494,6 @@ public class PropertyImpl extends ItemIm
}
}
dlg.setState(createMultiState(dlg.getName(), converted, type));
- return null;
}
@Override
Modified: jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionContext.java?rev=1700753&r1=1700752&r2=1700753&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionContext.java (original)
+++ jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionContext.java Wed Sep 2 10:17:51 2015
@@ -384,9 +384,9 @@ public class SessionContext implements N
*/
// TODO: should this be in SessionImpl?
private void unlockAllSessionScopedLocks() throws RepositoryException {
- delegate.perform(new SessionOperation<Void>("unlockAllSessionScopedLocks") {
+ delegate.performVoid(new SessionOperation("unlockAllSessionScopedLocks") {
@Override
- public Void perform() {
+ public void performVoid() {
Iterator<String> iterator = sessionScopedLocks.iterator();
while (iterator.hasNext()) {
NodeDelegate node = delegate.getNode(iterator.next());
@@ -399,7 +399,6 @@ public class SessionContext implements N
}
iterator.remove();
}
- return null;
}
});
}
Modified: jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionImpl.java?rev=1700753&r1=1700752&r2=1700753&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionImpl.java (original)
+++ jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/SessionImpl.java Wed Sep 2 10:17:51 2015
@@ -135,16 +135,6 @@ public class SessionImpl implements Jack
}
}
- @CheckForNull
- private <T> T perform(@Nonnull SessionOperation<T> op) throws RepositoryException {
- return sd.perform(op);
- }
-
- @CheckForNull
- private <T> T safePerform(@Nonnull SessionOperation<T> op) {
- return sd.safePerform(op);
- }
-
@Nonnull
private String getOakPathOrThrow(@Nonnull String absPath)
throws RepositoryException {
@@ -185,9 +175,9 @@ public class SessionImpl implements Jack
@CheckForNull
public Node getNodeOrNull(final String absPath) throws RepositoryException {
checkNotNull(absPath);
- return perform(new ReadOperation<Node>("getNodeOrNull") {
+ return sd.performNullable(new ReadOperation<Node>("getNodeOrNull") {
@Override
- public Node perform() throws RepositoryException {
+ public Node performNullable() throws RepositoryException {
try {
return NodeImpl.createNodeOrNull(sd.getNode(getOakPathOrThrow(absPath)), sessionContext);
} catch (PathNotFoundException e) {
@@ -216,9 +206,9 @@ public class SessionImpl implements Jack
} catch (PathNotFoundException e) {
return null;
}
- return perform(new ReadOperation<Property>("getPropertyOrNull") {
+ return sd.performNullable(new ReadOperation<Property>("getPropertyOrNull") {
@Override
- public Property perform() throws RepositoryException {
+ public Property performNullable() {
PropertyDelegate pd = sd.getProperty(oakPath);
if (pd != null) {
return new PropertyImpl(pd, sessionContext);
@@ -242,9 +232,9 @@ public class SessionImpl implements Jack
@CheckForNull
public Item getItemOrNull(final String absPath) throws RepositoryException {
checkNotNull(absPath);
- return perform(new ReadOperation<Item>("getItemOrNull") {
+ return sd.performNullable(new ReadOperation<Item>("getItemOrNull") {
@Override
- public Item perform() throws RepositoryException {
+ public Item performNullable() throws RepositoryException {
return getItemInternal(getOakPathOrThrow(absPath));
}
});
@@ -304,14 +294,15 @@ public class SessionImpl implements Jack
@Override
@Nonnull
public Node getRootNode() throws RepositoryException {
- return perform(new ReadOperation<Node>("getRootNode") {
+ return sd.perform(new ReadOperation<Node>("getRootNode") {
+ @Nonnull
@Override
public Node perform() throws RepositoryException {
NodeDelegate nd = sd.getRootNode();
if (nd == null) {
throw new AccessDeniedException("Root node is not accessible.");
}
- return NodeImpl.createNodeOrNull(nd, sessionContext);
+ return NodeImpl.createNode(nd, sessionContext);
}
});
}
@@ -332,14 +323,15 @@ public class SessionImpl implements Jack
@Nonnull
private Node getNodeById(@Nonnull final String id) throws RepositoryException {
- return perform(new ReadOperation<Node>("getNodeById") {
+ return sd.perform(new ReadOperation<Node>("getNodeById") {
+ @Nonnull
@Override
public Node perform() throws RepositoryException {
NodeDelegate nd = sd.getNodeByIdentifier(id);
if (nd == null) {
throw new ItemNotFoundException("Node with id " + id + " does not exist.");
}
- return NodeImpl.createNodeOrNull(nd, sessionContext);
+ return NodeImpl.createNode(nd, sessionContext);
}
});
}
@@ -389,7 +381,7 @@ public class SessionImpl implements Jack
checkIndexOnName(checkNotNull(destAbsPath));
final String srcOakPath = getOakPathOrThrowNotFound(checkNotNull(srcAbsPath));
final String destOakPath = getOakPathOrThrowNotFound(destAbsPath);
- sd.perform(new WriteOperation<Void>("move") {
+ sd.performVoid(new WriteOperation("move") {
@Override
public void checkPreconditions() throws RepositoryException {
super.checkPreconditions();
@@ -398,9 +390,8 @@ public class SessionImpl implements Jack
}
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
sd.move(srcOakPath, destOakPath, true);
- return null;
}
});
}
@@ -408,18 +399,16 @@ public class SessionImpl implements Jack
@Override
public void removeItem(final String absPath) throws RepositoryException {
final String oakPath = getOakPathOrThrowNotFound(checkNotNull(absPath));
- perform(new WriteOperation<Void>("removeItem") {
+ sd.performVoid(new WriteOperation("removeItem") {
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
ItemDelegate item = sd.getItem(oakPath);
if (item == null) {
throw new PathNotFoundException(absPath);
} else if (item.isProtected()) {
throw new ConstraintViolationException(
item.getPath() + " is protected");
- } else if (item.remove()) {
- return null;
- } else {
+ } else if (!item.remove()) {
throw new RepositoryException(
item.getPath() + " could not be removed");
}
@@ -429,11 +418,10 @@ public class SessionImpl implements Jack
@Override
public void save() throws RepositoryException {
- perform(new WriteOperation<Void>("save") {
+ sd.performVoid(new WriteOperation("save") {
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
sd.save(null);
- return null;
}
@Override
@@ -445,11 +433,10 @@ public class SessionImpl implements Jack
@Override
public void refresh(final boolean keepChanges) throws RepositoryException {
- perform(new WriteOperation<Void>("refresh") {
+ sd.performVoid(new WriteOperation("refresh") {
@Override
- public Void perform() {
+ public void performVoid() {
sd.refresh(keepChanges);
- return null;
}
@Override
@@ -475,19 +462,22 @@ public class SessionImpl implements Jack
public void logout() {
if (sd.isAlive()) {
sessionCounter.decrementAndGet();
- safePerform(new SessionOperation<Void>("logout") {
- @Override
- public Void perform() {
- sessionContext.dispose();
- sd.logout();
- return null;
- }
+ try {
+ sd.performVoid(new SessionOperation("logout") {
+ @Override
+ public void performVoid() {
+ sessionContext.dispose();
+ sd.logout();
+ }
- @Override
- public boolean isLogout() {
- return true;
- }
- });
+ @Override
+ public boolean isLogout() {
+ return true;
+ }
+ });
+ } catch (RepositoryException e) {
+ throw new RuntimeException("Unexpected exception thrown by operation 'logout'", e);
+ }
}
}
@@ -634,7 +624,8 @@ public class SessionImpl implements Jack
public boolean hasPermission(String absPath, final String actions) throws RepositoryException {
final String oakPath = getOakPathOrThrow(checkNotNull(absPath));
checkNotNull(actions);
- return perform(new ReadOperation<Boolean>("hasPermission") {
+ return sd.perform(new ReadOperation<Boolean>("hasPermission") {
+ @Nonnull
@Override
public Boolean perform() throws RepositoryException {
return sessionContext.getAccessManager().hasPermissions(oakPath, actions);
Modified: jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/WorkspaceImpl.java?rev=1700753&r1=1700752&r2=1700753&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/WorkspaceImpl.java (original)
+++ jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/WorkspaceImpl.java Wed Sep 2 10:17:51 2015
@@ -138,7 +138,7 @@ public class WorkspaceImpl implements Ja
throw new UnsupportedRepositoryOperationException("Not implemented.");
}
- sessionDelegate.perform(new SessionOperation<Object>("copy", true) {
+ sessionDelegate.performVoid(new SessionOperation("copy", true) {
@Override
public void checkPreconditions() throws RepositoryException {
super.checkPreconditions();
@@ -146,14 +146,13 @@ public class WorkspaceImpl implements Ja
}
@Override
- public Object perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
sessionDelegate.checkProtectedNode(getParentPath(srcOakPath));
sessionDelegate.checkProtectedNode(getParentPath(destOakPath));
checkIndexOnName(destAbsPath);
workspaceDelegate.copy(srcOakPath, destOakPath);
- return null;
}
});
@@ -164,7 +163,7 @@ public class WorkspaceImpl implements Ja
final String srcOakPath = getOakPathOrThrowNotFound(srcAbsPath);
final String destOakPath = getOakPathOrThrowNotFound(destAbsPath);
- sessionDelegate.perform(new SessionOperation<Object>("clone", true) {
+ sessionDelegate.performVoid(new SessionOperation("clone", true) {
@Override
public void checkPreconditions() throws RepositoryException {
@@ -173,7 +172,7 @@ public class WorkspaceImpl implements Ja
}
@Override
- public Object perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
sessionDelegate.checkProtectedNode(getParentPath(srcOakPath));
sessionDelegate.checkProtectedNode(getParentPath(destOakPath));
throw new UnsupportedRepositoryOperationException("Not implemented.");
Modified: jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/operation/SessionOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/operation/SessionOperation.java?rev=1700753&r1=1700752&r2=1700753&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/operation/SessionOperation.java (original)
+++ jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/session/operation/SessionOperation.java Wed Sep 2 10:17:51 2015
@@ -18,6 +18,8 @@
*/
package org.apache.jackrabbit.oak.jcr.session.operation;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.jcr.RepositoryException;
/**
@@ -28,12 +30,12 @@ public abstract class SessionOperation<T
private final String name;
private final boolean update;
- protected SessionOperation(String name, boolean update) {
+ protected SessionOperation(@Nonnull String name, boolean update) {
this.name = name;
this.update = update;
}
- protected SessionOperation(String name) {
+ protected SessionOperation(@Nonnull String name) {
this(name, false);
}
@@ -62,7 +64,19 @@ public abstract class SessionOperation<T
public void checkPreconditions() throws RepositoryException {
}
- public abstract T perform() throws RepositoryException;
+ @Nonnull
+ public T perform() throws RepositoryException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Nullable
+ public T performNullable() throws RepositoryException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void performVoid() throws RepositoryException {
+ throw new UnsupportedOperationException();
+ }
/**
* Provide details about the operation being performed.
Modified: jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java?rev=1700753&r1=1700752&r2=1700753&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java (original)
+++ jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionHistoryImpl.java Wed Sep 2 10:17:51 2015
@@ -23,6 +23,7 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
+import javax.annotation.Nonnull;
import javax.jcr.AccessDeniedException;
import javax.jcr.NodeIterator;
import javax.jcr.ReferentialIntegrityException;
@@ -61,6 +62,7 @@ public class VersionHistoryImpl extends
@Override
public String getVersionableIdentifier() throws RepositoryException {
return perform(new SessionOperation<String>("getVersionableIdentifier") {
+ @Nonnull
@Override
public String perform() throws RepositoryException {
return dlg.getVersionableIdentifier();
@@ -71,6 +73,7 @@ public class VersionHistoryImpl extends
@Override
public Version getRootVersion() throws RepositoryException {
return perform(new SessionOperation<Version>("getRootVersion") {
+ @Nonnull
@Override
public Version perform() throws RepositoryException {
return new VersionImpl(dlg.getRootVersion(), sessionContext);
@@ -81,6 +84,7 @@ public class VersionHistoryImpl extends
@Override
public VersionIterator getAllLinearVersions() throws RepositoryException {
return perform(new SessionOperation<VersionIterator>("getAllLinearVersions") {
+ @Nonnull
@Override
public VersionIterator perform() throws RepositoryException {
Iterator<Version> versions = transform(dlg.getAllLinearVersions(),
@@ -98,6 +102,7 @@ public class VersionHistoryImpl extends
@Override
public VersionIterator getAllVersions() throws RepositoryException {
return perform(new SessionOperation<VersionIterator>("getAllVersions") {
+ @Nonnull
@Override
public VersionIterator perform() throws RepositoryException {
Iterator<Version> versions = transform(dlg.getAllVersions(),
@@ -126,6 +131,7 @@ public class VersionHistoryImpl extends
public Version getVersion(final String versionName)
throws VersionException, RepositoryException {
return perform(new SessionOperation<Version>("getVersion") {
+ @Nonnull
@Override
public Version perform() throws RepositoryException {
return new VersionImpl(dlg.getVersion(versionName), sessionContext);
@@ -137,6 +143,7 @@ public class VersionHistoryImpl extends
public Version getVersionByLabel(final String label)
throws VersionException, RepositoryException {
return perform(new SessionOperation<Version>("getVersionByLabel") {
+ @Nonnull
@Override
public Version perform() throws RepositoryException {
String oakLabel = sessionContext.getOakName(label);
@@ -151,14 +158,13 @@ public class VersionHistoryImpl extends
final boolean moveLabel)
throws LabelExistsVersionException, VersionException,
RepositoryException {
- perform(new SessionOperation<Void>("addVersionLabel", true) {
+ sessionDelegate.performVoid(new SessionOperation("addVersionLabel", true) {
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
String oakLabel = sessionContext.getOakName(label);
// will throw VersionException if version does not exist
VersionDelegate version = dlg.getVersion(versionName);
dlg.addVersionLabel(version, oakLabel, moveLabel);
- return null;
}
});
}
@@ -166,12 +172,11 @@ public class VersionHistoryImpl extends
@Override
public void removeVersionLabel(final String label)
throws VersionException, RepositoryException {
- perform(new SessionOperation<Void>("removeVersionLabel", true) {
+ sessionDelegate.performVoid(new SessionOperation("removeVersionLabel", true) {
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
String oakLabel = sessionContext.getOakName(label);
dlg.removeVersionLabel(oakLabel);
- return null;
}
});
}
@@ -190,6 +195,7 @@ public class VersionHistoryImpl extends
@Override
public String[] getVersionLabels() throws RepositoryException {
return perform(new SessionOperation<String[]>("getVersionLabels") {
+ @Nonnull
@Override
public String[] perform() throws RepositoryException {
List<String> labels = new ArrayList<String>();
@@ -209,6 +215,7 @@ public class VersionHistoryImpl extends
"VersionHistory");
}
return perform(new SessionOperation<String[]>("getVersionLabels") {
+ @Nonnull
@Override
public String[] perform() throws RepositoryException {
List<String> labels = new ArrayList<String>();
@@ -226,12 +233,11 @@ public class VersionHistoryImpl extends
UnsupportedRepositoryOperationException, VersionException,
RepositoryException {
- perform(new SessionOperation<Void>("removeVersion", true) {
+ sessionDelegate.performVoid(new SessionOperation("removeVersion", true) {
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
String oakName = sessionContext.getOakName(versionName);
dlg.removeVersion(oakName);
- return null;
}
});
}
Modified: jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionImpl.java?rev=1700753&r1=1700752&r2=1700753&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionImpl.java (original)
+++ jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionImpl.java Wed Sep 2 10:17:51 2015
@@ -33,6 +33,7 @@ import javax.jcr.version.Version;
import javax.jcr.version.VersionHistory;
import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate;
import org.apache.jackrabbit.oak.jcr.session.NodeImpl;
import org.apache.jackrabbit.oak.jcr.session.SessionContext;
import org.apache.jackrabbit.oak.jcr.delegate.PropertyDelegate;
@@ -52,6 +53,7 @@ public class VersionImpl extends NodeImp
@Override
public VersionHistory getContainingHistory() throws RepositoryException {
return perform(new SessionOperation<VersionHistory>("getContainingHistory") {
+ @Nonnull
@Override
public VersionHistory perform() throws RepositoryException {
return new VersionHistoryImpl(
@@ -64,6 +66,7 @@ public class VersionImpl extends NodeImp
@Override
public Calendar getCreated() throws RepositoryException {
return sessionDelegate.perform(new SessionOperation<Calendar>("getCreated") {
+ @Nonnull
@Override
public Calendar perform() throws RepositoryException {
PropertyDelegate dlg = getPropertyOrThrow(JcrConstants.JCR_CREATED);
@@ -74,9 +77,9 @@ public class VersionImpl extends NodeImp
@Override
public Version getLinearPredecessor() throws RepositoryException {
- return perform(new SessionOperation<Version>("getLinearPredecessor") {
+ return sessionDelegate.performNullable(new SessionOperation<Version>("getLinearPredecessor") {
@Override
- public Version perform() throws RepositoryException {
+ public Version performNullable() throws RepositoryException {
VersionDelegate predecessor = dlg.getLinearPredecessor();
if (predecessor == null) {
return null;
@@ -89,9 +92,9 @@ public class VersionImpl extends NodeImp
@Override
public Version getLinearSuccessor() throws RepositoryException {
- return perform(new SessionOperation<Version>("getLinearSuccessor") {
+ return sessionDelegate.performNullable(new SessionOperation<Version>("getLinearSuccessor") {
@Override
- public Version perform() throws RepositoryException {
+ public Version performNullable() throws RepositoryException {
VersionHistoryDelegate vHistory = getVersionManagerDelegate()
.createVersionHistory(dlg.getParent());
Iterator<VersionDelegate> it = vHistory.getAllLinearVersions();
@@ -117,6 +120,7 @@ public class VersionImpl extends NodeImp
@Override
public Version[] getPredecessors() throws RepositoryException {
return perform(new SessionOperation<Version[]>("getPredecessors") {
+ @Nonnull
@Override
public Version[] perform() throws RepositoryException {
List<Version> predecessors = new ArrayList<Version>();
@@ -131,6 +135,7 @@ public class VersionImpl extends NodeImp
@Override
public Version[] getSuccessors() throws RepositoryException {
return perform(new SessionOperation<Version[]>("getSuccessors") {
+ @Nonnull
@Override
public Version[] perform() throws RepositoryException {
PropertyDelegate p = getPropertyOrThrow(VersionConstants.JCR_SUCCESSORS);
@@ -148,10 +153,15 @@ public class VersionImpl extends NodeImp
@Override
public Node getFrozenNode() throws RepositoryException {
return perform(new SessionOperation<Node>("getFrozenNode") {
+ @Nonnull
@Override
public Node perform() throws RepositoryException {
- return NodeImpl.createNodeOrNull(
- dlg.getChild(VersionConstants.JCR_FROZENNODE),
+ NodeDelegate frozenNode = dlg.getChild(VersionConstants.JCR_FROZENNODE);
+ if (frozenNode == null) {
+ throw new IllegalStateException("Version without frozen node.");
+ }
+ return NodeImpl.createNode(
+ frozenNode,
sessionContext);
}
});
Modified: jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java?rev=1700753&r1=1700752&r2=1700753&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java (original)
+++ jackrabbit/oak/branches/1.2/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java Wed Sep 2 10:17:51 2015
@@ -81,9 +81,9 @@ public class VersionManagerImpl implemen
final boolean removeExisting)
throws RepositoryException {
final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
- sessionDelegate.perform(new SessionOperation<Void>("restore", true) {
+ sessionDelegate.performVoid(new SessionOperation("restore", true) {
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
String oakPath = getOakPathOrThrowNotFound(absPath);
NodeDelegate nodeDelegate = sessionDelegate.getNode(oakPath);
if (nodeDelegate != null) {
@@ -132,7 +132,6 @@ public class VersionManagerImpl implemen
sessionDelegate.refresh(false);
}
}
- return null;
}
});
}
@@ -168,9 +167,9 @@ public class VersionManagerImpl implemen
throw new VersionException("Restore of root version not possible");
}
final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
- sessionDelegate.perform(new SessionOperation<Void>("restore", true) {
+ sessionDelegate.performVoid(new SessionOperation("restore", true) {
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
// check for pending changes
checkPendingChangesForRestore(sessionDelegate);
NodeDelegate n = sessionDelegate.getNodeByIdentifier(versionableId);
@@ -199,10 +198,8 @@ public class VersionManagerImpl implemen
}
}
// ready for restore
- VersionDelegate vd = versionManagerDelegate.getVersionByIdentifier(
- version.getIdentifier());
- versionManagerDelegate.restore(
- n.getParent(), n.getName(), vd);
+ VersionDelegate vd = versionManagerDelegate.getVersionByIdentifier(version.getIdentifier());
+ versionManagerDelegate.restore(n.getParent(), n.getName(), vd);
sessionDelegate.commit();
success = true;
} catch (CommitFailedException e) {
@@ -213,7 +210,6 @@ public class VersionManagerImpl implemen
sessionDelegate.refresh(false);
}
}
- return null;
}
});
}
@@ -255,6 +251,7 @@ public class VersionManagerImpl implemen
public boolean isCheckedOut(final String absPath) throws RepositoryException {
final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
return sessionDelegate.perform(new SessionOperation<Boolean>("isCheckoutOut") {
+ @Nonnull
@Override
public Boolean perform() throws RepositoryException {
String oakPath = getOakPathOrThrowNotFound(absPath);
@@ -272,6 +269,7 @@ public class VersionManagerImpl implemen
throws RepositoryException {
final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
return sessionDelegate.perform(new SessionOperation<VersionHistory>("getVersionHistory") {
+ @Nonnull
@Override
public VersionHistory perform() throws RepositoryException {
return new VersionHistoryImpl(
@@ -284,6 +282,7 @@ public class VersionManagerImpl implemen
public Version getBaseVersion(final String absPath) throws RepositoryException {
final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
return sessionDelegate.perform(new SessionOperation<Version>("getBaseVersion") {
+ @Nonnull
@Override
public Version perform() throws RepositoryException {
String oakPath = getOakPathOrThrowNotFound(absPath);
@@ -329,9 +328,9 @@ public class VersionManagerImpl implemen
@Override
public void checkout(final String absPath) throws RepositoryException {
final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
- sessionDelegate.perform(new SessionOperation<Void>("checkout", true) {
+ sessionDelegate.performVoid(new SessionOperation("checkout", true) {
@Override
- public Void perform() throws RepositoryException {
+ public void performVoid() throws RepositoryException {
String oakPath = getOakPathOrThrowNotFound(absPath);
NodeDelegate nodeDelegate = sessionDelegate.getNode(oakPath);
if (nodeDelegate == null) {
@@ -339,7 +338,6 @@ public class VersionManagerImpl implemen
}
checkNotLocked(absPath);
versionManagerDelegate.checkout(nodeDelegate);
- return null;
}
});
}
@@ -348,6 +346,7 @@ public class VersionManagerImpl implemen
public Version checkin(final String absPath) throws RepositoryException {
final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
return sessionDelegate.perform(new SessionOperation<Version>("checkin", true) {
+ @Nonnull
@Override
public Version perform() throws RepositoryException {
String oakPath = getOakPathOrThrowNotFound(absPath);