use of org.modeshape.jcr.api.index.IndexDefinition in project kylo by Teradata.
the class DebugController method getIndexes.
@GET
@Path("jcr-index")
@Produces(MediaType.APPLICATION_JSON)
public List<JcrIndexDefinition> getIndexes() {
return metadata.read(() -> {
this.accessController.checkPermission(AccessController.SERVICES, MetadataAccessControl.ACCESS_METADATA);
try {
Session session = JcrMetadataAccess.getActiveSession();
Workspace workspace = (Workspace) session.getWorkspace();
Map<String, IndexDefinition> indexDefinitionMap = workspace.getIndexManager().getIndexDefinitions();
if (indexDefinitionMap != null) {
return indexDefinitionMap.entrySet().stream().map((Map.Entry<String, IndexDefinition> e) -> {
JcrIndexDefinition indexDefinition = new JcrIndexDefinition();
StringBuffer names = new StringBuffer();
StringBuffer types = new StringBuffer();
for (int i = 0; i < e.getValue().size(); i++) {
if (i > 0) {
names.append(",");
types.append(",");
}
int columnType = e.getValue().getColumnDefinition(i).getColumnType();
String propertyName = e.getValue().getColumnDefinition(i).getPropertyName();
names.append(propertyName);
types.append(PropertyType.nameFromValue(columnType));
}
indexDefinition.setIndexKind(e.getValue().getKind().name());
indexDefinition.setIndexName(e.getKey());
indexDefinition.setNodeType(e.getValue().getNodeTypeName());
indexDefinition.setPropertyName(names.toString());
indexDefinition.setPropertyTypes(types.toString());
return indexDefinition;
}).collect(Collectors.toList());
} else {
return Collections.emptyList();
}
} catch (RepositoryException e) {
throw new RuntimeException(e);
}
});
}
Aggregations