You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2007/03/16 10:32:33 UTC
svn commit: r518900 -
/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
Author: angela
Date: Fri Mar 16 02:32:31 2007
New Revision: 518900
URL: http://svn.apache.org/viewvc?view=rev&rev=518900
Log:
batch-operations: if parent cannot be retrieved InvalidItemStateException is appropriate rather than PathNotFoundException, because it indicates that the parent was available in jcr2spi but got removed in the mean time.
Modified:
jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
Modified: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java?view=diff&rev=518900&r1=518899&r2=518900
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java Fri Mar 16 02:32:31 2007
@@ -932,20 +932,21 @@
executeGuarded(new Callable() {
public Object run() throws RepositoryException {
Session s = sInfo.getSession();
- Node n = getNode(parentId, sInfo);
+ Node parent = getParent(parentId, sInfo);
+
String jcrName = getJcrName(nodeName);
String ntName = getJcrName(nodetypeName);
if (uuid == null) {
if (ntName == null) {
- n.addNode(jcrName);
+ parent.addNode(jcrName);
} else {
- n.addNode(jcrName, ntName);
+ parent.addNode(jcrName, ntName);
}
} else {
String xml = createXMLFragment(jcrName, ntName, uuid);
InputStream in = new ByteArrayInputStream(xml.getBytes());
try {
- s.importXML(n.getPath(), in, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
+ s.importXML(parent.getPath(), in, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
} catch (IOException e) {
throw new RepositoryException(e.getMessage(), e);
}
@@ -962,10 +963,10 @@
executeGuarded(new Callable() {
public Object run() throws RepositoryException {
Session s = sInfo.getSession();
- Node n = getNode(parentId, sInfo);
+ Node parent = getParent(parentId, sInfo);
Value jcrValue = ValueFormat.getJCRValue(value,
sInfo.getNamespaceResolver(), s.getValueFactory());
- n.setProperty(getJcrName(propertyName), jcrValue);
+ parent.setProperty(getJcrName(propertyName), jcrValue);
return null;
}
});
@@ -977,7 +978,7 @@
executeGuarded(new Callable() {
public Object run() throws RepositoryException {
Session s = sInfo.getSession();
- Node n = getNode(parentId, sInfo);
+ Node n = getParent(parentId, sInfo);
Value[] jcrValues = new Value[values.length];
for (int i = 0; i < jcrValues.length; i++) {
jcrValues[i] = ValueFormat.getJCRValue(values[i],
@@ -1037,7 +1038,7 @@
throws RepositoryException {
executeGuarded(new Callable() {
public Object run() throws RepositoryException {
- Node parent = getNode(parentId, sInfo);
+ Node parent = getParent(parentId, sInfo);
Node srcNode = getNode(srcNodeId, sInfo);
Node beforeNode = null;
if (beforeNodeId != null) {
@@ -1231,7 +1232,17 @@
return path.toString();
}
- private Node getNode(NodeId id, SessionInfoImpl sessionInfo) throws ItemNotFoundException, RepositoryException {
+ private Node getParent(NodeId parentId, SessionInfoImpl sessionInfo) throws InvalidItemStateException, RepositoryException {
+ try {
+ return getNode(parentId, sessionInfo);
+ } catch (PathNotFoundException e) {
+ // if the parent of an batch operation is not available, this indicates
+ // that it has been destroyed by another session.
+ throw new InvalidItemStateException(e);
+ }
+ }
+
+ private Node getNode(NodeId id, SessionInfoImpl sessionInfo) throws PathNotFoundException, RepositoryException {
Session session = sessionInfo.getSession();
Node n;
if (id.getUniqueID() != null) {