diff --git a/config/alfresco/avm-base-context.xml b/config/alfresco/avm-base-context.xml
deleted file mode 100644
index 2d4b07ce91..0000000000
--- a/config/alfresco/avm-base-context.xml
+++ /dev/null
@@ -1,301 +0,0 @@
-
-
-
-
-
-
-
-
- ${db.driver}
-
-
- ${db.url}
-
-
- ${db.username}
-
-
- ${db.password}
-
-
- ${db.pool.initial}
-
-
- ${db.pool.max}
-
-
- 1
-
-
- 60
-
-
-
-
-
-
-
-
-
-
- ${hibernate.dialect}
- ${hibernate.current_session_context_class}
- ${hibernate.connection.isolation}
- ${hibernate.default_batch_fetch_size}
- ${hibernate.jdbc.batch_versioned_data}
- ${hibernate.cache.use_second_level_cache}
- ${hibernate.hbm2ddl.auto}
-
-
-
-
- org/alfresco/repo/avm/hibernate/AVM.hbm.xml
-
-
-
-
-
-
- node
-
-
-
-
-
-
-
-
- content
-
-
-
-
-
-
-
-
- layer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PROPAGATION_REQUIRED
-
-
- ISOLATION_READ_COMMITTED
-
-
- true
-
-
-
-
-
-
- PROPAGATION_REQUIRED
-
-
- ISOLATION_READ_COMMITTED
-
-
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 4000
-
-
- 1000
-
-
- 50
-
-
-
-
-
-
-
-
- ${avm.storage}
-
-
- ${avm.initialize}
-
-
-
-
-
-
-
-
-
-
-
- ${avm.storage}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/config/alfresco/avm-console.properties b/config/alfresco/avm-console.properties
index 29e89be9db..88bc7b85e1 100644
--- a/config/alfresco/avm-console.properties
+++ b/config/alfresco/avm-console.properties
@@ -14,5 +14,3 @@ hibernate.jdbc.batch_versioned_data=true
hibernate.cache.use_second_level_cache=true
hibernate.hbm2ddl.auto=update
# AVM specific properties.
-avm.storage=build/test-results/storage
-avm.initialize=false
diff --git a/config/alfresco/avm-services-context.xml b/config/alfresco/avm-services-context.xml
index 21383739b9..1001e423a6 100644
--- a/config/alfresco/avm-services-context.xml
+++ b/config/alfresco/avm-services-context.xml
@@ -199,11 +199,7 @@
-
-
- ${avm.storage}
-
+
diff --git a/config/alfresco/avm-test.properties b/config/alfresco/avm-test.properties
deleted file mode 100644
index b709ab1e37..0000000000
--- a/config/alfresco/avm-test.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# Database specifics.
-db.driver=org.gjt.mm.mysql.Driver
-db.url=jdbc:mysql://127.0.0.1/avm
-db.username=root
-db.password=
-db.pool.initial=4
-db.pool.max=32
-# Hibernate properties
-hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
-hibernate.current_session_context_class=thread
-hibernate.connection.isolation=4
-hibernate.default_batch_fetch_size=16
-hibernate.jdbc.batch_versioned_data=true
-hibernate.cache.use_second_level_cache=true
-hibernate.hbm2ddl.auto=update
-# AVM specific properties.
-avm.storage=build/test-results/storage
-avm.initialize=true
diff --git a/config/alfresco/public-services-context.xml b/config/alfresco/public-services-context.xml
index 7a8ca4d6a9..aeb6ab1d24 100644
--- a/config/alfresco/public-services-context.xml
+++ b/config/alfresco/public-services-context.xml
@@ -938,12 +938,6 @@
-
- ${avm.storage}
-
-
- ${avm.initialize}
-
diff --git a/config/alfresco/repository.properties b/config/alfresco/repository.properties
index 6df1278fdd..b912aa75b6 100644
--- a/config/alfresco/repository.properties
+++ b/config/alfresco/repository.properties
@@ -109,8 +109,6 @@ system.people_container.childname=sys:people
user.name.caseSensitive=false
# AVM Specific properties.
-avm.storage=build/test-results/storage
-avm.initialize=true
avm.remote.idlestream.timeout=30000
avm.remote.port=1313
diff --git a/source/java/org/alfresco/repo/avm/AVMNodeService.java b/source/java/org/alfresco/repo/avm/AVMNodeService.java
index 81aae4efb1..8c49ca808d 100644
--- a/source/java/org/alfresco/repo/avm/AVMNodeService.java
+++ b/source/java/org/alfresco/repo/avm/AVMNodeService.java
@@ -29,8 +29,10 @@ import java.util.SortedMap;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.domain.PropertyValue;
+import org.alfresco.repo.node.AbstractNodeServiceImpl;
import org.alfresco.service.Auditable;
-import org.alfresco.service.cmr.dictionary.DictionaryService;
+import org.alfresco.service.cmr.dictionary.AspectDefinition;
+import org.alfresco.service.cmr.dictionary.ClassDefinition;
import org.alfresco.service.cmr.dictionary.InvalidAspectException;
import org.alfresco.service.cmr.dictionary.InvalidTypeException;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
@@ -56,7 +58,7 @@ import org.apache.log4j.Logger;
* NodeService implementing facade over AVMService.
* @author britt
*/
-public class AVMNodeService implements NodeService
+public class AVMNodeService extends AbstractNodeServiceImpl implements NodeService
{
private static Logger fgLogger = Logger.getLogger(AVMNodeService.class);
@@ -65,11 +67,6 @@ public class AVMNodeService implements NodeService
*/
private AVMService fAVMService;
- /**
- * Reference to DictionaryService.
- */
- private DictionaryService fDictionaryService;
-
/**
* Set the AVMService. For Spring.
* @param service The AVMService instance.
@@ -79,15 +76,6 @@ public class AVMNodeService implements NodeService
fAVMService = service;
}
- /**
- * Set the DictionaryService. For Spring.
- * @param dictionaryService The DictionaryService instance.
- */
- public void setDictionaryService(DictionaryService dictionaryService)
- {
- fDictionaryService = dictionaryService;
- }
-
/**
* Default constructor.
*/
@@ -484,7 +472,68 @@ public class AVMNodeService implements NodeService
Map aspectProperties)
throws InvalidNodeRefException, InvalidAspectException
{
- throw new UnsupportedOperationException("AVM Nodes cannot be advised yet.");
+ // Check that the aspect exists.
+ AspectDefinition aspectDef = this.dictionaryService.getAspect(aspectTypeQName);
+ if (aspectDef == null)
+ {
+ throw new InvalidAspectException("The aspect is invalid: " + aspectTypeQName,
+ aspectTypeQName);
+ }
+ // Crack the nodeRef.
+ Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
+ int version = (Integer)avmVersionPath[0];
+ if (version >= 0)
+ {
+ throw new InvalidNodeRefException("Read Only node.", nodeRef);
+ }
+ String avmPath = (String)avmVersionPath[1];
+ // Get the current node properties.
+ Map properties = getProperties(nodeRef);
+ // Add the supplied properties.
+ if (aspectProperties != null)
+ {
+ properties.putAll(aspectProperties);
+ }
+ // Now set any unspecified default properties for the aspect.
+ addDefaultPropertyValues(aspectDef, properties);
+ // Now add any cascading aspects.
+ addDefaultAspects(aspectDef, avmPath, properties);
+ // Set the property values on the AVM Node.
+ setProperties(nodeRef, properties);
+ if (isBuiltinAspect(aspectTypeQName))
+ {
+ // No more work to do in this case.
+ return;
+ }
+ try
+ {
+ fAVMService.addAspect(avmPath, aspectTypeQName);
+ }
+ catch (AVMNotFoundException e)
+ {
+ throw new InvalidNodeRefException(nodeRef);
+ }
+ }
+
+ /**
+ * Add any aspects that are mandatory for the ClassDefinition.
+ * @param classDef The ClassDefinition.
+ * @param path The path to the AVMNode.
+ * @param properties The in/out map of accumulated properties.
+ */
+ private void addDefaultAspects(ClassDefinition classDef, String path,
+ Map properties)
+ {
+ // Get mandatory aspects.
+ List defaultAspectDefs = classDef.getDefaultAspects();
+ // add all the aspects (and there dependent aspects recursively).
+ for (AspectDefinition def : defaultAspectDefs)
+ {
+ fAVMService.addAspect(path, def.getName());
+ addDefaultPropertyValues(def, properties);
+ // recurse
+ addDefaultAspects(def, path, properties);
+ }
}
/**
@@ -499,7 +548,39 @@ public class AVMNodeService implements NodeService
public void removeAspect(NodeRef nodeRef, QName aspectTypeQName)
throws InvalidNodeRefException, InvalidAspectException
{
- throw new UnsupportedOperationException("AVM Nodes do not yet have aspects.");
+ AspectDefinition def = dictionaryService.getAspect(aspectTypeQName);
+ if (def == null)
+ {
+ throw new InvalidAspectException(aspectTypeQName);
+ }
+ if (isBuiltinAspect(aspectTypeQName))
+ {
+ // TODO shouldn't we be throwing some kind of exception here.
+ return;
+ }
+ Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
+ int version = (Integer)avmVersionPath[0];
+ if (version >= 0)
+ {
+ throw new InvalidNodeRefException("Read Only Node.", nodeRef);
+ }
+ String path = (String)avmVersionPath[1];
+ try
+ {
+ if (fAVMService.hasAspect(-1, path, aspectTypeQName))
+ {
+ fAVMService.removeAspect(path, aspectTypeQName);
+ Map propDefs = def.getProperties();
+ for (QName propertyName : propDefs.keySet())
+ {
+ fAVMService.deleteNodeProperty(path, propertyName);
+ }
+ }
+ }
+ catch (AVMNotFoundException e)
+ {
+ throw new InvalidNodeRefException(nodeRef);
+ }
}
/**
@@ -516,9 +597,38 @@ public class AVMNodeService implements NodeService
public boolean hasAspect(NodeRef nodeRef, QName aspectTypeQName)
throws InvalidNodeRefException, InvalidAspectException
{
- return false;
+ Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
+ int version = (Integer)avmVersionPath[0];
+ String path = (String)avmVersionPath[1];
+ if (isBuiltinAspect(aspectTypeQName))
+ {
+ return true;
+ }
+ try
+ {
+ return fAVMService.hasAspect(version, path, aspectTypeQName);
+ }
+ catch (AVMNotFoundException e)
+ {
+ throw new InvalidNodeRefException(nodeRef);
+ }
}
+ private static QName [] fgBuiltinAspects = new QName[] { ContentModel.ASPECT_AUDITABLE,
+ ContentModel.ASPECT_REFERENCEABLE };
+
+ private boolean isBuiltinAspect(QName aspectQName)
+ {
+ for (QName builtin : fgBuiltinAspects)
+ {
+ if (builtin.equals(aspectQName))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* @param nodeRef
* @return Returns a set of all aspects applied to the node, including mandatory
@@ -527,8 +637,28 @@ public class AVMNodeService implements NodeService
*/
public Set getAspects(NodeRef nodeRef) throws InvalidNodeRefException
{
- // TODO This is almost certainly not the right thing to do.
- return new HashSet();
+ Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
+ int version = (Integer)avmVersionPath[0];
+ String path = (String)avmVersionPath[1];
+ Set result = new HashSet();
+ // Add the builtin ones.
+ for (QName name : fgBuiltinAspects)
+ {
+ result.add(name);
+ }
+ try
+ {
+ List aspects = fAVMService.getAspects(version, path);
+ for (QName name : aspects)
+ {
+ result.add(name);
+ }
+ return result;
+ }
+ catch (AVMNotFoundException e)
+ {
+ throw new InvalidNodeRefException(nodeRef);
+ }
}
/**
@@ -648,7 +778,7 @@ public class AVMNodeService implements NodeService
for (QName qName : props.keySet())
{
PropertyValue value = props.get(qName);
- PropertyDefinition def = fDictionaryService.getProperty(qName);
+ PropertyDefinition def = this.dictionaryService.getProperty(qName);
result.put(qName, value.getValue(def.getDataType().getName()));
}
// Now spoof properties that are built in.
@@ -695,7 +825,7 @@ public class AVMNodeService implements NodeService
{
return null;
}
- PropertyDefinition def = fDictionaryService.getProperty(qname);
+ PropertyDefinition def = this.dictionaryService.getProperty(qname);
return value.getValue(def.getDataType().getName());
}
catch (AVMNotFoundException e)
@@ -726,7 +856,8 @@ public class AVMNodeService implements NodeService
}
catch (AVMException e)
{
- // TODO For now, ignore.
+ // TODO This seems very wrong. Do something better
+ // sooner rather than later.
return null;
}
}
@@ -807,6 +938,16 @@ public class AVMNodeService implements NodeService
}
}
+ static QName [] fgBuiltinProperties = new QName []
+ {
+ ContentModel.PROP_CREATED,
+ ContentModel.PROP_CREATOR,
+ ContentModel.PROP_MODIFIED,
+ ContentModel.PROP_MODIFIER,
+ ContentModel.PROP_OWNER,
+ ContentModel.PROP_CONTENT
+ };
+
/**
* Helper to distinguish built-in from generic properties.
* @param qName The name of the property to check.
@@ -814,12 +955,14 @@ public class AVMNodeService implements NodeService
*/
private boolean isBuiltInProperty(QName qName)
{
- return qName.equals(ContentModel.PROP_CREATED) ||
- qName.equals(ContentModel.PROP_CREATOR) ||
- qName.equals(ContentModel.PROP_MODIFIED) ||
- qName.equals(ContentModel.PROP_MODIFIER) ||
- qName.equals(ContentModel.PROP_OWNER) ||
- qName.equals(ContentModel.PROP_CONTENT);
+ for (QName name : fgBuiltinProperties)
+ {
+ if (name.equals(qName))
+ {
+ return true;
+ }
+ }
+ return false;
}
/**
@@ -875,9 +1018,6 @@ public class AVMNodeService implements NodeService
String path = (String)avmVersionPath[1];
List result = new ArrayList();
String [] splitPath = AVMNodeConverter.SplitBase(path);
- // TODO Remove when you figure this out.
- fgLogger.error(splitPath[0]);
- fgLogger.error(splitPath[1]);
if (splitPath[0] == null)
{
return result;
diff --git a/source/java/org/alfresco/repo/avm/AVMRepository.java b/source/java/org/alfresco/repo/avm/AVMRepository.java
index bb6bcb4820..f0a3a63476 100644
--- a/source/java/org/alfresco/repo/avm/AVMRepository.java
+++ b/source/java/org/alfresco/repo/avm/AVMRepository.java
@@ -28,8 +28,6 @@ import java.util.SortedMap;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.repository.ContentData;
-import org.alfresco.service.cmr.repository.ContentReader;
-import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.namespace.QName;
/**
@@ -59,11 +57,6 @@ public class AVMRepository
*/
private Issuer fLayerIssuer;
- /**
- * The file storage directory.
- */
- private String fStorage;
-
/**
* Create a new one.
*/
@@ -73,15 +66,6 @@ public class AVMRepository
fgInstance = this;
}
- /**
- * Set the storage directory.
- * @param storage The absolute path to content storage directory.
- */
- public void setStorage(String storage)
- {
- fStorage = storage;
- }
-
/**
* Set the node issuer. For Spring.
* @param nodeIssuer The issuer.
@@ -100,12 +84,6 @@ public class AVMRepository
fLayerIssuer = layerIssuer;
}
- public void init()
- {
- File storageDir = new File(fStorage);
- storageDir.mkdirs();
- }
-
/**
* Create a file.
* @param path The path to the containing directory.
@@ -496,33 +474,6 @@ public class AVMRepository
return store.getInputStream(version, pathParts[1]);
}
- /**
- * Get a ContentReader from a file.
- * @param version The version to look under.
- * @param path The path to the file.
- * @return A ContentReader
- */
- public ContentReader getReader(int version, String path)
- {
- fLookupCount.set(1);
- String [] pathParts = SplitPath(path);
- AVMStore store = getAVMStoreByName(pathParts[0]);
- return store.getReader(version, pathParts[1]);
- }
-
- /**
- * Get a ContentWriter to a file.
- * @param path The path to the file.
- * @return A ContentWriter.
- */
- public ContentWriter getWriter(String path)
- {
- fLookupCount.set(1);
- String [] pathParts = SplitPath(path);
- AVMStore store = getAVMStoreByName(pathParts[0]);
- return store.getWriter(pathParts[1]);
- }
-
/**
* Get a listing of a directory.
* @param version The version to look under.
@@ -819,15 +770,6 @@ public class AVMRepository
return pathParts;
}
- /**
- * Get the path to file storage.
- * @return The root path of file storage.
- */
- public String getStorageRoot()
- {
- return fStorage;
- }
-
/**
* Make a directory into a primary indirection.
* @param path The full path.
diff --git a/source/java/org/alfresco/repo/avm/AVMService.java b/source/java/org/alfresco/repo/avm/AVMService.java
index c6bcf1ab0a..f536e63652 100644
--- a/source/java/org/alfresco/repo/avm/AVMService.java
+++ b/source/java/org/alfresco/repo/avm/AVMService.java
@@ -26,8 +26,6 @@ import java.util.SortedMap;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.repository.ContentData;
-import org.alfresco.service.cmr.repository.ContentReader;
-import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.namespace.QName;
/**
@@ -60,25 +58,6 @@ public interface AVMService
*/
public OutputStream getFileOutputStream(String path);
- /**
- * Get a ContentReader for the given file.
- * @param version The version to look under.
- * @param path The path to the file.
- * @return A ContentReader.
- * @throws AVMNotFoundException If path
does not exist.
- * @throws AVMWrongTypeException if path
is not a file.
- */
- public ContentReader getReader(int version, String path);
-
- /**
- * Get a ContentWriter to a file.
- * @param path The path to the file.
- * @return A ContentWriter.
- * @throws AVMNotFoundException If path
does not exist.
- * @throws AVMWrongTypeException if path
is not a file.
- */
- public ContentWriter getWriter(String path);
-
/**
* Get a listing of a Folder by name.
* @param version The version id to look in.
diff --git a/source/java/org/alfresco/repo/avm/AVMServiceImpl.java b/source/java/org/alfresco/repo/avm/AVMServiceImpl.java
index 928e3d7eb2..77bd39032f 100644
--- a/source/java/org/alfresco/repo/avm/AVMServiceImpl.java
+++ b/source/java/org/alfresco/repo/avm/AVMServiceImpl.java
@@ -30,13 +30,12 @@ import java.util.SortedMap;
import org.alfresco.repo.avm.AVMRepository;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.repository.ContentData;
-import org.alfresco.service.cmr.repository.ContentReader;
-import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.namespace.QName;
+import org.alfresco.util.TempFileProvider;
import org.apache.log4j.Logger;
/**
- * Implements the AVMService. Stub.
+ * Implements the AVMService.
* @author britt
*/
public class AVMServiceImpl implements AVMService
@@ -53,16 +52,6 @@ public class AVMServiceImpl implements AVMService
*/
private AVMRepository fAVMRepository;
- /**
- * The storage directory.
- */
- private String fStorage;
-
- /**
- * Whether the tables should be dropped and created.
- */
- private boolean fInitialize;
-
/**
* Basic constructor for the service.
*/
@@ -70,32 +59,20 @@ public class AVMServiceImpl implements AVMService
{
}
- /**
- * Set the storage directory.
- * @param storage The full path to the storage directory.
- */
- public void setStorage(String storage)
- {
- fStorage = storage;
- }
-
/**
* Final initialization of the service. Must be called only on a
* fully initialized instance.
*/
public void init()
{
- if (fInitialize)
+ try
{
- try
- {
- createAVMStore("main");
- fgLogger.info("Created new main AVMStore");
- }
- catch (AVMExistsException e)
- {
- fgLogger.info("AVMStore main already exists");
- }
+ createAVMStore("main");
+ fgLogger.info("Created new main AVMStore");
+ }
+ catch (AVMExistsException e)
+ {
+ fgLogger.info("AVMStore main already exists");
}
}
@@ -108,15 +85,6 @@ public class AVMServiceImpl implements AVMService
fTransaction = txn;
}
- /**
- * Set whether we should create an initial AVMStore.
- * @param initialize
- */
- public void setInitialize(boolean initialize)
- {
- fInitialize = initialize;
- }
-
/**
* Set the repository reference. For Spring.
* @param avmRepository The repository reference.
@@ -153,58 +121,6 @@ public class AVMServiceImpl implements AVMService
return doit.in;
}
- /**
- * Get a ContentReader for the given file.
- * @param version The version to look under.
- * @param path The path to the file.
- * @return A ContentReader.
- */
- public ContentReader getReader(final int version, final String path)
- {
- if (path == null)
- {
- throw new AVMBadArgumentException("Null path.");
- }
- class TxnCallback implements RetryingTransactionCallback
- {
- public ContentReader reader;
-
- public void perform()
- {
- reader = fAVMRepository.getReader(version, path);
- }
- }
- TxnCallback doit = new TxnCallback();
- fTransaction.perform(doit, false);
- return doit.reader;
- }
-
- /**
- * Get a ContentWriter to a file.
- * @param path The path to the file.
- * @return A ContentWriter.
- * @throws AVMNotFoundException If path
does not exist.
- * @throws AVMWrongTypeException if path
is not a file.
- */
- public ContentWriter getWriter(final String path)
- {
- if (path == null)
- {
- throw new AVMBadArgumentException("Null path.");
- }
- class TxnCallback implements RetryingTransactionCallback
- {
- public ContentWriter writer;
-
- public void perform()
- {
- writer = fAVMRepository.getWriter(path);
- }
- }
- TxnCallback doit = new TxnCallback();
- fTransaction.perform(doit, true);
- return doit.writer;
- }
/**
* Get an output stream to a file. Triggers versioning.
*/
@@ -365,6 +281,7 @@ public class AVMServiceImpl implements AVMService
return doit.out;
}
+ // TODO Eliminate this.
/**
* Create a file with content specified by the InputStream.
* Guaranteed to be created atomically.
@@ -379,11 +296,10 @@ public class AVMServiceImpl implements AVMService
throw new AVMBadArgumentException("Illegal null argument.");
}
// Save the contents to temp space.
- File dir = new File(fStorage);
final File temp;
try
{
- temp = File.createTempFile("alf", "tmp", dir);
+ temp = TempFileProvider.createTempFile("alf", "tmp");
OutputStream out = new FileOutputStream(temp);
byte [] buff = new byte[8192];
int read;
diff --git a/source/java/org/alfresco/repo/avm/AVMStore.java b/source/java/org/alfresco/repo/avm/AVMStore.java
index 67c34e7b59..8ee5069bed 100644
--- a/source/java/org/alfresco/repo/avm/AVMStore.java
+++ b/source/java/org/alfresco/repo/avm/AVMStore.java
@@ -26,8 +26,6 @@ import java.util.SortedMap;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.repository.ContentData;
-import org.alfresco.service.cmr.repository.ContentReader;
-import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.namespace.QName;
/**
@@ -105,21 +103,6 @@ interface AVMStore
*/
public InputStream getInputStream(int version, String path);
- /**
- * Get a ContentReader from a file.
- * @param version The version to look under.
- * @param path The path to the file.
- * @return A ContentReader.
- */
- public ContentReader getReader(int version, String path);
-
- /**
- * Get a ContentWriter to a file.
- * @param path The path to the file.
- * @return A ContentWriter.
- */
- public ContentWriter getWriter(String path);
-
/**
* Get a listing of the designated directory.
* @param version The version to look under.
diff --git a/source/java/org/alfresco/repo/avm/AVMStoreImpl.java b/source/java/org/alfresco/repo/avm/AVMStoreImpl.java
index 3998d75648..e26c5ae739 100644
--- a/source/java/org/alfresco/repo/avm/AVMStoreImpl.java
+++ b/source/java/org/alfresco/repo/avm/AVMStoreImpl.java
@@ -268,7 +268,6 @@ class AVMStoreImpl implements AVMStore, Serializable
"UTF-8"));
ContentWriter writer = getWriter(AVMNodeConverter.ExtendAVMPath(path, name));
writer.putContent(data);
- file.setContentData(writer.getContentData());
}
/**
@@ -302,6 +301,12 @@ class AVMStoreImpl implements AVMStore, Serializable
public InputStream getInputStream(int version, String path)
{
ContentReader reader = getReader(version, path);
+ if (reader == null)
+ {
+ // TODO This is wrong, wrong, wrong. Do something about it
+ // sooner rather than later.
+ throw new AVMNotFoundException(path + " has no content.");
+ }
return reader.getContentInputStream();
/*
Lookup lPath = lookup(version, path, false);
@@ -323,7 +328,7 @@ class AVMStoreImpl implements AVMStore, Serializable
* @param path The path to the file.
* @return A ContentReader.
*/
- public ContentReader getReader(int version, String path)
+ private ContentReader getReader(int version, String path)
{
NodeRef nodeRef = AVMNodeConverter.ToNodeRef(version, fName + ":" + path);
return AVMContext.fgInstance.getContentService().getReader(nodeRef, ContentModel.PROP_CONTENT);
@@ -334,11 +339,12 @@ class AVMStoreImpl implements AVMStore, Serializable
* @param path The path to the file.
* @return A ContentWriter.
*/
- public ContentWriter getWriter(String path)
+ private ContentWriter getWriter(String path)
{
NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, fName + ":" + path);
ContentWriter writer =
AVMContext.fgInstance.getContentService().getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
+ // TODO This can't perform very well.
setContentData(path, writer.getContentData());
return writer;
}
diff --git a/source/java/org/alfresco/repo/avm/HibernateRetryingTransactionHelper.java b/source/java/org/alfresco/repo/avm/HibernateRetryingTransactionHelper.java
index ff09b139ba..8118ca2b8a 100644
--- a/source/java/org/alfresco/repo/avm/HibernateRetryingTransactionHelper.java
+++ b/source/java/org/alfresco/repo/avm/HibernateRetryingTransactionHelper.java
@@ -102,9 +102,9 @@ public class HibernateRetryingTransactionHelper extends HibernateTemplate implem
}
if (!newTxn)
{
- if (t instanceof AVMException)
+ if (t instanceof RuntimeException)
{
- throw (AVMException)t;
+ throw (RuntimeException)t;
}
throw new AVMException("Unrecoverable error.", t);
}
diff --git a/source/java/org/alfresco/repo/node/AbstractNodeServiceImpl.java b/source/java/org/alfresco/repo/node/AbstractNodeServiceImpl.java
index f9851d2b4f..7f9b75741f 100644
--- a/source/java/org/alfresco/repo/node/AbstractNodeServiceImpl.java
+++ b/source/java/org/alfresco/repo/node/AbstractNodeServiceImpl.java
@@ -49,8 +49,10 @@ import org.alfresco.repo.policy.AssociationPolicyDelegate;
import org.alfresco.repo.policy.ClassPolicyDelegate;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.search.Indexer;
+import org.alfresco.service.cmr.dictionary.ClassDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryException;
+import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -88,6 +90,7 @@ public abstract class AbstractNodeServiceImpl implements NodeService
private String uuid;
/** controls policy delegates */
private PolicyComponent policyComponent;
+ protected DictionaryService dictionaryService;
/*
* Policy delegates
@@ -125,6 +128,11 @@ public abstract class AbstractNodeServiceImpl implements NodeService
this.policyComponent = policyComponent;
}
+ public void setDictionaryService(DictionaryService dictionaryService)
+ {
+ this.dictionaryService = dictionaryService;
+ }
+
/**
* Checks equality by type and uuid
*/
@@ -564,7 +572,7 @@ public abstract class AbstractNodeServiceImpl implements NodeService
* @see RegexQNamePattern#MATCH_ALL
* @see NodeService#getChildAssocs(NodeRef, QNamePattern, QNamePattern)
*/
- public final List getChildAssocs(NodeRef nodeRef) throws InvalidNodeRefException
+ public List getChildAssocs(NodeRef nodeRef) throws InvalidNodeRefException
{
return getChildAssocs(nodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL);
}
@@ -677,4 +685,51 @@ public abstract class AbstractNodeServiceImpl implements NodeService
e);
}
}
+ /**
+ * Sets the default property values
+ *
+ * @param classDefinition
+ * @param properties
+ */
+ protected void addDefaultPropertyValues(ClassDefinition classDefinition, Map properties)
+ {
+ for (Map.Entry entry : classDefinition.getDefaultValues().entrySet())
+ {
+ if (properties.containsKey(entry.getKey()))
+ {
+ // property is present
+ continue;
+ }
+ Serializable value = entry.getValue();
+
+ // Check the type of the default property
+ PropertyDefinition prop = this.dictionaryService.getProperty(entry.getKey());
+ if (prop == null)
+ {
+ // dictionary doesn't have a default value present
+ continue;
+ }
+
+ // TODO: what other conversions are necessary here for other types of default values ?
+
+ // ensure that we deliver the property in the correct form
+ if (DataTypeDefinition.BOOLEAN.equals(prop.getDataType().getName()) == true)
+ {
+ if (value instanceof String)
+ {
+ if (((String)value).toUpperCase().equals("TRUE") == true)
+ {
+ value = Boolean.TRUE;
+ }
+ else if (((String)value).toUpperCase().equals("FALSE") == true)
+ {
+ value = Boolean.FALSE;
+ }
+ }
+ }
+
+ // Set the default value of the property
+ properties.put(entry.getKey(), value);
+ }
+ }
}
diff --git a/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java b/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java
index 0f990fb943..81fc7ecb7e 100644
--- a/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java
+++ b/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java
@@ -42,8 +42,6 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.ClassDefinition;
-import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
-import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.InvalidAspectException;
import org.alfresco.service.cmr.dictionary.InvalidTypeException;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
@@ -77,7 +75,6 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
{
private static Log logger = LogFactory.getLog(DbNodeServiceImpl.class);
- private DictionaryService dictionaryService;
private NodeDaoService nodeDaoService;
private StoreArchiveMap storeArchiveMap;
private NodeService avmNodeService;
@@ -87,11 +84,6 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
storeArchiveMap = new StoreArchiveMap(); // in case it is not set
}
- public void setDictionaryService(DictionaryService dictionaryService)
- {
- this.dictionaryService = dictionaryService;
- }
-
public void setNodeDaoService(NodeDaoService nodeDaoService)
{
this.nodeDaoService = nodeDaoService;
@@ -347,53 +339,6 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
}
}
- /**
- * Sets the default property values
- *
- * @param classDefinition
- * @param properties
- */
- private void addDefaultPropertyValues(ClassDefinition classDefinition, Map properties)
- {
- for (Map.Entry entry : classDefinition.getDefaultValues().entrySet())
- {
- if (properties.containsKey(entry.getKey()))
- {
- // property is present
- continue;
- }
- Serializable value = entry.getValue();
-
- // Check the type of the default property
- PropertyDefinition prop = this.dictionaryService.getProperty(entry.getKey());
- if (prop == null)
- {
- // dictionary doesn't have a default value present
- continue;
- }
-
- // TODO: what other conversions are necessary here for other types of default values ?
-
- // ensure that we deliver the property in the correct form
- if (DataTypeDefinition.BOOLEAN.equals(prop.getDataType().getName()) == true)
- {
- if (value instanceof String)
- {
- if (((String)value).toUpperCase().equals("TRUE") == true)
- {
- value = Boolean.TRUE;
- }
- else if (((String)value).toUpperCase().equals("FALSE") == true)
- {
- value = Boolean.FALSE;
- }
- }
- }
-
- // Set the default value of the property
- properties.put(entry.getKey(), value);
- }
- }
/**
* Drops the old primary association and creates a new one