public static boolean rename()

in src/main/java/com/microsoft/azure/datalake/store/Core.java [361:410]


    public static boolean rename(String path,
                                 String destination,
                                 boolean overwrite,
                                 ADLStoreClient client,
                                 RequestOptions opts,
                                 OperationResponse resp) {

        if (destination == null || destination.equals(""))
            throw new IllegalArgumentException("destination cannot be null or empty");

        // prepend the prefix, if applicable, to the destination path
        String prefix = client.getFilePathPrefix();
        if (prefix!=null) {
            if (destination.charAt(0) == '/') {
                destination = prefix + destination;
            } else {
                destination = prefix + "/" + destination;
            }
        }

        QueryParams qp = new QueryParams();
        qp.add("destination", destination);

        if (overwrite) qp.add("renameoptions", "OVERWRITE");

        HttpTransport.makeCall(client, Operation.RENAME, path, qp, null, 0, 0, opts, resp);
        if (!resp.successful) return false;

        boolean returnValue = true;
        try {
            JsonFactory jf = new JsonFactory();
            JsonParser jp = jf.createParser(resp.responseStream);
            jp.nextToken();  // START_OBJECT - {
            jp.nextToken();  // FIELD_NAME - "boolean":
            jp.nextToken();  // boolean value
            returnValue = jp.getValueAsBoolean();
            jp.nextToken(); //  END_OBJECT - }  for boolean
            jp.close();
        } catch (IOException ex) {
            resp.successful = false;
            resp.message = "Unexpected error happened reading response stream or parsing JSon from rename()";
        } finally {
            try {
                resp.responseStream.close();
            } catch (IOException ex) {
                //swallow since it is only the closing of the stream
            }
        }
        return returnValue;
    }