mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Added getRepository() and getRepositories() to AVMService, removed getRepositoryNames()
from same. These new methods return a RepositoryDescriptor and a List of RepositoryDescriptors. Note, Hibernate mapping has changed. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3207 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -174,7 +174,15 @@ class SuperRepository
|
||||
*/
|
||||
public void createRepository(String name)
|
||||
{
|
||||
// TODO need to check for repository existence first.
|
||||
try
|
||||
{
|
||||
getRepositoryByName(name, false);
|
||||
throw new AVMExistsException("Repository exists: " + name);
|
||||
}
|
||||
catch (AVMNotFoundException anf)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
// Newing up the object causes it to be written to the db.
|
||||
@SuppressWarnings("unused")
|
||||
Repository rep = new RepositoryImpl(this, name);
|
||||
@@ -564,12 +572,29 @@ class SuperRepository
|
||||
* @return A list of names.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getRepositoryNames()
|
||||
public List<RepositoryDescriptor> getRepositories()
|
||||
{
|
||||
Query query = fSession.get().createQuery("select r.name from RepositoryImpl r");
|
||||
return (List<String>)query.list();
|
||||
Query query = fSession.get().createQuery("from RepositoryImpl r");
|
||||
List<Repository> l = (List<Repository>)query.list();
|
||||
List<RepositoryDescriptor> result = new ArrayList<RepositoryDescriptor>();
|
||||
for (Repository rep : l)
|
||||
{
|
||||
result.add(rep.getDescriptor());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a descriptor for a repository.
|
||||
* @param name The name to get.
|
||||
* @return The descriptor.
|
||||
*/
|
||||
public RepositoryDescriptor getRepository(String name)
|
||||
{
|
||||
Repository rep = getRepositoryByName(name, false);
|
||||
return rep.getDescriptor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all version for a given repository.
|
||||
* @param name The name of the repository.
|
||||
@@ -668,9 +693,14 @@ class SuperRepository
|
||||
*/
|
||||
private Repository getRepositoryByName(String name, boolean write)
|
||||
{
|
||||
return (Repository)fSession.get().get(RepositoryImpl.class,
|
||||
Repository rep = (Repository)fSession.get().get(RepositoryImpl.class,
|
||||
name /* ,
|
||||
write ? LockMode.UPGRADE : LockMode.READ */);
|
||||
if (rep == null)
|
||||
{
|
||||
throw new AVMNotFoundException("Repository not found: " + name);
|
||||
}
|
||||
return rep;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -832,6 +862,16 @@ class SuperRepository
|
||||
return history;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the RepositoryDescriptor for a Repository.
|
||||
* @param name The name of the Repository.
|
||||
* @return The descriptor.
|
||||
*/
|
||||
public RepositoryDescriptor getRepositoryDescriptor(String name)
|
||||
{
|
||||
return getRepositoryByName(name, false).getDescriptor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the single instance of SuperRepository.
|
||||
* @return
|
||||
|
Reference in New Issue
Block a user