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:
@@ -312,10 +312,12 @@
|
||||
name = #name#,
|
||||
current_root_id = #rootNodeId#,
|
||||
acl_id = #aclId#,
|
||||
vers = (#vers# + 1)
|
||||
where
|
||||
id = #id# and
|
||||
vers = #vers#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="vers" compareValue="1">
|
||||
and vers = (#vers#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
|
||||
<!-- Delete AVMStore -->
|
||||
@@ -525,10 +527,12 @@
|
||||
encoding = #encoding#,
|
||||
length = #length#,
|
||||
guid = #guid#,
|
||||
vers = (#vers# + 1)
|
||||
where
|
||||
id = #id# and
|
||||
vers = #vers#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="vers" compareValue="1">
|
||||
and vers = (#vers#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
|
||||
<update id="update_AVMNode_modTimeAndGuid" parameterClass="AVMNode">
|
||||
@@ -537,10 +541,12 @@
|
||||
set
|
||||
modDate = #modifiedDate#,
|
||||
guid = #guid#,
|
||||
vers = (#vers# + 1)
|
||||
where
|
||||
id = #id# and
|
||||
vers = #vers#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="vers" compareValue="1">
|
||||
and vers = (#vers#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
|
||||
<update id="update_AVMNode_modTimeAndContentData" parameterClass="AVMNode">
|
||||
@@ -552,10 +558,12 @@
|
||||
mime_type = #mimetype#,
|
||||
encoding = #encoding#,
|
||||
length = #length#,
|
||||
vers = (#vers# + 1)
|
||||
where
|
||||
id = #id# and
|
||||
vers = #vers#
|
||||
where
|
||||
id = #id#
|
||||
<isGreaterThan property="vers" compareValue="1">
|
||||
and vers = (#vers#-1)
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
|
||||
<delete id="delete_AVMNode" parameterMap="parameter_IdMap">
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -373,6 +373,18 @@ public class AVMNodeEntity
|
||||
this.vers = vers;
|
||||
}
|
||||
|
||||
public void incrementVers()
|
||||
{
|
||||
if (this.vers >= Long.MAX_VALUE)
|
||||
{
|
||||
this.vers = 0L;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.vers++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
|
@@ -103,6 +103,18 @@ public class AVMStoreEntity
|
||||
this.vers = vers;
|
||||
}
|
||||
|
||||
public void incrementVers()
|
||||
{
|
||||
if (this.vers >= Long.MAX_VALUE)
|
||||
{
|
||||
this.vers = 0L;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.vers++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
|
@@ -189,7 +189,6 @@ public abstract class AbstractAVMNodeDAOImpl implements AVMNodeDAO
|
||||
{
|
||||
throw new ConcurrencyFailureException("AVMNode with ID (" + nodeEntity.getId() + ") no longer exists or has been updated concurrently");
|
||||
}
|
||||
nodeEntity.setVers(nodeEntity.getVers()+1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,7 +208,6 @@ public abstract class AbstractAVMNodeDAOImpl implements AVMNodeDAO
|
||||
{
|
||||
throw new ConcurrencyFailureException("AVMNode with ID (" + nodeEntity.getId() + ") no longer exists or has been updated concurrently");
|
||||
}
|
||||
nodeEntity.setVers(nodeEntity.getVers()+1);
|
||||
|
||||
// update cache
|
||||
avmNodeCache.removeByKey(nodeEntity.getId());
|
||||
@@ -232,7 +230,6 @@ public abstract class AbstractAVMNodeDAOImpl implements AVMNodeDAO
|
||||
{
|
||||
throw new ConcurrencyFailureException("AVMNode with ID (" + nodeEntity.getId() + ") no longer exists or has been updated concurrently");
|
||||
}
|
||||
nodeEntity.setVers(nodeEntity.getVers()+1);
|
||||
|
||||
// update cache
|
||||
avmNodeCache.removeByKey(nodeEntity.getId());
|
||||
|
@@ -1,34 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* 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:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.domain.avm;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* 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:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.domain.avm;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.cache.SimpleCache;
|
||||
import org.alfresco.repo.cache.lookup.EntityLookupCache;
|
||||
@@ -37,20 +37,20 @@ import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.repo.domain.QNameDAO;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
|
||||
/**
|
||||
* Abstract implementation for AVMStore DAO.
|
||||
* <p>
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
|
||||
/**
|
||||
* Abstract implementation for AVMStore DAO.
|
||||
* <p>
|
||||
* This provides basic services such as caching but defers to the underlying implementation
|
||||
* for CRUD operations.
|
||||
*
|
||||
* @author janv
|
||||
* @since 3.2
|
||||
*/
|
||||
public abstract class AbstractAVMStoreDAOImpl implements AVMStoreDAO
|
||||
{
|
||||
* for CRUD operations.
|
||||
*
|
||||
* @author janv
|
||||
* @since 3.2
|
||||
*/
|
||||
public abstract class AbstractAVMStoreDAOImpl implements AVMStoreDAO
|
||||
{
|
||||
private static final String CACHE_REGION_AVM_STORE = "AVMStore";
|
||||
private static final String CACHE_REGION_AVM_STORE_PROP = "AVMStoreProp";
|
||||
|
||||
@@ -59,7 +59,7 @@ public abstract class AbstractAVMStoreDAOImpl implements AVMStoreDAO
|
||||
|
||||
private QNameDAO qnameDAO;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Cache for the AVM store entity:<br/>
|
||||
* KEY: ID<br/>
|
||||
* VALUE: AVMStoreEntity<br/>
|
||||
@@ -123,8 +123,8 @@ public abstract class AbstractAVMStoreDAOImpl implements AVMStoreDAO
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public AVMStoreEntity createStore(String name)
|
||||
{
|
||||
ParameterCheck.mandatory("name", name);
|
||||
@@ -143,31 +143,31 @@ public abstract class AbstractAVMStoreDAOImpl implements AVMStoreDAO
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public AVMStoreEntity getStore(long storeId)
|
||||
{
|
||||
{
|
||||
Pair<Long, AVMStoreEntity> entityPair = avmStoreCache.getByKey(storeId);
|
||||
if (entityPair == null)
|
||||
{
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return entityPair.getSecond();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public AVMStoreEntity getStoreByRoot(long rootNodeId)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public AVMStoreEntity getStoreByRoot(long rootNodeId)
|
||||
{
|
||||
// TODO review - not via cache
|
||||
return getStoreEntityByRoot(rootNodeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public AVMStoreEntity getStore(String name)
|
||||
{
|
||||
ParameterCheck.mandatory("name", name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public AVMStoreEntity getStore(String name)
|
||||
{
|
||||
ParameterCheck.mandatory("name", name);
|
||||
|
||||
AVMStoreEntity storeEntity = new AVMStoreEntity();
|
||||
storeEntity.setName(name);
|
||||
|
||||
@@ -177,52 +177,51 @@ public abstract class AbstractAVMStoreDAOImpl implements AVMStoreDAO
|
||||
return null;
|
||||
}
|
||||
return entityPair.getSecond();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<AVMStoreEntity> getAllStores()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public List<AVMStoreEntity> getAllStores()
|
||||
{
|
||||
// not via cache
|
||||
return getAllStoreEntities();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void updateStore(AVMStoreEntity storeEntity)
|
||||
{
|
||||
ParameterCheck.mandatory("storeEntity", storeEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void updateStore(AVMStoreEntity storeEntity)
|
||||
{
|
||||
ParameterCheck.mandatory("storeEntity", storeEntity);
|
||||
ParameterCheck.mandatory("storeEntity.getId()", storeEntity.getId());
|
||||
ParameterCheck.mandatory("storeEntity.getVers()", storeEntity.getVers());
|
||||
|
||||
|
||||
int updated = avmStoreCache.updateValue(storeEntity.getId(), storeEntity);
|
||||
if (updated < 1)
|
||||
{
|
||||
throw new ConcurrencyFailureException("AVMStore with ID (" + storeEntity.getId() + ") no longer exists or has been updated concurrently");
|
||||
}
|
||||
storeEntity.setVers(storeEntity.getVers()+1);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void deleteStore(long storeId)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void deleteStore(long storeId)
|
||||
{
|
||||
Pair<Long, AVMStoreEntity> entityPair = avmStoreCache.getByKey(storeId);
|
||||
if (entityPair == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int deleted = avmStoreCache.deleteByKey(storeId);
|
||||
if (deleted < 1)
|
||||
{
|
||||
throw new ConcurrencyFailureException("AVMStore with ID " + storeId + " no longer exists");
|
||||
}
|
||||
}
|
||||
|
||||
if (deleted < 1)
|
||||
{
|
||||
throw new ConcurrencyFailureException("AVMStore with ID " + storeId + " no longer exists");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for <b>avm_stores</b> DAO
|
||||
*/
|
||||
@@ -291,22 +290,22 @@ public abstract class AbstractAVMStoreDAOImpl implements AVMStoreDAO
|
||||
avmStoreCache.clear();
|
||||
}
|
||||
|
||||
protected abstract AVMStoreEntity getStoreEntity(long id);
|
||||
protected abstract AVMStoreEntity getStoreEntity(String name);
|
||||
protected abstract AVMStoreEntity getStoreEntityByRoot(long rootNodeId);
|
||||
protected abstract List<AVMStoreEntity> getAllStoreEntities();
|
||||
protected abstract AVMStoreEntity getStoreEntity(long id);
|
||||
protected abstract AVMStoreEntity getStoreEntity(String name);
|
||||
protected abstract AVMStoreEntity getStoreEntityByRoot(long rootNodeId);
|
||||
protected abstract List<AVMStoreEntity> getAllStoreEntities();
|
||||
protected abstract AVMStoreEntity createStoreEntity(AVMStoreEntity storeEntity);
|
||||
protected abstract int deleteStoreEntity(long id);
|
||||
protected abstract int deleteStoreEntity(long id);
|
||||
protected abstract int updateStoreEntity(AVMStoreEntity storeEntity);
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void createOrUpdateStoreProperty(long storeId, QName qname, PropertyValue value)
|
||||
{
|
||||
{
|
||||
ParameterCheck.mandatory("qname", qname);
|
||||
ParameterCheck.mandatory("value", value);
|
||||
|
||||
|
||||
// Get the persistent ID for the QName
|
||||
Pair<Long, QName> qnamePair = qnameDAO.getOrCreateQName(qname);
|
||||
Long qnameId = qnamePair.getFirst();
|
||||
@@ -317,24 +316,24 @@ public abstract class AbstractAVMStoreDAOImpl implements AVMStoreDAO
|
||||
Pair<Pair<Long, Long>, AVMStorePropertyEntity> entityPair = avmStorePropCache.getByKey(key);
|
||||
|
||||
if (entityPair != null)
|
||||
{
|
||||
{
|
||||
int updated = avmStorePropCache.updateValue(key, propEntity);
|
||||
if (updated < 1)
|
||||
{
|
||||
throw new ConcurrencyFailureException("AVMStorePropertyEntity with IDs (" + propEntity.getAvmStoreId() + ", " + propEntity.getQnameId() + ") no longer exists");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
avmStorePropCache.getOrCreateByValue(propEntity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public PropertyValue getStoreProperty(long storeId, QName qname)
|
||||
{
|
||||
{
|
||||
// Get the persistent ID for the QName
|
||||
Pair<Long, QName> qnamePair = qnameDAO.getQName(qname);
|
||||
if (qnamePair != null)
|
||||
@@ -350,13 +349,13 @@ public abstract class AbstractAVMStoreDAOImpl implements AVMStoreDAO
|
||||
return entityPair.getSecond();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Map<QName, PropertyValue> getStoreProperties(long storeId)
|
||||
{
|
||||
{
|
||||
// not via cache
|
||||
List<AVMStorePropertyEntity> propEntities = getStorePropertyEntities(storeId);
|
||||
|
||||
@@ -370,16 +369,16 @@ public abstract class AbstractAVMStoreDAOImpl implements AVMStoreDAO
|
||||
}
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Map<String, Map<QName, PropertyValue>> getStorePropertiesByKeyPattern(String uriPattern, String localNamePattern)
|
||||
{
|
||||
ParameterCheck.mandatoryString("uriPattern", uriPattern);
|
||||
ParameterCheck.mandatoryString("localNamePattern", localNamePattern);
|
||||
|
||||
{
|
||||
ParameterCheck.mandatoryString("uriPattern", uriPattern);
|
||||
ParameterCheck.mandatoryString("localNamePattern", localNamePattern);
|
||||
|
||||
// not via cache
|
||||
List<AVMStorePropertyEntity> spEntities = getStorePropertyEntitiesByKeyPattern(uriPattern, localNamePattern);
|
||||
|
||||
@@ -405,16 +404,16 @@ public abstract class AbstractAVMStoreDAOImpl implements AVMStoreDAO
|
||||
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Map<QName, PropertyValue> getStorePropertiesByStoreAndKeyPattern(long storeId, String uriPattern, String localNamePattern)
|
||||
{
|
||||
ParameterCheck.mandatoryString("uriPattern", uriPattern);
|
||||
ParameterCheck.mandatoryString("localNamePattern", localNamePattern);
|
||||
|
||||
{
|
||||
ParameterCheck.mandatoryString("uriPattern", uriPattern);
|
||||
ParameterCheck.mandatoryString("localNamePattern", localNamePattern);
|
||||
|
||||
// not via cache
|
||||
List<AVMStorePropertyEntity> propEntities = getStorePropertyEntitiesByStoreAndKeyPattern(storeId, uriPattern, localNamePattern);
|
||||
|
||||
@@ -428,17 +427,17 @@ public abstract class AbstractAVMStoreDAOImpl implements AVMStoreDAO
|
||||
}
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void deleteStoreProperty(long storeId, QName qname)
|
||||
{
|
||||
{
|
||||
// Get the persistent ID for the QName
|
||||
Pair<Long, QName> qnamePair = qnameDAO.getQName(qname);
|
||||
if (qnamePair != null)
|
||||
{
|
||||
{
|
||||
Long qnameId = qnamePair.getFirst();
|
||||
|
||||
Pair<Long, Long> key = new Pair<Long, Long>(storeId, qnameId);
|
||||
@@ -453,20 +452,20 @@ public abstract class AbstractAVMStoreDAOImpl implements AVMStoreDAO
|
||||
{
|
||||
throw new ConcurrencyFailureException("AVMStoreProperty with key (" + storeId + ", " + qnameId + ") no longer exists");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void deleteStoreProperties(long storeId)
|
||||
{
|
||||
public void deleteStoreProperties(long storeId)
|
||||
{
|
||||
Map<QName, PropertyValue> props = getStoreProperties(storeId);
|
||||
if (props.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (QName qname : props.keySet())
|
||||
{
|
||||
deleteStoreProperty(storeId, qname);
|
||||
@@ -475,16 +474,16 @@ public abstract class AbstractAVMStoreDAOImpl implements AVMStoreDAO
|
||||
// TODO single delete + cache(s)
|
||||
|
||||
/*
|
||||
int deleted = deleteStorePropertyEntities(storeId);
|
||||
if (deleted < 1)
|
||||
{
|
||||
throw new ConcurrencyFailureException("AVMStoreProperties for store ID " + storeId + " no longer exist");
|
||||
}
|
||||
int deleted = deleteStorePropertyEntities(storeId);
|
||||
if (deleted < 1)
|
||||
{
|
||||
throw new ConcurrencyFailureException("AVMStoreProperties for store ID " + storeId + " no longer exist");
|
||||
}
|
||||
|
||||
// TODO clear store property cache for this store id
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for <b>avm_store_properties</b> DAO
|
||||
*/
|
||||
@@ -545,12 +544,12 @@ public abstract class AbstractAVMStoreDAOImpl implements AVMStoreDAO
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void insertStorePropertyEntity(AVMStorePropertyEntity propEntity);
|
||||
protected abstract void insertStorePropertyEntity(AVMStorePropertyEntity propEntity);
|
||||
protected abstract int updateStorePropertyEntity(AVMStorePropertyEntity propEntity);
|
||||
protected abstract AVMStorePropertyEntity getStorePropertyEntity(long storeId, long qnameId);
|
||||
protected abstract List<AVMStorePropertyEntity> getStorePropertyEntities(long storeId);
|
||||
protected abstract List<AVMStorePropertyEntity> getStorePropertyEntitiesByKeyPattern(String uriPattern, String localNamePattern);
|
||||
protected abstract List<AVMStorePropertyEntity> getStorePropertyEntitiesByStoreAndKeyPattern(long storeId, String uriPattern, String localNamePattern);
|
||||
protected abstract int deleteStorePropertyEntity(long storeId, long qnameId);
|
||||
protected abstract int deleteStorePropertyEntities(long storeId);
|
||||
}
|
||||
protected abstract AVMStorePropertyEntity getStorePropertyEntity(long storeId, long qnameId);
|
||||
protected abstract List<AVMStorePropertyEntity> getStorePropertyEntities(long storeId);
|
||||
protected abstract List<AVMStorePropertyEntity> getStorePropertyEntitiesByKeyPattern(String uriPattern, String localNamePattern);
|
||||
protected abstract List<AVMStorePropertyEntity> getStorePropertyEntitiesByStoreAndKeyPattern(long storeId, String uriPattern, String localNamePattern);
|
||||
protected abstract int deleteStorePropertyEntity(long storeId, long qnameId);
|
||||
protected abstract int deleteStorePropertyEntities(long storeId);
|
||||
}
|
||||
|
@@ -104,12 +104,16 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl
|
||||
@Override
|
||||
protected int updateNodeEntity(AVMNodeEntity updateNodeEntity)
|
||||
{
|
||||
updateNodeEntity.incrementVers();
|
||||
|
||||
return template.update(UPDATE_AVM_NODE, updateNodeEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int updateNodeEntityModTimeAndGuid(AVMNodeEntity updateNodeEntity)
|
||||
{
|
||||
updateNodeEntity.incrementVers();
|
||||
|
||||
// partial update
|
||||
return template.update(UPDATE_AVM_NODE_MODTIME_AND_GUID, updateNodeEntity);
|
||||
}
|
||||
@@ -117,6 +121,8 @@ public class AVMNodeDAOImpl extends AbstractAVMNodeDAOImpl
|
||||
@Override
|
||||
protected int updateNodeEntityModTimeAndContentData(AVMNodeEntity updateNodeEntity)
|
||||
{
|
||||
updateNodeEntity.incrementVers();
|
||||
|
||||
// partial update
|
||||
return template.update(UPDATE_AVM_NODE_MODTIME_AND_CDATA, updateNodeEntity);
|
||||
}
|
||||
|
@@ -109,6 +109,8 @@ public class AVMStoreDAOImpl extends AbstractAVMStoreDAOImpl
|
||||
@Override
|
||||
protected int updateStoreEntity(AVMStoreEntity updateStoreEntity)
|
||||
{
|
||||
updateStoreEntity.incrementVers();
|
||||
|
||||
return template.update(UPDATE_AVM_STORE, updateStoreEntity);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user