@Test public void resolveRankingOakIndex() { assertEquals("damAssetLucene-2-custom-1", OakIndexResolver.resolveRankingOakIndex(ctx.resourceResolver(),"damAssetLucene")); }
public static final String resolveRankingOakIndex(final ResourceResolver resourceResolver, final String oakIndexRootName) { final Resource oakIndexes = resourceResolver.getResource(PATH_OAK_INDEX); final Map<Version, String> map = new TreeMap<>(Collections.reverseOrder()); StreamSupport.stream(oakIndexes.getChildren().spliterator(), false) .filter(oakIndex -> VALUE_TYPE_LUCENE.equals(oakIndex.getValueMap().get(PN_TYPE, String.class))) .forEach(oakIndex -> { final Version version = getOakIndexVersion(oakIndexRootName, oakIndex.getName()); if (version != null) { log.debug("Resolved Oak Index [ {} ] -> [ {} ]", oakIndex.getPath(), version.toString()); map.put(version, oakIndex.getName()); } else { log.warn("Unable to parse version for Oak Index [ {} ]", oakIndex.getPath()); } } ); if (map.isEmpty()) { log.warn("Unable to collect any versions for the provided Oak Index Root Name [ {} ]. This probably means there is a type-o in this parameter.", oakIndexRootName); return null; } else { return map.entrySet().iterator().next().getValue(); } }
OakIndexResolver { public static final String resolveRankingOakIndex(final ResourceResolver resourceResolver, final String oakIndexRootName) { final Resource oakIndexes = resourceResolver.getResource(PATH_OAK_INDEX); final Map<Version, String> map = new TreeMap<>(Collections.reverseOrder()); StreamSupport.stream(oakIndexes.getChildren().spliterator(), false) .filter(oakIndex -> VALUE_TYPE_LUCENE.equals(oakIndex.getValueMap().get(PN_TYPE, String.class))) .forEach(oakIndex -> { final Version version = getOakIndexVersion(oakIndexRootName, oakIndex.getName()); if (version != null) { log.debug("Resolved Oak Index [ {} ] -> [ {} ]", oakIndex.getPath(), version.toString()); map.put(version, oakIndex.getName()); } else { log.warn("Unable to parse version for Oak Index [ {} ]", oakIndex.getPath()); } } ); if (map.isEmpty()) { log.warn("Unable to collect any versions for the provided Oak Index Root Name [ {} ]. This probably means there is a type-o in this parameter.", oakIndexRootName); return null; } else { return map.entrySet().iterator().next().getValue(); } } }
OakIndexResolver { public static final String resolveRankingOakIndex(final ResourceResolver resourceResolver, final String oakIndexRootName) { final Resource oakIndexes = resourceResolver.getResource(PATH_OAK_INDEX); final Map<Version, String> map = new TreeMap<>(Collections.reverseOrder()); StreamSupport.stream(oakIndexes.getChildren().spliterator(), false) .filter(oakIndex -> VALUE_TYPE_LUCENE.equals(oakIndex.getValueMap().get(PN_TYPE, String.class))) .forEach(oakIndex -> { final Version version = getOakIndexVersion(oakIndexRootName, oakIndex.getName()); if (version != null) { log.debug("Resolved Oak Index [ {} ] -> [ {} ]", oakIndex.getPath(), version.toString()); map.put(version, oakIndex.getName()); } else { log.warn("Unable to parse version for Oak Index [ {} ]", oakIndex.getPath()); } } ); if (map.isEmpty()) { log.warn("Unable to collect any versions for the provided Oak Index Root Name [ {} ]. This probably means there is a type-o in this parameter.", oakIndexRootName); return null; } else { return map.entrySet().iterator().next().getValue(); } } private  OakIndexResolver(); }
OakIndexResolver { public static final String resolveRankingOakIndex(final ResourceResolver resourceResolver, final String oakIndexRootName) { final Resource oakIndexes = resourceResolver.getResource(PATH_OAK_INDEX); final Map<Version, String> map = new TreeMap<>(Collections.reverseOrder()); StreamSupport.stream(oakIndexes.getChildren().spliterator(), false) .filter(oakIndex -> VALUE_TYPE_LUCENE.equals(oakIndex.getValueMap().get(PN_TYPE, String.class))) .forEach(oakIndex -> { final Version version = getOakIndexVersion(oakIndexRootName, oakIndex.getName()); if (version != null) { log.debug("Resolved Oak Index [ {} ] -> [ {} ]", oakIndex.getPath(), version.toString()); map.put(version, oakIndex.getName()); } else { log.warn("Unable to parse version for Oak Index [ {} ]", oakIndex.getPath()); } } ); if (map.isEmpty()) { log.warn("Unable to collect any versions for the provided Oak Index Root Name [ {} ]. This probably means there is a type-o in this parameter.", oakIndexRootName); return null; } else { return map.entrySet().iterator().next().getValue(); } } private  OakIndexResolver(); static final String resolveRankingOakIndex(final ResourceResolver resourceResolver, final String oakIndexRootName); }
OakIndexResolver { public static final String resolveRankingOakIndex(final ResourceResolver resourceResolver, final String oakIndexRootName) { final Resource oakIndexes = resourceResolver.getResource(PATH_OAK_INDEX); final Map<Version, String> map = new TreeMap<>(Collections.reverseOrder()); StreamSupport.stream(oakIndexes.getChildren().spliterator(), false) .filter(oakIndex -> VALUE_TYPE_LUCENE.equals(oakIndex.getValueMap().get(PN_TYPE, String.class))) .forEach(oakIndex -> { final Version version = getOakIndexVersion(oakIndexRootName, oakIndex.getName()); if (version != null) { log.debug("Resolved Oak Index [ {} ] -> [ {} ]", oakIndex.getPath(), version.toString()); map.put(version, oakIndex.getName()); } else { log.warn("Unable to parse version for Oak Index [ {} ]", oakIndex.getPath()); } } ); if (map.isEmpty()) { log.warn("Unable to collect any versions for the provided Oak Index Root Name [ {} ]. This probably means there is a type-o in this parameter.", oakIndexRootName); return null; } else { return map.entrySet().iterator().next().getValue(); } } private  OakIndexResolver(); static final String resolveRankingOakIndex(final ResourceResolver resourceResolver, final String oakIndexRootName);  }