mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +00:00
AVM stores are renamable. Beware. Database schema has changed since I needed to
introduce a synthetic primary key into the stores table. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4492 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
57424368b7
commit
b8ff632f15
@ -391,4 +391,11 @@ public interface AVMRemote
|
||||
* @param name The name of the property.
|
||||
*/
|
||||
public void deleteStoreProperty(String store, QName name);
|
||||
|
||||
/**
|
||||
* Rename a store.
|
||||
* @param sourceName The original name.
|
||||
* @param destName The new name.
|
||||
*/
|
||||
public void renameStore(String sourceName, String destName);
|
||||
}
|
||||
|
@ -430,4 +430,12 @@ public class AVMRemoteLocal implements AVMRemote
|
||||
{
|
||||
fService.uncover(dirPath, name);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.AVMRemote#renameStore(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void renameStore(String sourceName, String destName)
|
||||
{
|
||||
fService.renameStore(sourceName, destName);
|
||||
}
|
||||
}
|
||||
|
@ -408,4 +408,12 @@ public interface AVMRemoteTransport
|
||||
* @param name The name of the property.
|
||||
*/
|
||||
public void deleteStoreProperty(String ticket, String store, QName name);
|
||||
|
||||
/**
|
||||
* Rename a store.
|
||||
* @param ticket The authentication ticket.
|
||||
* @param sourceName The original name.
|
||||
* @param destName The new name.
|
||||
*/
|
||||
public void renameStore(String ticket, String sourceName, String destName);
|
||||
}
|
||||
|
@ -936,4 +936,13 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable
|
||||
fAuthService.validate(ticket);
|
||||
fAVMService.deleteStoreProperty(store, name);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.AVMRemoteTransport#renameStore(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void renameStore(String ticket, String sourceName, String destName)
|
||||
{
|
||||
fAuthService.validate(ticket);
|
||||
fAVMService.renameStore(sourceName, destName);
|
||||
}
|
||||
}
|
||||
|
@ -2236,4 +2236,30 @@ public class AVMRepository
|
||||
fLookupCount.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename a store.
|
||||
* @param sourceName The original name.
|
||||
* @param destName The new name.
|
||||
* @throws AVMNotFoundException
|
||||
* @throws AVMExistsException
|
||||
*/
|
||||
public void renameStore(String sourceName, String destName)
|
||||
{
|
||||
AVMStore store = getAVMStoreByName(sourceName);
|
||||
if (store == null)
|
||||
{
|
||||
throw new AVMNotFoundException("Store Not Found: " + sourceName);
|
||||
}
|
||||
if (getAVMStoreByName(destName) != null)
|
||||
{
|
||||
throw new AVMExistsException("Store Already Exists: " + destName);
|
||||
}
|
||||
if (!FileNameValidator.IsValid(destName))
|
||||
{
|
||||
throw new AVMBadArgumentException("Bad store name: " + destName);
|
||||
}
|
||||
store.setName(destName);
|
||||
fLookupCache.onDelete(sourceName);
|
||||
}
|
||||
}
|
||||
|
@ -1386,4 +1386,20 @@ public class AVMServiceImpl implements AVMService
|
||||
fAVMRepository.setACL(newPath, acl.getCopy());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename a store.
|
||||
* @param sourceName The original name.
|
||||
* @param destName The new name.
|
||||
* @throws AVMNotFoundException
|
||||
* @throws AVMExistsException
|
||||
*/
|
||||
public void renameStore(String sourceName, String destName)
|
||||
{
|
||||
if (sourceName == null || destName == null)
|
||||
{
|
||||
throw new AVMBadArgumentException("Illegal Null Argument.");
|
||||
}
|
||||
fAVMRepository.renameStore(sourceName, destName);
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +69,23 @@ import org.alfresco.util.Pair;
|
||||
*/
|
||||
public class AVMServiceTest extends AVMServiceTestBase
|
||||
{
|
||||
/**
|
||||
* Test renaming a store.
|
||||
*/
|
||||
public void testRenameStore()
|
||||
{
|
||||
try
|
||||
{
|
||||
fService.renameStore("main", "foo");
|
||||
assertNotNull(fService.getAVMStore("foo"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test copy.
|
||||
*/
|
||||
|
@ -41,6 +41,11 @@ import org.alfresco.service.namespace.QName;
|
||||
*/
|
||||
public interface AVMStore
|
||||
{
|
||||
/**
|
||||
* Get the primary key.
|
||||
*/
|
||||
public long getId();
|
||||
|
||||
/**
|
||||
* This returns the next version in this store that will be snapshotted.
|
||||
* @return The next version to be snapshotted.
|
||||
@ -264,6 +269,12 @@ public interface AVMStore
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Set the name of the store.
|
||||
* @param name To Set.
|
||||
*/
|
||||
public void setName(String name);
|
||||
|
||||
/**
|
||||
* Purge all the nodes reachable only by the given version.
|
||||
* @param version
|
||||
|
@ -62,4 +62,11 @@ public interface AVMStoreDAO
|
||||
* @param rep The dirty AVMStore.
|
||||
*/
|
||||
public void update(AVMStore rep);
|
||||
|
||||
/**
|
||||
* Get A store by primary key.
|
||||
* @param id The primary key.
|
||||
* @return The store.
|
||||
*/
|
||||
public AVMStore getByID(long id);
|
||||
}
|
||||
|
@ -61,6 +61,11 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
{
|
||||
static final long serialVersionUID = -1485972568675732904L;
|
||||
|
||||
/**
|
||||
* The primary key.
|
||||
*/
|
||||
private long fID;
|
||||
|
||||
/**
|
||||
* The name of this AVMStore.
|
||||
*/
|
||||
@ -130,6 +135,24 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
AVMDAOs.Instance().fVersionRootDAO.save(versionRoot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for hibernate.
|
||||
* @param id The primary key.
|
||||
*/
|
||||
protected void setId(long id)
|
||||
{
|
||||
fID = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the primary key.
|
||||
* @return The primary key.
|
||||
*/
|
||||
public long getId()
|
||||
{
|
||||
return fID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new root for this.
|
||||
* @param root
|
||||
@ -704,10 +727,10 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of this AVMStore. Hibernate.
|
||||
* Set the name of this AVMStore.
|
||||
* @param name
|
||||
*/
|
||||
protected void setName(String name)
|
||||
public void setName(String name)
|
||||
{
|
||||
fName = name;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class Lookup
|
||||
public Lookup(Lookup other, AVMNodeDAO nodeDAO, AVMStoreDAO storeDAO)
|
||||
{
|
||||
fValid = true;
|
||||
fAVMStore = storeDAO.getByName(other.fAVMStore.getName());
|
||||
fAVMStore = storeDAO.getByID(other.fAVMStore.getId());
|
||||
if (fAVMStore == null)
|
||||
{
|
||||
fValid = false;
|
||||
@ -155,7 +155,7 @@ class Lookup
|
||||
}
|
||||
fComponents.add(newComp);
|
||||
}
|
||||
fFinalStore = storeDAO.getByName(other.fFinalStore.getName());
|
||||
fFinalStore = storeDAO.getByID(other.fFinalStore.getId());
|
||||
if (fFinalStore == null)
|
||||
{
|
||||
fValid = false;
|
||||
|
@ -436,4 +436,12 @@ public class AVMRemoteImpl implements AVMRemote
|
||||
{
|
||||
fTransport.uncover(ClientTicketHolder.GetTicket(), dirPath, name);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.AVMRemote#renameStore(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void renameStore(String sourceName, String destName)
|
||||
{
|
||||
fTransport.renameStore(ClientTicketHolder.GetTicket(), sourceName, destName);
|
||||
}
|
||||
}
|
||||
|
@ -104,8 +104,11 @@
|
||||
<class table="avm_stores" name="AVMStoreImpl"
|
||||
proxy="AVMStore" optimistic-lock="version">
|
||||
<cache usage="read-write"/>
|
||||
<id name="name" column="name" type="string"/>
|
||||
<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. -->
|
||||
|
@ -77,7 +77,10 @@ class AVMStoreDAOHibernate extends HibernateDaoSupport implements
|
||||
*/
|
||||
public AVMStore getByName(String name)
|
||||
{
|
||||
return (AVMStore)getSession().get(AVMStoreImpl.class, name);
|
||||
Query query = getSession().createQuery("from AVMStoreImpl st " +
|
||||
"where st.name = :name");
|
||||
query.setParameter("name", name);
|
||||
return (AVMStore)query.uniqueResult();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,4 +104,12 @@ class AVMStoreDAOHibernate extends HibernateDaoSupport implements
|
||||
{
|
||||
// No op in Hibernate.
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.avm.AVMStoreDAO#getByID(long)
|
||||
*/
|
||||
public AVMStore getByID(long id)
|
||||
{
|
||||
return (AVMStore)getSession().get(AVMStoreImpl.class, id);
|
||||
}
|
||||
}
|
||||
|
@ -794,4 +794,13 @@ public interface AVMService
|
||||
* @throws AVMNotFoundException
|
||||
*/
|
||||
public void copy(int srcVersion, String srcPath, String dstPath, String name);
|
||||
|
||||
/**
|
||||
* Rename a store.
|
||||
* @param sourceName The original name.
|
||||
* @param destName The new name.
|
||||
* @throws AVMNotFoundException
|
||||
* @throws AVMExistsException
|
||||
*/
|
||||
public void renameStore(String sourceName, String destName);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user