Author: fguillaume
Date: Mon Sep 7 10:14:59 2009
New Revision: 812071
URL: http://svn.apache.org/viewvc?rev=812071&view=rev
Log:
Allow reuse of SimpleObjectEntry with any Connection subclass
Modified:
incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleFolder.java
incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java
incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObjectEntry.java
Modified:
incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleFolder.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleFolder.java?rev=812071&r1=812070&r2=812071&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleFolder.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleFolder.java
Mon Sep 7 10:14:59 2009
@@ -44,11 +44,11 @@
}
public Collection<ObjectId> deleteTree(Unfiling unfiling) {
- return entry.connection.deleteTree(this, unfiling, true);
+ return entry.connection.getSPI().deleteTree(this, unfiling, true);
}
public List<CMISObject> getChildren() {
- SimpleRepository repository = entry.connection.repository;
+ SimpleRepository repository = (SimpleRepository)
entry.connection.getRepository();
Set<String> ids = repository.children.get(getId());
List<CMISObject> children = new ArrayList<CMISObject>(ids.size());
for (String id : ids) {
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=812071&r1=812070&r2=812071&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
Mon Sep 7 10:14:59 2009
@@ -30,6 +30,7 @@
import org.apache.chemistry.PropertyDefinition;
import org.apache.chemistry.Relationship;
import org.apache.chemistry.RelationshipDirection;
+import org.apache.chemistry.Repository;
import org.apache.chemistry.Type;
import org.apache.chemistry.impl.base.BaseObject;
@@ -44,11 +45,11 @@
protected SimpleObject(SimpleObjectEntry entry) {
this.entry = entry;
- type = entry.connection.repository.getType(entry.getTypeId());
+ type = entry.connection.getRepository().getType(entry.getTypeId());
}
protected static SimpleObject construct(SimpleObjectEntry entry) {
- BaseType baseType = entry.connection.repository.getType(
+ BaseType baseType = entry.connection.getRepository().getType(
entry.getTypeId()).getBaseType();
switch (baseType) {
case DOCUMENT:
@@ -70,7 +71,7 @@
}
public void delete() {
- entry.connection.deleteObject(this, false);
+ entry.connection.getSPI().deleteObject(this, false);
}
public void unfile() {
@@ -79,7 +80,8 @@
}
public Folder getParent() {
- Set<String> parents = entry.connection.repository.parents.get(getId());
+ SimpleConnection connection = (SimpleConnection) entry.connection;
+ Set<String> parents = connection.repository.parents.get(getId());
if (parents == SimpleRepository.NO_PARENT) {
return null;
}
@@ -87,8 +89,8 @@
throw new RuntimeException("Several parents for: " + getId()); //
TODO
}
String pid = parents.iterator().next();
- SimpleData data = entry.connection.repository.datas.get(pid);
- return new SimpleFolder(new SimpleObjectEntry(data, entry.connection));
+ SimpleData data = connection.repository.datas.get(pid);
+ return new SimpleFolder(new SimpleObjectEntry(data, connection));
}
public Collection<Folder> getParents() {
@@ -153,7 +155,7 @@
public void save() {
if (getId() == null) {
- entry.connection.saveObject(this);
+ ((SimpleConnection) entry.connection).saveObject(this);
}
}
Modified:
incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObjectEntry.java
URL:
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObjectEntry.java?rev=812071&r1=812070&r2=812071&view=diff
==============================================================================
---
incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObjectEntry.java
(original)
+++
incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObjectEntry.java
Mon Sep 7 10:14:59 2009
@@ -25,6 +25,7 @@
import org.apache.chemistry.BaseType;
import org.apache.chemistry.ChangeInfo;
+import org.apache.chemistry.Connection;
import org.apache.chemistry.ObjectEntry;
import org.apache.chemistry.Property;
@@ -37,11 +38,11 @@
protected final SimpleData data;
- protected final SimpleConnection connection;
+ protected final Connection connection;
protected ChangeInfo changeInfo;
- protected SimpleObjectEntry(SimpleData data, SimpleConnection connection) {
+ public SimpleObjectEntry(SimpleData data, Connection connection) {
this.data = data;
this.connection = connection;
}