Yannick Pignot (European Commission) multilingual services

- EditionService for versioning of groups of translations
 - Quite a bit of trimming of whitespace that I have no intention of undoing.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5927 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-06-13 01:13:25 +00:00
parent f4c758dfe5
commit 9e836f04f8
23 changed files with 1835 additions and 1067 deletions

View File

@@ -15,11 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.version;
@@ -35,6 +35,7 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.version.common.VersionUtil;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.InvalidAspectException;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
@@ -57,22 +58,22 @@ import org.alfresco.service.namespace.RegexQNamePattern;
/**
* The light weight version store node service implementation.
*
*
* @author Roy Wetherall
*/
public class NodeServiceImpl implements NodeService, VersionModel
public class NodeServiceImpl implements NodeService, VersionModel
{
/**
* Error messages
*/
private final static String MSG_UNSUPPORTED =
private final static String MSG_UNSUPPORTED =
"This operation is not supported by a version store implementation of the node service.";
/**
* The name of the spoofed root association
*/
private static final QName rootAssocName = QName.createQName(VersionModel.NAMESPACE_URI, "versionedState");
/**
* The db node service, used as the version store implementation
*/
@@ -83,16 +84,16 @@ public class NodeServiceImpl implements NodeService, VersionModel
*/
@SuppressWarnings("unused")
private SearchService searcher;
/**
* The dictionary service
*/
protected DictionaryService dicitionaryService;
/**
* Sets the db node service, used as the version store implementation
*
*
* @param nodeService the node service
*/
public void setDbNodeService(NodeService nodeService)
@@ -102,24 +103,24 @@ public class NodeServiceImpl implements NodeService, VersionModel
/**
* Sets the searcher
*
*
* @param searcher the searcher
*/
public void setSearcher(SearchService searcher)
{
this.searcher = searcher;
this.searcher = searcher;
}
/**
* Sets the dictionary service
*
*
* @param dictionaryService the dictionary service
*/
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dicitionaryService = dictionaryService;
}
/**
* Delegates to the <code>NodeService</code> used as the version store implementation
*/
@@ -127,7 +128,7 @@ public class NodeServiceImpl implements NodeService, VersionModel
{
return dbNodeService.getStores();
}
/**
* Delegates to the <code>NodeService</code> used as the version store implementation
*/
@@ -149,9 +150,9 @@ public class NodeServiceImpl implements NodeService, VersionModel
*/
public boolean exists(NodeRef nodeRef)
{
return dbNodeService.exists(convertNodeRef(nodeRef));
return dbNodeService.exists(VersionUtil.convertNodeRef(nodeRef));
}
/**
* Delegates to the <code>NodeService</code> used as the version store implementation
*/
@@ -160,18 +161,6 @@ public class NodeServiceImpl implements NodeService, VersionModel
return dbNodeService.getNodeStatus(nodeRef);
}
/**
* Convert the incomming node ref (with the version store protocol specified)
* to the internal representation with the workspace protocol.
*
* @param nodeRef the incomming verison protocol node reference
* @return the internal version node reference
*/
private NodeRef convertNodeRef(NodeRef nodeRef)
{
return new NodeRef(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, STORE_ID), nodeRef.getId());
}
/**
* Delegates to the <code>NodeService</code> used as the version store implementation
*/
@@ -184,7 +173,7 @@ public class NodeServiceImpl implements NodeService, VersionModel
* @throws UnsupportedOperationException always
*/
public ChildAssociationRef createNode(
NodeRef parentRef,
NodeRef parentRef,
QName assocTypeQName,
QName assocQName,
QName nodeTypeQName) throws InvalidNodeRefException
@@ -192,12 +181,12 @@ public class NodeServiceImpl implements NodeService, VersionModel
// This operation is not supported for a version store
throw new UnsupportedOperationException(MSG_UNSUPPORTED);
}
/**
* @throws UnsupportedOperationException always
*/
public ChildAssociationRef createNode(
NodeRef parentRef,
NodeRef parentRef,
QName assocTypeQName,
QName assocQName,
QName nodeTypeQName,
@@ -206,7 +195,7 @@ public class NodeServiceImpl implements NodeService, VersionModel
// This operation is not supported for a version store
throw new UnsupportedOperationException(MSG_UNSUPPORTED);
}
/**
* @throws UnsupportedOperationException always
*/
@@ -215,7 +204,7 @@ public class NodeServiceImpl implements NodeService, VersionModel
// This operation is not supported for a version store
throw new UnsupportedOperationException(MSG_UNSUPPORTED);
}
/**
* @throws UnsupportedOperationException always
*/
@@ -227,7 +216,7 @@ public class NodeServiceImpl implements NodeService, VersionModel
// This operation is not supported for a version store
throw new UnsupportedOperationException(MSG_UNSUPPORTED);
}
/**
* @throws UnsupportedOperationException always
*/
@@ -274,9 +263,9 @@ public class NodeServiceImpl implements NodeService, VersionModel
*/
public QName getType(NodeRef nodeRef) throws InvalidNodeRefException
{
return (QName)this.dbNodeService.getProperty(convertNodeRef(nodeRef), PROP_QNAME_FROZEN_NODE_TYPE);
return (QName)this.dbNodeService.getProperty(VersionUtil.convertNodeRef(nodeRef), PROP_QNAME_FROZEN_NODE_TYPE);
}
/**
* @see org.alfresco.service.cmr.repository.NodeService#setType(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
*/
@@ -285,7 +274,7 @@ public class NodeServiceImpl implements NodeService, VersionModel
// This operation is not supported for a version store
throw new UnsupportedOperationException(MSG_UNSUPPORTED);
}
/**
* @throws UnsupportedOperationException always
*/
@@ -318,7 +307,7 @@ public class NodeServiceImpl implements NodeService, VersionModel
public Set<QName> getAspects(NodeRef nodeRef) throws InvalidNodeRefException
{
return new HashSet<QName>(
(ArrayList<QName>)this.dbNodeService.getProperty(convertNodeRef(nodeRef), PROP_QNAME_FROZEN_ASPECTS));
(ArrayList<QName>)this.dbNodeService.getProperty(VersionUtil.convertNodeRef(nodeRef), PROP_QNAME_FROZEN_ASPECTS));
}
/**
@@ -326,9 +315,9 @@ public class NodeServiceImpl implements NodeService, VersionModel
*/
public Map<QName, Serializable> getProperties(NodeRef nodeRef) throws InvalidNodeRefException
{
Map<QName, Serializable> result = new HashMap<QName, Serializable>();
Collection<ChildAssociationRef> children = this.dbNodeService.getChildAssocs(convertNodeRef(nodeRef), CHILD_QNAME_VERSIONED_ATTRIBUTES, RegexQNamePattern.MATCH_ALL);
Map<QName, Serializable> result = new HashMap<QName, Serializable>();
Collection<ChildAssociationRef> children = this.dbNodeService.getChildAssocs(VersionUtil.convertNodeRef(nodeRef), CHILD_QNAME_VERSIONED_ATTRIBUTES, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef child : children)
{
NodeRef versionedAttribute = child.getChildRef();
@@ -337,35 +326,35 @@ public class NodeServiceImpl implements NodeService, VersionModel
Serializable value = null;
QName qName = (QName)this.dbNodeService.getProperty(versionedAttribute, PROP_QNAME_QNAME);
PropertyDefinition propDef = this.dicitionaryService.getProperty(qName);
Boolean isMultiValue = (Boolean)this.dbNodeService.getProperty(versionedAttribute, PROP_QNAME_IS_MULTI_VALUE);
if (isMultiValue.booleanValue() == false)
{
value = this.dbNodeService.getProperty(versionedAttribute, PROP_QNAME_VALUE);
value = (Serializable)DefaultTypeConverter.INSTANCE.convert(propDef.getDataType(), value);
value = this.dbNodeService.getProperty(versionedAttribute, PROP_QNAME_VALUE);
value = (Serializable)DefaultTypeConverter.INSTANCE.convert(propDef.getDataType(), value);
}
else
{
value = this.dbNodeService.getProperty(versionedAttribute, PROP_QNAME_MULTI_VALUE);
}
result.put(qName, value);
}
return result;
}
return result;
}
/**
* Property translation for version store
*/
public Serializable getProperty(NodeRef nodeRef, QName qname) throws InvalidNodeRefException
{
{
// TODO should be doing this with a search ...
Map<QName, Serializable> properties = getProperties(convertNodeRef(nodeRef));
return properties.get(qname);
Map<QName, Serializable> properties = getProperties(VersionUtil.convertNodeRef(nodeRef));
return properties.get(qname);
}
/**
* @throws UnsupportedOperationException always
*/
@@ -374,7 +363,7 @@ public class NodeServiceImpl implements NodeService, VersionModel
// This operation is not supported for a version store
throw new UnsupportedOperationException(MSG_UNSUPPORTED);
}
/**
* @throws UnsupportedOperationException always
*/
@@ -383,7 +372,7 @@ public class NodeServiceImpl implements NodeService, VersionModel
// This operation is not supported for a version store
throw new UnsupportedOperationException(MSG_UNSUPPORTED);
}
/**
* @throws UnsupportedOperationException always
*/
@@ -395,17 +384,17 @@ public class NodeServiceImpl implements NodeService, VersionModel
/**
* The node will appear to be attached to the root of the version store
*
*
* @see NodeService#getParentAssocs(NodeRef)
*/
public List<ChildAssociationRef> getParentAssocs(NodeRef nodeRef)
{
return getParentAssocs(nodeRef, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL);
}
}
/**
* The node will apprear to be attached to the root of the version store
*
*
* @see NodeService#getParentAssocs(NodeRef, QNamePattern, QNamePattern)
*/
public List<ChildAssociationRef> getParentAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern)
@@ -428,7 +417,7 @@ public class NodeServiceImpl implements NodeService, VersionModel
*/
public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef) throws InvalidNodeRefException
{
return getChildAssocs(convertNodeRef(nodeRef), RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL);
return getChildAssocs(VersionUtil.convertNodeRef(nodeRef), RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL);
}
/**
@@ -438,46 +427,46 @@ public class NodeServiceImpl implements NodeService, VersionModel
{
// Get the child assocs from the version store
List<ChildAssociationRef> childAssocRefs = this.dbNodeService.getChildAssocs(
convertNodeRef(nodeRef),
VersionUtil.convertNodeRef(nodeRef),
RegexQNamePattern.MATCH_ALL, CHILD_QNAME_VERSIONED_CHILD_ASSOCS);
List<ChildAssociationRef> result = new ArrayList<ChildAssociationRef>(childAssocRefs.size());
for (ChildAssociationRef childAssocRef : childAssocRefs)
{
// Get the child reference
NodeRef childRef = childAssocRef.getChildRef();
NodeRef referencedNode = (NodeRef)this.dbNodeService.getProperty(childRef, ContentModel.PROP_REFERENCE);
NodeRef referencedNode = (NodeRef)this.dbNodeService.getProperty(childRef, ContentModel.PROP_REFERENCE);
if (this.dbNodeService.exists(referencedNode) == true)
{
// get the qualified name of the frozen child association and filter out unwanted names
QName qName = (QName)this.dbNodeService.getProperty(childRef, PROP_QNAME_ASSOC_QNAME);
if (qnamePattern.isMatch(qName) == true)
{
{
// Retrieve the isPrimary and nthSibling values of the forzen child association
QName assocType = (QName)this.dbNodeService.getProperty(childRef, PROP_QNAME_ASSOC_TYPE_QNAME);
boolean isPrimary = ((Boolean)this.dbNodeService.getProperty(childRef, PROP_QNAME_IS_PRIMARY)).booleanValue();
int nthSibling = ((Integer)this.dbNodeService.getProperty(childRef, PROP_QNAME_NTH_SIBLING)).intValue();
// Build a child assoc ref to add to the returned list
ChildAssociationRef newChildAssocRef = new ChildAssociationRef(
assocType,
nodeRef,
qName,
referencedNode,
isPrimary,
nodeRef,
qName,
referencedNode,
isPrimary,
nthSibling);
result.add(newChildAssocRef);
}
}
}
// sort the results so that the order appears to be exactly as it was originally
Collections.sort(result);
return result;
}
/**
* @throws UnsupportedOperationException always
*/
@@ -488,7 +477,7 @@ public class NodeServiceImpl implements NodeService, VersionModel
}
/**
* Simulates the node begin attached ot the root node of the version store.
* Simulates the node begin attached ot the root node of the version store.
*/
public ChildAssociationRef getPrimaryParent(NodeRef nodeRef) throws InvalidNodeRefException
{
@@ -498,7 +487,7 @@ public class NodeServiceImpl implements NodeService, VersionModel
rootAssocName,
nodeRef);
}
/**
* @throws UnsupportedOperationException always
*/
@@ -508,7 +497,7 @@ public class NodeServiceImpl implements NodeService, VersionModel
// This operation is not supported for a version store
throw new UnsupportedOperationException(MSG_UNSUPPORTED);
}
/**
* @throws UnsupportedOperationException always
*/
@@ -517,7 +506,7 @@ public class NodeServiceImpl implements NodeService, VersionModel
// This operation is not supported for a version store
throw new UnsupportedOperationException(MSG_UNSUPPORTED);
}
/**
* @throws UnsupportedOperationException always
*/
@@ -525,31 +514,31 @@ public class NodeServiceImpl implements NodeService, VersionModel
{
// Get the child assocs from the version store
List<ChildAssociationRef> childAssocRefs = this.dbNodeService.getChildAssocs(
convertNodeRef(sourceRef),
VersionUtil.convertNodeRef(sourceRef),
RegexQNamePattern.MATCH_ALL, CHILD_QNAME_VERSIONED_ASSOCS);
List<AssociationRef> result = new ArrayList<AssociationRef>(childAssocRefs.size());
for (ChildAssociationRef childAssocRef : childAssocRefs)
{
// Get the assoc reference
NodeRef childRef = childAssocRef.getChildRef();
NodeRef referencedNode = (NodeRef)this.dbNodeService.getProperty(childRef, ContentModel.PROP_REFERENCE);
NodeRef referencedNode = (NodeRef)this.dbNodeService.getProperty(childRef, ContentModel.PROP_REFERENCE);
if (this.dbNodeService.exists(referencedNode) == true)
{
// get the qualified type name of the frozen child association and filter out unwanted names
QName qName = (QName)this.dbNodeService.getProperty(childRef, PROP_QNAME_ASSOC_TYPE_QNAME);
if (qnamePattern.isMatch(qName) == true)
{
{
AssociationRef newAssocRef = new AssociationRef(sourceRef, qName, referencedNode);
result.add(newAssocRef);
}
}
}
return result;
}
/**
* @throws UnsupportedOperationException always
*/
@@ -558,7 +547,7 @@ public class NodeServiceImpl implements NodeService, VersionModel
// This operation is not supported for a version store
throw new UnsupportedOperationException(MSG_UNSUPPORTED);
}
/**
* @throws UnsupportedOperationException always
*/
@@ -567,9 +556,9 @@ public class NodeServiceImpl implements NodeService, VersionModel
ChildAssociationRef childAssocRef = getPrimaryParent(nodeRef);
Path path = new Path();
path.append(new Path.ChildAssocElement(childAssocRef));
return path;
return path;
}
/**
* @throws UnsupportedOperationException always
*/

