Merged V2.1 to HEAD:

6556: AVM performance tweaks
   6557: WCM-758.
   6558: Fixes WCM-753.
   6559: better handling of rename, copy and paste for form instance data and renditions.  addresses WCM-752 and partially addresses WCM-559.
   6560: Renamed JndiTest.java until we decide to keep it or not.
   6561: Oops.
   6562: probable fix WCM-669      
   6563: Build fix after the removal of flushing suport 
   6564: Fix for WCM-728
   6566: Support for avm index clustering via tracking - WCM-762
   6567: Test fix after flush changes
   6568: Fixed AWC-1517: Can now create space based on existing top-level space
   6569: misc IE fixes.
   6570: Various changes to improve AVM import performance and submit performance.
   6571: Session flushing is now deprecated and doesn't fail with an exception.
   6572: Reduced the iteration count to stress nextResults calls a bit more
   6573: WS query sessions put back into cache after more results have been fetched.
   6574: AR-1347: RepositoryServiceSoapBindingStub.queryAssociated() returns nothing when direction=target
   6575: Fixed AR-1680: XPath metadata extraction now handles Node, NodeList and String return values
   6577: Fix for AWC-1518 (User Homes renaming issue, and unreported issue with client config overriding of users home location)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6745 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-09-11 02:37:29 +00:00
parent 652b9406db
commit 19e1af2314
34 changed files with 2883 additions and 2279 deletions

View File

@@ -38,7 +38,6 @@ import javax.jcr.nodetype.NoSuchNodeTypeException;
import javax.jcr.version.VersionException;
import org.alfresco.jcr.session.SessionImpl;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
/**
@@ -107,7 +106,6 @@ public abstract class ItemImpl implements Item
*/
public void save() throws AccessDeniedException, ItemExistsException, ConstraintViolationException, InvalidItemStateException, ReferentialIntegrityException, VersionException, LockException, NoSuchNodeTypeException, RepositoryException
{
AlfrescoTransactionSupport.flush();
}
/* (non-Javadoc)

View File

@@ -1,127 +1,127 @@
/*
* Copyright (C) 2005-2007 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.avm;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.repo.avm.util.BulkLoader;
/**
* Another performance test that runs simultaneous crawlers that
* do operations with locality of reference.
* @author britt
*/
public class AVMCrawlTestP extends AVMServiceTestBase
{
/**
* Do the crawl test.
*/
public void testCrawl()
{
int n = 4; // Number of Threads.
int m = 2; // How many multiples of content to start with.
long runTime = 3600000; // 1 Hour. .
fService.purgeStore("main");
BulkLoader loader = new BulkLoader();
loader.setAvmService(fService);
for (int i = 0; i < m; i++)
{
fService.createStore("d" + i);
loader.recursiveLoad("source", "d" + i + ":/");
fService.createSnapshot("d" + i, null, null);
}
long startTime = System.currentTimeMillis();
List<AVMCrawler> crawlers = new ArrayList<AVMCrawler>();
List<Thread> threads = new ArrayList<Thread>();
for (int i = 0; i < n; i++)
{
crawlers.add(new AVMCrawler(fService));
threads.add(new Thread(crawlers.get(i)));
threads.get(i).start();
}
while (true)
{
try
{
Thread.sleep(5000);
// Check that none of the crawlers has errored out.
for (AVMCrawler crawler : crawlers)
{
if (crawler.getError())
{
for (AVMCrawler craw : crawlers)
{
craw.setDone();
}
for (Thread thread : threads)
{
try
{
thread.join();
}
catch (InterruptedException ie)
{
// Do nothing.
}
}
fail();
}
}
}
catch (InterruptedException ie)
{
// Do nothing.
}
long now = System.currentTimeMillis();
if (now - startTime > runTime)
{
break;
}
}
for (AVMCrawler crawler : crawlers)
{
crawler.setDone();
}
for (Thread thread : threads)
{
try
{
thread.join();
}
catch (InterruptedException ie)
{
// Do nothing.
}
}
long ops = 0L;
for (AVMCrawler crawler : crawlers)
{
ops += crawler.getOpCount();
}
long time = System.currentTimeMillis() - startTime;
System.out.println("Ops/Sec: " + (ops * 1000L / time));
}
}
/*
* Copyright (C) 2005-2007 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.avm;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.repo.avm.util.BulkLoader;
/**
* Another performance test that runs simultaneous crawlers that
* do operations with locality of reference.
* @author britt
*/
public class AVMCrawlTestP extends AVMServiceTestBase
{
/**
* Do the crawl test.
*/
public void testCrawl()
{
int n = 8; // Number of Threads.
int m = 2; // How many multiples of content to start with.
long runTime = 28800000; // 8 Hours. .
fService.purgeStore("main");
BulkLoader loader = new BulkLoader();
loader.setAvmService(fService);
for (int i = 0; i < m; i++)
{
fService.createStore("d" + i);
loader.recursiveLoad("source", "d" + i + ":/");
fService.createSnapshot("d" + i, null, null);
}
long startTime = System.currentTimeMillis();
List<AVMCrawler> crawlers = new ArrayList<AVMCrawler>();
List<Thread> threads = new ArrayList<Thread>();
for (int i = 0; i < n; i++)
{
crawlers.add(new AVMCrawler(fService));
threads.add(new Thread(crawlers.get(i)));
threads.get(i).start();
}
while (true)
{
try
{
Thread.sleep(5000);
// Check that none of the crawlers has errored out.
for (AVMCrawler crawler : crawlers)
{
if (crawler.getError())
{
for (AVMCrawler craw : crawlers)
{
craw.setDone();
}
for (Thread thread : threads)
{
try
{
thread.join();
}
catch (InterruptedException ie)
{
// Do nothing.
}
}
fail();
}
}
}
catch (InterruptedException ie)
{
// Do nothing.
}
long now = System.currentTimeMillis();
if (now - startTime > runTime)
{
break;
}
}
for (AVMCrawler crawler : crawlers)
{
crawler.setDone();
}
for (Thread thread : threads)
{
try
{
thread.join();
}
catch (InterruptedException ie)
{
// Do nothing.
}
}
long ops = 0L;
for (AVMCrawler crawler : crawlers)
{
ops += crawler.getOpCount();
}
long time = System.currentTimeMillis() - startTime;
System.out.println("Ops/Sec: " + (ops * 1000L / time));
}
}

View File

