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()
Repository
getId
in interface Repository
public String getName()
Repository
getName
in interface Repository
public String getName(Locale locale)
Repository
getName
in interface Repository
public String getDescription()
Repository
getDescription
in interface Repository
public String getDescription(Locale locale)
Repository
getDescription
in interface Repository
public RepositoryType getType()
Repository
getType
in interface Repository
public URI getLocation()
Repository
getLocation
in interface Repository
getLocation
in interface RepositoryStorage
public StorageAsset getLocalPath()
Repository
getLocalPath
in interface Repository
public Set<URI> getFailoverLocations()
Repository
getFailoverLocations
in interface Repository
public boolean isScanned()
Repository
isScanned
in interface Repository
public String getSchedulingDefinition()
Repository
getSchedulingDefinition
in interface Repository
public abstract boolean hasIndex()
Repository
hasIndex
in interface Repository
public String getLayout()
Repository
getLayout
in interface Repository
public abstract RepositoryCapabilities getCapabilities()
Repository
getCapabilities
in interface Repository
public <T extends RepositoryFeature<T>> RepositoryFeature<T> getFeature(Class<T> clazz) throws UnsupportedFeatureException
Repository
getFeature
in interface Repository
T
- 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)
Repository
supportsFeature
in interface Repository
T
- The requested feature classclazz
- The requested feature classpublic Locale getPrimaryLocale()
EditableRepository
getPrimaryLocale
in interface EditableRepository
public void setName(Locale locale, String name)
EditableRepository
setName
in interface EditableRepository
locale
- the locale for which the name is setname
- The name value in the language that matches the localepublic void setDescription(Locale locale, String description)
EditableRepository
setDescription
in interface EditableRepository
locale
- the locale for which the description is setdescription
- The description in the language that matches the locale.public void setLocation(URI location)
EditableRepository
setLocation
in interface EditableRepository
location
- the location URIpublic void updateLocation(URI newLocation) throws IOException
RepositoryStorage
updateLocation
in interface RepositoryStorage
newLocation
- The URI to the new locationIOException
- If the repository cannot be relocatedpublic void addFailoverLocation(URI location)
EditableRepository
addFailoverLocation
in interface EditableRepository
location
- The location that should be used as failover.public void removeFailoverLocation(URI location)
EditableRepository
removeFailoverLocation
in interface EditableRepository
location
- the location uri to removepublic void clearFailoverLocations()
EditableRepository
clearFailoverLocations
in interface EditableRepository
public void setScanned(boolean scanned)
EditableRepository
setScanned
in interface EditableRepository
scanned
- if true, the repository is scanned regulary.public void setLayout(String layout)
EditableRepository
setLayout
in interface EditableRepository
public void setBaseUri(URI baseUri)
EditableRepository
setBaseUri
in interface EditableRepository
public void setSchedulingDefinition(String cronExpression)
EditableRepository
cronExpression
must be a valid
quartz cron definition.setSchedulingDefinition
in interface EditableRepository
cronExpression
- the cron expression.protected <T extends RepositoryFeature<T>> void addFeature(RepositoryFeature<T> feature)
public void setIndexingContext(ArchivaIndexingContext context)
EditableRepository
setIndexingContext
in interface EditableRepository
public ArchivaIndexingContext getIndexingContext()
Repository
getIndexingContext
in interface Repository
public void close()
Repository
close
in interface Repository
public boolean isOpen()
Repository
isOpen
in interface Repository
true
, if repository has not been closed, otherwise false
public 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 EventSource
public <T extends Event> void unregisterEventHandler(EventType<T> type, EventHandler<? super T> eventHandler)
unregisterEventHandler
in interface EventSource
public StorageAsset getAsset(String path)
RepositoryStorage
getAsset
in interface RepositoryStorage
public StorageAsset addAsset(String path, boolean container)
RepositoryStorage
addAsset
in interface RepositoryStorage
path
- 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
RepositoryStorage
removeAsset
in interface RepositoryStorage
IOException
public StorageAsset moveAsset(StorageAsset origin, String destination, CopyOption... copyOptions) throws IOException
RepositoryStorage
moveAsset
in interface RepositoryStorage
origin
- The original assetdestination
- The destination path pointing to the new asset.copyOptions
- The copy options.IOException
public void moveAsset(StorageAsset origin, StorageAsset destination, CopyOption... copyOptions) throws IOException
RepositoryStorage
moveAsset
in interface RepositoryStorage
origin
- The original assetdestination
- The destination path.copyOptions
- The copy options (e.g. StandardCopyOption.REPLACE_EXISTING
IOException
- If it was not possible to copy the asset.public StorageAsset copyAsset(StorageAsset origin, String destination, CopyOption... copyOptions) throws IOException
RepositoryStorage
copyAsset
in interface RepositoryStorage
origin
- The original assetdestination
- The path to the new assetcopyOptions
- The copy options, e.g. (e.g. StandardCopyOption.REPLACE_EXISTING
IOException
- If it was not possible to copy the assetpublic void copyAsset(StorageAsset origin, StorageAsset destination, CopyOption... copyOptions) throws IOException
RepositoryStorage
copyAsset
in interface RepositoryStorage
origin
- The original assetdestination
- The path to the new assetcopyOptions
- The copy options, e.g. (e.g. StandardCopyOption.REPLACE_EXISTING
IOException
- If it was not possible to copy the assetpublic void consumeData(StorageAsset asset, Consumer<InputStream> consumerFunction, boolean readLock) throws IOException
RepositoryStorage
consumeData
in interface RepositoryStorage
asset
- 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.IOException
public void consumeDataFromChannel(StorageAsset asset, Consumer<ReadableByteChannel> consumerFunction, boolean readLock) throws IOException
RepositoryStorage
consumeDataFromChannel
in interface RepositoryStorage
asset
- 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.IOException
public void writeData(StorageAsset asset, Consumer<OutputStream> consumerFunction, boolean writeLock) throws IOException
RepositoryStorage
writeData
in interface RepositoryStorage
asset
- 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.IOException
public void writeDataToChannel(StorageAsset asset, Consumer<WritableByteChannel> consumerFunction, boolean writeLock) throws IOException
RepositoryStorage
writeDataToChannel
in interface RepositoryStorage
asset
- 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.IOException
protected void setStorage(RepositoryStorage storage)
protected RepositoryStorage getStorage()
Copyright © 2006–2019 The Apache Software Foundation. All rights reserved.