com.atlassian.modzdetector
Class ModzDetector

java.lang.Object
  extended by com.atlassian.modzdetector.ModzDetector

public class ModzDetector
extends java.lang.Object

Provides a service to determine whether resource content has been modified compared to a registry. The registry contains a map of names to hashes (implemented by the HashAlgorithm). Resources are loaded using a strategy defined in the registry on a per-resource basis. The two main strategies are filesystem loading and classpath loading. The ResourceAccessor implementation provides the concrete mechanism for acquiring the InputStream in the case of filesystem loading and the ClassLoader in the case of classpath loading.


Field Summary
static java.io.FileFilter OPEN_FILTER
           
 
Constructor Summary
ModzDetector(ResourceAccessor resourceAccessor)
           
ModzDetector(ResourceAccessor resourceAccessor, HashAlgorithm hashAlgorithm)
           
ModzDetector(ResourceAccessor resourceAccessor, HashAlgorithm hashAlgorithm, StreamMapper streamMapper)
           
 
Method Summary
 java.util.List<java.lang.String> getAddedFiles(java.io.File rootDirectory)
          Gets a report of what files were added using the default registry file, loaded off the classpath.
 java.util.List<java.lang.String> getAddedFiles(java.io.InputStream registryStream, java.io.File root, java.io.FileFilter filter)
          Searches the given root directory for all file paths beneath it that are not registered.
 Modifications getModifiedFiles()
          Gets a report of what files were modified using the default registry file, loaded off the classpath.
 Modifications getModifiedFiles(java.io.InputStream registryStream)
          Gets a report of what files were modified using the registry in the given registryStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPEN_FILTER

public static final java.io.FileFilter OPEN_FILTER
Constructor Detail

ModzDetector

public ModzDetector(ResourceAccessor resourceAccessor)

ModzDetector

public ModzDetector(ResourceAccessor resourceAccessor,
                    HashAlgorithm hashAlgorithm)

ModzDetector

public ModzDetector(ResourceAccessor resourceAccessor,
                    HashAlgorithm hashAlgorithm,
                    StreamMapper streamMapper)
Method Detail

getModifiedFiles

public Modifications getModifiedFiles()
                               throws ModzRegistryException
Gets a report of what files were modified using the default registry file, loaded off the classpath.

Returns:
the modifications, let's call it a report.
Throws:
ModzRegistryException

getModifiedFiles

public Modifications getModifiedFiles(java.io.InputStream registryStream)
                               throws ModzRegistryException
Gets a report of what files were modified using the registry in the given registryStream.

Parameters:
registryStream - a properties file, additionally a properly formed registry.
Returns:
the modifications.
Throws:
ModzRegistryException

getAddedFiles

public java.util.List<java.lang.String> getAddedFiles(java.io.File rootDirectory)
                                               throws ModzRegistryException
Gets a report of what files were added using the default registry file, loaded off the classpath. Note that only files within a filesystem can in practice be traversed to find added files

Returns:
the modifications, let's call it a report.
Throws:
ModzRegistryException

getAddedFiles

public java.util.List<java.lang.String> getAddedFiles(java.io.InputStream registryStream,
                                                      java.io.File root,
                                                      java.io.FileFilter filter)
                                               throws ModzRegistryException
Searches the given root directory for all file paths beneath it that are not registered.

Parameters:
registryStream - the registry.
root - the root of the file path to search for additional resources.
Returns:
the list of subpaths of root that are not registered in the given registry.
Throws:
ModzRegistryException - if something untoward occurs.


Copyright © 2011 Atlassian. All Rights Reserved.