test_class.declarator: testBaseDir = new File("target/repos/ChecklistExporterTest")
test_class.modifier: final
test_class.original_string: final File testBaseDir = new File("target/repos/ChecklistExporterTest");
test_class.type: File
test_class.var_name: testBaseDir
test_class.file: webster/src/test/java/net/adamcin/oakpal/webster/ChecklistExporterTest.java
test_class.identifier: ChecklistExporterTest
test_case.body: @Test
      public void testUpdateChecklist() throws Exception {
          final String pathPrefix = "/test";
          final File tempDir = new File(testBaseDir, "testUpdateChecklist");
          final File pass1Dir = new File(tempDir, "pass1/segmentstore");
          final File pass1Checklist = new File(tempDir, "pass1.chk.json");
          final File fullRepoDir = new File(tempDir, "fullRepo/segmentstore");
          final File diffRepoDir = new File(tempDir, "diffRepo/segmentstore");
          final File fullPassChecklist = new File(tempDir, "fullPass.chk.json");
          final File mergePassChecklist = new File(tempDir, "mergePass.chk.json");
          final File replacePassChecklist = new File(tempDir, "replacePass.chk.json");
          final File truncatePassChecklist = new File(tempDir, "truncatePass.chk.json");
  
          final int sample = 5;
          List<String> orderedPaths = IntStream.range(0, sample).mapToObj(val -> pathPrefix + "/ordered" + val).collect(Collectors.toList());
          List<String> unorderedPaths = IntStream.range(0, sample).mapToObj(val -> pathPrefix + "/unordered" + val).collect(Collectors.toList());
          assertEquals("should generate n paths: ", sample, orderedPaths.size());
  
          final List<String> allPaths = new ArrayList<>(orderedPaths);
          allPaths.addAll(unorderedPaths);
          allPaths.add(pathPrefix);
  
          TestUtil.prepareRepo(pass1Dir, session -> {
              TestUtil.installCndFromURL(session, getClass().getResource("/sling_nodetypes.cnd"));
              orderedPaths.forEach(Fun.tryOrVoid1(path ->
                      JcrUtils.getOrCreateByPath(path, "nt:folder",
                              "sling:OrderedFolder", session, true)));
              unorderedPaths.forEach(Fun.tryOrVoid1(path ->
                      JcrUtils.getOrCreateByPath(path, "nt:folder",
                              "sling:Folder", session, true)));
          });
  
          TestUtil.prepareRepo(fullRepoDir, session -> {
              TestUtil.installCndFromURL(session, getClass().getResource("/sling_nodetypes.cnd"));
              allPaths.forEach(Fun.uncheckVoid1(path -> {
                  Node node = JcrUtils.getOrCreateByPath(path, "sling:Folder", session);
                  node.addMixin("mix:title");
                  node.addMixin("sling:Resource");
              }));
              session.save();
          });
  
          TestUtil.prepareRepo(diffRepoDir, session -> {
              TestUtil.installCndFromURL(session, getClass().getResource("/sling_nodetypes.cnd"));
              allPaths.stream().filter(path -> path.matches(".*[02468]$"))
                      .forEachOrdered(Fun.uncheckVoid1(path -> {
                          Node node = JcrUtils.getOrCreateByPath(path, "sling:Folder", session);
                          node.addMixin("mix:title");
                          node.addMixin("sling:Resource");
                      }));
              session.save();
          });
  
          TestUtil.withReadOnlyFixture(pass1Dir, session -> {
              ChecklistExporter pathExporter = new ChecklistExporter.Builder().byPath(allPaths.toArray(new String[0])).build();
  
              pathExporter.updateChecklist(() -> new OutputStreamWriter(
                              new FileOutputStream(pass1Checklist), StandardCharsets.UTF_8),
                      session, Checklist.fromJson("", null, obj()
                              .key(Checklist.keys().jcrNamespaces(), Collections
                                      .singletonList(JcrNs.create("sling",
                                              "http://sling.apache.org/jcr/sling/1.0")))
                              .key(Checklist.keys().jcrPrivileges(), obj()
                                      .key("sling:doesAll", obj()
                                              .key("contains", arr("sling:doOne", "sling:doTwo")))
                                      .get())
                              .get()), null);
  
              try (JsonReader reader = Json.createReader(new FileInputStream(pass1Checklist))) {
                  JsonObject checklist = reader.readObject();
                  assertTrue("checklist object should contain the forcedRoots key",
                          checklist.containsKey(Checklist.keys().forcedRoots()));
                  assertTrue("checklist object should contain the privileges key",
                          checklist.containsKey(Checklist.keys().jcrPrivileges()));
  
                  JsonArray forcedRoots = checklist.getJsonArray(Checklist.keys().forcedRoots());
                  assertEquals("forcedRoots should be array with expected number of elements", allPaths.size(),
                          forcedRoots.size());
  
                  List<ForcedRoot> readRoots = JavaxJson.mapArrayOfObjects(forcedRoots, ForcedRoot::fromJson);
                  for (String path : unorderedPaths) {
                      ForcedRoot root0 = readRoots.stream().filter(root -> path.equals(root.getPath())).findFirst().orElse(null);
                      assertNotNull(String.format("[pass1] root for path %s should not be null", path), root0);
                      assertEquals(String.format("[pass1] root primaryType for path %s should be sling:Folder", path),
                              "sling:Folder", root0.getPrimaryType());
                  }
                  for (String path : orderedPaths) {
                      ForcedRoot root0 = readRoots.stream().filter(root -> path.equals(root.getPath())).findFirst().orElse(null);
                      assertNotNull(String.format("[pass1] root for path %s should not be null", path), root0);
                      assertEquals(String.format("[pass1] root primaryType for path %s should be sling:OrderedFolder", path),
                              "sling:OrderedFolder", root0.getPrimaryType());
                  }
              }
          });
  
  
          TestUtil.withReadOnlyFixture(fullRepoDir, session -> {
              ChecklistExporter pathExporter = new ChecklistExporter.Builder().byPath(allPaths.toArray(new String[0])).build();
  
              try (JsonReader reader = Json.createReader(new FileInputStream(pass1Checklist))) {
  
                  pathExporter.updateChecklist(() -> new OutputStreamWriter(
                                  new FileOutputStream(fullPassChecklist), StandardCharsets.UTF_8),
                          session, Checklist.fromJson("", null, reader.readObject()), null);
              }
  
              try (JsonReader reader = Json.createReader(new FileInputStream(fullPassChecklist))) {
                  JsonObject checklist = reader.readObject();
                  assertTrue("checklist object should contain the forcedRoots key",
                          checklist.containsKey(Checklist.keys().forcedRoots()));
                  assertTrue("checklist object should contain the privileges key",
                          checklist.containsKey(Checklist.keys().jcrPrivileges()));
  
                  JsonArray forcedRoots = checklist.getJsonArray(Checklist.keys().forcedRoots());
                  assertEquals("forcedRoots should be array with expected number of elements", allPaths.size(),
                          forcedRoots.size());
  
                  List<ForcedRoot> readRoots = JavaxJson.mapArrayOfObjects(forcedRoots, ForcedRoot::fromJson);
                  for (String path : allPaths) {
                      ForcedRoot root0 = readRoots.stream().filter(root -> path.equals(root.getPath())).findFirst().orElse(null);
                      assertNotNull(String.format("[pass2] root for path %s should not be null", path), root0);
                      assertEquals(String.format("[pass2] root primaryType for path %s should be sling:Folder", path),
                              "sling:Folder", root0.getPrimaryType());
                      assertTrue(String.format("[pass2] root mixinTypes for path %s should contain mix:title", path),
                              root0.getMixinTypes().contains("mix:title"));
                  }
              }
          });
  
          TestUtil.withReadOnlyFixture(diffRepoDir, session -> {
              ChecklistExporter diffExporter = new ChecklistExporter.Builder()
                      .byNodeType("sling:Folder")
                      .withScopePaths(Rules.fromJsonArray(arr(key("type", "include").key("pattern", pathPrefix + "/ordered.*")).get()))
                      .withNodeTypeFilters(Rules.fromJsonArray(arr(key("type", "exclude").key("pattern", "sling:.*")).get()))
                      .build();
  
              try (JsonReader reader = Json.createReader(new FileInputStream(fullPassChecklist))) {
  
                  diffExporter.updateChecklist(() -> new OutputStreamWriter(
                                  new FileOutputStream(mergePassChecklist), StandardCharsets.UTF_8),
                          session, Checklist.fromJson("", null, reader.readObject()),
                          ChecklistExporter.ForcedRootUpdatePolicy.MERGE);
              }
  
              try (JsonReader reader = Json.createReader(new FileInputStream(fullPassChecklist))) {
  
                  diffExporter.updateChecklist(() -> new OutputStreamWriter(
                                  new FileOutputStream(replacePassChecklist), StandardCharsets.UTF_8),
                          session, Checklist.fromJson("", null, reader.readObject()),
                          ChecklistExporter.ForcedRootUpdatePolicy.REPLACE);
              }
  
              try (JsonReader reader = Json.createReader(new FileInputStream(fullPassChecklist))) {
  
                  diffExporter.updateChecklist(() -> new OutputStreamWriter(
                                  new FileOutputStream(truncatePassChecklist), StandardCharsets.UTF_8),
                          session, Checklist.fromJson("", null, reader.readObject()),
                          ChecklistExporter.ForcedRootUpdatePolicy.TRUNCATE);
              }
  
              try (JsonReader reader = Json.createReader(new FileInputStream(mergePassChecklist))) {
                  JsonObject checklist = reader.readObject();
                  assertTrue("checklist object should contain the forcedRoots key",
                          checklist.containsKey(Checklist.keys().forcedRoots()));
  
                  JsonArray forcedRoots = checklist.getJsonArray(Checklist.keys().forcedRoots());
                  assertEquals("[mergePass] forcedRoots should be array with expected number of elements", allPaths.size(),
                          forcedRoots.size());
  
                  List<ForcedRoot> readRoots = JavaxJson.mapArrayOfObjects(forcedRoots, ForcedRoot::fromJson);
                  for (String path : allPaths) {
                      ForcedRoot root0 = readRoots.stream().filter(root -> path.equals(root.getPath())).findFirst().orElse(null);
                      if (path.matches(".*/ordered[02468]$")) {
                          assertNotNull(String.format("[mergePass] root for path %s should not be null", path), root0);
                          assertNull(String.format("[mergePass] root primaryType for path %s should be sling:Folder", path),
                                  root0.getPrimaryType());
                          assertTrue(String.format("[mergePass] root mixinTypes for path %s should contain mix:title", path),
                                  root0.getMixinTypes().contains("mix:title"));
                          assertFalse(String.format("[mergePass] root mixinTypes for path %s should NOT contain sling:Resource", path),
                                  root0.getMixinTypes().contains("sling:Resource"));
                      } else {
                          assertNotNull(String.format("[mergePass] root for path %s should not be null", path), root0);
                          assertEquals(String.format("[mergePass] root primaryType for path %s should be sling:Folder", path),
                                  "sling:Folder", root0.getPrimaryType());
                          assertTrue(String.format("[mergePass] root mixinTypes for path %s should contain mix:title", path),
                                  root0.getMixinTypes().contains("mix:title"));
                          assertTrue(String.format("[mergePass] root mixinTypes for path %s should contain sling:Resource", path),
                                  root0.getMixinTypes().contains("sling:Resource"));
                      }
                  }
              }
  
              try (JsonReader reader = Json.createReader(new FileInputStream(replacePassChecklist))) {
                  JsonObject checklist = reader.readObject();
                  assertTrue("checklist object should contain the forcedRoots key",
                          checklist.containsKey(Checklist.keys().forcedRoots()));
  
                  JsonArray forcedRoots = checklist.getJsonArray(Checklist.keys().forcedRoots());
                  assertEquals("[replacePass] forcedRoots should be array with expected number of elements",
                          1 + unorderedPaths.size() + orderedPaths.stream().filter(path -> path.matches(".*[02468]$")).count(),
                          forcedRoots.size());
  
                  List<ForcedRoot> readRoots = JavaxJson.mapArrayOfObjects(forcedRoots, ForcedRoot::fromJson);
                  for (String path : allPaths) {
                      ForcedRoot root0 = readRoots.stream().filter(root -> path.equals(root.getPath())).findFirst().orElse(null);
                      if (path.matches(".*/ordered[02468]$")) {
                          assertNotNull(String.format("[replacePass] root for path %s should not be null", path), root0);
                          assertNull(String.format("[replacePass] root primaryType for path %s should be sling:Folder", path),
                                  root0.getPrimaryType());
                          assertTrue(String.format("[replacePass] root mixinTypes for path %s should contain mix:title", path),
                                  root0.getMixinTypes().contains("mix:title"));
                          assertFalse(String.format("[replacePass] root mixinTypes for path %s should NOT contain sling:Resource", path),
                                  root0.getMixinTypes().contains("sling:Resource"));
                      } else if (path.equals(pathPrefix) || path.matches(".*/unordered.*")) {
                          assertNotNull(String.format("[replacePass] root for path %s should not be null", path), root0);
                          assertEquals(String.format("[replacePass] root primaryType for path %s should be sling:Folder", path),
                                  "sling:Folder", root0.getPrimaryType());
                          assertTrue(String.format("[replacePass] root mixinTypes for path %s should contain mix:title", path),
                                  root0.getMixinTypes().contains("mix:title"));
                          assertTrue(String.format("[replacePass] root mixinTypes for path %s should contain sling:Resource", path),
                                  root0.getMixinTypes().contains("sling:Resource"));
                      } else {
                          assertNull(String.format("[replacePass] root for path %s should be null", path), root0);
                      }
                  }
              }
  
              try (JsonReader reader = Json.createReader(new FileInputStream(truncatePassChecklist))) {
                  JsonObject checklist = reader.readObject();
                  assertTrue("checklist object should contain the forcedRoots key",
                          checklist.containsKey(Checklist.keys().forcedRoots()));
  
                  JsonArray forcedRoots = checklist.getJsonArray(Checklist.keys().forcedRoots());
                  assertEquals("[truncatePass] forcedRoots should be array with expected number of elements",
                          orderedPaths.stream().filter(path -> path.matches(".*[02468]$")).count(), forcedRoots.size());
  
                  List<ForcedRoot> readRoots = JavaxJson.mapArrayOfObjects(forcedRoots, ForcedRoot::fromJson);
                  for (String path : allPaths) {
                      ForcedRoot root0 = readRoots.stream().filter(root -> path.equals(root.getPath())).findFirst().orElse(null);
                      if (path.matches(".*/ordered[02468]$")) {
                          assertNotNull(String.format("[truncatePass] root for path %s should not be null", path), root0);
                          assertNull(String.format("[truncatePass] root primaryType for path %s should be sling:Folder", path),
                                  root0.getPrimaryType());
                          assertTrue(String.format("[truncatePass] root mixinTypes for path %s should contain mix:title", path),
                                  root0.getMixinTypes().contains("mix:title"));
                          assertFalse(String.format("[truncatePass] root mixinTypes for path %s should NOT contain sling:Resource", path),
                                  root0.getMixinTypes().contains("sling:Resource"));
                      } else {
                          assertNull(String.format("[truncatePass] root for path %s should not be null", path), root0);
                      }
                  }
              }
          });
      }
