Package org.onebusaway.admin.bundle
Class DirectoryBundleSource
- java.lang.Object
-
- org.onebusaway.admin.bundle.AbstractBundleSource
-
- org.onebusaway.admin.bundle.DirectoryBundleSource
-
- All Implemented Interfaces:
BundleSource
public class DirectoryBundleSource extends AbstractBundleSource implements BundleSource
Represents a bundle source where each bundle is saved as a set of files within a directory. The constructor takes a directory which contains multiple subdirectories, one for each bundle.
-
-
Field Summary
-
Fields inherited from class org.onebusaway.admin.bundle.AbstractBundleSource
BUNDLE_DATA_DIRNAME, BUNDLE_INPUT_DIRNAME, BUNDLE_OUTPUT_DIRNAME
-
-
Constructor Summary
Constructors Constructor Description DirectoryBundleSource(String masterBundleDirectoryPathname, JsonTool jsonTool)
Construct this DirectoryBundleSource, verifying that the passed directory is actually a directory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkIsValidBundleFile(String bundleId, String relativeFilePath)
Checks that the bundleId exists, and that the file is listed in the metadata.File
getBundleFile(String bundleId, String relativeFilePath)
Get the full path of a bundle file.List<Bundle>
getBundles()
Get all the bundles that seem initially correct.File
getMasterBundleDirectory()
void
setJsonTool(JsonTool tool)
void
setMasterBundleDirectoryPathname(String pathname)
-
Methods inherited from class org.onebusaway.admin.bundle.AbstractBundleSource
arrayContainsItem, getBundleFile, getFilePath
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.onebusaway.admin.bundle.BundleSource
getBundleFile
-
-
-
-
Constructor Detail
-
DirectoryBundleSource
public DirectoryBundleSource(String masterBundleDirectoryPathname, JsonTool jsonTool) throws Exception
Construct this DirectoryBundleSource, verifying that the passed directory is actually a directory.- Parameters:
masterBundleDirectoryPathname
- The path of a directory which can contain subdirectories for each bundle.jsonTool
- The json utility to use, wrapped in a JsonTool class.- Throws:
Exception
- If bundleDirectoryPathname is not a directory.
-
-
Method Detail
-
getMasterBundleDirectory
public File getMasterBundleDirectory()
-
setMasterBundleDirectoryPathname
public void setMasterBundleDirectoryPathname(String pathname)
-
setJsonTool
public void setJsonTool(JsonTool tool)
-
getBundles
public List<Bundle> getBundles()
Description copied from interface:BundleSource
Get all the bundles that seem initially correct.- Specified by:
getBundles
in interfaceBundleSource
- Returns:
- A list of the available bundle objects.
-
checkIsValidBundleFile
public boolean checkIsValidBundleFile(String bundleId, String relativeFilePath)
Description copied from interface:BundleSource
Checks that the bundleId exists, and that the file is listed in the metadata.- Specified by:
checkIsValidBundleFile
in interfaceBundleSource
- Parameters:
bundleId
- The Id of the bundle to which the requested file belongs.relativeFilePath
- the relative path of the file, as listed in the metadata.- Returns:
- true if the bundle exists and file is listed in the metadata. false otherwise.
-
getBundleFile
public File getBundleFile(String bundleId, String relativeFilePath) throws FileNotFoundException
Description copied from interface:BundleSource
Get the full path of a bundle file.- Specified by:
getBundleFile
in interfaceBundleSource
- Returns:
- Throws:
FileNotFoundException
-
-