modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java | 38 ++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerLocal.java | 31 +---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/DistributionSourceSynchronizer.java | 37 ++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/PackageSourceSynchronizer.java | 73 ++++------
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/ContentTestHelper.java | 37 +++++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/ContentSourceManagerBeanTest.java | 12 +
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java | 12 -
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java | 10 -
8 files changed, 124 insertions(+), 126 deletions(-)
New commits:
commit 821577efc8012111e1b9d3c7ba89fe15883e6c87
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Mon Nov 30 15:55:03 2009 -0800
1103 - fixing NPE when syncing content. still broken thou
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java
index 450a905..c7fd5a5 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java
@@ -59,8 +59,8 @@ import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.content.Architecture;
import org.rhq.core.domain.content.ContentSource;
import org.rhq.core.domain.content.ContentSourceSyncResults;
-import org.rhq.core.domain.content.ContentSyncStatus;
import org.rhq.core.domain.content.ContentSourceType;
+import org.rhq.core.domain.content.ContentSyncStatus;
import org.rhq.core.domain.content.Distribution;
import org.rhq.core.domain.content.DistributionFile;
import org.rhq.core.domain.content.DistributionType;
@@ -942,13 +942,13 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
//////////////////
// REMOVE
- syncResults = contentSourceManager._mergeDistributionSyncReportREMOVE(contentSource,
- report, syncResults, progress);
+ syncResults = contentSourceManager._mergeDistributionSyncReportREMOVE(contentSource, report, syncResults,
+ progress);
//////////////////
// ADD
- syncResults = contentSourceManager._mergeDistributionSyncReportADD(contentSource, report,
- syncResults, progress);
+ syncResults = contentSourceManager._mergeDistributionSyncReportADD(contentSource, report, syncResults,
+ progress);
// if we added/updated/deleted anything, change the last modified time of all repos
// that get content from this content source
@@ -965,7 +965,7 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
// ThrowableUtil will dump SQL nextException messages, too
String errorMsg = "Could not process sync report from [" + contentSource + "]. Cause: "
+ ThrowableUtil.getAllMessages(t);
- log.error(errorMsg);
+ log.error(errorMsg, t);
throw new RuntimeException(errorMsg, t);
}
@@ -975,8 +975,7 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
// we really want NEVER, but support tests that might be in a tx
public ContentSourceSyncResults mergePackageSyncReport(ContentSource contentSource, Repo repo,
- PackageSyncReport report,
- Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous,
+ PackageSyncReport report, Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous,
ContentSourceSyncResults syncResults) {
try {
StringBuilder progress = new StringBuilder();
@@ -994,8 +993,8 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
//////////////////
// REMOVE
- syncResults = contentSourceManager._mergePackageSyncReportREMOVE(contentSource, repo,
- report, previous, syncResults, progress);
+ syncResults = contentSourceManager._mergePackageSyncReportREMOVE(contentSource, repo, report, previous,
+ syncResults, progress);
//////////////////
// ADD
@@ -1018,8 +1017,8 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
}
List<ContentProviderPackageDetails> pkgs = newPackages.subList(fromIndex, toIndex);
- syncResults = contentSourceManager._mergePackageSyncReportADD(contentSource, repo,
- pkgs, previous, syncResults, progress, fromIndex);
+ syncResults = contentSourceManager._mergePackageSyncReportADD(contentSource, repo, pkgs, previous,
+ syncResults, progress, fromIndex);
addedCount += pkgs.size();
fromIndex += chunkSize;
toIndex += chunkSize;
@@ -1050,7 +1049,7 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
// ThrowableUtil will dump SQL nextException messages, too
String errorMsg = "Could not process sync report from [" + contentSource + "]. Cause: "
+ ThrowableUtil.getAllMessages(t);
- log.error(errorMsg);
+ log.error(errorMsg, t);
throw new RuntimeException(errorMsg, t);
}
@@ -1073,12 +1072,9 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
}
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
- public ContentSourceSyncResults _mergePackageSyncReportREMOVE(ContentSource contentSource,
- Repo repo,
- PackageSyncReport report,
- Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous,
- ContentSourceSyncResults syncResults,
- StringBuilder progress) {
+ public ContentSourceSyncResults _mergePackageSyncReportREMOVE(ContentSource contentSource, Repo repo,
+ PackageSyncReport report, Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous,
+ ContentSourceSyncResults syncResults, StringBuilder progress) {
progress.append(new Date()).append(": ").append("Removing");
syncResults.setResults(progress.toString());
@@ -1138,8 +1134,7 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
@SuppressWarnings("unchecked")
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
- public ContentSourceSyncResults _mergePackageSyncReportADD(ContentSource contentSource,
- Repo repo,
+ public ContentSourceSyncResults _mergePackageSyncReportADD(ContentSource contentSource, Repo repo,
Collection<ContentProviderPackageDetails> newPackages,
Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous,
ContentSourceSyncResults syncResults, StringBuilder progress, int addCount) {
@@ -1327,7 +1322,6 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
RepoPackageVersion mapping = new RepoPackageVersion(repo, pv);
entityManager.merge(mapping); // use merge just in case this mapping somehow already exists
-
// Cleanup
if ((++flushCount % 100) == 0) {
knownResourceTypes.clear();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerLocal.java
index 850cd6d..9dfa9a1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerLocal.java
@@ -41,9 +41,9 @@ import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.plugin.pc.content.ContentProviderPackageDetails;
import org.rhq.enterprise.server.plugin.pc.content.ContentProviderPackageDetailsKey;
+import org.rhq.enterprise.server.plugin.pc.content.DistributionSyncReport;
import org.rhq.enterprise.server.plugin.pc.content.PackageSyncReport;
import org.rhq.enterprise.server.plugin.pc.content.RepoDetails;
-import org.rhq.enterprise.server.plugin.pc.content.DistributionSyncReport;
/**
* Interface that provides access to the {@link ContentSource} objects deployed in the server, allowing the callers to
@@ -245,7 +245,7 @@ public interface ContentSourceManagerLocal {
* contains the location where those package versions are located in the content source
*/
List<PackageVersionContentSource> getPackageVersionsFromContentSourceForRepo(Subject subject, int contentSourceId,
- int repoId);
+ int repoId);
/**
* Returns count of PackageVersions associated with the given content source.
@@ -284,8 +284,6 @@ public interface ContentSourceManagerLocal {
PageList<PackageVersionContentSource> getPackageVersionsFromContentSources(Subject subject, int[] contentSourceIds,
PageControl pc);
-
-
/**
* Returns all the package versions that are served by the content source identified by the given ID but whose
* {@link PackageVersion#getPackageBits() package bits} have not been loaded yet.
@@ -300,8 +298,6 @@ public interface ContentSourceManagerLocal {
PageList<PackageVersionContentSource> getUnloadedPackageVersionsFromContentSourceInRepo(Subject subject,
int contentSourceId, int repoId, PageControl pc);
-
-
/**
* This will download all the distribution bits associated with a specific content source.
*
@@ -310,7 +306,6 @@ public interface ContentSourceManagerLocal {
*/
void downloadDistributionBits(Subject subject, ContentSource contentSource);
-
/**
* Given a {@link PackageVersionContentSource} which contains the ID of a content source, an ID of a package
* version, and the location of that package version on the remote content source repo, this will download the
@@ -401,9 +396,7 @@ public interface ContentSourceManagerLocal {
* @return the updated syncResults that includes more summary information in the results string that indicates what
* was done
*/
- ContentSourceSyncResults mergePackageSyncReport(ContentSource contentSource,
- Repo repo,
- PackageSyncReport report,
+ ContentSourceSyncResults mergePackageSyncReport(ContentSource contentSource, Repo repo, PackageSyncReport report,
Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous,
ContentSourceSyncResults syncResults);
@@ -417,19 +410,17 @@ public interface ContentSourceManagerLocal {
* @return the updated syncResults that includes more summary information in the results string that indicates what
* was done
*/
- ContentSourceSyncResults mergeDistributionSyncReport(ContentSource contentSource,
- DistributionSyncReport report,
- ContentSourceSyncResults syncResults);
+ ContentSourceSyncResults mergeDistributionSyncReport(ContentSource contentSource, DistributionSyncReport report,
+ ContentSourceSyncResults syncResults);
void _mergePackageSyncReportUpdateRepo(int contentSourceId);
- ContentSourceSyncResults _mergePackageSyncReportREMOVE(ContentSource contentSource,
- Repo repo, PackageSyncReport report,
- Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous,
+ ContentSourceSyncResults _mergePackageSyncReportREMOVE(ContentSource contentSource, Repo repo,
+ PackageSyncReport report, Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous,
ContentSourceSyncResults syncResults, StringBuilder progress);
- ContentSourceSyncResults _mergePackageSyncReportADD(ContentSource contentSource,
- Repo repo, Collection<ContentProviderPackageDetails> newPackages,
+ ContentSourceSyncResults _mergePackageSyncReportADD(ContentSource contentSource, Repo repo,
+ Collection<ContentProviderPackageDetails> newPackages,
Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous,
ContentSourceSyncResults syncResults, StringBuilder progress, int addCount);
@@ -437,8 +428,8 @@ public interface ContentSourceManagerLocal {
Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous,
ContentSourceSyncResults syncResults, StringBuilder progress);
- ContentSourceSyncResults _mergeDistributionSyncReportREMOVE(ContentSource contentSource, DistributionSyncReport report,
- ContentSourceSyncResults syncResults, StringBuilder progress);
+ ContentSourceSyncResults _mergeDistributionSyncReportREMOVE(ContentSource contentSource,
+ DistributionSyncReport report, ContentSourceSyncResults syncResults, StringBuilder progress);
ContentSourceSyncResults _mergeDistributionSyncReportADD(ContentSource contentSource,
DistributionSyncReport report, ContentSourceSyncResults syncResults, StringBuilder progress);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/DistributionSourceSynchronizer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/DistributionSourceSynchronizer.java
index 062390e..2171bbf 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/DistributionSourceSynchronizer.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/DistributionSourceSynchronizer.java
@@ -30,6 +30,7 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.content.ContentSource;
+import org.rhq.core.domain.content.ContentSourceSyncResults;
import org.rhq.core.domain.content.Distribution;
import org.rhq.core.domain.content.DistributionFile;
import org.rhq.core.domain.content.Repo;
@@ -63,8 +64,7 @@ public class DistributionSourceSynchronizer {
private ContentSource source;
private ContentProvider provider;
- public DistributionSourceSynchronizer(Repo repo, ContentSource source,
- ContentProvider provider) {
+ public DistributionSourceSynchronizer(Repo repo, ContentSource source, ContentProvider provider) {
this.repo = repo;
this.source = source;
this.provider = provider;
@@ -81,8 +81,7 @@ public class DistributionSourceSynchronizer {
DistributionSource distributionSource = (DistributionSource) provider;
- log.info("Synchronize Distributions: [" + source.getName() +
- "]: syncing repo [" + repo.getName() + "]");
+ log.info("Synchronize Distributions: [" + source.getName() + "]: syncing repo [" + repo.getName() + "]");
// Load existing distributions to send to source
// --------------------------------------------
@@ -90,18 +89,15 @@ public class DistributionSourceSynchronizer {
PageControl pc = PageControl.getUnlimitedInstance();
Subject overlord = subjectManager.getOverlord();
- List<Distribution> dists = repoManager
- .findAssociatedDistributions(overlord, repo.getId(), pc);
+ List<Distribution> dists = repoManager.findAssociatedDistributions(overlord, repo.getId(), pc);
log.debug("Found " + dists.size() + " distributions for repo " + repo.getId());
DistributionSyncReport distReport = new DistributionSyncReport(repo.getId());
- List<DistributionDetails> distDetails =
- new ArrayList<DistributionDetails>(dists.size());
+ List<DistributionDetails> distDetails = new ArrayList<DistributionDetails>(dists.size());
translateDomainToDto(dists, distDetails);
- log.info("Synchronize Distributions: [" + source.getName() +
- "]: loaded existing list of size=["
- + dists.size() + "] (" + (System.currentTimeMillis() - start) + ")ms");
+ log.info("Synchronize Distributions: [" + source.getName() + "]: loaded existing list of size=[" + dists.size()
+ + "] (" + (System.currentTimeMillis() - start) + ")ms");
// Ask source to do the sync
// --------------------------------------------
@@ -109,11 +105,11 @@ public class DistributionSourceSynchronizer {
distributionSource.synchronizeDistribution(repo.getName(), distReport, distDetails);
- log.info("Synchronize Distributions: [" + source.getName() +
- "]: got sync report from adapter=["
- + distReport + "] (" + (System.currentTimeMillis() - start) + ")ms");
+ log.info("Synchronize Distributions: [" + source.getName() + "]: got sync report from adapter=[" + distReport
+ + "] (" + (System.currentTimeMillis() - start) + ")ms");
- contentSourceManager.mergeDistributionSyncReport(source, distReport, null);
+ ContentSourceSyncResults syncResults = new ContentSourceSyncResults(source);
+ contentSourceManager.mergeDistributionSyncReport(source, distReport, syncResults);
}
public void synchronizeDistributionBits() throws Exception {
@@ -121,21 +117,18 @@ public class DistributionSourceSynchronizer {
contentSourceManager.downloadDistributionBits(overlord, source);
}
- private void translateDomainToDto(List<Distribution> dists,
- List<DistributionDetails> distDetails) {
+ private void translateDomainToDto(List<Distribution> dists, List<DistributionDetails> distDetails) {
DistributionManagerLocal distManager = LookupUtil.getDistributionManagerLocal();
for (Distribution d : dists) {
- DistributionDetails detail = new DistributionDetails(d.getLabel(),
- d.getDistributionType().getName());
+ DistributionDetails detail = new DistributionDetails(d.getLabel(), d.getDistributionType().getName());
detail.setLabel(d.getLabel());
detail.setDistributionPath(d.getBasePath());
detail.setDescription(d.getDistributionType().getDescription());
List<DistributionFile> files = distManager.getDistributionFilesByDistId(d.getId());
for (DistributionFile f : files) {
- DistributionFileDetails dfd =
- new DistributionFileDetails(f.getRelativeFilename(), f.getLastModified(),
- f.getMd5sum());
+ DistributionFileDetails dfd = new DistributionFileDetails(f.getRelativeFilename(), f.getLastModified(),
+ f.getMd5sum());
detail.addFile(dfd);
}
distDetails.add(detail);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/PackageSourceSynchronizer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/PackageSourceSynchronizer.java
index 6e6bc5a..cff3ba7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/PackageSourceSynchronizer.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/PackageSourceSynchronizer.java
@@ -34,11 +34,12 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.content.ContentSource;
+import org.rhq.core.domain.content.ContentSourceSyncResults;
+import org.rhq.core.domain.content.DownloadMode;
import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.content.PackageVersionContentSource;
import org.rhq.core.domain.content.PackageVersionContentSourcePK;
import org.rhq.core.domain.content.Repo;
-import org.rhq.core.domain.content.DownloadMode;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageControl;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
@@ -67,8 +68,7 @@ public class PackageSourceSynchronizer {
private ContentSource source;
private ContentProvider provider;
- public PackageSourceSynchronizer(Repo repo, ContentSource source,
- ContentProvider provider) {
+ public PackageSourceSynchronizer(Repo repo, ContentSource source, ContentProvider provider) {
this.repo = repo;
this.source = source;
this.provider = provider;
@@ -93,19 +93,17 @@ public class PackageSourceSynchronizer {
Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> keyPVCSMap;
Subject overlord = subjectManager.getOverlord();
- existingPVCS = contentSourceManager.getPackageVersionsFromContentSourceForRepo(
- overlord, source.getId(), repo.getId());
+ existingPVCS = contentSourceManager.getPackageVersionsFromContentSourceForRepo(overlord, source.getId(), repo
+ .getId());
int existingCount = existingPVCS.size();
- keyPVCSMap = new HashMap<ContentProviderPackageDetailsKey,
- PackageVersionContentSource>(existingCount);
+ keyPVCSMap = new HashMap<ContentProviderPackageDetailsKey, PackageVersionContentSource>(existingCount);
allDetails = new HashSet<ContentProviderPackageDetails>(existingCount);
translateDomainToDto(existingPVCS, allDetails, keyPVCSMap);
- log.info("Synchronize Packages: [" + source.getName() +
- "]: loaded existing list of size=[" + existingCount + "] (" +
- (System.currentTimeMillis() - start) + ")ms");
+ log.info("Synchronize Packages: [" + source.getName() + "]: loaded existing list of size=[" + existingCount
+ + "] (" + (System.currentTimeMillis() - start) + ")ms");
// Ask source to do the sync
// --------------------------------------------
@@ -114,19 +112,17 @@ public class PackageSourceSynchronizer {
PackageSyncReport report = new PackageSyncReport();
packageSource.synchronizePackages(repo.getName(), report, allDetails);
- log.info("Synchronize Packages: [" + source.getName() +
- "]: got sync report from adapter=[" + report + "] (" +
- (System.currentTimeMillis() - start) + ")ms");
+ log.info("Synchronize Packages: [" + source.getName() + "]: got sync report from adapter=[" + report + "] ("
+ + (System.currentTimeMillis() - start) + ")ms");
// Merge in the results of the synchronization
// --------------------------------------------
start = System.currentTimeMillis();
+ ContentSourceSyncResults syncResults = new ContentSourceSyncResults(source);
+ syncResults = contentSourceManager.mergePackageSyncReport(source, repo, report, keyPVCSMap, syncResults);
- contentSourceManager.mergePackageSyncReport(source, repo, report, keyPVCSMap, null);
-
- log.info("Synchronize Packages: [" + source.getName() +
- "]: merged sync report=(" +
- (System.currentTimeMillis() - start) + ")ms");
+ log.info("Synchronize Packages: [" + source.getName() + "]: merged sync report=("
+ + (System.currentTimeMillis() - start) + ")ms");
}
public void synchronizePackageBits() throws Exception {
@@ -137,18 +133,17 @@ public class PackageSourceSynchronizer {
}
if (source.getDownloadMode() == DownloadMode.NEVER) {
- log.info("Download mode of NEVER for source [" + source.getName() + "], skipping " +
- "package bits sync for repo [" + repo.getName() + "]");
+ log.info("Download mode of NEVER for source [" + source.getName() + "], skipping "
+ + "package bits sync for repo [" + repo.getName() + "]");
return;
}
if (source.isLazyLoad()) {
- log.info("Lazy load enabled for source [" + source.getName() + "], skipping " +
- "package bits sync for repo [" + repo.getName() + "]");
+ log.info("Lazy load enabled for source [" + source.getName() + "], skipping "
+ + "package bits sync for repo [" + repo.getName() + "]");
return;
}
-
long start;
// Determine which packages need bit synccing
@@ -162,8 +157,8 @@ public class PackageSourceSynchronizer {
// TODO: jdob - Need to change this call to only load packages for this repo
List<PackageVersionContentSource> packageVersionContentSources = contentSourceManager
.getUnloadedPackageVersionsFromContentSourceInRepo(overlord, source.getId(), repo.getId(), pc);
- log.info("Synchronize Package Bits: [" + source.getName() + "], repo [" + repo.getName() +
- "]: loaded package list for sync (" + (System.currentTimeMillis() - start) + ")ms");
+ log.info("Synchronize Package Bits: [" + source.getName() + "], repo [" + repo.getName()
+ + "]: loaded package list for sync (" + (System.currentTimeMillis() - start) + ")ms");
// Download the bits for each unloaded package version. Abort the entire download if we
// fail getting just one package.
@@ -174,27 +169,22 @@ public class PackageSourceSynchronizer {
try {
if (log.isDebugEnabled()) {
- log.debug(
- "Downloading package version [" + pk.getPackageVersion() + "] located at ["
- + item.getLocation() + "]" + "] from [" + pk.getContentSource() + "]...");
+ log.debug("Downloading package version [" + pk.getPackageVersion() + "] located at ["
+ + item.getLocation() + "]" + "] from [" + pk.getContentSource() + "]...");
}
overlord = subjectManager.getOverlord();
contentSourceManager.downloadPackageBits(overlord, item);
- }
- catch (Exception e) {
- String errorMsg =
- "Failed to load package bits for package version [" + pk.getPackageVersion()
- + "] from content source [" + pk.getContentSource() + "] at location [" +
- item.getLocation()
- + "]." + "No more packages will be downloaded for this content source.";
+ } catch (Exception e) {
+ String errorMsg = "Failed to load package bits for package version [" + pk.getPackageVersion()
+ + "] from content source [" + pk.getContentSource() + "] at location [" + item.getLocation() + "]."
+ + "No more packages will be downloaded for this content source.";
throw new Exception(errorMsg, e);
}
}
- log.info("All package bits for content source [" + source.getName() +
- "] have been downloaded."
+ log.info("All package bits for content source [" + source.getName() + "] have been downloaded."
+ "The downloads started at [" + new Date(start) + "] and ended at [" + new Date() + "]");
}
@@ -210,8 +200,8 @@ public class PackageSourceSynchronizer {
* @param keyPVCSMap mapping of package version key to package domain object
*/
private void translateDomainToDto(List<PackageVersionContentSource> existingPVCS,
- Set<ContentProviderPackageDetails> allDetails,
- Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> keyPVCSMap) {
+ Set<ContentProviderPackageDetails> allDetails,
+ Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> keyPVCSMap) {
for (PackageVersionContentSource pvcs : existingPVCS) {
PackageVersion pv = pvcs.getPackageVersionContentSourcePK().getPackageVersion();
@@ -219,9 +209,8 @@ public class PackageSourceSynchronizer {
ResourceType rt = p.getPackageType().getResourceType();
ContentProviderPackageDetailsKey key;
- key = new ContentProviderPackageDetailsKey(p.getName(), pv.getVersion(),
- p.getPackageType()
- .getName(), pv.getArchitecture().getName(), rt.getName(), rt.getPlugin());
+ key = new ContentProviderPackageDetailsKey(p.getName(), pv.getVersion(), p.getPackageType().getName(), pv
+ .getArchitecture().getName(), rt.getName(), rt.getPlugin());
ContentProviderPackageDetails details = new ContentProviderPackageDetails(key);
details.setClassification(pv.getGeneralPackage().getClassification());
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/ContentTestHelper.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/ContentTestHelper.java
new file mode 100644
index 0000000..960231e
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/ContentTestHelper.java
@@ -0,0 +1,37 @@
+package org.rhq.enterprise.server.content;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.content.ContentSource;
+import org.rhq.core.domain.content.ContentSourceType;
+import org.rhq.core.domain.content.Repo;
+import org.rhq.enterprise.server.content.metadata.ContentSourceMetadataManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+public class ContentTestHelper {
+
+ public static ContentSource getTestContentSource() throws Exception {
+ Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+ ContentSourceMetadataManagerLocal contentSourceMetadataManager = LookupUtil.getContentSourceMetadataManager();
+ ContentSourceManagerLocal contentSourceManager = LookupUtil.getContentSourceManager();
+ ContentSourceType type = new ContentSourceType("testGetSyncResultsListCST");
+ Set<ContentSourceType> types = new HashSet<ContentSourceType>();
+ types.add(type);
+ contentSourceMetadataManager.registerTypes(types); // this blows away any previous existing types
+ ContentSource contentSource = new ContentSource("testGetSyncResultsListCS", type);
+ contentSource = contentSourceManager.simpleCreateContentSource(overlord, contentSource);
+ return contentSource;
+ }
+
+ public static Repo getTestRepoWithContentSource() throws Exception {
+ Repo repo = new Repo("testSyncRepos");
+ Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+ LookupUtil.getRepoManagerLocal().createRepo(overlord, repo);
+ ContentSource contentSource = getTestContentSource();
+ repo.addContentSource(contentSource);
+ return repo;
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/ContentSourceManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/ContentSourceManagerBeanTest.java
index afe2593..f418715 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/ContentSourceManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/ContentSourceManagerBeanTest.java
@@ -349,7 +349,8 @@ public class ContentSourceManagerBeanTest extends AbstractEJB3Test {
// confirm that we didn't load the bits yet
pc = PageControl.getUnlimitedInstance();
List<PackageVersionContentSource> unloaded;
- unloaded = contentSourceManager.getUnloadedPackageVersionsFromContentSourceInRepo(overlord, contentSourceId, repoId, pc);
+ unloaded = contentSourceManager.getUnloadedPackageVersionsFromContentSourceInRepo(overlord,
+ contentSourceId, repoId, pc);
assert unloaded != null;
assert unloaded.size() == 1;
@@ -462,7 +463,8 @@ public class ContentSourceManagerBeanTest extends AbstractEJB3Test {
// confirm that we didn't load the bits yet
List<PackageVersionContentSource> unloaded;
- unloaded = contentSourceManager.getUnloadedPackageVersionsFromContentSourceInRepo(overlord, contentSourceId, repoId, pc);
+ unloaded = contentSourceManager.getUnloadedPackageVersionsFromContentSourceInRepo(overlord,
+ contentSourceId, repoId, pc);
assert unloaded != null;
assert unloaded.size() == 1;
@@ -492,7 +494,8 @@ public class ContentSourceManagerBeanTest extends AbstractEJB3Test {
assert inCS.size() == 1 : inCS;
// it should still be unloaded, make sure and check that it really was updated
- unloaded = contentSourceManager.getUnloadedPackageVersionsFromContentSourceInRepo(overlord, contentSourceId, repoId, pc);
+ unloaded = contentSourceManager.getUnloadedPackageVersionsFromContentSourceInRepo(overlord,
+ contentSourceId, repoId, pc);
assert unloaded != null;
assert unloaded.size() == 1;
assert unloaded.get(0).getPackageVersionContentSourcePK().getPackageVersion().getFileSize() == 9999L;
@@ -584,7 +587,8 @@ public class ContentSourceManagerBeanTest extends AbstractEJB3Test {
assert results != null;
List<PackageVersionContentSource> unloaded;
- unloaded = contentSourceManager.getUnloadedPackageVersionsFromContentSourceInRepo(overlord, contentSourceId, repoId, pc);
+ unloaded = contentSourceManager.getUnloadedPackageVersionsFromContentSourceInRepo(overlord,
+ contentSourceId, repoId, pc);
assert unloaded != null;
assert unloaded.size() == 1;
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
index 935bae9..a31ef46 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
@@ -47,6 +47,7 @@ import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.content.ContentSourceManagerLocal;
+import org.rhq.enterprise.server.content.ContentTestHelper;
import org.rhq.enterprise.server.content.RepoException;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.content.metadata.ContentSourceMetadataManagerLocal;
@@ -108,17 +109,8 @@ public class RepoManagerBeanTest extends AbstractEJB3Test {
@Test(enabled = true)
public void testSyncRepos() throws Exception {
- Repo repo = new Repo("testSyncStatus");
-
- ContentSourceType type = new ContentSourceType("testGetSyncResultsListCST");
- Set<ContentSourceType> types = new HashSet<ContentSourceType>();
- types.add(type);
- contentSourceMetadataManager.registerTypes(types); // this blows away any previous existing types
- ContentSource contentSource = new ContentSource("testGetSyncResultsListCS", type);
- contentSource = contentSourceManager.simpleCreateContentSource(overlord, contentSource);
- repo.addContentSource(contentSource);
+ Repo repo = ContentTestHelper.getTestRepoWithContentSource();
- repoManager.createRepo(overlord, repo);
Integer[] ids = { repo.getId() };
int syncCount = repoManager.synchronizeRepos(overlord, ids);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java
index a0c6b7c..1ffae7b 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java
@@ -6,11 +6,10 @@ import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.content.Repo;
+import org.rhq.enterprise.server.content.ContentTestHelper;
import org.rhq.enterprise.server.plugin.pc.content.TestContentServerPluginService;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
-import org.rhq.enterprise.server.util.LookupUtil;
public class RepoSyncingTest extends AbstractEJB3Test {
@@ -24,12 +23,11 @@ public class RepoSyncingTest extends AbstractEJB3Test {
public void testSyncRepos() throws Exception {
TestContentServerPluginService pluginService = new TestContentServerPluginService(this);
- Repo repo = new Repo("testSyncRepos");
-
- Subject overlord = LookupUtil.getSubjectManager().getOverlord();
- LookupUtil.getRepoManagerLocal().createRepo(overlord, repo);
+ Repo repo = ContentTestHelper.getTestRepoWithContentSource();
+ assert repo.getContentSources().size() == 1;
boolean synced = pluginService.getContentProviderManager().synchronizeRepo(repo.getId());
+
assert synced;
}