Content and folder node archival

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2767 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-05-04 16:04:55 +00:00
parent 35f3eda32f
commit fcad8b7a1f
29 changed files with 722 additions and 198 deletions

View File

@@ -58,6 +58,11 @@ public interface ClassDefinition
* @return true => aspect, false => type
*/
public boolean isAspect();
/**
* @return Return true if the type should be archived on delete
*/
public boolean isArchive();
/**
* @return the properties of the class, including inherited properties

View File

@@ -45,6 +45,8 @@ public interface DataTypeDefinition
public QName QNAME = QName.createQName(NamespaceService.DICTIONARY_MODEL_1_0_URI, "qname");
public QName CATEGORY = QName.createQName(NamespaceService.DICTIONARY_MODEL_1_0_URI, "category");
public QName NODE_REF = QName.createQName(NamespaceService.DICTIONARY_MODEL_1_0_URI, "noderef");
public QName CHILD_ASSOC_REF = QName.createQName(NamespaceService.DICTIONARY_MODEL_1_0_URI, "childassocref");
public QName ASSOC_REF = QName.createQName(NamespaceService.DICTIONARY_MODEL_1_0_URI, "assocref");
public QName PATH = QName.createQName(NamespaceService.DICTIONARY_MODEL_1_0_URI, "path");

View File

@@ -17,7 +17,9 @@
package org.alfresco.service.cmr.repository;
import java.io.Serializable;
import java.util.StringTokenizer;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.EqualsHelper;
@@ -29,6 +31,8 @@ import org.alfresco.util.EqualsHelper;
public class AssociationRef implements EntityRef, Serializable
{
private static final long serialVersionUID = 3977867284482439475L;
private static final String FILLER = "|";
private NodeRef sourceRef;
private QName assocTypeQName;
@@ -65,32 +69,36 @@ public class AssociationRef implements EntityRef, Serializable
throw new IllegalArgumentException("Target reference may not be null");
}
}
/**
* Get the qualified name of the source-target association
*
* @return Returns the qualified name of the source-target association.
* @param childAssocRefStr a string of the form <b>sourceNodeRef|targetNodeRef|assocTypeQName</b>
*/
public QName getTypeQName()
public AssociationRef(String assocRefStr)
{
return assocTypeQName;
StringTokenizer tokenizer = new StringTokenizer(assocRefStr, FILLER);
if (tokenizer.countTokens() != 3)
{
throw new AlfrescoRuntimeException("Unable to parse association string: " + assocRefStr);
}
String sourceNodeRefStr = tokenizer.nextToken();
String targetNodeRefStr = tokenizer.nextToken();
String assocTypeQNameStr = tokenizer.nextToken();
this.sourceRef = new NodeRef(sourceNodeRefStr);
this.targetRef = new NodeRef(targetNodeRefStr);
this.assocTypeQName = QName.createQName(assocTypeQNameStr);
}
/**
* @return Returns the child node reference - never null
* @return Returns a string of the form <b>sourceNodeRef|targetNodeRef|assocTypeQName|assocQName</b>
*/
public NodeRef getTargetRef()
public String toString()
{
return targetRef;
}
/**
* @return Returns the parent node reference, which may be null if this
* represents the imaginary reference to the root node
*/
public NodeRef getSourceRef()
{
return sourceRef;
StringBuilder sb = new StringBuilder(180);
sb.append(sourceRef).append(FILLER)
.append(targetRef).append(FILLER)
.append(assocTypeQName);
return sb.toString();
}
/**
@@ -126,12 +134,30 @@ public class AssociationRef implements EntityRef, Serializable
return hashCode;
}
public String toString()
/**
* Get the qualified name of the source-target association
*
* @return Returns the qualified name of the source-target association.
*/
public QName getTypeQName()
{
StringBuffer buffer = new StringBuffer();
buffer.append(getSourceRef());
buffer.append(" --- ").append(getTypeQName()).append(" ---> ");
buffer.append(getTargetRef());
return buffer.toString();
return assocTypeQName;
}
/**
* @return Returns the child node reference - never null
*/
public NodeRef getTargetRef()
{
return targetRef;
}
/**
* @return Returns the parent node reference, which may be null if this
* represents the imaginary reference to the root node
*/
public NodeRef getSourceRef()
{
return sourceRef;
}
}

View File

