mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +00:00
Another checkpoint, mostly to stay caught up with merges.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@2883 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
4b881e72ad
commit
f19fa92b31
@ -45,7 +45,7 @@ public class FolderEntry
|
|||||||
/**
|
/**
|
||||||
* @param name the name to set
|
* @param name the name to set
|
||||||
*/
|
*/
|
||||||
public void getName(String name)
|
public void setName(String name)
|
||||||
{
|
{
|
||||||
fName = name;
|
fName = name;
|
||||||
}
|
}
|
||||||
|
@ -365,6 +365,15 @@ public class LayeredDirectoryNode extends DirectoryNode
|
|||||||
fData.getAdded().remove(name);
|
fData.getAdded().remove(name);
|
||||||
fData.getDeleted().add(name);
|
fData.getDeleted().add(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Needed for the slide operation.
|
||||||
|
* @param name The name of the child to remove.
|
||||||
|
*/
|
||||||
|
public void rawRemoveChildNoGhost(String name)
|
||||||
|
{
|
||||||
|
fData.getAdded().remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.avm.DirectoryNode#removeChild(java.lang.String, org.alfresco.repo.avm.Lookup)
|
* @see org.alfresco.repo.avm.DirectoryNode#removeChild(java.lang.String, org.alfresco.repo.avm.Lookup)
|
||||||
|
@ -19,6 +19,7 @@ package org.alfresco.repo.avm;
|
|||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.avm.hibernate.LayeredFileNodeBean;
|
import org.alfresco.repo.avm.hibernate.LayeredFileNodeBean;
|
||||||
|
import org.alfresco.repo.avm.hibernate.LayeredFileNodeBeanImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A LayeredFileNode behaves like a copy on write symlink.
|
* A LayeredFileNode behaves like a copy on write symlink.
|
||||||
@ -57,7 +58,25 @@ public class LayeredFileNode extends FileNode
|
|||||||
{
|
{
|
||||||
// TODO Something.
|
// TODO Something.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a brand new layered file node.
|
||||||
|
* @param indirection The thing we point to.
|
||||||
|
* @param repo The repository we belong to.
|
||||||
|
*/
|
||||||
|
public LayeredFileNode(String indirection, Repository repo)
|
||||||
|
{
|
||||||
|
fData = new LayeredFileNodeBeanImpl(repo.getSuperRepository().issueID(),
|
||||||
|
-1L,
|
||||||
|
-1L,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
repo.getDataBean(),
|
||||||
|
indirection);
|
||||||
|
repo.getSuperRepository().getSession().save(fData);
|
||||||
|
setDataBean(fData);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the repository after a copy.
|
* Set the repository after a copy.
|
||||||
|
@ -179,6 +179,12 @@ public interface SuperRepository
|
|||||||
*/
|
*/
|
||||||
public long issueContentID();
|
public long issueContentID();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Issue an ID for the next layer.
|
||||||
|
* @return The layer id.
|
||||||
|
*/
|
||||||
|
public long issueLayerID();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current Hibernate Session.
|
* Get the current Hibernate Session.
|
||||||
* @return The Hibernate Session object.
|
* @return The Hibernate Session object.
|
||||||
|
@ -19,19 +19,26 @@ package org.alfresco.repo.avm.impl;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.avm.AVMNode;
|
import org.alfresco.repo.avm.AVMNode;
|
||||||
import org.alfresco.repo.avm.DirectoryNode;
|
import org.alfresco.repo.avm.DirectoryNode;
|
||||||
|
import org.alfresco.repo.avm.FileContent;
|
||||||
|
import org.alfresco.repo.avm.FileNode;
|
||||||
import org.alfresco.repo.avm.FolderEntry;
|
import org.alfresco.repo.avm.FolderEntry;
|
||||||
import org.alfresco.repo.avm.LayeredDirectoryNode;
|
import org.alfresco.repo.avm.LayeredDirectoryNode;
|
||||||
|
import org.alfresco.repo.avm.LayeredFileNode;
|
||||||
import org.alfresco.repo.avm.Lookup;
|
import org.alfresco.repo.avm.Lookup;
|
||||||
import org.alfresco.repo.avm.PlainDirectoryNode;
|
import org.alfresco.repo.avm.PlainDirectoryNode;
|
||||||
|
import org.alfresco.repo.avm.PlainFileNode;
|
||||||
import org.alfresco.repo.avm.Repository;
|
import org.alfresco.repo.avm.Repository;
|
||||||
import org.alfresco.repo.avm.SuperRepository;
|
import org.alfresco.repo.avm.SuperRepository;
|
||||||
import org.alfresco.repo.avm.hibernate.AVMNodeBean;
|
import org.alfresco.repo.avm.hibernate.AVMNodeBean;
|
||||||
|
import org.alfresco.repo.avm.hibernate.DirectoryEntry;
|
||||||
import org.alfresco.repo.avm.hibernate.DirectoryNodeBean;
|
import org.alfresco.repo.avm.hibernate.DirectoryNodeBean;
|
||||||
import org.alfresco.repo.avm.hibernate.PlainDirectoryNodeBean;
|
import org.alfresco.repo.avm.hibernate.PlainDirectoryNodeBean;
|
||||||
import org.alfresco.repo.avm.hibernate.PlainDirectoryNodeBeanImpl;
|
import org.alfresco.repo.avm.hibernate.PlainDirectoryNodeBeanImpl;
|
||||||
@ -156,7 +163,7 @@ public class RepositoryImpl implements Repository
|
|||||||
newDir = new PlainDirectoryNode(this);
|
newDir = new PlainDirectoryNode(this);
|
||||||
}
|
}
|
||||||
// TODO Untangle when you are going to set a new version id.
|
// TODO Untangle when you are going to set a new version id.
|
||||||
newDir.setVersion(fData.getNextVersionID());
|
newDir.setVersion(getLatestVersion() + 1);
|
||||||
this.setNew(newDir);
|
this.setNew(newDir);
|
||||||
dir.addChild(name, newDir, lPath);
|
dir.addChild(name, newDir, lPath);
|
||||||
}
|
}
|
||||||
@ -167,8 +174,26 @@ public class RepositoryImpl implements Repository
|
|||||||
public void createLayeredDirectory(String srcPath, String dstPath,
|
public void createLayeredDirectory(String srcPath, String dstPath,
|
||||||
String name)
|
String name)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
Lookup lPath = lookupDirectory(-1, dstPath);
|
||||||
|
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
|
||||||
|
if (dir.lookupChild(lPath, name, -1) != null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Child exists: " + name);
|
||||||
|
}
|
||||||
|
LayeredDirectoryNode newDir =
|
||||||
|
new LayeredDirectoryNode(srcPath, this);
|
||||||
|
if (lPath.isLayered())
|
||||||
|
{
|
||||||
|
LayeredDirectoryNode top = lPath.getTopLayer();
|
||||||
|
newDir.setLayerID(top.getLayerID());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newDir.setLayerID(fSuper.issueLayerID());
|
||||||
|
}
|
||||||
|
dir.addChild(name, newDir, lPath);
|
||||||
|
newDir.setVersion(getLatestVersion() + 1);
|
||||||
|
setNew(newDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@ -176,8 +201,16 @@ public class RepositoryImpl implements Repository
|
|||||||
*/
|
*/
|
||||||
public void createFile(String path, String name)
|
public void createFile(String path, String name)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
Lookup lPath = lookupDirectory(-1, path);
|
||||||
|
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
|
||||||
|
if (dir.lookupChild(lPath, name, -1) != null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Child exists: " + name);
|
||||||
|
}
|
||||||
|
PlainFileNode file = new PlainFileNode(this);
|
||||||
|
file.setVersion(getLatestVersion() + 1);
|
||||||
|
setNew(file);
|
||||||
|
dir.addChild(name, file, lPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@ -185,8 +218,17 @@ public class RepositoryImpl implements Repository
|
|||||||
*/
|
*/
|
||||||
public void createLayeredFile(String srcPath, String dstPath, String name)
|
public void createLayeredFile(String srcPath, String dstPath, String name)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
Lookup lPath = lookupDirectory(-1, dstPath);
|
||||||
|
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
|
||||||
|
if (dir.lookupChild(lPath, name, -1) != null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Child exists: " + name);
|
||||||
|
}
|
||||||
|
LayeredFileNode newFile =
|
||||||
|
new LayeredFileNode(srcPath, this);
|
||||||
|
dir.addChild(dstPath, newFile, lPath);
|
||||||
|
newFile.setVersion(getLatestVersion() + 1);
|
||||||
|
setNew(newFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@ -194,8 +236,15 @@ public class RepositoryImpl implements Repository
|
|||||||
*/
|
*/
|
||||||
public InputStream getInputStream(int version, String path)
|
public InputStream getInputStream(int version, String path)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
Lookup lPath = lookup(version, path);
|
||||||
return null;
|
AVMNode node = lPath.getCurrentNode();
|
||||||
|
if (!(node instanceof FileNode))
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Not a file: " + path + " r " + version);
|
||||||
|
}
|
||||||
|
FileNode file = (FileNode)node;
|
||||||
|
FileContent content = file.getContentForRead(version);
|
||||||
|
return content.getInputStream(fSuper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@ -203,8 +252,18 @@ public class RepositoryImpl implements Repository
|
|||||||
*/
|
*/
|
||||||
public List<FolderEntry> getListing(int version, String path)
|
public List<FolderEntry> getListing(int version, String path)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
Lookup lPath = lookupDirectory(version, path);
|
||||||
return null;
|
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
|
||||||
|
Map<String, DirectoryEntry> listing = dir.getListing(lPath, version);
|
||||||
|
ArrayList<FolderEntry> results = new ArrayList<FolderEntry>();
|
||||||
|
for (String name : listing.keySet())
|
||||||
|
{
|
||||||
|
FolderEntry item = new FolderEntry();
|
||||||
|
item.setName(name);
|
||||||
|
item.setType(listing.get(name).getEntryType());
|
||||||
|
results.add(item);
|
||||||
|
}
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@ -212,8 +271,15 @@ public class RepositoryImpl implements Repository
|
|||||||
*/
|
*/
|
||||||
public OutputStream getOutputStream(String path)
|
public OutputStream getOutputStream(String path)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
Lookup lPath = lookup(-1, path);
|
||||||
return null;
|
AVMNode node = lPath.getCurrentNode();
|
||||||
|
if (!(node instanceof FileNode))
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Not a file: " + path);
|
||||||
|
}
|
||||||
|
FileNode file = (FileNode)node;
|
||||||
|
FileContent content = file.getContentForWrite(this);
|
||||||
|
return content.getOutputStream(fSuper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@ -221,8 +287,13 @@ public class RepositoryImpl implements Repository
|
|||||||
*/
|
*/
|
||||||
public void removeNode(String path, String name)
|
public void removeNode(String path, String name)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
Lookup lPath = lookupDirectory(-1, path);
|
||||||
|
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
|
||||||
|
if (dir.lookupChild(lPath, name, -1) == null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Does not exist: " + name);
|
||||||
|
}
|
||||||
|
dir.removeChild(name, lPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@ -231,8 +302,51 @@ public class RepositoryImpl implements Repository
|
|||||||
public void slide(String srcPath, String srcName, String dstPath,
|
public void slide(String srcPath, String srcName, String dstPath,
|
||||||
String dstName)
|
String dstName)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
Lookup sPath = lookup(-1, srcPath);
|
||||||
|
if (!sPath.isLayered())
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Slide not allowed from non-layered directory.");
|
||||||
|
}
|
||||||
|
AVMNode node = sPath.getCurrentNode();
|
||||||
|
if (!(node instanceof LayeredDirectoryNode))
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Not a layered directory: " + srcPath);
|
||||||
|
}
|
||||||
|
LayeredDirectoryNode srcDir = (LayeredDirectoryNode)node;
|
||||||
|
AVMNode srcNode = srcDir.lookupChild(sPath, srcName, -1);
|
||||||
|
if (srcNode == null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Not found: " + srcName);
|
||||||
|
}
|
||||||
|
if (!(srcNode instanceof LayeredDirectoryNode))
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Not a layered directory:" + srcName);
|
||||||
|
}
|
||||||
|
if (!sPath.isInThisLayer() || !srcDir.directlyContains(srcNode))
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Not in this layer: " + srcName);
|
||||||
|
}
|
||||||
|
Lookup dPath = lookupDirectory(-1, dstPath);
|
||||||
|
if (!dPath.isLayered() || dPath.getTopLayer() != sPath.getTopLayer())
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Destination must be in same layer: " + dstPath);
|
||||||
|
}
|
||||||
|
DirectoryNode dstDir = (DirectoryNode)dPath.getCurrentNode();
|
||||||
|
if (dstDir.lookupChild(dPath, dstName, -1) != null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Destination exists: " + dstName);
|
||||||
|
}
|
||||||
|
// Remove child from src without leaving a ghost.
|
||||||
|
LayeredDirectoryNode srcDirCopy =
|
||||||
|
(LayeredDirectoryNode)srcDir.copyOnWrite(sPath);
|
||||||
|
srcDirCopy.rawRemoveChildNoGhost(srcName);
|
||||||
|
// Make a new version of source directly to be slid.
|
||||||
|
LayeredDirectoryNode dstNode =
|
||||||
|
new LayeredDirectoryNode((LayeredDirectoryNode)srcNode, this);
|
||||||
|
// Relookup the destination.
|
||||||
|
dPath = lookup(-1, dstPath);
|
||||||
|
dstDir = (DirectoryNode)dPath.getCurrentNode();
|
||||||
|
dstDir.addChild(dstName, dstNode, dPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -396,6 +396,14 @@ public class SuperRepositoryImpl implements SuperRepository
|
|||||||
return fContentIssuer.issue();
|
return fContentIssuer.issue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.avm.SuperRepository#issueLayerID()
|
||||||
|
*/
|
||||||
|
public long issueLayerID()
|
||||||
|
{
|
||||||
|
return fLayerIssuer.issue();
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.avm.SuperRepository#getSession()
|
* @see org.alfresco.repo.avm.SuperRepository#getSession()
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user