@Named public class DefaultUpdateCheckManager extends java.lang.Object implements UpdateCheckManager, Service
Modifier and Type | Field and Description |
---|---|
(package private) static java.lang.String |
CONFIG_PROP_SESSION_STATE |
private static java.lang.String |
ERROR_KEY_SUFFIX |
private static org.slf4j.Logger |
LOGGER |
private static java.lang.String |
NOT_FOUND |
private static java.lang.String |
SESSION_CHECKS |
private static int |
STATE_BYPASS |
private static int |
STATE_DISABLED |
private static int |
STATE_ENABLED |
private static java.lang.String |
UPDATED_KEY_SUFFIX |
private UpdatePolicyAnalyzer |
updatePolicyAnalyzer |
Constructor and Description |
---|
DefaultUpdateCheckManager() |
DefaultUpdateCheckManager(UpdatePolicyAnalyzer updatePolicyAnalyzer) |
Modifier and Type | Method and Description |
---|---|
void |
checkArtifact(RepositorySystemSession session,
UpdateCheck<Artifact,ArtifactTransferException> check)
Checks whether an artifact has to be updated from a remote repository.
|
void |
checkMetadata(RepositorySystemSession session,
UpdateCheck<Metadata,MetadataTransferException> check)
Checks whether metadata has to be updated from a remote repository.
|
private static int |
getCacheFlag(java.lang.String error) |
private java.lang.String |
getDataKey(Artifact artifact,
java.io.File artifactFile,
RemoteRepository repository) |
private java.lang.String |
getDataKey(Metadata metadata,
java.io.File metadataFile,
RemoteRepository repository) |
private java.lang.String |
getError(java.util.Properties props,
java.lang.String key) |
private long |
getLastUpdated(java.util.Properties props,
java.lang.String key) |
private java.lang.String |
getRepoKey(RepositorySystemSession session,
RemoteRepository repository) |
private int |
getSessionState(RepositorySystemSession session) |
private java.io.File |
getTouchFile(Artifact artifact,
java.io.File artifactFile) |
private java.io.File |
getTouchFile(Metadata metadata,
java.io.File metadataFile) |
private java.lang.String |
getTransferKey(RepositorySystemSession session,
Artifact artifact,
java.io.File artifactFile,
RemoteRepository repository) |
private java.lang.String |
getTransferKey(RepositorySystemSession session,
Metadata metadata,
java.io.File metadataFile,
RemoteRepository repository) |
private java.lang.String |
getUpdateKey(RepositorySystemSession session,
java.io.File file,
RemoteRepository repository) |
private boolean |
hasErrors(java.util.Properties props) |
void |
initService(ServiceLocator locator)
Provides the opportunity to initialize this service and to acquire other services for its operation from the
locator.
|
private boolean |
isAlreadyUpdated(RepositorySystemSession session,
java.lang.Object updateKey) |
private boolean |
isUpdatedRequired(RepositorySystemSession session,
long lastModified,
java.lang.String policy) |
private ArtifactTransferException |
newException(java.lang.String error,
Artifact artifact,
RemoteRepository repository) |
private MetadataTransferException |
newException(java.lang.String error,
Metadata metadata,
RemoteRepository repository) |
private java.lang.String |
normalizeRepoUrl(java.lang.String url) |
private java.util.Properties |
read(java.io.File touchFile) |
private void |
setUpdated(RepositorySystemSession session,
java.lang.Object updateKey) |
DefaultUpdateCheckManager |
setUpdatePolicyAnalyzer(UpdatePolicyAnalyzer updatePolicyAnalyzer) |
void |
touchArtifact(RepositorySystemSession session,
UpdateCheck<Artifact,ArtifactTransferException> check)
Updates the timestamp for the artifact contained in the update check.
|
void |
touchMetadata(RepositorySystemSession session,
UpdateCheck<Metadata,MetadataTransferException> check)
Updates the timestamp for the metadata contained in the update check.
|
private java.util.Properties |
write(java.io.File touchFile,
java.lang.String dataKey,
java.lang.String transferKey,
java.lang.Exception error) |
private static final org.slf4j.Logger LOGGER
private UpdatePolicyAnalyzer updatePolicyAnalyzer
private static final java.lang.String UPDATED_KEY_SUFFIX
private static final java.lang.String ERROR_KEY_SUFFIX
private static final java.lang.String NOT_FOUND
private static final java.lang.String SESSION_CHECKS
static final java.lang.String CONFIG_PROP_SESSION_STATE
private static final int STATE_ENABLED
private static final int STATE_BYPASS
private static final int STATE_DISABLED
public DefaultUpdateCheckManager()
@Inject DefaultUpdateCheckManager(UpdatePolicyAnalyzer updatePolicyAnalyzer)
public void initService(ServiceLocator locator)
Service
initService
in interface Service
locator
- The service locator, must not be null
.public DefaultUpdateCheckManager setUpdatePolicyAnalyzer(UpdatePolicyAnalyzer updatePolicyAnalyzer)
public void checkArtifact(RepositorySystemSession session, UpdateCheck<Artifact,ArtifactTransferException> check)
UpdateCheckManager
checkArtifact
in interface UpdateCheckManager
session
- The repository system session during which the request is made, must not be null
.check
- The update check request, must not be null
.private static int getCacheFlag(java.lang.String error)
private ArtifactTransferException newException(java.lang.String error, Artifact artifact, RemoteRepository repository)
public void checkMetadata(RepositorySystemSession session, UpdateCheck<Metadata,MetadataTransferException> check)
UpdateCheckManager
checkMetadata
in interface UpdateCheckManager
session
- The repository system session during which the request is made, must not be null
.check
- The update check request, must not be null
.private MetadataTransferException newException(java.lang.String error, Metadata metadata, RemoteRepository repository)
private long getLastUpdated(java.util.Properties props, java.lang.String key)
private java.lang.String getError(java.util.Properties props, java.lang.String key)
private java.io.File getTouchFile(Artifact artifact, java.io.File artifactFile)
private java.io.File getTouchFile(Metadata metadata, java.io.File metadataFile)
private java.lang.String getDataKey(Artifact artifact, java.io.File artifactFile, RemoteRepository repository)
private java.lang.String getTransferKey(RepositorySystemSession session, Artifact artifact, java.io.File artifactFile, RemoteRepository repository)
private java.lang.String getDataKey(Metadata metadata, java.io.File metadataFile, RemoteRepository repository)
private java.lang.String getTransferKey(RepositorySystemSession session, Metadata metadata, java.io.File metadataFile, RemoteRepository repository)
private java.lang.String getRepoKey(RepositorySystemSession session, RemoteRepository repository)
private java.lang.String normalizeRepoUrl(java.lang.String url)
private java.lang.String getUpdateKey(RepositorySystemSession session, java.io.File file, RemoteRepository repository)
private int getSessionState(RepositorySystemSession session)
private boolean isAlreadyUpdated(RepositorySystemSession session, java.lang.Object updateKey)
private void setUpdated(RepositorySystemSession session, java.lang.Object updateKey)
private boolean isUpdatedRequired(RepositorySystemSession session, long lastModified, java.lang.String policy)
private java.util.Properties read(java.io.File touchFile)
public void touchArtifact(RepositorySystemSession session, UpdateCheck<Artifact,ArtifactTransferException> check)
UpdateCheckManager
touchArtifact
in interface UpdateCheckManager
session
- The repository system session during which the request is made, must not be null
.check
- The update check request, must not be null
.private boolean hasErrors(java.util.Properties props)
public void touchMetadata(RepositorySystemSession session, UpdateCheck<Metadata,MetadataTransferException> check)
UpdateCheckManager
touchMetadata
in interface UpdateCheckManager
session
- The repository system session during which the request is made, must not be null
.check
- The update check request, must not be null
.private java.util.Properties write(java.io.File touchFile, java.lang.String dataKey, java.lang.String transferKey, java.lang.Exception error)