mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged V2.2 to HEAD (QNames)
7624: QName Refactor Merge 1 of 9 7625: QName Refactor Merge 2 of 9 7626: QName Refactor Merge 3 of 9 7627: QName Refactor Merge 4 of 9 7628: QName Refactor Merge 5 of 9 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8436 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -7,6 +7,7 @@ import org.alfresco.repo.attributes.AttributeDAO;
|
||||
import org.alfresco.repo.attributes.GlobalAttributeEntryDAO;
|
||||
import org.alfresco.repo.attributes.ListEntryDAO;
|
||||
import org.alfresco.repo.attributes.MapEntryDAO;
|
||||
import org.alfresco.repo.domain.QNameDAO;
|
||||
|
||||
/**
|
||||
* This is the (shudder) global context for AVM. It a rendezvous
|
||||
@@ -44,6 +45,11 @@ public class AVMDAOs
|
||||
*/
|
||||
public AVMNodeDAO fAVMNodeDAO;
|
||||
|
||||
/**
|
||||
* The QName DAO
|
||||
*/
|
||||
public QNameDAO fQNameDAO;
|
||||
|
||||
/**
|
||||
* The AVMStore DAO.
|
||||
*/
|
||||
@@ -102,6 +108,11 @@ public class AVMDAOs
|
||||
fAVMNodeDAO = nodeDAO;
|
||||
}
|
||||
|
||||
public void setQnameDAO(QNameDAO qnameDAO)
|
||||
{
|
||||
this.fQNameDAO = qnameDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param childEntryDAO the fChildEntryDAO to set
|
||||
*/
|
||||
|
@@ -28,7 +28,6 @@ import java.util.Set;
|
||||
import org.alfresco.repo.domain.DbAccessControlList;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* The Interface for versionable objects.
|
||||
@@ -153,35 +152,35 @@ public interface AVMNode
|
||||
|
||||
/**
|
||||
* Set a property.
|
||||
* @param name The name of the property.
|
||||
* @param value The value to set.
|
||||
* @param qnameEntityId the ID of the QName to set
|
||||
* @param value The value to set.
|
||||
*/
|
||||
public void setProperty(QName name, PropertyValue value);
|
||||
public void setProperty(Long qnameEntityId, PropertyValue value);
|
||||
|
||||
/**
|
||||
* Set a collection of properties on this node.
|
||||
* @param properties The Map of QNames to PropertyValues.
|
||||
* @param properties The Map of QName entity IDs to PropertyValues.
|
||||
*/
|
||||
public void setProperties(Map<QName, PropertyValue> properties);
|
||||
public void setProperties(Map<Long, PropertyValue> properties);
|
||||
|
||||
/**
|
||||
* Get a property by name.
|
||||
* @param name The name of the property to get.
|
||||
* @return A PropertyValue
|
||||
*/
|
||||
public PropertyValue getProperty(QName name);
|
||||
public PropertyValue getProperty(Long name);
|
||||
|
||||
/**
|
||||
* Get all the properties associated with this node.
|
||||
* @return A Map of QNames to PropertyValues.
|
||||
*/
|
||||
public Map<QName, PropertyValue> getProperties();
|
||||
public Map<Long, PropertyValue> getProperties();
|
||||
|
||||
/**
|
||||
* Delete a property from this node.
|
||||
* @param name The name of the property.
|
||||
* @param qnameEntityId the ID of the QName to delete
|
||||
*/
|
||||
public void deleteProperty(QName name);
|
||||
public void deleteProperty(Long qnameEntityId);
|
||||
|
||||
/**
|
||||
* Delete all properties from this node.
|
||||
@@ -232,15 +231,15 @@ public interface AVMNode
|
||||
|
||||
/**
|
||||
* Get the Aspects that this node has.
|
||||
* @return A Set of Aspects names.
|
||||
* @return A Set of Aspects IDs.
|
||||
*/
|
||||
public Set<QName> getAspects();
|
||||
public Set<Long> getAspects();
|
||||
|
||||
/**
|
||||
* Add properties to those that already exist.
|
||||
* @param properties The properties to add.
|
||||
*/
|
||||
public void addProperties(Map<QName, PropertyValue> properties);
|
||||
public void addProperties(Map<Long, PropertyValue> properties);
|
||||
|
||||
/**
|
||||
* Get the Basic Attributes on this node.
|
||||
|
@@ -34,7 +34,6 @@ import org.alfresco.repo.domain.DbAccessControlList;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.repo.security.permissions.ACLCopyMode;
|
||||
import org.alfresco.service.cmr.avm.AVMReadOnlyException;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -47,7 +46,7 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
{
|
||||
private static Log fgLogger = LogFactory.getLog(AVMNodeImpl.class);
|
||||
|
||||
protected static final boolean DEBUG = true;
|
||||
protected static final boolean DEBUG = fgLogger.isDebugEnabled();
|
||||
|
||||
/**
|
||||
* The Object ID.
|
||||
@@ -92,17 +91,17 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
/**
|
||||
* The Aspects that belong to this node.
|
||||
*/
|
||||
private Set<QName> fAspects;
|
||||
private Set<Long> fAspects;
|
||||
|
||||
private Map<QName, PropertyValue> fProperties;
|
||||
private Map<Long, PropertyValue> fProperties;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
protected AVMNodeImpl()
|
||||
{
|
||||
fAspects = new HashSet<QName>();
|
||||
fProperties = new HashMap<QName, PropertyValue>();
|
||||
fAspects = new HashSet<Long>();
|
||||
fProperties = new HashMap<Long, PropertyValue>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,8 +112,8 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
protected AVMNodeImpl(long id,
|
||||
AVMStore store)
|
||||
{
|
||||
fAspects = new HashSet<QName>();
|
||||
fProperties = new HashMap<QName, PropertyValue>();
|
||||
fAspects = new HashSet<Long>();
|
||||
fProperties = new HashMap<Long, PropertyValue>();
|
||||
fID = id;
|
||||
fVersionID = -1;
|
||||
fIsRoot = false;
|
||||
@@ -351,8 +350,8 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
*/
|
||||
protected void copyProperties(AVMNode other)
|
||||
{
|
||||
fProperties = new HashMap<QName, PropertyValue>();
|
||||
for (Map.Entry<QName, PropertyValue> entry : other.getProperties().entrySet())
|
||||
fProperties = new HashMap<Long, PropertyValue>();
|
||||
for (Map.Entry<Long, PropertyValue> entry : other.getProperties().entrySet())
|
||||
{
|
||||
fProperties.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
@@ -364,7 +363,7 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
*/
|
||||
protected void copyAspects(AVMNode other)
|
||||
{
|
||||
fAspects = new HashSet<QName>(other.getAspects());
|
||||
fAspects = new HashSet<Long>(other.getAspects());
|
||||
}
|
||||
|
||||
protected void copyACLs(AVMNode other, Long parentAcl, ACLCopyMode mode)
|
||||
@@ -392,18 +391,18 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
* @param name The name of the property.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
public void setProperty(QName name, PropertyValue value)
|
||||
public void setProperty(Long qnameEntityId, PropertyValue value)
|
||||
{
|
||||
if (DEBUG)
|
||||
{
|
||||
checkReadOnly();
|
||||
}
|
||||
fProperties.put(name, value);
|
||||
fProperties.put(qnameEntityId, value);
|
||||
}
|
||||
|
||||
public void addProperties(Map<QName, PropertyValue> properties)
|
||||
public void addProperties(Map<Long, PropertyValue> properties)
|
||||
{
|
||||
for (Map.Entry<QName, PropertyValue> entry : properties.entrySet())
|
||||
for (Map.Entry<Long, PropertyValue> entry : properties.entrySet())
|
||||
{
|
||||
fProperties.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
@@ -413,7 +412,7 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
* Set a collection of properties on this node.
|
||||
* @param properties The Map of QNames to PropertyValues.
|
||||
*/
|
||||
public void setProperties(Map<QName, PropertyValue> properties)
|
||||
public void setProperties(Map<Long, PropertyValue> properties)
|
||||
{
|
||||
fProperties = properties;
|
||||
}
|
||||
@@ -423,16 +422,15 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
* @param name The name of the property.
|
||||
* @return The PropertyValue or null if non-existent.
|
||||
*/
|
||||
public PropertyValue getProperty(QName name)
|
||||
public PropertyValue getProperty(Long qnameEntityId)
|
||||
{
|
||||
return fProperties.get(name);
|
||||
return fProperties.get(qnameEntityId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the properties associated with this node.
|
||||
* @return A Map of QNames to PropertyValues.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Map<QName, PropertyValue> getProperties()
|
||||
public Map<Long, PropertyValue> getProperties()
|
||||
{
|
||||
return fProperties;
|
||||
}
|
||||
@@ -441,13 +439,13 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
* Delete a property from this node.
|
||||
* @param name The name of the property.
|
||||
*/
|
||||
public void deleteProperty(QName name)
|
||||
public void deleteProperty(Long qnameEntityId)
|
||||
{
|
||||
if (DEBUG)
|
||||
{
|
||||
checkReadOnly();
|
||||
}
|
||||
fProperties.remove(name);
|
||||
fProperties.remove(qnameEntityId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -521,7 +519,7 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.AVMNode#getAspects()
|
||||
*/
|
||||
public Set<QName> getAspects()
|
||||
public Set<Long> getAspects()
|
||||
{
|
||||
return fAspects;
|
||||
}
|
||||
@@ -530,7 +528,7 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
* Set the aspects on this node.
|
||||
* @param aspects
|
||||
*/
|
||||
public void setAspects(Set<QName> aspects)
|
||||
public void setAspects(Set<Long> aspects)
|
||||
{
|
||||
fAspects = aspects;
|
||||
}
|
||||
|
@@ -39,6 +39,7 @@ import org.alfresco.model.WCMModel;
|
||||
import org.alfresco.repo.content.ContentStore;
|
||||
import org.alfresco.repo.domain.DbAccessControlList;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.repo.domain.QNameDAO;
|
||||
import org.alfresco.repo.security.permissions.ACLCopyMode;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
@@ -105,6 +106,8 @@ public class AVMRepository
|
||||
* The Lookup Cache instance.
|
||||
*/
|
||||
private LookupCache fLookupCache;
|
||||
|
||||
private QNameDAO qnameDAO;
|
||||
|
||||
private AVMStoreDAO fAVMStoreDAO;
|
||||
|
||||
@@ -214,6 +217,11 @@ public class AVMRepository
|
||||
fPurgeVersionTxnListener = listener;
|
||||
}
|
||||
|
||||
public void setQnameDAO(QNameDAO qnameDAO)
|
||||
{
|
||||
this.qnameDAO = qnameDAO;
|
||||
}
|
||||
|
||||
public void setAvmStoreDAO(AVMStoreDAO dao)
|
||||
{
|
||||
fAVMStoreDAO = dao;
|
||||
@@ -2318,7 +2326,7 @@ public class AVMRepository
|
||||
Map<QName, PropertyValue> results = new HashMap<QName, PropertyValue>();
|
||||
for (AVMStoreProperty prop : matches)
|
||||
{
|
||||
results.put(prop.getName(), prop.getValue());
|
||||
results.put(prop.getName().getQName(), prop.getValue());
|
||||
}
|
||||
return results;
|
||||
}
|
||||
@@ -2346,7 +2354,7 @@ public class AVMRepository
|
||||
pairs = new HashMap<QName, PropertyValue>();
|
||||
results.put(storeName, pairs);
|
||||
}
|
||||
pairs.put(prop.getName(), prop.getValue());
|
||||
pairs.put(prop.getName().getQName(), prop.getValue());
|
||||
}
|
||||
return results;
|
||||
}
|
||||
@@ -3096,7 +3104,10 @@ public class AVMRepository
|
||||
{
|
||||
throw new AccessDeniedException("Not allowed to read properties: " + desc);
|
||||
}
|
||||
return node.getProperties();
|
||||
QNameDAO qnameDAO = AVMDAOs.Instance().fQNameDAO;
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<QName, PropertyValue> converted = (Map<QName, PropertyValue>) qnameDAO.convertIdMapToQNameMap(node.getProperties());
|
||||
return converted;
|
||||
}
|
||||
|
||||
public ContentData getContentDataForRead(AVMNodeDescriptor desc)
|
||||
@@ -3129,8 +3140,10 @@ public class AVMRepository
|
||||
{
|
||||
throw new AccessDeniedException("Not allowed to read properties: " + desc);
|
||||
}
|
||||
Set<QName> aspects = node.getAspects();
|
||||
return aspects;
|
||||
Set<Long> aspectIds = node.getAspects();
|
||||
// Convert to QNames
|
||||
Set<QName> aspectQNames = qnameDAO.convertIdsToQNames(aspectIds);
|
||||
return aspectQNames;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3163,22 +3176,32 @@ public class AVMRepository
|
||||
}
|
||||
PermissionContext context = new PermissionContext(type);
|
||||
context.addDynamicAuthorityAssignment(node.getBasicAttributes().getOwner(), PermissionService.OWNER_AUTHORITY);
|
||||
context.getAspects().addAll(node.getAspects());
|
||||
Map<QName, PropertyValue> props = node.getProperties();
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(5);
|
||||
for (Map.Entry<QName, PropertyValue> entry : props.entrySet())
|
||||
// Pass in node aspects
|
||||
Set<Long> nodeAspectQNameIds = node.getAspects();
|
||||
Set<QName> contextQNames = context.getAspects();
|
||||
for (Long nodeAspectQNameId : nodeAspectQNameIds)
|
||||
{
|
||||
PropertyDefinition def = fDictionaryService.getProperty(entry.getKey());
|
||||
QName qname = qnameDAO.getQName(nodeAspectQNameId);
|
||||
contextQNames.add(qname);
|
||||
}
|
||||
// Pass in node properties
|
||||
Map<Long, PropertyValue> nodeProperties = node.getProperties();
|
||||
Map<QName, Serializable> contextProperties = new HashMap<QName, Serializable>(5);
|
||||
QNameDAO qnameDAO = AVMDAOs.Instance().fQNameDAO;
|
||||
for (Map.Entry<Long, PropertyValue> entry : nodeProperties.entrySet())
|
||||
{
|
||||
QName qname = qnameDAO.getQName(entry.getKey());
|
||||
PropertyDefinition def = fDictionaryService.getProperty(qname);
|
||||
if (def == null)
|
||||
{
|
||||
properties.put(entry.getKey(), entry.getValue().getValue(DataTypeDefinition.ANY));
|
||||
contextProperties.put(qname, entry.getValue().getValue(DataTypeDefinition.ANY));
|
||||
}
|
||||
else
|
||||
{
|
||||
properties.put(entry.getKey(), entry.getValue().getValue(def.getDataType().getName()));
|
||||
contextProperties.put(qname, entry.getValue().getValue(def.getDataType().getName()));
|
||||
}
|
||||
}
|
||||
context.getProperties().putAll(properties);
|
||||
context.getProperties().putAll(contextProperties);
|
||||
Long aclId = null;
|
||||
if(acl != null)
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -43,6 +43,8 @@ import org.alfresco.repo.avm.util.SimplePath;
|
||||
import org.alfresco.repo.domain.DbAccessControlList;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.repo.security.permissions.ACLCopyMode;
|
||||
import org.alfresco.repo.domain.QNameDAO;
|
||||
import org.alfresco.repo.domain.QNameEntity;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
|
||||
import org.alfresco.service.cmr.avm.AVMException;
|
||||
@@ -367,11 +369,26 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
dir.putChild(name, newDir);
|
||||
if (aspects != null)
|
||||
{
|
||||
newDir.getAspects().addAll(aspects);
|
||||
// Convert the aspect QNames to entities
|
||||
QNameDAO qnameDAO = AVMDAOs.Instance().fQNameDAO;
|
||||
Set<Long> aspectQNameEntityIds = newDir.getAspects();
|
||||
for (QName aspectQName : aspects)
|
||||
{
|
||||
Long qnameEntityId = qnameDAO.getOrCreateQNameEntity(aspectQName).getId();
|
||||
aspectQNameEntityIds.add(qnameEntityId);
|
||||
}
|
||||
}
|
||||
if (properties != null)
|
||||
{
|
||||
newDir.getProperties().putAll(properties);
|
||||
// Convert the property QNames to entities
|
||||
QNameDAO qnameDAO = AVMDAOs.Instance().fQNameDAO;
|
||||
Map<Long, PropertyValue> propertiesByQNameEntityId = new HashMap<Long, PropertyValue>(properties.size() * 2 + 1);
|
||||
for (Map.Entry<QName, PropertyValue> entry : properties.entrySet())
|
||||
{
|
||||
Long qnameEntityId = qnameDAO.getOrCreateQNameEntity(entry.getKey()).getId();
|
||||
propertiesByQNameEntityId.put(qnameEntityId, entry.getValue());
|
||||
}
|
||||
newDir.getProperties().putAll(propertiesByQNameEntityId);
|
||||
}
|
||||
DbAccessControlList acl = dir.getAcl();
|
||||
newDir.setAcl(acl != null ? acl.getCopy(acl.getId(), ACLCopyMode.INHERIT) : null);
|
||||
@@ -503,11 +520,26 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
"UTF-8"));
|
||||
if (aspects != null)
|
||||
{
|
||||
file.getAspects().addAll(aspects);
|
||||
// Convert the aspect QNames to entities
|
||||
QNameDAO qnameDAO = AVMDAOs.Instance().fQNameDAO;
|
||||
Set<Long> aspectQNameEntityIds = file.getAspects();
|
||||
for (QName aspectQName : aspects)
|
||||
{
|
||||
Long qnameEntityId = qnameDAO.getOrCreateQNameEntity(aspectQName).getId();
|
||||
aspectQNameEntityIds.add(qnameEntityId);
|
||||
}
|
||||
}
|
||||
if (properties != null)
|
||||
{
|
||||
file.getProperties().putAll(properties);
|
||||
// Convert the property QNames to entities
|
||||
QNameDAO qnameDAO = AVMDAOs.Instance().fQNameDAO;
|
||||
Map<Long, PropertyValue> propertiesByQNameEntityId = new HashMap<Long, PropertyValue>(properties.size() * 2 + 1);
|
||||
for (Map.Entry<QName, PropertyValue> entry : properties.entrySet())
|
||||
{
|
||||
Long qnameEntityId = qnameDAO.getOrCreateQNameEntity(entry.getKey()).getId();
|
||||
propertiesByQNameEntityId.put(qnameEntityId, entry.getValue());
|
||||
}
|
||||
file.getProperties().putAll(propertiesByQNameEntityId);
|
||||
}
|
||||
DbAccessControlList acl = dir.getAcl();
|
||||
file.setAcl(acl != null ? acl.getCopy(acl.getId(), ACLCopyMode.INHERIT) : null);
|
||||
@@ -1159,7 +1191,9 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
{
|
||||
throw new AccessDeniedException("Not allowed to write: " + path);
|
||||
}
|
||||
node.setProperty(name, value);
|
||||
QNameEntity qnameEntity = AVMDAOs.Instance().fQNameDAO.getOrCreateQNameEntity(name);
|
||||
|
||||
node.setProperty(qnameEntity.getId(), value);
|
||||
node.setGuid(GUID.generate());
|
||||
}
|
||||
|
||||
@@ -1180,7 +1214,18 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
{
|
||||
throw new AccessDeniedException("Not allowed to write: " + path);
|
||||
}
|
||||
node.addProperties(properties);
|
||||
if (properties != null)
|
||||
{
|
||||
// Convert the property QNames to entities
|
||||
QNameDAO qnameDAO = AVMDAOs.Instance().fQNameDAO;
|
||||
Map<Long, PropertyValue> propertiesByQNameEntityId = new HashMap<Long, PropertyValue>(properties.size() * 2 + 1);
|
||||
for (Map.Entry<QName, PropertyValue> entry : properties.entrySet())
|
||||
{
|
||||
Long qnameEntityId = qnameDAO.getOrCreateQNameEntity(entry.getKey()).getId();
|
||||
propertiesByQNameEntityId.put(qnameEntityId, entry.getValue());
|
||||
}
|
||||
node.addProperties(propertiesByQNameEntityId);
|
||||
}
|
||||
node.setGuid(GUID.generate());
|
||||
}
|
||||
|
||||
@@ -1203,8 +1248,19 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
{
|
||||
throw new AccessDeniedException("Not allowed to read: " + path);
|
||||
}
|
||||
PropertyValue prop = node.getProperty(name);
|
||||
return prop;
|
||||
// Convert the QName
|
||||
QNameDAO qnameDAO = AVMDAOs.Instance().fQNameDAO;
|
||||
QNameEntity qnameEntity = qnameDAO.getOrCreateQNameEntity(name);
|
||||
if (qnameEntity == null)
|
||||
{
|
||||
// No such QName
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
PropertyValue prop = node.getProperty(qnameEntity.getId());
|
||||
return prop;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1225,8 +1281,12 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
{
|
||||
throw new AccessDeniedException("Not allowed to read: " + path);
|
||||
}
|
||||
Map<QName, PropertyValue> props = node.getProperties();
|
||||
return props;
|
||||
Map<Long, PropertyValue> props = node.getProperties();
|
||||
// Convert to QNames
|
||||
QNameDAO qnameDAO = AVMDAOs.Instance().fQNameDAO;
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<QName, PropertyValue> convertedProps = (Map<QName, PropertyValue>) qnameDAO.convertIdMapToQNameMap(props);
|
||||
return convertedProps;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1247,7 +1307,17 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
throw new AccessDeniedException("Not allowed to write: " + path);
|
||||
}
|
||||
node.setGuid(GUID.generate());
|
||||
node.deleteProperty(name);
|
||||
|
||||
// convert the QName
|
||||
QNameEntity qnameEntity = AVMDAOs.Instance().fQNameDAO.getQNameEntity(name);
|
||||
if (qnameEntity == null)
|
||||
{
|
||||
// No such property
|
||||
}
|
||||
else
|
||||
{
|
||||
node.deleteProperty(qnameEntity.getId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1277,9 +1347,10 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
*/
|
||||
public void setProperty(QName name, PropertyValue value)
|
||||
{
|
||||
QNameEntity qnameEntity = AVMDAOs.Instance().fQNameDAO.getOrCreateQNameEntity(name);
|
||||
AVMStoreProperty prop = new AVMStorePropertyImpl();
|
||||
prop.setStore(this);
|
||||
prop.setName(name);
|
||||
prop.setName(qnameEntity);
|
||||
prop.setValue(value);
|
||||
AVMDAOs.Instance().fAVMStorePropertyDAO.save(prop);
|
||||
}
|
||||
@@ -1322,7 +1393,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
Map<QName, PropertyValue> retVal = new HashMap<QName, PropertyValue>();
|
||||
for (AVMStoreProperty prop : props)
|
||||
{
|
||||
retVal.put(prop.getName(), prop.getValue());
|
||||
retVal.put(prop.getName().getQName(), prop.getValue());
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
@@ -1454,7 +1525,11 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
{
|
||||
throw new AccessDeniedException("Not allowed to write: " + path);
|
||||
}
|
||||
node.getAspects().add(aspectName);
|
||||
// Convert the aspect QNames to entities
|
||||
QNameDAO qnameDAO = AVMDAOs.Instance().fQNameDAO;
|
||||
Long qnameEntityId = qnameDAO.getOrCreateQNameEntity(aspectName).getId();
|
||||
// Convert the
|
||||
node.getAspects().add(qnameEntityId);
|
||||
node.setGuid(GUID.generate());
|
||||
}
|
||||
|
||||
@@ -1476,8 +1551,10 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
{
|
||||
throw new AccessDeniedException("Not allowed to read properties: " + path);
|
||||
}
|
||||
Set<QName> aspects = node.getAspects();
|
||||
return aspects;
|
||||
Set<Long> aspects = node.getAspects();
|
||||
QNameDAO qnameDAO = AVMDAOs.Instance().fQNameDAO;
|
||||
Set<QName> aspectQNames = qnameDAO.convertIdsToQNames(aspects);
|
||||
return aspectQNames;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1497,13 +1574,20 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
{
|
||||
throw new AccessDeniedException("Not allowed to write properties: " + path);
|
||||
}
|
||||
node.getAspects().remove(aspectName);
|
||||
QNameDAO qnameDAO = AVMDAOs.Instance().fQNameDAO;
|
||||
// Get the persistent ID for the QName and remove from the set
|
||||
QNameEntity qnameEntity = qnameDAO.getQNameEntity(aspectName);
|
||||
if (qnameEntity != null)
|
||||
{
|
||||
node.getAspects().remove(qnameEntity.getId());
|
||||
}
|
||||
AspectDefinition def = RawServices.Instance().getDictionaryService().getAspect(aspectName);
|
||||
Map<QName, PropertyDefinition> properties =
|
||||
def.getProperties();
|
||||
for (QName name : properties.keySet())
|
||||
{
|
||||
node.getProperties().remove(name);
|
||||
QNameEntity propertyQNameEntity = qnameDAO.getQNameEntity(name);
|
||||
node.getProperties().remove(propertyQNameEntity.getId());
|
||||
}
|
||||
node.setGuid(GUID.generate());
|
||||
}
|
||||
@@ -1527,8 +1611,17 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
{
|
||||
throw new AccessDeniedException("Not allowed to read properties: " + path);
|
||||
}
|
||||
boolean has = node.getAspects().contains(aspectName);
|
||||
return has;
|
||||
QNameDAO qnameDAO = AVMDAOs.Instance().fQNameDAO;
|
||||
// Get the persistent ID for the QName and remove from the set
|
||||
QNameEntity qnameEntity = qnameDAO.getQNameEntity(aspectName);
|
||||
if (qnameEntity != null)
|
||||
{
|
||||
return node.getAspects().contains(qnameEntity.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1630,9 +1723,13 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
toLink.changeAncestor(child);
|
||||
toLink.setVersionID(child.getVersionID() + 1);
|
||||
// TODO This really shouldn't be here. Leaking layers.
|
||||
toLink.getAspects().add(WCMModel.ASPECT_REVERTED);
|
||||
QNameDAO qnameDAO = AVMDAOs.Instance().fQNameDAO;
|
||||
QNameEntity revertedQNameEntity = qnameDAO.getOrCreateQNameEntity(WCMModel.ASPECT_REVERTED);
|
||||
toLink.getAspects().add(revertedQNameEntity.getId());
|
||||
PropertyValue value = new PropertyValue(null, toRevertTo.getId());
|
||||
toLink.setProperty(WCMModel.PROP_REVERTED_ID, value);
|
||||
|
||||
QNameEntity qnameEntity = AVMDAOs.Instance().fQNameDAO.getOrCreateQNameEntity(WCMModel.PROP_REVERTED_ID);
|
||||
toLink.setProperty(qnameEntity.getId(), value);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@@ -24,7 +24,7 @@
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.repo.domain.QNameEntity;
|
||||
|
||||
/**
|
||||
* Arbitrary properties associated with AVMStores.
|
||||
@@ -46,15 +46,15 @@ public interface AVMStoreProperty
|
||||
|
||||
/**
|
||||
* Set the name of the property.
|
||||
* @param name The QName for the property.
|
||||
* @param qnameEntity The QNameEntity for the property.
|
||||
*/
|
||||
public void setName(QName name);
|
||||
public void setName(QNameEntity qnameEntity);
|
||||
|
||||
/**
|
||||
* Get the name of this property.
|
||||
* @return The QName of this property.
|
||||
* @return The QNameEntity of this property.
|
||||
*/
|
||||
public QName getName();
|
||||
public QNameEntity getName();
|
||||
|
||||
/**
|
||||
* Set the actual property value.
|
||||
|
@@ -26,7 +26,7 @@ package org.alfresco.repo.avm;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.repo.domain.QNameEntity;
|
||||
|
||||
/**
|
||||
* Simple bean to hold properties attached to AVMStores.
|
||||
@@ -49,7 +49,7 @@ class AVMStorePropertyImpl implements AVMStoreProperty, Serializable
|
||||
/**
|
||||
* The name of the property.
|
||||
*/
|
||||
private QName fName;
|
||||
private QNameEntity name;
|
||||
|
||||
/**
|
||||
* The actual PropertyValue.
|
||||
@@ -61,21 +61,19 @@ class AVMStorePropertyImpl implements AVMStoreProperty, Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the property.
|
||||
* @return The QName for the property.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public QName getName()
|
||||
public QNameEntity getName()
|
||||
{
|
||||
return fName;
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the property.
|
||||
* @param name The QName of the property.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setName(QName name)
|
||||
public void setName(QNameEntity name)
|
||||
{
|
||||
fName = name;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,13 +142,13 @@ class AVMStorePropertyImpl implements AVMStoreProperty, Serializable
|
||||
return false;
|
||||
}
|
||||
AVMStoreProperty o = (AVMStoreProperty)other;
|
||||
return fStore.equals(o.getStore()) && fName.equals(o.getName());
|
||||
return fStore.equals(o.getStore()) && name.equals(o.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return fStore.hashCode() + fName.hashCode();
|
||||
return fStore.hashCode() + name.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,6 @@
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -36,7 +35,6 @@ import org.alfresco.service.cmr.avm.AVMException;
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
@@ -119,8 +117,8 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
|
||||
public PlainFileNodeImpl(AVMStore store,
|
||||
BasicAttributes attrs,
|
||||
ContentData content,
|
||||
Map<QName, PropertyValue> props,
|
||||
Set<QName> aspects,
|
||||
Map<Long, PropertyValue> props,
|
||||
Set<Long> aspects,
|
||||
DbAccessControlList acl,
|
||||
int versionID, Long parentAcl, ACLCopyMode mode)
|
||||
{
|
||||
@@ -131,7 +129,7 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
|
||||
AVMDAOs.Instance().fAVMNodeDAO.save(this);
|
||||
AVMDAOs.Instance().fAVMNodeDAO.flush();
|
||||
addProperties(props);
|
||||
setAspects(new HashSet<QName>(aspects));
|
||||
setAspects(new HashSet<Long>(aspects));
|
||||
if (acl != null)
|
||||
{
|
||||
setAcl(acl.getCopy(parentAcl, mode));
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
|
||||
<hibernate-mapping package="org.alfresco.repo.avm">
|
||||
|
||||
<typedef class="org.alfresco.repo.domain.hibernate.QNameUserType" name="QName"/>
|
||||
<typedef class="org.alfresco.repo.domain.hibernate.QNameUserType" name="QName" />
|
||||
|
||||
<!-- AVMNodeBean is the abstract base for filesystem like objects.
|
||||
We're using the one table per class hierarchy strategy to implement
|
||||
@@ -48,17 +48,17 @@
|
||||
class="org.alfresco.repo.domain.hibernate.DbAccessControlListImpl"/>
|
||||
<set name="aspects" fetch="join" lazy="false" table="avm_aspects_new" cascade="all" optimistic-lock="true">
|
||||
<cache usage="read-write"/>
|
||||
<key column="id"/>
|
||||
<element type="QName" not-null="true" column="name" length="200"/>
|
||||
<key column="id" not-null="true" foreign-key="fk_avm_asp_n"/>
|
||||
<element column="qname_id" type="long" not-null="true"/>
|
||||
</set>
|
||||
<map name="properties" fetch="join" lazy="false" table="avm_node_properties_new" cascade="all" optimistic-lock="true">
|
||||
<cache usage="read-write"/>
|
||||
<key column="node_id" not-null="true"/>
|
||||
<map-key type="QName" length="200" column="qname"/>
|
||||
<key column="node_id" not-null="true" foreign-key="fk_avm_np_n"/>
|
||||
<map-key column="qname_id" type="long" />
|
||||
<composite-element class="org.alfresco.repo.domain.PropertyValue">
|
||||
<property name="actualType" column="actual_type" type="string" length="15" not-null="true" />
|
||||
<property name="actualType" column="actual_type_n" type="integer" not-null="true" />
|
||||
<property name="persistedType" column="persisted_type_n" type="integer" not-null="true" />
|
||||
<property name="multiValued" column="multi_valued" type="boolean" not-null="true" />
|
||||
<property name="persistedType" column="persisted_type" type="string" length="15" not-null="true" />
|
||||
<property name="booleanValue" column="boolean_value" type="boolean" />
|
||||
<property name="longValue" column="long_value" type="long" />
|
||||
<property name="floatValue" column="float_value" type="float" />
|
||||
@@ -141,6 +141,33 @@
|
||||
column="current_root_id" cascade="save-update" foreign-key="fk_avm_s_root">
|
||||
</many-to-one>
|
||||
</class>
|
||||
<class name="AVMStorePropertyImpl" proxy="AVMStoreProperty" table="avm_store_properties">
|
||||
<id name="id" column="id" type="long">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<many-to-one name="store" class="AVMStoreImpl" column="avm_store_id" foreign-key="fk_avm_sp_store"/>
|
||||
<many-to-one
|
||||
name="name"
|
||||
class="org.alfresco.repo.domain.hibernate.QNameEntityImpl"
|
||||
column="qname_id"
|
||||
foreign-key="fk_avm_sp_qname"
|
||||
lazy="proxy"
|
||||
fetch="select"
|
||||
unique="false"
|
||||
not-null="true"
|
||||
cascade="none" />
|
||||
<component class="org.alfresco.repo.domain.PropertyValue" name="value">
|
||||
<property name="actualType" column="actual_type_n" type="integer" not-null="true" />
|
||||
<property name="persistedType" column="persisted_type_n" type="integer" not-null="true" />
|
||||
<property name="multiValued" column="multi_valued" type="boolean" not-null="true" />
|
||||
<property name="booleanValue" column="boolean_value" type="boolean" />
|
||||
<property name="longValue" column="long_value" type="long" />
|
||||
<property name="floatValue" column="float_value" type="float" />
|
||||
<property name="doubleValue" column="double_value" type="double" />
|
||||
<property name="stringValue" column="string_value" type="string" length="1024"/>
|
||||
<property name="serializableValue" column="serializable_value" type="serializable" length="16384"/>
|
||||
</component>
|
||||
</class>
|
||||
<class name="VersionRootImpl" proxy="VersionRoot" table="avm_version_roots">
|
||||
<cache usage="read-write"/>
|
||||
<id name="id" column="id" type="long">
|
||||
@@ -185,6 +212,20 @@
|
||||
<key-many-to-one name="mto" class="AVMNodeImpl" column="mto" foreign-key="fk_avm_ml_to"/>
|
||||
</composite-id>
|
||||
</class>
|
||||
<!-- When a snapshot is created we stow away all of the layered
|
||||
nodes that were frozen by the snapshot so that subsequent
|
||||
snapshots can find them and force copies. -->
|
||||
<class name="VersionLayeredNodeEntryImpl" proxy="VersionLayeredNodeEntry"
|
||||
table="avm_version_layered_node_entry">
|
||||
<composite-id>
|
||||
<key-many-to-one name="version" class="VersionRootImpl" column="version_root_id" foreign-key="fk_avm_vlne_vr"/>
|
||||
<key-property name="md5Sum" type="string" length="32" column="md5sum"/>
|
||||
</composite-id>
|
||||
<property name="path" type="string" length="512" column="path"/>
|
||||
</class>
|
||||
|
||||
<!-- DEPRECATED START -->
|
||||
<!-- These are kept so that the AVMPropertiesPatch and AVMAspectsPatch -->
|
||||
<class name="AVMNodePropertyImpl" proxy="AVMNodeProperty" table="avm_node_properties">
|
||||
<id name="id" column="id" type="long">
|
||||
<generator class="native"/>
|
||||
@@ -192,27 +233,9 @@
|
||||
<many-to-one name="node" class="AVMNodeImpl" column="node_id" foreign-key="fk_avm_np_node"/>
|
||||
<property name="name" column="qname" type="QName" length="200" index="idx_avm_np_name"/>
|
||||
<component class="org.alfresco.repo.domain.PropertyValue" name="value">
|
||||
<property name="actualType" column="actual_type" type="string" length="15" not-null="true" />
|
||||
<property name="actualType" column="actual_type_n" type="integer" not-null="true" />
|
||||
<property name="persistedType" column="persisted_type_n" type="integer" not-null="true" />
|
||||
<property name="multiValued" column="multi_valued" type="boolean" not-null="true" />
|
||||
<property name="persistedType" column="persisted_type" type="string" length="15" not-null="true" />
|
||||
<property name="booleanValue" column="boolean_value" type="boolean" />
|
||||
<property name="longValue" column="long_value" type="long" />
|
||||
<property name="floatValue" column="float_value" type="float" />
|
||||
<property name="doubleValue" column="double_value" type="double" />
|
||||
<property name="stringValue" column="string_value" type="string" length="1024"/>
|
||||
<property name="serializableValue" column="serializable_value" type="serializable" length="16384"/>
|
||||
</component>
|
||||
</class>
|
||||
<class name="AVMStorePropertyImpl" proxy="AVMStoreProperty" table="avm_store_properties">
|
||||
<id name="id" column="id" type="long">
|
||||
<generator class="native"/>
|
||||
</id>
|
||||
<many-to-one name="store" class="AVMStoreImpl" column="avm_store_id" foreign-key="fk_avm_sp_store"/>
|
||||
<property name="name" column="qname" type="QName" length="200" index="idx_avm_sp_name"/>
|
||||
<component class="org.alfresco.repo.domain.PropertyValue" name="value">
|
||||
<property name="actualType" column="actual_type" type="string" length="15" not-null="true" />
|
||||
<property name="multiValued" column="multi_valued" type="boolean" not-null="true" />
|
||||
<property name="persistedType" column="persisted_type" type="string" length="15" not-null="true" />
|
||||
<property name="booleanValue" column="boolean_value" type="boolean" />
|
||||
<property name="longValue" column="long_value" type="long" />
|
||||
<property name="floatValue" column="float_value" type="float" />
|
||||
@@ -229,17 +252,8 @@
|
||||
<many-to-one name="node" class="AVMNodeImpl" column="node_id" foreign-key="fk_avm_asp_node"/>
|
||||
<property name="name" column="qname" type="QName" length="200"/>
|
||||
</class>
|
||||
<!-- When a snapshot is created we stow away all of the layered
|
||||
nodes that were frozen by the snapshot so that subsequent
|
||||
snapshots can find them and force copies. -->
|
||||
<class name="VersionLayeredNodeEntryImpl" proxy="VersionLayeredNodeEntry"
|
||||
table="avm_version_layered_node_entry">
|
||||
<composite-id>
|
||||
<key-many-to-one name="version" class="VersionRootImpl" column="version_root_id"/>
|
||||
<key-property name="md5Sum" type="string" length="32" column="md5sum"/>
|
||||
</composite-id>
|
||||
<property name="path" type="string" length="512" column="path"/>
|
||||
</class>
|
||||
<!-- DEPRECATED END -->
|
||||
|
||||
<class name="IssuerIDImpl" proxy="IssuerID" table="avm_issuer_ids" optimistic-lock="version" lazy="false">
|
||||
<id name="issuer" type="string" length="32" column="issuer"/>
|
||||
<version name="version" column="version" type="long"/>
|
||||
|
@@ -28,6 +28,8 @@ import java.util.List;
|
||||
import org.alfresco.repo.avm.AVMStore;
|
||||
import org.alfresco.repo.avm.AVMStoreProperty;
|
||||
import org.alfresco.repo.avm.AVMStorePropertyDAO;
|
||||
import org.alfresco.repo.domain.QNameDAO;
|
||||
import org.alfresco.repo.domain.QNameEntity;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.hibernate.Query;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
@@ -38,6 +40,16 @@ import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
*/
|
||||
class AVMStorePropertyDAOHibernate extends HibernateDaoSupport implements AVMStorePropertyDAO
|
||||
{
|
||||
private QNameDAO qnameDAO;
|
||||
|
||||
/**
|
||||
* Set the DAO for accessing QName entities
|
||||
*/
|
||||
public void setQnameDAO(QNameDAO qnameDAO)
|
||||
{
|
||||
this.qnameDAO = qnameDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist a property.
|
||||
* @param prop The AVMStoreProperty to persist.
|
||||
@@ -55,11 +67,25 @@ class AVMStorePropertyDAOHibernate extends HibernateDaoSupport implements AVMSto
|
||||
*/
|
||||
public AVMStoreProperty get(AVMStore store, QName name)
|
||||
{
|
||||
Query query =
|
||||
getSession().createQuery("from AVMStorePropertyImpl asp where asp.store = :store and asp.name = :name");
|
||||
query.setEntity("store", store);
|
||||
query.setParameter("name", name);
|
||||
return (AVMStoreProperty)query.uniqueResult();
|
||||
QNameEntity qnameEntity = qnameDAO.getQNameEntity(name);
|
||||
if (qnameEntity == null)
|
||||
{
|
||||
// No such QName
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Query query =
|
||||
getSession().createQuery(
|
||||
"select asp " +
|
||||
"from AVMStorePropertyImpl asp " +
|
||||
"where " +
|
||||
"asp.store = :store and " +
|
||||
"asp.name = :name");
|
||||
query.setEntity("store", store);
|
||||
query.setParameter("name", qnameEntity);
|
||||
return (AVMStoreProperty)query.uniqueResult();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,12 +111,30 @@ class AVMStorePropertyDAOHibernate extends HibernateDaoSupport implements AVMSto
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<AVMStoreProperty> queryByKeyPattern(AVMStore store, QName keyPattern)
|
||||
{
|
||||
// Get the URI and LocalName parts
|
||||
String uri = keyPattern.getNamespaceURI();
|
||||
if (uri == null || uri.length() == 0)
|
||||
{
|
||||
uri = "%";
|
||||
}
|
||||
String localName = keyPattern.getLocalName();
|
||||
if (localName == null || localName.length() == 0)
|
||||
{
|
||||
localName = "%";
|
||||
}
|
||||
Query query =
|
||||
getSession().createQuery(
|
||||
"select asp " +
|
||||
"from AVMStorePropertyImpl asp " +
|
||||
"where asp.store = :store and asp.name like :name");
|
||||
"join asp.name name " +
|
||||
"join name.namespace namespace " +
|
||||
"where " +
|
||||
"asp.store = :store and " +
|
||||
"namespace.uri like :uri and " +
|
||||
"name.localName like :localName");
|
||||
query.setEntity("store", store);
|
||||
query.setParameter("name", keyPattern);
|
||||
query.setParameter("uri", uri);
|
||||
query.setParameter("localName", localName);
|
||||
return (List<AVMStoreProperty>)query.list();
|
||||
}
|
||||
|
||||
@@ -102,11 +146,28 @@ class AVMStorePropertyDAOHibernate extends HibernateDaoSupport implements AVMSto
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<AVMStoreProperty> queryByKeyPattern(QName keyPattern)
|
||||
{
|
||||
// Get the URI and LocalName parts
|
||||
String uri = keyPattern.getNamespaceURI();
|
||||
if (uri == null || uri.length() == 0)
|
||||
{
|
||||
uri = "%";
|
||||
}
|
||||
String localName = keyPattern.getLocalName();
|
||||
if (localName == null || localName.length() == 0)
|
||||
{
|
||||
localName = "%";
|
||||
}
|
||||
Query query =
|
||||
getSession().createQuery(
|
||||
"from AVMStorePropertyImpl asp " +
|
||||
"where asp.name like :name");
|
||||
query.setParameter("name", keyPattern);
|
||||
"select asp " +
|
||||
"from AVMStorePropertyImpl asp " +
|
||||
"join asp.name name " +
|
||||
"join name.namespace namespace " +
|
||||
"where " +
|
||||
"namespace.uri like :uri and " +
|
||||
"name.localName like :localName");
|
||||
query.setParameter("uri", uri);
|
||||
query.setParameter("localName", localName);
|
||||
return (List<AVMStoreProperty>)query.list();
|
||||
}
|
||||
|
||||
@@ -126,12 +187,16 @@ class AVMStorePropertyDAOHibernate extends HibernateDaoSupport implements AVMSto
|
||||
*/
|
||||
public void delete(AVMStore store, QName name)
|
||||
{
|
||||
Query delete =
|
||||
getSession().createQuery("delete from AVMStorePropertyImpl asp " +
|
||||
"where asp.store = :store and asp.name = :name");
|
||||
delete.setEntity("store", store);
|
||||
delete.setParameter("name", name);
|
||||
delete.executeUpdate();
|
||||
QNameEntity qnameEntity = qnameDAO.getQNameEntity(name);
|
||||
if (qnameEntity != null)
|
||||
{
|
||||
Query delete =
|
||||
getSession().createQuery("delete from AVMStorePropertyImpl asp " +
|
||||
"where asp.store = :store and asp.name = :name");
|
||||
delete.setEntity("store", store);
|
||||
delete.setParameter("name", qnameEntity);
|
||||
delete.executeUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user