Groovy Documentation

java.gate.versioning.svnkit
Class SandboxManager

java.lang.Object
  java.gate.versioning.svnkit.SandboxManager

class SandboxManager

This class manages a set of Sandboxes. This is a Spring Bean and it is assumed that this will be a singleton. It ensures that there is never more than one Sandbox object for any given SVN-managed file tree, and it linearises operations on these objects. It is intended to be thread-safe. NOTE: this API assumes that its clients are friendly enough not to add a sandbox that is a subdirectory of another sandbox also being managed. If this rule is not followed then the results will be unpredictable!


Field Summary
private File configDir

A directory holding subversion config info, if null then the users default .subversion directory will be used

private static Logger log

ConcurrentMap sandboxMap

A map of sandboxes to their ids.

 
Constructor Summary
SandboxManager()

 
Method Summary
boolean addSandbox(File location, String username, String password)

Add a new Sandbox.

boolean addSandbox(File location, ISVNAuthenticationManager authManager)

Add a new Sandbox.

void addSandboxes(List folderIds, String username, String password)

This method adds a list of sandboxes to the sandboxMap.

SVNURL createLocalRepository(File location)

Create a new local SVN repository.

void forgetSandbox(File sbDir)

Forget a sandbox.

File getConfigDir()

Sandbox getSandbox(String id)

Get a sandbox from its ID (canonical path to the directory tree).

String getSandboxId(File sbDir)

Generate an ID for a File that points to a sandbox tree on disk.

List getSandboxList()

Get an (immutable) list of all known sandboxes.

Map getSandboxMap()

Get an (immutable) map of all known sandboxes indexed by id.

boolean isSandboxDir(File sbDir)

Check that a File points to a valid sandbox on disk.

void setConfigDir(File dir)

void shutdown()

Close all managed sandboxes.

 
Methods inherited from class Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll
 

Field Detail

configDir

private File configDir
A directory holding subversion config info, if null then the users default .subversion directory will be used


log

private static final Logger log


sandboxMap

ConcurrentMap sandboxMap
A map of sandboxes to their ids.


 
Constructor Detail

SandboxManager

SandboxManager()


 
Method Detail

addSandbox

public boolean addSandbox(File location, String username, String password)
Add a new Sandbox. This will be identified by the canonical form of the path to the directory tree. If a sandbox that is already recorded is added nothing is done and the method returns false.
param:
location a file pointing to the top-level directory of the sandbox on disk.
param:
username - for svn authentication
param:
password - for svn authentication
return:
boolean indicates if the new sandbox was added.
throws:
GateException when the location doesn't exist or isn't under version control.


addSandbox

public boolean addSandbox(File location, ISVNAuthenticationManager authManager)
Add a new Sandbox. This will be identified by the canonical form of the path to the directory tree. If a sandbox that is already recorded is added nothing is done and the method returns false.
param:
location a file pointing to the top-level directory of the sandbox on disk.
param:
authManager - custom authentication manager for svn authentication
return:
boolean indicates if the new sandbox was added.
throws:
GateException when the location doesn't exist or isn't under version control.


addSandboxes

public void addSandboxes(List folderIds, String username, String password)
This method adds a list of sandboxes to the sandboxMap. In case of any exception, the runtime exception is thrown and since the method is called when starting the application, the process of starting the application will be terminated. // TODO why does this throw runtime exception?! We assume that all sandboxes are for users with same username/password on svn.
param:
folderIds the list of full paths of the sandboxes to be added.
param:
username - for svn authentication
param:
password - for svn authentication


createLocalRepository

public SVNURL createLocalRepository(File location)
Create a new local SVN repository. This includes three directories "trunk", "tags" and "branches" as per normal convention.
return:
SVNURL the URL of the new repository.


forgetSandbox

public void forgetSandbox(File sbDir)
Forget a sandbox.
param:
sbDir a file pointing to the top-level directory of the sandbox on disk (it is assumed to be a File).


getConfigDir

public File getConfigDir()


getSandbox

public Sandbox getSandbox(String id)
Get a sandbox from its ID (canonical path to the directory tree).
param:
id the ID of the Sandbox (if you only have the location of the sandbox on disk, use getSandboxId(File) and pass the result to this method.


getSandboxId

public String getSandboxId(File sbDir)
Generate an ID for a File that points to a sandbox tree on disk. This ID is the directory's canonical path.
throws:
GateRuntimeException when the location won't resolve to a canonical path.


getSandboxList

public List getSandboxList()
Get an (immutable) list of all known sandboxes.


getSandboxMap

public Map getSandboxMap()
Get an (immutable) map of all known sandboxes indexed by id.


isSandboxDir

public boolean isSandboxDir(File sbDir)
Check that a File points to a valid sandbox on disk.
param:
sbDir a file pointing to the top-level directory of the sandbox on disk.
return:
boolean indicates if the sandbox is valid.


setConfigDir

public void setConfigDir(File dir)


shutdown

public void shutdown()
Close all managed sandboxes.


 

Groovy Documentation