@POST
  @Path("/copy")
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public Response copy(final MultiSrcDstFileRequest request,
                       @Context HttpHeaders headers, @Context UriInfo ui) {
    try {
      HdfsApi api = getApi();
      ResponseBuilder result;
      String message = "";

      List<String> sources = request.sourcePaths;
      String destination = request.destinationPath;
      if(sources.isEmpty()) {
        result = Response.ok(new FileOperationResult(false, "Can't copy 0 file/folder to '" + destination + "'")).
          status(422);
        return result.build();
      }

      int index = 0;
      for (String src : sources) {
        String fileName = getFileName(src);
        String finalDestination = getDestination(destination, fileName);
        try {
          api.copy(src, finalDestination);
          index ++;
        } catch (IOException|HdfsApiException exception) {
          message = exception.getMessage();
          logger.error("Failed to copy '{}' to '{}'. Exception: {}", src, finalDestination,
            exception.getMessage());
          break;
        }
      }
      if (index == sources.size()) {
        result = Response.ok(new FileOperationResult(true)).status(200);
      } else {
        FileOperationResult errorResult = getFailureFileOperationResult(sources, index, message);
        result = Response.ok(errorResult).status(422);
      }
      return result.build();
    } catch (Exception ex) {
      throw new ServiceFormattedException(ex.getMessage(), ex);
    }
  }
Copy file
@param request source and destination request
@return response with success
contrib/views/commons/src/main/java/org/apache/ambari/view/commons/hdfs/FileOperationService.java