org.rhq.enterprise.server.plugins.disk
Class DiskSource

java.lang.Object
  extended by org.rhq.enterprise.server.plugins.disk.DiskSource
All Implemented Interfaces:
ContentProvider, PackageSource

public class DiskSource
extends java.lang.Object
implements ContentProvider, PackageSource

This is the most basic reference implementation of a content source. It provides primative package synchronization with file-system based source. It is anticipated that more content aware subclasses will provide more useful functionality.

Author:
jortel, John Mazzitelli

Nested Class Summary
protected  class DiskSource.SupportedPackageType
           
 
Constructor Summary
DiskSource()
           
 
Method Summary
protected  ContentProviderPackageDetails createPackage(java.io.File file)
           
protected  DiskSource.SupportedPackageType determinePackageType(java.io.File file)
           
protected  ContentProviderPackageDetails findPackage(java.util.List<ContentProviderPackageDetails> packages, ContentProviderPackageDetails pkg)
           
 java.io.InputStream getInputStream(java.lang.String location)
           
protected  java.lang.String getRelativePath(java.io.File file)
           
protected  java.io.File getRootDirectory()
           
protected  java.util.Map<java.lang.String,DiskSource.SupportedPackageType> getSupportedPackageTypes()
           
 void initialize(Configuration configuration)
           
protected  void initializePackageTypes(Configuration config)
           
protected  void setRootDirectory(java.io.File path)
           
protected  void setSupportedPackageTypes(java.util.Map<java.lang.String,DiskSource.SupportedPackageType> supportedPackageTypes)
           
 void shutdown()
           
 void synchronizePackages(java.lang.String repoName, PackageSyncReport report, java.util.Collection<ContentProviderPackageDetails> existingPackages)
           
protected  void syncPackages(PackageSyncReport report, java.util.List<ContentProviderPackageDetails> packages, java.io.File directory)
          Recursive function that drills down into subdirectories and builds up the report of packages for all files found.
 void testConnection()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiskSource

public DiskSource()
Method Detail

getRootDirectory

protected java.io.File getRootDirectory()

setRootDirectory

protected void setRootDirectory(java.io.File path)

getSupportedPackageTypes

protected java.util.Map<java.lang.String,DiskSource.SupportedPackageType> getSupportedPackageTypes()

setSupportedPackageTypes

protected void setSupportedPackageTypes(java.util.Map<java.lang.String,DiskSource.SupportedPackageType> supportedPackageTypes)

initialize

public void initialize(Configuration configuration)
                throws java.lang.Exception
Specified by:
initialize in interface ContentProvider
Throws:
java.lang.Exception

shutdown

public void shutdown()
Specified by:
shutdown in interface ContentProvider

synchronizePackages

public void synchronizePackages(java.lang.String repoName,
                                PackageSyncReport report,
                                java.util.Collection<ContentProviderPackageDetails> existingPackages)
                         throws java.lang.Exception
Specified by:
synchronizePackages in interface PackageSource
Throws:
java.lang.Exception

testConnection

public void testConnection()
                    throws java.lang.Exception
Specified by:
testConnection in interface ContentProvider
Throws:
java.lang.Exception

getInputStream

public java.io.InputStream getInputStream(java.lang.String location)
                                   throws java.lang.Exception
Specified by:
getInputStream in interface PackageSource
Throws:
java.lang.Exception

syncPackages

protected void syncPackages(PackageSyncReport report,
                            java.util.List<ContentProviderPackageDetails> packages,
                            java.io.File directory)
                     throws java.lang.Exception
Recursive function that drills down into subdirectories and builds up the report of packages for all files found. As files are found, their associated packages are removed from packages if they exist - leaving only packages remaining that do not exist on the file system.

Parameters:
report - the report that we are building up
packages - existing packages not yet found on the file system but exist in server inventory
directory - the directory (and its subdirectories) to scan
Throws:
java.lang.Exception - if the sync fails

createPackage

protected ContentProviderPackageDetails createPackage(java.io.File file)
                                               throws java.lang.Exception
Throws:
java.lang.Exception

findPackage

protected ContentProviderPackageDetails findPackage(java.util.List<ContentProviderPackageDetails> packages,
                                                    ContentProviderPackageDetails pkg)

getRelativePath

protected java.lang.String getRelativePath(java.io.File file)

initializePackageTypes

protected void initializePackageTypes(Configuration config)

determinePackageType

protected DiskSource.SupportedPackageType determinePackageType(java.io.File file)


Copyright © 2008-2009 Red Hat, Inc.. All Rights Reserved.