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 boolean
contains(@NotNull PackageId id)
Checks if this registry contains the package with the given id.JcrPackage
create(String group, String name, String version)
@NotNull JcrPackage
createNew(@NotNull Node parent, @NotNull PackageId pid, @Nullable VaultPackage pack, boolean autoSave)
Creates a new jcr vault package.void
dispatch(PackageEvent.Type type, @NotNull PackageId id, @Nullable PackageId[] related)
Dispatches a package event using the configured dispatcher.String
getInstallationPath(PackageId id)
Returns the primary path of this package.@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 Node
getPrimaryPackageRoot(boolean autoCreate)
Returns the primary package root.void
installPackage(@NotNull Session session, @NotNull RegisteredPackage pkg, @NotNull ImportOptions opts, boolean extract)
Node
mkdir(String path, boolean autoSave)
yet another Convenience method to create intermediate nodes.@Nullable RegisteredPackage
open(@NotNull PackageId id)
Opens the package with the given id.JcrPackage
open(Node node, boolean allowInvalid)
@Nullable JcrPackage
openJcrPackage(@NotNull PackageId 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.JcrPackage
rename(JcrPackage pack, String group, String name, String version)
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
setBaseRegistry(@Nullable PackageRegistry baseRegisry)
Sets fallback PackageRegistry for dependency lookupvoid
setDispatcher(@Nullable PackageEventDispatcher dispatcher)
Sets the event dispatchervoid
uninstallPackage(@NotNull Session session, @NotNull RegisteredPackage pkg, @NotNull ImportOptions opts)
JcrPackage
upload(@NotNull ZipVaultPackage pkg, boolean replace)
Uploads the given package to the JCR package manager,JcrPackage
upload(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 andautoCreate
istrue
it will be created.- Parameters:
autoCreate
- iftrue
the 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: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.
-
openJcrPackage
@Nullable public @Nullable JcrPackage openJcrPackage(@NotNull @NotNull PackageId id) throws RepositoryException
- Throws:
RepositoryException
-
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.
-
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:AbstractPackageRegistry
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
Description copied from class:AbstractPackageRegistry
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
.
-
register
@NotNull public @NotNull PackageId register(@NotNull @NotNull File file, boolean replace) throws IOException, PackageExistsException
Description copied from class:AbstractPackageRegistry
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
.
-
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:
RepositoryException
IOException
PackageExistsException
-
mkdir
public Node mkdir(String path, boolean autoSave) throws RepositoryException
yet another Convenience method to create intermediate nodes.- Parameters:
path
- path to createautoSave
- iftrue
all 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:
RepositoryException
IOException
-
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
- iftrue
the 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, NoSuchPackageException
Description copied from class:AbstractPackageRegistry
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
-
rename
public JcrPackage rename(JcrPackage pack, String group, String name, String version) throws PackageException, RepositoryException
- Throws:
PackageException
RepositoryException
-
packages
@NotNull public @NotNull Set<PackageId> packages() throws IOException
Description copied from class:AbstractPackageRegistry
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.
-
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, PackageException
Description copied from class:AbstractPackageRegistry
- 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
Description copied from class:AbstractPackageRegistry
- Specified by:
uninstallPackage
in interfaceInternalPackageRegistry
- Specified by:
uninstallPackage
in classAbstractPackageRegistry
- Throws:
IOException
PackageException
-
-