@@ -17,7 +17,9 @@
package org.alfresco.service.cmr.repository;
import java.io.Serializable;
import java.util.StringTokenizer;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.EqualsHelper;
@@ -39,6 +41,8 @@ public class ChildAssociationRef
implements EntityRef, Comparable<ChildAssociationRef>, Serializable
{
private static final long serialVersionUID = 4051322336257127729L;
private static final String FILLER = "|";
private QName assocTypeQName;
private NodeRef parentRef;
@@ -97,7 +101,47 @@ public class ChildAssociationRef
{
this(assocTypeQName, parentRef, childQName, childRef, false, -1);
}
/**
* @param childAssocRefStr a string of the form <b>parentNodeRef|childNodeRef|assocTypeQName|assocQName|isPrimary|nthSibling</b>
*/
public ChildAssociationRef(String childAssocRefStr)
{
StringTokenizer tokenizer = new StringTokenizer(childAssocRefStr, FILLER);
if (tokenizer.countTokens() != 6)
{
throw new AlfrescoRuntimeException("Unable to parse child association string: " + childAssocRefStr);
}
String parentNodeRefStr = tokenizer.nextToken();
String childNodeRefStr = tokenizer.nextToken();
String assocTypeQNameStr = tokenizer.nextToken();
String assocQNameStr = tokenizer.nextToken();
String isPrimaryStr = tokenizer.nextToken();
String nthSiblingStr = tokenizer.nextToken();
this.parentRef = new NodeRef(parentNodeRefStr);
this.childRef = new NodeRef(childNodeRefStr);
this.assocTypeQName = QName.createQName(assocTypeQNameStr);
this.childQName = QName.createQName(assocQNameStr);
this.isPrimary = Boolean.parseBoolean(isPrimaryStr);
this.nthSibling = Integer.parseInt(nthSiblingStr);
}
/**
* @return Returns a string of the form <b>parentNodeRef|childNodeRef|assocTypeQName|assocQName|isPrimary|nthSibling</b>
*/
public String toString()
{
StringBuilder sb = new StringBuilder(250);
sb.append(parentRef).append(FILLER)
.append(childRef).append(FILLER)
.append(assocTypeQName).append(FILLER)
.append(childQName).append(FILLER)
.append(isPrimary).append(FILLER)
.append(nthSibling);
return sb.toString();
}
/**
* Compares:
* <ul>
@@ -144,16 +188,6 @@ public class ChildAssociationRef
return (thisVal < anotherVal ? -1 : (thisVal == anotherVal ? 0 : 1));
}
public String toString()
{
StringBuffer sb = new StringBuffer();
sb.append("[").append(getTypeQName()).append("]");
sb.append(getParentRef());
sb.append(" --- ").append(getQName()).append(" ---> ");
sb.append(getChildRef());
return sb.toString();
}
/**
* Get the qualified name of the association type
*

View File

@@ -30,8 +30,11 @@ import java.util.Calendar;
import java.util.Date;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.EntityRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.Path;
import org.alfresco.service.namespace.QName;
@@ -223,6 +226,24 @@ public class DefaultTypeConverter
});
INSTANCE.addConverter(String.class, ChildAssociationRef.class, new TypeConverter.Converter<String, ChildAssociationRef>()
{
public ChildAssociationRef convert(String source)
{
return new ChildAssociationRef(source);
}
});
INSTANCE.addConverter(String.class, AssociationRef.class, new TypeConverter.Converter<String, AssociationRef>()
{
public AssociationRef convert(String source)
{
return new AssociationRef(source);
}
});
INSTANCE.addConverter(String.class, InputStream.class, new TypeConverter.Converter<String, InputStream>()
{
public InputStream convert(String source)
@@ -582,19 +603,19 @@ public class DefaultTypeConverter
INSTANCE.addDynamicTwoStageConverter(QName.class, String.class, InputStream.class);
//
// NodeRef
// EntityRef (NodeRef, ChildAssociationRef, NodeAssociationRef)
//
INSTANCE.addConverter(NodeRef.class, String.class, new TypeConverter.Converter<NodeRef, String>()
INSTANCE.addConverter(EntityRef.class, String.class, new TypeConverter.Converter<EntityRef, String>()
{
public String convert(NodeRef source)
public String convert(EntityRef source)
{
return source.toString();
}
});
INSTANCE.addDynamicTwoStageConverter(NodeRef.class, String.class, InputStream.class);
INSTANCE.addDynamicTwoStageConverter(EntityRef.class, String.class, InputStream.class);
//
// ContentData
//