Package com.composum.nodes.setup.impl
Class NodesSetupService
- java.lang.Object
-
- com.composum.nodes.setup.impl.NodesSetupService
-
- All Implemented Interfaces:
org.apache.sling.event.jobs.consumer.JobConsumer
public class NodesSetupService extends Object implements org.apache.sling.event.jobs.consumer.JobConsumer
Ensures orderly removal of obsolete (e.g. Composum Core V1) bundles / configurations and replacing / updating new Composum Nore bundles and replacing the content in "/libs/composum/nodes". The service registers itself as a job (to be executed after the bundle is active) for this. The process is as follows:- Remove all obsolete and to be replaced bundles / configurations from "/libs/composum/nodes/install"
- Moves all bundles in "/libs/composum/nodes.setup/upload" to "/libs/composum/nodes/install" to be picked up by the OSGI installer and then removes "/libs/composum/nodes.setup/upload"
- Replaces the content of "/libs/composum/nodes" with the content of "/libs/composum/nodes.setup"
- Installs the composum-nodes-jslibs-package again to make sure it wasn't trashed by a bundle removal
- Removes the bundle containing this and it's LoginAdminWhitelist configuration (even if something previous failed).
-
-
Field Summary
Fields Modifier and Type Field Description static Pattern[]
BUNDLES_TO_UNINSTALL
Matches the old (Composum Core) bundles to be removed and the new (Composum Nodes) bundles to be replaced.static Pattern[]
INSTALL_ARTIFACTS
Matches the artifacts belonging to this setup bundle, which have to be removed later (used only for installation).static String
INSTALL_FOLDER
static String
JOB_TOPIC
protected org.apache.sling.event.jobs.JobManager
jobManager
static String
NODES_BUNDLES_PATH
"/libs/composum/nodes/install" - the path where artefacts to install are put for automatical installation and from where obsolete / replaced bundles are deleted.static String
NODES_CONTENT_PATH
static String
NODES_PACKAGES_PATH
protected static String
REP_ACCESS_CONTROLLABLE
protected static String
REP_POLICY
static String
SETUP_BUNDLES_PATH
"/libs/composum/nodes.setup/upload" a place the sling package puts the new bundles temporarily, to be moved by this service.static String
SETUP_EXT
static String
SETUP_NODES_FOLDER
"/libs/composum/nodes.setup" - temporary place for new content to replace the stuff in "/libs/composum/nodes" .static String
UPLOAD_FOLDER
static Pattern
VERSION_PATTERN
-
Constructor Summary
Constructors Constructor Description NodesSetupService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
activate(org.osgi.framework.BundleContext bundleContext)
protected org.apache.jackrabbit.vault.fs.io.ImportOptions
createPackageImportOptions()
protected void
deactivate()
protected void
installPackage(@NotNull javax.jcr.Session session, @NotNull String packagePath, @NotNull Pattern... subpckgPatterns)
(re-)install a package or subpackage if subpackages are specifiedprotected boolean
isInstallArtifact(@NotNull String name)
protected void
moveAcl(javax.jcr.Node src, javax.jcr.Node target, boolean isSubnode)
This moves any ACL restrictions from the subnodes of src to the nodes of target.org.apache.sling.event.jobs.consumer.JobConsumer.JobResult
process(org.apache.sling.event.jobs.Job job)
protected void
removeInstallArtifacts(@NotNull javax.jcr.Session session)
the final removal of the install artifacts (setup-bundle and the related configuration)protected boolean
removeNodesBundles(@NotNull javax.jcr.Session session)
protected void
removeNodesContent(@NotNull javax.jcr.Session session)
remove the Nodes modules content resources to prepare a clean installprotected boolean
removeUploadedBundles(@NotNull javax.jcr.Session session)
removes all matching artifacts in the bundle install repository folder (removes bundle files uploaded before)protected void
setupNodesBundlesAndContent(@NotNull javax.jcr.Session session)
setup new Nodes bundles and content installed in the setup folder during package installprotected boolean
uninstallBundles()
uninstalls all bundles matching to the unistall pattern list (removes bundles installed before)protected void
wait(int seconds)
-
-
-
Field Detail
-
JOB_TOPIC
public static final String JOB_TOPIC
- See Also:
- Constant Field Values
-
SETUP_EXT
public static final String SETUP_EXT
- See Also:
- Constant Field Values
-
INSTALL_FOLDER
public static final String INSTALL_FOLDER
- See Also:
- Constant Field Values
-
UPLOAD_FOLDER
public static final String UPLOAD_FOLDER
- See Also:
- Constant Field Values
-
NODES_CONTENT_PATH
public static final String NODES_CONTENT_PATH
- See Also:
- Constant Field Values
-
NODES_BUNDLES_PATH
public static final String NODES_BUNDLES_PATH
"/libs/composum/nodes/install" - the path where artefacts to install are put for automatical installation and from where obsolete / replaced bundles are deleted.- See Also:
- Constant Field Values
-
SETUP_NODES_FOLDER
public static final String SETUP_NODES_FOLDER
"/libs/composum/nodes.setup" - temporary place for new content to replace the stuff in "/libs/composum/nodes" .- See Also:
- Constant Field Values
-
SETUP_BUNDLES_PATH
public static final String SETUP_BUNDLES_PATH
"/libs/composum/nodes.setup/upload" a place the sling package puts the new bundles temporarily, to be moved by this service.- See Also:
- Constant Field Values
-
NODES_PACKAGES_PATH
public static final String NODES_PACKAGES_PATH
- See Also:
- Constant Field Values
-
VERSION_PATTERN
public static final Pattern VERSION_PATTERN
-
INSTALL_ARTIFACTS
public static final Pattern[] INSTALL_ARTIFACTS
Matches the artifacts belonging to this setup bundle, which have to be removed later (used only for installation).
-
BUNDLES_TO_UNINSTALL
public static final Pattern[] BUNDLES_TO_UNINSTALL
Matches the old (Composum Core) bundles to be removed and the new (Composum Nodes) bundles to be replaced.
-
REP_POLICY
protected static final String REP_POLICY
- See Also:
- Constant Field Values
-
REP_ACCESS_CONTROLLABLE
protected static final String REP_ACCESS_CONTROLLABLE
- See Also:
- Constant Field Values
-
jobManager
protected org.apache.sling.event.jobs.JobManager jobManager
-
-
Method Detail
-
activate
protected void activate(org.osgi.framework.BundleContext bundleContext)
-
deactivate
protected void deactivate()
-
process
public org.apache.sling.event.jobs.consumer.JobConsumer.JobResult process(org.apache.sling.event.jobs.Job job)
- Specified by:
process
in interfaceorg.apache.sling.event.jobs.consumer.JobConsumer
-
removeNodesBundles
protected boolean removeNodesBundles(@NotNull @NotNull javax.jcr.Session session) throws javax.jcr.RepositoryException
- Throws:
javax.jcr.RepositoryException
-
setupNodesBundlesAndContent
protected void setupNodesBundlesAndContent(@NotNull @NotNull javax.jcr.Session session) throws javax.jcr.RepositoryException, org.apache.jackrabbit.vault.packaging.PackageException, IOException
setup new Nodes bundles and content installed in the setup folder during package install- Parameters:
session
- the JCR session of the executed setup job- Throws:
javax.jcr.RepositoryException
- ...org.apache.jackrabbit.vault.packaging.PackageException
IOException
-
moveAcl
protected void moveAcl(javax.jcr.Node src, javax.jcr.Node target, boolean isSubnode) throws javax.jcr.RepositoryException
This moves any ACL restrictions from the subnodes of src to the nodes of target. This violates the constraints for the src since the rep:policy nodes are removed, but src will be deleted, anyway.- Throws:
javax.jcr.RepositoryException
-
installPackage
protected void installPackage(@NotNull @NotNull javax.jcr.Session session, @NotNull @NotNull String packagePath, @NotNull @NotNull Pattern... subpckgPatterns) throws javax.jcr.RepositoryException, org.apache.jackrabbit.vault.packaging.PackageException, IOException
(re-)install a package or subpackage if subpackages are specified- Parameters:
session
- the current sessionpackagePath
- the relative path of the package to installsubpckgPatterns
- a set of subpackage name patterns, each matching subpackage will be installed- Throws:
javax.jcr.RepositoryException
org.apache.jackrabbit.vault.packaging.PackageException
IOException
-
createPackageImportOptions
protected org.apache.jackrabbit.vault.fs.io.ImportOptions createPackageImportOptions()
-
removeNodesContent
protected void removeNodesContent(@NotNull @NotNull javax.jcr.Session session) throws javax.jcr.RepositoryException
remove the Nodes modules content resources to prepare a clean install- Throws:
javax.jcr.RepositoryException
-
removeUploadedBundles
protected boolean removeUploadedBundles(@NotNull @NotNull javax.jcr.Session session)
removes all matching artifacts in the bundle install repository folder (removes bundle files uploaded before)- Returns:
- true if at least one artifact has been removed
-
uninstallBundles
protected boolean uninstallBundles()
uninstalls all bundles matching to the unistall pattern list (removes bundles installed before)- Returns:
- true if at least one bundle has been uninstalled
-
isInstallArtifact
protected boolean isInstallArtifact(@NotNull @NotNull String name)
- Returns:
- 'true' if the name references an artifact od the setup itself
-
removeInstallArtifacts
protected void removeInstallArtifacts(@NotNull @NotNull javax.jcr.Session session) throws javax.jcr.RepositoryException
the final removal of the install artifacts (setup-bundle and the related configuration)- Throws:
javax.jcr.RepositoryException
-
wait
protected void wait(int seconds)
-
-