@Test public void testWriteNodetypesByName() throws Exception { final File tempDir = new File(testBaseDir, "testWriteNodetypesByName"); final File fromRepoDir = new File(tempDir, "fromRepo/segmentstore"); final File toRepoDir = new File(tempDir, "toRepo/segmentstore"); final File exportedCnd = new File(tempDir, "exported.cnd"); TestUtil.prepareRepo(fromRepoDir, session -> { final URL slingNodetypes = getClass().getResource("/sling_nodetypes.cnd"); TestUtil.installCndFromURL(session, slingNodetypes); }); if (exportedCnd.exists()) { exportedCnd.delete(); } TestUtil.withReadOnlyFixture(fromRepoDir, session -> { final Workspace workspace = session.getWorkspace(); NodeTypeManager ntManager = workspace.getNodeTypeManager(); assertTrue("sling:Folder should be imported", ntManager.hasNodeType("sling:Folder")); assertTrue("sling:OrderedFolder should be imported", ntManager.hasNodeType("sling:OrderedFolder")); new CndExporter.Builder().build() .writeNodetypes(exportedCnd, session, Collections.singletonList("sling:Folder")); }); TestUtil.prepareRepo(toRepoDir, session -> { final URL exportedUrl = exportedCnd.toURL(); TestUtil.installCndFromURL(session, exportedUrl); }); TestUtil.withReadOnlyFixture(toRepoDir, session -> { final Workspace workspace = session.getWorkspace(); NodeTypeManager ntManager = workspace.getNodeTypeManager(); assertTrue("sling:Folder should be imported", ntManager.hasNodeType("sling:Folder")); assertFalse("sling:OrderedFolder should NOT be imported", ntManager.hasNodeType("sling:OrderedFolder")); }); }
public void writeNodetypes(final @NotNull File cndFile, final @NotNull Session session, final @NotNull List<String> desiredTypeNames) throws RepositoryException, IOException, ParseException { writeNodetypes(() -> new OutputStreamWriter(new FileOutputStream(cndFile), StandardCharsets.UTF_8), session, desiredTypeNames, cndFile); }
CndExporter { public void writeNodetypes(final @NotNull File cndFile, final @NotNull Session session, final @NotNull List<String> desiredTypeNames) throws RepositoryException, IOException, ParseException { writeNodetypes(() -> new OutputStreamWriter(new FileOutputStream(cndFile), StandardCharsets.UTF_8), session, desiredTypeNames, cndFile); } }
CndExporter { public void writeNodetypes(final @NotNull File cndFile, final @NotNull Session session, final @NotNull List<String> desiredTypeNames) throws RepositoryException, IOException, ParseException { writeNodetypes(() -> new OutputStreamWriter(new FileOutputStream(cndFile), StandardCharsets.UTF_8), session, desiredTypeNames, cndFile); } private  CndExporter(final List<Rule> scopeExportNames,
                        final List<Rule> scopeReplaceNames,
                        final boolean includeBuiltins); }
CndExporter { public void writeNodetypes(final @NotNull File cndFile, final @NotNull Session session, final @NotNull List<String> desiredTypeNames) throws RepositoryException, IOException, ParseException { writeNodetypes(() -> new OutputStreamWriter(new FileOutputStream(cndFile), StandardCharsets.UTF_8), session, desiredTypeNames, cndFile); } private  CndExporter(final List<Rule> scopeExportNames,
                        final List<Rule> scopeReplaceNames,
                        final boolean includeBuiltins); void writeNodetypes(final @NotNull File cndFile,
                               final @NotNull Session session,
                               final @NotNull List<String> desiredTypeNames); void writeNodetypes(final @NotNull WriterOpener writerOpener,
                               final @NotNull Session session,
                               final @NotNull List<String> desiredTypeNames,
                               final @Nullable File initialCnd); static Map<Name, NodeTypeDefinition> retrieveNodeTypes(final @NotNull Session session,
                                                                  final @NotNull Collection<Name> desiredTypeNames); static Map<Name, NodeTypeDefinition> retrieveNodeTypes(final @NotNull Session session,
                      final @NotNull Collection<Name> desiredTypeNames,
                      final @Nullable BiPredicate<NamePathResolver, NodeType> nodeTypeSelector); }
CndExporter { public void writeNodetypes(final @NotNull File cndFile, final @NotNull Session session, final @NotNull List<String> desiredTypeNames) throws RepositoryException, IOException, ParseException { writeNodetypes(() -> new OutputStreamWriter(new FileOutputStream(cndFile), StandardCharsets.UTF_8), session, desiredTypeNames, cndFile); } private  CndExporter(final List<Rule> scopeExportNames,
                        final List<Rule> scopeReplaceNames,
                        final boolean includeBuiltins); void writeNodetypes(final @NotNull File cndFile,
                               final @NotNull Session session,
                               final @NotNull List<String> desiredTypeNames); void writeNodetypes(final @NotNull WriterOpener writerOpener,
                               final @NotNull Session session,
                               final @NotNull List<String> desiredTypeNames,
                               final @Nullable File initialCnd); static Map<Name, NodeTypeDefinition> retrieveNodeTypes(final @NotNull Session session,
                                                                  final @NotNull Collection<Name> desiredTypeNames); static Map<Name, NodeTypeDefinition> retrieveNodeTypes(final @NotNull Session session,
                      final @NotNull Collection<Name> desiredTypeNames,
                      final @Nullable BiPredicate<NamePathResolver, NodeType> nodeTypeSelector); static final List<String> BUILTIN_NODETYPES; }