@POST
  @Path("/moveToTrash")
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public Response moveToTrash(MultiRemoveRequest request) {
    try {
      ResponseBuilder result;
      HdfsApi api = getApi();
      String trash = api.getTrashDirPath();
      String message = "";

      if (request.paths.size() == 0) {
        result = Response.ok(new FileOperationResult(false, "No path entries provided.")).status(422);
      } else {
        if (!api.exists(trash)) {
          if (!api.mkdir(trash)) {
            result = Response.ok(new FileOperationResult(false, "Trash dir does not exists. Can't create dir for " +
              "trash '" + trash + "'")).status(422);
            return result.build();
          }
        }

        int index = 0;
        for (MultiRemoveRequest.PathEntry entry : request.paths) {
          String trashFilePath = api.getTrashDirPath(entry.path);
          try {
            if (api.rename(entry.path, trashFilePath)) {
              index ++;
            } else {
              message = "Failed to move '" + entry.path + "' to '" + trashFilePath + "'";
              break;
            }
          } catch (IOException exception) {
            message = exception.getMessage();
            logger.error("Failed to move '{}' to '{}'. Exception: {}", entry.path, trashFilePath,
              exception.getMessage());
            break;
          }
        }
        if (index == request.paths.size()) {
          result = Response.ok(new FileOperationResult(true)).status(200);
        } else {
          FileOperationResult errorResult = getFailureFileOperationResult(getPathsFromPathsEntries(request.paths), index, message);
          result = Response.ok(errorResult).status(422);
        }
      }
      return result.build();
    } catch (Exception ex) {
      throw new ServiceFormattedException(ex.getMessage(), ex);
    }
  }
Move to trash
@param request remove request
@return response with success
contrib/views/commons/src/main/java/org/apache/ambari/view/commons/hdfs/FileOperationService.java