use of org.apache.lucene.index.TermEnum in project jackrabbit by apache.
the class ChainedTermEnumTest method testEnum.
public void testEnum() throws Exception {
Collection<TermEnum> enums = new ArrayList<TermEnum>();
enums.add(createTermEnum("a", 2));
enums.add(createTermEnum("b", 1));
enums.add(createTermEnum("c", 0));
enums.add(createTermEnum("d", 2));
TermEnum terms = new IndexMigration.ChainedTermEnum(enums);
List<String> expected = new ArrayList<String>();
expected.addAll(Arrays.asList("a0", "a1", "b0", "d0", "d1"));
List<String> result = new ArrayList<String>();
do {
Term t = terms.term();
if (t != null) {
result.add(t.text());
}
} while (terms.next());
assertEquals(expected, result);
}
use of org.apache.lucene.index.TermEnum in project jackrabbit-oak by apache.
the class RepositoryUpgrade method assertNoLongNames.
void assertNoLongNames() throws RepositoryException {
Session session = source.getRepository().login(null, null);
boolean longNameFound = false;
try {
IndexReader reader = IndexAccessor.getReader(source);
if (reader == null) {
return;
}
TermEnum terms = reader.terms(new Term(FieldNames.LOCAL_NAME));
while (terms.next()) {
Term t = terms.term();
if (!FieldNames.LOCAL_NAME.equals(t.field())) {
continue;
}
String name = t.text();
if (NameFilteringNodeState.isNameTooLong(name)) {
TermDocs docs = reader.termDocs(t);
if (docs.next()) {
int docId = docs.doc();
String uuid = reader.document(docId).get(FieldNames.UUID);
Node n = session.getNodeByIdentifier(uuid);
logger.warn("Name too long: {}", n.getPath());
longNameFound = true;
}
}
}
} catch (IOException e) {
throw new RepositoryException(e);
} finally {
session.logout();
}
if (longNameFound) {
logger.error("Node with a long name has been found. Please fix the content or rerun the migration with {} option.", SKIP_NAME_CHECK);
throw new RepositoryException("Node with a long name has been found.");
}
}
Aggregations