1 package org.eclipse.aether.internal.impl;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.eclipse.aether.RepositorySystemSession;
23 import org.eclipse.aether.artifact.Artifact;
24 import org.eclipse.aether.impl.UpdateCheck;
25 import org.eclipse.aether.impl.UpdateCheckManager;
26 import org.eclipse.aether.metadata.Metadata;
27 import org.eclipse.aether.transfer.ArtifactNotFoundException;
28 import org.eclipse.aether.transfer.ArtifactTransferException;
29 import org.eclipse.aether.transfer.MetadataNotFoundException;
30 import org.eclipse.aether.transfer.MetadataTransferException;
31
32 class StaticUpdateCheckManager
33 implements UpdateCheckManager
34 {
35
36 private boolean checkRequired;
37
38 private boolean localUpToDate;
39
40 public StaticUpdateCheckManager( boolean checkRequired )
41 {
42 this( checkRequired, !checkRequired );
43 }
44
45 public StaticUpdateCheckManager( boolean checkRequired, boolean localUpToDate )
46 {
47 this.checkRequired = checkRequired;
48 this.localUpToDate = localUpToDate;
49 }
50
51 public void touchMetadata( RepositorySystemSession session, UpdateCheck<Metadata, MetadataTransferException> check )
52 {
53 }
54
55 public void touchArtifact( RepositorySystemSession session, UpdateCheck<Artifact, ArtifactTransferException> check )
56 {
57 }
58
59 public void checkMetadata( RepositorySystemSession session, UpdateCheck<Metadata, MetadataTransferException> check )
60 {
61 check.setRequired( checkRequired );
62
63 if ( check.getLocalLastUpdated() != 0L && localUpToDate )
64 {
65 check.setRequired( false );
66 }
67 if ( !check.isRequired() && !check.getFile().isFile() )
68 {
69 check.setException( new MetadataNotFoundException( check.getItem(), check.getRepository() ) );
70 }
71 }
72
73 public void checkArtifact( RepositorySystemSession session, UpdateCheck<Artifact, ArtifactTransferException> check )
74 {
75 check.setRequired( checkRequired );
76
77 if ( check.getLocalLastUpdated() != 0L && localUpToDate )
78 {
79 check.setRequired( false );
80 }
81 if ( !check.isRequired() && !check.getFile().isFile() )
82 {
83 check.setException( new ArtifactNotFoundException( check.getItem(), check.getRepository() ) );
84 }
85 }
86
87 }