01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.ivy.core.event.download;
19:
20: import java.io.File;
21:
22: import org.apache.ivy.core.cache.ArtifactOrigin;
23: import org.apache.ivy.core.module.descriptor.Artifact;
24: import org.apache.ivy.core.report.ArtifactDownloadReport;
25: import org.apache.ivy.plugins.resolver.DependencyResolver;
26:
27: public class EndArtifactDownloadEvent extends DownloadEvent {
28: public static final String NAME = "post-download-artifact";
29:
30: private DependencyResolver resolver;
31:
32: private ArtifactDownloadReport report;
33:
34: public EndArtifactDownloadEvent(DependencyResolver resolver,
35: Artifact artifact, ArtifactDownloadReport report, File dest) {
36: super (NAME, artifact);
37: this .resolver = resolver;
38: this .report = report;
39: addAttribute("resolver", this .resolver.getName());
40: addAttribute("status", this .report.getDownloadStatus()
41: .toString());
42: addAttribute("details", this .report.getDownloadDetails());
43: addAttribute("size", String.valueOf(this .report.getSize()));
44: addAttribute("file", dest.getAbsolutePath());
45: addAttribute("duration", String.valueOf(this .report
46: .getDownloadTimeMillis()));
47: ArtifactOrigin origin = report.getArtifactOrigin();
48: if (origin != null && origin != ArtifactOrigin.UNKNOWN) {
49: addAttribute("origin", origin.getLocation());
50: addAttribute("local", String.valueOf(origin.isLocal()));
51: } else {
52: addAttribute("origin", "");
53: addAttribute("local", "");
54: }
55: }
56:
57: public ArtifactDownloadReport getReport() {
58: return report;
59: }
60:
61: public DependencyResolver getResolver() {
62: return resolver;
63: }
64:
65: }
|