mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
This checks in the current state of WCM development.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3128 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -14,256 +14,137 @@
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import org.alfresco.repo.avm.hibernate.AVMNodeBean;
|
||||
import org.alfresco.repo.avm.hibernate.DirectoryNodeBean;
|
||||
|
||||
/**
|
||||
* Base class for all repository file system like objects.
|
||||
* The Interface for versionable objects.
|
||||
* @author britt
|
||||
*/
|
||||
public abstract class AVMNode
|
||||
interface AVMNode
|
||||
{
|
||||
/**
|
||||
* The AVMNodeBean that contains our data.
|
||||
*/
|
||||
private AVMNodeBean fData;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
protected AVMNode()
|
||||
{
|
||||
fData = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ancestor of this node.
|
||||
* @param ancestor The ancestor to set.
|
||||
*/
|
||||
public void setAncestor(AVMNode ancestor)
|
||||
{
|
||||
fData.setAncestor(ancestor.getDataBean());
|
||||
}
|
||||
public void setAncestor(AVMNode ancestor);
|
||||
|
||||
/**
|
||||
* Get the ancestor of this node.
|
||||
* @return The ancestor of this node.
|
||||
*/
|
||||
public AVMNode getAncestor()
|
||||
{
|
||||
return AVMNodeFactory.CreateFromBean(fData.getAncestor());
|
||||
}
|
||||
|
||||
public AVMNode getAncestor();
|
||||
|
||||
/**
|
||||
* Set the merged from node.
|
||||
* @param mergedFrom The merged from node.
|
||||
*/
|
||||
public void setMergedFrom(AVMNode mergedFrom)
|
||||
{
|
||||
fData.setMergedFrom(mergedFrom.getDataBean());
|
||||
}
|
||||
|
||||
public void setMergedFrom(AVMNode mergedFrom);
|
||||
|
||||
/**
|
||||
* Get the node this was merged from.
|
||||
* @return The node this was merged from.
|
||||
*/
|
||||
public AVMNode getMergedFrom()
|
||||
{
|
||||
return AVMNodeFactory.CreateFromBean(fData.getMergedFrom());
|
||||
}
|
||||
|
||||
/**
|
||||
* Should this be copied on modification.
|
||||
*/
|
||||
public boolean shouldBeCopied()
|
||||
{
|
||||
return !fData.getIsNew();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to need copying or not.
|
||||
* @param copyable Whether this should be copied.
|
||||
*/
|
||||
public void setShouldBeCopied(boolean copyable)
|
||||
{
|
||||
fData.setIsNew(!copyable);
|
||||
}
|
||||
|
||||
public AVMNode getMergedFrom();
|
||||
|
||||
/**
|
||||
* Get the version number.
|
||||
* @return The version number.
|
||||
*/
|
||||
public long getVersion()
|
||||
{
|
||||
return fData.getVersionID();
|
||||
}
|
||||
|
||||
public int getVersionID();
|
||||
|
||||
/**
|
||||
* Set the version number.
|
||||
* @param version The version number to set.
|
||||
*/
|
||||
public void setVersion(int version)
|
||||
{
|
||||
fData.setVersionID(version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the branch id of this node.
|
||||
* @return The branch id.
|
||||
*/
|
||||
public long getBranchID()
|
||||
{
|
||||
return fData.getBranchID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the branch id on this node.
|
||||
* @param branchID The id to set.
|
||||
*/
|
||||
public void setBranchID(long branchID)
|
||||
{
|
||||
fData.setBranchID(branchID);
|
||||
}
|
||||
|
||||
public void setVersionID(int version);
|
||||
|
||||
/**
|
||||
* Get the (possibly null) parent.
|
||||
* @return The parent or null.
|
||||
*/
|
||||
public DirectoryNode getParent()
|
||||
{
|
||||
return (DirectoryNode)AVMNodeFactory.CreateFromBean(fData.getParent());
|
||||
}
|
||||
public DirectoryNode getParent();
|
||||
|
||||
/**
|
||||
* Set the parent of this node.
|
||||
* @param parent The DirectoryNode to set.
|
||||
*/
|
||||
public void setParent(DirectoryNode parent)
|
||||
{
|
||||
fData.setParent((DirectoryNodeBean)parent.getDataBean());
|
||||
}
|
||||
|
||||
public void setParent(DirectoryNode parent);
|
||||
|
||||
/**
|
||||
* Perform a COW if required.
|
||||
* @param lPath The lookup path.
|
||||
* @return A 'copied' version of this node.
|
||||
*/
|
||||
public AVMNode copyOnWrite(Lookup lPath)
|
||||
{
|
||||
// Call the subclass's copy on write logic.
|
||||
AVMNode newMe = possiblyCopy(lPath);
|
||||
// No copying needed, so short circuit.
|
||||
if (newMe == null)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
String myName = lPath.getName();
|
||||
lPath.upCurrentNode();
|
||||
Repository repos = lPath.getRepository();
|
||||
newMe.setVersion(repos.getLatestVersion() + 1);
|
||||
// Get our parent directory if we have one.
|
||||
DirectoryNode parent = null;
|
||||
if (getParent() != null)
|
||||
{
|
||||
parent = (DirectoryNode)lPath.getCurrentNode();
|
||||
}
|
||||
if (parent != null)
|
||||
{
|
||||
// Recursive invocation.
|
||||
DirectoryNode newParent =
|
||||
(DirectoryNode)parent.copyOnWrite(lPath);
|
||||
newParent.putChild(myName, newMe);
|
||||
newMe.setParent(newParent);
|
||||
}
|
||||
else // Null parent means root of repository.
|
||||
{
|
||||
repos.setNewRoot((DirectoryNode)newMe);
|
||||
}
|
||||
newMe.setRepository(repos);
|
||||
newMe.setShouldBeCopied(false);
|
||||
repos.setNew(newMe);
|
||||
return newMe;
|
||||
}
|
||||
public AVMNode copyOnWrite(Lookup lPath);
|
||||
|
||||
/**
|
||||
* Possibly copy ourselves.
|
||||
* @param lPath The Lookup for this node.
|
||||
* @return A copy of ourself or null if no copy was necessary.
|
||||
*/
|
||||
public abstract AVMNode possiblyCopy(Lookup lPath);
|
||||
|
||||
/**
|
||||
* Handle any after recursive copy processing.
|
||||
*
|
||||
* @param parent The DirectoryNode that is the parent of
|
||||
* this copied node, after recursive copying.
|
||||
*/
|
||||
public abstract void handlePostCopy(DirectoryNode parent);
|
||||
|
||||
public AVMNode possiblyCopy(Lookup lPath);
|
||||
|
||||
/**
|
||||
* Set the repository for a node.
|
||||
* @param repo The Repository to set.
|
||||
*/
|
||||
public void setRepository(Repository repo)
|
||||
{
|
||||
fData.setRepository(repo.getDataBean());
|
||||
}
|
||||
public void setRepository(Repository repo);
|
||||
|
||||
/**
|
||||
* Get the data bean in this node.
|
||||
* @return The data bean.
|
||||
*/
|
||||
public AVMNodeBean getDataBean()
|
||||
{
|
||||
return fData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the data bean in this node.
|
||||
* @param bean The data bean to set.
|
||||
*/
|
||||
public void setDataBean(AVMNodeBean bean)
|
||||
{
|
||||
fData = bean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of this node.
|
||||
*/
|
||||
public abstract int getType();
|
||||
public int getType();
|
||||
|
||||
/**
|
||||
* Get the descriptor for this node.
|
||||
* @param The Lookup.
|
||||
* @return The descriptor for this node.
|
||||
*/
|
||||
public AVMNodeDescriptor getDescriptor(Lookup lPath);
|
||||
|
||||
/**
|
||||
* Get a debugging string representation.
|
||||
* Get a node descriptor for this node.
|
||||
* @param parentPath The parent path.
|
||||
* @param name The name looked up as.
|
||||
* @param parentIndirection The indirection of the parent.
|
||||
* @return The descriptor for this node.
|
||||
*/
|
||||
public AVMNodeDescriptor getDescriptor(String parentPath, String name, String parentIndirection);
|
||||
|
||||
/**
|
||||
* Get the object id.
|
||||
* @return The object id.
|
||||
*/
|
||||
public long getId();
|
||||
|
||||
/**
|
||||
* Set this node's newness.
|
||||
* @param isNew The newness.
|
||||
*/
|
||||
public void setIsNew(boolean isNew);
|
||||
|
||||
/**
|
||||
* Get the newnews.
|
||||
* @return Whether the node is new.
|
||||
*/
|
||||
public boolean getIsNew();
|
||||
|
||||
/**
|
||||
* Get a string representation for debugging.
|
||||
* @param lPath The Lookup.
|
||||
* @return A String representation.
|
||||
*/
|
||||
public abstract String toString(Lookup lPath);
|
||||
public String toString(Lookup lPath);
|
||||
|
||||
/**
|
||||
* Set whether this node to be a root of a Repository.
|
||||
* @param isRoot
|
||||
*/
|
||||
public void setIsRoot(boolean isRoot);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
/**
|
||||
* Get whether this node is a root of a Repository.
|
||||
* @return Whether this node is a root.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof AVMNode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return getDataBean().equals(((AVMNode)obj).getDataBean());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return getDataBean().hashCode();
|
||||
}
|
||||
}
|
||||
public boolean getIsRoot();
|
||||
}
|
Reference in New Issue
Block a user