edu.internet2.middleware.shibboleth.common.resource
Class SVNResource

java.lang.Object
  extended by org.opensaml.util.resource.AbstractFilteredResource
      extended by edu.internet2.middleware.shibboleth.common.resource.SVNResource
All Implemented Interfaces:
org.opensaml.util.resource.Resource

public class SVNResource
extends org.opensaml.util.resource.AbstractFilteredResource

A resource representing a file fetch from a Subversion server. This resource will fetch the given resource as follows:

The behavior of multiple SVNResource operating on the same local copy are undefined.

Since:
1.1

Nested Class Summary
private  class SVNResource.SVNStatusHandler
          Simple ISVNStatusHandler implementation that just stores and returns the status.
 
Field Summary
private  org.tmatesoft.svn.core.wc.SVNClientManager clientManager
          SVN Client manager.
private  org.joda.time.DateTime lastModified
          Time the resource file was last modified.
private  org.slf4j.Logger log
          Class logger.
private  org.tmatesoft.svn.core.SVNURL remoteRepository
          URL to the remote repository.
private  String resourceFileName
          File, within the working copy, represented by this resource.
private  org.tmatesoft.svn.core.wc.SVNRevision retrievalRevision
          Revision of the working copy.
private  File workingCopyDirectory
          Directory where the working copy will be kept.
 
Constructor Summary
SVNResource(org.tmatesoft.svn.core.wc.SVNClientManager svnClientMgr, org.tmatesoft.svn.core.SVNURL repositoryUrl, File workingCopy, long workingRevision, String resourceFile)
          Constructor.
 
Method Summary
protected  void checkoutOrUpdateResource()
          Checks out the resource specified by the remoteRepository in to the working copy workingCopyDirectory.
private  org.tmatesoft.svn.core.wc.SVNRevision checkoutResourceDirectory()
          Fetches the content from the SVN repository and creates the local working copy.
protected  void checkWorkingCopyDirectory(File directory)
          Checks that the given file exists, or can be created, is a directory, and is read/writable by this process.
 boolean exists()
          
 InputStream getInputStream()
          
private  org.joda.time.DateTime getLastModificationForRevision(org.tmatesoft.svn.core.wc.SVNRevision revision)
          Gets the last modified time for the given revision.
 org.joda.time.DateTime getLastModifiedTime()
          
 String getLocation()
          
protected  File getResourceFile()
          Gets File for the resource.
private  org.tmatesoft.svn.core.wc.SVNRevision updateResourceDirectory()
          Updates an existing local working copy from the repository.
private  boolean workingCopyDirectoryExists()
          Checks to see if the working copy directory exists.
 
Methods inherited from class org.opensaml.util.resource.AbstractFilteredResource
applyFilter, getResourceFilter, setResourceFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private final org.slf4j.Logger log
Class logger.


clientManager

private final org.tmatesoft.svn.core.wc.SVNClientManager clientManager
SVN Client manager.


remoteRepository

private org.tmatesoft.svn.core.SVNURL remoteRepository
URL to the remote repository.


workingCopyDirectory

private File workingCopyDirectory
Directory where the working copy will be kept.


retrievalRevision

private org.tmatesoft.svn.core.wc.SVNRevision retrievalRevision
Revision of the working copy.


resourceFileName

private String resourceFileName
File, within the working copy, represented by this resource.


lastModified

private org.joda.time.DateTime lastModified
Time the resource file was last modified.

Constructor Detail

SVNResource

public SVNResource(org.tmatesoft.svn.core.wc.SVNClientManager svnClientMgr,
                   org.tmatesoft.svn.core.SVNURL repositoryUrl,
                   File workingCopy,
                   long workingRevision,
                   String resourceFile)
            throws org.opensaml.util.resource.ResourceException
Constructor.

Parameters:
svnClientMgr - manager used to create SVN clients
repositoryUrl - URL of the remote repository
workingCopy - directory that will serve as the root of the local working copy
workingRevision - revision of the resource to retrieve or -1 for HEAD revision
resourceFile - file, within the working copy, represented by this resource
Throws:
org.opensaml.util.resource.ResourceException - thrown if there is a problem initializing the SVN resource
Method Detail

exists

public boolean exists()
               throws org.opensaml.util.resource.ResourceException

Throws:
org.opensaml.util.resource.ResourceException

getInputStream

public InputStream getInputStream()
                           throws org.opensaml.util.resource.ResourceException

Throws:
org.opensaml.util.resource.ResourceException

getLastModifiedTime

public org.joda.time.DateTime getLastModifiedTime()
                                           throws org.opensaml.util.resource.ResourceException

Throws:
org.opensaml.util.resource.ResourceException

getLocation

public String getLocation()


getResourceFile

protected File getResourceFile()
                        throws org.opensaml.util.resource.ResourceException
Gets File for the resource.

Returns:
file for the resource
Throws:
org.opensaml.util.resource.ResourceException - thrown if there is a problem fetching the resource or checking on its status

checkWorkingCopyDirectory

protected void checkWorkingCopyDirectory(File directory)
                                  throws org.opensaml.util.resource.ResourceException
Checks that the given file exists, or can be created, is a directory, and is read/writable by this process.

Parameters:
directory - the directory to check
Throws:
org.opensaml.util.resource.ResourceException - thrown if the file is invalid

checkoutOrUpdateResource

protected void checkoutOrUpdateResource()
                                 throws org.opensaml.util.resource.ResourceException
Checks out the resource specified by the remoteRepository in to the working copy workingCopyDirectory. If the working copy is empty than an SVN checkout is performed if the working copy already exists then an SVN update is performed.

Throws:
org.opensaml.util.resource.ResourceException - thrown if there is a problem communicating with the remote repository, the revision does not exist, or the working copy is unusable

workingCopyDirectoryExists

private boolean workingCopyDirectoryExists()
Checks to see if the working copy directory exists.

Returns:
true if the working copy directory exists, false otherwise

checkoutResourceDirectory

private org.tmatesoft.svn.core.wc.SVNRevision checkoutResourceDirectory()
                                                                 throws org.opensaml.util.resource.ResourceException
Fetches the content from the SVN repository and creates the local working copy.

Returns:
the revision of the fetched content
Throws:
org.opensaml.util.resource.ResourceException - thrown if there is a problem checking out the content from the repository

updateResourceDirectory

private org.tmatesoft.svn.core.wc.SVNRevision updateResourceDirectory()
                                                               throws org.opensaml.util.resource.ResourceException
Updates an existing local working copy from the repository.

Returns:
the revision of the fetched content
Throws:
org.opensaml.util.resource.ResourceException - thrown if there is a problem updating the working copy

getLastModificationForRevision

private org.joda.time.DateTime getLastModificationForRevision(org.tmatesoft.svn.core.wc.SVNRevision revision)
                                                       throws org.opensaml.util.resource.ResourceException
Gets the last modified time for the given revision.

Parameters:
revision - revision to get the last modified date for
Returns:
the last modified time
Throws:
org.opensaml.util.resource.ResourceException - thrown if there is a problem getting the last modified time


Copyright © 1999-2012. All Rights Reserved.