Source:
public Answer handleDownloadTemplateToPrimaryStorage(DirectDownloadCommand cmd) { final PrimaryDataStoreTO pool = cmd.getDestPool(); if (!pool.getPoolType().equals(StoragePoolType.NetworkFilesystem)) { return new DirectDownloadAnswer(false, "Unsopported pool type " + pool.getPoolType().toString()); } KVMStoragePool destPool = storagePoolMgr.getStoragePool(pool.getPoolType(), pool.getUuid()); DirectTemplateDownloader downloader; if (cmd instanceof HttpDirectDownloadCommand) { downloader = new HttpDirectTemplateDownloader(cmd.getUrl(), cmd.getTemplateId(), destPool.getLocalPath(), cmd.getChecksum(), ((HttpDirectDownloadCommand) cmd).getHeaders()); } else if (cmd instanceof NfsDirectDownloadCommand) { downloader = new NfsDirectTemplateDownloader(cmd.getUrl(), destPool.getLocalPath(), cmd.getTemplateId(), cmd.getChecksum()); } else if (cmd instanceof MetalinkDirectDownloadCommand) { downloader = new MetalinkDirectTemplateDownloader(cmd.getUrl(), destPool.getLocalPath(), cmd.getTemplateId(), cmd.getChecksum()); } else { return new DirectDownloadAnswer(false, "Unsopported protocol, please provide HTTP(S), NFS or a metalink"); } if (!downloader.downloadTemplate()) { return new DirectDownloadAnswer(false, "Could not download template " + cmd.getTemplateId() + " on " + destPool.getLocalPath()); } if (!downloader.validateChecksum()) { return new DirectDownloadAnswer(false, "Checksum validation failed for template " + cmd.getTemplateId()); } if (!downloader.extractAndInstallDownloadedTemplate()) { return new DirectDownloadAnswer(false, "Template downloaded but there was an error on installation"); } DirectTemplateInformation info = downloader.getTemplateInformation(); return new DirectDownloadAnswer(true, info.getSize(), info.getInstallPath()); }

Target:
public Answer handleDownloadTemplateToPrimaryStorage(DirectDownloadCommand cmd) { final PrimaryDataStoreTO pool = cmd.getDestPool(); if (!pool.getPoolType().equals(StoragePoolType.NetworkFilesystem)) { return new DirectDownloadAnswer(false, "Unsupported pool type " + pool.getPoolType().toString()); } KVMStoragePool destPool = storagePoolMgr.getStoragePool(pool.getPoolType(), pool.getUuid()); DirectTemplateDownloader downloader; if (cmd instanceof HttpDirectDownloadCommand) { downloader = new HttpDirectTemplateDownloader(cmd.getUrl(), cmd.getTemplateId(), destPool.getLocalPath(), cmd.getChecksum(), ((HttpDirectDownloadCommand) cmd).getHeaders()); } else if (cmd instanceof HttpsDirectDownloadCommand) { downloader = new HttpsDirectTemplateDownloader(cmd.getUrl(), cmd.getTemplateId(), destPool.getLocalPath(), cmd.getChecksum()); } else if (cmd instanceof NfsDirectDownloadCommand) { downloader = new NfsDirectTemplateDownloader(cmd.getUrl(), destPool.getLocalPath(), cmd.getTemplateId(), cmd.getChecksum()); } else if (cmd instanceof MetalinkDirectDownloadCommand) { downloader = new MetalinkDirectTemplateDownloader(cmd.getUrl(), destPool.getLocalPath(), cmd.getTemplateId(), cmd.getChecksum()); } else { return new DirectDownloadAnswer(false, "Unsupported protocol, please provide HTTP(S), NFS or a metalink"); } if (!downloader.downloadTemplate()) { return new DirectDownloadAnswer(false, "Could not download template " + cmd.getTemplateId() + " on " + destPool.getLocalPath()); } if (!downloader.validateChecksum()) { return new DirectDownloadAnswer(false, "Checksum validation failed for template " + cmd.getTemplateId()); } if (!downloader.extractAndInstallDownloadedTemplate()) { return new DirectDownloadAnswer(false, "Template downloaded but there was an error on installation"); } DirectTemplateInformation info = downloader.getTemplateInformation(); return new DirectDownloadAnswer(true, info.getSize(), info.getInstallPath()); }