Class JcrPackageManagerImpl
- java.lang.Object
-
- org.apache.jackrabbit.vault.packaging.impl.PackageManagerImpl
-
- org.apache.jackrabbit.vault.packaging.impl.JcrPackageManagerImpl
-
- All Implemented Interfaces:
JcrPackageManager
,PackageManager
public class JcrPackageManagerImpl extends PackageManagerImpl implements JcrPackageManager
Extends thePackageManager
by JCR specific methods
-
-
Field Summary
Fields Modifier and Type Field Description static String
ARCHIVE_PACKAGE_ROOT_PATH
root path for packages
-
Constructor Summary
Constructors Modifier Constructor Description JcrPackageManagerImpl(@NotNull Session session, @Nullable String[] roots)
Deprecated.JcrPackageManagerImpl(@NotNull Session session, @Nullable String[] roots, @Nullable String[] authIdsForHookExecution, @Nullable String[] authIdsForRootInstallation, boolean isStrict, boolean overwritePrimaryTypesOfFoldersByDefault, IdConflictPolicy idConflictPolicy)
protected
JcrPackageManagerImpl(JcrPackageRegistry registry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assemble(Node packNode, JcrPackageDefinition definition, ProgressTrackerListener listener)
Assembles a package.void
assemble(JcrPackageDefinition definition, ProgressTrackerListener listener, OutputStream out)
Assembles a package directly to a output streamvoid
assemble(JcrPackage pack, ProgressTrackerListener listener)
Assembles a package.JcrPackage
create(String group, String name)
Creates a new package with the new group and name.JcrPackage
create(String group, String name, String version)
Creates a new package with the new group, name and version.JcrPackage
create(Node folder, String name)
Creates a new package below the given folder.@NotNull PackageId[]
extract(@NotNull Archive archive, @NotNull ImportOptions options, boolean replace)
Extracts a package directly from the given archive without uploading it to the repository first.JcrPackageRegistry
getInternalRegistry()
Node
getPackageRoot()
Returns the configured package root node.Node
getPackageRoot(boolean noCreate)
Returns the configured package root node.PackageRegistry
getRegistry()
List<JcrPackage>
listPackages()
Returns the list of all packages installed below the package root.List<JcrPackage>
listPackages(String group, boolean built)
Returns the list of all packages installed below the package root that match the given group.List<JcrPackage>
listPackages(WorkspaceFilter filter)
Returns the list of all packages installed below the package root that are included in the filter.protected Node
mkdir(String path, boolean autoSave)
yet another Convenience method to create intermediate nodes.JcrPackage
open(Node node)
Opens a package that is based on the given node.JcrPackage
open(Node node, boolean allowInvalid)
Opens a package that is based on the given node.JcrPackage
open(PackageId id)
Opens a package with the given package id.void
remove(JcrPackage pack)
Removes a package and its snapshots if present.JcrPackage
rename(JcrPackage pack, String group, String name)
Renames the given package with a new group id and name.JcrPackage
rename(JcrPackage pack, String group, String name, String version)
Renames the given package with a new group id, name and version.PackageId
resolve(Dependency dependency, boolean onlyInstalled)
Finds the id of the package that matches the given dependency best.void
rewrap(JcrPackage pack, ProgressTrackerListener listener)
Rewraps the package in respect to its underlying definition.void
setDispatcher(@Nullable PackageEventDispatcher dispatcher)
JcrPackage
upload(File file, boolean isTmpFile, boolean replace, String nameHint)
Uploads a package.JcrPackage
upload(File file, boolean isTmpFile, boolean replace, String nameHint, boolean strict)
Uploads a package.JcrPackage
upload(InputStream in, boolean replace)
Uploads a package.JcrPackage
upload(InputStream in, boolean replace, boolean strict)
Uploads a package.PackageId[]
usage(PackageId id)
Returns the package ids of installed packages that depend on the given package.-
Methods inherited from class org.apache.jackrabbit.vault.packaging.impl.PackageManagerImpl
assemble, assemble, open, open, open, open, rewrap, rewrap
-
-
-
-
Field Detail
-
ARCHIVE_PACKAGE_ROOT_PATH
public static final String ARCHIVE_PACKAGE_ROOT_PATH
root path for packages- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JcrPackageManagerImpl
@Deprecated public JcrPackageManagerImpl(@NotNull @NotNull Session session, @Nullable @Nullable String[] roots)
Deprecated.Creates a new package manager using the given session. This method allows to specify one more or package registry root paths, where the first will be the primary when installing new packages. The others serve as backward compatibility to read existing packages.- Parameters:
session
- repository sessionroots
- the root paths to store the packages.
-
JcrPackageManagerImpl
public JcrPackageManagerImpl(@NotNull @NotNull Session session, @Nullable @Nullable String[] roots, @Nullable @Nullable String[] authIdsForHookExecution, @Nullable @Nullable String[] authIdsForRootInstallation, boolean isStrict, boolean overwritePrimaryTypesOfFoldersByDefault, IdConflictPolicy idConflictPolicy)
-
JcrPackageManagerImpl
protected JcrPackageManagerImpl(JcrPackageRegistry registry)
-
-
Method Detail
-
getRegistry
public PackageRegistry getRegistry()
-
getInternalRegistry
public JcrPackageRegistry getInternalRegistry()
-
open
public JcrPackage open(PackageId id) throws RepositoryException
Opens a package with the given package id.- Specified by:
open
in interfaceJcrPackageManager
- Parameters:
id
- the package id.- Returns:
- the new package or
null
it the package does not exist or is not valid. - Throws:
RepositoryException
- if an error occurs
-
open
public JcrPackage open(Node node) throws RepositoryException
Opens a package that is based on the given node.- Specified by:
open
in interfaceJcrPackageManager
- Parameters:
node
- the underlying node- Returns:
- the new package or
null
it the package is not valid. - Throws:
RepositoryException
- if an error occurs
-
open
public JcrPackage open(Node node, boolean allowInvalid) throws RepositoryException
Opens a package that is based on the given node. IfallowInvalid
istrue
also invalid packages are returned, but only if the node is file like (i.e. is nt:hierarchyNode and has a jcr:content/jcr:data property).- Specified by:
open
in interfaceJcrPackageManager
- Parameters:
node
- the underlying nodeallowInvalid
- iftrue
invalid packages are openend, too.- Returns:
- the new package or
null
it the package is not valid unlessallowInvalid
istrue
. - Throws:
RepositoryException
- if an error occurs
-
resolve
public PackageId resolve(Dependency dependency, boolean onlyInstalled) throws RepositoryException
Finds the id of the package that matches the given dependency best. IfonlyInstalled
istrue
only installed packages are searched.- Specified by:
resolve
in interfaceJcrPackageManager
- Parameters:
dependency
- dependency informationonlyInstalled
- iftrue
only installed packages are searched.- Returns:
- the id of the matching package or
null
if not found. - Throws:
RepositoryException
- if an error occurs
-
usage
public PackageId[] usage(PackageId id) throws RepositoryException
Returns the package ids of installed packages that depend on the given package.- Specified by:
usage
in interfaceJcrPackageManager
- Parameters:
id
- the package id to search for- Returns:
- the array of package ids.
- Throws:
RepositoryException
- if an error occurs
-
upload
public JcrPackage upload(InputStream in, boolean replace) throws RepositoryException, IOException
Uploads a package. The location is chosen from the installation path of the package. if the package does not provide such a path an IOException is thrown. if the package already exists at that path it is not uploaded aItemExistsException
is thrown unlessreplace
istrue
.- Specified by:
upload
in interfaceJcrPackageManager
- Parameters:
in
- input stream that provides the content of the package. note that after this method returns, the input stream is closed in any case.replace
- iftrue
existing packages are replaced.- Returns:
- the new jcr package
- Throws:
RepositoryException
- if an error occurrsIOException
- if an I/O error occurrs
-
upload
public JcrPackage upload(InputStream in, boolean replace, boolean strict) throws RepositoryException, IOException
Uploads a package. The location is chosen from the installation path of the package. if the package does not provide such a path an IOException is thrown. if the package already exists at that path it is not uploaded aItemExistsException
is thrown unlessreplace
istrue
.- Specified by:
upload
in interfaceJcrPackageManager
- Parameters:
in
- input stream that provides the content of the package. note that after this method returns, the input stream is closed in any case.replace
- iftrue
existing packages are replaced.strict
- iftrue
import is more strict in regards to errors- Returns:
- the new jcr package
- Throws:
RepositoryException
- if an error occurrsIOException
- if an I/O error occurrs
-
extract
@NotNull public @NotNull PackageId[] extract(@NotNull @NotNull Archive archive, @NotNull @NotNull ImportOptions options, boolean replace) throws RepositoryException, PackageException, IOException
Extracts a package directly from the given archive without uploading it to the repository first. A package node is created but w/o any content. The resulting package cannot be downloaded, uninstalled or re-installed.If the package defines unsatisfied dependencies
DependencyHandling
might cause the extraction to fail.If the package contains sub-packages, they will follow the same behaviour, i.e. they will not be uploaded to the repository but directly installed unless
ImportOptions.setNonRecursive(boolean)
is set to true, in which case the sub packages will be uploaded.The method will throw an
ItemExistsException
if a package with the same id already exists, unlessreplace
is set totrue
.- Specified by:
extract
in interfaceJcrPackageManager
- Parameters:
archive
- the input archive that contains the package.options
- the import optionsreplace
- iftrue
existing packages are replaced.- Returns:
- an array of the package(s) that were extracted.
- Throws:
RepositoryException
- if an error occursPackageException
- if an internal error occurrsIOException
- if an I/O error occurrs
-
upload
public JcrPackage upload(File file, boolean isTmpFile, boolean replace, String nameHint) throws RepositoryException, IOException
Uploads a package. The location is chosen from the installation path of the package. if the package does not provide such a path, the nameHint is respected and the package is placed below the package root. if the package already exists at that path it is not installed andnull
is returned unlessreplace
istrue
.- Specified by:
upload
in interfaceJcrPackageManager
- Parameters:
file
- package file to uploadisTmpFile
- indicates if the given file is a temp file and can be deleted when the package is closedreplace
- iftrue
existing packages are replaced.nameHint
- hint for the name if package does not provide one- Returns:
- the new jcr package
- Throws:
RepositoryException
- if an error occurrsIOException
- if an I/O error occurrs
-
upload
public JcrPackage upload(File file, boolean isTmpFile, boolean replace, String nameHint, boolean strict) throws RepositoryException, IOException
Uploads a package. The location is chosen from the installation path of the package. if the package does not provide such a path, the nameHint is respected and the package is placed below the package root. if the package already exists at that path it is not uploaded aItemExistsException
is thrown unlessreplace
istrue
.- Specified by:
upload
in interfaceJcrPackageManager
- Parameters:
file
- package file to uploadisTmpFile
- indicates if the given file is a temp file and can be deleted when the package is closedreplace
- iftrue
existing packages are replaced.nameHint
- hint for the name if package does not provide onestrict
- iftrue
import is more strict in regards to errors- Returns:
- the new jcr package
- Throws:
RepositoryException
- if an error occurrsIOException
- if an I/O error occurrs
-
create
public JcrPackage create(Node folder, String name) throws RepositoryException, IOException
Creates a new package below the given folder.- Specified by:
create
in interfaceJcrPackageManager
- Parameters:
folder
- parent folder ornull
for the package rootname
- name of the new package- Returns:
- a new jcr package
- Throws:
RepositoryException
- if a repository error occurrsIOException
- if an I/O exception occurs
-
create
public JcrPackage create(String group, String name) throws RepositoryException, IOException
Creates a new package with the new group and name.- Specified by:
create
in interfaceJcrPackageManager
- Parameters:
group
- group of the new packagename
- name of the new package- Returns:
- a new jcr package
- Throws:
RepositoryException
- if a repository error occurrsIOException
- if an I/O exception occurs
-
create
public JcrPackage create(String group, String name, String version) throws RepositoryException, IOException
Creates a new package with the new group, name and version.- Specified by:
create
in interfaceJcrPackageManager
- Parameters:
group
- group of the new packagename
- name of the new packageversion
- version of the new package; can benull
- Returns:
- a new jcr package
- Throws:
RepositoryException
- if a repository error occurrsIOException
- if an I/O exception occurs
-
remove
public void remove(JcrPackage pack) throws RepositoryException
Removes a package and its snapshots if present.- Specified by:
remove
in interfaceJcrPackageManager
- Parameters:
pack
- the package to remove- Throws:
RepositoryException
- if a repository error occurrs
-
rename
public JcrPackage rename(JcrPackage pack, String group, String name) throws PackageException, RepositoryException
Renames the given package with a new group id and name. Please note that the package is moved and the internal 'path' is adjusted in the definition, but the package is not rewrapped.- Specified by:
rename
in interfaceJcrPackageManager
- Parameters:
pack
- the package to renamegroup
- the new group id ornull
name
- the new name ornull
- Returns:
- the renamed package
- Throws:
PackageException
- if the package is not unwrapped.RepositoryException
- if an error occurs
-
rename
public JcrPackage rename(JcrPackage pack, String group, String name, String version) throws PackageException, RepositoryException
Renames the given package with a new group id, name and version. Please note that the package is moved and the internal 'path' is adjusted in the definition, but the package is not rewrapped.- Specified by:
rename
in interfaceJcrPackageManager
- Parameters:
pack
- the package to renamegroup
- the new group id ornull
name
- the new name ornull
version
- the new version ornull
- Returns:
- the renamed package
- Throws:
PackageException
- if the package is not unwrapped.RepositoryException
- if an error occurs
-
assemble
public void assemble(JcrPackage pack, ProgressTrackerListener listener) throws PackageException, RepositoryException, IOException
Assembles a package.- Specified by:
assemble
in interfaceJcrPackageManager
- Parameters:
pack
- the package to assemblelistener
- a progress listener- Throws:
PackageException
- if a package error occursRepositoryException
- if a repository error occursIOException
- if an I/O error occurs
-
assemble
public void assemble(Node packNode, JcrPackageDefinition definition, ProgressTrackerListener listener) throws PackageException, RepositoryException, IOException
Assembles a package.- Specified by:
assemble
in interfaceJcrPackageManager
- Parameters:
packNode
- the node of the packagedefinition
- the definition of the packagelistener
- a progress listener- Throws:
PackageException
- if a package error occursRepositoryException
- if a repository error occursIOException
- if an I/O error occurs
-
assemble
public void assemble(JcrPackageDefinition definition, ProgressTrackerListener listener, OutputStream out) throws IOException, RepositoryException, PackageException
Assembles a package directly to a output stream- Specified by:
assemble
in interfaceJcrPackageManager
- Parameters:
definition
- the definition of the packagelistener
- a progress listenerout
- the output stream to write to- Throws:
IOException
- if an I/O error occursRepositoryException
- if a repository error occursPackageException
- if a package error occurs
-
rewrap
public void rewrap(JcrPackage pack, ProgressTrackerListener listener) throws PackageException, RepositoryException, IOException
Rewraps the package in respect to its underlying definition.- Specified by:
rewrap
in interfaceJcrPackageManager
- Parameters:
pack
- the package to rewraplistener
- the progress listener- Throws:
PackageException
- if a package error occursRepositoryException
- if a repository error occursIOException
- if an I/O error occurs
-
mkdir
protected 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
-
getPackageRoot
public Node getPackageRoot() throws RepositoryException
Returns the configured package root node.- Specified by:
getPackageRoot
in interfaceJcrPackageManager
- Returns:
- the package root node
- Throws:
RepositoryException
- if an error occurs
-
getPackageRoot
public Node getPackageRoot(boolean noCreate) throws RepositoryException
Returns the configured package root node.- Specified by:
getPackageRoot
in interfaceJcrPackageManager
- Parameters:
noCreate
- do not create missing root iftrue
- Returns:
- the package root node or
null
if not present and noCreate istrue
. - Throws:
RepositoryException
- if an error occurs
-
listPackages
public List<JcrPackage> listPackages() throws RepositoryException
Returns the list of all packages installed below the package root.- Specified by:
listPackages
in interfaceJcrPackageManager
- Returns:
- a list of packages
- Throws:
RepositoryException
- if an error occurs
-
listPackages
public List<JcrPackage> listPackages(WorkspaceFilter filter) throws RepositoryException
Returns the list of all packages installed below the package root that are included in the filter.- Specified by:
listPackages
in interfaceJcrPackageManager
- Parameters:
filter
- filter for packages- Returns:
- a list of packages
- Throws:
RepositoryException
- if an error occurs
-
listPackages
public List<JcrPackage> listPackages(String group, boolean built) throws RepositoryException
Returns the list of all packages installed below the package root that match the given group. ifgroup
isnull
all packages are returned.- Specified by:
listPackages
in interfaceJcrPackageManager
- Parameters:
group
- the group filterbuilt
- iftrue
only packages with size > 0 are listed- Returns:
- the list of packages
- Throws:
RepositoryException
- if an error occurs
-
setDispatcher
public void setDispatcher(@Nullable @Nullable PackageEventDispatcher dispatcher)
- Overrides:
setDispatcher
in classPackageManagerImpl
-
-