Changed signature of AVMRepository.getAVMStoreByName() to get rid of

unused and misleading parameter.  Fixed PlainFileNodeImpl copy from 
LayeredFileNode constructor so that properties will be correctly copied.
Switched out the GPL mysql driver that I had been inadvertantly using.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3378 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-07-22 17:35:56 +00:00
parent a6fc3aef83
commit 1125926c90
6 changed files with 59 additions and 52 deletions

View File

@@ -1,5 +1,5 @@
# Database specifics. # Database specifics.
db.driver=com.mysql.jdbc.Driver db.driver=org.gjt.mm.mysql.Driver
db.url=jdbc:mysql://127.0.0.1/avm db.url=jdbc:mysql://127.0.0.1/avm
db.username=root db.username=root
db.password= db.password=

View File

@@ -1,5 +1,5 @@
# Database specifics. # Database specifics.
db.driver=com.mysql.jdbc.Driver db.driver=org.gjt.mm.mysql.Driver
db.url=jdbc:mysql://127.0.0.1/avm db.url=jdbc:mysql://127.0.0.1/avm
db.username=root db.username=root
db.password= db.password=

View File

@@ -96,7 +96,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String[] pathParts = SplitPath(path); String[] pathParts = SplitPath(path);
AVMStore rep = getAVMStoreByName(pathParts[0], true); AVMStore rep = getAVMStoreByName(pathParts[0]);
// fSession.get().lock(rep, LockMode.UPGRADE); // fSession.get().lock(rep, LockMode.UPGRADE);
return rep.createFile(pathParts[1], name); return rep.createFile(pathParts[1], name);
} }
@@ -111,7 +111,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String[] pathParts = SplitPath(path); String[] pathParts = SplitPath(path);
AVMStore rep = getAVMStoreByName(pathParts[0], true); AVMStore rep = getAVMStoreByName(pathParts[0]);
rep.createFile(pathParts[1], name, data); rep.createFile(pathParts[1], name, data);
} }
@@ -124,7 +124,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String[] pathParts = SplitPath(path); String[] pathParts = SplitPath(path);
AVMStore rep = getAVMStoreByName(pathParts[0], true); AVMStore rep = getAVMStoreByName(pathParts[0]);
rep.createDirectory(pathParts[1], name); rep.createDirectory(pathParts[1], name);
} }
@@ -143,7 +143,7 @@ class AVMRepository
} }
fLookupCount.set(1); fLookupCount.set(1);
String[] pathParts = SplitPath(dstPath); String[] pathParts = SplitPath(dstPath);
AVMStore rep = getAVMStoreByName(pathParts[0], true); AVMStore rep = getAVMStoreByName(pathParts[0]);
// fSession.get().lock(rep, LockMode.UPGRADE); // fSession.get().lock(rep, LockMode.UPGRADE);
rep.createLayeredDirectory(srcPath, pathParts[1], name); rep.createLayeredDirectory(srcPath, pathParts[1], name);
} }
@@ -158,7 +158,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String[] pathParts = SplitPath(dstPath); String[] pathParts = SplitPath(dstPath);
AVMStore rep = getAVMStoreByName(pathParts[0], true); AVMStore rep = getAVMStoreByName(pathParts[0]);
rep.createLayeredFile(srcPath, pathParts[1], name); rep.createLayeredFile(srcPath, pathParts[1], name);
} }
@@ -170,7 +170,7 @@ class AVMRepository
{ {
try try
{ {
getAVMStoreByName(name, false); getAVMStoreByName(name);
throw new AVMExistsException("AVMStore exists: " + name); throw new AVMExistsException("AVMStore exists: " + name);
} }
catch (AVMNotFoundException anf) catch (AVMNotFoundException anf)
@@ -201,12 +201,12 @@ class AVMRepository
// Lookup the src node. // Lookup the src node.
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(srcPath); String [] pathParts = SplitPath(srcPath);
AVMStore srcRepo = getAVMStoreByName(pathParts[0], false); AVMStore srcRepo = getAVMStoreByName(pathParts[0]);
Lookup sPath = srcRepo.lookup(version, pathParts[1], false); Lookup sPath = srcRepo.lookup(version, pathParts[1], false);
// Lookup the destination directory. // Lookup the destination directory.
fLookupCount.set(1); fLookupCount.set(1);
pathParts = SplitPath(dstPath); pathParts = SplitPath(dstPath);
AVMStore dstRepo = getAVMStoreByName(pathParts[0], true); AVMStore dstRepo = getAVMStoreByName(pathParts[0]);
Lookup dPath = dstRepo.lookupDirectory(-1, pathParts[1], true); Lookup dPath = dstRepo.lookupDirectory(-1, pathParts[1], true);
DirectoryNode dirNode = (DirectoryNode)dPath.getCurrentNode(); DirectoryNode dirNode = (DirectoryNode)dPath.getCurrentNode();
AVMNode srcNode = sPath.getCurrentNode(); AVMNode srcNode = sPath.getCurrentNode();
@@ -247,7 +247,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore rep = getAVMStoreByName(pathParts[0], true); AVMStore rep = getAVMStoreByName(pathParts[0]);
return rep.getOutputStream(pathParts[1]); return rep.getOutputStream(pathParts[1]);
} }
@@ -262,7 +262,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String[] pathParts = SplitPath(path); String[] pathParts = SplitPath(path);
AVMStore rep = getAVMStoreByName(pathParts[0], true); AVMStore rep = getAVMStoreByName(pathParts[0]);
return rep.getRandomAccess(version, pathParts[1], access); return rep.getRandomAccess(version, pathParts[1], access);
} }
@@ -283,7 +283,7 @@ class AVMRepository
} }
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(srcPath); String [] pathParts = SplitPath(srcPath);
AVMStore srcRepo = getAVMStoreByName(pathParts[0], true); AVMStore srcRepo = getAVMStoreByName(pathParts[0]);
Lookup sPath = srcRepo.lookupDirectory(-1, pathParts[1], true); Lookup sPath = srcRepo.lookupDirectory(-1, pathParts[1], true);
DirectoryNode srcDir = (DirectoryNode)sPath.getCurrentNode(); DirectoryNode srcDir = (DirectoryNode)sPath.getCurrentNode();
AVMNode srcNode = srcDir.lookupChild(sPath, srcName, -1, true); AVMNode srcNode = srcDir.lookupChild(sPath, srcName, -1, true);
@@ -293,7 +293,7 @@ class AVMRepository
} }
fLookupCount.set(1); fLookupCount.set(1);
pathParts = SplitPath(dstPath); pathParts = SplitPath(dstPath);
AVMStore dstRepo = getAVMStoreByName(pathParts[0], true); AVMStore dstRepo = getAVMStoreByName(pathParts[0]);
Lookup dPath = dstRepo.lookupDirectory(-1, pathParts[1], true); Lookup dPath = dstRepo.lookupDirectory(-1, pathParts[1], true);
DirectoryNode dstDir = (DirectoryNode)dPath.getCurrentNode(); DirectoryNode dstDir = (DirectoryNode)dPath.getCurrentNode();
AVMNode dstNode = dstDir.lookupChild(dPath, dstName, -1, true); AVMNode dstNode = dstDir.lookupChild(dPath, dstName, -1, true);
@@ -396,7 +396,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(dirPath); String [] pathParts = SplitPath(dirPath);
AVMStore repo = getAVMStoreByName(pathParts[0], true); AVMStore repo = getAVMStoreByName(pathParts[0]);
repo.uncover(pathParts[1], name); repo.uncover(pathParts[1], name);
} }
@@ -410,7 +410,7 @@ class AVMRepository
List<Integer> result = new ArrayList<Integer>(); List<Integer> result = new ArrayList<Integer>();
for (String repName : repositories) for (String repName : repositories)
{ {
AVMStore repo = getAVMStoreByName(repName, true); AVMStore repo = getAVMStoreByName(repName);
result.add(repo.createSnapshot()); result.add(repo.createSnapshot());
} }
return result; return result;
@@ -423,7 +423,7 @@ class AVMRepository
*/ */
public int createSnapshot(String storeName) public int createSnapshot(String storeName)
{ {
AVMStore store = getAVMStoreByName(storeName, true); AVMStore store = getAVMStoreByName(storeName);
return store.createSnapshot(); return store.createSnapshot();
} }
@@ -436,7 +436,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], true); AVMStore store = getAVMStoreByName(pathParts[0]);
store.removeNode(pathParts[1], name); store.removeNode(pathParts[1], name);
} }
@@ -448,7 +448,7 @@ class AVMRepository
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void purgeAVMStore(String name) public void purgeAVMStore(String name)
{ {
AVMStore store = getAVMStoreByName(name, true); AVMStore store = getAVMStoreByName(name);
AVMNode root = store.getRoot(); AVMNode root = store.getRoot();
root.setIsRoot(false); root.setIsRoot(false);
VersionRootDAO vrDAO = AVMContext.fgInstance.fVersionRootDAO; VersionRootDAO vrDAO = AVMContext.fgInstance.fVersionRootDAO;
@@ -475,7 +475,7 @@ class AVMRepository
*/ */
public void purgeVersion(String name, int version) public void purgeVersion(String name, int version)
{ {
AVMStore store = getAVMStoreByName(name, true); AVMStore store = getAVMStoreByName(name);
store.purgeVersion(version); store.purgeVersion(version);
} }
@@ -489,7 +489,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], false); AVMStore store = getAVMStoreByName(pathParts[0]);
return store.getInputStream(version, pathParts[1]); return store.getInputStream(version, pathParts[1]);
} }
@@ -525,7 +525,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], false); AVMStore store = getAVMStoreByName(pathParts[0]);
return store.getListing(version, pathParts[1]); return store.getListing(version, pathParts[1]);
} }
@@ -570,7 +570,7 @@ class AVMRepository
*/ */
public AVMStoreDescriptor getAVMStore(String name) public AVMStoreDescriptor getAVMStore(String name)
{ {
AVMStore store = getAVMStoreByName(name, false); AVMStore store = getAVMStoreByName(name);
return store.getDescriptor(); return store.getDescriptor();
} }
@@ -581,7 +581,7 @@ class AVMRepository
*/ */
public List<VersionDescriptor> getAVMStoreVersions(String name) public List<VersionDescriptor> getAVMStoreVersions(String name)
{ {
AVMStore store = getAVMStoreByName(name, false); AVMStore store = getAVMStoreByName(name);
return store.getVersions(); return store.getVersions();
} }
@@ -595,7 +595,7 @@ class AVMRepository
*/ */
public List<VersionDescriptor> getAVMStoreVersions(String name, Date from, Date to) public List<VersionDescriptor> getAVMStoreVersions(String name, Date from, Date to)
{ {
AVMStore store = getAVMStoreByName(name, false); AVMStore store = getAVMStoreByName(name);
return store.getVersions(from, to); return store.getVersions(from, to);
} }
@@ -636,7 +636,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], false); AVMStore store = getAVMStoreByName(pathParts[0]);
return store.getIndirectionPath(version, pathParts[1]); return store.getIndirectionPath(version, pathParts[1]);
} }
@@ -647,17 +647,16 @@ class AVMRepository
*/ */
public int getLatestVersionID(String name) public int getLatestVersionID(String name)
{ {
AVMStore store = getAVMStoreByName(name, false); AVMStore store = getAVMStoreByName(name);
return store.getNextVersionID(); return store.getNextVersionID();
} }
/** /**
* Get an AVMStore by name. * Get an AVMStore by name.
* @param name The name of the AVMStore. * @param name The name of the AVMStore.
* @param write Whether this is called for a write operation.
* @return The AVMStore. * @return The AVMStore.
*/ */
private AVMStore getAVMStoreByName(String name, boolean write) private AVMStore getAVMStoreByName(String name)
{ {
AVMStore store = AVMContext.fgInstance.fAVMStoreDAO.getByName(name); AVMStore store = AVMContext.fgInstance.fAVMStoreDAO.getByName(name);
if (store == null) if (store == null)
@@ -675,7 +674,7 @@ class AVMRepository
*/ */
public AVMNodeDescriptor getAVMStoreRoot(int version, String name) public AVMNodeDescriptor getAVMStoreRoot(int version, String name)
{ {
AVMStore store = getAVMStoreByName(name, false); AVMStore store = getAVMStoreByName(name);
if (store == null) if (store == null)
{ {
throw new AVMNotFoundException("Not found: " + name); throw new AVMNotFoundException("Not found: " + name);
@@ -706,7 +705,7 @@ class AVMRepository
throw new AVMCycleException("Cycle in lookup."); throw new AVMCycleException("Cycle in lookup.");
} }
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], false); AVMStore store = getAVMStoreByName(pathParts[0]);
Lookup result = store.lookup(version, pathParts[1], false); Lookup result = store.lookup(version, pathParts[1], false);
if (count == null) if (count == null)
{ {
@@ -748,7 +747,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], false); AVMStore store = getAVMStoreByName(pathParts[0]);
Lookup lookup = store.lookup(version, pathParts[1], false); Lookup lookup = store.lookup(version, pathParts[1], false);
return new LayeringDescriptor(!lookup.getDirectlyContained(), return new LayeringDescriptor(!lookup.getDirectlyContained(),
lookup.getAVMStore().getDescriptor(), lookup.getAVMStore().getDescriptor(),
@@ -769,7 +768,7 @@ class AVMRepository
throw new AVMCycleException("Cycle in lookup."); throw new AVMCycleException("Cycle in lookup.");
} }
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], false); AVMStore store = getAVMStoreByName(pathParts[0]);
return store.lookupDirectory(version, pathParts[1], false); return store.lookupDirectory(version, pathParts[1], false);
} }
@@ -805,7 +804,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String[] pathParts = SplitPath(path); String[] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], true); AVMStore store = getAVMStoreByName(pathParts[0]);
store.makePrimary(pathParts[1]); store.makePrimary(pathParts[1]);
} }
@@ -818,7 +817,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String[] pathParts = SplitPath(path); String[] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], true); AVMStore store = getAVMStoreByName(pathParts[0]);
store.retargetLayeredDirectory(pathParts[1], target); store.retargetLayeredDirectory(pathParts[1], target);
} }
@@ -862,7 +861,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String[] pathParts = SplitPath(path); String[] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], true); AVMStore store = getAVMStoreByName(pathParts[0]);
store.setOpacity(pathParts[1], opacity); store.setOpacity(pathParts[1], opacity);
} }
@@ -876,7 +875,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], true); AVMStore store = getAVMStoreByName(pathParts[0]);
store.setNodeProperty(pathParts[1], name, value); store.setNodeProperty(pathParts[1], name, value);
} }
@@ -889,7 +888,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], true); AVMStore store = getAVMStoreByName(pathParts[0]);
store.setNodeProperties(pathParts[1], properties); store.setNodeProperties(pathParts[1], properties);
} }
@@ -904,7 +903,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], false); AVMStore store = getAVMStoreByName(pathParts[0]);
return store.getNodeProperty(version, pathParts[1], name); return store.getNodeProperty(version, pathParts[1], name);
} }
@@ -918,7 +917,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], false); AVMStore store = getAVMStoreByName(pathParts[0]);
return store.getNodeProperties(version, pathParts[1]); return store.getNodeProperties(version, pathParts[1]);
} }
@@ -931,7 +930,7 @@ class AVMRepository
{ {
fLookupCount.set(1); fLookupCount.set(1);
String [] pathParts = SplitPath(path); String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], true); AVMStore store = getAVMStoreByName(pathParts[0]);
store.deleteNodeProperty(pathParts[1], name); store.deleteNodeProperty(pathParts[1], name);
} }
@@ -943,7 +942,7 @@ class AVMRepository
*/ */
public void setStoreProperty(String store, QName name, PropertyValue value) public void setStoreProperty(String store, QName name, PropertyValue value)
{ {
getAVMStoreByName(store, true).setProperty(name, value); getAVMStoreByName(store).setProperty(name, value);
} }
/** /**
@@ -953,7 +952,7 @@ class AVMRepository
*/ */
public void setStoreProperties(String store, Map<QName, PropertyValue> props) public void setStoreProperties(String store, Map<QName, PropertyValue> props)
{ {
getAVMStoreByName(store, true).setProperties(props); getAVMStoreByName(store).setProperties(props);
} }
/** /**
@@ -964,7 +963,7 @@ class AVMRepository
*/ */
public PropertyValue getStoreProperty(String store, QName name) public PropertyValue getStoreProperty(String store, QName name)
{ {
return getAVMStoreByName(store, false).getProperty(name); return getAVMStoreByName(store).getProperty(name);
} }
/** /**
@@ -974,7 +973,7 @@ class AVMRepository
*/ */
public Map<QName, PropertyValue> getStoreProperties(String store) public Map<QName, PropertyValue> getStoreProperties(String store)
{ {
return getAVMStoreByName(store, false).getProperties(); return getAVMStoreByName(store).getProperties();
} }
/** /**
@@ -984,7 +983,7 @@ class AVMRepository
*/ */
public void deleteStoreProperty(String store, QName name) public void deleteStoreProperty(String store, QName name)
{ {
getAVMStoreByName(store, true).deleteProperty(name); getAVMStoreByName(store).deleteProperty(name);
} }
/** /**
@@ -994,7 +993,7 @@ class AVMRepository
*/ */
public AVMStoreDescriptor getAVMStoreDescriptor(String name) public AVMStoreDescriptor getAVMStoreDescriptor(String name)
{ {
return getAVMStoreByName(name, false).getDescriptor(); return getAVMStoreByName(name).getDescriptor();
} }
/** /**

View File

@@ -84,7 +84,10 @@ class LayeredFileNodeImpl extends FileNodeImpl implements LayeredFileNode
// This is a mildly dirty trick. We use getContentForRead so as not to startle // This is a mildly dirty trick. We use getContentForRead so as not to startle
// the ultimate destination content into copying itself prematurely. // the ultimate destination content into copying itself prematurely.
FileContent content = ((FileNode)indirect).getContentForRead(); FileContent content = ((FileNode)indirect).getContentForRead();
PlainFileNodeImpl newMe = new PlainFileNodeImpl(content, lPath.getAVMStore(), getBasicAttributes()); PlainFileNodeImpl newMe = new PlainFileNodeImpl(this,
content,
lPath.getAVMStore(),
getBasicAttributes());
newMe.setAncestor(this); newMe.setAncestor(this);
return newMe; return newMe;
} }

View File

@@ -86,11 +86,12 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
} }
/** /**
* Constructor that takes a FileContent to share. * Constructor that takes a FileContent to share. Called by LayeredFileNodeImpl.copy().
* @param content The FileContent to share. * @param content The FileContent to share.
* @param store The AVMStore. * @param store The AVMStore.
*/ */
public PlainFileNodeImpl(FileContent content, public PlainFileNodeImpl(LayeredFileNode other,
FileContent content,
AVMStore store, AVMStore store,
BasicAttributes oAttrs) BasicAttributes oAttrs)
{ {
@@ -100,6 +101,7 @@ class PlainFileNodeImpl extends FileNodeImpl implements PlainFileNode
AVMContext.fgInstance.fAVMNodeDAO.save(this); AVMContext.fgInstance.fAVMNodeDAO.save(this);
AVMContext.fgInstance.fAVMNodeDAO.flush(); AVMContext.fgInstance.fAVMNodeDAO.flush();
AVMContext.fgInstance.fNewInAVMStoreDAO.save(new NewInAVMStoreImpl(store, this)); AVMContext.fgInstance.fNewInAVMStoreDAO.save(new NewInAVMStoreImpl(store, this));
copyProperties(other);
} }
/** /**

View File

@@ -70,8 +70,11 @@ public class HibernateRetryingTransaction extends HibernateTemplate implements R
fRandom = new Random(); fRandom = new Random();
} }
/* (non-Javadoc) /**
* @see org.alfresco.repo.avm.hibernate.RetryingTransaction#perform(org.alfresco.repo.avm.hibernate.HibernateTxnCallback, boolean) * Run an idempotent transaction, repeating invocations as necessary
* for failures caused by deadlocks and lost races.
* @param callback The callback containging the work to do.
* @param write Whether this is a write transaction.
*/ */
public void perform(RetryingTransactionCallback callback, boolean write) public void perform(RetryingTransactionCallback callback, boolean write)
{ {