private NodeRef findOrCreateTree(final String treePath, final FeatureType type) {

    RevTree tree =
        context
            .command(FindOrCreateSubtree.class)
            .setChildPath(treePath)
            .setIndex(true)
            .setParent(workHead)
            .setParentPath(NodeRef.ROOT)
            .call();

    ObjectId metadataId = ObjectId.NULL;
    if (type != null) {
      RevFeatureType revFeatureType = RevFeatureTypeImpl.build(type);
      if (tree.isEmpty()) {
        indexDatabase.put(revFeatureType);
      }
      metadataId = revFeatureType.getId();
    }
    Envelope bounds = SpatialOps.boundsOf(tree);
    Node node =
        Node.create(NodeRef.nodeFromPath(treePath), tree.getId(), metadataId, TYPE.TREE, bounds);

    String parentPath = NodeRef.parentPath(treePath);
    return new NodeRef(node, parentPath, ObjectId.NULL);
  }
Example #2
0
  /**
   * Runs the command and builds the appropriate response
   *
   * @param context - the context to use for this command
   * @throws CommandSpecException
   */
  @Override
  public void run(CommandContext context) {
    if (oldRefSpec == null || oldRefSpec.trim().isEmpty()) {
      throw new CommandSpecException("No old ref spec");
    }

    final Context geogig = this.getCommandLocator(context);

    final Iterator<DiffEntry> diff =
        geogig
            .command(DiffOp.class)
            .setOldVersion(oldRefSpec)
            .setNewVersion(newRefSpec)
            .setFilter(pathFilter)
            .call();

    context.setResponseContent(
        new CommandResponse() {
          @Override
          public void write(ResponseWriter out) throws Exception {
            out.start();
            if (showGeometryChanges) {
              out.writeGeometryChanges(geogig, diff, page, elementsPerPage);
            } else {
              out.writeDiffEntries("diff", page * elementsPerPage, elementsPerPage, diff);
            }
            out.finish();
          }
        });
  }