public abstract class AbstractRepository extends Object implements EditableRepository, EventHandler<RepositoryEvent>
| Modifier and Type | Field and Description |
|---|---|
static com.cronutils.model.definition.CronDefinition |
CRON_DEFINITION |
protected URI |
location |
| Constructor and Description |
|---|
AbstractRepository(Locale primaryLocale,
RepositoryType type,
String id,
String name,
RepositoryStorage repositoryStorage) |
AbstractRepository(RepositoryType type,
String id,
String name,
RepositoryStorage repositoryStorage) |
| Modifier and Type | Method and Description |
|---|---|
StorageAsset |
addAsset(String path,
boolean container)
Adds a new asset to the underlying storage.
|
void |
addFailoverLocation(URI location)
Adds a failover location for the repository.
|
protected <T extends RepositoryFeature<T>> |
addFeature(RepositoryFeature<T> feature) |
void |
clearFailoverLocations()
Clears the failover location set.
|
void |
close()
Closes all resources that are opened by this repository.
|
void |
consumeData(StorageAsset asset,
Consumer<InputStream> consumerFunction,
boolean readLock)
Consumes the data and sets a lock for the file during the operation.
|
void |
consumeDataFromChannel(StorageAsset asset,
Consumer<ReadableByteChannel> consumerFunction,
boolean readLock)
Consumes the data and sets a lock for the file during the operation.
|
void |
copyAsset(StorageAsset origin,
StorageAsset destination,
CopyOption... copyOptions)
Copies the given asset to the new destination.
|
StorageAsset |
copyAsset(StorageAsset origin,
String destination,
CopyOption... copyOptions)
Copies the given asset to the new destination.
|
StorageAsset |
getAsset(String path)
Returns information about a specific storage asset.
|
abstract RepositoryCapabilities |
getCapabilities()
Returns the capabilities of the repository implementation.
|
String |
getDescription()
Returns a description of this repository.
|
String |
getDescription(Locale locale)
Returns the description for the given locale.
|
Set<URI> |
getFailoverLocations()
A repository may allow additional locations that can be used, if the primary location is not available.
|
<T extends RepositoryFeature<T>> |
getFeature(Class<T> clazz)
Extension method that allows to provide different features that are not supported by all
repository types.
|
String |
getId()
Return the identifier of the repository.
|
ArchivaIndexingContext |
getIndexingContext()
Returns a indexing context.
|
String |
getLayout()
Returns a layout definition.
|
StorageAsset |
getLocalPath()
Returns a storage representation to the local data stored for this repository.
|
URI |
getLocation()
Returns the location of this repository.
|
String |
getName()
This is the display name of the repository.
|
String |
getName(Locale locale)
Returns the name in the given locale.
|
Locale |
getPrimaryLocale()
Returns the primary locale used for setting the default values for
name and description.
|
String |
getSchedulingDefinition()
Returns the definition, when the repository jobs are executed.
|
protected RepositoryStorage |
getStorage() |
RepositoryType |
getType()
This identifies the type of repository.
|
void |
handle(RepositoryEvent event) |
abstract boolean |
hasIndex()
Returns true, if this repository has a index available
|
boolean |
isOpen()
Returns the current status of this repository.
|
boolean |
isScanned()
True, if this repository is scanned regularly.
|
void |
moveAsset(StorageAsset origin,
StorageAsset destination,
CopyOption... copyOptions)
Moves the asset to the given location and returns the asset object for the destination.
|
StorageAsset |
moveAsset(StorageAsset origin,
String destination,
CopyOption... copyOptions)
Moves the asset to the given location and returns the asset object for the destination.
|
<T extends Event> |
registerEventHandler(EventType<T> eventType,
EventHandler<? super T> eventHandler) |
void |
removeAsset(StorageAsset asset)
Removes the given asset from the storage.
|
void |
removeFailoverLocation(URI location)
Removes a failover location from the set.
|
void |
setBaseUri(URI baseUri)
Sets the base uri for relative location uris.
|
void |
setDescription(Locale locale,
String description)
Sets the description for the given locale
|
void |
setIndexingContext(ArchivaIndexingContext context)
Sets the indexing context reference.
|
void |
setLayout(String layout)
Sets the layout string.
|
void |
setLocation(URI location)
Sets the location of the repository.
|
void |
setName(Locale locale,
String name)
Sets the name for the given locale
|
protected void |
setPrimaryLocale(Locale locale) |
void |
setScanned(boolean scanned)
Sets the flag for scanning the repository.
|
void |
setSchedulingDefinition(String cronExpression)
Sets the scheduling definition, that defines the times, when the regular repository
jobs are started.
|
protected void |
setStorage(RepositoryStorage storage) |
<T extends RepositoryFeature<T>> |
supportsFeature(Class<T> clazz)
Returns true, if the requested feature is supported by this repository.
|
<T extends Event> |
unregisterEventHandler(EventType<T> type,
EventHandler<? super T> eventHandler) |
void |
updateLocation(URI newLocation)
Updates the base location of the repository storage.
|
void |
writeData(StorageAsset asset,
Consumer<OutputStream> consumerFunction,
boolean writeLock)
Writes data to the asset using a write lock.
|
void |
writeDataToChannel(StorageAsset asset,
Consumer<WritableByteChannel> consumerFunction,
boolean writeLock)
Writes data and sets a lock during the operation.
|
public static final com.cronutils.model.definition.CronDefinition CRON_DEFINITION
public AbstractRepository(RepositoryType type, String id, String name, RepositoryStorage repositoryStorage)
public AbstractRepository(Locale primaryLocale, RepositoryType type, String id, String name, RepositoryStorage repositoryStorage)
protected void setPrimaryLocale(Locale locale)
public String getId()
RepositorygetId in interface Repositorypublic String getName()
RepositorygetName in interface Repositorypublic String getName(Locale locale)
RepositorygetName in interface Repositorypublic String getDescription()
RepositorygetDescription in interface Repositorypublic String getDescription(Locale locale)
RepositorygetDescription in interface Repositorypublic RepositoryType getType()
RepositorygetType in interface Repositorypublic URI getLocation()
RepositorygetLocation in interface RepositorygetLocation in interface RepositoryStoragepublic StorageAsset getLocalPath()
RepositorygetLocalPath in interface Repositorypublic Set<URI> getFailoverLocations()
RepositorygetFailoverLocations in interface Repositorypublic boolean isScanned()
RepositoryisScanned in interface Repositorypublic String getSchedulingDefinition()
RepositorygetSchedulingDefinition in interface Repositorypublic abstract boolean hasIndex()
RepositoryhasIndex in interface Repositorypublic String getLayout()
RepositorygetLayout in interface Repositorypublic abstract RepositoryCapabilities getCapabilities()
RepositorygetCapabilities in interface Repositorypublic <T extends RepositoryFeature<T>> RepositoryFeature<T> getFeature(Class<T> clazz) throws UnsupportedFeatureException
RepositorygetFeature in interface RepositoryT - This is the class of the featureclazz - The feature class that is requestedUnsupportedFeatureException - if the feature is not supported by this repository typepublic <T extends RepositoryFeature<T>> boolean supportsFeature(Class<T> clazz)
RepositorysupportsFeature in interface RepositoryT - The requested feature classclazz - The requested feature classpublic Locale getPrimaryLocale()
EditableRepositorygetPrimaryLocale in interface EditableRepositorypublic void setName(Locale locale, String name)
EditableRepositorysetName in interface EditableRepositorylocale - the locale for which the name is setname - The name value in the language that matches the localepublic void setDescription(Locale locale, String description)
EditableRepositorysetDescription in interface EditableRepositorylocale - the locale for which the description is setdescription - The description in the language that matches the locale.public void setLocation(URI location)
EditableRepositorysetLocation in interface EditableRepositorylocation - the location URIpublic void updateLocation(URI newLocation) throws IOException
RepositoryStorageupdateLocation in interface RepositoryStoragenewLocation - The URI to the new locationIOException - If the repository cannot be relocatedpublic void addFailoverLocation(URI location)
EditableRepositoryaddFailoverLocation in interface EditableRepositorylocation - The location that should be used as failover.public void removeFailoverLocation(URI location)
EditableRepositoryremoveFailoverLocation in interface EditableRepositorylocation - the location uri to removepublic void clearFailoverLocations()
EditableRepositoryclearFailoverLocations in interface EditableRepositorypublic void setScanned(boolean scanned)
EditableRepositorysetScanned in interface EditableRepositoryscanned - if true, the repository is scanned regulary.public void setLayout(String layout)
EditableRepositorysetLayout in interface EditableRepositorypublic void setBaseUri(URI baseUri)
EditableRepositorysetBaseUri in interface EditableRepositorypublic void setSchedulingDefinition(String cronExpression)
EditableRepositorycronExpression must be a valid
quartz cron definition.setSchedulingDefinition in interface EditableRepositorycronExpression - the cron expression.protected <T extends RepositoryFeature<T>> void addFeature(RepositoryFeature<T> feature)
public void setIndexingContext(ArchivaIndexingContext context)
EditableRepositorysetIndexingContext in interface EditableRepositorypublic ArchivaIndexingContext getIndexingContext()
RepositorygetIndexingContext in interface Repositorypublic void close()
Repositoryclose in interface Repositorypublic boolean isOpen()
RepositoryisOpen in interface Repositorytrue, if repository has not been closed, otherwise falsepublic void handle(RepositoryEvent event)
handle in interface EventHandler<RepositoryEvent>public <T extends Event> void registerEventHandler(EventType<T> eventType, EventHandler<? super T> eventHandler)
registerEventHandler in interface EventSourcepublic <T extends Event> void unregisterEventHandler(EventType<T> type, EventHandler<? super T> eventHandler)
unregisterEventHandler in interface EventSourcepublic StorageAsset getAsset(String path)
RepositoryStoragegetAsset in interface RepositoryStoragepublic StorageAsset addAsset(String path, boolean container)
RepositoryStorageaddAsset in interface RepositoryStoragepath - The path to the asset.container - True, if the asset should be a container, false, if it is a file.public void removeAsset(StorageAsset asset) throws IOException
RepositoryStorageremoveAsset in interface RepositoryStorageIOExceptionpublic StorageAsset moveAsset(StorageAsset origin, String destination, CopyOption... copyOptions) throws IOException
RepositoryStoragemoveAsset in interface RepositoryStorageorigin - The original assetdestination - The destination path pointing to the new asset.copyOptions - The copy options.IOExceptionpublic void moveAsset(StorageAsset origin, StorageAsset destination, CopyOption... copyOptions) throws IOException
RepositoryStoragemoveAsset in interface RepositoryStorageorigin - The original assetdestination - The destination path.copyOptions - The copy options (e.g. StandardCopyOption.REPLACE_EXISTINGIOException - If it was not possible to copy the asset.public StorageAsset copyAsset(StorageAsset origin, String destination, CopyOption... copyOptions) throws IOException
RepositoryStoragecopyAsset in interface RepositoryStorageorigin - The original assetdestination - The path to the new assetcopyOptions - The copy options, e.g. (e.g. StandardCopyOption.REPLACE_EXISTINGIOException - If it was not possible to copy the assetpublic void copyAsset(StorageAsset origin, StorageAsset destination, CopyOption... copyOptions) throws IOException
RepositoryStoragecopyAsset in interface RepositoryStorageorigin - The original assetdestination - The path to the new assetcopyOptions - The copy options, e.g. (e.g. StandardCopyOption.REPLACE_EXISTINGIOException - If it was not possible to copy the assetpublic void consumeData(StorageAsset asset, Consumer<InputStream> consumerFunction, boolean readLock) throws IOException
RepositoryStorageconsumeData in interface RepositoryStorageasset - The asset from which the data is consumed.consumerFunction - The consumer that reads the datareadLock - If true, a read lock is acquired on the asset.IOExceptionpublic void consumeDataFromChannel(StorageAsset asset, Consumer<ReadableByteChannel> consumerFunction, boolean readLock) throws IOException
RepositoryStorageconsumeDataFromChannel in interface RepositoryStorageasset - The asset from which the data is consumed.consumerFunction - The consumer that reads the datareadLock - If true, a read lock is acquired on the asset.IOExceptionpublic void writeData(StorageAsset asset, Consumer<OutputStream> consumerFunction, boolean writeLock) throws IOException
RepositoryStoragewriteData in interface RepositoryStorageasset - The asset to which the data is written.consumerFunction - The function that provides the data.writeLock - If true, a write lock is acquired on the destination.IOExceptionpublic void writeDataToChannel(StorageAsset asset, Consumer<WritableByteChannel> consumerFunction, boolean writeLock) throws IOException
RepositoryStoragewriteDataToChannel in interface RepositoryStorageasset - The asset to which the data is written.consumerFunction - The function that provides the data.writeLock - If true, a write lock is acquired on the destination.IOExceptionprotected void setStorage(RepositoryStorage storage)
protected RepositoryStorage getStorage()
Copyright © 2006–2019 The Apache Software Foundation. All rights reserved.