File diff suppressed because it is too large Load Diff

View File

@@ -15,11 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.version.common;
@@ -27,11 +27,13 @@ package org.alfresco.repo.version.common;
import java.util.Collection;
import org.alfresco.repo.version.VersionModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.version.ReservedVersionNameException;
/**
* Helper class containing helper methods for the versioning services.
*
*
* @author Roy Wetherall
*/
public class VersionUtil
@@ -40,20 +42,20 @@ public class VersionUtil
* Reserved property names
*/
public static final String[] RESERVED_PROPERTY_NAMES = new String[]{
VersionModel.PROP_CREATED_DATE,
VersionModel.PROP_FROZEN_NODE_ID,
VersionModel.PROP_FROZEN_NODE_STORE_ID,
VersionModel.PROP_CREATED_DATE,
VersionModel.PROP_FROZEN_NODE_ID,
VersionModel.PROP_FROZEN_NODE_STORE_ID,
VersionModel.PROP_FROZEN_NODE_STORE_PROTOCOL,
VersionModel.PROP_FROZEN_NODE_TYPE,
VersionModel.PROP_FROZEN_ASPECTS,
VersionModel.PROP_VERSION_LABEL,
VersionModel.PROP_VERSION_NUMBER};
/**
* Checks that the names of the additional version properties are valid and that they do not clash
* with the reserved properties.
*
* @param versionProperties the property names
*
* @param versionProperties the property names
* @return true is the names are considered valid, false otherwise
* @throws ReservedVersionNameException
*/
@@ -68,4 +70,16 @@ public class VersionUtil
}
}
}
/**
* Convert the incomming node ref (with the version store protocol specified)
* to the internal representation with the workspace protocol.
*
* @param nodeRef the incomming verison protocol node reference
* @return the internal version node reference
*/
public static NodeRef convertNodeRef(NodeRef nodeRef)
{
return new NodeRef(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, VersionModel.STORE_ID), nodeRef.getId());
}
}