Example usage for org.apache.maven.repository ArtifactTransferResource getUrl

List of usage examples for org.apache.maven.repository ArtifactTransferResource getUrl

Introduction

In this page you can find the example usage for org.apache.maven.repository ArtifactTransferResource getUrl.

Prototype

String getUrl();

Source Link

Document

Gets the full URL of the artifact.

Usage

From source file:org.commonjava.emb.boot.log.BatchTransferListener.java

License:Apache License

protected void doCompleted(final ArtifactTransferEvent transferEvent) {
    final ArtifactTransferResource artifact = transferEvent.getResource();
    final long contentLength = transferEvent.getTransferredBytes();
    if (contentLength >= 0) {
        final String type = (transferEvent.getRequestType() == ArtifactTransferEvent.REQUEST_PUT ? "Uploaded"
                : "Downloaded");
        final String len = contentLength >= 1024 ? toKB(contentLength) + " KB" : contentLength + " B";

        String throughput = "";
        final long duration = System.currentTimeMillis() - artifact.getTransferStartTime();
        if (duration > 0) {
            final DecimalFormat format = new DecimalFormat("0.0", new DecimalFormatSymbols(Locale.ENGLISH));
            final double kbPerSec = (contentLength / 1024.0) / (duration / 1000.0);
            throughput = " at " + format.format(kbPerSec) + " KB/sec";
        }//w w  w . j  a  va2s.  co m

        out.println(type + ": " + artifact.getUrl() + " (" + len + throughput + ")");
    }
}