@Override public PackageManager getPackageManager() { return PackagingService.getPackageManager(); }
@Override public JcrPackageDefinition createPackageDefinition(final Node defNode) { return PackagingService.createPackageDefinition(defNode); }
@Override public JcrPackage open(final Node node, final boolean allowInvalid) throws RepositoryException { return PackagingService.open(node, allowInvalid); } }
@Override public JcrPackageManager getPackageManager(final Session session) { if (jcrPackageManagerClazz != null) { try { return jcrPackageManagerClazz.getConstructor(Session.class, String[].class) .newInstance(session, new String[0]); } catch (Exception e) { LOGGER.warn("failed to construct instance of " + JCR_PACK_MAN_IMPL_CLASS, e); } } return PackagingService.getPackageManager(session); }
/** * Opens a package that is based on the given node. If {@code allowInvalid} * is {@code true} 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). * * This is a shortcut version of {@link JcrPackageManager#open(Node, boolean)} * which does not create a package manager instance. * * @param node the underlying node * @param allowInvalid if {@code true} invalid packages are openend, too. * @return the new package or {@code null} it the package is not * valid unless {@code allowInvalid} is {@code true}. * @throws RepositoryException if an error occurs * * @since 2.3.0 */ public static JcrPackage open(Node node, boolean allowInvalid) throws RepositoryException { JcrPackageManager pMgr = getPackageManager(node.getSession()); return pMgr.open(node, allowInvalid); } }
@Override public void after() throws Exception { super.after(); if (assemble) { JcrPackageManager mgr = PackagingService.getPackageManager(resolver.adaptTo(Session.class)); mgr.assemble(jcrPackage, null); } } }
public void excute() throws RepositoryException, PackageException, IOException, ReplicationException { boolean succeeded = false; try (ResourceResolver resolver = ConfigurationUpdateListener.getResourceResolver(resolverFactory)){ Session session = resolver.adaptTo(Session.class); JcrPackageManager pkgMgr = PackagingService.getPackageManager(session); PackageId packageId = new PackageId(packagePath); // check if the package exists JcrPackage jcrPackage = pkgMgr.open(packageId); if (jcrPackage == null || jcrPackage.getNode() == null) { log.warn("Package at path " + packagePath + " does not exist"); throw new IllegalArgumentException("Package at path " + packagePath + " does not exist"); } log.debug("Assembling package {}", packagePath); pkgMgr.assemble(jcrPackage, null); log.debug("Replicating package {}", packagePath); replicator.replicate(session, ReplicationActionType.ACTIVATE, jcrPackage.getNode().getPath()); log.debug("Package {} replicated successfully!", packagePath); fireEvent(OSGI_EVENT_REPLICATED_TOPIC); succeeded = true; } finally { if(!succeeded){ fireEvent(OSGI_EVENT_FAILED_TOPIC); } } }
/** * computes configured package based on expression configuration (either existing or creating it) * @throws IOException problem with binary * @throws RepositoryException problem with package persistence * @throws IOException problem with package build * @throws ScriptException problem with some expression/path compute */ protected void init() throws IOException, RepositoryException, ScriptException { if (jcrPackage == null){ String packagePath = getExpr(); if (StringUtils.isNotBlank(packagePath)) { JcrPackageManager mgr = PackagingService.getPackageManager(resolver.adaptTo(Session.class)); Resource packageResource = resolver.getResource(packagePath); if (packageResource != null) { jcrPackage = mgr.open(packageResource.adaptTo(Node.class)); } else { String parent = Text.getRelativeParent(packagePath, 1); Resource folderResource = resolver.getResource(parent); if (folderResource == null) { LOGGER.error("folder of configured path should exists"); } else { String name = Text.getName(packagePath); jcrPackage = mgr.create(folderResource.adaptTo(Node.class), name); } } } else { LOGGER.error("expression should not be blank as it's supposed to hold package path"); } } }
protected static ValidationResult validatePackage(File file, ValidationOptions options) { PackageManager manager = PackagingService.getPackageManager(); VaultPackage pack = null; try {