test_case.class_method_signature: ChecklistExporterTest.testUpdateChecklist()
test_case.full_signature: @Test public void testUpdateChecklist()
test_case.identifier: testUpdateChecklist
test_case.invocations: collect mapToObj range toList collect mapToObj range toList assertEquals size addAll add prepareRepo installCndFromURL getResource getClass forEach tryOrVoid1 getOrCreateByPath forEach tryOrVoid1 getOrCreateByPath prepareRepo installCndFromURL getResource getClass forEach uncheckVoid1 getOrCreateByPath addMixin addMixin save prepareRepo installCndFromURL getResource getClass forEachOrdered filter stream matches uncheckVoid1 getOrCreateByPath addMixin addMixin save withReadOnlyFixture build byPath toArray updateChecklist fromJson get key key obj jcrNamespaces keys singletonList create jcrPrivileges keys get key obj key obj arr createReader readObject assertTrue containsKey forcedRoots keys assertTrue containsKey jcrPrivileges keys getJsonArray forcedRoots keys assertEquals size size mapArrayOfObjects orElse findFirst filter stream equals getPath assertNotNull format assertEquals format getPrimaryType orElse findFirst filter stream equals getPath assertNotNull format assertEquals format getPrimaryType withReadOnlyFixture build byPath toArray createReader updateChecklist fromJson readObject createReader readObject assertTrue containsKey forcedRoots keys assertTrue containsKey jcrPrivileges keys getJsonArray forcedRoots keys assertEquals size size mapArrayOfObjects orElse findFirst filter stream equals getPath assertNotNull format assertEquals format getPrimaryType assertTrue format contains getMixinTypes withReadOnlyFixture build withNodeTypeFilters withScopePaths byNodeType fromJsonArray get arr key key fromJsonArray get arr key key createReader updateChecklist fromJson readObject createReader updateChecklist fromJson readObject createReader updateChecklist fromJson readObject createReader readObject assertTrue containsKey forcedRoots keys getJsonArray forcedRoots keys assertEquals size size mapArrayOfObjects orElse findFirst filter stream equals getPath matches assertNotNull format assertNull format getPrimaryType assertTrue format contains getMixinTypes assertFalse format contains getMixinTypes assertNotNull format assertEquals format getPrimaryType assertTrue format contains getMixinTypes assertTrue format contains getMixinTypes createReader readObject assertTrue containsKey forcedRoots keys getJsonArray forcedRoots keys assertEquals size count filter stream matches size mapArrayOfObjects orElse findFirst filter stream equals getPath matches assertNotNull format assertNull format getPrimaryType assertTrue format contains getMixinTypes assertFalse format contains getMixinTypes equals matches assertNotNull format assertEquals format getPrimaryType assertTrue format contains getMixinTypes assertTrue format contains getMixinTypes assertNull format createReader readObject assertTrue containsKey forcedRoots keys getJsonArray forcedRoots keys assertEquals count filter stream matches size mapArrayOfObjects orElse findFirst filter stream equals getPath matches assertNotNull format assertNull format getPrimaryType assertTrue format contains getMixinTypes assertFalse format contains getMixinTypes assertNull format
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testUpdateChecklist()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(ChecklistExporter.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(ChecklistExporter.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: operations
focal_class.modifier: private final
focal_class.original_string: private final List<Op> operations;
focal_class.type: List<Op>
focal_class.var_name: operations
focal_class.declarator: exportTypeDefs
focal_class.modifier: private final
focal_class.original_string: private final List<String> exportTypeDefs;
focal_class.type: List<String>
focal_class.var_name: exportTypeDefs
focal_class.declarator: pathScopes
focal_class.modifier: private final
focal_class.original_string: private final List<Rule> pathScopes;
focal_class.type: List<Rule>
focal_class.var_name: pathScopes
focal_class.declarator: nodeTypeFilters
focal_class.modifier: private final
focal_class.original_string: private final List<Rule> nodeTypeFilters;
focal_class.type: List<Rule>
focal_class.var_name: nodeTypeFilters
focal_class.declarator: jcrNamespaces
focal_class.modifier: private final
focal_class.original_string: private final List<JcrNs> jcrNamespaces;
focal_class.type: List<JcrNs>
focal_class.var_name: jcrNamespaces
focal_class.declarator: DEFAULT_UPDATE_POLICY = ForcedRootUpdatePolicy.REPLACE
focal_class.modifier: public static final
focal_class.original_string: public static final ForcedRootUpdatePolicy DEFAULT_UPDATE_POLICY = ForcedRootUpdatePolicy.REPLACE;
focal_class.type: ForcedRootUpdatePolicy
focal_class.var_name: DEFAULT_UPDATE_POLICY
focal_class.declarator: COVARIANT_PREFIX = "+"
focal_class.modifier: public static final
focal_class.original_string: public static final String COVARIANT_PREFIX = "+";
focal_class.type: String
focal_class.var_name: COVARIANT_PREFIX
focal_class.declarator: COVARIANT_FILTER = name -> name.startsWith(COVARIANT_PREFIX)
focal_class.modifier: static final
focal_class.original_string: static final Predicate<String> COVARIANT_FILTER = name -> name.startsWith(COVARIANT_PREFIX);
focal_class.type: Predicate<String>
focal_class.var_name: COVARIANT_FILTER
focal_class.declarator: COVARIANT_FORMAT = name -> name.substring(COVARIANT_PREFIX.length())
focal_class.modifier: static final
focal_class.original_string: static final Function<String, String> COVARIANT_FORMAT = name -> name.substring(COVARIANT_PREFIX.length());
focal_class.type: Function<String, String>
focal_class.var_name: COVARIANT_FORMAT
focal_class.file: webster/src/main/java/net/adamcin/oakpal/webster/ChecklistExporter.java
focal_class.identifier: ChecklistExporter
focal_class.class_method_signature: ChecklistExporter.ChecklistExporter(final List<Op> operations,
                                final List<String> exportTypeDefs,
                                final List<Rule> pathScopes,
                                final List<Rule> nodeTypeFilters,
                                final List<JcrNs> jcrNamespaces)
focal_class.full_signature: private  ChecklistExporter(final List<Op> operations,
                                final List<String> exportTypeDefs,
                                final List<Rule> pathScopes,
                                final List<Rule> nodeTypeFilters,
                                final List<JcrNs> jcrNamespaces)
focal_class.identifier: ChecklistExporter
focal_class.modifiers: private
focal_class.parameters: (final List<Op> operations,
                                final List<String> exportTypeDefs,
                                final List<Rule> pathScopes,
                                final List<Rule> nodeTypeFilters,
                                final List<JcrNs> jcrNamespaces)
focal_class.signature:  ChecklistExporter(final List<Op> operations,
                                final List<String> exportTypeDefs,
                                final List<Rule> pathScopes,
                                final List<Rule> nodeTypeFilters,
                                final List<JcrNs> jcrNamespaces)
focal_class.class_method_signature: ChecklistExporter.ensureNamespaces(final @NotNull Session session,
                                   final @NotNull NamespaceMapping namespaces)
focal_class.full_signature: static void ensureNamespaces(final @NotNull Session session,
                                   final @NotNull NamespaceMapping namespaces)
focal_class.identifier: ensureNamespaces
focal_class.modifiers: static
focal_class.parameters: (final @NotNull Session session,
                                   final @NotNull NamespaceMapping namespaces)
focal_class.return: void
focal_class.signature: void ensureNamespaces(final @NotNull Session session,
                                   final @NotNull NamespaceMapping namespaces)
focal_class.class_method_signature: ChecklistExporter.findJcrPrefixesInForcedRoot(final @NotNull Set<String> acc, final @NotNull ForcedRoot forcedRoot)
focal_class.full_signature: static Set<String> findJcrPrefixesInForcedRoot(final @NotNull Set<String> acc, final @NotNull ForcedRoot forcedRoot)
focal_class.identifier: findJcrPrefixesInForcedRoot
focal_class.modifiers: static
focal_class.parameters: (final @NotNull Set<String> acc, final @NotNull ForcedRoot forcedRoot)
focal_class.return: Set<String>
focal_class.signature: Set<String> findJcrPrefixesInForcedRoot(final @NotNull Set<String> acc, final @NotNull ForcedRoot forcedRoot)
focal_class.class_method_signature: ChecklistExporter.findNodeTypesInForcedRoot(final Set<String> acc, final ForcedRoot forcedRoot)
focal_class.full_signature: static Set<String> findNodeTypesInForcedRoot(final Set<String> acc, final ForcedRoot forcedRoot)
focal_class.identifier: findNodeTypesInForcedRoot
focal_class.modifiers: static
focal_class.parameters: (final Set<String> acc, final ForcedRoot forcedRoot)
focal_class.return: Set<String>
focal_class.signature: Set<String> findNodeTypesInForcedRoot(final Set<String> acc, final ForcedRoot forcedRoot)
focal_class.class_method_signature: ChecklistExporter.preferDifferent(final @NotNull U value)
focal_class.full_signature: static BinaryOperator<U> preferDifferent(final @NotNull U value)
focal_class.identifier: preferDifferent
focal_class.modifiers: static
focal_class.parameters: (final @NotNull U value)
focal_class.return: BinaryOperator<U>
focal_class.signature: BinaryOperator<U> preferDifferent(final @NotNull U value)
focal_class.class_method_signature: ChecklistExporter.nsRemapName(final NamespaceMapping fromMapping, final NamespaceMapping toMapping)
focal_class.full_signature: static Function<String, String> nsRemapName(final NamespaceMapping fromMapping, final NamespaceMapping toMapping)
focal_class.identifier: nsRemapName
focal_class.modifiers: static
focal_class.parameters: (final NamespaceMapping fromMapping, final NamespaceMapping toMapping)
focal_class.return: Function<String, String>
focal_class.signature: Function<String, String> nsRemapName(final NamespaceMapping fromMapping, final NamespaceMapping toMapping)
focal_class.class_method_signature: ChecklistExporter.nsRemapForcedRoot(final NamespaceMapping fromMapping, final NamespaceMapping toMapping)
focal_class.full_signature: static Function<ForcedRoot, ForcedRoot> nsRemapForcedRoot(final NamespaceMapping fromMapping, final NamespaceMapping toMapping)
focal_class.identifier: nsRemapForcedRoot
focal_class.modifiers: static
focal_class.parameters: (final NamespaceMapping fromMapping, final NamespaceMapping toMapping)
focal_class.return: Function<ForcedRoot, ForcedRoot>
focal_class.signature: Function<ForcedRoot, ForcedRoot> nsRemapForcedRoot(final NamespaceMapping fromMapping, final NamespaceMapping toMapping)
focal_class.class_method_signature: ChecklistExporter.getRetainFilter(final ForcedRootUpdatePolicy updatePolicy)
focal_class.full_signature:  Predicate<ForcedRoot> getRetainFilter(final ForcedRootUpdatePolicy updatePolicy)
focal_class.identifier: getRetainFilter
focal_class.parameters: (final ForcedRootUpdatePolicy updatePolicy)
focal_class.return: Predicate<ForcedRoot>
focal_class.signature: Predicate<ForcedRoot> getRetainFilter(final ForcedRootUpdatePolicy updatePolicy)
focal_class.class_method_signature: ChecklistExporter.exportTypeDefSelector()
focal_class.full_signature:  BiPredicate<NamePathResolver, NodeType> exportTypeDefSelector()
focal_class.identifier: exportTypeDefSelector
focal_class.parameters: ()
focal_class.return: BiPredicate<NamePathResolver, NodeType>
focal_class.signature: BiPredicate<NamePathResolver, NodeType> exportTypeDefSelector()
focal_class.class_method_signature: ChecklistExporter.updateChecklist(final WriterOpener writerOpener,
                                  final Session session,
                                  final Checklist checklist,
                                  final ForcedRootUpdatePolicy updatePolicy)
focal_class.full_signature: public void updateChecklist(final WriterOpener writerOpener,
                                  final Session session,
                                  final Checklist checklist,
                                  final ForcedRootUpdatePolicy updatePolicy)
focal_class.identifier: updateChecklist
focal_class.modifiers: public
focal_class.parameters: (final WriterOpener writerOpener,
                                  final Session session,
                                  final Checklist checklist,
                                  final ForcedRootUpdatePolicy updatePolicy)
focal_class.return: void
focal_class.signature: void updateChecklist(final WriterOpener writerOpener,
                                  final Session session,
                                  final Checklist checklist,
                                  final ForcedRootUpdatePolicy updatePolicy)
focal_class.class_method_signature: ChecklistExporter.addToLeft()
focal_class.full_signature: static BinaryOperator<U> addToLeft()
focal_class.identifier: addToLeft
focal_class.modifiers: static
focal_class.parameters: ()
focal_class.return: BinaryOperator<U>
focal_class.signature: BinaryOperator<U> addToLeft()
focal_class.class_method_signature: ChecklistExporter.findRoots(final Session session)
focal_class.full_signature: public List<ForcedRoot> findRoots(final Session session)
focal_class.identifier: findRoots
focal_class.modifiers: public
focal_class.parameters: (final Session session)
focal_class.return: List<ForcedRoot>
focal_class.signature: List<ForcedRoot> findRoots(final Session session)
focal_class.class_method_signature: ChecklistExporter.ntStatement(final Session session, final List<String> nodeTypeNames)
focal_class.full_signature:  String ntStatement(final Session session, final List<String> nodeTypeNames)
focal_class.identifier: ntStatement
focal_class.parameters: (final Session session, final List<String> nodeTypeNames)
focal_class.return: String
focal_class.signature: String ntStatement(final Session session, final List<String> nodeTypeNames)
focal_class.class_method_signature: ChecklistExporter.query(final Session session, final String statement)
focal_class.full_signature:  List<ForcedRoot> query(final Session session, final String statement)
focal_class.identifier: query
focal_class.parameters: (final Session session, final String statement)
focal_class.return: List<ForcedRoot>
focal_class.signature: List<ForcedRoot> query(final Session session, final String statement)
focal_class.class_method_signature: ChecklistExporter.traverse(final Session session, final List<String> paths)
focal_class.full_signature:  List<ForcedRoot> traverse(final Session session, final List<String> paths)
focal_class.identifier: traverse
focal_class.parameters: (final Session session, final List<String> paths)
focal_class.return: List<ForcedRoot>
focal_class.signature: List<ForcedRoot> traverse(final Session session, final List<String> paths)
focal_class.class_method_signature: ChecklistExporter.nodeToRoot(final Node node, final NamespaceMapping mapping)
focal_class.full_signature:  Optional<ForcedRoot> nodeToRoot(final Node node, final NamespaceMapping mapping)
focal_class.identifier: nodeToRoot
focal_class.parameters: (final Node node, final NamespaceMapping mapping)
focal_class.return: Optional<ForcedRoot>
focal_class.signature: Optional<ForcedRoot> nodeToRoot(final Node node, final NamespaceMapping mapping)
focal_method.body: public void updateChecklist(final WriterOpener writerOpener,
                                  final Session session,
                                  final Checklist checklist,
                                  final ForcedRootUpdatePolicy updatePolicy)
              throws IOException, RepositoryException {
  
          final List<JcrNs> chkNs = new ArrayList<>();
          // first attempt to remap JCR namespaces in the session, if necessary.
          if (checklist != null && checklist.getJcrNamespaces() != null) {
              chkNs.addAll(checklist.getJcrNamespaces());
          }
  
          final NamespaceMapping origMapping = JsonCnd.toNamespaceMapping(chkNs);
          final NamespaceMapping remapping = JsonCnd.toNamespaceMapping(jcrNamespaces);
  
          ensureNamespaces(session, origMapping);
          ensureNamespaces(session, remapping);
  
          // try to find the roots. If any error occurs there, we want to fail fast before committing to other
          // potentially expensive, destructive, or error-prone logic.
          final List<ForcedRoot> newRoots = findRoots(session);
  
          // construct a stream filter for retaining existing forced roots
          Predicate<ForcedRoot> retainFilter = getRetainFilter(updatePolicy);
  
          final JsonObjectBuilder builder = Json.createObjectBuilder();
          final Map<String, ForcedRoot> existing = new LinkedHashMap<>();
          final List<PrivilegeDefinition> privileges = new ArrayList<>();
  
          // remap the names of existing jcr definitions to match the new jcr namespaces
          if (checklist != null) {
              checklist.toJson().forEach(builder::add);
  
              privileges.addAll(checklist.getJcrPrivileges());
  
              checklist.getForcedRoots().stream()
                      .map(nsRemapForcedRoot(origMapping, remapping))
                      .filter(retainFilter)
                      .forEachOrdered(root -> existing.put(root.getPath(), root));
          }
  
          //final Set<String> finalPrefixes = new HashSet<>();
          final NamespaceMappingRequest.Builder request = new NamespaceMappingRequest.Builder();
          if (!privileges.isEmpty()) {
              builder.add(Checklist.keys().jcrPrivileges(), JsonCnd.privilegesToJson(privileges, origMapping));
              privileges.stream().flatMap(JsonCnd::namedBy).forEach(request::withQName);
          }
  
          newRoots.forEach(root -> existing.put(root.getPath(), root));
  
          final List<ForcedRoot> forcedRoots = new ArrayList<>(existing.values());
          Collections.sort(forcedRoots);
  
          final JsonArray forcedRootsJson = forcedRoots.stream()
                  .map(ForcedRoot::toJson)
                  .collect(JsonCollectors.toJsonArray());
  
          builder.add(Checklist.keys().forcedRoots(), forcedRootsJson);
  
          // begin nodetype handling
  
          final NamePathResolver resolver = new DefaultNamePathResolver(session);
          final Set<Name> builtinNodetypes = CndExporter.BUILTIN_NODETYPES.stream()
                  .map(uncheck1(resolver::getQName))
                  .filter(Objects::nonNull)
                  .collect(Collectors.toSet());
  
          final List<Name> foundNodeTypes = forcedRoots.stream()
                  .reduce(new HashSet<>(),
                          ChecklistExporter::findNodeTypesInForcedRoot,
                          addToLeft()).stream()
                  .map(uncheck1(resolver::getQName))
                  .collect(Collectors.toList());
  
          final Map<Name, NodeTypeDefinition> exportedNodeTypes =
                  CndExporter.retrieveNodeTypes(session, foundNodeTypes, exportTypeDefSelector());
          final List<QNodeTypeDefinition> qNodeTypes = exportedNodeTypes.entrySet().stream()
                  .map(mapValue(JsonCnd.adaptToQ(session)))
                  .filter(testKey(((Predicate<Name>) builtinNodetypes::contains).negate()))
                  .map(Map.Entry::getValue)
                  .collect(Collectors.toList());
  
          final NamespaceMapping spm = new NamespaceMapping(new SessionNamespaceResolver(session));
  
          if (!qNodeTypes.isEmpty()) {
              final Set<String> nsUris = qNodeTypes.stream()
                      .flatMap(JsonCnd::namedBy)
                      .map(Name::getNamespaceURI)
                      .collect(Collectors.toSet());
  
              final Map<String, String> uriMapping = remapping.getURIToPrefixMapping();
              nsUris.forEach(Fun.uncheckVoid1(uri -> {
                  final String prefix = uriMapping.containsKey(uri) ? uriMapping.get(uri) : spm.getPrefix(uri);
                  request.withRetainPrefix(prefix);
                  spm.setMapping(prefix, uri);
              }));
  
              final JsonObject jcrNodetypes =
                      JsonCnd.toJson(qNodeTypes, new NamespaceMapping(new SessionNamespaceResolver(session)));
              builder.add(Checklist.keys().jcrNodetypes(), jcrNodetypes);
          }
  
          // begin namespace handling
          final Set<String> forcedRootPrefixes = forcedRoots.stream()
                  .reduce(new HashSet<>(),
                          ChecklistExporter::findJcrPrefixesInForcedRoot,
                          addToLeft());
          forcedRootPrefixes.forEach(request::withRetainPrefix);
  
          final List<JcrNs> exportNamespaces = request.build()
                  .resolveToJcrNs(spm).stream()
                  .flatMap(Result::stream)
                  .collect(Collectors.toList());
          if (!exportNamespaces.isEmpty()) {
              builder.add(Checklist.keys().jcrNamespaces(), JavaxJson.wrap(exportNamespaces));
          }
  
          final JsonObject sorted = builder.build().entrySet().stream()
                  .sorted(Checklist.comparingJsonKeys(Map.Entry::getKey))
                  .collect(JsonCollectors.toJsonObject());
  
          try (Writer writer = writerOpener.open();
               JsonWriter jsonWriter = Json
                       .createWriterFactory(Collections.singletonMap(JsonGenerator.PRETTY_PRINTING, true))
                       .createWriter(writer)) {
              jsonWriter.writeObject(sorted);
          }
      }
focal_method.class_method_signature: ChecklistExporter.updateChecklist(final WriterOpener writerOpener,
                                  final Session session,
                                  final Checklist checklist,
                                  final ForcedRootUpdatePolicy updatePolicy)
focal_method.full_signature: public void updateChecklist(final WriterOpener writerOpener,
                                  final Session session,
                                  final Checklist checklist,
                                  final ForcedRootUpdatePolicy updatePolicy)
focal_method.identifier: updateChecklist
focal_method.invocations: getJcrNamespaces addAll getJcrNamespaces toNamespaceMapping toNamespaceMapping ensureNamespaces ensureNamespaces findRoots getRetainFilter createObjectBuilder forEach toJson addAll getJcrPrivileges forEachOrdered filter map stream getForcedRoots nsRemapForcedRoot put getPath isEmpty add jcrPrivileges keys privilegesToJson forEach flatMap stream forEach put getPath values sort collect map stream toJsonArray add forcedRoots keys collect filter map stream uncheck1 toSet collect map stream reduce stream addToLeft uncheck1 toList retrieveNodeTypes exportTypeDefSelector collect map filter map stream entrySet mapValue adaptToQ testKey negate toList isEmpty collect map flatMap stream toSet getURIToPrefixMapping forEach uncheckVoid1 containsKey get getPrefix withRetainPrefix setMapping toJson add jcrNodetypes keys reduce stream addToLeft forEach collect flatMap stream resolveToJcrNs build toList isEmpty add jcrNamespaces keys wrap collect sorted stream entrySet build comparingJsonKeys toJsonObject open createWriter createWriterFactory singletonMap writeObject
focal_method.modifiers: public
focal_method.parameters: (final WriterOpener writerOpener,
                                  final Session session,
                                  final Checklist checklist,
                                  final ForcedRootUpdatePolicy updatePolicy)
focal_method.return: void
focal_method.signature: void updateChecklist(final WriterOpener writerOpener,
                                  final Session session,
                                  final Checklist checklist,
                                  final ForcedRootUpdatePolicy updatePolicy)