You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fg...@apache.org on 2010/01/21 16:32:54 UTC
svn commit: r901740 - in /incubator/chemistry/trunk/chemistry:
chemistry-api/src/main/java/org/apache/chemistry/
chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/
chemistry-commons/src/main/java/org/apache/chemistry/impl/simpl...
Author: fguillaume
Date: Thu Jan 21 15:32:53 2010
New Revision: 901740
URL: http://svn.apache.org/viewvc?rev=901740&view=rev
Log:
CMIS-100: Add CMISObject.getConnection() method
Modified:
incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java
incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java
incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java
incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java
incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrDocument.java
incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java
incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrNewDocument.java
incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrNewFolder.java
incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrObjectEntry.java
Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java?rev=901740&r1=901739&r2=901740&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java Thu Jan 21 15:32:53 2010
@@ -43,6 +43,13 @@
*/
public interface CMISObject extends ObjectId {
+ /**
+ * Gets the connection to which this object is associated.
+ *
+ * @return the connection
+ */
+ Connection getConnection();
+
/*
* ----- Object Services -----
*/
Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java?rev=901740&r1=901739&r2=901740&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java Thu Jan 21 15:32:53 2010
@@ -28,6 +28,7 @@
import org.apache.chemistry.BaseType;
import org.apache.chemistry.CMISRuntimeException;
+import org.apache.chemistry.Connection;
import org.apache.chemistry.ContentStream;
import org.apache.chemistry.Folder;
import org.apache.chemistry.ObjectEntry;
@@ -82,6 +83,10 @@
}
}
+ public Connection getConnection() {
+ return entry.connection;
+ }
+
/*
* ----- Object Services -----
*/
Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java?rev=901740&r1=901739&r2=901740&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java Thu Jan 21 15:32:53 2010
@@ -25,6 +25,7 @@
import org.apache.chemistry.BaseType;
import org.apache.chemistry.CMISObject;
+import org.apache.chemistry.Connection;
import org.apache.chemistry.ContentStream;
import org.apache.chemistry.Folder;
import org.apache.chemistry.NameConstraintViolationException;
@@ -68,6 +69,10 @@
}
}
+ public Connection getConnection() {
+ return entry.connection;
+ }
+
public void move(Folder targetFolder, Folder sourceFolder)
throws NameConstraintViolationException, UpdateConflictException {
entry.connection.getSPI().moveObject(this, targetFolder, sourceFolder);
Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java?rev=901740&r1=901739&r2=901740&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java Thu Jan 21 15:32:53 2010
@@ -89,9 +89,9 @@
} else {
Node node = session.getRootNode().getNode(relPath);
if (JcrCmisMap.isNodeDocument(node)) {
- return new JcrDocument(node);
+ return new JcrDocument(node, this);
} else {
- return new JcrFolder(node);
+ return new JcrFolder(node, this);
}
}
} catch (RepositoryException e) {
@@ -107,7 +107,7 @@
public Folder getRootFolder() {
try {
- return new JcrFolder(session.getRootNode());
+ return new JcrFolder(session.getRootNode(), this);
} catch (RepositoryException e) {
String msg = "Unable to get root entry.";
log.error(msg, e);
@@ -153,9 +153,9 @@
public ObjectEntry newObjectEntry(String typeId) {
if (JcrCmisMap.isBaseTypeDocument(typeId)) {
- return new JcrDocument();
+ return new JcrDocument(null, this);
} else {
- return new JcrFolder();
+ return new JcrFolder(null, this);
}
}
@@ -299,9 +299,9 @@
while (result.size() < maxItems && iter.hasNext()) {
Node child = iter.nextNode();
if (JcrCmisMap.isNodeDocument(child)) {
- result.add(new JcrDocument(child));
+ result.add(new JcrDocument(child, this));
} else {
- result.add(new JcrFolder(child));
+ result.add(new JcrFolder(child, this));
}
}
result.setHasMoreItems(iter.hasNext());
@@ -326,7 +326,7 @@
String relPath = JcrObjectEntry.getPath(documentId.getId()).substring(
1);
Node node = session.getRootNode().getNode(relPath);
- JcrDocument document = new JcrDocument(node);
+ JcrDocument document = new JcrDocument(node, this);
return document.getContentStream();
} catch (RepositoryException e) {
String msg = "Unable to get object: " + documentId;
@@ -368,9 +368,9 @@
} else {
Node node = session.getRootNode().getNode(relPath);
if (JcrCmisMap.isNodeDocument(node)) {
- return new JcrDocument(node);
+ return new JcrDocument(node, this);
} else {
- return new JcrFolder(node);
+ return new JcrFolder(node, this);
}
}
} catch (RepositoryException e) {
@@ -390,9 +390,9 @@
}
Node node = session.getRootNode().getNode(path);
if (node.isNodeType(JcrConstants.NT_FOLDER)) {
- return new JcrFolder(node);
+ return new JcrFolder(node, this);
} else if (node.isNodeType(JcrConstants.NT_FILE)) {
- return new JcrDocument(node);
+ return new JcrDocument(node, this);
}
}
} catch (RepositoryException e) {
@@ -452,9 +452,9 @@
while (result.size() < maxItems && iter.hasNext()) {
Node child = iter.nextNode();
if (child.isNodeType(JcrConstants.NT_FOLDER)) {
- result.add(new JcrFolder(child));
+ result.add(new JcrFolder(child, this));
} else if (child.isNodeType(JcrConstants.NT_FILE)) {
- result.add(new JcrDocument(child));
+ result.add(new JcrDocument(child, this));
}
}
result.setHasMoreItems(iter.hasNext());
Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrDocument.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrDocument.java?rev=901740&r1=901739&r2=901740&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrDocument.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrDocument.java Thu Jan 21 15:32:53 2010
@@ -38,11 +38,8 @@
private static final Log log = LogFactory.getLog(JcrDocument.class);
- public JcrDocument(Node node) {
- super(node);
- }
-
- protected JcrDocument() {
+ public JcrDocument(Node node, JcrConnection connection) {
+ super(node, connection);
}
public ContentStream getContentStream() {
@@ -63,7 +60,7 @@
public Folder getParent() {
try {
- return new JcrFolder(node.getParent());
+ return new JcrFolder(node.getParent(), connection);
} catch (RepositoryException e) {
String msg = "Unable to get parent.";
log.error(msg, e);
Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java?rev=901740&r1=901739&r2=901740&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java Thu Jan 21 15:32:53 2010
@@ -41,17 +41,13 @@
import org.apache.chemistry.Unfiling;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.JcrConstants;
public class JcrFolder extends JcrObjectEntry implements Folder {
private static final Log log = LogFactory.getLog(JcrFolder.class);
- public JcrFolder(Node node) {
- super(node);
- }
-
- protected JcrFolder() {
+ public JcrFolder(Node node, JcrConnection connection) {
+ super(node, connection);
}
public List<CMISObject> getChildren() {
@@ -63,9 +59,9 @@
Node child = iter.nextNode();
CMISObject entry;
if (JcrCmisMap.isNodeDocument(child)) {
- entry = new JcrDocument(child);
+ entry = new JcrDocument(child, connection);
} else {
- entry = new JcrFolder(child);
+ entry = new JcrFolder(child, connection);
}
result.add(entry);
}
@@ -78,17 +74,17 @@
}
public Document newDocument(String typeId) {
- return new JcrNewDocument(node);
+ return new JcrNewDocument(node, connection);
}
public Folder newFolder(String typeId) {
- return new JcrNewFolder(node);
+ return new JcrNewFolder(node, connection);
}
public Folder getParent() {
try {
if (node.getDepth() > 0) {
- return new JcrFolder(node.getParent());
+ return new JcrFolder(node.getParent(), connection);
}
} catch (RepositoryException e) {
String msg = "Unable to get parent.";
Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrNewDocument.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrNewDocument.java?rev=901740&r1=901739&r2=901740&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrNewDocument.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrNewDocument.java Thu Jan 21 15:32:53 2010
@@ -44,7 +44,8 @@
private ContentStream cs;
private boolean saved;
- public JcrNewDocument(Node parent) {
+ public JcrNewDocument(Node parent, JcrConnection connection) {
+ super(null, connection);
this.parent = parent;
}
@@ -59,7 +60,7 @@
@Override
public Folder getParent() {
if (!saved) {
- return new JcrFolder(parent);
+ return new JcrFolder(parent, connection);
}
return super.getParent();
}
Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrNewFolder.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrNewFolder.java?rev=901740&r1=901739&r2=901740&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrNewFolder.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrNewFolder.java Thu Jan 21 15:32:53 2010
@@ -43,7 +43,8 @@
private String name;
private boolean saved;
- public JcrNewFolder(Node parent) {
+ public JcrNewFolder(Node parent, JcrConnection connection) {
+ super(null, connection);
this.parent = parent;
}
@@ -74,7 +75,7 @@
@Override
public Folder getParent() {
if (!saved) {
- return new JcrFolder(parent);
+ return new JcrFolder(parent, connection);
}
return super.getParent();
}
Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrObjectEntry.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrObjectEntry.java?rev=901740&r1=901739&r2=901740&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrObjectEntry.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrObjectEntry.java Thu Jan 21 15:32:53 2010
@@ -37,6 +37,7 @@
import javax.jcr.Value;
import javax.xml.namespace.QName;
+import org.apache.chemistry.Connection;
import org.apache.chemistry.Document;
import org.apache.chemistry.Folder;
import org.apache.chemistry.ObjectEntry;
@@ -60,11 +61,15 @@
protected Node node;
- public JcrObjectEntry(Node node) {
+ protected final JcrConnection connection;
+
+ public JcrObjectEntry(Node node, JcrConnection connection) {
this.node = node;
+ this.connection = connection;
}
- public JcrObjectEntry() {
+ public Connection getConnection() {
+ return connection;
}
public Map<QName, Boolean> getAllowableActions() {