Beispiel #1
0
  private RestQueryResult.RestRow createRestRow(
      Session session,
      QueryResult result,
      RestQueryResult restQueryResult,
      String[] columnNames,
      String baseUrl,
      Row resultRow)
      throws RepositoryException {
    RestQueryResult.RestRow restRow = restQueryResult.new RestRow();
    Map<Value, String> binaryPropertyPaths = null;

    for (String columnName : columnNames) {
      Value value = resultRow.getValue(columnName);
      if (value == null) {
        continue;
      }
      String propertyPath = null;
      // because we generate links for binary properties, we need the path of the property which has
      // the value
      if (value.getType() == PropertyType.BINARY) {
        if (binaryPropertyPaths == null) {
          binaryPropertyPaths = binaryPropertyPaths(resultRow, result.getSelectorNames());
        }
        propertyPath = binaryPropertyPaths.get(value);
      }

      String valueString = valueToString(propertyPath, value, baseUrl, session);
      restRow.addValue(columnName, valueString);
    }
    return restRow;
  }
Beispiel #2
0
 private void createLinksFromNodePaths(
     QueryResult result, String baseUrl, Row resultRow, RestQueryResult.RestRow restRow)
     throws RepositoryException {
   String defaultPath = resultRow.getPath();
   if (!StringUtil.isBlank(defaultPath)) {
     restRow.addValue(
         MODE_URI, RestHelper.urlFrom(baseUrl, RestHelper.ITEMS_METHOD_NAME, defaultPath));
   }
   for (String selectorName : result.getSelectorNames()) {
     try {
       String selectorPath = resultRow.getPath(selectorName);
       if (!StringUtil.isBlank(defaultPath) && !selectorPath.equals(defaultPath)) {
         restRow.addValue(
             MODE_URI + "-" + selectorName,
             RestHelper.urlFrom(baseUrl, RestHelper.ITEMS_METHOD_NAME, selectorPath));
       }
     } catch (RepositoryException e) {
       logger.debug(e, e.getMessage());
     }
   }
 }