Class JcrPackageRegistry
- java.lang.Object
-
- org.apache.jackrabbit.vault.packaging.registry.impl.AbstractPackageRegistry
-
- org.apache.jackrabbit.vault.packaging.registry.impl.JcrPackageRegistry
-
- All Implemented Interfaces:
InternalPackageRegistry,PackageRegistry
public class JcrPackageRegistry extends AbstractPackageRegistry
JcrPackagePersistence...
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.jackrabbit.vault.packaging.registry.impl.AbstractPackageRegistry
AbstractPackageRegistry.SecurityConfig
-
-
Field Summary
-
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 JcrPackageRegistry(@NotNull Session session, @Nullable String... roots)Creates a new JcrPackageRegistry based on the given session.JcrPackageRegistry(@NotNull Session session, AbstractPackageRegistry.SecurityConfig securityConfig, boolean isStrict, boolean overwritePrimaryTypesOfFoldersByDefault, IdConflictPolicy defaultIdConflictPolicy, @Nullable String... roots)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(@NotNull PackageId id)Checks if this registry contains the package with the given id.JcrPackagecreate(String group, String name, String version)@NotNull JcrPackagecreateNew(@NotNull Node parent, @NotNull PackageId pid, @Nullable VaultPackage pack, boolean autoSave)Creates a new jcr vault package.voiddispatch(PackageEvent.Type type, @NotNull PackageId id, @Nullable PackageId[] related)Dispatches a package event using the configured dispatcher.StringgetInstallationPath(PackageId id)Returns the primary path of this package. please note that since 2.3 this also includes the version, but never the extension (.zip).@NotNull List<Node>getPackageRoots()Returns the list of package roots that currently exist in no particular order.@NotNull String[]getPackRootPaths()Returns the package root paths this registry is created with.@Nullable NodegetPrimaryPackageRoot(boolean autoCreate)Returns the primary package root.voidinstallPackage(@NotNull Session session, @NotNull RegisteredPackage pkg, @NotNull ImportOptions opts, boolean extract)Nodemkdir(String path, boolean autoSave)yet another Convenience method to create intermediate nodes.@Nullable RegisteredPackageopen(@NotNull PackageId id)Opens the package with the given id.JcrPackageopen(Node node, boolean allowInvalid)@Nullable JcrPackageopenJcrPackage(@NotNull PackageId 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.JcrPackagerename(JcrPackage pack, String group, String name, String version)PackageIdresolve(Dependency dependency, boolean onlyInstalled)Tries to resolve the given dependency and returns the id of the package that matches the dependency filter best.voidsetBaseRegistry(@Nullable PackageRegistry baseRegisry)Sets fallback PackageRegistry for dependency lookupvoidsetDispatcher(@Nullable PackageEventDispatcher dispatcher)Sets the event dispatchervoiduninstallPackage(@NotNull Session session, @NotNull RegisteredPackage pkg, @NotNull ImportOptions opts)JcrPackageupload(@NotNull ZipVaultPackage pkg, boolean replace)Uploads the given package to the JCR package manager,JcrPackageupload(InputStream in, boolean replace)-
Methods inherited from class org.apache.jackrabbit.vault.packaging.registry.impl.AbstractPackageRegistry
analyzeDependencies, createExecutionPlan, createRandomPid, getDefaultIdConflictPolicy, getRelativeInstallationPath, getSecurityConfig, isStrictByDefault, overwritePrimaryTypesOfFoldersByDefault, usage
-
-
-
-
Constructor Detail
-
JcrPackageRegistry
public JcrPackageRegistry(@NotNull @NotNull Session session, @Nullable @Nullable String... roots)Creates a new JcrPackageRegistry based on the given session.- Parameters:
session- the JCR session that is used to access the repository.roots- the root paths to store the packages.
-
JcrPackageRegistry
public JcrPackageRegistry(@NotNull @NotNull Session session, @Nullable AbstractPackageRegistry.SecurityConfig securityConfig, boolean isStrict, boolean overwritePrimaryTypesOfFoldersByDefault, IdConflictPolicy defaultIdConflictPolicy, @Nullable @Nullable String... roots)
-
-
Method Detail
-
setBaseRegistry
public void setBaseRegistry(@Nullable @Nullable PackageRegistry baseRegisry)Sets fallback PackageRegistry for dependency lookup- Parameters:
baseRegisry-
-
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
-
getPackRootPaths
@NotNull public @NotNull String[] getPackRootPaths()
Returns the package root paths this registry is created with.- Returns:
- the package root paths.
-
getPrimaryPackageRoot
@Nullable public @Nullable Node getPrimaryPackageRoot(boolean autoCreate) throws RepositoryException
Returns the primary package root. If the root does not exist yet andautoCreateistrueit will be created.- Parameters:
autoCreate- iftruethe roots are created if missing.- Returns:
- the the package root or
null - Throws:
RepositoryException- if an error occurs.
-
getPackageRoots
@NotNull public @NotNull List<Node> getPackageRoots() throws RepositoryException
Returns the list of package roots that currently exist in no particular order.- Returns:
- the list of package roots.
- Throws:
RepositoryException- if an error occurs.
-
open
@Nullable public @Nullable RegisteredPackage open(@NotNull @NotNull PackageId id) throws IOException
Description copied from class:AbstractPackageRegistryOpens the package with the given id.- Specified by:
openin interfacePackageRegistry- Specified by:
openin classAbstractPackageRegistry- Parameters:
id- the package id- Returns:
- the package or
nullif it does not exists. - Throws:
IOException- if an I/O error occurs.
-
openJcrPackage
@Nullable public @Nullable JcrPackage openJcrPackage(@NotNull @NotNull PackageId id) throws RepositoryException
- Throws:
RepositoryException
-
contains
public boolean contains(@NotNull @NotNull PackageId id) throws IOExceptionDescription copied from class:AbstractPackageRegistryChecks if this registry contains the package with the given id.- Specified by:
containsin interfacePackageRegistry- Specified by:
containsin classAbstractPackageRegistry- Parameters:
id- the package id.- Returns:
trueif the package is registered.- Throws:
IOException- if an I/O error occurs.
-
open
public JcrPackage open(Node node, boolean allowInvalid) throws RepositoryException
- Throws:
RepositoryException
-
resolve
public PackageId resolve(Dependency dependency, boolean onlyInstalled) throws IOException
Description copied from class:AbstractPackageRegistryTries to resolve the given dependency and returns the id of the package that matches the dependency filter best.- Specified by:
resolvein interfacePackageRegistry- Specified by:
resolvein classAbstractPackageRegistry- 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.
-
register
@NotNull public @NotNull PackageId register(@NotNull @NotNull InputStream in, boolean replace) throws IOException, PackageExistsException
Description copied from class:AbstractPackageRegistryRegisters 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- Specified by:
registerin classAbstractPackageRegistry- 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 class:AbstractPackageRegistryRegisters 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- Specified by:
registerin classAbstractPackageRegistry- 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 class:AbstractPackageRegistryRegisters 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- Specified by:
registerExternalin classAbstractPackageRegistry- 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.
-
upload
public JcrPackage upload(InputStream in, boolean replace) throws RepositoryException, IOException, PackageExistsException
-
upload
public JcrPackage upload(@NotNull @NotNull ZipVaultPackage pkg, boolean replace) throws RepositoryException, IOException, PackageExistsException
Uploads the given package to the JCR package manager,- Parameters:
pkg- the packagereplace-- Returns:
- the uploaded package
- Throws:
RepositoryExceptionIOExceptionPackageExistsException
-
mkdir
public Node mkdir(String path, boolean autoSave) throws RepositoryException
yet another Convenience method to create intermediate nodes.- Parameters:
path- path to createautoSave- iftrueall changes are automatically persisted- Returns:
- the node
- Throws:
RepositoryException- if an error occurrs
-
create
public JcrPackage create(String group, String name, String version) throws RepositoryException, IOException
- Throws:
RepositoryExceptionIOException
-
createNew
@NotNull public @NotNull JcrPackage createNew(@NotNull @NotNull Node parent, @NotNull @NotNull PackageId pid, @Nullable @Nullable VaultPackage pack, boolean autoSave) throws RepositoryException, IOException
Creates a new jcr vault package.- Parameters:
parent- the parent nodepid- the package id of the new package.pack- the underlying zip package or null.autoSave- iftruethe changes are persisted immediately- Returns:
- the created jcr vault package.
- Throws:
RepositoryException- if an repository error occursIOException- if an I/O error occurs- Since:
- 2.3.0
-
remove
public void remove(@NotNull @NotNull PackageId id) throws IOException, NoSuchPackageExceptionDescription copied from class:AbstractPackageRegistryRemoves the package from this registry.- Specified by:
removein interfacePackageRegistry- Specified by:
removein 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
-
rename
public JcrPackage rename(JcrPackage pack, String group, String name, String version) throws PackageException, RepositoryException
- Throws:
PackageExceptionRepositoryException
-
packages
@NotNull public @NotNull Set<PackageId> packages() throws IOException
Description copied from class:AbstractPackageRegistryReturns as set of all packages registered in this registry.- Specified by:
packagesin interfacePackageRegistry- Specified by:
packagesin classAbstractPackageRegistry- Returns:
- a set of package ids.
- Throws:
IOException- if an I/O error occurs.
-
getInstallationPath
public String getInstallationPath(PackageId id)
Returns the primary 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 path of this package
- Since:
- 2.2
-
installPackage
public void installPackage(@NotNull @NotNull Session session, @NotNull @NotNull RegisteredPackage pkg, @NotNull @NotNull ImportOptions opts, boolean extract) throws IOException, PackageExceptionDescription copied from class:AbstractPackageRegistry- Specified by:
installPackagein interfaceInternalPackageRegistry- Specified by:
installPackagein classAbstractPackageRegistry- Throws:
IOExceptionPackageException
-
uninstallPackage
public void uninstallPackage(@NotNull @NotNull Session session, @NotNull @NotNull RegisteredPackage pkg, @NotNull @NotNull ImportOptions opts) throws IOException, PackageExceptionDescription copied from class:AbstractPackageRegistry- Specified by:
uninstallPackagein interfaceInternalPackageRegistry- Specified by:
uninstallPackagein classAbstractPackageRegistry- Throws:
IOExceptionPackageException
-
-