@Override
  public void handle(HttpServletRequest request, HttpServletResponse response, HandlerChain chain)
      throws Exception {
    LumifyVisibility lumifyVisibility = new LumifyVisibility();
    final String propertyName = getRequiredParameter(request, "propertyName");
    final String propertyKey = getRequiredParameter(request, "propertyKey");
    final String sourceId = getRequiredParameter(request, "source");
    final String destId = getRequiredParameter(request, "dest");
    final String edgeId = getRequiredParameter(request, "edgeId");

    User user = getUser(request);
    Authorizations authorizations = getAuthorizations(request, user);
    String workspaceId = getActiveWorkspaceId(request);

    OntologyProperty property = ontologyRepository.getProperty(propertyName);
    if (property == null) {
      throw new RuntimeException("Could not find property: " + propertyName);
    }

    // TODO remove all properties from all edges? I don't think so
    Edge edge = graph.getEdge(edgeId, authorizations);
    Object oldValue = null;
    Property oldProperty = edge.getProperty(propertyKey, propertyName);
    if (oldProperty != null) {
      oldValue = oldProperty.getValue();
    }
    // TODO: replace "" when we implement commenting on ui
    auditRepository.auditRelationshipProperty(
        AuditAction.DELETE,
        sourceId,
        destId,
        propertyKey,
        property.getDisplayName(),
        oldValue,
        null,
        edge,
        "",
        "",
        user,
        lumifyVisibility.getVisibility());
    edge.removeProperty(propertyKey, propertyName, authorizations);
    graph.flush();

    List<Property> properties = new ArrayList<Property>();
    for (Property p : edge.getProperties()) {
      properties.add(p);
    }

    workQueueRepository.pushGraphPropertyQueue(edge, null, propertyName);

    JSONArray resultsJson = JsonSerializer.toJsonProperties(properties, workspaceId);
    respondWithJson(response, resultsJson);
  }
Example #2
0
  /** Determines if this is a property that should be analyzed by text processing tools. */
  protected boolean isTextProperty(Property property) {
    if (property == null) {
      return false;
    }

    if (property.getName().equals(LumifyProperties.RAW.getPropertyName())) {
      return false;
    }

    String mimeType =
        (String) property.getMetadata().get(LumifyProperties.MIME_TYPE.getPropertyName());
    return !(mimeType == null || !mimeType.startsWith("text"));
  }
  @Override
  public boolean isHandled(Element element, Property property) {
    if (property == null) {
      return false;
    }

    if (property.getName().equals(LumifyProperties.RAW.getPropertyName())) {
      return false;
    }

    String mimeType =
        (String) property.getMetadata().get(LumifyProperties.MIME_TYPE.getPropertyName());
    return !(mimeType == null || !mimeType.startsWith("text"));
  }