Class FSPackageRegistry
- java.lang.Object
-
- org.apache.jackrabbit.vault.packaging.registry.impl.AbstractPackageRegistry
-
- org.apache.jackrabbit.vault.packaging.registry.impl.FSPackageRegistry
-
- All Implemented Interfaces:
InternalPackageRegistry
,PackageRegistry
public class FSPackageRegistry extends AbstractPackageRegistry
FileSystem based registry not depending on a JCR Session. All metadata is stored in Filesystem and can be prepared and used without a running JCR repository Only methods to install or uninstall packages require an activeSession
object of running jcr instance to perform the actual installation tasks
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.jackrabbit.vault.packaging.registry.impl.AbstractPackageRegistry
AbstractPackageRegistry.SecurityConfig
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
REPOSITORY_HOME
-
Fields inherited from class org.apache.jackrabbit.vault.packaging.registry.impl.AbstractPackageRegistry
ARCHIVE_PACKAGE_ROOT_PATH, DEFAULT_PACKAGE_ROOT_PATH, DEFAULT_PACKAGE_ROOT_PATH_PREFIX, securityConfig
-
-
Constructor Summary
Constructors Constructor Description FSPackageRegistry()
Default constructor for OSGi initialization (homeDir defined via activator)FSPackageRegistry(@NotNull File homeDir)
Deprecated.FSPackageRegistry(@NotNull File homeDir, InstallationScope scope)
Deprecated.FSPackageRegistry(@NotNull File homeDir, InstallationScope scope, AbstractPackageRegistry.SecurityConfig securityConfig)
Deprecated.FSPackageRegistry(@NotNull File homeDir, InstallationScope scope, AbstractPackageRegistry.SecurityConfig securityConfig, boolean isStrict, boolean overwritePrimaryTypesOfFolders, IdConflictPolicy defaultIdConflictPolicy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activate(org.osgi.framework.BundleContext context, org.apache.jackrabbit.vault.packaging.registry.impl.FSPackageRegistry.Config config)
@NotNull DependencyReport
analyzeDependencies(@NotNull PackageId id, boolean onlyInstalled)
Creates a dependency report that lists the resolved and unresolved dependencies.boolean
contains(@NotNull PackageId id)
Checks if this registry contains the package with the given id.void
dispatch(PackageEvent.Type type, @NotNull PackageId id, @Nullable PackageId[] related)
Dispatches a package event using the configured dispatcher.void
installPackage(@NotNull Session session, @NotNull RegisteredPackage pkg, @NotNull ImportOptions opts, boolean extract)
@Nullable RegisteredPackage
open(@NotNull PackageId id)
Opens the package with the given id.protected @NotNull VaultPackage
openPackageFile(@NotNull PackageId id)
Opens the package of a file with the given Id.@NotNull Set<PackageId>
packages()
Returns as set of all packages registered in this registry.@NotNull PackageId
register(@NotNull File file, boolean replace)
Registers a package provided via a file.@NotNull PackageId
register(@NotNull InputStream in, boolean replace)
Registers a package provided via an input stream.@NotNull PackageId
registerExternal(@NotNull File file, boolean replace)
Registers a package provided via an external file.void
remove(@NotNull PackageId id)
Removes the package from this registry.PackageId
resolve(Dependency dependency, boolean onlyInstalled)
Tries to resolve the given dependency and returns the id of the package that matches the dependency filter best.void
setDispatcher(@Nullable PackageEventDispatcher dispatcher)
Sets the event dispatchervoid
uninstallPackage(@NotNull Session session, @NotNull RegisteredPackage pkg, @NotNull ImportOptions opts)
Uninstallation not supported for FS based PackageRegistryprotected ZipVaultPackage
upload(InputStream in, boolean replace)
-
Methods inherited from class org.apache.jackrabbit.vault.packaging.registry.impl.AbstractPackageRegistry
createExecutionPlan, createRandomPid, getDefaultIdConflictPolicy, getRelativeInstallationPath, getSecurityConfig, isStrictByDefault, overwritePrimaryTypesOfFoldersByDefault, usage
-
-
-
-
Field Detail
-
REPOSITORY_HOME
protected static final String REPOSITORY_HOME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FSPackageRegistry
@Deprecated public FSPackageRegistry(@NotNull @NotNull File homeDir) throws IOException
Deprecated.Creates a new FSPackageRegistry based on the given home directory.- Parameters:
homeDir
- the directory in which packages and their metadata is stored- Throws:
IOException
- If an I/O error occurs.
-
FSPackageRegistry
@Deprecated public FSPackageRegistry(@NotNull @NotNull File homeDir, InstallationScope scope) throws IOException
Deprecated.Creates a new FSPackageRegistry based on the given home directory.- Parameters:
homeDir
- the directory in which packages and their metadata is storedscope
- to set a corresponding workspacefilter- Throws:
IOException
- If an I/O error occurs.
-
FSPackageRegistry
@Deprecated public FSPackageRegistry(@NotNull @NotNull File homeDir, InstallationScope scope, @Nullable AbstractPackageRegistry.SecurityConfig securityConfig) throws IOException
Deprecated.- Parameters:
homeDir
-scope
-securityConfig
-- Throws:
IOException
-
FSPackageRegistry
public FSPackageRegistry(@NotNull @NotNull File homeDir, InstallationScope scope, @Nullable AbstractPackageRegistry.SecurityConfig securityConfig, boolean isStrict, boolean overwritePrimaryTypesOfFolders, IdConflictPolicy defaultIdConflictPolicy) throws IOException
- Throws:
IOException
-
FSPackageRegistry
public FSPackageRegistry() throws IOException
Default constructor for OSGi initialization (homeDir defined via activator)- Throws:
IOException
-
-
Method Detail
-
activate
public void activate(org.osgi.framework.BundleContext context, org.apache.jackrabbit.vault.packaging.registry.impl.FSPackageRegistry.Config config) throws IOException
- Throws:
IOException
-
setDispatcher
public void setDispatcher(@Nullable @Nullable PackageEventDispatcher dispatcher)
Sets the event dispatcher- Parameters:
dispatcher
- the dispatcher.
-
dispatch
public void dispatch(@NotNull PackageEvent.Type type, @NotNull @NotNull PackageId id, @Nullable @Nullable PackageId[] related)
Dispatches a package event using the configured dispatcher.- Parameters:
type
- event typeid
- package idrelated
- related packages
-
open
@Nullable public @Nullable RegisteredPackage open(@NotNull @NotNull PackageId id) throws IOException
Description copied from class:AbstractPackageRegistry
Opens the package with the given id.- Specified by:
open
in interfacePackageRegistry
- Specified by:
open
in classAbstractPackageRegistry
- Parameters:
id
- the package id- Returns:
- the package or
null
if it does not exists. - Throws:
IOException
- if an I/O error occurs.
-
contains
public boolean contains(@NotNull @NotNull PackageId id) throws IOException
Description copied from class:AbstractPackageRegistry
Checks if this registry contains the package with the given id.- Specified by:
contains
in interfacePackageRegistry
- Specified by:
contains
in classAbstractPackageRegistry
- Parameters:
id
- the package id.- Returns:
true
if the package is registered.- Throws:
IOException
- if an I/O error occurs.
-
openPackageFile
@NotNull protected @NotNull VaultPackage openPackageFile(@NotNull @NotNull PackageId id) throws IOException, NoSuchPackageException
Opens the package of a file with the given Id.- Parameters:
id
- The Id of package file.- Returns:
- the package
- Throws:
IOException
- if an I/O error occurs.NoSuchPackageException
-
analyzeDependencies
@NotNull public @NotNull DependencyReport analyzeDependencies(@NotNull @NotNull PackageId id, boolean onlyInstalled) throws IOException, NoSuchPackageException
Creates a dependency report that lists the resolved and unresolved dependencies.- Specified by:
analyzeDependencies
in interfacePackageRegistry
- Overrides:
analyzeDependencies
in classAbstractPackageRegistry
- Parameters:
id
- the package id.onlyInstalled
- iftrue
only installed packages are used for resolution- Returns:
- the report
- Throws:
IOException
- if an error accessing the repository occurrsNoSuchPackageException
- if the package with the givenid
does not exist.
-
resolve
public PackageId resolve(Dependency dependency, boolean onlyInstalled) throws IOException
Tries to resolve the given dependency and returns the id of the package that matches the dependency filter best.- Specified by:
resolve
in interfacePackageRegistry
- Specified by:
resolve
in classAbstractPackageRegistry
- Parameters:
dependency
- the dependency to resolve against.onlyInstalled
- iftrue
only installed packages are respected.- Returns:
- the package id or
null
- Throws:
IOException
- if an I/O error occurrs.
-
register
@NotNull public @NotNull PackageId register(@NotNull @NotNull InputStream in, boolean replace) throws IOException, PackageExistsException
Registers a package provided via an input stream. The method fails, if a package with the same id already exists, andreplace
is set tofalse
. otherwise the existing package is replaced.- Specified by:
register
in interfacePackageRegistry
- Specified by:
register
in classAbstractPackageRegistry
- Parameters:
in
- the input stream to the package datareplace
-true
if existing package should be replaced.- Returns:
- the new package id.
- Throws:
IOException
- if an I/O error occurs.PackageExistsException
- if the package exists andreplace
isfalse
.
-
upload
protected ZipVaultPackage upload(InputStream in, boolean replace) throws IOException, PackageExistsException
- Throws:
IOException
PackageExistsException
-
register
@NotNull public @NotNull PackageId register(@NotNull @NotNull File file, boolean replace) throws IOException, PackageExistsException
Registers a package provided via a file. The method fails, if a package with the same id already exists, andreplace
is set tofalse
; otherwise the existing package is replaced.- Specified by:
register
in interfacePackageRegistry
- Specified by:
register
in classAbstractPackageRegistry
- Parameters:
file
- the file to the package datareplace
-true
if existing package should be replaced.- Returns:
- the new package id.
- Throws:
IOException
- if an I/O error occurrs.PackageExistsException
- if the package exists andreplace
isfalse
.
-
registerExternal
@NotNull public @NotNull PackageId registerExternal(@NotNull @NotNull File file, boolean replace) throws IOException, PackageExistsException
Description copied from class:AbstractPackageRegistry
Registers a package provided via an external file. The binary data of the package will not be copied into the underlying persistence but only be referenced. Removing such a linked package afterwards will not delete the original file. The method fails, if a package with the same id already exists, andreplace
is set tofalse
; otherwise the existing package is replaced.- Specified by:
registerExternal
in interfacePackageRegistry
- Specified by:
registerExternal
in classAbstractPackageRegistry
- Parameters:
file
- the file to the package data.replace
-true
if existing package should be replaced.- Returns:
- the new package id.
- Throws:
IOException
- if an I/O error occurrs.PackageExistsException
- if the package exists andreplace
isfalse
.
-
remove
public void remove(@NotNull @NotNull PackageId id) throws IOException, NoSuchPackageException
Removes the package from this registry.- Specified by:
remove
in interfacePackageRegistry
- Specified by:
remove
in classAbstractPackageRegistry
- Parameters:
id
- the id of the package to remove- Throws:
IOException
- if an I/O error occurrs.NoSuchPackageException
- if the package does not exist
-
packages
@NotNull public @NotNull Set<PackageId> packages() throws IOException
Returns as set of all packages registered in this registry.- Specified by:
packages
in interfacePackageRegistry
- Specified by:
packages
in classAbstractPackageRegistry
- Returns:
- a set of package ids.
- Throws:
IOException
- if an I/O error occurs.
-
installPackage
public void installPackage(@NotNull @NotNull Session session, @NotNull @NotNull RegisteredPackage pkg, @NotNull @NotNull ImportOptions opts, boolean extract) throws IOException, PackageException
- Specified by:
installPackage
in interfaceInternalPackageRegistry
- Specified by:
installPackage
in classAbstractPackageRegistry
- Throws:
IOException
PackageException
-
uninstallPackage
public void uninstallPackage(@NotNull @NotNull Session session, @NotNull @NotNull RegisteredPackage pkg, @NotNull @NotNull ImportOptions opts) throws IOException, PackageException
Uninstallation not supported for FS based PackageRegistry- Specified by:
uninstallPackage
in interfaceInternalPackageRegistry
- Specified by:
uninstallPackage
in classAbstractPackageRegistry
- Throws:
IOException
PackageException
-
-