@@ -46,6 +46,7 @@ import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.ClassDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.InvalidAspectException;
import org.alfresco.service.cmr.dictionary.InvalidTypeException;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
@@ -1194,7 +1195,12 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
}
}
}
values.put(qName, new PropertyValue(null, properties.get(qName)));
DataTypeDefinition def = dictionaryService.getDataType(qName);
if (def == null)
{
def = dictionaryService.getDataType(properties.get(qName).getClass());
}
values.put(qName, new PropertyValue(def.getName(), properties.get(qName)));
}
fAVMService.setNodeProperties(avmVersionPath.getSecond(), values);
// Invoke policy behaviors.
@@ -1287,7 +1293,12 @@ public class AVMNodeService extends AbstractNodeServiceImpl implements NodeServi
try
{
// Map<QName, Serializable> propsBefore = getProperties(nodeRef);
fAVMService.setNodeProperty(avmVersionPath.getSecond(), qname, new PropertyValue(null, value));
DataTypeDefinition def = dictionaryService.getDataType(qname);
if (def == null)
{
def = dictionaryService.getDataType(value.getClass());
}
fAVMService.setNodeProperty(avmVersionPath.getSecond(), qname, new PropertyValue(def.getName(), value));
// Map<QName, Serializable> propsAfter = getProperties(nodeRef);
// Invoke policy behaviors.
// invokeOnUpdateNode(nodeRef);

View File

@@ -639,7 +639,8 @@ public class AVMRepository
throw new AVMNotFoundException("Path not found.");
}
srcDir = (DirectoryNode)sPath.getCurrentNode();
srcNode = srcDir.lookupChild(sPath, srcName, false);
Pair<AVMNode, Boolean> temp = srcDir.lookupChild(sPath, srcName, false);
srcNode = (temp == null) ? null : temp.getFirst();
if (srcNode == null)
{
throw new AVMNotFoundException("Not found: " + srcName);
@@ -665,7 +666,8 @@ public class AVMRepository
throw new AVMNotFoundException("Path not found.");
}
DirectoryNode dstDir = (DirectoryNode)dPath.getCurrentNode();
AVMNode child = dstDir.lookupChild(dPath, dstName, true);
Pair<AVMNode, Boolean> temp = dstDir.lookupChild(dPath, dstName, true);
AVMNode child = (temp == null) ? null : temp.getFirst();
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
{
throw new AVMExistsException("Node exists: " + dstName);

View File

@@ -254,13 +254,13 @@ public class AVMServiceTest extends AVMServiceTestBase
props = new HashMap<QName, PropertyValue>();
QName n1 = QName.createQName("silly.uri", "Prop1");
PropertyValue p1 = new PropertyValue(null, new Date(System.currentTimeMillis()));
PropertyValue p1 = new PropertyValue(DataTypeDefinition.DATETIME, new Date(System.currentTimeMillis()));
props.put(n1, p1);
QName n2 = QName.createQName("silly.uri", "Prop2");
PropertyValue p2 = new PropertyValue(null, "A String Property.");
PropertyValue p2 = new PropertyValue(DataTypeDefinition.TEXT, "A String Property.");
props.put(n2, p2);
QName n3 = QName.createQName("silly.uri", "Prop3");
PropertyValue p3 = new PropertyValue(null, 42);
PropertyValue p3 = new PropertyValue(DataTypeDefinition.INT, 42);
props.put(n3, p3);
fService.setNodeProperties("main:/a/b/c/bar", props);
fService.createSnapshot("main", null, null);
@@ -5187,11 +5187,11 @@ public class AVMServiceTest extends AVMServiceTestBase
fService.addAspect("main:/a/b/c/foo", ContentModel.ASPECT_TITLED);
fService.addAspect("main:/a/b/c/foo", ContentModel.ASPECT_AUDITABLE);
Map<QName, PropertyValue> properties = new HashMap<QName, PropertyValue>();
properties.put(ContentModel.PROP_ACCESSED, new PropertyValue(null, new Date(System.currentTimeMillis())));
properties.put(ContentModel.PROP_CREATED, new PropertyValue(null, new Date(System.currentTimeMillis())));
properties.put(ContentModel.PROP_MODIFIED, new PropertyValue(null, new Date(System.currentTimeMillis())));
properties.put(ContentModel.PROP_CREATOR, new PropertyValue(null, "Giles"));
properties.put(ContentModel.PROP_MODIFIER, new PropertyValue(null, "Quentin"));
properties.put(ContentModel.PROP_ACCESSED, new PropertyValue(DataTypeDefinition.DATETIME, new Date(System.currentTimeMillis())));
properties.put(ContentModel.PROP_CREATED, new PropertyValue(DataTypeDefinition.DATETIME, new Date(System.currentTimeMillis())));
properties.put(ContentModel.PROP_MODIFIED, new PropertyValue(DataTypeDefinition.DATETIME, new Date(System.currentTimeMillis())));
properties.put(ContentModel.PROP_CREATOR, new PropertyValue(DataTypeDefinition.TEXT, "Giles"));
properties.put(ContentModel.PROP_MODIFIER, new PropertyValue(DataTypeDefinition.TEXT, "Quentin"));
fService.setNodeProperties("main:/a/b/c/foo", properties);
fService.createSnapshot("main", null, null);

View File

@@ -59,6 +59,7 @@ import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;
import org.alfresco.util.Pair;
/**
* A Repository contains a current root directory and a list of
@@ -326,7 +327,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
throw new AVMNotFoundException("Path " + path + " not found.");
}
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
AVMNode child = dir.lookupChild(lPath, name, true);
Pair<AVMNode, Boolean> temp = dir.lookupChild(lPath, name, true);
AVMNode child = (temp == null) ? null : temp.getFirst();
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
{
throw new AVMExistsException("Child exists: " + name);
@@ -368,7 +370,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
throw new AVMNotFoundException("Path " + dstPath + " not found.");
}
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
AVMNode child = dir.lookupChild(lPath, name, true);
Pair<AVMNode, Boolean> temp = dir.lookupChild(lPath, name, true);
AVMNode child = (temp == null) ? null : temp.getFirst();
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
{
throw new AVMExistsException("Child exists: " + name);
@@ -411,7 +414,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
throw new AVMNotFoundException("Path " + path + " not found.");
}
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
AVMNode child = dir.lookupChild(lPath, name, true);
Pair<AVMNode, Boolean> temp = dir.lookupChild(lPath, name, true);
AVMNode child = (temp == null) ? null : temp.getFirst();
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
{
throw new AVMExistsException("Child exists: " + name);
@@ -446,7 +450,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
throw new AVMNotFoundException("Path " + path + " not found.");
}
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
AVMNode child = dir.lookupChild(lPath, name, true);
Pair<AVMNode, Boolean> temp = dir.lookupChild(lPath, name, true);
AVMNode child = (temp == null) ? null : temp.getFirst();
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
{
throw new AVMExistsException("Child exists: " + name);
@@ -483,7 +488,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
throw new AVMNotFoundException("Path " + dstPath + " not found.");
}
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
AVMNode child = dir.lookupChild(lPath, name, true);
Pair<AVMNode, Boolean> temp = dir.lookupChild(lPath, name, true);
AVMNode child = (temp == null) ? null : temp.getFirst();
if (child != null && child.getType() != AVMNodeType.DELETED_NODE)
{
throw new AVMExistsException("Child exists: " + name);
@@ -1431,7 +1437,8 @@ public class AVMStoreImpl implements AVMStore, Serializable
throw new AVMNotFoundException("Path " + path + " not found.");
}
DirectoryNode dir = (DirectoryNode)lPath.getCurrentNode();
AVMNode child = dir.lookupChild(lPath, name, true);
Pair<AVMNode, Boolean> temp = dir.lookupChild(lPath, name, true);
AVMNode child = (temp == null) ? null : temp.getFirst();
if (child == null)
{
throw new AVMNotFoundException("Node not found: " + name);

File diff suppressed because it is too large Load Diff

View File

@@ -27,6 +27,7 @@ import java.util.Map;
import java.util.SortedMap;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.util.Pair;
/**
* The interface for Directory Nodes.
@@ -54,7 +55,7 @@ public interface DirectoryNode extends AVMNode
* @param name The name of the child to lookup.
* @param includeDeleted Include deleted nodes or not.
*/
public AVMNode lookupChild(Lookup lPath, String name, boolean includeDeleted);
public Pair<AVMNode, Boolean> lookupChild(Lookup lPath, String name, boolean includeDeleted);
/**
* Lookup a child node using an AVMNodeDescriptor as context.

View File

@@ -35,6 +35,7 @@ import org.alfresco.service.cmr.avm.AVMException;
import org.alfresco.service.cmr.avm.AVMExistsException;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMNotFoundException;
import org.alfresco.util.Pair;
/**
* A layered directory node. A layered directory node points at
@@ -507,7 +508,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
* @return The child or null if not found.
*/
@SuppressWarnings("unchecked")
public AVMNode lookupChild(Lookup lPath, String name, boolean includeDeleted)
public Pair<AVMNode, Boolean> lookupChild(Lookup lPath, String name, boolean includeDeleted)
{
ChildKey key = new ChildKey(this, name);
ChildEntry entry = AVMDAOs.Instance().fChildEntryDAO.get(key);
@@ -517,7 +518,7 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
{
return null;
}
return AVMNodeUnwrapper.Unwrap(entry.getChild());
return new Pair<AVMNode, Boolean>(AVMNodeUnwrapper.Unwrap(entry.getChild()), true);
}
// Don't check our underlying directory if we are opaque.
if (fOpacity)
@@ -529,7 +530,11 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
if (lookup != null)
{
DirectoryNode dir = (DirectoryNode)lookup.getCurrentNode();
AVMNode retVal = dir.lookupChild(lookup, name, includeDeleted);
Pair<AVMNode, Boolean> retVal = dir.lookupChild(lookup, name, includeDeleted);
if (retVal != null)
{
retVal.setSecond(false);
}
lPath.setFinalStore(lookup.getFinalStore());
return retVal;
}
@@ -573,12 +578,12 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
if (lookup != null)
{
DirectoryNode dir = (DirectoryNode)lookup.getCurrentNode();
AVMNode child = dir.lookupChild(lookup, name, includeDeleted);
Pair<AVMNode, Boolean> child = dir.lookupChild(lookup, name, includeDeleted);
if (child == null)
{
return null;
}
return child.getDescriptor(lookup);
return child.getFirst().getDescriptor(lookup);
}
else
{
@@ -613,7 +618,15 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
}
else
{
child = lookupChild(lPath, name, false);
Pair<AVMNode, Boolean> temp = lookupChild(lPath, name, false);
if (temp == null)
{
child = null;
}
else
{
child = temp.getFirst();
}
indirect = true;
}
if (child != null && (indirect || child.getStoreNew() == null || child.getAncestor() != null))
@@ -893,7 +906,8 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec
throw new AVMBadArgumentException("Non primary layered directories cannot be linked.");
}
// Look for an existing child of that name.
AVMNode existing = lookupChild(lPath, name, true);
Pair<AVMNode, Boolean> temp = lookupChild(lPath, name, true);
AVMNode existing = (temp == null) ? null : temp.getFirst();
ChildKey key = new ChildKey(this, name);
if (existing != null)
{

View File

@@ -218,7 +218,7 @@ class Lookup implements Serializable
* @param write Whether this is in the context of
* a write operation.
*/
public void add(AVMNode node, String name, boolean write)
public void add(AVMNode node, String name, boolean directlyContained, boolean write)
{
LookupComponent comp = new LookupComponent();
comp.setName(name);
@@ -226,7 +226,11 @@ class Lookup implements Serializable
if (fPosition >= 0 && fDirectlyContained &&
fComponents.get(fPosition).getNode().getType() == AVMNodeType.LAYERED_DIRECTORY)
{
fDirectlyContained = ((DirectoryNode)fComponents.get(fPosition).getNode()).directlyContains(node);
// if (directlyContained != ((DirectoryNode)fComponents.get(fPosition).getNode()).directlyContains(node))
// {
// System.err.println("Bloody Murder!");
// }
fDirectlyContained = directlyContained;
}
if (!write)
{

View File

@@ -1,287 +1,290 @@
/**
*
*/
package org.alfresco.repo.avm;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.repo.avm.util.SimplePath;
import org.alfresco.repo.cache.SimpleCache;
import org.apache.log4j.Logger;
/**
* All lookup traffic goes through here.
* @author britt
*/
public class LookupCache
{
private static Logger fgLogger = Logger.getLogger(LookupCache.class);
/**
* The Map of of keys to lookups.
*/
private SimpleCache<LookupKey, Lookup> fCache;
/**
* Reference to the Node DAO.
*/
private AVMNodeDAO fAVMNodeDAO;
/**
* Reference to the Store DAO.
*/
private AVMStoreDAO fAVMStoreDAO;
/**
* Make one up.
*/
public LookupCache()
{
}
/**
* Set up the node dao.
* @param dao The dao to set.
*/
public void setAvmNodeDAO(AVMNodeDAO dao)
{
fAVMNodeDAO = dao;
}
/**
* Set the store dao.
* @param dao The dao to set.
*/
public void setAvmStoreDAO(AVMStoreDAO dao)
{
fAVMStoreDAO = dao;
}
public void setTransactionalCache(SimpleCache<LookupKey, Lookup> cache)
{
fCache = cache;
}
/**
* Lookup a path. Try to fulfill the request from the cache.
* @param store The AVMStore.
* @param version The versions.
* @param path The path we are looking up.
* @param write Whether this is a write lookup.
* @param includeDeleted
* @return
*/
public Lookup lookup(AVMStore store, int version, SimplePath path,
boolean write, boolean includeDeleted)
{
// Create a key object.
LookupKey key = new LookupKey(version, path, store.getName(), write, includeDeleted);
// Is it in the cache?
Lookup found = findInCache(key);
// TODO Testing.
// found = null;
if (found != null)
{
if (fgLogger.isDebugEnabled())
{
fgLogger.debug("Cache Hit: " + key + ", " + found.getCurrentNode().getId());
}
return found;
}
// Make up a Lookup to hold the results.
if (path.size() == 0)
{
return null;
}
Lookup result = new Lookup(store, store.getName(), version);
// Grab the root node to start the lookup.
DirectoryNode dir = null;
// Versions less than 0 mean get current.
if (version < 0)
{
dir = store.getRoot();
}
else
{
dir = fAVMNodeDAO.getAVMStoreRoot(store, version);
}
if (dir == null)
{
return null;
}
// Add an entry for the root.
result.add(dir, "", write);
dir = (DirectoryNode)result.getCurrentNode();
if (path.size() == 1 && path.get(0).equals(""))
{
fCache.put(key, result);
return result;
}
// Now look up each path element in sequence up to one
// before the end.
for (int i = 0; i < path.size() - 1; i++)
{
AVMNode child = dir.lookupChild(result, path.get(i), includeDeleted);
if (child == null)
{
return null;
}
// Every element that is not the last needs to be a directory.
if (child.getType() != AVMNodeType.PLAIN_DIRECTORY &&
child.getType() != AVMNodeType.LAYERED_DIRECTORY)
{
return null;
}
result.add(child, path.get(i), write);
dir = (DirectoryNode)result.getCurrentNode();
}
// Now look up the last element.
AVMNode child = dir.lookupChild(result, path.get(path.size() - 1),
includeDeleted);
if (child == null)
{
return null;
}
result.add(child, path.get(path.size() - 1), write);
fCache.put(key, result);
return result;
}
/**
* Try to find a match in the cache.
* @param key The lookup key.
* @return A valid for this session Lookup or null if not found.
*/
private synchronized Lookup findInCache(LookupKey key)
{
Lookup found = fCache.get(key);
if (found != null)
{
// Get a freshened Lookup.
Lookup result = new Lookup(found, fAVMNodeDAO, fAVMStoreDAO);
// Check that nothing horrible is wrong. This should
// be assertible, but I'll leave the check in for now.
if (!result.isValid())
{
fgLogger.error("Invalid entry in cache: " + key);
return null;
}
return result;
}
// Alternatively for a read lookup a write can match.
if (!key.isWrite())
{
// Make a copy of the key and set it to 'write'
LookupKey newKey = new LookupKey(key);
newKey.setWrite(true);
found = fCache.get(newKey);
if (found != null)
{
// We found it. Make a freshened copy of the Lookup.
Lookup result = new Lookup(found, fAVMNodeDAO, fAVMStoreDAO);
// Check for badness. This should be assertible but I'll
// leave the check in for now.
if (!result.isValid())
{
fgLogger.error("Invalid entry in cache: " + newKey);
return null;
}
return result;
}
}
return null;
}
// Following are the cache invalidation calls.
/**
* Called when a simple write operation occurs. This
* invalidates all read lookups and all layered lookups.
*/
public synchronized void onWrite(String storeName)
{
// Invalidate if it's a read lookup in the store, or
// any read lookup is it's layered.
List<LookupKey> keys = new ArrayList<LookupKey>();
for (LookupKey key : fCache.getKeys())
{
keys.add(key);
}
for (LookupKey key : keys)
{
Lookup value = fCache.get(key);
if ((key.getStoreName().equals(storeName) &&
!key.isWrite()) || value == null ||
(!key.isWrite() && value.isLayered()))
{
if (fgLogger.isDebugEnabled())
{
fgLogger.debug("Invalidating: " + key + ", " + (value != null ? value.getCurrentNode().getId() : -2));
}
fCache.remove(key);
}
}
}
/**
* Called when a delete has occurred in a store. This invalidates both
* reads and write lookups in that store.
*/
public synchronized void onDelete(String storeName)
{
// Invalidate any entries that are in the store or are layered lookups.
List<LookupKey> keys = new ArrayList<LookupKey>();
for (LookupKey key : fCache.getKeys())
{
keys.add(key);
}
for (LookupKey key : keys)
{
Lookup value = fCache.get(key);
if (key.getStoreName().equals(storeName) ||
value == null || value.isLayered())
{
if (fgLogger.isDebugEnabled())
{
fgLogger.debug("Invalidating: " + key + ", " + (value != null ? value.getCurrentNode().getId() : -2));
}
fCache.remove(key);
}
}
}
/**
* Called when a snapshot occurs in a store. This invalidates write
* lookups. Read lookups stay untouched.
*/
public synchronized void onSnapshot(String storeName)
{
// Invalidate any entries that in the store and writes or
// any layered lookups.
List<LookupKey> keys = new ArrayList<LookupKey>();
for (LookupKey key : fCache.getKeys())
{
keys.add(key);
}
for (LookupKey key : keys)
{
Lookup value = fCache.get(key);
if ((key.getStoreName().equals(storeName) &&
key.isWrite()) ||
value == null || value.isLayered())
{
if (fgLogger.isDebugEnabled())
{
fgLogger.debug("Invalidating: " + key + ", " + (value != null ? value.getCurrentNode().getId() : -2));
}
fCache.remove(key);
}
}
}
public synchronized void reset()
{
fCache.clear();
}
}
/**
*
*/
package org.alfresco.repo.avm;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.repo.avm.util.SimplePath;
import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.util.Pair;
import org.apache.log4j.Logger;
/**
* All lookup traffic goes through here.
* @author britt
*/
public class LookupCache
{
private static Logger fgLogger = Logger.getLogger(LookupCache.class);
/**
* The Map of of keys to lookups.
*/
private SimpleCache<LookupKey, Lookup> fCache;
/**
* Reference to the Node DAO.
*/
private AVMNodeDAO fAVMNodeDAO;
/**
* Reference to the Store DAO.
*/
private AVMStoreDAO fAVMStoreDAO;
/**
* Make one up.
*/
public LookupCache()
{
}
/**
* Set up the node dao.
* @param dao The dao to set.
*/
public void setAvmNodeDAO(AVMNodeDAO dao)
{
fAVMNodeDAO = dao;
}
/**
* Set the store dao.
* @param dao The dao to set.
*/
public void setAvmStoreDAO(AVMStoreDAO dao)
{
fAVMStoreDAO = dao;
}
public void setTransactionalCache(SimpleCache<LookupKey, Lookup> cache)
{
fCache = cache;
}
/**
* Lookup a path. Try to fulfill the request from the cache.
* @param store The AVMStore.
* @param version The versions.
* @param path The path we are looking up.
* @param write Whether this is a write lookup.
* @param includeDeleted
* @return
*/
public Lookup lookup(AVMStore store, int version, SimplePath path,
boolean write, boolean includeDeleted)
{
// Create a key object.
LookupKey key = new LookupKey(version, path, store.getName(), write, includeDeleted);
// Is it in the cache?
Lookup found = findInCache(key);
// TODO Testing.
// found = null;
if (found != null)
{
if (fgLogger.isDebugEnabled())
{
fgLogger.debug("Cache Hit: " + key + ", " + found.getCurrentNode().getId());
}
return found;
}
// Make up a Lookup to hold the results.
if (path.size() == 0)
{
return null;
}
Lookup result = new Lookup(store, store.getName(), version);
// Grab the root node to start the lookup.
DirectoryNode dir = null;
// Versions less than 0 mean get current.
if (version < 0)
{
dir = store.getRoot();
}
else
{
VersionRoot vRoot = AVMDAOs.Instance().fVersionRootDAO.getByVersionID(store, version);
dir = vRoot.getRoot();
// dir = fAVMNodeDAO.getAVMStoreRoot(store, version);
}
if (dir == null)
{
return null;
}
// Add an entry for the root.
result.add(dir, "", true, write);
dir = (DirectoryNode)result.getCurrentNode();
if (path.size() == 1 && path.get(0).equals(""))
{
fCache.put(key, result);
return result;
}
// Now look up each path element in sequence up to one
// before the end.
for (int i = 0; i < path.size() - 1; i++)
{
Pair<AVMNode, Boolean> child = dir.lookupChild(result, path.get(i), includeDeleted);
if (child == null)
{
return null;
}
// Every element that is not the last needs to be a directory.
if (child.getFirst().getType() != AVMNodeType.PLAIN_DIRECTORY &&
child.getFirst().getType() != AVMNodeType.LAYERED_DIRECTORY)
{
return null;
}
result.add(child.getFirst(), path.get(i), child.getSecond(), write);
dir = (DirectoryNode)result.getCurrentNode();
}
// Now look up the last element.
Pair<AVMNode, Boolean> child = dir.lookupChild(result, path.get(path.size() - 1),
includeDeleted);
if (child == null)
{
return null;
}
result.add(child.getFirst(), path.get(path.size() - 1), child.getSecond(), write);
fCache.put(key, result);
return result;
}
/**
* Try to find a match in the cache.
* @param key The lookup key.
* @return A valid for this session Lookup or null if not found.
*/
private synchronized Lookup findInCache(LookupKey key)
{
Lookup found = fCache.get(key);
if (found != null)
{
// Get a freshened Lookup.
Lookup result = new Lookup(found, fAVMNodeDAO, fAVMStoreDAO);
// Check that nothing horrible is wrong. This should
// be assertible, but I'll leave the check in for now.
if (!result.isValid())
{
fgLogger.error("Invalid entry in cache: " + key);
return null;
}
return result;
}
// Alternatively for a read lookup a write can match.
if (!key.isWrite())
{
// Make a copy of the key and set it to 'write'
LookupKey newKey = new LookupKey(key);
newKey.setWrite(true);
found = fCache.get(newKey);
if (found != null)
{
// We found it. Make a freshened copy of the Lookup.
Lookup result = new Lookup(found, fAVMNodeDAO, fAVMStoreDAO);
// Check for badness. This should be assertible but I'll
// leave the check in for now.
if (!result.isValid())
{
fgLogger.error("Invalid entry in cache: " + newKey);
return null;
}
return result;
}
}
return null;
}
// Following are the cache invalidation calls.
/**
* Called when a simple write operation occurs. This
* invalidates all read lookups and all layered lookups.
*/
public synchronized void onWrite(String storeName)
{
// Invalidate if it's a read lookup in the store, or
// any read lookup is it's layered.
List<LookupKey> keys = new ArrayList<LookupKey>();
for (LookupKey key : fCache.getKeys())
{
keys.add(key);
}
for (LookupKey key : keys)
{
Lookup value = fCache.get(key);
if ((key.getStoreName().equals(storeName) &&
!key.isWrite()) || value == null ||
(!key.isWrite() && value.isLayered()))
{
if (fgLogger.isDebugEnabled())
{
fgLogger.debug("Invalidating: " + key + ", " + (value != null ? value.getCurrentNode().getId() : -2));
}
fCache.remove(key);
}
}
}
/**
* Called when a delete has occurred in a store. This invalidates both
* reads and write lookups in that store.
*/
public synchronized void onDelete(String storeName)
{
// Invalidate any entries that are in the store or are layered lookups.
List<LookupKey> keys = new ArrayList<LookupKey>();
for (LookupKey key : fCache.getKeys())
{
keys.add(key);
}
for (LookupKey key : keys)
{
Lookup value = fCache.get(key);
if (key.getStoreName().equals(storeName) ||
value == null || value.isLayered())
{
if (fgLogger.isDebugEnabled())
{
fgLogger.debug("Invalidating: " + key + ", " + (value != null ? value.getCurrentNode().getId() : -2));
}
fCache.remove(key);
}
}
}
/**
* Called when a snapshot occurs in a store. This invalidates write
* lookups. Read lookups stay untouched.
*/
public synchronized void onSnapshot(String storeName)
{
// Invalidate any entries that in the store and writes or
// any layered lookups.
List<LookupKey> keys = new ArrayList<LookupKey>();
for (LookupKey key : fCache.getKeys())
{
keys.add(key);
}
for (LookupKey key : keys)
{
Lookup value = fCache.get(key);
if ((key.getStoreName().equals(storeName) &&
key.isWrite()) ||
value == null || value.isLayered())
{
if (fgLogger.isDebugEnabled())
{
fgLogger.debug("Invalidating: " + key + ", " + (value != null ? value.getCurrentNode().getId() : -2));
}
fCache.remove(key);
}
}
}
public synchronized void reset()
{
fCache.clear();
}
}

View File

@@ -34,6 +34,7 @@ import org.alfresco.service.cmr.avm.AVMBadArgumentException;
import org.alfresco.service.cmr.avm.AVMExistsException;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMNotFoundException;
import org.alfresco.util.Pair;
/**
* A plain directory. No monkey tricks except for possiblyCopy.
@@ -185,7 +186,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
* @return The child or null.
*/
@SuppressWarnings("unchecked")
public AVMNode lookupChild(Lookup lPath, String name, boolean includeDeleted)
public Pair<AVMNode, Boolean> lookupChild(Lookup lPath, String name, boolean includeDeleted)
{
ChildKey key = new ChildKey(this, name);
ChildEntry entry = AVMDAOs.Instance().fChildEntryDAO.get(key);
@@ -196,7 +197,7 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory
}
// We're doing the hand unrolling of the proxy because
// Hibernate/CGLIB proxies are broken.
return AVMNodeUnwrapper.Unwrap(entry.getChild());
return new Pair<AVMNode, Boolean>(AVMNodeUnwrapper.Unwrap(entry.getChild()), true);
}
/**

View File

@@ -1,116 +1,116 @@
/*
* Copyright (C) 2005-2007 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.avm;
/**
* Represents a single version root.
* @author britt
*/
public interface VersionRoot
{
/**
* @return the createDate
*/
public long getCreateDate();
/**
* @param createDate the createDate to set
*/
public void setCreateDate(long createDate);
/**
* @return the creator
*/
public String getCreator();
/**
* @param creator the creator to set
*/
public void setCreator(String creator);
/**
* @return the id
*/
public long getId();
/**
* @param id the id to set
*/
public void setId(long id);
/**
* @return the AVMStore
*/
public AVMStore getAvmStore();
/**
* @param store the store to set
*/
public void setAvmStore(AVMStore store);
/**
* @return the root
*/
public DirectoryNode getRoot();
/**
* @param root the root to set
*/
public void setRoot(DirectoryNode root);
/**
* Set the version id.
* @param versionID
*/
public void setVersionID(int versionID);
/**
* Get the version id.
* @return The version id.
*/
public int getVersionID();
/**
* Get the tag (short description).
* @return The tag.
*/
public String getTag();
/**
* Get the thick description.
* @return The thick description.
*/
public String getDescription();
/**
* Set the tag.
* @param tag
*/
public void setTag(String tag);
/**
* Set the description.
* @param description
*/
public void setDescription(String description);
/*
* Copyright (C) 2005-2007 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.avm;
/**
* Represents a single version root.
* @author britt
*/
public interface VersionRoot
{
/**
* @return the createDate
*/
public long getCreateDate();
/**
* @param createDate the createDate to set
*/
public void setCreateDate(long createDate);
/**
* @return the creator
*/
public String getCreator();
/**
* @param creator the creator to set
*/
public void setCreator(String creator);
/**
* @return the id
*/
public Long getId();
/**
* @param id the id to set
*/
public void setId(long id);
/**
* @return the AVMStore
*/
public AVMStore getAvmStore();
/**
* @param store the store to set
*/
public void setAvmStore(AVMStore store);
/**
* @return the root
*/
public DirectoryNode getRoot();
/**
* @param root the root to set
*/
public void setRoot(DirectoryNode root);
/**
* Set the version id.
* @param versionID
*/
public void setVersionID(int versionID);
/**
* Get the version id.
* @return The version id.
*/
public int getVersionID();
/**
* Get the tag (short description).
* @return The tag.
*/
public String getTag();
/**
* Get the thick description.
* @return The thick description.
*/
public String getDescription();
/**
* Set the tag.
* @param tag
*/
public void setTag(String tag);
/**
* Set the description.
* @param description
*/
public void setDescription(String description);
}

View File

@@ -1,259 +1,259 @@
/*
* Copyright (C) 2005-2007 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.avm;
import java.io.Serializable;
/**
* Hold a single version root.
* @author britt
*/
class VersionRootImpl implements VersionRoot, Serializable
{
static final long serialVersionUID = 8826954538210455917L;
/**
* The object id
*/
private Long fID;
/**
* The version id.
*/
private int fVersionID;
/**
* The creation date.
*/
private long fCreateDate;
/**
* The creator.
*/
private String fCreator;
/**
* The AVMStore.
*/
private AVMStore fAVMStore;
/**
* The root node.
*/
private DirectoryNode fRoot;
/**
* The short description.
*/
private String fTag;
/**
* The thick description.
*/
private String fDescription;
/**
* A default constructor.
*/
public VersionRootImpl()
{
}
/**
* Rich constructor.
* @param store
* @param root
* @param versionID
* @param createDate
* @param creator
*/
public VersionRootImpl(AVMStore store,
DirectoryNode root,
int versionID,
long createDate,
String creator,
String tag,
String description)
{
fAVMStore = store;
fRoot = root;
fVersionID = versionID;
fCreateDate = createDate;
fCreator = creator;
fTag = tag;
fDescription = description;
}
public long getCreateDate()
{
return fCreateDate;
}
public void setCreateDate(long createDate)
{
fCreateDate = createDate;
}
public String getCreator()
{
return fCreator;
}
public void setCreator(String creator)
{
fCreator = creator;
}
public long getId()
{
return fID;
}
public void setId(long id)
{
fID = id;
}
public AVMStore getAvmStore()
{
return fAVMStore;
}
public void setAvmStore(AVMStore store)
{
fAVMStore = store;
}
public DirectoryNode getRoot()
{
return fRoot;
}
public void setRoot(DirectoryNode root)
{
fRoot = root;
}
/**
* Set the versionID.
* @param versionID
*/
public void setVersionID(int versionID)
{
fVersionID = versionID;
}
/**
* Get the version id.
* @return The version id.
*/
public int getVersionID()
{
return fVersionID;
}
/**
* Check equality. Based on AVMStore equality and version id equality.
* @param obj
* @return Equality.
*/
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (!(obj instanceof VersionRoot))
{
return false;
}
VersionRoot other = (VersionRoot)obj;
return fAVMStore.equals(other.getAvmStore())
&& fVersionID == other.getVersionID();
}
/**
* Generate a hash code.
* @return The hash code.
*/
@Override
public int hashCode()
{
return fAVMStore.hashCode() + fVersionID;
}
/**
* Get the tag (short description).
* @return The tag.
*/
public String getTag()
{
return fTag;
}
/**
* Set the tag (short description).
* @param tag The short description.
*/
public void setTag(String tag)
{
fTag = tag;
}
/**
* Get the thick description.
* @return The thick description.
*/
public String getDescription()
{
return fDescription;
}
/**
* Set the thick description.
* @param description The thick discription.
*/
public void setDescription(String description)
{
fDescription = description;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append("[VersionRoot:");
builder.append(fAVMStore.getName());
builder.append(':');
builder.append(fVersionID);
builder.append(']');
return builder.toString();
}
}
/*
* Copyright (C) 2005-2007 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.avm;
import java.io.Serializable;
/**
* Hold a single version root.
* @author britt
*/
public class VersionRootImpl implements VersionRoot, Serializable
{
static final long serialVersionUID = 8826954538210455917L;
/**
* The object id
*/
private Long fID;
/**
* The version id.
*/
private int fVersionID;
/**
* The creation date.
*/
private long fCreateDate;
/**
* The creator.
*/
private String fCreator;
/**
* The AVMStore.
*/
private AVMStore fAVMStore;
/**
* The root node.
*/
private DirectoryNode fRoot;
/**
* The short description.
*/
private String fTag;
/**
* The thick description.
*/
private String fDescription;
/**
* A default constructor.
*/
public VersionRootImpl()
{
}
/**
* Rich constructor.
* @param store
* @param root
* @param versionID
* @param createDate
* @param creator
*/
public VersionRootImpl(AVMStore store,
DirectoryNode root,
int versionID,
long createDate,
String creator,
String tag,
String description)
{
fAVMStore = store;
fRoot = root;
fVersionID = versionID;
fCreateDate = createDate;
fCreator = creator;
fTag = tag;
fDescription = description;
}
public long getCreateDate()
{
return fCreateDate;
}
public void setCreateDate(long createDate)
{
fCreateDate = createDate;
}
public String getCreator()
{
return fCreator;
}
public void setCreator(String creator)
{
fCreator = creator;
}
public Long getId()
{
return fID;
}
public void setId(long id)
{
fID = id;
}
public AVMStore getAvmStore()
{
return fAVMStore;
}
public void setAvmStore(AVMStore store)
{
fAVMStore = store;
}
public DirectoryNode getRoot()
{
return fRoot;
}
public void setRoot(DirectoryNode root)
{
fRoot = root;
}
/**
* Set the versionID.
* @param versionID
*/
public void setVersionID(int versionID)
{
fVersionID = versionID;
}
/**
* Get the version id.
* @return The version id.
*/
public int getVersionID()
{
return fVersionID;
}
/**
* Check equality. Based on AVMStore equality and version id equality.
* @param obj
* @return Equality.
*/
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (!(obj instanceof VersionRoot))
{
return false;
}
VersionRoot other = (VersionRoot)obj;
return fAVMStore.equals(other.getAvmStore())
&& fVersionID == other.getVersionID();
}
/**
* Generate a hash code.
* @return The hash code.
*/
@Override
public int hashCode()
{
return fAVMStore.hashCode() + fVersionID;
}
/**
* Get the tag (short description).
* @return The tag.
*/
public String getTag()
{
return fTag;
}
/**
* Set the tag (short description).
* @param tag The short description.
*/
public void setTag(String tag)
{
fTag = tag;
}
/**
* Get the thick description.
* @return The thick description.
*/
public String getDescription()
{
return fDescription;
}
/**
* Set the thick description.
* @param description The thick discription.
*/
public void setDescription(String description)
{
fDescription = description;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append("[VersionRoot:");
builder.append(fAVMStore.getName());
builder.append(':');
builder.append(fVersionID);
builder.append(']');
return builder.toString();
}
}

View File

@@ -1,315 +1,315 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="org.alfresco.repo.avm">
<typedef class="org.alfresco.repo.domain.hibernate.QNameUserType" name="QName"/>
<!-- AVMNodeBean is the abstract base for filesystem like objects.
We're using the one table per class hierarchy strategy to implement
polymorphism. -->
<class table="avm_nodes" abstract="true"
name="AVMNodeImpl"
proxy="AVMNode"
optimistic-lock="version"
lazy="true">
<cache usage="read-write"/>
<!-- The id is set programmatically using an Issuer. See below. -->
<id name="id"
column="id"
type="long"/>
<!-- I suppose this would be more efficient to encode type by an int.
We'll see if using a string makes a difference. -->
<discriminator column="class_type"
type="string"
length="20"/>
<!-- We're using hibernate's own versioning scheme for concurrency control.
I don't know how well that will play with a full Spring-JTA stack. -->
<version column="vers"
name="vers"
type="long"/>
<!-- This should really be not null, but I haven't figured out
the right way to build the relation so that nullability constraints
won't cause violations in the db during saves. -->
<property name="versionID" type="int" column="version_id"
not-null="true"/>
<property name="guid" type="string" length="36" column="guid"/>
<component name="basicAttributes" class="BasicAttributesImpl">
<property name="creator" type="string" not-null="true"/>
<property name="owner" type="string" not-null="true"/>
<property name="lastModifier" type="string" not-null="true"/>
<property name="createDate" type="long" not-null="true"/>
<property name="modDate" type="long" not-null="true"/>
<property name="accessDate" type="long" not-null="true"/>
</component>
<property name="isRoot" column="is_root" type="boolean"/>
<many-to-one name="storeNew" class="AVMStoreImpl" column="store_new_id" foreign-key="fk_avm_n_store"/>
<!-- ACL -->
<many-to-one name="acl" column="acl_id" foreign-key="fk_avm_n_acl"
class="org.alfresco.repo.domain.hibernate.DbAccessControlListImpl"/>
<set name="aspects" fetch="join" lazy="false" table="avm_aspects_new" cascade="all" optimistic-lock="true">
<cache usage="read-write"/>
<key column="id"/>
<element type="QName" not-null="true" column="name" length="200"/>
</set>
<map name="properties" fetch="join" lazy="false" table="avm_node_properties_new" cascade="all" optimistic-lock="true">
<cache usage="read-write"/>
<key column="node_id" not-null="true"/>
<map-key type="QName" length="200" column="qname"/>
<composite-element class="org.alfresco.repo.domain.PropertyValue">
<property name="actualType" column="actual_type" type="string" length="15" not-null="true" />
<property name="multiValued" column="multi_valued" type="boolean" not-null="true" />
<property name="persistedType" column="persisted_type" type="string" length="15" not-null="true" />
<property name="booleanValue" column="boolean_value" type="boolean" />
<property name="longValue" column="long_value" type="long" />
<property name="floatValue" column="float_value" type="float" />
<property name="doubleValue" column="double_value" type="double" />
<property name="stringValue" column="string_value" type="string" length="1024"/>
<property name="serializableValue" column="serializable_value" type="serializable" length="16384"/>
</composite-element>
</map>
<!-- Deleted nodes -->
<subclass name="DeletedNodeImpl"
proxy="DeletedNode"
lazy="true"
discriminator-value="deletednode">
<property name="deletedType" type="int"/>
</subclass>
<!-- Directories, two flavors. -->
<subclass name="DirectoryNodeImpl"
proxy="DirectoryNode"
abstract="true"
lazy="true">
<!-- A Layered Directory is our smart symlink thingy. -->
<subclass name="LayeredDirectoryNodeImpl"
proxy="LayeredDirectoryNode"
discriminator-value="layereddirectory" lazy="true">
<!-- The layer id is an implementation trick to disambiguate
exactly what layer is being refered to in various circumstances. -->
<property name="layerID" column="layer_id" type="long"/>
<!-- The is the moral equivalent of the value of a symlink. -->
<property name="indirection" column="indirection"
type="string" length="511" />
<property name="indirectionVersion" type="int" column="indirection_version"/>
<!-- This marks a layered directory as either knowing itself what
it points at (true) or inheriting what it points at from its
container (false). -->
<property name="primaryIndirection"
column="primary_indirection" type="boolean"/>
<property name="opacity" column="opacity" type="boolean"/>
<!-- Map of names to DirectoryEntries. -->
</subclass>
<!-- Just plain directories. -->
<subclass name="PlainDirectoryNodeImpl"
discriminator-value="plaindirectory" proxy="PlainDirectoryNode" lazy="true">
</subclass>
</subclass>
<!-- There are two kinds of files, plain and symlinky. -->
<subclass name="FileNodeImpl"
proxy="FileNode"
abstract="true"
lazy="false">
<!-- Plain files just have a reference to a Content object. -->
<subclass discriminator-value="plainfile"
name="PlainFileNodeImpl" proxy="PlainFileNode" lazy="true">
<property name="contentURL" column="content_url" type="string" length="128"/>
<property name="mimeType" column="mime_type" type="string" length="64"/>
<property name="encoding" column="encoding" type="string" length="16"/>
<property name="length" column="length" type="long"/>
</subclass>
<!-- Layered files are almost exactly copy on write symlinks. -->
<subclass name="LayeredFileNodeImpl"
discriminator-value="layeredfile" proxy="LayeredFileNode" lazy="true">
<property name="indirection" type="string" length="511"
column="indirection" />
<property name="indirectionVersion" type="int" column="indirection_version"/>
</subclass>
</subclass>
</class>
<!-- A store is the what we used to call a virtual repository. -->
<class table="avm_stores" name="AVMStoreImpl"
proxy="AVMStore" optimistic-lock="version">
<cache usage="read-write"/>
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<version name="vers" column="vers" type="long"/>
<property name="name" column="name" type="string" unique="true"/>
<property type="int" name="nextVersionID"
column="next_version_id" not-null="true"/>
<!-- Every AVMStore has a root directory that is the current root directory. -->
<many-to-one name="root" class="DirectoryNodeImpl"
column="current_root_id" cascade="save-update" foreign-key="fk_avm_s_root">
</many-to-one>
</class>
<class name="VersionRootImpl" proxy="VersionRoot" table="avm_version_roots">
<!-- <cache usage="read-write"/> -->
<id column="id" type="long">
<generator class="native"></generator>
</id>
<natural-id>
<property name="versionID" type="int" not-null="true"
column="version_id" index="idx_avm_vr_version">
</property>
<many-to-one name="avmStore" column="avm_store_id"
class="AVMStoreImpl" not-null="true" foreign-key="fk_avm_vr_store">
</many-to-one>
</natural-id>
<property name="createDate" type="long" not-null="true" column="create_date">
</property>
<property name="creator" type="string" column="creator"
not-null="true">
</property>
<many-to-one name="root" class="DirectoryNodeImpl"
column="root_id" not-null="true" foreign-key="fk_avm_vr_root">
</many-to-one>
<property name="tag" type="string" length="255" column="tag"/>
<property name="description" type="string" length="4000" column="description"/>
</class>
<class name="ChildEntryImpl" proxy="ChildEntry" table="avm_child_entries">
<cache usage="read-write"/>
<composite-id name="key" class="ChildKey">
<key-many-to-one name="parent" column="parent_id" class="DirectoryNodeImpl" foreign-key="fk_avm_ce_parent"/>
<key-property name="name" column="name" type="string" length="160"/>
</composite-id>
<many-to-one name="child" column="child_id" class="AVMNodeImpl" not-null="true" foreign-key="fk_avm_ce_child"/>
</class>
<class name="HistoryLinkImpl" proxy="HistoryLink" table="avm_history_links">
<composite-id>
<key-many-to-one name="ancestor" class="AVMNodeImpl" column="ancestor" foreign-key="fk_avm_hl_ancestor"/>
<key-many-to-one name="descendent" class="AVMNodeImpl" column="descendent" foreign-key="fk_avm_hl_desc"/>
</composite-id>
</class>
<class name="MergeLinkImpl" proxy="MergeLink" table="avm_merge_links">
<composite-id>
<key-many-to-one name="mfrom" class="AVMNodeImpl" column="mfrom" foreign-key="fk_avm_ml_from"/>
<key-many-to-one name="mto" class="AVMNodeImpl" column="mto" foreign-key="fk_avm_ml_to"/>
</composite-id>
</class>
<class name="AVMNodePropertyImpl" proxy="AVMNodeProperty" table="avm_node_properties">
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<many-to-one name="node" class="AVMNodeImpl" column="node_id" foreign-key="fk_avm_np_node"/>
<property name="name" column="qname" type="QName" length="200" index="idx_avm_np_name"/>
<component class="org.alfresco.repo.domain.PropertyValue" name="value">
<property name="actualType" column="actual_type" type="string" length="15" not-null="true" />
<property name="multiValued" column="multi_valued" type="boolean" not-null="true" />
<property name="persistedType" column="persisted_type" type="string" length="15" not-null="true" />
<property name="booleanValue" column="boolean_value" type="boolean" />
<property name="longValue" column="long_value" type="long" />
<property name="floatValue" column="float_value" type="float" />
<property name="doubleValue" column="double_value" type="double" />
<property name="stringValue" column="string_value" type="string" length="1024"/>
<property name="serializableValue" column="serializable_value" type="serializable" length="16384"/>
</component>
</class>
<class name="AVMStorePropertyImpl" proxy="AVMStoreProperty" table="avm_store_properties">
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<many-to-one name="store" class="AVMStoreImpl" column="avm_store_id" foreign-key="fk_avm_sp_store"/>
<property name="name" column="qname" type="QName" length="200" index="idx_avm_sp_name"/>
<component class="org.alfresco.repo.domain.PropertyValue" name="value">
<property name="actualType" column="actual_type" type="string" length="15" not-null="true" />
<property name="multiValued" column="multi_valued" type="boolean" not-null="true" />
<property name="persistedType" column="persisted_type" type="string" length="15" not-null="true" />
<property name="booleanValue" column="boolean_value" type="boolean" />
<property name="longValue" column="long_value" type="long" />
<property name="floatValue" column="float_value" type="float" />
<property name="doubleValue" column="double_value" type="double" />
<property name="stringValue" column="string_value" type="string" length="1024"/>
<property name="serializableValue" column="serializable_value" type="serializable" length="16384"/>
</component>
</class>
<!-- Aspect name table for AVM Nodes. -->
<class name="AVMAspectNameImpl" proxy="AVMAspectName" table="avm_aspects">
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<many-to-one name="node" class="AVMNodeImpl" column="node_id" foreign-key="fk_avm_asp_node"/>
<property name="name" column="qname" type="QName" length="200"/>
</class>
<!-- When a snapshot is created we stow away all of the layered
nodes that were frozen by the snapshot so that subsequent
snapshots can find them and force copies. -->
<class name="VersionLayeredNodeEntryImpl" proxy="VersionLayeredNodeEntry"
table="avm_version_layered_node_entry">
<composite-id>
<key-many-to-one name="version" class="VersionRootImpl" column="version_root_id"/>
<key-property name="md5Sum" type="string" length="32" column="md5sum"/>
</composite-id>
<property name="path" type="string" length="512" column="path"/>
</class>
<query name="ChildEntry.DeleteByParent">
<![CDATA[
delete ChildEntryImpl ce
where ce.key.parent = :parent
]]>
</query>
<query name="AVMNode.GetNewInStore">
<![CDATA[
from AVMNodeImpl an
where an.storeNew = :store
]]>
</query>
<query name="AVMNode.GetDescendents">
<![CDATA[
select hl.descendent
from HistoryLinkImpl hl
where hl.ancestor = :node
]]>
</query>
<query name="HistoryLink.ByAncestor">
<![CDATA[
from HistoryLinkImpl hl
where hl.ancestor = :node
]]>
</query>
<query name="AVMNode.GetMergedTo">
<![CDATA[
select ml.mto
from MergeLinkImpl ml
where ml.mfrom = :merged
]]>
</query>
<query name="MergeLink.ByFrom">
<![CDATA[
from MergeLinkImpl ml
where ml.mfrom = :merged
]]>
</query>
<query name="VersionRoot.GetVersionRoot">
<![CDATA[
select v.root
from VersionRootImpl v
where
v.avmStore = :store and v.versionID = :version
]]>
</query>
<query name="VersionRoot.VersionByID">
<![CDATA[
from VersionRootImpl v
where
v.avmStore = :store and v.versionID = :version
]]>
</query>
<query name="FindOrphans">
<![CDATA[
from AVMNodeImpl an
where
an not in ( select ce.child
from ChildEntryImpl ce )
and an.isRoot = false
]]>
</query>
<query name="PlainFileNode.GetContentUrls">
<![CDATA[
select
pfn.contentURL
from
PlainFileNodeImpl pfn
where pfn.contentURL is not null
]]>
</query>
</hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="org.alfresco.repo.avm">
<typedef class="org.alfresco.repo.domain.hibernate.QNameUserType" name="QName"/>
<!-- AVMNodeBean is the abstract base for filesystem like objects.
We're using the one table per class hierarchy strategy to implement
polymorphism. -->
<class table="avm_nodes" abstract="true"
name="AVMNodeImpl"
proxy="AVMNode"
optimistic-lock="version"
lazy="true">
<cache usage="read-write"/>
<!-- The id is set programmatically using an Issuer. See below. -->
<id name="id"
column="id"
type="long"/>
<!-- I suppose this would be more efficient to encode type by an int.
We'll see if using a string makes a difference. -->
<discriminator column="class_type"
type="string"
length="20"/>
<!-- We're using hibernate's own versioning scheme for concurrency control.
I don't know how well that will play with a full Spring-JTA stack. -->
<version column="vers"
name="vers"
type="long"/>
<!-- This should really be not null, but I haven't figured out
the right way to build the relation so that nullability constraints
won't cause violations in the db during saves. -->
<property name="versionID" type="int" column="version_id"
not-null="true"/>
<property name="guid" type="string" length="36" column="guid"/>
<component name="basicAttributes" class="BasicAttributesImpl">
<property name="creator" type="string" not-null="true"/>
<property name="owner" type="string" not-null="true"/>
<property name="lastModifier" type="string" not-null="true"/>
<property name="createDate" type="long" not-null="true"/>
<property name="modDate" type="long" not-null="true"/>
<property name="accessDate" type="long" not-null="true"/>
</component>
<property name="isRoot" column="is_root" type="boolean"/>
<many-to-one name="storeNew" class="AVMStoreImpl" column="store_new_id" foreign-key="fk_avm_n_store"/>
<!-- ACL -->
<many-to-one name="acl" column="acl_id" foreign-key="fk_avm_n_acl"
class="org.alfresco.repo.domain.hibernate.DbAccessControlListImpl"/>
<set name="aspects" fetch="join" lazy="false" table="avm_aspects_new" cascade="all" optimistic-lock="true">
<cache usage="read-write"/>
<key column="id"/>
<element type="QName" not-null="true" column="name" length="200"/>
</set>
<map name="properties" fetch="join" lazy="false" table="avm_node_properties_new" cascade="all" optimistic-lock="true">
<cache usage="read-write"/>
<key column="node_id" not-null="true"/>
<map-key type="QName" length="200" column="qname"/>
<composite-element class="org.alfresco.repo.domain.PropertyValue">
<property name="actualType" column="actual_type" type="string" length="15" not-null="true" />
<property name="multiValued" column="multi_valued" type="boolean" not-null="true" />
<property name="persistedType" column="persisted_type" type="string" length="15" not-null="true" />
<property name="booleanValue" column="boolean_value" type="boolean" />
<property name="longValue" column="long_value" type="long" />
<property name="floatValue" column="float_value" type="float" />
<property name="doubleValue" column="double_value" type="double" />
<property name="stringValue" column="string_value" type="string" length="1024"/>
<property name="serializableValue" column="serializable_value" type="serializable" length="16384"/>
</composite-element>
</map>
<!-- Deleted nodes -->
<subclass name="DeletedNodeImpl"
proxy="DeletedNode"
lazy="true"
discriminator-value="deletednode">
<property name="deletedType" type="int"/>
</subclass>
<!-- Directories, two flavors. -->
<subclass name="DirectoryNodeImpl"
proxy="DirectoryNode"
abstract="true"
lazy="true">
<!-- A Layered Directory is our smart symlink thingy. -->
<subclass name="LayeredDirectoryNodeImpl"
proxy="LayeredDirectoryNode"
discriminator-value="layereddirectory" lazy="true">
<!-- The layer id is an implementation trick to disambiguate
exactly what layer is being refered to in various circumstances. -->
<property name="layerID" column="layer_id" type="long"/>
<!-- The is the moral equivalent of the value of a symlink. -->
<property name="indirection" column="indirection"
type="string" length="511" />
<property name="indirectionVersion" type="int" column="indirection_version"/>
<!-- This marks a layered directory as either knowing itself what
it points at (true) or inheriting what it points at from its
container (false). -->
<property name="primaryIndirection"
column="primary_indirection" type="boolean"/>
<property name="opacity" column="opacity" type="boolean"/>
<!-- Map of names to DirectoryEntries. -->
</subclass>
<!-- Just plain directories. -->
<subclass name="PlainDirectoryNodeImpl"
discriminator-value="plaindirectory" proxy="PlainDirectoryNode" lazy="true">
</subclass>
</subclass>
<!-- There are two kinds of files, plain and symlinky. -->
<subclass name="FileNodeImpl"
proxy="FileNode"
abstract="true"
lazy="false">
<!-- Plain files just have a reference to a Content object. -->
<subclass discriminator-value="plainfile"
name="PlainFileNodeImpl" proxy="PlainFileNode" lazy="true">
<property name="contentURL" column="content_url" type="string" length="128"/>
<property name="mimeType" column="mime_type" type="string" length="64"/>
<property name="encoding" column="encoding" type="string" length="16"/>
<property name="length" column="length" type="long"/>
</subclass>
<!-- Layered files are almost exactly copy on write symlinks. -->
<subclass name="LayeredFileNodeImpl"
discriminator-value="layeredfile" proxy="LayeredFileNode" lazy="true">
<property name="indirection" type="string" length="511"
column="indirection" />
<property name="indirectionVersion" type="int" column="indirection_version"/>
</subclass>
</subclass>
</class>
<!-- A store is the what we used to call a virtual repository. -->
<class table="avm_stores" name="AVMStoreImpl"
proxy="AVMStore" optimistic-lock="version">
<cache usage="read-write"/>
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<version name="vers" column="vers" type="long"/>
<property name="name" column="name" type="string" unique="true"/>
<property type="int" name="nextVersionID"
column="next_version_id" not-null="true"/>
<!-- Every AVMStore has a root directory that is the current root directory. -->
<many-to-one name="root" class="DirectoryNodeImpl"
column="current_root_id" cascade="save-update" foreign-key="fk_avm_s_root">
</many-to-one>
</class>
<class name="VersionRootImpl" proxy="VersionRoot" table="avm_version_roots">
<cache usage="read-write"/>
<id name="id" column="id" type="long">
<generator class="native"></generator>
</id>
<natural-id>
<property name="versionID" type="int" not-null="true"
column="version_id" index="idx_avm_vr_version">
</property>
<many-to-one name="avmStore" column="avm_store_id"
class="AVMStoreImpl" not-null="true" foreign-key="fk_avm_vr_store">
</many-to-one>
</natural-id>
<property name="createDate" type="long" not-null="true" column="create_date">
</property>
<property name="creator" type="string" column="creator"
not-null="true">
</property>
<many-to-one name="root" class="DirectoryNodeImpl"
column="root_id" not-null="true" foreign-key="fk_avm_vr_root">
</many-to-one>
<property name="tag" type="string" length="255" column="tag"/>
<property name="description" type="string" length="4000" column="description"/>
</class>
<class name="ChildEntryImpl" proxy="ChildEntry" table="avm_child_entries">
<cache usage="read-write"/>
<composite-id name="key" class="ChildKey">
<key-many-to-one name="parent" column="parent_id" class="DirectoryNodeImpl" foreign-key="fk_avm_ce_parent"/>
<key-property name="name" column="name" type="string" length="160"/>
</composite-id>
<many-to-one name="child" column="child_id" class="AVMNodeImpl" not-null="true" foreign-key="fk_avm_ce_child"/>
</class>
<class name="HistoryLinkImpl" proxy="HistoryLink" table="avm_history_links">
<composite-id>
<key-many-to-one name="ancestor" class="AVMNodeImpl" column="ancestor" foreign-key="fk_avm_hl_ancestor"/>
<key-many-to-one name="descendent" class="AVMNodeImpl" column="descendent" foreign-key="fk_avm_hl_desc"/>
</composite-id>
</class>
<class name="MergeLinkImpl" proxy="MergeLink" table="avm_merge_links">
<composite-id>
<key-many-to-one name="mfrom" class="AVMNodeImpl" column="mfrom" foreign-key="fk_avm_ml_from"/>
<key-many-to-one name="mto" class="AVMNodeImpl" column="mto" foreign-key="fk_avm_ml_to"/>
</composite-id>
</class>
<class name="AVMNodePropertyImpl" proxy="AVMNodeProperty" table="avm_node_properties">
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<many-to-one name="node" class="AVMNodeImpl" column="node_id" foreign-key="fk_avm_np_node"/>
<property name="name" column="qname" type="QName" length="200" index="idx_avm_np_name"/>
<component class="org.alfresco.repo.domain.PropertyValue" name="value">
<property name="actualType" column="actual_type" type="string" length="15" not-null="true" />
<property name="multiValued" column="multi_valued" type="boolean" not-null="true" />
<property name="persistedType" column="persisted_type" type="string" length="15" not-null="true" />
<property name="booleanValue" column="boolean_value" type="boolean" />
<property name="longValue" column="long_value" type="long" />
<property name="floatValue" column="float_value" type="float" />
<property name="doubleValue" column="double_value" type="double" />
<property name="stringValue" column="string_value" type="string" length="1024"/>
<property name="serializableValue" column="serializable_value" type="serializable" length="16384"/>
</component>
</class>
<class name="AVMStorePropertyImpl" proxy="AVMStoreProperty" table="avm_store_properties">
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<many-to-one name="store" class="AVMStoreImpl" column="avm_store_id" foreign-key="fk_avm_sp_store"/>
<property name="name" column="qname" type="QName" length="200" index="idx_avm_sp_name"/>
<component class="org.alfresco.repo.domain.PropertyValue" name="value">
<property name="actualType" column="actual_type" type="string" length="15" not-null="true" />
<property name="multiValued" column="multi_valued" type="boolean" not-null="true" />
<property name="persistedType" column="persisted_type" type="string" length="15" not-null="true" />
<property name="booleanValue" column="boolean_value" type="boolean" />
<property name="longValue" column="long_value" type="long" />
<property name="floatValue" column="float_value" type="float" />
<property name="doubleValue" column="double_value" type="double" />
<property name="stringValue" column="string_value" type="string" length="1024"/>
<property name="serializableValue" column="serializable_value" type="serializable" length="16384"/>
</component>
</class>
<!-- Aspect name table for AVM Nodes. -->
<class name="AVMAspectNameImpl" proxy="AVMAspectName" table="avm_aspects">
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<many-to-one name="node" class="AVMNodeImpl" column="node_id" foreign-key="fk_avm_asp_node"/>
<property name="name" column="qname" type="QName" length="200"/>
</class>
<!-- When a snapshot is created we stow away all of the layered
nodes that were frozen by the snapshot so that subsequent
snapshots can find them and force copies. -->
<class name="VersionLayeredNodeEntryImpl" proxy="VersionLayeredNodeEntry"
table="avm_version_layered_node_entry">
<composite-id>
<key-many-to-one name="version" class="VersionRootImpl" column="version_root_id"/>
<key-property name="md5Sum" type="string" length="32" column="md5sum"/>
</composite-id>
<property name="path" type="string" length="512" column="path"/>
</class>
<query name="ChildEntry.DeleteByParent">
<![CDATA[
delete ChildEntryImpl ce
where ce.key.parent = :parent
]]>
</query>
<query name="AVMNode.GetNewInStore">
<![CDATA[
from AVMNodeImpl an
where an.storeNew = :store
]]>
</query>
<query name="AVMNode.GetDescendents">
<![CDATA[
select hl.descendent
from HistoryLinkImpl hl
where hl.ancestor = :node
]]>
</query>
<query name="HistoryLink.ByAncestor">
<![CDATA[
from HistoryLinkImpl hl
where hl.ancestor = :node
]]>
</query>
<query name="AVMNode.GetMergedTo">
<![CDATA[
select ml.mto
from MergeLinkImpl ml
where ml.mfrom = :merged
]]>
</query>
<query name="MergeLink.ByFrom">
<![CDATA[
from MergeLinkImpl ml
where ml.mfrom = :merged
]]>
</query>
<query name="VersionRoot.GetVersionRoot">
<![CDATA[
select v.root
from VersionRootImpl v
where
v.avmStore = :store and v.versionID = :version
]]>
</query>
<query name="VersionRoot.VersionByID">
<![CDATA[
from VersionRootImpl v
where
v.avmStore = :store and v.versionID = :version
]]>
</query>
<query name="FindOrphans">
<![CDATA[
from AVMNodeImpl an
where
an not in ( select ce.child
from ChildEntryImpl ce )
and an.isRoot = false
]]>
</query>
<query name="PlainFileNode.GetContentUrls">
<![CDATA[
select
pfn.contentURL
from
PlainFileNodeImpl pfn
where pfn.contentURL is not null
]]>
</query>
</hibernate-mapping>

View File

@@ -1,178 +1,210 @@
/*
* Copyright (C) 2005-2007 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.avm.hibernate;
import java.util.Date;
import java.util.List;
import org.alfresco.repo.avm.AVMNode;
import org.alfresco.repo.avm.AVMStore;
import org.alfresco.repo.avm.VersionRoot;
import org.alfresco.repo.avm.VersionRootDAO;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
* This is the Hibernate version of the DAO for version roots.
* @author britt
*/
class VersionRootDAOHibernate extends HibernateDaoSupport implements
VersionRootDAO
{
/**
* Do nothing constructor.
*/
public VersionRootDAOHibernate()
{
super();
}
/**
* Save an unsaved VersionRoot.
* @param vr The VersionRoot to save.
*/
public void save(VersionRoot vr)
{
getSession().save(vr);
}
/**
* Delete a VersionRoot.
* @param vr The VersionRoot to delete.
*/
public void delete(VersionRoot vr)
{
getSession().delete(vr);
getSession().flush();
}
/**
* Get all the version roots in a given store.
* @param store The store.
* @return A List of VersionRoots. In id order.
*/
@SuppressWarnings("unchecked")
public List<VersionRoot> getAllInAVMStore(AVMStore store)
{
Query query = getSession().createQuery("from VersionRootImpl v where v.avmStore = :store order by v.versionID");
query.setEntity("store", store);
return (List<VersionRoot>)query.list();
}
/**
* Get the version of a store by dates.
* @param store The store.
* @param from The starting date. May be null but not with to null also.
* @param to The ending date. May be null but not with from null also.
* @return A List of VersionRoots.
*/
@SuppressWarnings("unchecked")
public List<VersionRoot> getByDates(AVMStore store, Date from, Date to)
{
Query query;
if (from == null)
{
query =
getSession().createQuery("from VersionRootImpl vr where vr.createDate <= :to " +
"and vr.avmStore = :store " +
"order by vr.versionID");
query.setLong("to", to.getTime());
}
else if (to == null)
{
query =
getSession().createQuery("from VersionRootImpl vr " +
"where vr.createDate >= :from " +
"and vr.avmStore = :store " +
"order by vr.versionID");
query.setLong("from", from.getTime());
}
else
{
query =
getSession().createQuery("from VersionRootImpl vr "+
"where vr.createDate between :from and :to " +
"and vr.avmStore = :store " +
"order by vr.versionID");
query.setLong("from", from.getTime());
query.setLong("to", to.getTime());
}
query.setEntity("store", store);
return (List<VersionRoot>)query.list();
}
/**
* Get the VersionRoot corresponding to the given id.
* @param store The store
* @param id The version id.
* @return The VersionRoot or null if not found.
*/
public VersionRoot getByVersionID(AVMStore store, int id)
{
Query query = getSession().getNamedQuery("VersionRoot.VersionByID");
query.setEntity("store", store);
query.setInteger("version", id);
return (VersionRoot)query.uniqueResult();
}
/**
* Get one from its root.
* @param root The root to match.
* @return The version root or null.
*/
public VersionRoot getByRoot(AVMNode root)
{
Query query = getSession().createQuery("from VersionRootImpl vr " +
"where vr.root = :root");
query.setEntity("root", root);
return (VersionRoot)query.uniqueResult();
}
/**
* Get the highest numbered version in a repository.
* @param rep The repository.
* @return The highest numbered version.
*/
public VersionRoot getMaxVersion(AVMStore rep)
{
Query query = getSession().createQuery("from VersionRootImpl vr " +
"where vr.avmStore = :store and vr.versionID = " +
"(select max(v.versionID) from VersionRootImpl v where v.avmStore = :store)");
query.setEntity("store", rep);
return (VersionRoot)query.uniqueResult();
}
/**
* Get the highest numbered id from all the versions in a store.
* @param store The store.
* @return The highest numbered id.
*/
public Integer getMaxVersionID(AVMStore store)
{
Query query = getSession().createQuery("select max(vr.versionID) from VersionRootImpl vr " +
"where vr.avmStore = :store");
query.setEntity("store", store);
return (Integer)query.uniqueResult();
}
}
/*
* Copyright (C) 2005-2007 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.avm.hibernate;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import org.alfresco.repo.avm.AVMNode;
import org.alfresco.repo.avm.AVMStore;
import org.alfresco.repo.avm.VersionRoot;
import org.alfresco.repo.avm.VersionRootImpl;
import org.alfresco.repo.avm.VersionRootDAO;
import org.alfresco.util.Pair;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
* This is the Hibernate version of the DAO for version roots.
* @author britt
*/
class VersionRootDAOHibernate extends HibernateDaoSupport implements
VersionRootDAO
{
private LinkedHashMap<Pair<Long, Integer>, Long> fCache;
/**
* Do nothing constructor.
*/
public VersionRootDAOHibernate()
{
super();
fCache = new LinkedHashMap<Pair<Long, Integer>, Long>();
}
/**
* Save an unsaved VersionRoot.
* @param vr The VersionRoot to save.
*/
public void save(VersionRoot vr)
{
getSession().save(vr);
}
/**
* Delete a VersionRoot.
* @param vr The VersionRoot to delete.
*/
public void delete(VersionRoot vr)
{
getSession().delete(vr);
getSession().flush();
}
/**
* Get all the version roots in a given store.
* @param store The store.
* @return A List of VersionRoots. In id order.
*/
@SuppressWarnings("unchecked")
public List<VersionRoot> getAllInAVMStore(AVMStore store)
{
Query query = getSession().createQuery("from VersionRootImpl v where v.avmStore = :store order by v.versionID");
query.setEntity("store", store);
return (List<VersionRoot>)query.list();
}
/**
* Get the version of a store by dates.
* @param store The store.
* @param from The starting date. May be null but not with to null also.
* @param to The ending date. May be null but not with from null also.
* @return A List of VersionRoots.
*/
@SuppressWarnings("unchecked")
public List<VersionRoot> getByDates(AVMStore store, Date from, Date to)
{
Query query;
if (from == null)
{
query =
getSession().createQuery("from VersionRootImpl vr where vr.createDate <= :to " +
"and vr.avmStore = :store " +
"order by vr.versionID");
query.setLong("to", to.getTime());
}
else if (to == null)
{
query =
getSession().createQuery("from VersionRootImpl vr " +
"where vr.createDate >= :from " +
"and vr.avmStore = :store " +
"order by vr.versionID");
query.setLong("from", from.getTime());
}
else
{
query =
getSession().createQuery("from VersionRootImpl vr "+
"where vr.createDate between :from and :to " +
"and vr.avmStore = :store " +
"order by vr.versionID");
query.setLong("from", from.getTime());
query.setLong("to", to.getTime());
}
query.setEntity("store", store);
return (List<VersionRoot>)query.list();
}
/**
* Get the VersionRoot corresponding to the given id.
* @param store The store
* @param id The version id.
* @return The VersionRoot or null if not found.
*/
public synchronized VersionRoot getByVersionID(AVMStore store, int id)
{
Long vID = fCache.get(new Pair<Long, Integer>(store.getId(), id));
if (vID != null)
{
VersionRoot root = (VersionRoot)getSession().get(VersionRootImpl.class, vID);
if (root != null)
{
return root;
}
fCache.remove(new Pair<Long, Integer>(store.getId(), id));
}
Query query = getSession().getNamedQuery("VersionRoot.VersionByID");
query.setEntity("store", store);
query.setInteger("version", id);
VersionRoot root = (VersionRoot)query.uniqueResult();
if (root != null)
{
vID = root.getId();
if (vID != null)
{
if (fCache.size() >= 10)
{
Iterator<Pair<Long, Integer>> iter = fCache.keySet().iterator();
iter.next();
iter.remove();
}
fCache.put(new Pair<Long, Integer>(store.getId(), id), vID);
}
}
return root;
}
/**
* Get one from its root.
* @param root The root to match.
* @return The version root or null.
*/
public VersionRoot getByRoot(AVMNode root)
{
Query query = getSession().createQuery("from VersionRootImpl vr " +
"where vr.root = :root");
query.setEntity("root", root);
return (VersionRoot)query.uniqueResult();
}
/**
* Get the highest numbered version in a repository.
* @param rep The repository.
* @return The highest numbered version.
*/
public VersionRoot getMaxVersion(AVMStore rep)
{
Query query = getSession().createQuery("from VersionRootImpl vr " +
"where vr.avmStore = :store and vr.versionID = " +
"(select max(v.versionID) from VersionRootImpl v where v.avmStore = :store)");
query.setEntity("store", rep);
return (VersionRoot)query.uniqueResult();
}
/**
* Get the highest numbered id from all the versions in a store.
* @param store The store.
* @return The highest numbered id.
*/
public Integer getMaxVersionID(AVMStore store)
{
Query query = getSession().createQuery("select max(vr.versionID) from VersionRootImpl vr " +
"where vr.avmStore = :store");
query.setEntity("store", store);
return (Integer)query.uniqueResult();
}
}

View File

@@ -264,7 +264,7 @@ public class AVMLockingServiceImpl implements AVMLockingService
keys.add(lock.getWebProject());
String digest = MD5.Digest(lock.getPath().getBytes());
keys.add(digest);
if (fAttributeService.getAttribute(keys) != null)
if (fAttributeService.exists(keys))
{
throw new AVMExistsException("Lock Exists: " + keys);
}
@@ -316,8 +316,7 @@ public class AVMLockingServiceImpl implements AVMLockingService
keys.add(WEB_PROJECTS);
keys.add(webProject);
keys.add(pathKey);
Attribute lockData = fAttributeService.getAttribute(keys);
if (lockData == null)
if (!fAttributeService.exists(keys))
{
return;
}

View File

@@ -34,6 +34,7 @@ import java.util.Map;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.avm.AVMException;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.namespace.QName;
/**
@@ -78,7 +79,7 @@ public class BulkLoader
Map<QName, PropertyValue> props = new HashMap<QName, PropertyValue>();
for (int i = 0; i < fPropertyCount; i++)
{
props.put(QName.createQName("silly", "prop" + i), new PropertyValue(null, "I am property " + i));
props.put(QName.createQName("silly", "prop" + i), new PropertyValue(DataTypeDefinition.TEXT, "I am property " + i));
}
File file = new File(fsPath);
String name = file.getName();

View File

@@ -249,30 +249,16 @@ public class XPathMetadataExtracter extends AbstractMappingMetadataExtracter imp
{
String documentProperty = element.getKey();
XPathExpression xpathExpression = element.getValue();
// Execute it
NodeList nodeList = (NodeList) xpathExpression.evaluate(document, XPathConstants.NODESET);
// Convert the value
// Get the value, assuming it is a nodeset
Serializable value = null;
int nodeCount = nodeList.getLength();
if (nodeCount == 0)
try
{
// No result
value = getNodeSetValue(document, xpathExpression);
}
else if (nodeCount == 1)
catch (XPathExpressionException e)
{
Node node = nodeList.item(0);
// Get the string value
value = node.getTextContent();
}
else
{
// Make a collection of the values
ArrayList<String> stringValues = new ArrayList<String>(5);
for (int i = 0; i < nodeCount; i++)
{
stringValues.add(nodeList.item(i).getTextContent());
}
value = stringValues;
// That didn't work, so give it a try as a STRING
value = getStringValue(document, xpathExpression);
}
// Put the value
rawProperties.put(documentProperty, value);
@@ -281,6 +267,57 @@ public class XPathMetadataExtracter extends AbstractMappingMetadataExtracter imp
return rawProperties;
}
private Serializable getStringValue(Document document, XPathExpression xpathExpression) throws XPathExpressionException
{
String value = (String) xpathExpression.evaluate(document, XPathConstants.STRING);
// Done
return value;
}
private Serializable getNodeSetValue(Document document, XPathExpression xpathExpression) throws XPathExpressionException
{
// Execute it
NodeList nodeList = null;
try
{
nodeList = (NodeList) xpathExpression.evaluate(document, XPathConstants.NODESET);
}
catch (XPathExpressionException e)
{
// Expression didn't evaluate to a nodelist
if (logger.isDebugEnabled())
{
logger.debug("Unable to evaluate expression and return a NODESET: " + xpathExpression);
}
throw e;
}
// Convert the value
Serializable value = null;
int nodeCount = nodeList.getLength();
if (nodeCount == 0)
{
// No result
}
else if (nodeCount == 1)
{
Node node = nodeList.item(0);
// Get the string value
value = node.getTextContent();
}
else
{
// Make a collection of the values
ArrayList<String> stringValues = new ArrayList<String>(5);
for (int i = 0; i < nodeCount; i++)
{
stringValues.add(nodeList.item(i).getTextContent());
}
value = stringValues;
}
// Done
return value;
}
/**
* A utility method to convert mapping properties to the Map form.
*

View File

@@ -600,6 +600,23 @@ public class FileFolderServiceImpl implements FileFolderService
NamespaceService.CONTENT_MODEL_1_0_URI,
QName.createValidLocalName(newName));
QName targetParentType = nodeService.getType(targetParentRef);
// Fix AWC-1517
QName assocTypeQname = null;
if (dictionaryService.isSubClass(targetParentType, ContentModel.TYPE_FOLDER))
{
assocTypeQname = ContentModel.ASSOC_CONTAINS; // cm:folder -> cm:contains
}
else if (dictionaryService.isSubClass(targetParentType, ContentModel.TYPE_CONTAINER))
{
assocTypeQname = ContentModel.ASSOC_CHILDREN; // sys:container -> sys:children
}
else
{
throw new InvalidTypeException("Unexpected type (" + targetParentType + ") for target parent: " + targetParentRef);
}
// move or copy
NodeRef targetNodeRef = null;
if (move)
@@ -611,7 +628,7 @@ public class FileFolderServiceImpl implements FileFolderService
ChildAssociationRef newAssocRef = nodeService.moveNode(
sourceNodeRef,
targetParentRef,
assocRef.getTypeQName(),
assocTypeQname,
qname);
targetNodeRef = newAssocRef.getChildRef();
}
@@ -629,7 +646,7 @@ public class FileFolderServiceImpl implements FileFolderService
targetNodeRef = copyService.copy(
sourceNodeRef,
targetParentRef,
assocRef.getTypeQName(),
assocTypeQname,
qname,
true);
}

View File

@@ -31,6 +31,7 @@ import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.QName;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
@@ -84,7 +85,8 @@ public class MLContentInterceptor implements MethodInterceptor
NodeRef nodeRef = (NodeRef) args[0];
// Shortcut it if the node is not an empty translation
if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
if (nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM) ||
!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
{
return invocation.proceed();
}

View File

@@ -40,6 +40,7 @@ import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.MLText;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.EqualsHelper;
@@ -251,7 +252,7 @@ public class MLPropertyInterceptor implements MethodInterceptor
*/
private NodeRef getPivotNodeRef(NodeRef nodeRef)
{
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
if (!nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM) && nodeService.hasAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
{
return multilingualContentService.getPivotTranslation(nodeRef);
}

View File

@@ -355,7 +355,7 @@ public class ArchiveAndRestoreTest extends TestCase
verifyNodeExistence(bb_, true);
// flush
AlfrescoTransactionSupport.flush();
//AlfrescoTransactionSupport.flush();
// check that the required properties are present and correct
Map<QName, Serializable> bb_Properties = nodeService.getProperties(bb_);
@@ -383,7 +383,7 @@ public class ArchiveAndRestoreTest extends TestCase
verifyChildAssocExistence(childAssocBtoBB_, true);
// flush
AlfrescoTransactionSupport.flush();
//AlfrescoTransactionSupport.flush();
// restore the node
nodeService.restoreNode(b_, null, null, null);
@@ -398,7 +398,7 @@ public class ArchiveAndRestoreTest extends TestCase
nodeService.deleteNode(a);
// flush
AlfrescoTransactionSupport.flush();
//AlfrescoTransactionSupport.flush();
// restore in reverse order
nodeService.restoreNode(a_, null, null, null);
@@ -414,7 +414,7 @@ public class ArchiveAndRestoreTest extends TestCase
nodeService.deleteNode(b);
// flush
AlfrescoTransactionSupport.flush();
//AlfrescoTransactionSupport.flush();
// restore in reverse order
nodeService.restoreNode(b_, null, null, null);
@@ -430,7 +430,7 @@ public class ArchiveAndRestoreTest extends TestCase
nodeService.deleteNode(b);
// flush
AlfrescoTransactionSupport.flush();
//AlfrescoTransactionSupport.flush();
// in restoring 'a' first, there will be some associations that won't be recreated
nodeService.restoreNode(a_, null, null, null);
@@ -486,7 +486,7 @@ public class ArchiveAndRestoreTest extends TestCase
cumulatedArchiveTimeNs += (end - start);
// flush
AlfrescoTransactionSupport.flush();
//AlfrescoTransactionSupport.flush();
// now restore
start = System.nanoTime();

View File

@@ -29,7 +29,6 @@ import java.lang.reflect.Method;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.node.BaseNodeServiceTest;
import org.alfresco.repo.node.db.DbNodeServiceImpl;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.TransactionResourceInterceptor;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
@@ -53,7 +52,7 @@ public class SessionSizeManagementTest extends BaseNodeServiceTest
{
try
{
Class clazz = SessionSizeManagementTest.class;
Class<SessionSizeManagementTest> clazz = SessionSizeManagementTest.class;
createNodesMethod = clazz.getMethod(
"createNodes",
new Class[] {NodeService.class, Integer.TYPE, Boolean.TYPE});
@@ -118,9 +117,6 @@ public class SessionSizeManagementTest extends BaseNodeServiceTest
NodeService nodeService = getNodeService();
createNodes(nodeService, LOAD_COUNT, false);
// We can't check the session size as this is dependent on machine speed
// Now flush integrity to be sure things are not broken
AlfrescoTransactionSupport.flush();
}
/**
@@ -136,8 +132,5 @@ public class SessionSizeManagementTest extends BaseNodeServiceTest
}
createNodes(nodeService, LOAD_COUNT, true);
// Now flush integrity to be sure things are not broken
AlfrescoTransactionSupport.flush();
}
}

View File

@@ -1,5 +1,6 @@
package org.alfresco.repo.node.index;
import java.util.LinkedHashMap;
import java.util.List;
import org.alfresco.repo.node.index.FullIndexRecoveryComponent.RecoveryMode;
@@ -50,15 +51,13 @@ public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
{
this.lockServer = lockServer;
}
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
public void setAvmSnapShotTriggeredIndexingMethodInterceptor(
AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor)
public void setAvmSnapShotTriggeredIndexingMethodInterceptor(AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor)
{
this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor;
}
@@ -72,77 +71,180 @@ public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
private void processStores()
{
List<AVMStoreDescriptor> stores = avmService.getStores();
if(stores.size() == 0)
LinkedHashMap<String, RecoveryMode> actions = new LinkedHashMap<String, RecoveryMode>();
if (stores.size() == 0)
{
return;
}
int count = 0;
int tracker = -1;
logger.info("Checking indexes for AVM Stores");
for (AVMStoreDescriptor store : stores)
switch (recoveryMode)
{
if (isShuttingDown())
case AUTO:
case VALIDATE:
int count = 0;
int tracker = -1;
if (logger.isDebugEnabled())
{
return;
logger.debug("Checking indexes for AVM Stores: " + recoveryMode);
}
processStore(store.getName());
count++;
if (count*10l/stores.size() > tracker)
{
tracker = (int)(count*10l/stores.size());
logger.info(" Stores "+(tracker*10)+"% complete");
for (AVMStoreDescriptor store : stores)
{
if (isShuttingDown())
{
return;
}
actions.put(store.getName(), checkStore(store.getName()));
count++;
if (count * 10l / stores.size() > tracker)
{
tracker = (int) (count * 10l / stores.size());
if (logger.isDebugEnabled())
{
logger.debug(" Store check " + (tracker * 10) + "% complete");
}
}
}
if (logger.isDebugEnabled())
{
logger.debug("Finished checking indexes for AVM Stores");
}
break;
case FULL:
case NONE:
for (AVMStoreDescriptor store : stores)
{
if (isShuttingDown())
{
return;
}
actions.put(store.getName(), checkStore(store.getName()));
}
break;
default:
}
int full = 0;
int auto = 0;
int invalid = 0;
for (String store : actions.keySet())
{
RecoveryMode mode = actions.get(store);
switch (mode)
{
case AUTO:
auto++;
break;
case FULL:
full++;
break;
case VALIDATE:
invalid++;
break;
case NONE:
default:
}
}
logger.info("Finished checking indexes for AVM Stores");
if (recoveryMode != RecoveryMode.NONE)
{
if (logger.isDebugEnabled())
{
logger.debug("Invalid indexes: " + invalid);
logger.debug("Indexes for full rebuild: " + full);
logger.debug("Indexes for auto update: " + auto);
}
}
int count = 0;
int tracker = -1;
int total = full + auto;
if (total > 0)
{
logger.info("Rebuilding indexes for " + total + " AVM Stores");
for (String store : actions.keySet())
{
RecoveryMode mode = actions.get(store);
if (isShuttingDown())
{
return;
}
if ((mode == RecoveryMode.FULL) || (mode == RecoveryMode.AUTO))
{
processStore(store, mode);
count++;
}
if (count * 10l / total > tracker)
{
tracker = (int) (count * 10l / total);
logger.info(" Reindex " + (tracker * 10) + "% complete");
}
}
logger.info("Finished rebuilding indexes for AVM Stores");
}
}
private void processStore(String store)
private RecoveryMode checkStore(String store)
{
if (logger.isDebugEnabled())
{
logger.debug("Performing AVM index recovery for type: " + recoveryMode + " on store " + store);
logger.debug("Checking AVM store for index recovery: " + recoveryMode + " on store " + store);
}
// do we just ignore
if (recoveryMode == RecoveryMode.NONE)
{
return;
return RecoveryMode.NONE;
}
// check the level of cover required
boolean fullRecoveryRequired = false;
// Nothing to do for unindexed stores
if (avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(store) == IndexMode.UNINDEXED)
{
if (!avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated(store))
{
logger.warn(" Index for avm store " + store + " is out of date");
return recoveryMode;
}
else
{
return RecoveryMode.NONE;
}
}
if (recoveryMode == RecoveryMode.FULL) // no validate required
{
fullRecoveryRequired = true;
return RecoveryMode.FULL;
}
else
// validate first
{
if(avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(store) == IndexMode.UNINDEXED)
if (!avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated(store))
{
return;
logger.warn(" Index for avm store " + store + " is out of date");
return recoveryMode;
}
int lastActualSnapshotId = avmService.getLatestSnapshotID(store);
if (lastActualSnapshotId <= 0)
{
return;
return RecoveryMode.NONE;
}
int lastIndexedSnapshotId = avmSnapShotTriggeredIndexingMethodInterceptor.getLastIndexedSnapshot(store);
if (lastActualSnapshotId != lastIndexedSnapshotId)
{
logger.warn("Index for avm store " + store + " is out of date");
// this store isn't up to date
if (recoveryMode == RecoveryMode.VALIDATE)
{
// the store is out of date - validation failed
}
else if (recoveryMode == RecoveryMode.AUTO)
{
fullRecoveryRequired = true;
}
logger.warn(" Index for avm store " + store + " is out of date");
return recoveryMode;
}
else
{
return recoveryMode.NONE;
}
}
}
private void processStore(String store, RecoveryMode mode)
{
// put the server into read-only mode for the duration
boolean allowWrite = !transactionService.isReadOnly();
try
@@ -153,11 +255,8 @@ public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
transactionService.setAllowWrite(false);
}
// do we need to perform a full recovery
if (fullRecoveryRequired)
{
recoverStore(store);
}
recoverStore(store, mode);
}
finally
{
@@ -167,56 +266,97 @@ public class AVMFullIndexRecoveryComponent extends AbstractReindexComponent
}
private void recoverStore(String store)
private void recoverStore(String store, RecoveryMode mode)
{
int tracker = -1;
int latest = avmService.getLatestSnapshotID(store);
if(latest <= 0)
if (mode == RecoveryMode.AUTO)
{
return;
logger.info(" Auto recovering index for " + store);
}
logger.info("Recovery for "+store);
if(!avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated(store))
else if (mode == RecoveryMode.FULL)
{
logger.info(" Rebuilding index for " + store);
}
if (!avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated(store))
{
avmSnapShotTriggeredIndexingMethodInterceptor.createIndex(store);
}
for (int i = 0; i <= latest; i++)
int latest = avmService.getLatestSnapshotID(store);
if (latest <= 0)
{
if (isShuttingDown())
return;
}
boolean wasRecovered = false;
if (avmSnapShotTriggeredIndexingMethodInterceptor.getIndexMode(store) != IndexMode.UNINDEXED)
{
for (int i = 0; i <= latest; i++)
{
return;
}
recoverSnapShot(store, i);
if (i*10l/latest > tracker)
{
tracker = (int)(i*10l/latest);
logger.info(" Store "+store +" "+(tracker*10)+"% complete");
if (isShuttingDown())
{
return;
}
wasRecovered = recoverSnapShot(store, i, mode, wasRecovered);
if (i * 10l / latest > tracker)
{
tracker = (int) (i * 10l / latest);
if (logger.isDebugEnabled())
{
logger.debug(" Store " + store + " " + (tracker * 10) + "% complete");
}
}
}
}
logger.info("Recovery for "+store+" done");
if (logger.isDebugEnabled())
{
logger.debug(" Index updated for " + store);
}
}
private void recoverSnapShot(final String store, final int id)
private boolean recoverSnapShot(final String store, final int id, final RecoveryMode mode, final boolean wasRecovered)
{
if (logger.isDebugEnabled())
{
logger.debug("Reindexing avm store: " + store + " snapshot id " + id);
logger.debug(" Reindexing avm store: " + store + " snapshot id " + id);
}
RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
RetryingTransactionCallback<Boolean> reindexWork = new RetryingTransactionCallback<Boolean>()
{
public Object execute() throws Exception
public Boolean execute() throws Exception
{
if (!avmSnapShotTriggeredIndexingMethodInterceptor.isSnapshotIndexed(store, id))
if (wasRecovered)
{
avmSnapShotTriggeredIndexingMethodInterceptor.indexSnapshot(store, id - 1, id);
return true;
}
// done
return null;
else
{
if (mode == RecoveryMode.AUTO)
{
if (!avmSnapShotTriggeredIndexingMethodInterceptor.isSnapshotIndexed(store, id))
{
avmSnapShotTriggeredIndexingMethodInterceptor.indexSnapshot(store, id - 1, id);
return true;
}
else
{
return wasRecovered;
}
}
else
{
avmSnapShotTriggeredIndexingMethodInterceptor.indexSnapshot(store, id - 1, id);
return true;
}
}
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true, true);
return transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true, true);
// done
}

View File

@@ -0,0 +1,129 @@
/*
* Copyright (C) 2005-2007 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.node.index;
import java.util.List;
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Track and update when snapshots are created and indexed in a cluster
*/
public class AVMRemoteSnapshotTracker extends AbstractReindexComponent
{
private static Log logger = LogFactory.getLog(AVMRemoteSnapshotTracker.class);
private AVMService avmService;
private AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor;
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
public void setAvmSnapShotTriggeredIndexingMethodInterceptor(AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor)
{
this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor;
}
@Override
protected void reindexImpl()
{
processStores();
}
/**
* Loop throught the avm stores and compare the latest snapshot to that in the index.
* Update the index if it has fallen behind.
*
*/
private void processStores()
{
List<AVMStoreDescriptor> stores = avmService.getStores();
if (stores.size() == 0)
{
return;
}
boolean upToDate;
do
{
upToDate = true;
for (AVMStoreDescriptor store : stores)
{
if (isShuttingDown())
{
break;
}
int current = avmService.getLatestSnapshotID(store.getName());
int lastIndexed = avmSnapShotTriggeredIndexingMethodInterceptor.getLastIndexedSnapshot(store.getName());
if (lastIndexed < current)
{
if(logger.isDebugEnabled())
{
logger.debug("Updating index for store "+store.getName()+" from snapshot "+lastIndexed+ " to "+current);
}
recoverSnapShot(store.getName(), lastIndexed, current);
upToDate = false;
}
}
}
while(!upToDate);
}
/**
* Do the index update in one lump (not individual snapshots)
*
* @param store
* @param lastIndexed
* @param current
*/
private void recoverSnapShot(final String store, final int lastIndexed, final int current)
{
RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
if(lastIndexed == -1)
{
avmSnapShotTriggeredIndexingMethodInterceptor.createIndex(store);
}
avmSnapShotTriggeredIndexingMethodInterceptor.indexSnapshot(store, lastIndexed, current);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true);
}
}

View File

@@ -0,0 +1,206 @@
/*
* Copyright (C) 2005-2007 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.node.index;
import javax.transaction.Status;
import javax.transaction.UserTransaction;
import org.alfresco.repo.content.ContentStore;
import org.alfresco.repo.node.db.NodeDaoService;
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor;
import org.alfresco.repo.search.Indexer;
import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.TransactionServiceImpl;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.BaseSpringTest;
/**
* Test that the index tracker catches up
*
* @author andyh
*/
public class AVMRemoteSnapshotTrackerTest extends BaseSpringTest
{
private AuthenticationComponent authenticationComponent;
private AVMService avmService;
private AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor;
private TransactionService transactionService;
private UserTransaction testTX;
private SearchService searchService;
private NodeService nodeService;
private FullTextSearchIndexer ftsIndexer;
private Indexer indexer;
private NodeDaoService nodeDaoService;
public AVMRemoteSnapshotTrackerTest()
{
// TODO Auto-generated constructor stub
}
@Override
protected void onSetUpInTransaction() throws Exception
{
super.onSetUpInTransaction();
ServiceRegistry serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
avmService = (AVMService) applicationContext.getBean("AVMService");
avmSnapShotTriggeredIndexingMethodInterceptor = (AVMSnapShotTriggeredIndexingMethodInterceptor) applicationContext.getBean("avmSnapShotTriggeredIndexingMethodInterceptor");
transactionService = (TransactionService) applicationContext.getBean("transactionComponent");
searchService = serviceRegistry.getSearchService();
nodeService = serviceRegistry.getNodeService();
ftsIndexer = (FullTextSearchIndexer) applicationContext.getBean("LuceneFullTextSearchIndexer");
indexer = (Indexer) applicationContext.getBean("indexerComponent");
nodeDaoService = (NodeDaoService) applicationContext.getBean("nodeDaoService");
testTX = transactionService.getUserTransaction();
testTX.begin();
authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
authenticationComponent.setSystemUserAsCurrentUser();
}
@Override
protected void onTearDownInTransaction() throws Exception
{
if (testTX.getStatus() == Status.STATUS_ACTIVE)
{
testTX.rollback();
}
try
{
authenticationComponent.clearCurrentSecurityContext();
}
catch (Throwable e)
{
// do nothing
}
super.onTearDownInTransaction();
}
public void testCatchUp()
{
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("one"));
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("two"));
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("three"));
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("four"));
// initial state
avmService.createStore("one");
//assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("one"));
avmService.createDirectory("one:/", "a");
avmService.createSnapshot("one", null, null);
avmService.createStore("two");
avmService.createDirectory("two:/", "a");
avmService.createStore("three");
// Check state
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("one"));
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("one"));
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("two"));
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("two"));
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("three"));
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("three"));
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("four"));
// Disable the indexer and do updates
avmSnapShotTriggeredIndexingMethodInterceptor.setEnableIndexing(false);
// one unchanged
// two snap shot
avmService.createSnapshot("two", null, null);
// three update and snapshot
avmService.createDirectory("three:/", "a");
avmService.createSnapshot("three", null, null);
// four create
avmService.createStore("four");
avmService.createDirectory("four:/", "a");
avmService.createSnapshot("four", null, null);
avmService.createDirectory("four:/", "b");
avmService.createSnapshot("four", null, null);
//
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("one"));
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("one"));
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("two"));
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("two"));
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("three"));
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("three"));
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("four"));
assertFalse(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("four"));
avmSnapShotTriggeredIndexingMethodInterceptor.setEnableIndexing(true);
AVMRemoteSnapshotTracker tracker = new AVMRemoteSnapshotTracker();
tracker.setAuthenticationComponent(authenticationComponent);
tracker.setAvmService(avmService);
tracker.setAvmSnapShotTriggeredIndexingMethodInterceptor(avmSnapShotTriggeredIndexingMethodInterceptor);
tracker.setTransactionService((TransactionServiceImpl) transactionService);
tracker.setFtsIndexer(ftsIndexer);
tracker.setIndexer(indexer);
tracker.setNodeDaoService(nodeDaoService);
tracker.setNodeService(nodeService);
tracker.setSearcher(searchService);
tracker.reindex();
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("one"));
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("one"));
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("two"));
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("two"));
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("three"));
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("three"));
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.hasIndexBeenCreated("four"));
assertTrue(avmSnapShotTriggeredIndexingMethodInterceptor.isIndexUpToDate("four"));
}
}

