Class AbstractPackageRegistry
- java.lang.Object
-
- org.apache.jackrabbit.vault.packaging.registry.impl.AbstractPackageRegistry
-
- All Implemented Interfaces:
InternalPackageRegistry,PackageRegistry
- Direct Known Subclasses:
FSPackageRegistry,JcrPackageRegistry
public abstract class AbstractPackageRegistry extends Object implements PackageRegistry, InternalPackageRegistry
Abstraction for shared methods of PackageRegistry & InternalPackageRegistry implementations
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractPackageRegistry.SecurityConfig
-
Field Summary
Fields Modifier and Type Field Description static StringARCHIVE_PACKAGE_ROOT_PATHArchive root path for packagesstatic StringDEFAULT_PACKAGE_ROOT_PATHdefault root path for packagesstatic StringDEFAULT_PACKAGE_ROOT_PATH_PREFIXdefault root path prefix for packagesprotected @NotNull AbstractPackageRegistry.SecurityConfigsecurityConfig
-
Constructor Summary
Constructors Constructor Description AbstractPackageRegistry(AbstractPackageRegistry.SecurityConfig securityConfig, boolean isStrictByDefault, boolean overwritePrimaryTypesOfFoldersByDefault, IdConflictPolicy defaultIdConflictPolicy)
-
Method Summary
All Methods Static Methods Instance Methods Abstract 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.abstract booleancontains(PackageId id)Checks if this registry contains the package with the given id.@NotNull ExecutionPlanBuildercreateExecutionPlan()Creates a new execution plan builder.protected static PackageIdcreateRandomPid()Creates a random package id for packages that lack one.IdConflictPolicygetDefaultIdConflictPolicy()static StringgetRelativeInstallationPath(PackageId id)Returns the relative path of this package. please note that since 2.3 this also includes the version, but never the extension (.zip).@NotNull AbstractPackageRegistry.SecurityConfiggetSecurityConfig()abstract voidinstallPackage(Session session, RegisteredPackage pkg, ImportOptions opts, boolean extract)booleanisStrictByDefault()abstract RegisteredPackageopen(PackageId id)Opens the package with the given id.booleanoverwritePrimaryTypesOfFoldersByDefault()abstract Set<PackageId>packages()Returns as set of all packages registered in this registry.abstract PackageIdregister(File file, boolean replace)Registers a package provided via a file.abstract PackageIdregister(InputStream in, boolean replace)Registers a package provided via an input stream.abstract PackageIdregisterExternal(File file, boolean replace)Registers a package provided via an external file.abstract voidremove(PackageId id)Removes the package from this registry.abstract PackageIdresolve(Dependency dependency, boolean onlyInstalled)Tries to resolve the given dependency and returns the id of the package that matches the dependency filter best.abstract voiduninstallPackage(Session session, RegisteredPackage pkg, ImportOptions opts)@NotNull PackageId[]usage(PackageId id)Returns the package ids of installed packages that depend on the given package.
-
-
-
Field Detail
-
DEFAULT_PACKAGE_ROOT_PATH
public static final String DEFAULT_PACKAGE_ROOT_PATH
default root path for packages- See Also:
- Constant Field Values
-
ARCHIVE_PACKAGE_ROOT_PATH
public static final String ARCHIVE_PACKAGE_ROOT_PATH
Archive root path for packages- See Also:
- Constant Field Values
-
DEFAULT_PACKAGE_ROOT_PATH_PREFIX
public static final String DEFAULT_PACKAGE_ROOT_PATH_PREFIX
default root path prefix for packages- See Also:
- Constant Field Values
-
securityConfig
@NotNull protected @NotNull AbstractPackageRegistry.SecurityConfig securityConfig
-
-
Constructor Detail
-
AbstractPackageRegistry
public AbstractPackageRegistry(AbstractPackageRegistry.SecurityConfig securityConfig, boolean isStrictByDefault, boolean overwritePrimaryTypesOfFoldersByDefault, IdConflictPolicy defaultIdConflictPolicy)
-
-
Method Detail
-
isStrictByDefault
public boolean isStrictByDefault()
-
overwritePrimaryTypesOfFoldersByDefault
public boolean overwritePrimaryTypesOfFoldersByDefault()
-
getDefaultIdConflictPolicy
public IdConflictPolicy getDefaultIdConflictPolicy()
-
installPackage
public abstract void installPackage(Session session, RegisteredPackage pkg, ImportOptions opts, boolean extract) throws IOException, PackageException
- Specified by:
installPackagein interfaceInternalPackageRegistry- Throws:
IOExceptionPackageException
-
uninstallPackage
public abstract void uninstallPackage(Session session, RegisteredPackage pkg, ImportOptions opts) throws IOException, PackageException
- Specified by:
uninstallPackagein interfaceInternalPackageRegistry- Throws:
IOExceptionPackageException
-
contains
public abstract boolean contains(PackageId id) throws IOException
Checks 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
public abstract Set<PackageId> packages() throws IOException
Returns 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
public abstract RegisteredPackage open(PackageId id) throws IOException
Opens 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
public abstract PackageId register(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, 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
public abstract PackageId register(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, 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
public abstract PackageId registerExternal(File file, boolean replace) throws IOException, PackageExistsException
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, 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 abstract void remove(PackageId id) throws IOException, NoSuchPackageException
Removes 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
Creates 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
public abstract 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:
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(PackageId id) throws IOException
Returns 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()
Creates 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
-
getRelativeInstallationPath
public static String getRelativeInstallationPath(PackageId id)
Returns the relative path of this package. please note that since 2.3 this also includes the version, but never the extension (.zip).- Parameters:
id- the package id- Returns:
- the relative path of this package
- Since:
- 2.2
-
createRandomPid
protected static PackageId createRandomPid()
Creates a random package id for packages that lack one.- Returns:
- a random package id.
-
getSecurityConfig
@NotNull public @NotNull AbstractPackageRegistry.SecurityConfig getSecurityConfig()
-
-