Class CompositePackageRegistry
- java.lang.Object
-
- org.apache.jackrabbit.vault.packaging.registry.impl.CompositePackageRegistry
-
- All Implemented Interfaces:
PackageRegistry
public class CompositePackageRegistry extends Object implements PackageRegistry
Package registry wrapping a number ofPackageRegistryinstances. This registry only works, if each package id contained in any of the registries is unique among all registries. In case duplicates are detected exceptions are thrown. The first given registry is used for registering new packages.
-
-
Constructor Summary
Constructors Constructor Description CompositePackageRegistry(List<PackageRegistry> registries)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull DependencyReportanalyzeDependencies(@NotNull PackageId id, boolean onlyInstalled)Creates a dependency report that lists the resolved and unresolved dependencies.booleancontains(@NotNull PackageId id)Checks if this registry contains the package with the given id.@NotNull ExecutionPlanBuildercreateExecutionPlan()Creates a new execution plan builder.@Nullable RegisteredPackageopen(@NotNull PackageId id)Opens the package with the given id.@NotNull Set<PackageId>packages()Returns as set of all packages registered in this registry.@NotNull PackageIdregister(@NotNull File file, boolean replace)Registers a package provided via a file.@NotNull PackageIdregister(@NotNull InputStream in, boolean replace)Registers a package provided via an input stream.@NotNull PackageIdregisterExternal(@NotNull File file, boolean replace)Registers a package provided via an external file.voidremove(@NotNull PackageId id)Removes the package from this registry.@Nullable PackageIdresolve(@NotNull Dependency dependency, boolean onlyInstalled)Tries to resolve the given dependency and returns the id of the package that matches the dependency filter best.@NotNull PackageId[]usage(@NotNull PackageId id)Returns the package ids of installed packages that depend on the given package.
-
-
-
Constructor Detail
-
CompositePackageRegistry
public CompositePackageRegistry(List<PackageRegistry> registries) throws IOException
- Throws:
IOException
-
-
Method Detail
-
contains
public boolean contains(@NotNull @NotNull PackageId id) throws IOExceptionDescription copied from interface:PackageRegistryChecks if this registry contains the package with the given id.- Specified by:
containsin interfacePackageRegistry- Parameters:
id- the package id.- Returns:
trueif the package is registered.- Throws:
IOException- if an I/O error occurs.
-
packages
@NotNull public @NotNull Set<PackageId> packages() throws IOException
Description copied from interface:PackageRegistryReturns as set of all packages registered in this registry.- Specified by:
packagesin interfacePackageRegistry- Returns:
- a set of package ids.
- Throws:
IOException- if an I/O error occurs.
-
open
@Nullable public @Nullable RegisteredPackage open(@NotNull @NotNull PackageId id) throws IOException
Description copied from interface:PackageRegistryOpens the package with the given id.- Specified by:
openin interfacePackageRegistry- Parameters:
id- the package id- Returns:
- the package or
nullif it does not exists. - Throws:
IOException- if an I/O error occurs.
-
register
@NotNull public @NotNull PackageId register(@NotNull @NotNull InputStream in, boolean replace) throws IOException, PackageExistsException
Description copied from interface:PackageRegistryRegisters a package provided via an input stream. The method fails, if a package with the same id already exists, andreplaceis set tofalse. otherwise the existing package is replaced.- Specified by:
registerin interfacePackageRegistry- Parameters:
in- the input stream to the package datareplace-trueif existing package should be replaced.- Returns:
- the new package id.
- Throws:
IOException- if an I/O error occurs.PackageExistsException- if the package exists andreplaceisfalse.
-
register
@NotNull public @NotNull PackageId register(@NotNull @NotNull File file, boolean replace) throws IOException, PackageExistsException
Description copied from interface:PackageRegistryRegisters a package provided via a file. The method fails, if a package with the same id already exists, andreplaceis set tofalse; otherwise the existing package is replaced.- Specified by:
registerin interfacePackageRegistry- Parameters:
file- the file to the package datareplace-trueif existing package should be replaced.- Returns:
- the new package id.
- Throws:
IOException- if an I/O error occurrs.PackageExistsException- if the package exists andreplaceisfalse.
-
registerExternal
@NotNull public @NotNull PackageId registerExternal(@NotNull @NotNull File file, boolean replace) throws IOException, PackageExistsException
Description copied from interface:PackageRegistryRegisters 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, andreplaceis set tofalse; otherwise the existing package is replaced.- Specified by:
registerExternalin interfacePackageRegistry- Parameters:
file- the file to the package data.replace-trueif existing package should be replaced.- Returns:
- the new package id.
- Throws:
IOException- if an I/O error occurrs.PackageExistsException- if the package exists andreplaceisfalse.
-
remove
public void remove(@NotNull @NotNull PackageId id) throws IOException, NoSuchPackageExceptionDescription copied from interface:PackageRegistryRemoves the package from this registry.- Specified by:
removein interfacePackageRegistry- Parameters:
id- the id of the package to remove- Throws:
IOException- if an I/O error occurrs.NoSuchPackageException- if the package does not exist
-
analyzeDependencies
@NotNull public @NotNull DependencyReport analyzeDependencies(@NotNull @NotNull PackageId id, boolean onlyInstalled) throws IOException, NoSuchPackageException
Description copied from interface:PackageRegistryCreates a dependency report that lists the resolved and unresolved dependencies.- Specified by:
analyzeDependenciesin interfacePackageRegistry- Parameters:
id- the package id.onlyInstalled- iftrueonly installed packages are used for resolution- Returns:
- the report
- Throws:
IOException- if an error accessing the repository occurrsNoSuchPackageException- if the package with the giveniddoes not exist.
-
resolve
@Nullable public @Nullable PackageId resolve(@NotNull @NotNull Dependency dependency, boolean onlyInstalled) throws IOException
Description copied from interface:PackageRegistryTries to resolve the given dependency and returns the id of the package that matches the dependency filter best.- Specified by:
resolvein interfacePackageRegistry- Parameters:
dependency- the dependency to resolve against.onlyInstalled- iftrueonly installed packages are respected.- Returns:
- the package id or
null - Throws:
IOException- if an I/O error occurrs.
-
usage
@NotNull public @NotNull PackageId[] usage(@NotNull @NotNull PackageId id) throws IOException
Description copied from interface:PackageRegistryReturns the package ids of installed packages that depend on the given package.- Specified by:
usagein interfacePackageRegistry- Parameters:
id- the package id to search for- Returns:
- the array of package ids.
- Throws:
IOException- if an I/O error occurs.
-
createExecutionPlan
@NotNull public @NotNull ExecutionPlanBuilder createExecutionPlan()
Description copied from interface:PackageRegistryCreates a new execution plan builder. The builder allows to create an execution plan for package installation related tasks.- Specified by:
createExecutionPlanin interfacePackageRegistry- Returns:
- a new builder
-
-