View File

@@ -469,6 +469,7 @@ public class AVMSnapShotTriggeredIndexingMethodInterceptor implements MethodInte
if (indexer instanceof AVMLuceneIndexer)
{
AVMLuceneIndexer avmIndexer = (AVMLuceneIndexer) indexer;
avmIndexer.flushPending();
return avmIndexer.hasIndexBeenCreated(store);
}
return false;

View File

@@ -1545,16 +1545,30 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<String> impl
}
}
public boolean hasIndexBeenCreated(String store)
{
IndexReader mainReader = null;
return hasIndexBeenCreatedimpl(store, IndexChannel.MAIN) || hasIndexBeenCreatedimpl(store, IndexChannel.DELTA);
}
public boolean hasIndexBeenCreatedimpl(String store, IndexChannel channel)
{
IndexReader reader = null;
try
{
mainReader = getReader();
if (channel == IndexChannel.DELTA)
{
flushPending();
reader = getDeltaReader();
}
else
{
reader = getReader();
}
TermDocs termDocs = null;
try
{
termDocs = mainReader.termDocs(new Term("ISROOT", "T"));
termDocs = reader.termDocs(new Term("ISROOT", "T"));
return termDocs.next();
}
finally
@@ -1573,9 +1587,17 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<String> impl
{
try
{
if (mainReader != null)
if (reader != null)
{
mainReader.close();
if (channel == IndexChannel.DELTA)
{
closeDeltaReader();
}
else
{
reader.close();
}
}
}
catch (IOException e)

View File

@@ -35,7 +35,6 @@ import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.node.integrity.IntegrityChecker;
import org.alfresco.repo.search.impl.lucene.LuceneIndexerAndSearcher;
import org.alfresco.service.cmr.rule.RuleService;
import org.alfresco.util.GUID;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -352,22 +351,13 @@ public abstract class AlfrescoTransactionSupport
}
/**
* Flush in-transaction resources. A transaction must be active.
* <p>
* The flush may include:
* <ul>
* <li>{@link TransactionalDao#flush()}</li>
* <li>{@link RuleService#executePendingRules()}</li>
* <li>{@link IntegrityChecker#checkIntegrity()}</li>
* </ul>
*
* No-op
*
* @deprecated No longer does anything
*/
public static void flush()
{
// get transaction-local synchronization
TransactionSynchronizationImpl synch = getSynchronization();
// flush
synch.flush();
// No-op
}
/**
@@ -548,15 +538,6 @@ public abstract class AlfrescoTransactionSupport
return sb.toString();
}
/**
* Performs the in-transaction flushing. Typically done during a transaction or
* before commit.
*/
public void flush()
{
throw new UnsupportedOperationException("Manual flush no longer supported.");
}
/**
* @see AlfrescoTransactionSupport#SESSION_SYNCHRONIZATION_ORDER
*/
@@ -589,7 +570,7 @@ public abstract class AlfrescoTransactionSupport
/**
* Pre-commit cleanup.
* <p>
* Ensures that the session resources are {@link #flush() flushed}.
* Ensures that the session transaction listeners are property executed.
* The Lucene indexes are then prepared.
*/
@Override

View File

@@ -157,10 +157,6 @@ public class AlfrescoTransactionSupportTest extends TestCase
// register it
AlfrescoTransactionSupport.bindListener(listener);
// test flush
AlfrescoTransactionSupport.flush();
assertTrue("flush not called on listener", strings.contains("flush"));
// test commit
txn.commit();
assertTrue("beforeCommit not called on listener", strings.contains("beforeCommit"));

View File

@@ -34,11 +34,7 @@ package org.alfresco.repo.transaction;
public interface TransactionListener
{
/**
* Allows the listener to flush any consuming resources. This mechanism is
* used primarily during long-lived transactions to ensure that system resources
* are not used up.
* <p>
* This method must not be used for implementing business logic.
* @deprecated No longer supported
*/
void flush();