Package com.day.jcr.vault.packaging

Examples of com.day.jcr.vault.packaging.JcrPackage


        contentPaths.add("/content/bar");

        final String packagePath = "/etc/packages/acs-commons/test.zip";
        final Resource packageResource = mock(Resource.class);
        final Node packageNode = mock(Node.class);
        final JcrPackage jcrPackage = mock(JcrPackage.class);
        final Node jcrPackageNode = mock(Node.class);
        final JcrPackageDefinition jcrPackageDefinition = mock(JcrPackageDefinition.class);
        final Resource jcrPackageJcrContent = mock(Resource.class);

        final Resource contentResource1 = mock(Resource.class);
        final Resource contentResource2 = mock(Resource.class);
        final Node contentNode1 = mock(Node.class);
        final Node contentNode2 = mock(Node.class);

        final String[] paths = new String[] { packagePath };

        final Map<String, Object> map = new HashMap<String, Object>();
        map.put("paths", paths);

        final Event event = new Event("MOCK", map);

        when(adminResourceResolver.getResource(packagePath)).thenReturn(packageResource);
        when(packageResource.adaptTo(Node.class)).thenReturn(packageNode);
        when(packaging.open(packageNode, false)).thenReturn(jcrPackage);
        when(packageHelper.getContents(jcrPackage)).thenReturn(contentPaths);
        when(jcrPackage.getDefinition()).thenReturn(jcrPackageDefinition);
        when(jcrPackageDefinition.getId()).thenReturn(mock(PackageId.class));
        when(jcrPackage.getNode()).thenReturn(jcrPackageNode);
        when(jcrPackageNode.getPath()).thenReturn(packagePath);
        when(packageResource.getChild("jcr:content")).thenReturn(jcrPackageJcrContent);

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(JcrConstants.JCR_LASTMODIFIED, calendar);
View Full Code Here


        final List<JcrPackage> packages = new ArrayList<JcrPackage>();

        for (final String path : paths) {
            final Resource eventResource = this.adminResourceResolver.getResource(path);

            JcrPackage jcrPackage;

            try {
                jcrPackage = packaging.open(eventResource.adaptTo(Node.class), false);
                if (jcrPackage != null) {
                    packages.add(jcrPackage);
View Full Code Here

            boolean configVersionEligible = true;

            while (children.hasNext()) {
                final Node child = children.nextNode();

                final JcrPackage jcrPackage = jcrPackageManager.open(child, true);
                if (jcrPackage == null
                        || jcrPackage.getDefinition() == null
                        || jcrPackage.getDefinition().getId() == null) {

                    log.warn("Could not covert node [ {} ] into a proper JCR Package, moving to next node",
                            child.getPath());
                    continue;

                } else if (!StringUtils.equals(name, jcrPackage.getDefinition().getId().getName())) {
                    // Name mismatch - so just skip
                    continue;
                }

                final Version packageVersion = jcrPackage.getDefinition().getId().getVersion();

                log.debug(packageVersion.toString() + " compareTo " + latestVersion.toString()
                        + " = " + packageVersion.compareTo(latestVersion));

                if (packageVersion.compareTo(latestVersion) >= 1) {
View Full Code Here

     */
    public void removePackage(final JcrPackageManager jcrPackageManager,
                              final String groupName, final String name,
                              final String version) throws RepositoryException {
        final PackageId packageId = new PackageId(groupName, name, version);
        final JcrPackage jcrPackage = jcrPackageManager.open(packageId);

        if (jcrPackage != null && jcrPackage.getNode() != null) {
            jcrPackage.getNode().remove();
            jcrPackage.getNode().getSession().save();
        } else {
            log.debug("Nothing to remove at: ", packageId.getInstallationPath());
        }
    }
View Full Code Here

            this.removePackage(jcrPackageManager, groupName, name, version);
        } else if (ConflictResolution.IncrementVersion.equals(conflictResolution)) {
            version = this.getNextVersion(jcrPackageManager, groupName, name, version).toString();
        }

        final JcrPackage jcrPackage = jcrPackageManager.create(groupName, name, version);
        final JcrPackageDefinition jcrPackageDefinition = jcrPackage.getDefinition();
        final DefaultWorkspaceFilter workspaceFilter = new DefaultWorkspaceFilter();

        for (final PathFilterSet pathFilterSet : pathFilterSets) {
            workspaceFilter.add(pathFilterSet);
        }
View Full Code Here

                // Do not create empty packages; This will only clutter up CRX Package Manager
                response.getWriter().print(packageHelper.getErrorJSON("Refusing to create a package with no filter "
                        + "set rules."));
            } else {
                // Create JCR Package; Defaults should always be passed in via Request Parameters, but just in case
                final JcrPackage jcrPackage = packageHelper.createPackageFromPathFilterSets(packageResources,
                        request.getResourceResolver().adaptTo(Session.class),
                        properties.get(PACKAGE_GROUP_NAME, DEFAULT_PACKAGE_GROUP_NAME),
                        properties.get(PACKAGE_NAME, DEFAULT_PACKAGE_NAME),
                        properties.get(PACKAGE_VERSION, DEFAULT_PACKAGE_VERSION),
                        PackageHelper.ConflictResolution.valueOf(properties.get(CONFLICT_RESOLUTION,
View Full Code Here

                // Do not create empty packages; This will only clutter up CRX Package Manager
                response.getWriter().print(packageHelper.getErrorJSON("Refusing to create a package with no filter "
                        + "set rules."));
            } else {
                // Create JCR Package; Defaults should always be passed in via Request Parameters, but just in case
                final JcrPackage jcrPackage = packageHelper.createPackage(packageResources,
                        request.getResourceResolver().adaptTo(Session.class),
                        properties.get(PACKAGE_GROUP_NAME, DEFAULT_PACKAGE_GROUP_NAME),
                        properties.get(PACKAGE_NAME, DEFAULT_PACKAGE_NAME),
                        properties.get(PACKAGE_VERSION, DEFAULT_PACKAGE_VERSION),
                        PackageHelper.ConflictResolution.valueOf(properties.get(CONFLICT_RESOLUTION,
View Full Code Here

TOP

Related Classes of com.day.jcr.vault.packaging.JcrPackage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.