final String multiValueKey = getRequiredParameter(request, "multiValueKey");
String workspaceId = getActiveWorkspaceId(request);
User user = getUser(request);
Authorizations authorizations = getAuthorizations(request, user);
Vertex artifactVertex = graph.getVertex(vertexId, authorizations);
ArtifactDetectedObject artifactDetectedObject = LumifyProperties.DETECTED_OBJECT.getPropertyValue(artifactVertex, multiValueKey);
Edge edge = graph.getEdge(artifactDetectedObject.getEdgeId(), authorizations);
Vertex resolvedVertex = edge.getOtherVertex(artifactVertex.getId(), authorizations);
SandboxStatus vertexSandboxStatus = GraphUtil.getSandboxStatus(resolvedVertex, workspaceId);
SandboxStatus edgeSandboxStatus = GraphUtil.getSandboxStatus(edge, workspaceId);
if (vertexSandboxStatus == SandboxStatus.PUBLIC && edgeSandboxStatus == SandboxStatus.PUBLIC) {
LOGGER.warn("Can not unresolve a public entity");
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
chain.next(request, response);
return;
}
VisibilityJson visibilityJson;
if (vertexSandboxStatus == SandboxStatus.PUBLIC) {
visibilityJson = LumifyProperties.VISIBILITY_JSON.getPropertyValue(edge);
visibilityJson = GraphUtil.updateVisibilityJsonRemoveFromWorkspace(visibilityJson, workspaceId);
} else {
visibilityJson = LumifyProperties.VISIBILITY_JSON.getPropertyValue(resolvedVertex);
visibilityJson = GraphUtil.updateVisibilityJsonRemoveFromWorkspace(visibilityJson, workspaceId);
}
LumifyVisibility lumifyVisibility = visibilityTranslator.toVisibility(visibilityJson);
// remove edge
graph.removeEdge(edge, authorizations);
auditRepository.auditRelationship(AuditAction.DELETE, artifactVertex, resolvedVertex, edge, "", "", user, lumifyVisibility.getVisibility());
// remove property
LumifyProperties.DETECTED_OBJECT.removeProperty(artifactVertex, multiValueKey, authorizations);
graph.flush();
this.workQueueRepository.pushEdgeDeletion(edge);
this.workQueueRepository.pushGraphPropertyQueue(artifactVertex, multiValueKey,
LumifyProperties.DETECTED_OBJECT.getPropertyName(), workspaceId, visibilityJson.getSource());
auditRepository.auditVertex(AuditAction.UNRESOLVE, resolvedVertex.getId(), "", "", user, lumifyVisibility.getVisibility());
ClientApiElement result = ClientApiConverter.toClientApi(artifactVertex, workspaceId, authorizations);
respondWithClientApiObject(response, result);
}