AVM Nodes are (theoretically) mostly aspect ready. AVMNodeService is

now derived from AbstractNodeServiceImpl to make policy awareness easier.
Moved addDefaultPropertyValues from DbNodeServiceImpl to 
AbstractNodeServiceImpl so AVMNodeService can use it.  A fix for an
NPE that showed up in stress test.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3603 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-08-24 18:36:59 +00:00
parent d67b926589
commit 0606fa3ab6
15 changed files with 252 additions and 619 deletions

View File

@@ -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<QName, Serializable> 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<QName, Serializable> 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<QName, Serializable> properties)
{
// Get mandatory aspects.
List<AspectDefinition> 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<QName, PropertyDefinition> 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<QName> getAspects(NodeRef nodeRef) throws InvalidNodeRefException
{
// TODO This is almost certainly not the right thing to do.
return new HashSet<QName>();
Object [] avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef);
int version = (Integer)avmVersionPath[0];
String path = (String)avmVersionPath[1];
Set<QName> result = new HashSet<QName>();
// Add the builtin ones.
for (QName name : fgBuiltinAspects)
{
result.add(name);
}
try
{
List<QName> 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<ChildAssociationRef> result = new ArrayList<ChildAssociationRef>();
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;

View File

@@ -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.

View File

@@ -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 <code>path</code> does not exist.
* @throws AVMWrongTypeException if <code>path</code> 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 <code>path</code> does not exist.
* @throws AVMWrongTypeException if <code>path</code> 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.

View File

@@ -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 <code>path</code> does not exist.
* @throws AVMWrongTypeException if <code>path</code> 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;

View File

@@ -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.

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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<ChildAssociationRef> getChildAssocs(NodeRef nodeRef) throws InvalidNodeRefException
public List<ChildAssociationRef> 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<QName, Serializable> properties)
{
for (Map.Entry<QName, Serializable> 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);
}
}
}

View File

@@ -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<QName, Serializable> properties)
{
for (Map.Entry<QName, Serializable> 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