当前位置: 首页>>代码示例>>Java>>正文


Java VaultPackage类代码示例

本文整理汇总了Java中org.apache.jackrabbit.vault.packaging.VaultPackage的典型用法代码示例。如果您正苦于以下问题:Java VaultPackage类的具体用法?Java VaultPackage怎么用?Java VaultPackage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VaultPackage类属于org.apache.jackrabbit.vault.packaging包,在下文中一共展示了VaultPackage类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getExportOptions

import org.apache.jackrabbit.vault.packaging.VaultPackage; //导入依赖的package包/类
public static ExportOptions getExportOptions(WorkspaceFilter filter, String[] packageRoots,
                                             String packageGroup,
                                             String packageName,
                                             String packageVersion) {
    DefaultMetaInf inf = new DefaultMetaInf();
    ExportOptions opts = new ExportOptions();
    inf.setFilter(filter);

    Properties props = new Properties();
    props.setProperty(VaultPackage.NAME_GROUP, packageGroup);
    props.setProperty(VaultPackage.NAME_NAME, packageName);
    props.setProperty(VaultPackage.NAME_VERSION, packageVersion);
    inf.setProperties(props);

    opts.setMetaInf(inf);

    String root = getPackageRoot(filter.getFilterSets(), packageRoots);
    opts.setRootPath(root);
    opts.setMountPath(root);

    return opts;
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:23,代码来源:VltUtils.java

示例2: createPackage

import org.apache.jackrabbit.vault.packaging.VaultPackage; //导入依赖的package包/类
public static VaultPackage createPackage(PackageManager packageManager, Session session, ExportOptions options, File tempFolder) throws IOException, RepositoryException {
    File file = File.createTempFile("distr-vault-create-" + System.nanoTime(), ".zip", tempFolder);

    try {
        VaultPackage vaultPackage = packageManager.assemble(session, options, file);
        return vaultPackage;
    } catch (RepositoryException e) {
        FileUtils.deleteQuietly(file);
        throw e;
    }
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:12,代码来源:VltUtils.java

示例3: readPackage

import org.apache.jackrabbit.vault.packaging.VaultPackage; //导入依赖的package包/类
public static VaultPackage readPackage(PackageManager packageManager, InputStream stream, File tempFolder) throws IOException {
    File file = File.createTempFile("distr-vault-read-" + System.nanoTime(), ".zip", tempFolder);
    OutputStream out = FileUtils.openOutputStream(file);
    try {
        IOUtils.copy(stream, out);
        return packageManager.open(file);
    } catch (IOException e) {
        FileUtils.deleteQuietly(file);
        throw e;
    } finally {
        IOUtils.closeQuietly(stream);
        IOUtils.closeQuietly(out);
    }
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:15,代码来源:VltUtils.java

示例4: deletePackage

import org.apache.jackrabbit.vault.packaging.VaultPackage; //导入依赖的package包/类
public static void deletePackage(VaultPackage vaultPackage) {
    if (vaultPackage == null) {
        return;
    }

    File file = vaultPackage.getFile();
    vaultPackage.close();

    FileUtils.deleteQuietly(file);
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:11,代码来源:VltUtils.java

示例5: checkForbiddenFilterRootPrefix

import org.apache.jackrabbit.vault.packaging.VaultPackage; //导入依赖的package包/类
protected static ValidationResult checkForbiddenFilterRootPrefix(ValidationOptions options, VaultPackage pack) {
    List<String> forbiddenFilterRootPrefixes = options.getForbiddenFilterRootPrefixes();
    if (forbiddenFilterRootPrefixes != null) {
        for (String rootPrefix : forbiddenFilterRootPrefixes) {
            String trimmed = rootPrefix.trim();
            if (trimmed.isEmpty()) {
                continue;
            }
            final String noTrailingSlash = trimmed.replaceAll("/*$", "").replaceAll("^/*", "/");
            final String withTrailingSlash = noTrailingSlash.replaceAll("/*$", "/");
            for (PathFilterSet filterSet : pack.getMetaInf().getFilter().getFilterSets()) {
                if (filterSet.getRoot().equals(noTrailingSlash)
                        || filterSet.getRoot().startsWith(withTrailingSlash)) {
                    WspFilter.Root invalidRoot = WspFilter.adaptFilterSet(filterSet);
                    return ValidationResult.forbiddenRootPrefix(rootPrefix, invalidRoot);
                }
            }
        }
    }

    return ValidationResult.success();
}
 
开发者ID:adamcin,项目名称:granite-client-packman,代码行数:23,代码来源:PackageValidator.java

示例6: checkDeniedPathInclusion

import org.apache.jackrabbit.vault.packaging.VaultPackage; //导入依赖的package包/类
protected static ValidationResult checkDeniedPathInclusion(ValidationOptions options, VaultPackage pack) {
    List<String> pathsDeniedForInclusion = options.getPathsDeniedForInclusion();
    if (pathsDeniedForInclusion != null) {
        for (String path : pathsDeniedForInclusion) {
            if (pack.getMetaInf().getFilter().contains(path)) {
                WspFilter.Root invalidRoot = null;
                PathFilterSet filter = pack.getMetaInf().getFilter().getCoveringFilterSet(path);
                if (filter != null) {
                    invalidRoot = WspFilter.adaptFilterSet(filter);
                }
                return ValidationResult.deniedPathInclusion(path, invalidRoot);
            }
        }
    }
    return ValidationResult.success();
}
 
开发者ID:adamcin,项目名称:granite-client-packman,代码行数:17,代码来源:PackageValidator.java

示例7: createPackage

import org.apache.jackrabbit.vault.packaging.VaultPackage; //导入依赖的package包/类
/**
 * Create a JCR package and store it under /etc/packages/group_name/package_name-version.zip.
 * {@link org.apache.sling.distribution.serialization.impl.vlt.JcrVaultDistributionPackageBuilder#createPackageForAdd}
 *
 * @param request The Sling HTTP servlet request
 * @param groupName The name of the package group
 * @param packageName The name of the package
 * @param version The version of the package
 * @param paths The JCR paths to include in the package
 * @return true  the saved JCR Package
 */
public JcrPackage createPackage(final SlingHttpServletRequest request, final String groupName,
        final String packageName, final String version, final String[] paths) {

    Session session = null;
    VaultPackage vaultPackage = null;
    JcrPackage savedPackage = null;

    File tempDirectory = VltUtils.getTempFolder(settingsService.getTemporaryDirectory());

    try {
        session = request.getResourceResolver().adaptTo(Session.class);

        WorkspaceFilter filter = VltUtils.createFilter(paths, true);
        ExportOptions opts = VltUtils.getExportOptions(filter, paths, groupName, packageName, version);

        vaultPackage = VltUtils.createPackage(packaging.getPackageManager(), session, opts, tempDirectory);

        savedPackage = uploadPackage(session, vaultPackage);

        session.save();
    } catch (Exception e) {
        VltUtils.deletePackage(vaultPackage);
    }

    return savedPackage;
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:38,代码来源:PackageServiceImpl.java

示例8: uploadPackage

import org.apache.jackrabbit.vault.packaging.VaultPackage; //导入依赖的package包/类
/**
 * Create package in the JCR under /etc/packages/group_name.
 * {@link org.apache.sling.distribution.serialization.impl.vlt.JcrVaultDistributionPackageBuilder#uploadPackage}
 *
 * @param session The current session
 * @param pack the Vault Package to upload
 * @return the JCR Package from the uploaded file
 * @throws IOException
 * @throws RepositoryException
 */
private JcrPackage uploadPackage(Session session, VaultPackage pack) throws IOException, RepositoryException {
    JcrPackageManager packageManager = packaging.getPackageManager(session);

    InputStream in = FileUtils.openInputStream(pack.getFile());

    try {
        JcrPackage jcrPackage = packageManager.upload(in, true);
        return jcrPackage;
    } finally {
        IOUtils.closeQuietly(in);
    }
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:23,代码来源:PackageServiceImpl.java

示例9: validatePackage

import org.apache.jackrabbit.vault.packaging.VaultPackage; //导入依赖的package包/类
protected static ValidationResult validatePackage(File file, ValidationOptions options) {
    PackageManager manager = PackagingService.getPackageManager();
    VaultPackage pack = null;
    try {
        pack = manager.open(file, true);

        if (!pack.isValid()) {
            return new ValidationResult(Reason.INVALID_META_INF);
        }

        ValidationResult acHandlingResult = checkACHandling(options, pack);
        if (acHandlingResult.getReason() != Reason.SUCCESS) {
            return acHandlingResult;
        }

        ValidationResult forbiddenFilterRootPrefixResult = checkForbiddenFilterRootPrefix(options, pack);
        if (forbiddenFilterRootPrefixResult.getReason() != Reason.SUCCESS) {
            return forbiddenFilterRootPrefixResult;
        }

        ValidationResult deniedPathInclusionResult = checkDeniedPathInclusion(options, pack);
        if (deniedPathInclusionResult.getReason() != Reason.SUCCESS) {
            return deniedPathInclusionResult;
        }

        WspFilter archiveFilter =
                WspFilter.adaptWorkspaceFilter(
                        pack.getMetaInf().getFilter());

        return checkFilter(options, archiveFilter);
    } catch (IOException e) {
        return new ValidationResult(Reason.FAILED_TO_OPEN, e);
    } finally {
        if (pack != null) {
            pack.close();
        }
    }
}
 
开发者ID:adamcin,项目名称:granite-client-packman,代码行数:39,代码来源:PackageValidator.java

示例10: checkACHandling

import org.apache.jackrabbit.vault.packaging.VaultPackage; //导入依赖的package包/类
protected static ValidationResult checkACHandling(ValidationOptions options, VaultPackage pack) {
    List<ACHandling> forbidden = options.getForbiddenACHandlingModes();
    ACHandling jkMode = modeForJKMode(pack.getACHandling());
    if (forbidden != null && jkMode != null) {
        if (forbidden.contains(jkMode)) {
            return ValidationResult.forbiddenACHandlingMode(jkMode);
        }
    }
    return ValidationResult.success();
}
 
开发者ID:adamcin,项目名称:granite-client-packman,代码行数:11,代码来源:PackageValidator.java

示例11: testUpdateFilter

import org.apache.jackrabbit.vault.packaging.VaultPackage; //导入依赖的package包/类
@Test
public void testUpdateFilter() {
    TestBody.test(new PackmgrClientTestBody() {
        @Override protected void execute() throws Exception {
            client.login(USER, PASS);

            PackId id = PackId.createPackId("test-packmgr", "test-update-filter", "1.0");
            if (client.existsOnServer(id)) {
                LOGGER.info("deleting: {}", client.delete(id));
            }

            assertFalse("package should not exist on server", client.existsOnServer(id));

            LOGGER.info("creating: {}", client.create(id));

            assertTrue("package should exist on server", client.existsOnServer(id));

            String theOneRoot = "/tmp/test-update-filter";
            String theOnePattern = theOneRoot + "(/.*)?";

            WspFilter.Root origRoot =new WspFilter.Root(theOneRoot,
                    new WspFilter.Rule(true, theOnePattern));
            WspFilter origWSPFilter = new WspFilter(origRoot);

            LOGGER.info("updating filter: {}", client.updateFilter(id, origWSPFilter));

            LOGGER.info("building: {}", client.build(id, LISTENER));

            File downloaded = new File("target/test-update-filter-1.0.zip");

            LOGGER.info("downloading: {}", client.download(id, downloaded));

            VaultPackage pack = null;
            try {
                PackageManager manager = PackagingService.getPackageManager();
                pack = manager.open(downloaded, true);

                assertTrue("package should be valid after download", pack.isValid());

                WorkspaceFilter wspFilter = pack.getMetaInf().getFilter();

                List<PathFilterSet> filterSets = wspFilter.getFilterSets();

                assertFalse("package filter sets should not be empty", filterSets.isEmpty());

                PathFilterSet filterSet = filterSets.get(0);
                WspFilter.Root archiveFilterRoot = WspFilter.adaptFilterSet(filterSet);

                assertEquals("filterSet root should be the same as before.", theOneRoot, archiveFilterRoot.getPath());

                assertFalse("package filter set rules should not be empty", archiveFilterRoot.getRules().isEmpty());

                assertTrue("package filter rule should be an include",
                        archiveFilterRoot.getRules().get(0).isInclude());

                WspFilter.Rule archiveRule = archiveFilterRoot.getRules().get(0);

                assertEquals("filter pattern should be the same as before.",
                        theOnePattern, archiveRule.getPattern());

            } catch (IOException e) {
                FailUtil.sprintFail(e);
            } finally {
                if (pack != null) {
                    pack.close();
                }
            }

            LOGGER.info("deleting: {}", client.delete(id));

            assertFalse("package should not exist on server", client.existsOnServer(id));
        }
    });
}
 
开发者ID:adamcin,项目名称:granite-client-packman,代码行数:75,代码来源:AbstractPackageManagerClientITBase.java

示例12: setUp

import org.apache.jackrabbit.vault.packaging.VaultPackage; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
   calendar = Calendar.getInstance();

    final List<String> contentPaths = new ArrayList<String>();
    contentPaths.add("/content/foo/jcr:content");
    contentPaths.add("/content/bar");
    contentPaths.add("/content/dam/folder/jcr:content");

    final Resource packageResource = mock(Resource.class);
    final Node packageNode = mock(Node.class);
    final JcrPackage jcrPackage = mock(JcrPackage.class);
    final VaultPackage vaultPackage = mock(VaultPackage.class);
    final Node jcrPackageNode = mock(Node.class);
    final JcrPackageDefinition jcrPackageDefinition = mock(JcrPackageDefinition.class);
    final Resource jcrPackageJcrContent = mock(Resource.class);

    final Resource contentResource1parent = mock(Resource.class);
    final Resource contentResource3parent = mock(Resource.class);

    final Node contentNode1 = mock(Node.class);
    final Node contentNode1parent = mock(Node.class);
    final Node contentNode2 = mock(Node.class);
    final Node contentNode3 = mock(Node.class);
    final Node contentNode3parent = mock(Node.class);

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

    when(job.getProperty("paths")).thenReturn(paths);

    when(resourceResolverFactory.getServiceResourceResolver(anyMap())).thenReturn(resourceResolver);
    when(resourceResolver.getResource(PACKAGE_PATH)).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(PACKAGE_PATH);
    when(packageResource.getChild("jcr:content")).thenReturn(jcrPackageJcrContent);

    when(jcrPackage.getPackage()).thenReturn(vaultPackage);
    when(vaultPackage.getCreated()).thenReturn(calendar);

    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put(JcrConstants.JCR_LASTMODIFIED, calendar);
    when(jcrPackageJcrContent.adaptTo(ValueMap.class)).thenReturn(new ValueMapDecorator(properties));

    when(resourceResolver.getResource("/content/foo/jcr:content")).thenReturn(contentResource1);
    when(contentResource1.adaptTo(Node.class)).thenReturn(contentNode1);
    when(contentNode1.isNodeType("cq:PageContent")).thenReturn(true);
    when(contentResource1.getParent()).thenReturn(contentResource1parent);
    when(contentResource1parent.adaptTo(Node.class)).thenReturn(contentNode1parent);
    when(contentNode1parent.isNodeType("cq:Page")).thenReturn(true);

    when(resourceResolver.getResource("/content/bar")).thenReturn(contentResource2);
    when(contentResource2.adaptTo(Node.class)).thenReturn(contentNode2);
    when(contentNode2.isNodeType("dam:AssetContent")).thenReturn(true);

    when(resourceResolver.getResource("/content/dam/folder/jcr:content")).thenReturn(contentResource3);
    when(contentResource3.adaptTo(Node.class)).thenReturn(contentNode3);
    when(contentNode3.isNodeType("nt:unstructured")).thenReturn(true);

    when(contentResource3.getParent()).thenReturn(contentResource3parent);
    when(contentResource3parent.adaptTo(Node.class)).thenReturn(contentNode3parent);
    when(contentNode3parent.isNodeType("sling:OrderedFolder")).thenReturn(true);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:68,代码来源:JcrPackageReplicationStatusEventHandlerTest.java


注:本文中的org.apache.jackrabbit.vault.packaging.VaultPackage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。