mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
AVM DAO - add rollover for avm_store/avm_node "vers" col
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16992 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -64,8 +64,8 @@ import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* A Repository contains a current root directory and a list of
|
||||
@@ -75,7 +75,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
*/
|
||||
public class AVMStoreImpl implements AVMStore
|
||||
{
|
||||
private static Log fgLogger = LogFactory.getLog(AVMStoreImpl.class);
|
||||
private static Log logger = LogFactory.getLog(AVMStoreImpl.class);
|
||||
/**
|
||||
* The primary key.
|
||||
*/
|
||||
@@ -198,6 +198,8 @@ public class AVMStoreImpl implements AVMStore
|
||||
*/
|
||||
public Map<String, Integer> createSnapshot(String tag, String description, Map<String, Integer> snapShotMap)
|
||||
{
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
long rootID = getRoot().getId();
|
||||
AVMStoreImpl me = (AVMStoreImpl)AVMDAOs.Instance().fAVMStoreDAO.getByID(getId());
|
||||
VersionRoot lastVersion = AVMDAOs.Instance().fVersionRootDAO.getMaxVersion(me);
|
||||
@@ -207,6 +209,11 @@ public class AVMStoreImpl implements AVMStore
|
||||
DirectoryNode root = (DirectoryNode)AVMDAOs.Instance().fAVMNodeDAO.getByID(rootID);
|
||||
if (!root.getIsNew() && layeredEntries.size() == 0)
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("createSnapshot: no snapshot required: "+me.getName()+" ["+me.getId()+"] - lastVersion = "+lastVersion.getVersionID() + "("+tag+", "+description+")");
|
||||
}
|
||||
|
||||
// So, we set the tag and description fields of the latest version.
|
||||
if (tag != null || description != null)
|
||||
{
|
||||
@@ -218,6 +225,12 @@ public class AVMStoreImpl implements AVMStore
|
||||
snapShotMap.put(getName(), lastVersion.getVersionID());
|
||||
return snapShotMap;
|
||||
}
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("createSnapshot: snapshot: "+me.getName()+" ["+me.getId()+"] - lastVersion="+lastVersion.getVersionID()+", layeredEntries="+layeredEntries.size());
|
||||
}
|
||||
|
||||
snapShotMap.put(getName(), me.getNextVersionID());
|
||||
// Force copies on all the layered nodes from last snapshot.
|
||||
for (VersionLayeredNodeEntry entry : layeredEntries)
|
||||
@@ -241,13 +254,14 @@ public class AVMStoreImpl implements AVMStore
|
||||
if (lookup.getCurrentNode().getType() == AVMNodeType.LAYERED_DIRECTORY)
|
||||
{
|
||||
fAVMRepository.forceCopy(entry.getPath());
|
||||
me = (AVMStoreImpl)AVMDAOs.Instance().fAVMStoreDAO.getByID(getId());
|
||||
}
|
||||
else if (lookup.getCurrentNode().getType() == AVMNodeType.LAYERED_FILE)
|
||||
{
|
||||
String parentName[] = AVMUtil.splitBase(entry.getPath());
|
||||
parentName[0] = parentName[0].substring(parentName[0].indexOf(':') + 1);
|
||||
|
||||
lookup = lookupDirectory(-1, parentName[0], true);
|
||||
lookup = me.lookupDirectory(-1, parentName[0], true);
|
||||
|
||||
DirectoryNode parent = (DirectoryNode)lookup.getCurrentNode();
|
||||
Pair<AVMNode, Boolean> temp = parent.lookupChild(lookup, parentName[1], false);
|
||||
@@ -337,6 +351,7 @@ public class AVMStoreImpl implements AVMStore
|
||||
{
|
||||
user = RawServices.Instance().getAuthenticationContext().getSystemUserName();
|
||||
}
|
||||
|
||||
me = (AVMStoreImpl)AVMDAOs.Instance().fAVMStoreDAO.getByID(getId());
|
||||
VersionRoot versionRoot = new VersionRootImpl(me,
|
||||
me.getRoot(),
|
||||
@@ -350,6 +365,8 @@ public class AVMStoreImpl implements AVMStore
|
||||
|
||||
AVMDAOs.Instance().fAVMStoreDAO.update(me);
|
||||
|
||||
int vlneCnt = 0;
|
||||
|
||||
AVMDAOs.Instance().fVersionRootDAO.save(versionRoot);
|
||||
for (Long nodeID : layeredNodeIDs)
|
||||
{
|
||||
@@ -361,7 +378,20 @@ public class AVMStoreImpl implements AVMStore
|
||||
new VersionLayeredNodeEntryImpl(versionRoot, path);
|
||||
AVMDAOs.Instance().fVersionLayeredNodeEntryDAO.save(entry);
|
||||
}
|
||||
|
||||
vlneCnt = vlneCnt+paths.size();
|
||||
}
|
||||
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("createSnapshot: snapshot: "+me.getName()+" ["+me.getId()+"] - created new version root ["+versionRoot.getId()+"] - layeredNodeIDs="+layeredNodeIDs.size()+", versionLayeredNodeEntries="+vlneCnt);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("createSnapshot: snapshot: "+me.getName()+" ["+me.getId()+"] in "+(System.currentTimeMillis()-start)+" msecs");
|
||||
}
|
||||
|
||||
return snapShotMap;
|
||||
}
|
||||
|
||||
@@ -589,38 +619,38 @@ public class AVMStoreImpl implements AVMStore
|
||||
{
|
||||
throw new AVMExistsException("Child exists: " + name);
|
||||
}
|
||||
// TODO Reexamine decision to not check validity of srcPath. Warning for now.
|
||||
String[] srcPathParts = srcPath.split(":");
|
||||
String[] dstPathParts = dstPath.split(":");
|
||||
|
||||
Lookup lPathSrc = null;
|
||||
if (srcPathParts[0].equals(dstPathParts[0]))
|
||||
{
|
||||
lPathSrc = lookup(-1, srcPathParts[1], false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
AVMStore srcStore = AVMDAOs.Instance().fAVMStoreDAO.getByName(srcPathParts[0]);
|
||||
if (srcStore != null)
|
||||
{
|
||||
lPathSrc = srcStore.lookup(-1, srcPathParts[1], false, false);
|
||||
}
|
||||
}
|
||||
|
||||
AVMNode srcNode = null;
|
||||
if (lPathSrc == null)
|
||||
{
|
||||
fgLogger.warn("CreateLayeredFile: srcPath not found: "+srcPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcNode = (AVMNode)lPathSrc.getCurrentNode();
|
||||
if (! (srcNode instanceof FileNode))
|
||||
{
|
||||
fgLogger.warn("CreateLayeredFile: srcPath is not a file: "+srcPath);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Reexamine decision to not check validity of srcPath. Warning for now.
|
||||
String[] srcPathParts = srcPath.split(":");
|
||||
String[] dstPathParts = dstPath.split(":");
|
||||
|
||||
Lookup lPathSrc = null;
|
||||
if (srcPathParts[0].equals(dstPathParts[0]))
|
||||
{
|
||||
lPathSrc = lookup(-1, srcPathParts[1], false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
AVMStore srcStore = AVMDAOs.Instance().fAVMStoreDAO.getByName(srcPathParts[0]);
|
||||
if (srcStore != null)
|
||||
{
|
||||
lPathSrc = srcStore.lookup(-1, srcPathParts[1], false, false);
|
||||
}
|
||||
}
|
||||
|
||||
AVMNode srcNode = null;
|
||||
if (lPathSrc == null)
|
||||
{
|
||||
logger.warn("CreateLayeredFile: srcPath not found: "+srcPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcNode = (AVMNode)lPathSrc.getCurrentNode();
|
||||
if (! (srcNode instanceof FileNode))
|
||||
{
|
||||
logger.warn("CreateLayeredFile: srcPath is not a file: "+srcPath);
|
||||
}
|
||||
}
|
||||
|
||||
LayeredFileNodeImpl newFile =
|
||||
new LayeredFileNodeImpl(srcPath, this, null);
|
||||
|
||||
@@ -633,12 +663,12 @@ public class AVMStoreImpl implements AVMStore
|
||||
{
|
||||
newFile.setAncestor(child);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((srcNode != null) && (srcNode instanceof FileNode))
|
||||
{
|
||||
newFile.setAncestor((FileNode)srcNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((srcNode != null) && (srcNode instanceof FileNode))
|
||||
{
|
||||
newFile.setAncestor((FileNode)srcNode);
|
||||
}
|
||||
}
|
||||
|
||||
// newFile.setVersionID(getNextVersionID());
|
||||
@@ -805,24 +835,24 @@ public class AVMStoreImpl implements AVMStore
|
||||
{
|
||||
throw new AVMNotFoundException("Path " + path + " not found.");
|
||||
}
|
||||
|
||||
|
||||
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
|
||||
Pair<AVMNode, Boolean> temp = dir.lookupChild(lPath, name, false);
|
||||
AVMNode child = (temp == null) ? null : temp.getFirst();
|
||||
if (child == null)
|
||||
{
|
||||
Lookup lPathToChild = lookup(-1, path+"/"+name, true, false);
|
||||
if (lPathToChild != null)
|
||||
{
|
||||
// ETHREEOH-2297
|
||||
child = lPathToChild.getCurrentNode();
|
||||
}
|
||||
if (child == null)
|
||||
{
|
||||
throw new AVMNotFoundException("Does not exist: " + name);
|
||||
}
|
||||
|
||||
dir = lPathToChild.getCurrentNodeDirectory();
|
||||
Lookup lPathToChild = lookup(-1, path+"/"+name, true, false);
|
||||
if (lPathToChild != null)
|
||||
{
|
||||
// ETHREEOH-2297
|
||||
child = lPathToChild.getCurrentNode();
|
||||
}
|
||||
if (child == null)
|
||||
{
|
||||
throw new AVMNotFoundException("Does not exist: " + name);
|
||||
}
|
||||
|
||||
dir = lPathToChild.getCurrentNodeDirectory();
|
||||
}
|
||||
|
||||
if (!fAVMRepository.can(this, child, PermissionService.DELETE_NODE, false))
|
||||
@@ -1772,14 +1802,14 @@ public class AVMStoreImpl implements AVMStore
|
||||
|
||||
Lookup cPath = new Lookup(lPath, AVMDAOs.Instance().fAVMNodeDAO, AVMDAOs.Instance().fAVMStoreDAO);
|
||||
Pair<AVMNode, Boolean> result = dir.lookupChild(cPath, name, true);
|
||||
if (result != null)
|
||||
if (result != null)
|
||||
{
|
||||
AVMNode child = result.getFirst();
|
||||
if (!fAVMRepository.can(null, child, PermissionService.WRITE, cPath.getDirectlyContained()))
|
||||
{
|
||||
throw new AccessDeniedException("Not allowed to update node: " + parentPath + "/" +name );
|
||||
}
|
||||
dir.removeChild(lPath, name);
|
||||
AVMNode child = result.getFirst();
|
||||
if (!fAVMRepository.can(null, child, PermissionService.WRITE, cPath.getDirectlyContained()))
|
||||
{
|
||||
throw new AccessDeniedException("Not allowed to update node: " + parentPath + "/" +name );
|
||||
}
|
||||
dir.removeChild(lPath, name);
|
||||
}
|
||||
dir.link(lPath, name, toLink);
|
||||
}
|
||||
|
Reference in New Issue
Block a user