org.alfresco.maven.plugin.amp.util
Class AmpStructure

java.lang.Object
  extended by org.alfresco.maven.plugin.amp.util.AmpStructure

public class AmpStructure
extends Object

Represents the structure of a web application composed of multiple overlays. Each overlay is registered within this structure with the set of files it holds.

Note that this structure is persisted to disk at each invocation to store wich owner holds which path (file).

Author:
Stephane Nicoll

Nested Class Summary
static interface AmpStructure.RegistrationCallback
          Callback interfce to handle events related to filepath registration in the webapp.
 
Constructor Summary
AmpStructure()
          Creates a new empty instance.
AmpStructure(AmpStructure cache)
          Creates a new instance with the specified cache.
 
Method Summary
 PathSet getFullStructure()
          Returns all paths that have been registered so far.
 String getOwner(String path)
          Returns the owner of the specified path.
 Set getOwners()
          Returns the owners.
 PathSet getStructure(String id)
          Returns the list of registered files for the specified owner.
 boolean isRegistered(String path)
          Specify if the specified path is registered or not.
 boolean registerFile(String id, String path)
          Registers the specified path for the specified owner.
 void registerFile(String id, String path, AmpStructure.RegistrationCallback callback)
          Registers the specified path for the specified owner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AmpStructure

public AmpStructure()
Creates a new empty instance.


AmpStructure

public AmpStructure(AmpStructure cache)
Creates a new instance with the specified cache.

Parameters:
cache - the cache
Method Detail

isRegistered

public boolean isRegistered(String path)
Specify if the specified path is registered or not.

Parameters:
path - the relative path from the webapp root directory
Returns:
true if the path is registered, false otherwise

registerFile

public boolean registerFile(String id,
                            String path)
Registers the specified path for the specified owner. Returns true if the path is not already registered, false otherwise.

Parameters:
id - the owner of the path
path - the relative path from the webapp root directory
Returns:
true if the file was registered successfully

registerFile

public void registerFile(String id,
                         String path,
                         AmpStructure.RegistrationCallback callback)
                  throws IOException
Registers the specified path for the specified owner. Invokes the callback with the result of the registration.

Parameters:
id - the owner of the path
path - the relative path from the webapp root directory
callback - the callback to invoke with the result of the registration
Throws:
IOException - if the callback invocation throws an IOException

getOwner

public String getOwner(String path)
Returns the owner of the specified path. If the file is not registered, returns null

Parameters:
path - the relative path from the webapp root directory
Returns:
the owner or null.

getOwners

public Set getOwners()
Returns the owners. Note that this the returned Set may be inconsistent since it represents a persistent cache accross multiple invocations.

For instance, if an overlay was removed in this execution, it will be still be there till the cache is cleaned. This happens when the clean mojo is invoked.

Returns:
the list of owners

getFullStructure

public PathSet getFullStructure()
Returns all paths that have been registered so far.

Returns:
all registered path

getStructure

public PathSet getStructure(String id)
Returns the list of registered files for the specified owner.

Parameters:
id - the owner
Returns:
the list of files registered for that owner


Copyright © 2009 Alfresco. All Rights Reserved.