use of org.platformlayer.cas.CasStoreMap in project platformlayer by platformlayer.
the class DownloadFileByHash method getResolved.
public Md5Hash getResolved(OpsTarget target) throws OpsException {
if (resolved == null) {
if (hash == null) {
if (specifier != null) {
CasStoreMap casStores = cas.getCasStoreMap(target);
resolved = (Md5Hash) casStores.resolve(specifier);
}
} else {
resolved = hash;
}
}
if (resolved == null) {
throw new OpsException("Unable to resolve artifact: " + getHumanName());
}
return resolved;
}
use of org.platformlayer.cas.CasStoreMap in project platformlayer by platformlayer.
the class DownloadFileByHash method uploadFile.
@Override
protected void uploadFile(OpsTarget target, File remoteFilePath) throws IOException, OpsException {
target.mkdir(remoteFilePath.getParentFile());
Md5Hash resolved = getResolved(target);
CasStoreObject casObject;
CasStoreMap casStoreMap = cas.getCasStoreMap(target);
try {
casObject = casStoreMap.findArtifact(new OpsCasTarget(target), resolved);
} catch (Exception e) {
throw new OpsException("Error while resolving artifact:" + getHumanName(), e);
}
if (url != null && casObject == null) {
target.mkdir(remoteFilePath.getParentFile());
CurlRequest curlRequest = new CurlRequest(url);
curlRequest.bareRequest = true;
CommandEnvironment commandEnvironment = httpProxies.getHttpProxyEnvironment(target, Usage.General, url);
Command curlCommand = curlRequest.toCommand();
curlCommand.addLiteral(">");
curlCommand.addFile(remoteFilePath);
curlCommand.setEnvironment(commandEnvironment);
curlCommand.setTimeout(TimeSpan.FIVE_MINUTES);
// TODO: Can we cache into CAS instead??
log.info("Not found in CAS system; downloading directly: " + url);
target.executeCommand(curlCommand);
} else {
if (casObject == null) {
throw new OpsException("Unable to find artifact: " + getHumanName());
}
log.info("Doing a CAS copy from " + casObject + " to target");
cas.copyObject(casStoreMap, casObject, new OpsCasTarget(target), remoteFilePath, true);
}
}
use of org.platformlayer.cas.CasStoreMap in project platformlayer by platformlayer.
the class CasStoreHelper method getCasStoreMap.
public CasStoreMap getCasStoreMap(OpsTarget target) throws OpsException {
// TODO: Reintroduce (some) caching?
// if (this.casStores == null) {
CasStoreMap casStores = new CasStoreMap();
FilesystemCasStore filesystemCasStore = new FilesystemCasStore(new CasStoreInfo(false), new OpsCasTarget(target));
casStores.addPrimary(filesystemCasStore);
// TODO: Don't hard-code
casStores.addSecondary(buildJenkins("http://192.168.131.14:8080/"));
for (ProviderOf<CasStoreProvider> casStoreProvider : providers.listItemsProviding(CasStoreProvider.class)) {
CasStore casStore = casStoreProvider.get().getCasStore();
casStores.addSecondary(casStore);
if (casStore.getOptions().isStaging()) {
// Use this as a staging store i.e. we can upload files to here instead of to the VM
casStores.addStagingStore(casStore);
}
}
// }
return casStores;
}
Aggregations