[rhq] Branch 'content' - modules/enterprise
by jdob
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java | 16 ++++----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java | 8 ++--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerRemote.java | 3 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java | 18 +++++++++-
4 files changed, 32 insertions(+), 13 deletions(-)
New commits:
commit a991939f2738c92ccfdb8ef6570547b52dcf5eaa
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Tue Nov 24 12:27:40 2009 -0500
635 - Rewired hook from RepoManagerBean synchronizeRepos to call the repo sync instead of the content provider sync.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java
index 9f89050..4f9ec58 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java
@@ -71,6 +71,7 @@ import org.rhq.enterprise.server.plugin.pc.content.ContentServerPluginContainer;
import org.rhq.enterprise.server.plugin.pc.content.RepoDetails;
import org.rhq.enterprise.server.plugin.pc.content.RepoGroupDetails;
import org.rhq.enterprise.server.plugin.pc.content.RepoImportReport;
+import org.rhq.enterprise.server.plugin.pc.content.ContentProviderManager;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
@@ -917,18 +918,17 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
}
@RequiredPermission(Permission.MANAGE_INVENTORY)
- public int synchronizeRepos(Subject subject, Integer[] repoIds) {
+ public int synchronizeRepos(Subject subject, Integer[] repoIds) throws Exception {
int syncCount = 0;
+ ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer();
+ ContentProviderManager providerManager = pc.getAdapterManager();
+
for (Integer id : repoIds) {
- Repo r = this.getRepo(subject, id);
- Set<ContentSource> sources = r.getContentSources();
- Iterator<ContentSource> i = sources.iterator();
- while (i.hasNext()) {
- ContentSource source = i.next();
- contentSourceManager.synchronizeAndLoadContentSource(subject, source.getId());
+ boolean syncExecuted = providerManager.synchronizeRepo(id);
+
+ if (syncExecuted) {
syncCount++;
- log.debug("Initiating sync: " + source.getId());
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java
index fe2090b..a5ae71b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java
@@ -284,10 +284,12 @@ public interface RepoManagerLocal {
PageList<Distribution> findAssociatedDistributions(Subject subject, int repoid, PageControl pc);
/**
- * Syncronize the content associated with the repoIds passed in.
- * @param repoIds to syncronize
+ * Synchronize the content associated with the repoIds passed in.
+ *
+ * @param repoIds to synchronize; may not be <code>null</code>
* @return count of the number of repositories synced.
+ * @throws Exception if there is an error connecting with the plugin container
*/
- int synchronizeRepos(Subject subject, Integer[] repoIds);
+ int synchronizeRepos(Subject subject, Integer[] repoIds) throws Exception;
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerRemote.java
index 6eff16a..119b767 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerRemote.java
@@ -266,6 +266,7 @@ public interface RepoManagerRemote {
@WebParam(name = "pageControl") PageControl pc);
@WebMethod
- int synchronizeRepos(@WebParam(name = "subject") Subject subject, @WebParam(name = "repoIds") Integer[] repoIds);
+ int synchronizeRepos(@WebParam(name = "subject") Subject subject, @WebParam(name = "repoIds") Integer[] repoIds)
+ throws Exception;
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java
index a5c57c2..6bb8b41 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java
@@ -220,7 +220,21 @@ public class ContentProviderManager {
return true;
}
-
+ /**
+ * Asks each content provider associated with the given repo to synchronize the following
+ * information for the given repo:
+ * <ul>
+ * <li>Package Metadata</li>
+ * <li>Package Bits</li>
+ * <li>Distribution Tree Metadata</li>
+ * <li>Distribution Tree Bits</li>
+ * </ul>
+ *
+ * @param repoId must indicate a valid repo in the database
+ * @return <code>true</code> if the synchronize took place; <code>false</code> if it did not
+ * (for instance, if there is already a sync taking place for this repo)
+ * @throws Exception if the data required to perform the sync is missing or invalid
+ */
public boolean synchronizeRepo(int repoId) throws Exception {
RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
@@ -234,6 +248,8 @@ public class ContentProviderManager {
throw new Exception("Invalid repo ID specified for sync: " + repoId);
}
+ // TODO: Add check to sync results tracking to make sure it's not already synccing
+
// Synchronize every content provider associated with the repo
for (ContentSource source : repo.getContentSources()) {
ContentProvider provider = getIsolatedContentProvider(source.getId());
14 years, 6 months
[rhq] Branch 'content' - modules/enterprise
by jdob
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java | 23 +++----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/DistributionSourceSynchronizer.java | 20 +++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/PackageSourceSynchronizer.java | 21 ++++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/RepoSourceSynchronizer.java | 29 +++++++---
4 files changed, 63 insertions(+), 30 deletions(-)
New commits:
commit 4cad6139725c9db42d6fd7e0caa2f415be89fad7
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Tue Nov 24 12:15:46 2009 -0500
Signature cleanup and docs
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java
index 7c8921a..a5c57c2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java
@@ -66,10 +66,6 @@ public class ContentProviderManager {
private ContentServerPluginManager pluginManager;
private Map<ContentSource, ContentProvider> adapters;
- private RepoSourceSynchronizer repoSourceSynchronizer = new RepoSourceSynchronizer();
- private PackageSourceSynchronizer packageSourceSynchronizer;
- private DistributionSourceSynchronizer distributionSourceSynchronizer = new DistributionSourceSynchronizer();
-
// This is used as a monitor lock to the synchronizeContentProvider method;
// it helps us avoid two content sources getting synchronized at the same time.
private final Object synchronizeContentSourceLock = new Object();
@@ -139,7 +135,6 @@ public class ContentProviderManager {
public boolean synchronizeContentProvider(int contentSourceId) throws Exception {
ContentSourceManagerLocal contentSourceManager = LookupUtil.getContentSourceManager();
- RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
ContentProvider provider = getIsolatedContentProvider(contentSourceId);
ContentSourceSyncResults results = null;
@@ -187,8 +182,9 @@ public class ContentProviderManager {
return false;
}
- repoSourceSynchronizer.synchronizeCandidateRepos(contentSourceId,
- repoManager, provider, overlord, progress, contentSource);
+ RepoSourceSynchronizer repoSourceSynchronizer =
+ new RepoSourceSynchronizer(contentSource, provider);
+ repoSourceSynchronizer.synchronizeCandidateRepos(progress);
}
catch (Throwable t) {
if (results != null) {
@@ -228,7 +224,6 @@ public class ContentProviderManager {
public boolean synchronizeRepo(int repoId) throws Exception {
RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
- ContentSourceManagerLocal contentSourceManager = LookupUtil.getContentSourceManager();
SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
Subject overlord = subjectManager.getOverlord();
@@ -243,11 +238,15 @@ public class ContentProviderManager {
for (ContentSource source : repo.getContentSources()) {
ContentProvider provider = getIsolatedContentProvider(source.getId());
- packageSourceSynchronizer.synchronizePackageMetadata(repo, source, provider);
- packageSourceSynchronizer.synchronizePackageBits(repo, source, provider);
+ PackageSourceSynchronizer packageSourceSynchronizer =
+ new PackageSourceSynchronizer(repo, source, provider);
+ packageSourceSynchronizer.synchronizePackageMetadata();
+ packageSourceSynchronizer.synchronizePackageBits();
- distributionSourceSynchronizer.synchronizeDistributionMetadata(repo, source, provider);
- distributionSourceSynchronizer.synchronizeDistributionBits(repo, source, provider);
+ DistributionSourceSynchronizer distributionSourceSynchronizer =
+ new DistributionSourceSynchronizer(repo, source, provider);
+ distributionSourceSynchronizer.synchronizeDistributionMetadata();
+ distributionSourceSynchronizer.synchronizeDistributionBits();
}
return true;
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 97c29b4..062390e 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
@@ -46,6 +46,9 @@ import org.rhq.enterprise.server.plugin.pc.content.DistributionSyncReport;
import org.rhq.enterprise.server.util.LookupUtil;
/**
+ * Holds the methods necessary to interact with a plugin and execute its distribution related
+ * synchronization tasks.
+ *
* @author Jason Dobies
*/
public class DistributionSourceSynchronizer {
@@ -56,14 +59,22 @@ public class DistributionSourceSynchronizer {
private ContentSourceManagerLocal contentSourceManager;
private SubjectManagerLocal subjectManager;
- public DistributionSourceSynchronizer() {
+ private Repo repo;
+ private ContentSource source;
+ private ContentProvider provider;
+
+ public DistributionSourceSynchronizer(Repo repo, ContentSource source,
+ ContentProvider provider) {
+ this.repo = repo;
+ this.source = source;
+ this.provider = provider;
+
repoManager = LookupUtil.getRepoManagerLocal();
contentSourceManager = LookupUtil.getContentSourceManager();
subjectManager = LookupUtil.getSubjectManager();
}
- public void synchronizeDistributionMetadata(Repo repo, ContentSource source,
- ContentProvider provider) throws Exception {
+ public void synchronizeDistributionMetadata() throws Exception {
if (!(provider instanceof DistributionSource)) {
return;
}
@@ -105,8 +116,7 @@ public class DistributionSourceSynchronizer {
contentSourceManager.mergeDistributionSyncReport(source, distReport, null);
}
- public void synchronizeDistributionBits(Repo repo, ContentSource source,
- ContentProvider provider) throws Exception {
+ public void synchronizeDistributionBits() throws Exception {
Subject overlord = subjectManager.getOverlord();
contentSourceManager.downloadDistributionBits(overlord, source);
}
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 b099bce..abfbf19 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
@@ -62,13 +62,21 @@ public class PackageSourceSynchronizer {
private ContentSourceManagerLocal contentSourceManager;
private SubjectManagerLocal subjectManager;
- public PackageSourceSynchronizer() {
+ private Repo repo;
+ private ContentSource source;
+ private ContentProvider provider;
+
+ public PackageSourceSynchronizer(Repo repo, ContentSource source,
+ ContentProvider provider) {
+ this.repo = repo;
+ this.source = source;
+ this.provider = provider;
+
contentSourceManager = LookupUtil.getContentSourceManager();
subjectManager = LookupUtil.getSubjectManager();
}
- public void synchronizePackageMetadata(Repo repo, ContentSource source,
- ContentProvider provider) throws Exception {
+ public void synchronizePackageMetadata() throws Exception {
if (!(provider instanceof PackageSource)) {
return;
}
@@ -120,8 +128,7 @@ public class PackageSourceSynchronizer {
(System.currentTimeMillis() - start) + ")ms");
}
- public void synchronizePackageBits(Repo repo, ContentSource contentSource,
- ContentProvider provider) throws Exception {
+ public void synchronizePackageBits() throws Exception {
if (!(provider instanceof PackageSource)) {
return;
@@ -137,7 +144,7 @@ public class PackageSourceSynchronizer {
Subject overlord = subjectManager.getOverlord();
packageVersionContentSources = contentSourceManager
.getUnloadedPackageVersionsFromContentSource(overlord,
- contentSource.getId(), pc);
+ source.getId(), pc);
// For each unloaded package version, let's download them now.
// This can potentially take a very long time.
@@ -166,7 +173,7 @@ public class PackageSourceSynchronizer {
}
}
- log.info("All package bits for content source [" + contentSource.getName() +
+ 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() + "]");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/RepoSourceSynchronizer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/RepoSourceSynchronizer.java
index d8142b2..5f801ab 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/RepoSourceSynchronizer.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/RepoSourceSynchronizer.java
@@ -29,22 +29,38 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.content.ContentSource;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.plugin.pc.content.ContentProvider;
import org.rhq.enterprise.server.plugin.pc.content.RepoImportReport;
import org.rhq.enterprise.server.plugin.pc.content.RepoSource;
+import org.rhq.enterprise.server.util.LookupUtil;
/**
+ * Holds the methods necessary to interact with a plugin and execute its repo related
+ * synchronization tasks.
+ *
* @author Jason Dobies
*/
public class RepoSourceSynchronizer {
private final Log log = LogFactory.getLog(this.getClass());
- public void synchronizeCandidateRepos(int contentSourceId, RepoManagerLocal repoManager,
- ContentProvider provider, Subject overlord,
- StringBuilder progress, ContentSource contentSource)
- throws Exception {
+ private RepoManagerLocal repoManager;
+ private SubjectManagerLocal subjectManager;
+
+ private ContentSource source;
+ private ContentProvider provider;
+
+ public RepoSourceSynchronizer(ContentSource source, ContentProvider provider) {
+ this.source = source;
+ this.provider = provider;
+
+ repoManager = LookupUtil.getRepoManagerLocal();
+ subjectManager = LookupUtil.getSubjectManager();
+ }
+
+ public void synchronizeCandidateRepos(StringBuilder progress) throws Exception {
if (!(provider instanceof RepoSource)) {
return;
@@ -60,9 +76,10 @@ public class RepoSourceSynchronizer {
// Call to the plugin
RepoImportReport report = repoSource.importRepos();
- repoManager.processRepoImportReport(overlord, report, contentSourceId, progress);
+ Subject overlord = subjectManager.getOverlord();
+ repoManager.processRepoImportReport(overlord, report, source.getId(), progress);
- log.info("importRepos: [" + contentSource.getName() + "]: report has been merged ("
+ log.info("importRepos: [" + source.getName() + "]: report has been merged ("
+ (System.currentTimeMillis() - start) + ")ms");
}
14 years, 6 months
[rhq] Branch 'content' - modules/enterprise
by jdob
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java | 4 ++--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java | 6 +++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/PackageSourceSynchronizer.java | 3 +++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManagerTest.java | 2 +-
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentServerPluginService.java | 2 +-
5 files changed, 10 insertions(+), 7 deletions(-)
New commits:
commit 2defff7896f00ee80226465ef9a6d3308571f979
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Tue Nov 24 12:04:51 2009 -0500
More renaming of source -> provider
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 19bd33b..1365208 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
@@ -693,7 +693,7 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
DistributionSource distSource = (DistributionSource) provider;
//
- // Following same sort of workaround done in ContentProviderManager for synchronizeContentSource
+ // Following same sort of workaround done in ContentProviderManager for synchronizeContentProvider
// Assume this will need to be updated when we place syncing in repo layer
//
RepoCriteria reposForContentSource = new RepoCriteria();
@@ -873,7 +873,7 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
@TransactionAttribute(TransactionAttributeType.NEVER)
public boolean internalSynchronizeContentSource(int contentSourceId) throws Exception {
ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer();
- return pc.getAdapterManager().synchronizeContentSource(contentSourceId);
+ return pc.getAdapterManager().synchronizeContentProvider(contentSourceId);
}
@SuppressWarnings("unchecked")
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java
index ba26d28..7c8921a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java
@@ -67,10 +67,10 @@ public class ContentProviderManager {
private Map<ContentSource, ContentProvider> adapters;
private RepoSourceSynchronizer repoSourceSynchronizer = new RepoSourceSynchronizer();
- private PackageSourceSynchronizer packageSourceSynchronizer = new PackageSourceSynchronizer();
+ private PackageSourceSynchronizer packageSourceSynchronizer;
private DistributionSourceSynchronizer distributionSourceSynchronizer = new DistributionSourceSynchronizer();
- // This is used as a monitor lock to the synchronizeContentSource method;
+ // This is used as a monitor lock to the synchronizeContentProvider method;
// it helps us avoid two content sources getting synchronized at the same time.
private final Object synchronizeContentSourceLock = new Object();
@@ -136,7 +136,7 @@ public class ContentProviderManager {
* already a synchronization happening and this method aborted
* @throws Exception
*/
- public boolean synchronizeContentSource(int contentSourceId) throws Exception {
+ public boolean synchronizeContentProvider(int contentSourceId) throws Exception {
ContentSourceManagerLocal contentSourceManager = LookupUtil.getContentSourceManager();
RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
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 bff4918..b099bce 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
@@ -50,6 +50,9 @@ import org.rhq.enterprise.server.plugin.pc.content.PackageSyncReport;
import org.rhq.enterprise.server.util.LookupUtil;
/**
+ * Holds the methods necessary to interact with a plugin and execute its package related
+ * synchronization tasks.
+ *
* @author Jason Dobies
*/
public class PackageSourceSynchronizer {
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManagerTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManagerTest.java
index 60f9fd1..d022a6d 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManagerTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManagerTest.java
@@ -258,7 +258,7 @@ public class ContentProviderManagerTest extends AbstractEJB3Test {
// Test
// --------------------------------------------
- boolean completed = providerManager.synchronizeContentSource(syncSource.getId());
+ boolean completed = providerManager.synchronizeContentProvider(syncSource.getId());
assert completed;
// Verify RepoGroups
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentServerPluginService.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentServerPluginService.java
index 0f728cc..3716282 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentServerPluginService.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentServerPluginService.java
@@ -151,7 +151,7 @@ public class TestContentServerPluginService extends ServerPluginService implemen
}
@Override
- public boolean synchronizeContentSource(int contentSourceId) throws Exception {
+ public boolean synchronizeContentProvider(int contentSourceId) throws Exception {
if (testAdapters != null) {
for (ContentSource cs : testAdapters.keySet()) {
if (cs.getId() == contentSourceId) {
14 years, 6 months
[rhq] Branch 'content' - modules/enterprise
by jdob
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/RepoSyncJob.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit cee352617d1fd2d54ea8057eecc2970b26e5d2e8
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Tue Nov 24 12:00:05 2009 -0500
Updated docs
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/RepoSyncJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/RepoSyncJob.java
index ff12646..d5a5cb5 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/RepoSyncJob.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/RepoSyncJob.java
@@ -43,7 +43,8 @@ import org.rhq.enterprise.server.util.LookupUtil;
* <ul>
* <li>Package Metadata</li>
* <li>Package Bits</li>
- * <li>Distribution Trees</li>
+ * <li>Distribution Tree Metadata</li>
+ * <li>Distribution Tree Bits</li>
* </ul>
* <p/>
* Many of the calls out to the plugin are ultimately made from the
14 years, 6 months
[rhq] Branch 'content' - modules/enterprise
by jdob
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentServerPluginContainer.java | 14
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/ContentProviderSyncJob.java | 223 +++++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/ContentSourceSyncJob.java | 230 ----------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/RepoSyncJob.java | 2
4 files changed, 231 insertions(+), 238 deletions(-)
New commits:
commit bf042e70a0f964d12e64c0ee5ecbe2d77148e609
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Tue Nov 24 11:56:00 2009 -0500
Renamed job to reflect the new terminology (which looks like it's here to stay)
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentServerPluginContainer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentServerPluginContainer.java
index e32e858..9eb014e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentServerPluginContainer.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentServerPluginContainer.java
@@ -31,7 +31,7 @@ import org.rhq.enterprise.server.plugin.pc.MasterServerPluginContainer;
import org.rhq.enterprise.server.plugin.pc.ServerPluginManager;
import org.rhq.enterprise.server.plugin.pc.ServerPluginType;
import org.rhq.enterprise.server.scheduler.SchedulerLocal;
-import org.rhq.enterprise.server.scheduler.jobs.ContentSourceSyncJob;
+import org.rhq.enterprise.server.scheduler.jobs.ContentProviderSyncJob;
import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.enterprise.server.xmlschema.generated.serverplugin.content.ContentPluginDescriptorType;
@@ -109,10 +109,10 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
// Create our job with a trigger that fires immediately and doesn't repeat.
// Make the name unique - we may already have our cron job schedules.
// What happens if this is triggered when our cron job is triggered? the job will abort and let the current job finish
- JobDetail job = new JobDetail(ContentSourceSyncJob.createUniqueJobName(contentSource), SYNC_JOB_GROUP_NAME,
- ContentSourceSyncJob.class, false, false, false);
+ JobDetail job = new JobDetail(ContentProviderSyncJob.createUniqueJobName(contentSource), SYNC_JOB_GROUP_NAME,
+ ContentProviderSyncJob.class, false, false, false);
- ContentSourceSyncJob.createJobDataMap(contentSource, job);
+ ContentProviderSyncJob.createJobDataMap(contentSource, job);
SimpleTrigger trigger = new SimpleTrigger(job.getName(), job.getGroup());
trigger.setVolatility(false);
@@ -147,8 +147,8 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
}
SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
- scheduler.scheduleCronJob(ContentSourceSyncJob.createJobName(contentSource), SYNC_JOB_GROUP_NAME,
- ContentSourceSyncJob.createJobDataMap(contentSource, null), ContentSourceSyncJob.class, true, false,
+ scheduler.scheduleCronJob(ContentProviderSyncJob.createJobName(contentSource), SYNC_JOB_GROUP_NAME,
+ ContentProviderSyncJob.createJobDataMap(contentSource, null), ContentProviderSyncJob.class, true, false,
syncSchedule);
return;
@@ -182,7 +182,7 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
*/
public void unscheduleSyncJob(ContentSource contentSource) throws SchedulerException {
SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
- scheduler.deleteJob(ContentSourceSyncJob.createJobName(contentSource), SYNC_JOB_GROUP_NAME);
+ scheduler.deleteJob(ContentProviderSyncJob.createJobName(contentSource), SYNC_JOB_GROUP_NAME);
return;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/ContentProviderSyncJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/ContentProviderSyncJob.java
new file mode 100644
index 0000000..7e864bf
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/ContentProviderSyncJob.java
@@ -0,0 +1,223 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.server.scheduler.jobs;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.quartz.Job;
+import org.quartz.JobDataMap;
+import org.quartz.JobDetail;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.quartz.StatefulJob;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.content.ContentSource;
+import org.rhq.core.domain.content.ContentSourceType;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
+import org.rhq.enterprise.server.content.ContentSourceManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * This is a Quartz scheduler job whose job is to synchronize one particular {@link ContentSource}. After synchronizing
+ * the metadata, this will also attempt to load the content if the content source is not configured for
+ * {@link ContentSource#isLazyLoad() lazy loading}.
+ *
+ * <p>This implements {@link StatefulJob} (as opposed to {@link Job}) because we do not need nor want this job triggered
+ * concurrently. That is, we don't need multiple instances of this job running at the same time.</p>
+ *
+ * @author John Mazzitelli
+ * @author Jason Dobies
+ */
+public class ContentProviderSyncJob implements StatefulJob {
+ private static final String DATAMAP_CONTENT_SOURCE_NAME = "contentSourceName";
+ private static final String DATAMAP_CONTENT_SOURCE_TYPE_NAME = "contentSourceTypeName";
+
+ private static final Log log = LogFactory.getLog(ContentProviderSyncJob.class);
+ private static final String SEPARATOR = "--";
+
+ public void execute(JobExecutionContext context) throws JobExecutionException {
+ try {
+ JobDetail jobDetail = context.getJobDetail();
+ if (jobDetail == null) {
+ throw new IllegalStateException("The job does not have any details");
+ }
+
+ JobDataMap dataMap = jobDetail.getJobDataMap();
+ if (dataMap == null) {
+ throw new IllegalStateException("The job does not have any data in its details");
+ }
+
+ String name = dataMap.getString(DATAMAP_CONTENT_SOURCE_NAME);
+ String typeName = dataMap.getString(DATAMAP_CONTENT_SOURCE_TYPE_NAME);
+
+ if (name == null) {
+ throw new IllegalStateException("Missing the content source name in details data");
+ }
+
+ if (typeName == null) {
+ throw new IllegalStateException("Missing the content source type name in details data");
+ }
+
+ synchronizeAndLoad(name, typeName);
+
+ } catch (Exception e) {
+ String errorMsg = "Failed to sync content source in job [" + context.getJobDetail() + "]";
+ log.error(errorMsg, e);
+ JobExecutionException jobExecutionException = new JobExecutionException(errorMsg, e, false);
+
+ // should we unschedule so we never attempt to sync again?
+ // That would mean any error will cause this sync to never occur again automatically until
+ // we restart the server, restart the server-side content plugin container or somehow manually create
+ // the schedule again. I will assume we will allow this schedule to trigger again, not sure if
+ // that is what we want, but we can flip this to true if we want the other behavior.
+ // NOTE: we do NOT retrigger if we threw IllegalStateException because we know it'll never work anyway
+ if (!(e instanceof IllegalStateException)) {
+ jobExecutionException.setUnscheduleAllTriggers(false);
+ }
+
+ throw jobExecutionException;
+ }
+ }
+
+ /**
+ * This will synchronize the identified content source such that its package version information is updated and, if
+ * not lazy-loading, its package bits are downloaded.
+ *
+ * <p>Note that this method executes outside of any transaction. This is very important since this job is
+ * potentially very long running (on the order of hours potentially). We do our processing in here with this in
+ * mind. We make sure we never do any one thing that potentially could timeout a transaction.</p>
+ *
+ * @param contentSourceName name of the {@link ContentSource}
+ * @param contentSourceTypeName name of the {@link ContentSourceType}
+ *
+ * @throws Exception if either the sync failed or one of the packages failed to download
+ */
+ private void synchronizeAndLoad(String contentSourceName, String contentSourceTypeName) throws Exception {
+ // note that we will keep calling getOverlord on this subject manager - the overlord
+ // has a very short session lifespan so we need to keep asking for a new one, due to the possibility
+ // that some of the methods we call here take longer than the overlord's lifespan
+ SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
+ Subject overlord;
+ ContentSourceManagerLocal contentManager = LookupUtil.getContentSourceManager();
+ ContentSource contentSource;
+
+ overlord = subjectManager.getOverlord();
+ contentSource = contentManager
+ .getContentSourceByNameAndType(overlord, contentSourceName, contentSourceTypeName);
+
+ if (contentSource == null) {
+ throw new Exception("Sync job was asked to sync an unknown content source: " + contentSourceName + "|"
+ + contentSourceTypeName);
+ }
+
+ int contentSourceId = contentSource.getId();
+
+ // Pulls the metadata down from the remote repository - this creates PackageVersions
+ // and associates them with the content source.
+ // If 'completed' is false, there was already a synchronization taking place,
+ // so we should abort and let that already running sync take care of everything.
+ boolean completed = contentManager.internalSynchronizeContentSource(contentSourceId);
+
+ if (!completed) {
+ log.info("Content source [" + contentSourceName + "] is currently being synchronized already. "
+ + "Please wait for the current sync job to finish.");
+ }
+ }
+
+ /**
+ * All content source sync jobs must have specified data prepared
+ * in their job details data map. This creates that data map. You must
+ * call this method everytime you schedule a content source sync job.
+ * If the given details is not <code>null</code>, this will place the
+ * created data map in the details for you. Otherwise, you must ensure
+ * the returned data map gets associated with the job when it is created.
+ *
+ * @param contentSource the content source whose sync job's details is being prepared
+ * @param details where the job's data map will be stored (may be <code>null</code>)
+ *
+ * @return the data map with the data necessary to execute a content sync job
+ */
+ public static JobDataMap createJobDataMap(ContentSource contentSource, JobDetail details) {
+ JobDataMap dataMap;
+
+ if (details != null) {
+ dataMap = details.getJobDataMap();
+ } else {
+ dataMap = new JobDataMap();
+ }
+
+ dataMap.put(DATAMAP_CONTENT_SOURCE_NAME, contentSource.getName());
+ dataMap.put(DATAMAP_CONTENT_SOURCE_TYPE_NAME, contentSource.getContentSourceType().getName());
+
+ return dataMap;
+ }
+
+ /**
+ * Creates the name for the scheduled content source's sync job. Calling this
+ * method multiple times with the same content source always produces the same name.
+ *
+ * @param cs the content source whose scheduled job name is to be returned
+ *
+ * @return the scheduled job name for the given content source
+ */
+ public static String createJobName(ContentSource cs) {
+ // the quartz table has a limited column width of 80 - but we need to use the names to make jobs unique
+ // so encode the names' hashcodes to ensure we fix into the quartz job name column.
+ String nameEncoded = Integer.toHexString(cs.getName().hashCode());
+ String typeNameEncoded = Integer.toHexString(cs.getContentSourceType().getName().hashCode());
+
+ String jobName = nameEncoded + SEPARATOR + typeNameEncoded;
+
+ if (jobName.length() > 80) {
+ throw new IllegalArgumentException("Job names max size is 80 chars due to DB column size restrictions: "
+ + jobName);
+ }
+
+ return jobName;
+ }
+
+ /**
+ * Creates a unique name for a new content source sync job. Calling this
+ * method multiple times with the same content source always produces a different name
+ * which is useful if you want to schedule an new job that is separate and distinct
+ * from any other job in the system.
+ *
+ * @param cs the content source
+ *
+ * @return a unique job name that can be used for a new job to sync a given content source
+ */
+ public static String createUniqueJobName(ContentSource cs) {
+ // the quartz table has a limited column width of 80 - but we need to use the names to make jobs unique
+ // so encode the names' hashcodes to ensure we fix into the quartz job name column.
+ // appendStr is used to make the job unique among others for the same content source.
+ String nameEncoded = Integer.toHexString(cs.getName().hashCode());
+ String typeNameEncoded = Integer.toHexString(cs.getContentSourceType().getName().hashCode());
+ String appendStr = Long.toHexString(System.currentTimeMillis());
+
+ String jobName = nameEncoded + SEPARATOR + typeNameEncoded + SEPARATOR + appendStr;
+
+ if (jobName.length() > 80) {
+ throw new IllegalArgumentException("Job names max size is 80 chars due to DB column size restrictions: "
+ + jobName);
+ }
+
+ return jobName;
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/ContentSourceSyncJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/ContentSourceSyncJob.java
deleted file mode 100644
index 67ca931..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/ContentSourceSyncJob.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.server.scheduler.jobs;
-
-import java.util.Date;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.quartz.Job;
-import org.quartz.JobDataMap;
-import org.quartz.JobDetail;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-import org.quartz.StatefulJob;
-
-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.DownloadMode;
-import org.rhq.core.domain.content.PackageVersionContentSource;
-import org.rhq.core.domain.content.PackageVersionContentSourcePK;
-import org.rhq.core.domain.content.Distribution;
-import org.rhq.core.domain.util.PageControl;
-import org.rhq.enterprise.server.auth.SubjectManagerLocal;
-import org.rhq.enterprise.server.content.ContentSourceManagerLocal;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-/**
- * This is a Quartz scheduler job whose job is to synchronize one particular {@link ContentSource}. After synchronizing
- * the metadata, this will also attempt to load the content if the content source is not configured for
- * {@link ContentSource#isLazyLoad() lazy loading}.
- *
- * <p>This implements {@link StatefulJob} (as opposed to {@link Job}) because we do not need nor want this job triggered
- * concurrently. That is, we don't need multiple instances of this job running at the same time.</p>
- *
- * @author John Mazzitelli
- */
-public class ContentSourceSyncJob implements StatefulJob {
- private static final String DATAMAP_CONTENT_SOURCE_NAME = "contentSourceName";
- private static final String DATAMAP_CONTENT_SOURCE_TYPE_NAME = "contentSourceTypeName";
-
- private static final Log log = LogFactory.getLog(ContentSourceSyncJob.class);
- private static final String SEPARATOR = "--";
-
- public void execute(JobExecutionContext context) throws JobExecutionException {
- try {
- JobDetail jobDetail = context.getJobDetail();
- if (jobDetail == null) {
- throw new IllegalStateException("The job does not have any details");
- }
-
- JobDataMap dataMap = jobDetail.getJobDataMap();
- if (dataMap == null) {
- throw new IllegalStateException("The job does not have any data in its details");
- }
-
- String name = dataMap.getString(DATAMAP_CONTENT_SOURCE_NAME);
- String typeName = dataMap.getString(DATAMAP_CONTENT_SOURCE_TYPE_NAME);
-
- if (name == null) {
- throw new IllegalStateException("Missing the content source name in details data");
- }
-
- if (typeName == null) {
- throw new IllegalStateException("Missing the content source type name in details data");
- }
-
- synchronizeAndLoad(name, typeName);
-
- } catch (Exception e) {
- String errorMsg = "Failed to sync content source in job [" + context.getJobDetail() + "]";
- log.error(errorMsg, e);
- JobExecutionException jobExecutionException = new JobExecutionException(errorMsg, e, false);
-
- // should we unschedule so we never attempt to sync again?
- // That would mean any error will cause this sync to never occur again automatically until
- // we restart the server, restart the server-side content plugin container or somehow manually create
- // the schedule again. I will assume we will allow this schedule to trigger again, not sure if
- // that is what we want, but we can flip this to true if we want the other behavior.
- // NOTE: we do NOT retrigger if we threw IllegalStateException because we know it'll never work anyway
- if (!(e instanceof IllegalStateException)) {
- jobExecutionException.setUnscheduleAllTriggers(false);
- }
-
- throw jobExecutionException;
- }
- }
-
- /**
- * This will synchronize the identified content source such that its package version information is updated and, if
- * not lazy-loading, its package bits are downloaded.
- *
- * <p>Note that this method executes outside of any transaction. This is very important since this job is
- * potentially very long running (on the order of hours potentially). We do our processing in here with this in
- * mind. We make sure we never do any one thing that potentially could timeout a transaction.</p>
- *
- * @param contentSourceName name of the {@link ContentSource}
- * @param contentSourceTypeName name of the {@link ContentSourceType}
- *
- * @throws Exception if either the sync failed or one of the packages failed to download
- */
- private void synchronizeAndLoad(String contentSourceName, String contentSourceTypeName) throws Exception {
- // note that we will keep calling getOverlord on this subject manager - the overlord
- // has a very short session lifespan so we need to keep asking for a new one, due to the possibility
- // that some of the methods we call here take longer than the overlord's lifespan
- SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
- Subject overlord;
- ContentSourceManagerLocal contentManager = LookupUtil.getContentSourceManager();
- ContentSource contentSource;
-
- overlord = subjectManager.getOverlord();
- contentSource = contentManager
- .getContentSourceByNameAndType(overlord, contentSourceName, contentSourceTypeName);
-
- if (contentSource == null) {
- throw new Exception("Sync job was asked to sync an unknown content source: " + contentSourceName + "|"
- + contentSourceTypeName);
- }
-
- int contentSourceId = contentSource.getId();
-
- // Pulls the metadata down from the remote repository - this creates PackageVersions
- // and associates them with the content source.
- // If 'completed' is false, there was already a synchronization taking place,
- // so we should abort and let that already running sync take care of everything.
- boolean completed = contentManager.internalSynchronizeContentSource(contentSourceId);
-
- if (!completed) {
- log.info("Content source [" + contentSourceName + "] is currently being synchronized already. "
- + "Please wait for the current sync job to finish.");
- }
- }
-
- /**
- * All content source sync jobs must have specified data prepared
- * in their job details data map. This creates that data map. You must
- * call this method everytime you schedule a content source sync job.
- * If the given details is not <code>null</code>, this will place the
- * created data map in the details for you. Otherwise, you must ensure
- * the returned data map gets associated with the job when it is created.
- *
- * @param contentSource the content source whose sync job's details is being prepared
- * @param details where the job's data map will be stored (may be <code>null</code>)
- *
- * @return the data map with the data necessary to execute a content sync job
- */
- public static JobDataMap createJobDataMap(ContentSource contentSource, JobDetail details) {
- JobDataMap dataMap;
-
- if (details != null) {
- dataMap = details.getJobDataMap();
- } else {
- dataMap = new JobDataMap();
- }
-
- dataMap.put(DATAMAP_CONTENT_SOURCE_NAME, contentSource.getName());
- dataMap.put(DATAMAP_CONTENT_SOURCE_TYPE_NAME, contentSource.getContentSourceType().getName());
-
- return dataMap;
- }
-
- /**
- * Creates the name for the scheduled content source's sync job. Calling this
- * method multiple times with the same content source always produces the same name.
- *
- * @param cs the content source whose scheduled job name is to be returned
- *
- * @return the scheduled job name for the given content source
- */
- public static String createJobName(ContentSource cs) {
- // the quartz table has a limited column width of 80 - but we need to use the names to make jobs unique
- // so encode the names' hashcodes to ensure we fix into the quartz job name column.
- String nameEncoded = Integer.toHexString(cs.getName().hashCode());
- String typeNameEncoded = Integer.toHexString(cs.getContentSourceType().getName().hashCode());
-
- String jobName = nameEncoded + SEPARATOR + typeNameEncoded;
-
- if (jobName.length() > 80) {
- throw new IllegalArgumentException("Job names max size is 80 chars due to DB column size restrictions: "
- + jobName);
- }
-
- return jobName;
- }
-
- /**
- * Creates a unique name for a new content source sync job. Calling this
- * method multiple times with the same content source always produces a different name
- * which is useful if you want to schedule an new job that is separate and distinct
- * from any other job in the system.
- *
- * @param cs the content source
- *
- * @return a unique job name that can be used for a new job to sync a given content source
- */
- public static String createUniqueJobName(ContentSource cs) {
- // the quartz table has a limited column width of 80 - but we need to use the names to make jobs unique
- // so encode the names' hashcodes to ensure we fix into the quartz job name column.
- // appendStr is used to make the job unique among others for the same content source.
- String nameEncoded = Integer.toHexString(cs.getName().hashCode());
- String typeNameEncoded = Integer.toHexString(cs.getContentSourceType().getName().hashCode());
- String appendStr = Long.toHexString(System.currentTimeMillis());
-
- String jobName = nameEncoded + SEPARATOR + typeNameEncoded + SEPARATOR + appendStr;
-
- if (jobName.length() > 80) {
- throw new IllegalArgumentException("Job names max size is 80 chars due to DB column size restrictions: "
- + jobName);
- }
-
- return jobName;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/RepoSyncJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/RepoSyncJob.java
index 6c7891d..ff12646 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/RepoSyncJob.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/RepoSyncJob.java
@@ -54,7 +54,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
* nor want this job triggered concurrently. That is, we don't need multiple instances of this job
* running at the same time.
* <p/>
- * Much of the functionality in this class was migrated from {@link ContentSourceSyncJob}.
+ * Much of the functionality in this class was migrated from {@link ContentProviderSyncJob}.
*
* @author Jason Dobies
*/
14 years, 6 months
[rhq] Branch 'content' - modules/enterprise
by jdob
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerLocal.java | 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java | 343 +---------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/DistributionSourceSynchronizer.java | 135 +++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/PackageSourceSynchronizer.java | 218 ++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/RepoSourceSynchronizer.java | 69 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/ContentSourceSyncJob.java | 74 --
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/ContentSourceManagerBeanTest.java | 14
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManagerTest.java | 51 -
9 files changed, 500 insertions(+), 416 deletions(-)
New commits:
commit 90157a5795bfc787ac8e048c66954ba2f6a785e9
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Tue Nov 24 11:50:18 2009 -0500
Work towards refactoring what is done in the content provider sync v. an individual repo sync.
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 15e4b08..19bd33b 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
@@ -930,7 +930,7 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
// we really want NEVER, but support tests that might be in a tx
- public ContentSourceSyncResults mergeContentSourceSyncReport(ContentSource contentSource,
+ public ContentSourceSyncResults mergeDistributionSyncReport(ContentSource contentSource,
DistributionSyncReport report, ContentSourceSyncResults syncResults) {
try {
StringBuilder progress = new StringBuilder();
@@ -972,7 +972,7 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
// we really want NEVER, but support tests that might be in a tx
- public ContentSourceSyncResults mergeContentSourceSyncReport(ContentSource contentSource, PackageSyncReport report,
+ public ContentSourceSyncResults mergePackageSyncReport(ContentSource contentSource, PackageSyncReport report,
Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous,
ContentSourceSyncResults syncResults) {
try {
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 cea083c..df7c91e 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
@@ -400,7 +400,8 @@ public interface ContentSourceManagerLocal {
* @return the updated syncResults that includes more summary information in the results string that indicates what
* was done
*/
- ContentSourceSyncResults mergeContentSourceSyncReport(ContentSource contentSource, PackageSyncReport report,
+ ContentSourceSyncResults mergePackageSyncReport(ContentSource contentSource,
+ PackageSyncReport report,
Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous,
ContentSourceSyncResults syncResults);
@@ -414,8 +415,9 @@ public interface ContentSourceManagerLocal {
* @return the updated syncResults that includes more summary information in the results string that indicates what
* was done
*/
- ContentSourceSyncResults mergeContentSourceSyncReport(ContentSource contentSource, DistributionSyncReport report,
- ContentSourceSyncResults syncResults);
+ ContentSourceSyncResults mergeDistributionSyncReport(ContentSource contentSource,
+ DistributionSyncReport report,
+ ContentSourceSyncResults syncResults);
void _mergeContentSourceSyncReportUpdateRepo(int contentSourceId);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java
index e5e42ba..ba26d28 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java
@@ -40,22 +40,17 @@ import org.rhq.core.domain.content.ContentSource;
import org.rhq.core.domain.content.ContentSourceSyncResults;
import org.rhq.core.domain.content.ContentSourceSyncStatus;
import org.rhq.core.domain.content.ContentSourceType;
-import org.rhq.core.domain.content.Distribution;
-import org.rhq.core.domain.content.DistributionFile;
-import org.rhq.core.domain.content.Package;
-import org.rhq.core.domain.content.PackageVersion;
-import org.rhq.core.domain.content.PackageVersionContentSource;
import org.rhq.core.domain.content.Repo;
-import org.rhq.core.domain.criteria.RepoCriteria;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageControl;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.content.ContentSourceManagerLocal;
-import org.rhq.enterprise.server.content.DistributionManagerLocal;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.content.metadata.ContentSourceMetadataManagerLocal;
import org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment;
import org.rhq.enterprise.server.plugin.pc.content.metadata.ContentSourcePluginMetadataManager;
+import org.rhq.enterprise.server.plugin.pc.content.sync.DistributionSourceSynchronizer;
+import org.rhq.enterprise.server.plugin.pc.content.sync.PackageSourceSynchronizer;
+import org.rhq.enterprise.server.plugin.pc.content.sync.RepoSourceSynchronizer;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -63,6 +58,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
* come from the content plugins themselves.
*
* @author John Mazzitelli
+ * @author Jason Dobies
*/
public class ContentProviderManager {
private static final Log log = LogFactory.getLog(ContentProviderManager.class);
@@ -70,6 +66,10 @@ public class ContentProviderManager {
private ContentServerPluginManager pluginManager;
private Map<ContentSource, ContentProvider> adapters;
+ private RepoSourceSynchronizer repoSourceSynchronizer = new RepoSourceSynchronizer();
+ private PackageSourceSynchronizer packageSourceSynchronizer = new PackageSourceSynchronizer();
+ private DistributionSourceSynchronizer distributionSourceSynchronizer = new DistributionSourceSynchronizer();
+
// This is used as a monitor lock to the synchronizeContentSource method;
// it helps us avoid two content sources getting synchronized at the same time.
private final Object synchronizeContentSourceLock = new Object();
@@ -148,7 +148,6 @@ public class ContentProviderManager {
// append to this as we go along, building a status report
StringBuilder progress = new StringBuilder();
- long start = System.currentTimeMillis();
try {
ContentSource contentSource = contentSourceManager
@@ -188,188 +187,8 @@ public class ContentProviderManager {
return false;
}
- // If the provider is capable of syncing repos, do that call first
- if (provider instanceof RepoSource) {
- progress.append(new Date()).append(": ");
- progress.append("Asking content provider for repositories to import...");
-
- RepoSource repoSource = (RepoSource) provider;
-
- start = System.currentTimeMillis();
-
- // Call to the plugin
- RepoImportReport report = repoSource.importRepos();
-
- repoManager.processRepoImportReport(overlord, report, contentSourceId, progress);
-
- log.info("importRepos: [" + contentSource.getName() + "]: report has been merged ("
- + (System.currentTimeMillis() - start) + ")ms");
- }
-
- // ------------------
- // NOTE: Ultimately, this will be moved out as repos get their own schedules. For now,
- // simply synchronize *all* repos for this provider.
- // ------------------
-
- // If the provider is capable of handling packages, perform the package synchronization
- // portion of the sync
- if (provider instanceof PackageSource) {
- PackageSource packageSource = (PackageSource) provider;
-
- RepoCriteria reposForContentSource = new RepoCriteria();
- reposForContentSource.addFilterContentSourceIds(contentSourceId);
- reposForContentSource.addFilterCandidate(false); // Don't sync packages for candidates
-
- List<Repo> repos = repoManager.findReposByCriteria(overlord, reposForContentSource);
-
- // Temporary functionality: loop for all repos that use this content source
- for (Repo repo : repos) {
- // Convert the existing package list for this repo into DTOs for the API
- // --------------------------------------------
- List<PackageVersionContentSource> existingPVCS; // already know about this source
- Set<ContentProviderPackageDetails> allDetails; // send to plugin
- Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> keyPVCSMap;
-
- start = System.currentTimeMillis();
-
- existingPVCS = contentSourceManager
- .getPackageVersionsFromContentSourceForRepo(subjMgr.getOverlord(),
- contentSource.getId(), repo.getId());
-
- int existingCount = existingPVCS.size();
- keyPVCSMap = new HashMap<ContentProviderPackageDetailsKey,
- PackageVersionContentSource>(existingCount);
- allDetails = new HashSet<ContentProviderPackageDetails>(existingCount);
-
- translateDomainToDto(existingPVCS, allDetails, keyPVCSMap);
-
- log.info("synchronizePackages: [" + contentSource.getName() +
- "]: loaded existing list of size=["
- + existingCount + "] (" + (System.currentTimeMillis() - start) + ")ms");
-
- progress.append(existingCount).append('\n');
- progress.append(new Date()).append(": ");
- progress.append("Asking content source to update the list of packages...");
- results.setResults(progress.toString());
- results = contentSourceManager.mergeContentSourceSyncResults(results);
- start = System.currentTimeMillis();
-
- PackageSyncReport report; // the plugin will fill this in for us
- report = new PackageSyncReport();
-
- packageSource.synchronizePackages(repo.getName(), report, allDetails);
-
- log.info("synchronizePackages: [" + contentSource.getName() +
- "]: got sync report from adapter=["
- + report + "] (" + (System.currentTimeMillis() - start) + ")ms");
-
- progress.append("new=").append(report.getNewPackages().size());
- progress.append(", updated=").append(report.getUpdatedPackages().size());
- progress.append(", deleted=").append(report.getDeletedPackages().size())
- .append('\n');
- progress.append(new Date()).append(": ");
- progress.append("FULL SUMMARY FOLLOWS:").append('\n');
- progress.append(report.getSummary()).append('\n');
- progress.append(new Date()).append(": ");
- progress.append("Merging the updated list of packages to database").append('\n');
- results.setResults(progress.toString());
- results = contentSourceManager.mergeContentSourceSyncResults(results);
- start = System.currentTimeMillis();
-
- results = contentSourceManager
- .mergeContentSourceSyncReport(contentSource, report, keyPVCSMap, results);
-
- }
-
- // Reset our progress string to the full results including the text added by the merge
- progress.setLength(0);
- progress.append(results.getResults());
-
- log.info(
- "synchronizePackages: [" + contentSource.getName() + "]: report has been merged ("
- + (System.currentTimeMillis() - start) + ")ms");
-
- progress.append(new Date()).append(": ").append("DONE.");
- results.setResults(progress.toString());
- results.setStatus(ContentSourceSyncStatus.SUCCESS);
- results = contentSourceManager.mergeContentSourceSyncResults(results);
- }
-
- log.info("Checking if provider: " + provider + " is a DistributionSource");
- if (provider instanceof DistributionSource) {
- log.info("synchronizeContentSource(" + contentSourceId +
- "): this source is a DistributionSource");
- log.info("We will skip the sync for now until PackageSource is working.");
-
- DistributionSource distSource = (DistributionSource) provider;
- RepoCriteria reposForContentSource = new RepoCriteria();
- reposForContentSource.addFilterContentSourceIds(contentSourceId);
- reposForContentSource.addFilterCandidate(false); // Don't sync packages for candidates
- List<Repo> repos = repoManager.findReposByCriteria(overlord, reposForContentSource);
-
- // Temporary functionality: loop for all repos that use this content source
- for (Repo repo : repos) {
- log.info(
- "ContentProviderManager::synchronizeContentSource DistributionSource would " +
- "be syncing repo: " + repo.getName());
-
- start = System.currentTimeMillis();
-
- PageControl pc = PageControl.getUnlimitedInstance();
- log.debug("Looking up existing distributions for repoId: " + repo.getId());
- List<Distribution> dists = repoManager
- .findAssociatedDistributions(overlord, repo.getId(), pc);
- log.debug("Found " + dists.size() + " Distributions for repoId " + repo.getId());
-
- progress.append(dists.size()).append('\n');
- progress.append(new Date()).append(": ");
- progress.append("Asking content source to update the list of packages...");
-
- DistributionSyncReport distReport = new DistributionSyncReport(repo.getId());
- List<DistributionDetails> distDetails = new ArrayList<DistributionDetails>(
- dists.size());
- translateDomainToDto(dists, distDetails);
-
- distSource.synchronizeDistribution(repo.getName(), distReport, distDetails);
-
- log.info("synchronizeDistributions: [" + contentSource.getName() +
- "]: loaded existing list of size=["
- + dists.size() + "] (" + (System.currentTimeMillis() - start) + ")ms");
-
- results.setResults(progress.toString());
- results = contentSourceManager.mergeContentSourceSyncResults(results);
- start = System.currentTimeMillis();
-
-
- distSource.synchronizeDistribution(repo.getName(), distReport, distDetails);
- log.info("synchronizeDistributions: [" + contentSource.getName() +
- "]: got sync report from adapter=["
- + distReport + "] (" + (System.currentTimeMillis() - start) + ")ms");
-
- progress.append("new=").append(distReport.getDistributions().size());
-
- progress.append(", deleted=").append(distReport.getDeletedDistributions().size())
- .append('\n');
- results.setResults(progress.toString());
- results = contentSourceManager.mergeContentSourceSyncResults(results);
- start = System.currentTimeMillis();
- results = contentSourceManager
- .mergeContentSourceSyncReport(contentSource, distReport, results);
- }
- // Reset our progress string to the full results including the text added by the merge
- progress.setLength(0);
- progress.append(results.getResults());
-
- log.info("synchronizeDistributions: [" + contentSource.getName() +
- "]: report has been merged ("
- + (System.currentTimeMillis() - start) + ")ms");
-
- progress.append(new Date()).append(": ").append("DONE.");
- results.setResults(progress.toString());
- results.setStatus(ContentSourceSyncStatus.SUCCESS);
- results = contentSourceManager.mergeContentSourceSyncResults(results);
-
- }
+ repoSourceSynchronizer.synchronizeCandidateRepos(contentSourceId,
+ repoManager, provider, overlord, progress, contentSource);
}
catch (Throwable t) {
if (results != null) {
@@ -405,6 +224,35 @@ public class ContentProviderManager {
return true;
}
+
+ public boolean synchronizeRepo(int repoId) throws Exception {
+
+ RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
+ ContentSourceManagerLocal contentSourceManager = LookupUtil.getContentSourceManager();
+ SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
+
+ Subject overlord = subjectManager.getOverlord();
+
+ // Load the repo to sync
+ Repo repo = repoManager.getRepo(overlord, repoId);
+ if (repo == null) {
+ throw new Exception("Invalid repo ID specified for sync: " + repoId);
+ }
+
+ // Synchronize every content provider associated with the repo
+ for (ContentSource source : repo.getContentSources()) {
+ ContentProvider provider = getIsolatedContentProvider(source.getId());
+
+ packageSourceSynchronizer.synchronizePackageMetadata(repo, source, provider);
+ packageSourceSynchronizer.synchronizePackageBits(repo, source, provider);
+
+ distributionSourceSynchronizer.synchronizeDistributionMetadata(repo, source, provider);
+ distributionSourceSynchronizer.synchronizeDistributionBits(repo, source, provider);
+ }
+
+ return true;
+ }
+
/**
* Tests the connection to the content source that has the given ID.
*
@@ -470,8 +318,6 @@ public class ContentProviderManager {
e);
throw new InitializationException(e);
}
-
- return;
}
/**
@@ -520,6 +366,28 @@ public class ContentProviderManager {
}
/**
+ * Given a ID to a content source, this returns the adapter that is responsible for communicating
+ * with that content source where that adapter object will ensure invocations on it are isolated
+ * to its plugin classloader.
+ *
+ * @param contentProviderId an ID to a {@link ContentSource}
+ * @return the adapter that is communicating with the content source, isolated to its classloader
+ * @throws RuntimeException if there is no content source with the given ID
+ */
+ public ContentProvider getIsolatedContentProvider(int contentProviderId) throws RuntimeException {
+ synchronized (this.adapters) {
+ for (ContentSource contentSource : this.adapters.keySet()) {
+ if (contentSource.getId() == contentProviderId) {
+ return getIsolatedContentSourceAdapter(contentSource);
+ }
+ }
+ }
+
+ throw new RuntimeException(
+ "Content source ID [" + contentProviderId + "] doesn't exist; can't get adapter");
+ }
+
+ /**
* Tells this manager to initialize itself which will initialize all the adapters.
*
* <p>This is protected so only the plugin container and subclasses can use it.</p>
@@ -594,28 +462,6 @@ public class ContentProviderManager {
}
/**
- * Given a ID to a content source, this returns the adapter that is responsible for communicating
- * with that content source where that adapter object will ensure invocations on it are isolated
- * to its plugin classloader.
- *
- * @param contentProviderId an ID to a {@link ContentSource}
- * @return the adapter that is communicating with the content source, isolated to its classloader
- * @throws RuntimeException if there is no content source with the given ID
- */
- public ContentProvider getIsolatedContentProvider(int contentProviderId) throws RuntimeException {
- synchronized (this.adapters) {
- for (ContentSource contentSource : this.adapters.keySet()) {
- if (contentSource.getId() == contentProviderId) {
- return getIsolatedContentSourceAdapter(contentSource);
- }
- }
- }
-
- throw new RuntimeException(
- "Content source ID [" + contentProviderId + "] doesn't exist; can't get adapter");
- }
-
- /**
* This returns the adapter that is responsible for communicating with the given content source
* where that adaptor object will ensure invocations on it are isolated to its plugin classloader.
*
@@ -715,73 +561,6 @@ public class ContentProviderManager {
}
/**
- * Translates the domain representation of a list of packages into DTOs used in the plugin APIs.
- * During the translation the two collections (allDetails and keyPVCSMap) will be populated with
- * different views into the data.
- *
- * @param existingPVCS list of packages in the form of the wrapper object linking them to
- * the content source
- * @param allDetails set of all translated package DTOs
- * @param keyPVCSMap mapping of package version key to package domain object
- */
- private void translateDomainToDto(List<PackageVersionContentSource> existingPVCS,
- Set<ContentProviderPackageDetails> allDetails,
- Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> keyPVCSMap) {
-
- for (PackageVersionContentSource pvcs : existingPVCS) {
- PackageVersion pv = pvcs.getPackageVersionContentSourcePK().getPackageVersion();
- Package p = pv.getGeneralPackage();
- ResourceType rt = p.getPackageType().getResourceType();
-
- ContentProviderPackageDetailsKey key;
- 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());
- details.setDisplayName(pv.getDisplayName());
- details.setDisplayVersion(pv.getDisplayVersion());
- details.setExtraProperties(pv.getExtraProperties());
- details.setFileCreatedDate(pv.getFileCreatedDate());
- details.setFileName(pv.getFileName());
- details.setFileSize(pv.getFileSize());
- details.setLicenseName(pv.getLicenseName());
- details.setLicenseVersion(pv.getLicenseVersion());
- details.setLocation(pvcs.getLocation());
- details.setLongDescription(pv.getLongDescription());
- details.setMD5(pv.getMD5());
- details.setMetadata(pv.getMetadata());
- details.setSHA256(pv.getSHA256());
- details.setShortDescription(pv.getShortDescription());
-
- allDetails.add(details);
- keyPVCSMap.put(key, pvcs);
- }
- }
-
- 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());
- 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());
- detail.addFile(dfd);
- }
- distDetails.add(detail);
- }
- }
-
- /**
* This will handle invocations to an object ensuring that the call is isolated to within the
* appropriate classloader.
*/
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
new file mode 100644
index 0000000..97c29b4
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/DistributionSourceSynchronizer.java
@@ -0,0 +1,135 @@
+/*
+* RHQ Management Platform
+* Copyright (C) 2009 Red Hat, Inc.
+* All rights reserved.
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License, version 2, as
+* published by the Free Software Foundation, and/or the GNU Lesser
+* General Public License, version 2.1, also as published by the Free
+* Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License and the GNU Lesser General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License
+* and the GNU Lesser General Public License along with this program;
+* if not, write to the Free Software Foundation, Inc.,
+* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+package org.rhq.enterprise.server.plugin.pc.content.sync;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+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.Distribution;
+import org.rhq.core.domain.content.DistributionFile;
+import org.rhq.core.domain.content.Repo;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
+import org.rhq.enterprise.server.content.ContentSourceManagerLocal;
+import org.rhq.enterprise.server.content.DistributionManagerLocal;
+import org.rhq.enterprise.server.content.RepoManagerLocal;
+import org.rhq.enterprise.server.plugin.pc.content.ContentProvider;
+import org.rhq.enterprise.server.plugin.pc.content.DistributionDetails;
+import org.rhq.enterprise.server.plugin.pc.content.DistributionFileDetails;
+import org.rhq.enterprise.server.plugin.pc.content.DistributionSource;
+import org.rhq.enterprise.server.plugin.pc.content.DistributionSyncReport;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * @author Jason Dobies
+ */
+public class DistributionSourceSynchronizer {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ private RepoManagerLocal repoManager;
+ private ContentSourceManagerLocal contentSourceManager;
+ private SubjectManagerLocal subjectManager;
+
+ public DistributionSourceSynchronizer() {
+ repoManager = LookupUtil.getRepoManagerLocal();
+ contentSourceManager = LookupUtil.getContentSourceManager();
+ subjectManager = LookupUtil.getSubjectManager();
+ }
+
+ public void synchronizeDistributionMetadata(Repo repo, ContentSource source,
+ ContentProvider provider) throws Exception {
+ if (!(provider instanceof DistributionSource)) {
+ return;
+ }
+
+ DistributionSource distributionSource = (DistributionSource) provider;
+
+ log.info("Synchronize Distributions: [" + source.getName() +
+ "]: syncing repo [" + repo.getName() + "]");
+
+ // Load existing distributions to send to source
+ // --------------------------------------------
+ long start = System.currentTimeMillis();
+
+ PageControl pc = PageControl.getUnlimitedInstance();
+ Subject overlord = subjectManager.getOverlord();
+ 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());
+ translateDomainToDto(dists, distDetails);
+
+ log.info("Synchronize Distributions: [" + source.getName() +
+ "]: loaded existing list of size=["
+ + dists.size() + "] (" + (System.currentTimeMillis() - start) + ")ms");
+
+ // Ask source to do the sync
+ // --------------------------------------------
+ start = System.currentTimeMillis();
+
+ distributionSource.synchronizeDistribution(repo.getName(), distReport, distDetails);
+
+ log.info("Synchronize Distributions: [" + source.getName() +
+ "]: got sync report from adapter=["
+ + distReport + "] (" + (System.currentTimeMillis() - start) + ")ms");
+
+ contentSourceManager.mergeDistributionSyncReport(source, distReport, null);
+ }
+
+ public void synchronizeDistributionBits(Repo repo, ContentSource source,
+ ContentProvider provider) throws Exception {
+ Subject overlord = subjectManager.getOverlord();
+ contentSourceManager.downloadDistributionBits(overlord, source);
+ }
+
+ 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());
+ 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());
+ 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
new file mode 100644
index 0000000..bff4918
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/PackageSourceSynchronizer.java
@@ -0,0 +1,218 @@
+/*
+* RHQ Management Platform
+* Copyright (C) 2009 Red Hat, Inc.
+* All rights reserved.
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License, version 2, as
+* published by the Free Software Foundation, and/or the GNU Lesser
+* General Public License, version 2.1, also as published by the Free
+* Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License and the GNU Lesser General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License
+* and the GNU Lesser General Public License along with this program;
+* if not, write to the Free Software Foundation, Inc.,
+* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+package org.rhq.enterprise.server.plugin.pc.content.sync;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+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.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.resource.ResourceType;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
+import org.rhq.enterprise.server.content.ContentSourceManagerLocal;
+import org.rhq.enterprise.server.plugin.pc.content.ContentProvider;
+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.PackageSource;
+import org.rhq.enterprise.server.plugin.pc.content.PackageSyncReport;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * @author Jason Dobies
+ */
+public class PackageSourceSynchronizer {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ private ContentSourceManagerLocal contentSourceManager;
+ private SubjectManagerLocal subjectManager;
+
+ public PackageSourceSynchronizer() {
+ contentSourceManager = LookupUtil.getContentSourceManager();
+ subjectManager = LookupUtil.getSubjectManager();
+ }
+
+ public void synchronizePackageMetadata(Repo repo, ContentSource source,
+ ContentProvider provider) throws Exception {
+ if (!(provider instanceof PackageSource)) {
+ return;
+ }
+
+ PackageSource packageSource = (PackageSource) provider;
+
+ // Load packages to send to package source
+ // --------------------------------------------
+ long start = System.currentTimeMillis();
+
+ List<PackageVersionContentSource> existingPVCS; // already know about this source
+ Set<ContentProviderPackageDetails> allDetails; // send to plugin
+ Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> keyPVCSMap;
+
+ Subject overlord = subjectManager.getOverlord();
+ existingPVCS = contentSourceManager.getPackageVersionsFromContentSourceForRepo(
+ overlord, source.getId(), repo.getId());
+
+ int existingCount = existingPVCS.size();
+ 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");
+
+ // Ask source to do the sync
+ // --------------------------------------------
+ start = System.currentTimeMillis();
+
+ 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");
+
+ // Merge in the results of the synchronization
+ // --------------------------------------------
+ start = System.currentTimeMillis();
+
+ contentSourceManager.mergePackageSyncReport(source, report, keyPVCSMap, null);
+
+ log.info("Synchronize Packages: [" + source.getName() +
+ "]: merged sync report=(" +
+ (System.currentTimeMillis() - start) + ")ms");
+ }
+
+ public void synchronizePackageBits(Repo repo, ContentSource contentSource,
+ ContentProvider provider) throws Exception {
+
+ if (!(provider instanceof PackageSource)) {
+ return;
+ }
+
+ long start = System.currentTimeMillis();
+
+ List<PackageVersionContentSource> packageVersionContentSources;
+
+ // make sure we only get back those that have not yet been loaded
+ // TODO: consider paging here - do we have to load them all in at once or can we do them in chunks?
+ PageControl pc = PageControl.getUnlimitedInstance();
+ Subject overlord = subjectManager.getOverlord();
+ packageVersionContentSources = contentSourceManager
+ .getUnloadedPackageVersionsFromContentSource(overlord,
+ contentSource.getId(), pc);
+
+ // For each unloaded package version, let's download them now.
+ // This can potentially take a very long time.
+ // We abort the entire download if we fail getting just one package.
+ for (PackageVersionContentSource item : packageVersionContentSources) {
+ PackageVersionContentSourcePK pk = item.getPackageVersionContentSourcePK();
+
+ try {
+ if (log.isDebugEnabled()) {
+ 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.";
+
+ throw new Exception(errorMsg, e);
+ }
+ }
+
+ log.info("All package bits for content source [" + contentSource.getName() +
+ "] have been downloaded."
+ + "The downloads started at [" + new Date(start) + "] and ended at [" + new Date() + "]");
+
+ }
+
+ /**
+ * Translates the domain representation of a list of packages into DTOs used in the plugin APIs.
+ * During the translation the two collections (allDetails and keyPVCSMap) will be populated with
+ * different views into the data.
+ *
+ * @param existingPVCS list of packages in the form of the wrapper object linking them to
+ * the content source
+ * @param allDetails set of all translated package DTOs
+ * @param keyPVCSMap mapping of package version key to package domain object
+ */
+ private void translateDomainToDto(List<PackageVersionContentSource> existingPVCS,
+ Set<ContentProviderPackageDetails> allDetails,
+ Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> keyPVCSMap) {
+
+ for (PackageVersionContentSource pvcs : existingPVCS) {
+ PackageVersion pv = pvcs.getPackageVersionContentSourcePK().getPackageVersion();
+ org.rhq.core.domain.content.Package p = pv.getGeneralPackage();
+ ResourceType rt = p.getPackageType().getResourceType();
+
+ ContentProviderPackageDetailsKey key;
+ 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());
+ details.setDisplayName(pv.getDisplayName());
+ details.setDisplayVersion(pv.getDisplayVersion());
+ details.setExtraProperties(pv.getExtraProperties());
+ details.setFileCreatedDate(pv.getFileCreatedDate());
+ details.setFileName(pv.getFileName());
+ details.setFileSize(pv.getFileSize());
+ details.setLicenseName(pv.getLicenseName());
+ details.setLicenseVersion(pv.getLicenseVersion());
+ details.setLocation(pvcs.getLocation());
+ details.setLongDescription(pv.getLongDescription());
+ details.setMD5(pv.getMD5());
+ details.setMetadata(pv.getMetadata());
+ details.setSHA256(pv.getSHA256());
+ details.setShortDescription(pv.getShortDescription());
+
+ allDetails.add(details);
+ keyPVCSMap.put(key, pvcs);
+ }
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/RepoSourceSynchronizer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/RepoSourceSynchronizer.java
new file mode 100644
index 0000000..d8142b2
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/RepoSourceSynchronizer.java
@@ -0,0 +1,69 @@
+/*
+* RHQ Management Platform
+* Copyright (C) 2009 Red Hat, Inc.
+* All rights reserved.
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License, version 2, as
+* published by the Free Software Foundation, and/or the GNU Lesser
+* General Public License, version 2.1, also as published by the Free
+* Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License and the GNU Lesser General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License
+* and the GNU Lesser General Public License along with this program;
+* if not, write to the Free Software Foundation, Inc.,
+* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+package org.rhq.enterprise.server.plugin.pc.content.sync;
+
+import java.util.Date;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.content.ContentSource;
+import org.rhq.enterprise.server.content.RepoManagerLocal;
+import org.rhq.enterprise.server.plugin.pc.content.ContentProvider;
+import org.rhq.enterprise.server.plugin.pc.content.RepoImportReport;
+import org.rhq.enterprise.server.plugin.pc.content.RepoSource;
+
+/**
+ * @author Jason Dobies
+ */
+public class RepoSourceSynchronizer {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public void synchronizeCandidateRepos(int contentSourceId, RepoManagerLocal repoManager,
+ ContentProvider provider, Subject overlord,
+ StringBuilder progress, ContentSource contentSource)
+ throws Exception {
+
+ if (!(provider instanceof RepoSource)) {
+ return;
+ }
+
+ progress.append(new Date()).append(": ");
+ progress.append("Asking content provider for repositories to import...");
+
+ RepoSource repoSource = (RepoSource) provider;
+
+ long start = System.currentTimeMillis();
+
+ // Call to the plugin
+ RepoImportReport report = repoSource.importRepos();
+
+ repoManager.processRepoImportReport(overlord, report, contentSourceId, progress);
+
+ log.info("importRepos: [" + contentSource.getName() + "]: report has been merged ("
+ + (System.currentTimeMillis() - start) + ")ms");
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/ContentSourceSyncJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/ContentSourceSyncJob.java
index 3d8e7ce..67ca931 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/ContentSourceSyncJob.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/ContentSourceSyncJob.java
@@ -142,84 +142,10 @@ public class ContentSourceSyncJob implements StatefulJob {
// so we should abort and let that already running sync take care of everything.
boolean completed = contentManager.internalSynchronizeContentSource(contentSourceId);
- // That might have taken a long time and a user might have updated
- // the content source in the meantime (like, switching to download mode of NEVER)
- // so let's get an updated content source.
- overlord = subjectManager.getOverlord();
- contentSource = contentManager
- .getContentSourceByNameAndType(overlord, contentSourceName, contentSourceTypeName);
-
- if (contentSource == null) {
- throw new Exception("Content source was deleted, aborting sync job: " + contentSourceName + "|"
- + contentSourceTypeName);
- }
-
if (!completed) {
log.info("Content source [" + contentSourceName + "] is currently being synchronized already. "
+ "Please wait for the current sync job to finish.");
- } else if (contentSource.getDownloadMode() == DownloadMode.NEVER) {
- log.info("Content source [" + contentSourceName + "] is fully synchronized now. "
- + "It is marked to never download bits - bits will not be downloaded now.");
- } else if (contentSource.isLazyLoad()) {
- log.info("Content source [" + contentSourceName + "] is fully synchronized now. "
- + "It is marked for lazy loading - bits will not be downloaded now.");
- } else {
- log.info("Content source [" + contentSourceName + "] is fully synchronized now. "
- + "It is not marked for lazy loading - downloading all bits now.");
-
- long start = System.currentTimeMillis();
-
- List<PackageVersionContentSource> packageVersionContentSources;
-
- // make sure we only get back those that have not yet been loaded
- // TODO: consider paging here - do we have to load them all in at once or can we do them in chunks?
- PageControl pc = PageControl.getUnlimitedInstance();
- overlord = subjectManager.getOverlord();
- packageVersionContentSources = contentManager.getUnloadedPackageVersionsFromContentSource(overlord,
- contentSourceId, pc);
-
- // For each unloaded package version, let's download them now.
- // This can potentially take a very long time.
- // We abort the entire download if we fail getting just one package.
- for (PackageVersionContentSource item : packageVersionContentSources) {
- PackageVersionContentSourcePK pk = item.getPackageVersionContentSourcePK();
-
- try {
- if (log.isDebugEnabled()) {
- log.debug("Downloading package version [" + pk.getPackageVersion() + "] located at ["
- + item.getLocation() + "]" + "] from [" + pk.getContentSource() + "]...");
- }
-
- overlord = subjectManager.getOverlord();
- contentManager.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.";
-
- throw new Exception(errorMsg, e);
- }
- }
-
- log.info("All package bits for content source [" + contentSourceName + "] have been downloaded."
- + "The downloads started at [" + new Date(start) + "] and ended at [" + new Date() + "]");
- }
-
- // Get DistributionSource bits.
- // Note: We are ignoring LazyLoad for Distributions, we will always perform an eager fetch for the "bits".
- if (!completed) {
- log.info("Content source [" + contentSourceName + "] is currently being synchronized already. "
- + "Please wait for the current sync job to finish. [DistributionSync]");
- } else {
- log.info("Content source [" + contentSourceName + "] is fully synchronized now. "
- + "Downloading all Distribution bits now.");
- long start = System.currentTimeMillis();
- contentManager.downloadDistributionBits(overlord, contentSource);
- log.info("All distribution bits for content source [" + contentSourceName + "] have been downloaded."
- + "The downloads started at [" + new Date(start) + "] and ended at [" + new Date() + "]");
}
-
- return;
}
/**
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 7dcd2ff..47cb78f 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
@@ -279,7 +279,7 @@ public class ContentSourceManagerBeanTest extends AbstractEJB3Test {
results = contentSourceManager.persistContentSourceSyncResults(results);
assert results != null;
- results = contentSourceManager.mergeContentSourceSyncReport(contentSource, report, previous, results);
+ results = contentSourceManager.mergePackageSyncReport(contentSource, report, previous, results);
assert results != null;
// Verify the product version was created
@@ -452,7 +452,7 @@ public class ContentSourceManagerBeanTest extends AbstractEJB3Test {
previous = new HashMap<ContentProviderPackageDetailsKey, PackageVersionContentSource>();
// ADD: merge the report!
- results = contentSourceManager.mergeContentSourceSyncReport(contentSource, report, previous, results);
+ results = contentSourceManager.mergePackageSyncReport(contentSource, report, previous, results);
assert results != null;
// see the package version has been assigned to the content source
@@ -483,7 +483,7 @@ public class ContentSourceManagerBeanTest extends AbstractEJB3Test {
report.addUpdatedPackage(details);
// UPDATE: merge the report!
- results = contentSourceManager.mergeContentSourceSyncReport(contentSource, report, previous, results);
+ results = contentSourceManager.mergePackageSyncReport(contentSource, report, previous, results);
assert results != null;
// see the package version is still assigned to the content source
@@ -504,7 +504,7 @@ public class ContentSourceManagerBeanTest extends AbstractEJB3Test {
report.addDeletePackage(details);
// REMOVE: merge the report!
- results = contentSourceManager.mergeContentSourceSyncReport(contentSource, report, previous, results);
+ results = contentSourceManager.mergePackageSyncReport(contentSource, report, previous, results);
assert results != null;
// see the package version is gone
@@ -576,7 +576,7 @@ public class ContentSourceManagerBeanTest extends AbstractEJB3Test {
previous = new HashMap<ContentProviderPackageDetailsKey, PackageVersionContentSource>();
// ADD: merge the report!
- results = contentSourceManager.mergeContentSourceSyncReport(contentSource, report, previous, results);
+ results = contentSourceManager.mergePackageSyncReport(contentSource, report, previous, results);
assert results != null;
List<PackageVersionContentSource> unloaded;
@@ -597,7 +597,7 @@ public class ContentSourceManagerBeanTest extends AbstractEJB3Test {
report.addDeletePackage(details);
// REMOVE: merge the report!
- results = contentSourceManager.mergeContentSourceSyncReport(contentSource, report, previous, results);
+ results = contentSourceManager.mergePackageSyncReport(contentSource, report, previous, results);
assert results != null;
// check the count - note the repo's PV remains intact!!
@@ -876,7 +876,7 @@ public class ContentSourceManagerBeanTest extends AbstractEJB3Test {
results = contentSourceManager.persistContentSourceSyncResults(results);
assert results != null;
- contentSourceManager.mergeContentSourceSyncReport(contentSource, report, previous, results);
+ contentSourceManager.mergePackageSyncReport(contentSource, report, previous, results);
List<PackageVersion> inRepo;
inRepo = repoManager.findPackageVersionsInRepo(overlord, repo.getId(), PageControl.getUnlimitedInstance());
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManagerTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManagerTest.java
index 5c2565f..60f9fd1 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManagerTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManagerTest.java
@@ -23,7 +23,6 @@
package org.rhq.enterprise.server.plugin.pc.content;
import java.io.InputStream;
-import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -31,7 +30,6 @@ import java.util.Set;
import java.util.HashSet;
import javax.persistence.EntityManager;
-import javax.persistence.Query;
import javax.transaction.TransactionManager;
import org.testng.annotations.AfterMethod;
@@ -68,9 +66,6 @@ public class ContentProviderManagerTest extends AbstractEJB3Test {
private static final String PACKAGE_TYPE_NAME = "testPackageType";
private static final String RESOURCE_TYPE_NAME = "testResourceType";
private static final String PLUGIN_NAME = "testPlugin";
- private static final String PACKAGE_NAME = "package1";
- private static final String PACKAGE_VERSION = "1.0";
- private static final String PACKAGE_ARCH = "noarch";
private static final String CUSTOM_IMPORTED_REPO_NAME = "customImportedRepo";
private static final String EXISTING_IMPORTED_REPO_NAME = "testRepoImportedExisting";
@@ -350,31 +345,6 @@ public class ContentProviderManagerTest extends AbstractEJB3Test {
retrievedRepos = repoManager.getRepoByName("testRepoFoo");
assert retrievedRepos.size() == 0;
- // Verify Packages
- // --------------------------------------------
- TransactionManager tx = getTransactionManager();
- tx.begin();
- EntityManager entityManager = getEntityManager();
-
- try {
- Query packageQuery = entityManager.createNamedQuery(PackageVersion.QUERY_FIND_BY_PACKAGE_DETAILS_KEY);
- packageQuery.setParameter("packageName", PACKAGE_NAME);
- packageQuery.setParameter("packageTypeName", PACKAGE_TYPE_NAME);
- packageQuery.setParameter("resourceTypeId", testResourceType.getId());
- packageQuery.setParameter("architectureName", PACKAGE_ARCH);
- packageQuery.setParameter("version", PACKAGE_VERSION);
-
- List<PackageVersion> packageList = packageQuery.getResultList();
- assert packageList.size() == 1;
- packagesToDelete.add(packageList.get(0).getId());
- } finally {
- tx.rollback();
- }
-
- // -> Verify the correct repos were requested in the package sync
- List<String> reposRequestedInSync = testProvider.getReposRequestedInSync();
- assert reposRequestedInSync.size() == reposThatShouldBeSyncced.size();
- assert reposRequestedInSync.containsAll(reposThatShouldBeSyncced);
}
/**
@@ -382,8 +352,6 @@ public class ContentProviderManagerTest extends AbstractEJB3Test {
*/
private class TestContentProvider implements ContentProvider, PackageSource, RepoSource {
- private List<String> reposRequestedInSync = new ArrayList<String>();
-
public RepoImportReport importRepos() throws Exception {
RepoImportReport report = new RepoImportReport();
@@ -423,14 +391,7 @@ public class ContentProviderManagerTest extends AbstractEJB3Test {
public void synchronizePackages(String repoName, PackageSyncReport report,
Collection<ContentProviderPackageDetails> existingPackages) throws Exception {
- reposRequestedInSync.add(repoName);
-
- ContentProviderPackageDetailsKey key1 = new ContentProviderPackageDetailsKey(PACKAGE_NAME, PACKAGE_VERSION,
- PACKAGE_TYPE_NAME, PACKAGE_ARCH, RESOURCE_TYPE_NAME, PLUGIN_NAME);
- ContentProviderPackageDetails pkg1 = new ContentProviderPackageDetails(key1);
- pkg1.setLocation("repo/foo");
-
- report.addNewPackage(pkg1);
+ // No-op
}
public void initialize(Configuration configuration) throws Exception {
@@ -446,14 +407,8 @@ public class ContentProviderManagerTest extends AbstractEJB3Test {
}
public InputStream getInputStream(String location) throws Exception {
- String fakeBits = "Totally fake bits";
- ByteArrayInputStream bis = new ByteArrayInputStream(fakeBits.getBytes());
-
- return bis;
- }
-
- public List<String> getReposRequestedInSync() {
- return reposRequestedInSync;
+ // No-op
+ return null;
}
}
14 years, 6 months
[rhq] Branch 'raw-config' - modules/core
by John Sanda
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementFactory.java | 32 +
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementFactoryImpl.java | 89 +++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java | 8
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManagerInitializer.java | 4
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactory.java | 32 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImpl.java | 89 ---
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigManagementFactoryImplTest.java | 273 ++++++++++
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerTest.java | 12
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImplTest.java | 273 ----------
9 files changed, 406 insertions(+), 406 deletions(-)
New commits:
commit 4ff1b8440d4e0bdbd1a24995d8f03420d2093253
Author: John Sanda <john(a)localhost.localdomain>
Date: Tue Nov 24 11:14:54 2009 -0500
[US 6] Renaming LoadResourceConfigurationFactory to ConfigManagementFactory
Also renaming implemenators and variables to be consistent.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementFactory.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementFactory.java
new file mode 100644
index 0000000..fc44dcd
--- /dev/null
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementFactory.java
@@ -0,0 +1,32 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.pc.configuration;
+
+import org.rhq.core.clientapi.agent.PluginContainerException;
+
+public interface ConfigManagementFactory {
+
+ ConfigManagement getStrategy(int resourceId) throws PluginContainerException;
+
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementFactoryImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementFactoryImpl.java
new file mode 100644
index 0000000..66aef29
--- /dev/null
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementFactoryImpl.java
@@ -0,0 +1,89 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.pc.configuration;
+
+import static org.rhq.core.domain.configuration.definition.ConfigurationFormat.*;
+
+import org.rhq.core.pc.util.ComponentService;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.clientapi.agent.PluginContainerException;
+import org.apache.maven.artifact.versioning.ComparableVersion;
+
+public class ConfigManagementFactoryImpl implements ConfigManagementFactory {
+
+ private static final ComparableVersion NON_LEGACY_AMPS_VERSION = new ComparableVersion("2.1");
+
+ private ComponentService componentService;
+
+ private ConfigurationUtilityService configUtilityService = new ConfigurationUtilityServiceImpl();
+
+ public void setComponentService(ComponentService componentService) {
+ this.componentService = componentService;
+ }
+
+ public ConfigManagement getStrategy(int resourceId) throws PluginContainerException {
+ ConfigManagement loadConfig = createStrategy(resourceId);
+ initStrategyDependencies(loadConfig);
+
+ return loadConfig;
+ }
+
+ private void initStrategyDependencies(ConfigManagement loadConfig) {
+ loadConfig.setComponentService(componentService);
+ loadConfig.setConfigurationUtilityService(configUtilityService);
+ }
+
+ private ConfigManagement createStrategy(int resourceId) throws PluginContainerException {
+ String ampsVersion = componentService.getAmpsVersion(resourceId);
+
+ if (isLegacyVersion(ampsVersion)) {
+ return new LegacyConfigManagement();
+ }
+
+ ResourceType resourceType = componentService.getResourceType(resourceId);
+
+ if (isStructured(resourceType)) {
+ return new LoadStructured();
+ }
+
+ if (isRaw(resourceType)) {
+ return new RawConfigManagement();
+ }
+
+ // else format is both structured and raw
+ return new LoadStructuredAndRaw();
+ }
+
+ private boolean isLegacyVersion(String ampsVersion) {
+ return new ComparableVersion(ampsVersion).compareTo(NON_LEGACY_AMPS_VERSION) < 0;
+ }
+
+ private boolean isStructured(ResourceType resourceType) {
+ return resourceType.getResourceConfigurationDefinition().getConfigurationFormat().equals(STRUCTURED);
+ }
+
+ private boolean isRaw(ResourceType resourceType) {
+ return resourceType.getResourceConfigurationDefinition().getConfigurationFormat().equals(RAW);
+ }
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java
index 25ae1e7..dd38c78 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java
@@ -72,7 +72,7 @@ public class ConfigurationManager extends AgentService implements ContainerServi
private ComponentService componentService;
- private LoadResourceConfigurationFactory loadConfigFactory;
+ private ConfigManagementFactory configMgmtFactory;
public ConfigurationManager() {
super(ConfigurationAgentService.class);
@@ -108,8 +108,8 @@ public class ConfigurationManager extends AgentService implements ContainerServi
this.componentService = componentService;
}
- public void setLoadConfigFactory(LoadResourceConfigurationFactory factory) {
- loadConfigFactory = factory;
+ public void setConfigManagementFactory(ConfigManagementFactory factory) {
+ configMgmtFactory = factory;
}
public void updateResourceConfiguration(ConfigurationUpdateRequest request) {
@@ -243,7 +243,7 @@ public class ConfigurationManager extends AgentService implements ContainerServi
public Configuration loadResourceConfiguration(int resourceId)
throws PluginContainerException {
- ConfigManagement loadConfig = loadConfigFactory.getStrategy(resourceId);
+ ConfigManagement loadConfig = configMgmtFactory.getStrategy(resourceId);
Configuration configuration = null;
try {
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManagerInitializer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManagerInitializer.java
index 9208d46..b547e94 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManagerInitializer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManagerInitializer.java
@@ -31,11 +31,11 @@ public class ConfigurationManagerInitializer {
public void initialize(ConfigurationManager manager) {
ComponentService componentService = new ComponentServiceImpl();
- LoadResourceConfigurationFactoryImpl factory = new LoadResourceConfigurationFactoryImpl();
+ ConfigManagementFactoryImpl factory = new ConfigManagementFactoryImpl();
factory.setComponentService(componentService);
manager.setComponentService(componentService);
- manager.setLoadConfigFactory(factory);
+ manager.setConfigManagementFactory(factory);
}
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactory.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactory.java
deleted file mode 100644
index be777be..0000000
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactory.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.core.pc.configuration;
-
-import org.rhq.core.clientapi.agent.PluginContainerException;
-
-public interface LoadResourceConfigurationFactory {
-
- ConfigManagement getStrategy(int resourceId) throws PluginContainerException;
-
-}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImpl.java
deleted file mode 100644
index ad5ece4..0000000
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImpl.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.core.pc.configuration;
-
-import static org.rhq.core.domain.configuration.definition.ConfigurationFormat.*;
-
-import org.rhq.core.pc.util.ComponentService;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.clientapi.agent.PluginContainerException;
-import org.apache.maven.artifact.versioning.ComparableVersion;
-
-public class LoadResourceConfigurationFactoryImpl implements LoadResourceConfigurationFactory {
-
- private static final ComparableVersion NON_LEGACY_AMPS_VERSION = new ComparableVersion("2.1");
-
- private ComponentService componentService;
-
- private ConfigurationUtilityService configUtilityService = new ConfigurationUtilityServiceImpl();
-
- public void setComponentService(ComponentService componentService) {
- this.componentService = componentService;
- }
-
- public ConfigManagement getStrategy(int resourceId) throws PluginContainerException {
- ConfigManagement loadConfig = createStrategy(resourceId);
- initStrategyDependencies(loadConfig);
-
- return loadConfig;
- }
-
- private void initStrategyDependencies(ConfigManagement loadConfig) {
- loadConfig.setComponentService(componentService);
- loadConfig.setConfigurationUtilityService(configUtilityService);
- }
-
- private ConfigManagement createStrategy(int resourceId) throws PluginContainerException {
- String ampsVersion = componentService.getAmpsVersion(resourceId);
-
- if (isLegacyVersion(ampsVersion)) {
- return new LegacyConfigManagement();
- }
-
- ResourceType resourceType = componentService.getResourceType(resourceId);
-
- if (isStructured(resourceType)) {
- return new LoadStructured();
- }
-
- if (isRaw(resourceType)) {
- return new RawConfigManagement();
- }
-
- // else format is both structured and raw
- return new LoadStructuredAndRaw();
- }
-
- private boolean isLegacyVersion(String ampsVersion) {
- return new ComparableVersion(ampsVersion).compareTo(NON_LEGACY_AMPS_VERSION) < 0;
- }
-
- private boolean isStructured(ResourceType resourceType) {
- return resourceType.getResourceConfigurationDefinition().getConfigurationFormat().equals(STRUCTURED);
- }
-
- private boolean isRaw(ResourceType resourceType) {
- return resourceType.getResourceConfigurationDefinition().getConfigurationFormat().equals(RAW);
- }
-}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigManagementFactoryImplTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigManagementFactoryImplTest.java
new file mode 100644
index 0000000..8ea73cf
--- /dev/null
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigManagementFactoryImplTest.java
@@ -0,0 +1,273 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.pc.configuration;
+
+import static org.testng.Assert.*;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
+import org.rhq.core.pc.util.ComponentService;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.ConfigurationFormat;
+import org.rhq.test.JMockTest;
+import org.jmock.Expectations;
+
+public class ConfigManagementFactoryImplTest extends JMockTest {
+
+ static final String LEGACY_AMPS_VERSION = "2.0";
+
+ static final String NON_LEGACY_AMPS_VERSION = "2.1";
+
+ ComponentService componentService;
+
+ int resourceId = -1;
+
+ ConfigManagementFactoryImpl factory;
+
+ @BeforeMethod
+ public void setup() {
+ componentService = context.mock(ComponentService.class);
+
+ factory = new ConfigManagementFactoryImpl();
+ factory.setComponentService(componentService);
+ }
+
+ @Test
+ public void factoryShouldReturnLegacyLoadConfigWhenAmpsVersionIsLessThan2dot1() throws Exception {
+ context.checking(new Expectations() {{
+ allowing(componentService).getAmpsVersion(resourceId); will(returnValue(LEGACY_AMPS_VERSION));
+ }});
+
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
+
+ assertTrue(
+ loadConfig instanceof LegacyConfigManagement,
+ "Expected to get an instance of " + LegacyConfigManagement.class.getSimpleName() + " when the " +
+ "resource is from a plugin having an ampsVersion less than " + NON_LEGACY_AMPS_VERSION
+ );
+ }
+
+ @Test
+ public void factoryShouldInitializeLegacyLoadConfigWithComponentService() throws Exception {
+ context.checking(new Expectations() {{
+ allowing(componentService).getAmpsVersion(resourceId); will(returnValue(LEGACY_AMPS_VERSION));
+ }});
+
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
+
+ assertComponentServiceInitialized(loadConfig);
+ }
+
+ @Test
+ public void factoryShouldInitializeLegacyLoadConfigWithConfigurationUtilityService() throws Exception {
+ context.checking(new Expectations() {{
+ allowing(componentService).getAmpsVersion(resourceId); will(returnValue(LEGACY_AMPS_VERSION));
+ }});
+
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
+
+ assertConfigurationUtilityServiceInitialized(loadConfig);
+ }
+
+ @Test
+ public void factoryShouldReturnStructuredLoadConfigWhenAmpsVersionIs2dot1AndFormatIsStructured() throws Exception {
+ context.checking(new Expectations() {{
+ allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
+
+ allowing(componentService).getResourceType(resourceId);
+ will(returnValue(createResourceTypeThatSupportsStructured()));
+ }});
+
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
+
+ assertTrue(
+ loadConfig instanceof LoadStructured,
+ "Expected to get an instance of " + LoadStructured.class.getSimpleName() +
+ "when resource is from a plugin having an ampsversion >= " + NON_LEGACY_AMPS_VERSION + " and the resource " +
+ "configuration format is structured."
+ );
+ }
+
+ @Test
+ public void factoryShouldInitializeLoadStructuredWithComponentService() throws Exception {
+ context.checking(new Expectations() {{
+ allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
+
+ allowing(componentService).getResourceType(resourceId);
+ will(returnValue(createResourceTypeThatSupportsStructured()));
+ }});
+
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
+
+ assertComponentServiceInitialized(loadConfig);
+ }
+
+ @Test
+ public void factoryShouldInitializeLoadStructuredWithConfigurationUtilityService() throws Exception {
+ context.checking(new Expectations() {{
+ allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
+
+ allowing(componentService).getResourceType(resourceId);
+ will(returnValue(createResourceTypeThatSupportsStructured()));
+ }});
+
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
+
+ assertConfigurationUtilityServiceInitialized(loadConfig);
+ }
+
+ @Test
+ public void factoryShouldReturnLoadRawWhenAmpsVersionIs2dot1AndFormatIsRaw() throws Exception {
+ context.checking(new Expectations() {{
+ allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
+
+ allowing(componentService).getResourceType(resourceId);
+ will(returnValue(createResourceTypeThatSupportsRaw()));
+ }});
+
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
+
+ assertTrue(
+ loadConfig instanceof RawConfigManagement,
+ "Expected to get an instance of " + RawConfigManagement.class.getSimpleName() + " when " +
+ "resource is from a plugin having an ampsversion >= " + NON_LEGACY_AMPS_VERSION + " and the resource " +
+ "configuration format is raw."
+ );
+ }
+
+ @Test
+ public void factoryShouldInitializeLoadRawWithComponentService() throws Exception {
+ context.checking(new Expectations() {{
+ allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
+
+ allowing(componentService).getResourceType(resourceId);
+ will(returnValue(createResourceTypeThatSupportsStructured()));
+ }});
+
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
+
+ assertComponentServiceInitialized(loadConfig);
+ }
+
+ @Test
+ public void factoryShouldInitializeLoadRawWithConfigurationUtilityService() throws Exception {
+ context.checking(new Expectations() {{
+ allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
+
+ allowing(componentService).getResourceType(resourceId);
+ will(returnValue(createResourceTypeThatSupportsStructured()));
+ }});
+
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
+
+ assertConfigurationUtilityServiceInitialized(loadConfig);
+ }
+
+ @Test
+ public void factoryShouldReturnLoadStructuredAndRawWhenAmpsVersionIs2dot1AndFormatIsBoth() throws Exception {
+ context.checking(new Expectations() {{
+ allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
+
+ allowing(componentService).getResourceType(resourceId);
+ will(returnValue(createResourceTypeThatSupportsStructuredAndRaw()));
+ }});
+
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
+
+ assertTrue(
+ loadConfig instanceof LoadStructuredAndRaw,
+ "Expected to get an instance of" + LoadStructuredAndRaw.class.getSimpleName() +
+ " when resource is from a plugin having an ampsVersion >= " + NON_LEGACY_AMPS_VERSION + " and the " +
+ "resource configuration format is both (structured and raw)."
+ );
+ }
+
+ @Test
+ public void factoryShouldInitializeLoadStructuredAndRawWithComponentService() throws Exception {
+ context.checking(new Expectations() {{
+ allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
+
+ allowing(componentService).getResourceType(resourceId);
+ will(returnValue(createResourceTypeThatSupportsStructured()));
+ }});
+
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
+
+ assertComponentServiceInitialized(loadConfig);
+ }
+
+ @Test
+ public void factoryShouldInitializeLoadStructuredAndRawWithConfigurationUtilityService() throws Exception {
+ context.checking(new Expectations() {{
+ allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
+
+ allowing(componentService).getResourceType(resourceId);
+ will(returnValue(createResourceTypeThatSupportsStructured()));
+ }});
+
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
+
+ assertConfigurationUtilityServiceInitialized(loadConfig);
+ }
+
+ void assertComponentServiceInitialized(ConfigManagement loadConfig) {
+ assertNotNull(loadConfig.getComponentService(), "The factory must initialize the componentService " +
+ "property of the loadConfig object.");
+ }
+
+ void assertConfigurationUtilityServiceInitialized(ConfigManagement loadConfig) {
+ assertNotNull(loadConfig.getConfigurationUtilityService(), "The factory must initialize the " +
+ "configurationUtilityService property of the loadConfig object.");
+ }
+
+ ResourceType createResourceType() {
+ ResourceType resourceType = new ResourceType();
+ resourceType.setResourceConfigurationDefinition(new ConfigurationDefinition("test_config", "Test Configuration"));
+
+ return resourceType;
+ }
+
+ ResourceType createResourceTypeThatSupportsStructured() {
+ ResourceType resourceType = createResourceType();
+ resourceType.getResourceConfigurationDefinition().setConfigurationFormat(ConfigurationFormat.STRUCTURED);
+
+ return resourceType;
+ }
+
+ ResourceType createResourceTypeThatSupportsRaw() {
+ ResourceType resourceType = createResourceType();
+ resourceType.getResourceConfigurationDefinition().setConfigurationFormat(ConfigurationFormat.RAW);
+
+ return resourceType;
+ }
+
+ ResourceType createResourceTypeThatSupportsStructuredAndRaw() {
+ ResourceType resourceType = createResourceType();
+ resourceType.getResourceConfigurationDefinition().setConfigurationFormat(ConfigurationFormat.STRUCTURED_AND_RAW);
+
+ return resourceType;
+ }
+
+}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerTest.java
index 747f29e..200ed40 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerTest.java
@@ -49,7 +49,7 @@ public class ConfigurationManagerTest extends ConfigManagementTest {
boolean FROM_RAW = false;
- LoadResourceConfigurationFactory loadConfigFactory;
+ ConfigManagementFactory configMgmtFactory;
ComponentService componentService;
@@ -57,12 +57,12 @@ public class ConfigurationManagerTest extends ConfigManagementTest {
@BeforeMethod
public void setup() {
- loadConfigFactory = context.mock(LoadResourceConfigurationFactory.class);
+ configMgmtFactory = context.mock(ConfigManagementFactory.class);
componentService = context.mock(ComponentService.class);
configurationMgr = new ConfigurationManager();
- configurationMgr.setLoadConfigFactory(loadConfigFactory);
+ configurationMgr.setConfigManagementFactory(configMgmtFactory);
configurationMgr.setComponentService(componentService);
}
@@ -73,7 +73,7 @@ public class ConfigurationManagerTest extends ConfigManagementTest {
final ConfigManagement loadConfig = context.mock(ConfigManagement.class);
context.checking(new Expectations() {{
- atLeast(1).of(loadConfigFactory).getStrategy(resourceId); will(returnValue(loadConfig));
+ atLeast(1).of(configMgmtFactory).getStrategy(resourceId); will(returnValue(loadConfig));
atLeast(1).of(loadConfig).execute(resourceId); will(returnValue(expectedConfig));
}});
@@ -88,7 +88,7 @@ public class ConfigurationManagerTest extends ConfigManagementTest {
final ConfigManagement loadConfig = context.mock(ConfigManagement.class);
context.checking(new Expectations() {{
- atLeast(1).of(loadConfigFactory).getStrategy(resourceId); will(returnValue(loadConfig));
+ atLeast(1).of(configMgmtFactory).getStrategy(resourceId); will(returnValue(loadConfig));
atLeast(1).of(loadConfig).execute(resourceId); will(returnValue(null));
@@ -105,7 +105,7 @@ public class ConfigurationManagerTest extends ConfigManagementTest {
context.checking(new Expectations() {{
allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
- atLeast(1).of(loadConfigFactory).getStrategy(resourceId); will(returnValue(loadConfig));
+ atLeast(1).of(configMgmtFactory).getStrategy(resourceId); will(returnValue(loadConfig));
atLeast(1).of(loadConfig).execute(resourceId); will(throwException(new RuntimeException()));
}});
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImplTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImplTest.java
deleted file mode 100644
index f22c4c1..0000000
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImplTest.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.core.pc.configuration;
-
-import static org.testng.Assert.*;
-
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeMethod;
-import org.rhq.core.pc.util.ComponentService;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.configuration.definition.ConfigurationFormat;
-import org.rhq.test.JMockTest;
-import org.jmock.Expectations;
-
-public class LoadResourceConfigurationFactoryImplTest extends JMockTest {
-
- static final String LEGACY_AMPS_VERSION = "2.0";
-
- static final String NON_LEGACY_AMPS_VERSION = "2.1";
-
- ComponentService componentService;
-
- int resourceId = -1;
-
- LoadResourceConfigurationFactoryImpl factory;
-
- @BeforeMethod
- public void setup() {
- componentService = context.mock(ComponentService.class);
-
- factory = new LoadResourceConfigurationFactoryImpl();
- factory.setComponentService(componentService);
- }
-
- @Test
- public void factoryShouldReturnLegacyLoadConfigWhenAmpsVersionIsLessThan2dot1() throws Exception {
- context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(LEGACY_AMPS_VERSION));
- }});
-
- ConfigManagement loadConfig = factory.getStrategy(resourceId);
-
- assertTrue(
- loadConfig instanceof LegacyConfigManagement,
- "Expected to get an instance of " + LegacyConfigManagement.class.getSimpleName() + " when the " +
- "resource is from a plugin having an ampsVersion less than " + NON_LEGACY_AMPS_VERSION
- );
- }
-
- @Test
- public void factoryShouldInitializeLegacyLoadConfigWithComponentService() throws Exception {
- context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(LEGACY_AMPS_VERSION));
- }});
-
- ConfigManagement loadConfig = factory.getStrategy(resourceId);
-
- assertComponentServiceInitialized(loadConfig);
- }
-
- @Test
- public void factoryShouldInitializeLegacyLoadConfigWithConfigurationUtilityService() throws Exception {
- context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(LEGACY_AMPS_VERSION));
- }});
-
- ConfigManagement loadConfig = factory.getStrategy(resourceId);
-
- assertConfigurationUtilityServiceInitialized(loadConfig);
- }
-
- @Test
- public void factoryShouldReturnStructuredLoadConfigWhenAmpsVersionIs2dot1AndFormatIsStructured() throws Exception {
- context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
-
- allowing(componentService).getResourceType(resourceId);
- will(returnValue(createResourceTypeThatSupportsStructured()));
- }});
-
- ConfigManagement loadConfig = factory.getStrategy(resourceId);
-
- assertTrue(
- loadConfig instanceof LoadStructured,
- "Expected to get an instance of " + LoadStructured.class.getSimpleName() +
- "when resource is from a plugin having an ampsversion >= " + NON_LEGACY_AMPS_VERSION + " and the resource " +
- "configuration format is structured."
- );
- }
-
- @Test
- public void factoryShouldInitializeLoadStructuredWithComponentService() throws Exception {
- context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
-
- allowing(componentService).getResourceType(resourceId);
- will(returnValue(createResourceTypeThatSupportsStructured()));
- }});
-
- ConfigManagement loadConfig = factory.getStrategy(resourceId);
-
- assertComponentServiceInitialized(loadConfig);
- }
-
- @Test
- public void factoryShouldInitializeLoadStructuredWithConfigurationUtilityService() throws Exception {
- context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
-
- allowing(componentService).getResourceType(resourceId);
- will(returnValue(createResourceTypeThatSupportsStructured()));
- }});
-
- ConfigManagement loadConfig = factory.getStrategy(resourceId);
-
- assertConfigurationUtilityServiceInitialized(loadConfig);
- }
-
- @Test
- public void factoryShouldReturnLoadRawWhenAmpsVersionIs2dot1AndFormatIsRaw() throws Exception {
- context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
-
- allowing(componentService).getResourceType(resourceId);
- will(returnValue(createResourceTypeThatSupportsRaw()));
- }});
-
- ConfigManagement loadConfig = factory.getStrategy(resourceId);
-
- assertTrue(
- loadConfig instanceof RawConfigManagement,
- "Expected to get an instance of " + RawConfigManagement.class.getSimpleName() + " when " +
- "resource is from a plugin having an ampsversion >= " + NON_LEGACY_AMPS_VERSION + " and the resource " +
- "configuration format is raw."
- );
- }
-
- @Test
- public void factoryShouldInitializeLoadRawWithComponentService() throws Exception {
- context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
-
- allowing(componentService).getResourceType(resourceId);
- will(returnValue(createResourceTypeThatSupportsStructured()));
- }});
-
- ConfigManagement loadConfig = factory.getStrategy(resourceId);
-
- assertComponentServiceInitialized(loadConfig);
- }
-
- @Test
- public void factoryShouldInitializeLoadRawWithConfigurationUtilityService() throws Exception {
- context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
-
- allowing(componentService).getResourceType(resourceId);
- will(returnValue(createResourceTypeThatSupportsStructured()));
- }});
-
- ConfigManagement loadConfig = factory.getStrategy(resourceId);
-
- assertConfigurationUtilityServiceInitialized(loadConfig);
- }
-
- @Test
- public void factoryShouldReturnLoadStructuredAndRawWhenAmpsVersionIs2dot1AndFormatIsBoth() throws Exception {
- context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
-
- allowing(componentService).getResourceType(resourceId);
- will(returnValue(createResourceTypeThatSupportsStructuredAndRaw()));
- }});
-
- ConfigManagement loadConfig = factory.getStrategy(resourceId);
-
- assertTrue(
- loadConfig instanceof LoadStructuredAndRaw,
- "Expected to get an instance of" + LoadStructuredAndRaw.class.getSimpleName() +
- " when resource is from a plugin having an ampsVersion >= " + NON_LEGACY_AMPS_VERSION + " and the " +
- "resource configuration format is both (structured and raw)."
- );
- }
-
- @Test
- public void factoryShouldInitializeLoadStructuredAndRawWithComponentService() throws Exception {
- context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
-
- allowing(componentService).getResourceType(resourceId);
- will(returnValue(createResourceTypeThatSupportsStructured()));
- }});
-
- ConfigManagement loadConfig = factory.getStrategy(resourceId);
-
- assertComponentServiceInitialized(loadConfig);
- }
-
- @Test
- public void factoryShouldInitializeLoadStructuredAndRawWithConfigurationUtilityService() throws Exception {
- context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
-
- allowing(componentService).getResourceType(resourceId);
- will(returnValue(createResourceTypeThatSupportsStructured()));
- }});
-
- ConfigManagement loadConfig = factory.getStrategy(resourceId);
-
- assertConfigurationUtilityServiceInitialized(loadConfig);
- }
-
- void assertComponentServiceInitialized(ConfigManagement loadConfig) {
- assertNotNull(loadConfig.getComponentService(), "The factory must initialize the componentService " +
- "property of the loadConfig object.");
- }
-
- void assertConfigurationUtilityServiceInitialized(ConfigManagement loadConfig) {
- assertNotNull(loadConfig.getConfigurationUtilityService(), "The factory must initialize the " +
- "configurationUtilityService property of the loadConfig object.");
- }
-
- ResourceType createResourceType() {
- ResourceType resourceType = new ResourceType();
- resourceType.setResourceConfigurationDefinition(new ConfigurationDefinition("test_config", "Test Configuration"));
-
- return resourceType;
- }
-
- ResourceType createResourceTypeThatSupportsStructured() {
- ResourceType resourceType = createResourceType();
- resourceType.getResourceConfigurationDefinition().setConfigurationFormat(ConfigurationFormat.STRUCTURED);
-
- return resourceType;
- }
-
- ResourceType createResourceTypeThatSupportsRaw() {
- ResourceType resourceType = createResourceType();
- resourceType.getResourceConfigurationDefinition().setConfigurationFormat(ConfigurationFormat.RAW);
-
- return resourceType;
- }
-
- ResourceType createResourceTypeThatSupportsStructuredAndRaw() {
- ResourceType resourceType = createResourceType();
- resourceType.getResourceConfigurationDefinition().setConfigurationFormat(ConfigurationFormat.STRUCTURED_AND_RAW);
-
- return resourceType;
- }
-
-}
14 years, 6 months
[rhq] Branch 'linux-config' - 11 commits - modules/enterprise
by Jay Shaughnessy
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/ExtensionPoint.java | 12
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/MenuItem.java | 37 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectiveServerPluginManager.java | 52 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/metadata/PerspectivePluginMetadataManager.java | 189 ++++++++
modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml | 4
modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-perspective.xsd | 213 +++++-----
6 files changed, 413 insertions(+), 94 deletions(-)
New commits:
commit b6390b22dbd28be0688566e3034bb5f4a0b1d840
Merge: ef77c4a... 3755cc5...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Nov 24 10:00:33 2009 -0500
Merge branch 'linux-config-dev' into linux-config
Conflicts:
modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml
modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-perspective.xsd
diff --cc modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml
index 63e1746,fb640ee..1617ef6
--- a/modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml
@@@ -503,4 -503,4 +503,4 @@@
--</perspectivePlugin>
++</perspectivePlugin>
commit 3755cc5f1d58c2bf3b26102c2bd8d642f82f74c0
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Nov 24 09:29:05 2009 -0500
files removed
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/ExtensionPoint.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/ExtensionPoint.java
new file mode 100644
index 0000000..8f7bc47
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/ExtensionPoint.java
@@ -0,0 +1,12 @@
+package org.rhq.enterprise.server.perspective;
+
+
+/**
+ * Immutable class representing a single perspective extension point.
+ *
+ * @author jshaughnessy
+ *
+ */
+public enum ExtensionPoint {
+ coreMenu, taskPane;
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/MenuItem.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/MenuItem.java
new file mode 100644
index 0000000..8284b5e
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/MenuItem.java
@@ -0,0 +1,37 @@
+package org.rhq.enterprise.server.perspective;
+
+import java.util.List;
+
+import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.MenuItemType;
+
+public class MenuItem {
+
+ private MenuItemType item;
+ private List<MenuItem> children;
+
+ public MenuItem(MenuItemType item) {
+ super();
+ this.item = item;
+ }
+
+ /**
+ * @return the children
+ */
+ public List<MenuItem> getChildren() {
+ return children;
+ }
+
+ /**
+ * @param children the children to set
+ */
+ public void setChildren(List<MenuItem> children) {
+ this.children = children;
+ }
+
+ /**
+ * @return the item
+ */
+ public MenuItemType getItem() {
+ return item;
+ }
+}
commit 960c732c54ab56a00674dbd7bc612ab186c659db
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Nov 24 09:27:02 2009 -0500
Descriptor processing to make definitions available to the server/gui code.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectiveServerPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectiveServerPluginManager.java
index ed9408a..ee0fef1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectiveServerPluginManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectiveServerPluginManager.java
@@ -34,6 +34,8 @@ import javax.naming.InitialContext;
import org.rhq.core.util.file.FileUtil;
import org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment;
import org.rhq.enterprise.server.plugin.pc.ServerPluginManager;
+import org.rhq.enterprise.server.plugin.pc.perspective.metadata.PerspectivePluginMetadataManager;
+import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.PerspectivePluginDescriptorType;
/**
* This loads in all perspective server plugins that can be found. You can obtain a loaded plugin's
@@ -44,10 +46,34 @@ import org.rhq.enterprise.server.plugin.pc.ServerPluginManager;
*/
public class PerspectiveServerPluginManager extends ServerPluginManager {
+ private PerspectivePluginMetadataManager metadataManager;
+
public PerspectiveServerPluginManager(PerspectiveServerPluginContainer pc) {
super(pc);
}
+ @Override
+ public void initialize() throws Exception {
+ super.initialize();
+ this.metadataManager = new PerspectivePluginMetadataManager();
+ }
+
+ @Override
+ public void shutdown() {
+ super.shutdown();
+ this.metadataManager = null;
+ }
+
+ /**
+ * An object that can be used to process and store all metadata from all perspective plugins. This object will contain all the
+ * metadata found in all loaded perspective plugins.
+ *
+ * @return object to retrieve plugin metadata from
+ */
+ public PerspectivePluginMetadataManager getMetadataManager() {
+ return this.metadataManager;
+ }
+
/* At load-time ensure that any WAR files packaged with the server plugin are deployed to the RHQ
* Server. Note, perspective apps are logically deployed along-side, not inside the rhq.ear (although physically
* under the default/work). They should have access to the same shared components.
@@ -58,6 +84,9 @@ public class PerspectiveServerPluginManager extends ServerPluginManager {
public synchronized void loadPlugin(ServerPluginEnvironment env) throws Exception {
super.loadPlugin(env);
+ // merge this perspective into any previously loaded perspective definitions
+ this.metadataManager.loadPlugin((PerspectivePluginDescriptorType) env.getPluginDescriptor());
+
String name = null;
try {
JarFile plugin = new JarFile(env.getPluginUrl().getFile());
@@ -118,6 +147,27 @@ public class PerspectiveServerPluginManager extends ServerPluginManager {
return destFile;
}
+ /**
+ * All of the plugins have been loaded, so now let the metadata manager sort through the definitions.
+ *
+ * @see org.rhq.enterprise.server.plugin.pc.ServerPluginManager#startPlugins()
+ */
+ @Override
+ public synchronized void startPlugins() {
+ super.startPlugins();
+
+ this.metadataManager.start();
+ }
+
+ /* (non-Javadoc)
+ * @see org.rhq.enterprise.server.plugin.pc.ServerPluginManager#stopPlugins()
+ */
+ @Override
+ public synchronized void stopPlugins() {
+ // TODO Auto-generated method stub
+ super.stopPlugins();
+ }
+
/* At unload-time ensure that any WAR files packaged with the server plugin are un-deployed on
* the RHQ Server.
*
@@ -139,6 +189,8 @@ public class PerspectiveServerPluginManager extends ServerPluginManager {
getLog().error("Failed to deploy " + env.getPluginName() + "#" + name, e);
}
+ this.metadataManager.unloadPlugin((PerspectivePluginDescriptorType) env.getPluginDescriptor());
+
super.unloadPlugin(env);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/metadata/PerspectivePluginMetadataManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/metadata/PerspectivePluginMetadataManager.java
new file mode 100644
index 0000000..9e86e6d
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/metadata/PerspectivePluginMetadataManager.java
@@ -0,0 +1,189 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.server.plugin.pc.perspective.metadata;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.enterprise.server.perspective.ExtensionPoint;
+import org.rhq.enterprise.server.perspective.MenuItem;
+import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.MenuItemType;
+import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.PerspectivePluginDescriptorType;
+import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.PlacementType;
+import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.PositionType;
+import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.TaskType;
+
+/**
+ * This loads in all deployed perspective server plugins and maintains the complete set of
+ * {@link #getMetadataManager() metadata} found in all plugin descriptors. Individual plugin
+ * metadata is irrelevant and not retrievable. The union of the perpective definitions is
+ * maintained and made available. Conflict resolution rules are applied as needed for
+ * clashing perspective definitions.
+ *
+ * Activators are not processed here, they use session-time information. This is performed at
+ * plugin-load-time.
+ *
+ * @author Jay Shaughnessy
+ */
+
+public class PerspectivePluginMetadataManager {
+ private final String CORE_PERSPECTIVE_NAME = "CorePerspective";
+
+ private Log log = LogFactory.getLog(PerspectivePluginMetadataManager.class);
+
+ //private static PerspectivePluginMetadataManager manager = new PerspectivePluginMetadataManager();
+
+ private Map<String, PerspectivePluginDescriptorType> loadedPlugins = new HashMap<String, PerspectivePluginDescriptorType>();
+
+ private boolean isStarted = false;
+ private List<TaskType> globalTasks = null;
+ private List<TaskType> resourceTasks = null;
+ private List<MenuItem> coreMenu = null;
+
+ public PerspectivePluginMetadataManager() {
+ }
+
+ /**
+ * Transforms the pluginDescriptor into domain object form and stores those objects.
+ *
+ * @param descriptor the descriptor to transform
+ *
+ * @return void
+ */
+ public synchronized void loadPlugin(PerspectivePluginDescriptorType descriptor) {
+ loadedPlugins.put(descriptor.getName(), descriptor);
+ }
+
+ public synchronized void unloadPlugin(PerspectivePluginDescriptorType descriptor) {
+ loadedPlugins.remove(descriptor.getName());
+ }
+
+ public synchronized void start() {
+ if (isStarted)
+ return;
+
+ // always process the core perspective first as other perspectives may reference its definitions
+ processCorePerspective();
+
+ isStarted = true;
+ }
+
+ private void processCorePerspective() {
+ PerspectivePluginDescriptorType cp = loadedPlugins.get(CORE_PERSPECTIVE_NAME);
+
+ if (null == cp) {
+ throw new IllegalStateException("Core perspective must be loaded. Invalid startup. Load: "
+ + CORE_PERSPECTIVE_NAME);
+ }
+
+ globalTasks = cp.getGlobalTask();
+ resourceTasks = cp.getResourceTask();
+
+ // Setup core menus
+ if (null == this.coreMenu) {
+ this.coreMenu = new ArrayList<MenuItem>();
+ }
+ for (MenuItemType menuItemDef : cp.getMenuItem()) {
+ PositionType position = menuItemDef.getPosition();
+ if (ExtensionPoint.coreMenu == ExtensionPoint.valueOf(position.getExtensionPoint())) {
+ addToMenu(this.coreMenu, menuItemDef);
+ } else {
+ throw new IllegalArgumentException("Unknown Extension Point defined in menuItem ["
+ + menuItemDef.getName() + "] : " + position.getExtensionPoint());
+ }
+ }
+
+ // TODO: remove this debug code
+ //printMenu(this.coreMenu, "");
+ }
+
+ // TODO: remove this debug code
+ @SuppressWarnings("unused")
+ private void printMenu(List<MenuItem> menu, String indent) {
+ if (null == menu)
+ return;
+
+ for (MenuItem menuItem : menu) {
+ System.out.println(indent + menuItem.getItem().getName());
+ printMenu(menuItem.getChildren(), indent + " ");
+ }
+ }
+
+ private void addToMenu(List<MenuItem> menu, MenuItemType menuItemDef) {
+
+ PositionType position = menuItemDef.getPosition();
+ List<MenuItem> containingMenu = getContainingMenu(menu, menuItemDef);
+ MenuItem menuItem = new MenuItem(menuItemDef);
+
+ if (PlacementType.START == position.getPlacement()) {
+ containingMenu.add(0, menuItem);
+ } else if (PlacementType.END == position.getPlacement()) {
+ containingMenu.add(menuItem);
+ } else {
+ int index = getMenuItemIndex(containingMenu, position.getName());
+ if (-1 == index) {
+ throw new IllegalArgumentException("Invalid position defined for menuItem [" + menuItemDef.getName()
+ + "]. Referenced menuItem not found : " + position.getName()
+ + ". Make sure supporting menus are defined for the menuItem.");
+ }
+
+ containingMenu.add((PlacementType.AFTER == position.getPlacement() ? ++index : --index), menuItem);
+ }
+ }
+
+ private List<MenuItem> getContainingMenu(List<MenuItem> menu, MenuItemType menuItemDef) {
+ String name = menuItemDef.getName();
+ String[] nameTokens = (null != name) ? name.split("\\.") : new String[0];
+ List<MenuItem> result = menu;
+
+ for (int i = 0; (i + 1 < nameTokens.length); ++i) {
+ int index = this.getMenuItemIndex(result, nameTokens[i]);
+ if (-1 == index) {
+ throw new IllegalArgumentException("Invalid position defined for menuItem [" + menuItemDef.getName()
+ + "]. No containing menu found for : " + name
+ + ". Make sure supporting menus are defined for the menuItem.");
+ }
+ MenuItem menuItem = result.get(index);
+ result = menuItem.getChildren();
+ if (null == result) {
+ result = new ArrayList<MenuItem>();
+ menuItem.setChildren(result);
+ }
+ }
+
+ return result;
+ }
+
+ private int getMenuItemIndex(List<MenuItem> menu, String name) {
+ int result = -1;
+
+ for (int i = 0, size = menu.size(); (i < size); ++i) {
+ if (menu.get(i).getItem().getName().endsWith(name)) {
+ result = i;
+ break;
+ }
+ }
+ return result;
+ }
+}
diff --git a/modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml
index 63e1746..fb640ee 100644
--- a/modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -119,7 +119,7 @@
url="/ResourceHub.do?resourceCategory=SERVICE">
<position
extensionPoint="coreMenu"
- name="resources.platforms"
+ name="resources.servers"
placement="after" />
</menuItem>
<menuItem
diff --git a/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-perspective.xsd b/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-perspective.xsd
index 0ddd9b5..4c48957 100644
--- a/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-perspective.xsd
+++ b/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-perspective.xsd
@@ -111,15 +111,39 @@
name="TaskType">
<xs:sequence>
<xs:element
- name="NewElement"
- type="xs:string">
+ ref="perspective:extensionPoint"
+ minOccurs="0"
+ maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>
+ Limit task to the designated task pane extension points. Otherwise, all.
+ </xs:documentation>
+ </xs:annotation>
</xs:element>
+
<xs:element
- ref="perspective:extensionPoint"
- minOccurs="1"
+ ref="perspective:resourceActivator"
+ minOccurs="0"
maxOccurs="unbounded">
<xs:annotation>
- <xs:documentation>A task pane extension point for which this task is presented.</xs:documentation>
+ <xs:documentation>
+ Activate task only if the user has resources of the specified type in inventory.
+ Activated
+ only if the user has the required permissions. At least one resource
+ activator required for
+ resource tasks. Activated for resources only if specified trait
+ conditions are also met.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element
+ ref="perspective:permissionActivator"
+ minOccurs="0"
+ maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>
+ Activate task only if the user has the required global permissions.
+ </xs:documentation>
</xs:annotation>
</xs:element>
<xs:element
@@ -198,7 +222,8 @@
</xs:element>
<xs:element
- name="menuItem">
+ name="menuItem"
+ type="perspective:MenuItemType">
<xs:annotation>
<xs:documentation>
Add or Remove a menu item in an existing menu extension point. Additions can specify
@@ -210,100 +235,103 @@
name="PerspectiveMenuItemElement" />
</xs:appinfo>
</xs:annotation>
- <xs:complexType>
- <xs:sequence>
- <xs:element
- ref="perspective:position"
- minOccurs="0"
- maxOccurs="1">
- <xs:annotation>
- <xs:documentation>
- Required for root menuItem additions. Position of children is implicit given the
- XML
- structure.
- </xs:documentation>
- </xs:annotation>
- </xs:element>
- </xs:sequence>
- <xs:attribute
- name="action"
- type="perspective:ActionType"
- use="optional"
- default="add">
+ </xs:element>
+
+ <xs:complexType
+ name="MenuItemType">
+ <xs:sequence>
+ <xs:element
+ ref="perspective:position"
+ minOccurs="0"
+ maxOccurs="1">
<xs:annotation>
<xs:documentation>
- Add or remove the menu entry. For removal all but the name attribute are ignored.
- Default is add.
- </xs:documentation>
+ Required for root menuItem additions. Position of children is implicit given the
+ XML
+ structure.
+ </xs:documentation>
</xs:annotation>
- </xs:attribute>
- <xs:attribute
- name="name"
- type="perspective:NameType"
- use="required">
- <xs:annotation>
- <xs:documentation>
- ExtensionPoint name used for reference by other defined extension points.
- Unique within
- perspective.
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute
+ name="action"
+ type="perspective:ActionType"
+ use="optional"
+ default="add">
+ <xs:annotation>
+ <xs:documentation>
+ Add or remove the menu entry. For removal all but the name attribute are ignored.
+ Default
+ is add.
</xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attribute
- name="displayName"
- type="perspective:DisplayNameType"
- use="optional">
- <xs:annotation>
- <xs:documentation>
- The displayed menu item name. Required for add actions. If empty an icon must be
- defined.
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="name"
+ type="perspective:NameType"
+ use="required">
+ <xs:annotation>
+ <xs:documentation>
+ ExtensionPoint name used for reference by other defined extension points.
+ Unique within
+ perspective.
</xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attribute
- name="feature"
- type="perspective:MenuItemFeatureType"
- use="optional">
- <xs:annotation>
- <xs:documentation>
- Certain menu items utilize special built-in rendering features.
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="displayName"
+ type="perspective:DisplayNameType"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ The displayed menu item name. Required for add actions. If empty an icon must be
+ defined.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="feature"
+ type="perspective:MenuItemFeatureType"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ Certain menu items utilize special built-in rendering features.
</xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attribute
- name="url"
- type="xs:anyURI"
- use="optional">
- <xs:annotation>
- <xs:documentation>
- The request URL for the menu entry. If not provided the entry is just a placeholder for
- MenuItems.
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="url"
+ type="xs:anyURI"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ The request URL for the menu entry. If not provided the entry is just a placeholder for
+ MenuItems.
</xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attribute
- name="iconUrl"
- type="xs:anyURI"
- use="optional">
- <xs:annotation>
- <xs:documentation>
- The request URL for the icon image for this menu item. If not provided then no image is
- used.
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="iconUrl"
+ type="xs:anyURI"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ The request URL for the icon image for this menu item. If not provided then no image is
+ used.
</xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attribute
- name="iconWidth"
- type="xs:int"
- use="optional">
- </xs:attribute>
- <xs:attribute
- name="iconHeight"
- type="xs:int"
- use="optional">
- </xs:attribute>
- </xs:complexType>
- </xs:element>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="iconWidth"
+ type="xs:int"
+ use="optional">
+ </xs:attribute>
+ <xs:attribute
+ name="iconHeight"
+ type="xs:int"
+ use="optional">
+ </xs:attribute>
+ </xs:complexType>
<xs:element
name="resourceTab">
@@ -436,6 +464,7 @@
Activators must be satisfied for the extension point to be active.
</xs:documentation>
</xs:annotation>
+
<xs:complexType>
<xs:sequence>
<xs:element
commit ce32637f2997a499b9bbe9e2629c658d9dcb8e31
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Nov 23 10:28:37 2009 -0500
more perspective descriptor schema tweaks
diff --git a/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-perspective.xsd b/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-perspective.xsd
index b6fabfd..0ddd9b5 100644
--- a/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-perspective.xsd
+++ b/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-perspective.xsd
@@ -228,7 +228,8 @@
<xs:attribute
name="action"
type="perspective:ActionType"
- use="optional">
+ use="optional"
+ default="add">
<xs:annotation>
<xs:documentation>
Add or remove the menu entry. For removal all but the name attribute are ignored.
@@ -342,7 +343,8 @@
<xs:attribute
name="action"
type="perspective:ActionType"
- use="optional">
+ use="optional"
+ default="add">
<xs:annotation>
<xs:documentation>
Add or remove the menu entry. Add is the default.
@@ -401,7 +403,8 @@
<xs:attribute
name="action"
type="perspective:ActionType"
- use="optional">
+ use="optional"
+ default="add">
<xs:annotation>
<xs:documentation>
Add or remove the menu entry. Add is the default.
@@ -581,6 +584,12 @@
type="perspective:PlacementType"
use="required">
</xs:attribute>
+ <xs:attribute
+ name="break"
+ type="xs:boolean"
+ use="optional"
+ default="false">
+ </xs:attribute>
</xs:complexType>
<xs:simpleType
@@ -616,7 +625,7 @@
<xs:restriction
base="xs:string">
<xs:minLength
- value="1" />
+ value="0" />
<xs:maxLength
value="128" />
</xs:restriction>
commit bcaecd83a38c03d4cf98f1a287b96778c49162af
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Nov 23 10:27:30 2009 -0500
Add core perspective to rhq.ear
diff --git a/modules/enterprise/server/ear/pom.xml b/modules/enterprise/server/ear/pom.xml
index ac874e9..dfce882 100644
--- a/modules/enterprise/server/ear/pom.xml
+++ b/modules/enterprise/server/ear/pom.xml
@@ -399,6 +399,12 @@
<version>${project.version}</version>
</artifactItem>
+ <artifactItem>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-perspective</artifactId>
+ <version>${project.version}</version>
+ </artifactItem>
+
<!-- Temporary Sample Perspective -->
<artifactItem>
<groupId>org.rhq</groupId>
commit 3a7d95f1bd0790c2a549255b11cd170afedfed48
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Nov 23 10:26:42 2009 -0500
conforming to schema change
diff --git a/etc/samples/perspectives/sample-perspective/perspective/src/main/resources/META-INF/rhq-serverplugin.xml b/etc/samples/perspectives/sample-perspective/perspective/src/main/resources/META-INF/rhq-serverplugin.xml
index 490ae03..36430f3 100644
--- a/etc/samples/perspectives/sample-perspective/perspective/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/etc/samples/perspectives/sample-perspective/perspective/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<perspective-plugin
+<perspectivePlugin
apiVersion="1.0"
version="1.0"
description="A Sample Perspective Utilizing Every Extension Point and Filter"
@@ -11,4 +11,4 @@
xmlns:serverplugin="urn:xmlns:rhq-serverplugin"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-</perspective-plugin>
\ No newline at end of file
+</perspectivePlugin>
\ No newline at end of file
commit f55fdc2662c75544f370a4e8d37ab6ce8ed2dd0d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Nov 20 22:23:28 2009 -0500
Add Core perspective to build
diff --git a/modules/enterprise/server/plugins/pom.xml b/modules/enterprise/server/plugins/pom.xml
index a3331db..dc2c402 100644
--- a/modules/enterprise/server/plugins/pom.xml
+++ b/modules/enterprise/server/plugins/pom.xml
@@ -39,6 +39,7 @@
<module>yum</module>
<module>url</module>
<module>rhnhosted</module>
+ <module>perspectives/core</module>
<!-- temporary sample perspective plugin -->
<module>../../../../etc/samples/perspectives/sample-perspective</module>
</modules>
commit 8cab3e9ae416eac6ef3c4abc3c9917eb7bb9edc0
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Nov 20 22:22:51 2009 -0500
New Core Perspective defining CoreUI extensions
diff --git a/modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml b/modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml
new file mode 100644
index 0000000..e8dfec7
--- /dev/null
+++ b/modules/enterprise/server/plugins/perspectives/core/perspective/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-parent</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-perspective</artifactId>
+ <packaging>jar</packaging>
+
+ <name>RHQ Core Perspective</name>
+ <description>A Perspective defining Core UI Elements</description>
+
+ <properties>
+ <rhq.version>1.4.0-SNAPSHOT</rhq.version>
+ </properties>
+
+ <dependencies>
+
+ <!-- Below are the core modules that are required dependencies of all server plugins -->
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-server</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope> <!-- provided by the server/plugin-container -->
+ </dependency>
+
+ <!-- uncomment the one of the three logging systems your plugin uses: log4j, commons-logging or i18nlog -->
+ <!-- all three are provided to your plugin by the server/plugin-container -->
+ <!--
+ <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.14</version>
+ <scope>provided</scope> </dependency>
+ -->
+
+ <!--
+ <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1</version>
+ <scope>provided</scope> </dependency>
+ -->
+
+ <!--
+ <dependency> <groupId>i18nlog</groupId> <artifactId>i18nlog</artifactId> <version>1.0.9</version> </dependency>
+ -->
+
+ <!-- Define any third-party dependencies your plugin has here. -->
+ <!--
+ <dependency> <groupId>group-id-of-dependency-goes-here</groupId>
+ <artifactId>artifact-id-of-dependency-goes-here</artifactId> <version>version-of-dependency-goes-here</version>
+ </dependency>
+ -->
+
+ </dependencies>
+
+</project>
diff --git a/modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml
new file mode 100644
index 0000000..63e1746
--- /dev/null
+++ b/modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -0,0 +1,506 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<perspectivePlugin
+ version="1.0"
+ apiVersion="2.0"
+ description="The Core Perspective defining Core UI Elements"
+ displayName="Core Perspective"
+ name="CorePerspective"
+ package="org.rhq.perspective.core"
+ xmlns="urn:xmlns:rhq-serverplugin.perspective"
+ xmlns:serverplugin="urn:xmlns:rhq-serverplugin"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <!-- Core Menu -->
+ <menuItem
+ name="logo"
+ displayName=""
+ url="/"
+ iconUrl="/images/JBossLogo_small.png">
+ <position
+ extensionPoint="coreMenu"
+ placement="start" />
+ </menuItem>
+ <menuItem
+ name="overview"
+ displayName="Overview">
+ <position
+ extensionPoint="coreMenu"
+ name="logo"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="resources"
+ displayName="Resources">
+ <position
+ extensionPoint="coreMenu"
+ name="overview"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="groups"
+ displayName="Groups">
+ <position
+ extensionPoint="coreMenu"
+ name="resources"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="administration"
+ displayName="Administration">
+ <position
+ extensionPoint="coreMenu"
+ name="groups"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="help"
+ displayName="Help">
+ <position
+ extensionPoint="coreMenu"
+ name="administration"
+ placement="after" />
+ </menuItem>
+
+
+ <!-- Core Menu: Overview -->
+ <menuItem
+ name="overview.subsystemViews"
+ displayName="Subsystem Views">
+ <position
+ extensionPoint="coreMenu"
+ name="overview"
+ placement="start" />
+ </menuItem>
+ <menuItem
+ name="overview.autoDiscoveryQueue"
+ displayName="Auto Discovery Queue"
+ url="/rhq/discovery/queue.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="overview.subsystemViews"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="overview.dashboard"
+ displayName="Dashboard"
+ url="/Dashboard.do">
+ <position
+ extensionPoint="coreMenu"
+ name="overview.autoDiscoveryQueue"
+ placement="after" />
+ </menuItem>
+
+ <!-- Core Menu: Resources -->
+ <menuItem
+ name="resources.platforms"
+ displayName="Platforms"
+ iconUrl="/images/icons/Platform_up_16.png"
+ url="/ResourceHub.do?resourceCategory=PLATFORM">
+ <position
+ extensionPoint="coreMenu"
+ name="resources"
+ placement="start" />
+ </menuItem>
+ <menuItem
+ name="resources.servers"
+ displayName="Servers"
+ iconUrl="/images/icons/Server_up_16.png"
+ url="/ResourceHub.do?resourceCategory=SERVER">
+ <position
+ extensionPoint="coreMenu"
+ name="resources.platforms"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="resources.services"
+ displayName="Services"
+ iconUrl="/images/icons/Service_up_16.png"
+ url="/ResourceHub.do?resourceCategory=SERVICE">
+ <position
+ extensionPoint="coreMenu"
+ name="resources.platforms"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="resources.favoriteResources"
+ displayName="Favorite Resources"
+ feature="resourceFavorites"
+ iconUrl="/images/icons/Favorite_16.png">
+ <position
+ extensionPoint="coreMenu"
+ name="resources.services"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="resources.recentlyViewedResources"
+ displayName="Recently Viewed Resources"
+ feature="resourceRecentlyViewed"
+ iconUrl="/images/icons/History_16.png">
+ <position
+ extensionPoint="coreMenu"
+ name="resources.favoriteResources"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="resources.search"
+ displayName="Search:"
+ feature="resourceSearch"
+ iconUrl="/images/icons/Search_16.png">
+ <position
+ extensionPoint="coreMenu"
+ name="resources.recentlyViewedResources"
+ placement="after"
+ break="true" />
+ </menuItem>
+
+ <!-- Core Menu: Groups -->
+ <menuItem
+ name="groups.compatibleGroups"
+ displayName="Compatible Groups"
+ iconUrl="images/icons/Cluster_up_16.png"
+ url="/GroupHub.do?groupCategory=COMPATIBLE">
+ <position
+ extensionPoint="coreMenu"
+ name="groups"
+ placement="start" />
+ </menuItem>
+ <menuItem
+ name="groups.mixedGroups"
+ displayName="Mixed Groups"
+ iconUrl="/images/icons/Group_up_16.png"
+ url="/GroupHub.do?groupCategory=MIXED">
+ <position
+ extensionPoint="coreMenu"
+ name="groups.compatibleGroups"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="groups.groupDefinitions"
+ displayName="Group Definitions"
+ iconUrl="/images/GroupDefinition_16.png"
+ url="/rhq/definition/group/list.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="groups.mixedGroups"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="groups.newGroup"
+ displayName="New Group"
+ url="/resource/group/Inventory.do?mode=new">
+ <position
+ extensionPoint="coreMenu"
+ name="groups.groupDefinitions"
+ placement="after"
+ break="true" />
+ </menuItem>
+ <menuItem
+ name="groups.newGroupDefinition"
+ displayName="New Group Definition"
+ url="/rhq/definition/group/new.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="groups.newGroup"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="groups.favoriteGroups"
+ displayName="Favorite Groups"
+ feature="groupFavorites"
+ iconUrl="/images/icons/Favorite_16.png">
+ <position
+ extensionPoint="coreMenu"
+ name="groups.newGroupDefinition"
+ placement="after"
+ break="true" />
+ </menuItem>
+ <menuItem
+ name="groups.recentlyViewedGroups"
+ displayName="Recently Viewed Groups"
+ feature="groupRecentlyViewed"
+ iconUrl="/images/icons/History_16.png">
+ <position
+ extensionPoint="coreMenu"
+ name="groups.favoriteGroups"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="groups.search"
+ displayName="Search:"
+ feature="groupSearch"
+ iconUrl="/images/icons/Search_16.png">
+ <position
+ extensionPoint="coreMenu"
+ name="groups.recentlyViewedGroups"
+ placement="after"
+ break="true" />
+ </menuItem>
+
+ <!-- Core Menu: Administration -->
+ <menuItem
+ name="administration.security"
+ displayName="Security">
+ <position
+ extensionPoint="coreMenu"
+ name="administration"
+ placement="start" />
+ </menuItem>
+ <menuItem
+ name="administration.systemConfiguration"
+ displayName="systemConfiguration">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.security"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="administration.content"
+ displayName="Content">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.systemConfiguration"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="administration.highAvailability"
+ displayName="High Availability">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.content"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="administration.reports"
+ displayName="Reports">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.highAvailability"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="administration.download"
+ displayName="Download"
+ iconUrl="/images/icons/Save_16.png"
+ url="/rhq/admin/downloads.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.reports"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="administration.license"
+ displayName="License"
+ url="/admin/license/LicenseAdmin.do?mode=view">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.download"
+ placement="after" />
+ </menuItem>
+
+ <!-- Core Menu: Help -->
+ <menuItem
+ name="help.onlineDocumentation"
+ displayName="Online Documentation"
+ feature="newWindow"
+ url="http://www.redhat.com/docs/en-US/JBoss_ON/">
+ <position
+ extensionPoint="coreMenu"
+ name="help"
+ placement="start" />
+ </menuItem>
+ <menuItem
+ name="help.openASupportCase"
+ displayName="Open a Support Case"
+ feature="newWindow"
+ url="https://support.redhat.com/jbossnetwork/restricted/addCase.html">
+ <position
+ extensionPoint="coreMenu"
+ name="help.onlineDocumentation"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="help.about"
+ displayName="About"
+ feature="aboutBox"
+ iconUrl="/images/icons/availability_grey_16.png">
+ <position
+ extensionPoint="coreMenu"
+ name="help.openASupportCase"
+ placement="after"
+ break="true" />
+ </menuItem>
+
+ <!-- Core Menu: Overview.Subsystem Views -->
+ <menuItem
+ name="overview.subsystemViews.configurationChanges"
+ displayName="Configuration Changes"
+ iconUrl="/images/icons/Configure_16.png"
+ url="/rhq/subsystem/configurationUpdate.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="overview.subsystemViews"
+ placement="start" />
+ </menuItem>
+ <menuItem
+ name="overview.subsystemViews.suspectMetrics"
+ displayName="suspectMetrics"
+ iconUrl="/images/icons/Monitor_failed_16.png"
+ url="/rhq/subsystem/oobHistory.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="overview.subsystemViews.configurationChanges"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="overview.subsystemViews.operations"
+ displayName="Operations"
+ iconUrl="/images/icons/Operation_16.png"
+ url="/rhq/subsystem/operationHistory.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="overview.subsystemViews.suspectMetrics"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="overview.subsystemViews.alerts"
+ displayName="Alerts"
+ iconUrl="/images/icons/Flag_blue_16.png"
+ url="/rhq/subsystem/alertHistory.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="overview.subsystemViews.operations"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="overview.subsystemViews.alertDefinitions"
+ displayName="Alert Definitions"
+ iconUrl="/images/icons/Flag_blue_16.png"
+ url="/rhq/subsystem/alertDefinitions.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="overview.subsystemViews.alerts"
+ placement="after" />
+ </menuItem>
+
+ <!-- Core Menu: Administration.Security -->
+ <menuItem
+ name="administration.security.users"
+ displayName="Users"
+ url="/admin/user/UserAdmin.do?mode=list">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.security"
+ placement="start" />
+ </menuItem>
+ <menuItem
+ name="administration.security.roles"
+ displayName="Roles"
+ url="/admin/role/RoleAdmin.do?mode=list">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.security.users"
+ placement="after" />
+ </menuItem>
+
+ <!-- Core Menu: administration.systemConfiguration -->
+ <menuItem
+ name="administration.systemConfiguration.settings"
+ displayName="Settings"
+ url="/admin/config/Config.do?mode=edit">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.systemConfiguration"
+ placement="start" />
+ </menuItem>
+ <menuItem
+ name="administration.systemConfiguration.plugins"
+ displayName="Plugins"
+ url="/rhq/admin/plugin/plugin-list.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.systemConfiguration.settings"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="administration.systemConfiguration.templates"
+ displayName="Templates"
+ url="/admin/config/EditDefaults.do?mode=monitor&viewMode=all">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.systemConfiguration.plugins"
+ placement="after" />
+ </menuItem>
+
+ <!-- Core Menu: administration.content -->
+ <menuItem
+ name="administration.content.contentProviders"
+ displayName="Content Providers"
+ url="/rhq/content/listContentProviders.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.content"
+ placement="start" />
+ </menuItem>
+ <menuItem
+ name="administration.content.repositories"
+ displayName="Repositories"
+ url="/rhq/content/listRepos.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.content.contentProviders"
+ placement="after" />
+ </menuItem>
+
+ <!-- Core Menu: administration.highAvailability -->
+ <menuItem
+ name="administration.highAvailability.servers"
+ displayName="Servers"
+ url="/rhq/ha/listServers.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.highAvailability"
+ placement="start" />
+ </menuItem>
+ <menuItem
+ name="administration.highAvailability.agents"
+ displayName="Agents"
+ url="/rhq/ha/listAgents.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.highAvailability.servers"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="administration.highAvailability.affinityGroups"
+ displayName="Affinity Groups"
+ url="/rhq/ha/listAffinityGroups.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.highAvailability.agents"
+ placement="after" />
+ </menuItem>
+ <menuItem
+ name="administration.highAvailability.paritionEvents"
+ displayName="Partition Events"
+ url="/rhq/ha/listPartitionEvents.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.highAvailability.affinityGroups"
+ placement="after" />
+ </menuItem>
+
+ <!-- Core Menu: administration.reports -->
+ <menuItem
+ name="administration.reports.resourceVersionInventoryReport"
+ displayName="Servers"
+ url="/rhq/admin/report/resourceInstallReport.xhtml">
+ <position
+ extensionPoint="coreMenu"
+ name="administration.reports"
+ placement="start" />
+ </menuItem>
+
+
+
+</perspectivePlugin>
\ No newline at end of file
diff --git a/modules/enterprise/server/plugins/perspectives/core/pom.xml b/modules/enterprise/server/plugins/perspectives/core/pom.xml
new file mode 100644
index 0000000..01ce0b1
--- /dev/null
+++ b/modules/enterprise/server/plugins/perspectives/core/pom.xml
@@ -0,0 +1,44 @@
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-parent</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-perspective-parent</artifactId>
+ <packaging>pom</packaging>
+
+ <name>RHQ Core Perspective Parent</name>
+ <description>parent POM for modules comprising the RHQ Core Perspective</description>
+
+ <scm>
+ <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/plugins...</connection>
+ <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/plugins...</developerConnection>
+ </scm>
+
+ <properties>
+ <scm.module.path>modules/enterprise/plugins/perspectives/core/</scm.module.path>
+ </properties>
+
+ <profiles>
+
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>perspective</module>
+ </modules>
+ </profile>
+
+ </profiles>
+
+</project>
\ No newline at end of file
commit 5868ff69cc004122739a493551bda21f1dc5fa1d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Nov 20 22:21:01 2009 -0500
Under Construction - Perspective Descriptor
diff --git a/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-perspective.xsd b/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-perspective.xsd
index ce586b7..b6fabfd 100644
--- a/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-perspective.xsd
+++ b/modules/enterprise/server/xml-schemas/src/main/resources/rhq-serverplugin-perspective.xsd
@@ -1,48 +1,731 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:config="urn:xmlns:rhq-configuration"
- xmlns:serverplugin="urn:xmlns:rhq-serverplugin"
- xmlns:perspective="urn:xmlns:rhq-serverplugin.perspective"
- targetNamespace="urn:xmlns:rhq-serverplugin.perspective"
- elementFormDefault="qualified"
- jaxb:version="2.0"
- xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" blockDefault="">
-
- <xs:import namespace="urn:xmlns:rhq-serverplugin" schemaLocation="rhq-serverplugin.xsd" />
-
- <xs:annotation>
- <xs:documentation>
- Schema for a Perspective Descriptor. Perspective are deployed as Server Plugins.
- </xs:documentation>
- <xs:appinfo>
- <jaxb:schemaBindings>
- <jaxb:package name="org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective" />
- </jaxb:schemaBindings>
- </xs:appinfo>
- </xs:annotation>
-
- <xs:element name="perspective-plugin" type="perspective:PerspectivePluginDescriptorType" substitutionGroup="serverplugin:server-plugin">
- <xs:annotation>
- <xs:documentation>
- Defines a Perspective plugin. A Perspective is deployed as a Server Plugin.
- The Server Plugin Container (SPC) handles simple lifecycle management for
- the deployed plugins (e.g. start, stop). The plugin is otherwise standalone
- and can do everything it needs to do without additional help from the SPC.
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:config="urn:xmlns:rhq-configuration"
+ xmlns:serverplugin="urn:xmlns:rhq-serverplugin"
+ xmlns:perspective="urn:xmlns:rhq-serverplugin.perspective"
+ targetNamespace="urn:xmlns:rhq-serverplugin.perspective"
+ elementFormDefault="qualified"
+ jaxb:version="2.0"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+ blockDefault="">
+
+ <xs:include
+ schemaLocation=""></xs:include>
+ <xs:import
+ namespace="urn:xmlns:rhq-serverplugin"
+ schemaLocation="rhq-serverplugin.xsd" />
+
+ <xs:annotation>
+ <xs:documentation>
+ Schema for a Perspective Descriptor. Perspective are deployed as Server Plugins.
+ </xs:documentation>
+ <xs:appinfo>
+ <jaxb:schemaBindings>
+ <jaxb:package
+ name="org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective" />
+ </jaxb:schemaBindings>
+ </xs:appinfo>
+ </xs:annotation>
+
+ <xs:element
+ name="perspectivePlugin"
+ type="perspective:PerspectivePluginDescriptorType"
+ substitutionGroup="serverplugin:server-plugin">
+ <xs:annotation>
+ <xs:documentation>
+ Defines a Perspective plugin. A Perspective is deployed as a Server Plugin.
+ The Server Plugin
+ Container (SPC) handles simple lifecycle management for
+ the deployed plugins (e.g. start, stop). The plugin
+ is otherwise standalone
+ and can do everything it needs to do without additional help from the SPC.
+ </xs:documentation>
+ <xs:appinfo>
+ <jaxb:class
+ name="PerspectivePluginElement" />
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+
+ <xs:complexType
+ name="PerspectivePluginDescriptorType">
+ <xs:complexContent>
+ <xs:extension
+ base="serverplugin:ServerPluginDescriptorType">
+ <xs:sequence>
+ <xs:element
+ ref="perspective:globalTask"
+ minOccurs="0"
+ maxOccurs="unbounded">
+ </xs:element>
+ <xs:element
+ ref="perspective:resourceTask"
+ minOccurs="0"
+ maxOccurs="unbounded">
+ </xs:element>
+ <xs:element
+ ref="perspective:menuItem"
+ minOccurs="0"
+ maxOccurs="unbounded">
+ </xs:element>
+ <xs:element
+ ref="perspective:resourceTab"
+ minOccurs="0"
+ maxOccurs="unbounded">
+ </xs:element>
+ <xs:element
+ ref="perspective:resourceSubTab"
+ minOccurs="0"
+ maxOccurs="unbounded">
+ </xs:element>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <xs:element
+ name="globalTask"
+ type="perspective:TaskType">
+ <xs:annotation>
+ <xs:appinfo>
+ <jaxb:class
+ name="PerspectiveGlobalTaskElement" />
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+
+ <xs:element
+ name="resourceTask"
+ type="perspective:TaskType">
+ <xs:annotation>
+ <xs:appinfo>
+ <jaxb:class
+ name="PerspectiveResourceTaskElement" />
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+
+ <xs:complexType
+ name="TaskType">
+ <xs:sequence>
+ <xs:element
+ name="NewElement"
+ type="xs:string">
+ </xs:element>
+ <xs:element
+ ref="perspective:extensionPoint"
+ minOccurs="1"
+ maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>A task pane extension point for which this task is presented.</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element
+ ref="perspective:helpText"
+ minOccurs="0"
+ maxOccurs="1">
+ <xs:annotation>
+ <xs:documentation>Optional additional help text for the task.</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute
+ name="name"
+ type="perspective:NameType"
+ use="required">
+ <xs:annotation>
+ <xs:documentation>
+ The task name. Unique within names defined by the perspective. Used for
+ display if
+ displayName not provided.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="displayName"
+ type="perspective:DisplayNameType"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ The name used for display, if provided.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="description"
+ type="perspective:DescriptionType"
+ use="required">
+ <xs:annotation>
+ <xs:documentation>
+ The task description displayed for the task.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="url"
+ type="xs:anyURI"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ The request URL for the task. Typically kicks off a wizard or similar workflow.
</xs:documentation>
- <xs:appinfo>
- <jaxb:class name="PerspectivePluginElement" />
- </xs:appinfo>
- </xs:annotation>
- </xs:element>
- <xs:complexType name="PerspectivePluginDescriptorType">
- <xs:complexContent>
- <xs:extension base="serverplugin:ServerPluginDescriptorType">
- <xs:sequence>
- <!--...put specific perspective schema definitions here...-->
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="category"
+ type="xs:string"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ Optional task category. Tasks for the same category will be grouped together.
+ Categories
+ are not predefined.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+
+ <xs:element
+ name="extensionPoint"
+ type="perspective:ExtensionPointNameType">
+ </xs:element>
+
+ <xs:element
+ name="helpText"
+ type="perspective:HelpTextType">
+ </xs:element>
+
+ <xs:element
+ name="menuItem">
+ <xs:annotation>
+ <xs:documentation>
+ Add or Remove a menu item in an existing menu extension point. Additions can specify
+ positioning as
+ well as a recursive structure, defineing a tree of MenuItems.
+ </xs:documentation>
+ <xs:appinfo>
+ <jaxb:class
+ name="PerspectiveMenuItemElement" />
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element
+ ref="perspective:position"
+ minOccurs="0"
+ maxOccurs="1">
+ <xs:annotation>
+ <xs:documentation>
+ Required for root menuItem additions. Position of children is implicit given the
+ XML
+ structure.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute
+ name="action"
+ type="perspective:ActionType"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ Add or remove the menu entry. For removal all but the name attribute are ignored.
+ Default is add.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="name"
+ type="perspective:NameType"
+ use="required">
+ <xs:annotation>
+ <xs:documentation>
+ ExtensionPoint name used for reference by other defined extension points.
+ Unique within
+ perspective.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="displayName"
+ type="perspective:DisplayNameType"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ The displayed menu item name. Required for add actions. If empty an icon must be
+ defined.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="feature"
+ type="perspective:MenuItemFeatureType"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ Certain menu items utilize special built-in rendering features.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="url"
+ type="xs:anyURI"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ The request URL for the menu entry. If not provided the entry is just a placeholder for
+ MenuItems.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="iconUrl"
+ type="xs:anyURI"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ The request URL for the icon image for this menu item. If not provided then no image is
+ used.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="iconWidth"
+ type="xs:int"
+ use="optional">
+ </xs:attribute>
+ <xs:attribute
+ name="iconHeight"
+ type="xs:int"
+ use="optional">
+ </xs:attribute>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element
+ name="resourceTab">
+ <xs:annotation>
+ <xs:appinfo>
+ <jaxb:class
+ name="PerspectiveResourceTabElement" />
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element
+ ref="perspective:position"
+ minOccurs="0"
+ maxOccurs="1">
+ <xs:annotation>
+ <xs:documentation>
+ Required for root menuItem additions. Position of children is implicit given the
+ XML
+ structure.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute
+ name="name"
+ type="perspective:NameType"
+ use="required">
+ <xs:annotation>
+ <xs:documentation>
+ The menu entry name. Unique within menu items defined for the perspective. Displayed
+ on
+ screen.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="action"
+ type="perspective:ActionType"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ Add or remove the menu entry. Add is the default.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="url"
+ type="xs:anyURI"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ The request URL for the menu entry. If not provided the entry is just a placeholder for
+ MenuItems.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element
+ name="resourceSubTab">
+ <xs:annotation>
+ <xs:appinfo>
+ <jaxb:class
+ name="PerspectiveResourceSubTabElement" />
+ </xs:appinfo>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element
+ ref="perspective:position"
+ minOccurs="0"
+ maxOccurs="1">
+ <xs:annotation>
+ <xs:documentation>
+ Required for root menuItem additions. Position of children is implicit given the
+ XML
+ structure.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute
+ name="name"
+ type="perspective:NameType"
+ use="required">
+ <xs:annotation>
+ <xs:documentation>
+ The menu entry name. Unique within menu items defined for the perspective. Displayed
+ on
+ screen.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="action"
+ type="perspective:ActionType"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ Add or remove the menu entry. Add is the default.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="url"
+ type="xs:anyURI"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ The request URL for the menu entry. If not provided the entry is just a placeholder for
+ MenuItems.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element
+ name="inventoryActivator">
+ <xs:annotation>
+ <xs:appinfo>
+ <jaxb:class
+ name="InventoryActivatorElement" />
+ </xs:appinfo>
+ <xs:documentation>
+ Activators must be satisfied for the extension point to be active.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element
+ ref="perspective:permissionActivator"
+ minOccurs="0"
+ maxOccurs="unbounded">
+ </xs:element>
+ <xs:element
+ ref="perspective:traitActivator"
+ minOccurs="0"
+ maxOccurs="unbounded">
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute
+ name="plugin"
+ type="xs:string"
+ use="required">
+ <xs:annotation>
+ <xs:documentation>
+ Plugin for the specified resource type.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="resourceType"
+ type="xs:string"
+ use="required">
+ <xs:annotation>
+ <xs:documentation>
+ Resource Type that must be in inventory to activate the extension point.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element
+ name="permissionActivator"
+ type="perspective:PermissionType">
+ <xs:annotation>
+ <xs:documentation>
+ Activators must be satisfied for the extension point to be active.
+ The specified permission
+ must be available to the current user session.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+
+ <xs:element
+ name="traitActivator"
+ type="perspective:TraitActivatorType">
+ <xs:annotation>
+ <xs:documentation>
+ Activators must be satisfied for the extension point to be active.
+ The specified permission
+ must be available to the current user session.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+
+ <xs:complexType
+ name="TraitActivatorType">
+ <xs:attribute
+ name="trait"
+ type="xs:string"
+ use="required">
+ <xs:annotation>
+ <xs:documentation>
+ The trait being tested for activation.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="value"
+ type="xs:string"
+ use="required">
+ <xs:annotation>
+ <xs:documentation>
+ The value of the trait. By default this is a 'contains' test. For equality, set strict to
+ true.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="isEquals"
+ type="xs:boolean"
+ use="optional"
+ default="false">
+ <xs:annotation>
+ <xs:documentation>
+ If true perform equality test. If false (default) perform a contains test.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="isCaseSensitive"
+ type="xs:boolean"
+ use="optional"
+ default="false">
+ <xs:annotation>
+ <xs:documentation>
+ If true perform a case sensitive test. If false (default) test is sase insensitive.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+
+ <xs:element
+ name="position"
+ type="perspective:PositionType">
+ <xs:annotation>
+ <xs:appinfo>
+ <jaxb:class
+ name="PerspectivePositionElement" />
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+
+ <xs:complexType
+ name="PositionType">
+ <xs:attribute
+ name="extensionPoint"
+ type="perspective:ExtensionPointNameType"
+ use="required">
+ <xs:annotation>
+ <xs:documentation>
+ The extension point (a menu, resource tab bar, etc) where the insertion is occuring.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="name"
+ type="perspective:NameType"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>
+ Position relatively against this name. Required for before/after positioning.
+ The name is
+ context specific, it could be a
+ menu entry name, a menu item name, tab name, subTab name, etc.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute
+ name="placement"
+ type="perspective:PlacementType"
+ use="required">
+ </xs:attribute>
+ </xs:complexType>
+
+ <xs:simpleType
+ name="ActionType">
+ <xs:annotation>
+ <xs:documentation>
+ Add : Add new or Replaces existing
+ Remove : Removes existing
+ </xs:documentation>
+ </xs:annotation>
+ <xs:restriction
+ base="xs:string">
+ <xs:enumeration
+ value="add"></xs:enumeration>
+ <xs:enumeration
+ value="remove"></xs:enumeration>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType
+ name="DescriptionType">
+ <xs:restriction
+ base="xs:string">
+ <xs:minLength
+ value="1" />
+ <xs:maxLength
+ value="512" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType
+ name="DisplayNameType">
+ <xs:restriction
+ base="xs:string">
+ <xs:minLength
+ value="1" />
+ <xs:maxLength
+ value="128" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType
+ name="ExtensionPointNameType">
+ <xs:restriction
+ base="xs:string">
+ <xs:minLength
+ value="1" />
+ <xs:maxLength
+ value="128" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType
+ name="HelpTextType">
+ <xs:restriction
+ base="xs:string">
+ <xs:minLength
+ value="1" />
+ <xs:maxLength
+ value="1024" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType
+ name="MenuItemFeatureType">
+ <xs:restriction
+ base="xs:string">
+ <xs:enumeration
+ value="aboutBox"></xs:enumeration>
+ <xs:enumeration
+ value="groupFavorites"></xs:enumeration>
+ <xs:enumeration
+ value="groupRecentlyViewed"></xs:enumeration>
+ <xs:enumeration
+ value="groupSearch"></xs:enumeration>
+ <xs:enumeration
+ value="resourceFavorites"></xs:enumeration>
+ <xs:enumeration
+ value="resourceRecentlyViewed"></xs:enumeration>
+ <xs:enumeration
+ value="resourceSearch"></xs:enumeration>
+ <xs:enumeration
+ value="newWindow"></xs:enumeration>
+ <xs:enumeration
+ value="resourceSearch"></xs:enumeration>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType
+ name="NameType">
+ <xs:restriction
+ base="xs:string">
+ <xs:minLength
+ value="1" />
+ <xs:maxLength
+ value="64" />
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType
+ name="PermissionType">
+ <xs:restriction
+ base="xs:string">
+ <xs:enumeration
+ value="MANAGE_INVENTORY"></xs:enumeration>
+ <xs:enumeration
+ value="MANAGE_SECURITY"></xs:enumeration>
+ <xs:enumeration
+ value="MANAGE_SETTINGS"></xs:enumeration>
+
+ <xs:enumeration
+ value="CONFIGURE"></xs:enumeration>
+ <xs:enumeration
+ value="CONTROL"></xs:enumeration>
+ <xs:enumeration
+ value="CREATE_CHILD_RESOURCE"></xs:enumeration>
+ <xs:enumeration
+ value="DELETE_RESOURCE"></xs:enumeration>
+ <xs:enumeration
+ value="MANAGE_ALERTS"></xs:enumeration>
+ <xs:enumeration
+ value="MANAGE_CONTENT"></xs:enumeration>
+ <xs:enumeration
+ value="MANAGE_MEASUREMENTS"></xs:enumeration>
+ <xs:enumeration
+ value="MODIFY_RESOURCE"></xs:enumeration>
+ <xs:enumeration
+ value="VIEW_RESOURCE"></xs:enumeration>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType
+ name="PlacementType">
+ <xs:restriction
+ base="xs:string">
+ <xs:enumeration
+ value="before"></xs:enumeration>
+ <xs:enumeration
+ value="after"></xs:enumeration>
+ <xs:enumeration
+ value="start"></xs:enumeration>
+ <xs:enumeration
+ value="end"></xs:enumeration>
+ </xs:restriction>
+ </xs:simpleType>
+
</xs:schema>
diff --git a/modules/enterprise/server/xml-schemas/src/test/resources/test-serverplugin-perspective.xml b/modules/enterprise/server/xml-schemas/src/test/resources/test-serverplugin-perspective.xml
index f39a1b6..ac01d06 100644
--- a/modules/enterprise/server/xml-schemas/src/test/resources/test-serverplugin-perspective.xml
+++ b/modules/enterprise/server/xml-schemas/src/test/resources/test-serverplugin-perspective.xml
@@ -1,15 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
-<perspective-plugin
+<perspectivePlugin
apiVersion="1.0"
version="1.0"
description="A Sample Perspective Utilizing Every Extension Point and Filter"
displayName="Sample Perspective"
name="SamplePerspective"
package="org.rhq.perspective.sample"
- pluginLifecycleListener="perspectivePluginLifecycleListener"
xmlns="urn:xmlns:rhq-serverplugin.perspective"
xmlns:serverplugin="urn:xmlns:rhq-serverplugin"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-</perspective-plugin>
+</perspectivePlugin>
commit 28dd3c299d4f163cb50da28fcd15b1f73b834a05
Merge: 5a0c922... 1dec3d8...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Nov 16 09:16:48 2009 -0500
Merge branch 'linux-config' into linux-config-dev
commit 5a0c922a1416fc9cf2d62629df37e32032526b80
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Nov 16 09:10:34 2009 -0500
Obsolete stuff from old perspctives investigation.
diff --git a/modules/enterprise/server/jar/src/main/resources/perspectives/admin.xml b/modules/enterprise/server/jar/src/main/resources/perspectives/admin.xml
deleted file mode 100644
index eb29b5a..0000000
--- a/modules/enterprise/server/jar/src/main/resources/perspectives/admin.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<perspective name="admin" path="/admin"
- description="platform administration tasks"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-perspective">
-</perspective>
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/resources/perspectives/content.xml b/modules/enterprise/server/jar/src/main/resources/perspectives/content.xml
deleted file mode 100644
index ec9d159..0000000
--- a/modules/enterprise/server/jar/src/main/resources/perspectives/content.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<perspective name="content" path="/pulp"
- description="advanced software content management"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-perspective">
- <task name="repo create" path="/pulp/repos/create"
- description="Create Repo">
- <pathmatches>/pulp/repos</pathmatches>
- <pathmatches>/pulp/repos/create</pathmatches>
- <pathmatches>/pulp/repos/create_confirm</pathmatches>
- <pathmatches>/pulp/repos/create*</pathmatches>
- </task>
- <task name="repo add package"
- path="/pulp/repos/add_package?cid={0}"
- description="Add Content to this Repo" context="repo">
- <pathmatches>/pulp/repos/details/*</pathmatches>
- </task>
- <task name="repo clone" path="/pulp/repos/clone"
- description="Clone A Repo">
- <pathmatches>/pulp/repos/*</pathmatches>
- </task>
- <task name="repo clone existing" path="/pulp/repos/clone?cid={0}"
- description="Clone this Repo" context="repo">
- <pathmatches>/pulp/repos/*</pathmatches>
- </task>
- <task name="repo delete" path="/pulp/repos/delete"
- description="Delete A repo">
- <pathmatches>/pulp/repos/*</pathmatches>
- </task>
-</perspective>
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/resources/perspectives/middleware.xml b/modules/enterprise/server/jar/src/main/resources/perspectives/middleware.xml
deleted file mode 100644
index 0d0c9e8..0000000
--- a/modules/enterprise/server/jar/src/main/resources/perspectives/middleware.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<perspective name="middleware" path="/middleware"
- description="manage middleware applications"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-perspective">
-</perspective>
diff --git a/modules/enterprise/server/jar/src/main/resources/perspectives/root.xml b/modules/enterprise/server/jar/src/main/resources/perspectives/root.xml
deleted file mode 100644
index e222b25..0000000
--- a/modules/enterprise/server/jar/src/main/resources/perspectives/root.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<perspective name="root" path="/"
- description="start here"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:xmlns:rhq-perspective">
-</perspective>
\ No newline at end of file
14 years, 6 months
[rhq] Branch 'raw-config' - modules/core modules/test-utils
by John Sanda
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/BaseLoadConfig.java | 60 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagement.java | 48 +
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementSupport.java | 71 +
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java | 18
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LegacyConfigManagement.java | 88 ++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LegacyLoadConfig.java | 81 --
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadRaw.java | 62 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfiguration.java | 44 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactory.java | 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImpl.java | 12
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadStructured.java | 8
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadStructuredAndRaw.java | 8
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawConfigManagement.java | 67 +
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/UpdateResourceConfigurationRunner.java | 19
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigManagementTest.java | 23
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerTest.java | 395 +++++++---
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerUnitTest.java | 320 --------
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadRawTest.java | 116 --
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImplTest.java | 36
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadStructuredAndRawTest.java | 4
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadStructuredTest.java | 4
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/RawConfigManagementTest.java | 116 ++
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/UpdateResourceConfigurationRunnerTest.java | 79 +-
modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java | 21
modules/test-utils/src/main/java/org/rhq/test/CollectionEqualsChecker.java | 91 ++
modules/test-utils/src/main/java/org/rhq/test/EqualsResult.java | 44 +
26 files changed, 968 insertions(+), 869 deletions(-)
New commits:
commit 082c3dd41f771708b9b1a6cae52a36b25e2fe59f
Author: John Sanda <john(a)localhost.localdomain>
Date: Tue Nov 24 09:32:38 2009 -0500
[US 6] Starting to refactor UpdateResourceConfigurationRunner for raw config support and lots of refactoring.
Renaming LoadResourceConfiguration to ConfigManagement since the interface now
provides operations both for loading and updating configs. Renaming
implementors to more logical names.
Refactoring UpdatResourceConfigurationRunner to take an instance of
ConfigManagement instead of ConfigurationFacet.
Adding the method assertCollectionEqualsNoOrder() in AssertUtils in the test-utils
module. The method implementation is largely delegated to CollectionEqualsChecker
has logic to provide a useful error report. It will generate a message that tells
you if elements were found in the collection that should not have been there as
well as if elements were not found that should have been.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/BaseLoadConfig.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/BaseLoadConfig.java
deleted file mode 100644
index 417bf7f..0000000
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/BaseLoadConfig.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.core.pc.configuration;
-
-import org.rhq.core.pc.util.ComponentService;
-import org.rhq.core.pc.util.FacetLockType;
-import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
-import org.rhq.core.clientapi.agent.PluginContainerException;
-
-public abstract class BaseLoadConfig implements LoadResourceConfiguration {
-
- protected ComponentService componentService;
-
- protected ConfigurationUtilityService configUtilityService;
-
- public ComponentService getComponentService() {
- return componentService;
- }
-
- public void setComponentService(ComponentService componentService) {
- this.componentService = componentService;
- }
-
- public ConfigurationUtilityService getConfigurationUtilityService() {
- return configUtilityService;
- }
-
- public void setConfigurationUtilityService(ConfigurationUtilityService configUtilityService) {
- this.configUtilityService = configUtilityService;
- }
-
- protected ResourceConfigurationFacet loadResouceConfiguratonFacet(int resourceId) throws PluginContainerException {
- boolean daemonOnly = true;
- boolean onlyIfStarted = true;
-
- return componentService.getComponent(resourceId, ResourceConfigurationFacet.class, FacetLockType.READ,
- FACET_METHOD_TIMEOUT, daemonOnly, onlyIfStarted);
- }
-}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagement.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagement.java
new file mode 100644
index 0000000..b6f24b3
--- /dev/null
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagement.java
@@ -0,0 +1,48 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.pc.configuration;
+
+import org.rhq.core.pc.util.ComponentService;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.clientapi.agent.PluginContainerException;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+
+public interface ConfigManagement {
+
+ static final int FACET_METHOD_TIMEOUT = 60 * 1000; // 60 seconds
+
+ ComponentService getComponentService();
+
+ void setComponentService(ComponentService componentService);
+
+ ConfigurationUtilityService getConfigurationUtilityService();
+
+ void setConfigurationUtilityService(ConfigurationUtilityService configUtilityService);
+
+ Configuration execute(int resourceId) throws PluginContainerException;
+
+ ConfigurationUpdateReport executeUpdate(int resourceId, Configuration configuration)
+ throws PluginContainerException;
+
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementSupport.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementSupport.java
new file mode 100644
index 0000000..24fd900
--- /dev/null
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementSupport.java
@@ -0,0 +1,71 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.pc.configuration;
+
+import org.rhq.core.pc.util.ComponentService;
+import org.rhq.core.pc.util.FacetLockType;
+import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.clientapi.agent.PluginContainerException;
+
+public abstract class ConfigManagementSupport implements ConfigManagement {
+
+ protected ComponentService componentService;
+
+ protected ConfigurationUtilityService configUtilityService;
+
+ public ComponentService getComponentService() {
+ return componentService;
+ }
+
+ public void setComponentService(ComponentService componentService) {
+ this.componentService = componentService;
+ }
+
+ public ConfigurationUtilityService getConfigurationUtilityService() {
+ return configUtilityService;
+ }
+
+ public void setConfigurationUtilityService(ConfigurationUtilityService configUtilityService) {
+ this.configUtilityService = configUtilityService;
+ }
+
+ protected ResourceConfigurationFacet loadResouceConfiguratonFacet(int resourceId) throws PluginContainerException {
+ boolean daemonOnly = true;
+ boolean onlyIfStarted = true;
+
+ return componentService.getComponent(resourceId, ResourceConfigurationFacet.class, FacetLockType.READ,
+ FACET_METHOD_TIMEOUT, daemonOnly, onlyIfStarted);
+ }
+
+ protected ConfigurationFacet loadConfigurationFacet(int resourceId, FacetLockType lockType)
+ throws PluginContainerException {
+
+ boolean daemonThread = (lockType != FacetLockType.WRITE);
+ boolean onlyIfStarted = true;
+
+ return componentService.getComponent(resourceId, ConfigurationFacet.class, lockType, FACET_METHOD_TIMEOUT,
+ daemonThread, onlyIfStarted);
+ }
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java
index 8bfbfb3..25ae1e7 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java
@@ -22,7 +22,6 @@
*/
package org.rhq.core.pc.configuration;
-import java.util.List;
import java.util.Set;
import java.util.Queue;
import java.util.LinkedList;
@@ -35,13 +34,11 @@ import org.apache.maven.artifact.versioning.ComparableVersion;
import org.rhq.core.clientapi.agent.PluginContainerException;
import org.rhq.core.clientapi.agent.configuration.ConfigurationAgentService;
import org.rhq.core.clientapi.agent.configuration.ConfigurationUpdateRequest;
-import org.rhq.core.clientapi.agent.configuration.ConfigurationUtility;
import org.rhq.core.clientapi.server.configuration.ConfigurationServerService;
import org.rhq.core.clientapi.server.configuration.ConfigurationUpdateResponse;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.RawConfiguration;
import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pc.ContainerService;
import org.rhq.core.pc.PluginContainerConfiguration;
@@ -53,7 +50,6 @@ import org.rhq.core.pc.util.FacetLockType;
import org.rhq.core.pc.util.LoggingThreadFactory;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
-import org.rhq.core.util.exception.WrappedRemotingException;
/**
* Manages configuration of all resources across all plugins.
@@ -119,12 +115,14 @@ public class ConfigurationManager extends AgentService implements ContainerServi
public void updateResourceConfiguration(ConfigurationUpdateRequest request) {
ConfigurationServerService configurationServerService = getConfigurationServerService();
+ ConfigManagement configMgmt = new LegacyConfigManagement();
+ configMgmt.setComponentService(componentService);
+
try {
ResourceType resourceType = getResourceType(request.getResourceId());
- ConfigurationFacet configurationFacet = getConfigurationFacet(request.getResourceId(), FacetLockType.WRITE);
Runnable runnable = new UpdateResourceConfigurationRunner(configurationServerService, resourceType,
- configurationFacet, request);
+ configMgmt, request);
getThreadPool().submit(runnable);
} catch (PluginContainerException e) {
log.error("Failed to submit config update task. Cause: " + e);
@@ -149,12 +147,14 @@ public class ConfigurationManager extends AgentService implements ContainerServi
try {
ConfigurationServerService configurationServerService = getConfigurationServerService();
ResourceType resourceType = getResourceType(request.getResourceId());
- ConfigurationFacet configurationFacet = getConfigurationFacet(request.getResourceId(), FacetLockType.WRITE);
+
+ ConfigManagement configMgmt = new LegacyConfigManagement();
+ configMgmt.setComponentService(componentService);
Callable<ConfigurationUpdateResponse> runner;
runner = new UpdateResourceConfigurationRunner(configurationServerService, resourceType,
- configurationFacet, request);
+ configMgmt, request);
response = getThreadPool().submit(runner).get();
} catch (Exception e) {
@@ -243,7 +243,7 @@ public class ConfigurationManager extends AgentService implements ContainerServi
public Configuration loadResourceConfiguration(int resourceId)
throws PluginContainerException {
- LoadResourceConfiguration loadConfig = loadConfigFactory.getStrategy(resourceId);
+ ConfigManagement loadConfig = loadConfigFactory.getStrategy(resourceId);
Configuration configuration = null;
try {
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LegacyConfigManagement.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LegacyConfigManagement.java
new file mode 100644
index 0000000..85aa6ce
--- /dev/null
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LegacyConfigManagement.java
@@ -0,0 +1,88 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.pc.configuration;
+
+import static org.rhq.core.pc.util.FacetLockType.*;
+import org.rhq.core.pc.util.FacetLockType;
+
+import org.rhq.core.clientapi.agent.PluginContainerException;
+import org.rhq.core.clientapi.agent.configuration.ConfigurationUtility;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.List;
+
+public class LegacyConfigManagement extends ConfigManagementSupport {
+
+ private static final Log log = LogFactory.getLog(LegacyConfigManagement.class);
+
+ public Configuration execute(int resourceId) throws PluginContainerException {
+ Configuration configuration = loadConfigFromFacet(resourceId, READ);
+ ResourceType resourceType = componentService.getResourceType(resourceId);
+
+ // If the plugin didn't already set the notes field, set it to something useful.
+ if (configuration.getNotes() == null) {
+ configuration.setNotes("Resource config for " + resourceType.getName() + " Resource w/ id " + resourceId);
+ }
+
+ ConfigurationDefinition configurationDefinition = resourceType.getResourceConfigurationDefinition();
+
+ // Normalize and validate the config.
+ ConfigurationUtility.normalizeConfiguration(configuration, configurationDefinition);
+ List<String> errorMessages = ConfigurationUtility.validateConfiguration(configuration,
+ configurationDefinition);
+ for (String errorMessage : errorMessages) {
+ log.warn("Plugin Error: Invalid " + resourceType.getName() + " Resource configuration returned by "
+ + resourceType.getPlugin() + " plugin - " + errorMessage);
+ }
+
+ return configuration;
+ }
+
+ private Configuration loadConfigFromFacet(int resourceId, FacetLockType lockType) throws PluginContainerException {
+ ConfigurationFacet configFacet = loadConfigurationFacet(resourceId, lockType);
+
+ try {
+ return configFacet.loadResourceConfiguration();
+ } catch (Exception e) {
+ throw new PluginContainerException(e);
+ }
+ }
+
+ public ConfigurationUpdateReport executeUpdate(int resourceId, Configuration configuration)
+ throws PluginContainerException {
+ ConfigurationFacet facet = loadConfigurationFacet(resourceId, WRITE);
+ ConfigurationUpdateReport report = new ConfigurationUpdateReport(configuration);
+
+ facet.updateResourceConfiguration(report);
+
+ return report;
+ }
+
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LegacyLoadConfig.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LegacyLoadConfig.java
deleted file mode 100644
index b987ddf..0000000
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LegacyLoadConfig.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.core.pc.configuration;
-
-import org.rhq.core.clientapi.agent.PluginContainerException;
-import org.rhq.core.clientapi.agent.configuration.ConfigurationUtility;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.pc.util.FacetLockType;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.List;
-
-public class LegacyLoadConfig extends BaseLoadConfig {
-
- private static final Log log = LogFactory.getLog(LegacyLoadConfig.class);
-
- public Configuration execute(int resourceId) throws PluginContainerException {
- Configuration configuration = loadConfigFromFacet(resourceId);
- ResourceType resourceType = componentService.getResourceType(resourceId);
-
- // If the plugin didn't already set the notes field, set it to something useful.
- if (configuration.getNotes() == null) {
- configuration.setNotes("Resource config for " + resourceType.getName() + " Resource w/ id " + resourceId);
- }
-
- ConfigurationDefinition configurationDefinition = resourceType.getResourceConfigurationDefinition();
-
- // Normalize and validate the config.
- ConfigurationUtility.normalizeConfiguration(configuration, configurationDefinition);
- List<String> errorMessages = ConfigurationUtility.validateConfiguration(configuration,
- configurationDefinition);
- for (String errorMessage : errorMessages) {
- log.warn("Plugin Error: Invalid " + resourceType.getName() + " Resource configuration returned by "
- + resourceType.getPlugin() + " plugin - " + errorMessage);
- }
-
- return configuration;
- }
-
- private Configuration loadConfigFromFacet(int resourceId) throws PluginContainerException {
- FacetLockType lockType = FacetLockType.READ;
- boolean daemonThread = (lockType != FacetLockType.WRITE);
- boolean onlyIfStarted = true;
-
- ConfigurationFacet configFacet = componentService.getComponent(resourceId, ConfigurationFacet.class,
- lockType, FACET_METHOD_TIMEOUT, daemonThread, onlyIfStarted);
-
- Configuration configuration = null;
- try {
- return configFacet.loadResourceConfiguration();
- } catch (Exception e) {
- throw new PluginContainerException(e);
- }
- }
-
-}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadRaw.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadRaw.java
deleted file mode 100644
index debfa45..0000000
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadRaw.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.core.pc.configuration;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.core.clientapi.agent.PluginContainerException;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.RawConfiguration;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
-
-import java.util.Set;
-
-public class LoadRaw extends BaseLoadConfig {
-
- private final Log log = LogFactory.getLog(LoadRaw.class);
-
- public Configuration execute(int resourceId) throws PluginContainerException {
- ResourceConfigurationFacet facet = loadResouceConfiguratonFacet(resourceId);
-
- Set<RawConfiguration> rawConfigs = facet.loadRawConfigurations();
-
- if (rawConfigs == null) {
- return null;
- }
-
- Configuration config = new Configuration();
- for (RawConfiguration rawConfig : rawConfigs) {
- config.addRawConfiguration(rawConfig);
- }
-
- if (config.getNotes() == null) {
- ResourceType resourceType = componentService.getResourceType(resourceId);
- config.setNotes("Resource config for " + resourceType.getName() + " Resource w/ id " + resourceId);
- }
-
- return config;
- }
-
-}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfiguration.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfiguration.java
deleted file mode 100644
index 60133c7..0000000
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfiguration.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.core.pc.configuration;
-
-import org.rhq.core.pc.util.ComponentService;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.clientapi.agent.PluginContainerException;
-
-public interface LoadResourceConfiguration {
-
- static final int FACET_METHOD_TIMEOUT = 60 * 1000; // 60 seconds
-
- ComponentService getComponentService();
-
- void setComponentService(ComponentService componentService);
-
- ConfigurationUtilityService getConfigurationUtilityService();
-
- void setConfigurationUtilityService(ConfigurationUtilityService configUtilityService);
-
- Configuration execute(int resourceId) throws PluginContainerException;
-
-}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactory.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactory.java
index 5bd04ed..be777be 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactory.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactory.java
@@ -27,6 +27,6 @@ import org.rhq.core.clientapi.agent.PluginContainerException;
public interface LoadResourceConfigurationFactory {
- LoadResourceConfiguration getStrategy(int resourceId) throws PluginContainerException;
+ ConfigManagement getStrategy(int resourceId) throws PluginContainerException;
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImpl.java
index e2b1e86..ad5ece4 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImpl.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImpl.java
@@ -42,23 +42,23 @@ public class LoadResourceConfigurationFactoryImpl implements LoadResourceConfigu
this.componentService = componentService;
}
- public LoadResourceConfiguration getStrategy(int resourceId) throws PluginContainerException {
- LoadResourceConfiguration loadConfig = createStrategy(resourceId);
+ public ConfigManagement getStrategy(int resourceId) throws PluginContainerException {
+ ConfigManagement loadConfig = createStrategy(resourceId);
initStrategyDependencies(loadConfig);
return loadConfig;
}
- private void initStrategyDependencies(LoadResourceConfiguration loadConfig) {
+ private void initStrategyDependencies(ConfigManagement loadConfig) {
loadConfig.setComponentService(componentService);
loadConfig.setConfigurationUtilityService(configUtilityService);
}
- private LoadResourceConfiguration createStrategy(int resourceId) throws PluginContainerException {
+ private ConfigManagement createStrategy(int resourceId) throws PluginContainerException {
String ampsVersion = componentService.getAmpsVersion(resourceId);
if (isLegacyVersion(ampsVersion)) {
- return new LegacyLoadConfig();
+ return new LegacyConfigManagement();
}
ResourceType resourceType = componentService.getResourceType(resourceId);
@@ -68,7 +68,7 @@ public class LoadResourceConfigurationFactoryImpl implements LoadResourceConfigu
}
if (isRaw(resourceType)) {
- return new LoadRaw();
+ return new RawConfigManagement();
}
// else format is both structured and raw
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadStructured.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadStructured.java
index 7d29270..e978233 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadStructured.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadStructured.java
@@ -27,12 +27,13 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.clientapi.agent.PluginContainerException;
import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.List;
-public class LoadStructured extends BaseLoadConfig {
+public class LoadStructured extends ConfigManagementSupport {
private final Log log = LogFactory.getLog(LoadStructured.class);
@@ -66,4 +67,9 @@ public class LoadStructured extends BaseLoadConfig {
+ resourceType.getPlugin() + " plugin - " + errorMessage);
}
}
+
+ public ConfigurationUpdateReport executeUpdate(int resourceId, Configuration configuration)
+ throws PluginContainerException {
+ return null;
+ }
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadStructuredAndRaw.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadStructuredAndRaw.java
index c139ae5..2ff175f 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadStructuredAndRaw.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/LoadStructuredAndRaw.java
@@ -30,13 +30,14 @@ import org.rhq.core.domain.configuration.RawConfiguration;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.clientapi.agent.PluginContainerException;
import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.List;
import java.util.Set;
-public class LoadStructuredAndRaw extends BaseLoadConfig {
+public class LoadStructuredAndRaw extends ConfigManagementSupport {
private final Log log = LogFactory.getLog(LoadStructuredAndRaw.class);
@@ -83,4 +84,9 @@ public class LoadStructuredAndRaw extends BaseLoadConfig {
+ resourceType.getPlugin() + " plugin - " + errorMessage);
}
}
+
+ public ConfigurationUpdateReport executeUpdate(int resourceId, Configuration configuration)
+ throws PluginContainerException {
+ return null;
+ }
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawConfigManagement.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawConfigManagement.java
new file mode 100644
index 0000000..c3c99f9
--- /dev/null
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawConfigManagement.java
@@ -0,0 +1,67 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.pc.configuration;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.clientapi.agent.PluginContainerException;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.RawConfiguration;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+
+import java.util.Set;
+
+public class RawConfigManagement extends ConfigManagementSupport {
+
+ private final Log log = LogFactory.getLog(RawConfigManagement.class);
+
+ public Configuration execute(int resourceId) throws PluginContainerException {
+ ResourceConfigurationFacet facet = loadResouceConfiguratonFacet(resourceId);
+
+ Set<RawConfiguration> rawConfigs = facet.loadRawConfigurations();
+
+ if (rawConfigs == null) {
+ return null;
+ }
+
+ Configuration config = new Configuration();
+ for (RawConfiguration rawConfig : rawConfigs) {
+ config.addRawConfiguration(rawConfig);
+ }
+
+ if (config.getNotes() == null) {
+ ResourceType resourceType = componentService.getResourceType(resourceId);
+ config.setNotes("Resource config for " + resourceType.getName() + " Resource w/ id " + resourceId);
+ }
+
+ return config;
+ }
+
+ public ConfigurationUpdateReport executeUpdate(int resourceId, Configuration configuration)
+ throws PluginContainerException {
+ return null;
+ }
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/UpdateResourceConfigurationRunner.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/UpdateResourceConfigurationRunner.java
index c93485b..163dc8c 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/UpdateResourceConfigurationRunner.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/UpdateResourceConfigurationRunner.java
@@ -29,7 +29,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rhq.core.clientapi.agent.configuration.ConfigurationUpdateRequest;
-import org.rhq.core.clientapi.agent.configuration.ConfigurationUtility;
import org.rhq.core.clientapi.server.configuration.ConfigurationServerService;
import org.rhq.core.clientapi.server.configuration.ConfigurationUpdateResponse;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
@@ -51,6 +50,8 @@ public class UpdateResourceConfigurationRunner implements Runnable, Callable<Con
*/
private ConfigurationUpdateRequest request;
+ private ConfigManagement configMgmt;
+
/**
* The resource component's facet that will perform the actual re-configuration of the resource.
*/
@@ -70,10 +71,10 @@ public class UpdateResourceConfigurationRunner implements Runnable, Callable<Con
private ConfigurationUtilityService configUtilService = new ConfigurationUtilityServiceImpl();
public UpdateResourceConfigurationRunner(ConfigurationServerService configurationServerService, ResourceType type,
- ConfigurationFacet facet, ConfigurationUpdateRequest request) {
+ ConfigManagement configMgmt, ConfigurationUpdateRequest request) {
this.configurationServerService = configurationServerService; // may be null
this.resourceType = type;
- this.configurationFacet = facet;
+ this.configMgmt = configMgmt;
this.request = request;
}
@@ -92,10 +93,12 @@ public class UpdateResourceConfigurationRunner implements Runnable, Callable<Con
public ConfigurationUpdateResponse call() throws Exception {
ConfigurationUpdateResponse response;
int requestId = request.getConfigurationUpdateId();
- ConfigurationUpdateReport report = new ConfigurationUpdateReport(request.getConfiguration());
+// ConfigurationUpdateReport report = new ConfigurationUpdateReport(request.getConfiguration());
+ ConfigurationUpdateReport report = null;
try {
- configurationFacet.updateResourceConfiguration(report);
-
+// configurationFacet.updateResourceConfiguration(report);
+ report = configMgmt.executeUpdate(request.getResourceId(), request.getConfiguration());
+
response = new ConfigurationUpdateResponse(requestId, report.getConfiguration(), report.getStatus(), report
.getErrorMessage());
@@ -123,7 +126,7 @@ public class UpdateResourceConfigurationRunner implements Runnable, Callable<Con
} catch (Throwable t) {
log.error("Plugin Error: Exception thrown while updating Resource configuration for "
+ resourceType.getName() + " Resource with id [" + request.getResourceId() + "].", t);
- response = new ConfigurationUpdateResponse(requestId, report.getConfiguration(), t);
+ response = new ConfigurationUpdateResponse(requestId, request.getConfiguration(), t);
}
if (this.configurationServerService != null) {
@@ -132,4 +135,4 @@ public class UpdateResourceConfigurationRunner implements Runnable, Callable<Con
return response;
}
-}
\ No newline at end of file
+}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigManagementTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigManagementTest.java
index cf6e9e9..cc8e760 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigManagementTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigManagementTest.java
@@ -29,6 +29,8 @@ import org.rhq.core.domain.configuration.RawConfiguration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.test.JMockTest;
+
+import static org.rhq.test.AssertUtils.*;
import static org.testng.Assert.assertEquals;
import java.util.HashSet;
@@ -83,19 +85,30 @@ public class ConfigManagementTest extends JMockTest {
}
void assertRawsLoaded(Set<RawConfiguration> expectedRaws, Configuration actualConfig) {
- assertEquals(
- actualConfig.getRawConfigurations(),
+ assertCollectionEqualsNoOrder(
expectedRaws,
+ actualConfig.getRawConfigurations(),
"The raw configs were not loaded correctly."
);
+// assertEquals(
+// actualConfig.getRawConfigurations(),
+// expectedRaws,
+// "The raw configs were not loaded correctly."
+// );
}
void assertStructuredLoaded(Configuration expectedConfig, Configuration actualConfig) {
- assertEquals(
- actualConfig.getAllProperties(),
- expectedConfig.getAllProperties(),
+ assertCollectionEqualsNoOrder(
+ expectedConfig.getProperties(),
+ actualConfig.getProperties(),
"The structured configuration was not loaded correctly."
);
+
+// assertEquals(
+// actualConfig.getAllProperties(),
+// expectedConfig.getAllProperties(),
+// "The structured configuration was not loaded correctly."
+// );
}
void assertNotesSetToDefault(Configuration loadedConfig) {
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerTest.java
index 3e0bd7f..747f29e 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerTest.java
@@ -1,143 +1,320 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
package org.rhq.core.pc.configuration;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+import org.jmock.Expectations;
import org.rhq.core.clientapi.agent.PluginContainerException;
-import org.rhq.core.clientapi.agent.configuration.ConfigurationUpdateRequest;
-import org.rhq.core.clientapi.server.configuration.ConfigurationServerService;
-import org.rhq.core.clientapi.server.configuration.ConfigurationUpdateResponse;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.RawConfiguration;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.pc.PluginContainerConfiguration;
-import org.rhq.core.pc.ServerServices;
+import org.rhq.core.pc.util.ComponentService;
import org.rhq.core.pc.util.FacetLockType;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
-/**
- * ConfigurationManager Tester.
- *
- * @author mspritzler
- *
- * @since 1.0
- * @created June 14, 2007
- */
-public class ConfigurationManagerTest {
- private ConfigurationManager manager;
+import java.util.Set;
+
+public class ConfigurationManagerTest extends ConfigManagementTest {
+
+ static final String LEGACY_AMPS_VERSION = "2.0";
+
+ static final String NON_LEGACY_AMPS_VERSION = "2.1";
+
+ boolean FROM_STRUCTURED = true;
+
+ boolean FROM_RAW = false;
+
+ LoadResourceConfigurationFactory loadConfigFactory;
+
+ ComponentService componentService;
+
+ ConfigurationManager configurationMgr;
@BeforeMethod
- public void setUp() {
- // create a plugin container config that contains our mock server service so the manager uses it
- ServerServices serverServices = new ServerServices();
- serverServices.setConfigurationServerService(new MockConfigurationServerService());
- PluginContainerConfiguration pcConfig = new PluginContainerConfiguration();
- pcConfig.setServerServices(serverServices);
-
- // create our mock manager and initialize it
- manager = new MockConfigurationManager();
- manager.setConfiguration(pcConfig);
- manager.initialize();
- }
+ public void setup() {
+ loadConfigFactory = context.mock(LoadResourceConfigurationFactory.class);
- @AfterMethod
- public void tearDown() {
- manager.shutdown();
+ componentService = context.mock(ComponentService.class);
+
+ configurationMgr = new ConfigurationManager();
+ configurationMgr.setLoadConfigFactory(loadConfigFactory);
+ configurationMgr.setComponentService(componentService);
}
@Test
- public void testUpdateResourceConfiguration() {
- //TODO: Test goes here...
+ public void straegyShouldBeCalledToLoadConfig() throws Exception {
+ final Configuration expectedConfig = new Configuration();
+
+ final ConfigManagement loadConfig = context.mock(ConfigManagement.class);
+
+ context.checking(new Expectations() {{
+ atLeast(1).of(loadConfigFactory).getStrategy(resourceId); will(returnValue(loadConfig));
+
+ atLeast(1).of(loadConfig).execute(resourceId); will(returnValue(expectedConfig));
+ }});
+
+ Configuration actualConfig = configurationMgr.loadResourceConfiguration(resourceId);
+
+ assertNotNull(actualConfig, "Expected a non-null " + Configuration.class.getSimpleName() + " to be returned.");
+ }
+
+ @Test(expectedExceptions = {PluginContainerException.class})
+ public void exceptionShouldBeThrownIfConfigIsNull() throws Exception {
+ final ConfigManagement loadConfig = context.mock(ConfigManagement.class);
+
+ context.checking(new Expectations() {{
+ atLeast(1).of(loadConfigFactory).getStrategy(resourceId); will(returnValue(loadConfig));
+
+ atLeast(1).of(loadConfig).execute(resourceId); will(returnValue(null));
+
+ allowing(componentService).getResourceType(resourceId); will(returnValue(new ResourceType()));
+ }});
+
+ configurationMgr.loadResourceConfiguration(resourceId);
+ }
+
+ @Test(expectedExceptions = {PluginContainerException.class})
+ public void exceptionShouldBeThrownWhenStrategyThrowsAnException() throws Exception {
+ final ConfigManagement loadConfig = context.mock(ConfigManagement.class);
+
+ context.checking(new Expectations() {{
+ allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
+
+ atLeast(1).of(loadConfigFactory).getStrategy(resourceId); will(returnValue(loadConfig));
+
+ atLeast(1).of(loadConfig).execute(resourceId); will(throwException(new RuntimeException()));
+ }});
+
+ configurationMgr.loadResourceConfiguration(resourceId);
}
@Test
- public void testExecuteUpdateResourceConfigurationImmediatelySuccess() {
- Configuration configuration = new Configuration();
- ConfigurationUpdateRequest request = new ConfigurationUpdateRequest(1, configuration, 1);
- try {
- ConfigurationUpdateResponse response = manager.executeUpdateResourceConfigurationImmediately(request);
- assert response.getStatus().equals(ConfigurationUpdateStatus.SUCCESS);
- } catch (PluginContainerException e) {
- e.printStackTrace();
- assert false : "PluginContainerException has been caught: " + e;
- }
+ public void mergingStucturedIntoRawShouldUpdateLatestRawConfigs() throws Exception {
+ final Configuration config = new Configuration();
+ config.addRawConfiguration(createRawConfiguration("/tmp/raw0.txt"));
+
+ final RawConfiguration raw1 = createRawConfiguration("/tmp/raw1.txt");
+ config.addRawConfiguration(raw1);
+
+ final RawConfiguration raw2 = createRawConfiguration("/tmp/raw2.txt");
+
+ final Set<RawConfiguration> latestRaws = toSet(raw1, raw2);
+
+ final RawConfiguration mergedRaw1 = createRawConfiguration("/tmp/raw1.txt");
+ final RawConfiguration mergedRaw2 = createRawConfiguration("/tmp/raw2.txt");
+
+ final ResourceConfigurationFacet facet = context.mock(ResourceConfigurationFacet.class);
+
+ context.checking(new Expectations() {{
+ allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
+
+ atLeast(1).of(componentService).getComponent(resourceId,
+ ResourceConfigurationFacet.class,
+ FacetLockType.READ,
+ ConfigManagement.FACET_METHOD_TIMEOUT,
+ daemonThread,
+ onlyIfStarted);
+ will(returnValue(facet));
+
+ atLeast(1).of(facet).loadRawConfigurations(); will(returnValue(latestRaws));
+
+ oneOf(facet).mergeRawConfiguration(config, raw1); will(returnValue(mergedRaw1));
+ oneOf(facet).mergeRawConfiguration(config, raw2); will(returnValue(mergedRaw2));
+ }});
+
+ Configuration mergedConfig = configurationMgr.merge(config, resourceId, FROM_STRUCTURED);
+
+ Configuration expectedConfig = new Configuration();
+ expectedConfig.addRawConfiguration(mergedRaw1);
+ expectedConfig.addRawConfiguration(mergedRaw2);
+
+ assertStructuredMergedIntoRaws(mergedConfig, expectedConfig, "Failed to update existing raw configs");
}
@Test
- public void testExecuteUpdateResourceConfigurationImmediatelyFailure() {
- Configuration configuration = new Configuration();
- ConfigurationUpdateRequest request = new ConfigurationUpdateRequest(2, configuration, 1);
- try {
- ConfigurationUpdateResponse response = manager.executeUpdateResourceConfigurationImmediately(request);
- assert response.getStatus().equals(ConfigurationUpdateStatus.FAILURE);
- } catch (PluginContainerException e) {
- e.printStackTrace();
- assert false : "PluginContainerException has been caught: " + e;
- }
+ public void mergingStructuredIntoRawShouldIgnoreNulls() throws Exception {
+ final Configuration config = new Configuration();
+
+ final RawConfiguration originalRaw = createRawConfiguration("/tmp/raw.txt");
+ config.addRawConfiguration(originalRaw);
+
+ final Set<RawConfiguration> latestRaws = toSet(originalRaw);
+
+ final ResourceConfigurationFacet facet = context.mock(ResourceConfigurationFacet.class);
+
+ context.checking(new Expectations() {{
+ allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
+
+ atLeast(1).of(componentService).getComponent(resourceId,
+ ResourceConfigurationFacet.class,
+ FacetLockType.READ,
+ ConfigManagement.FACET_METHOD_TIMEOUT,
+ daemonThread,
+ onlyIfStarted);
+ will(returnValue(facet));
+
+ atLeast(1).of(facet).loadRawConfigurations(); will(returnValue(latestRaws));
+
+ oneOf(facet).mergeRawConfiguration(config, originalRaw); will(returnValue(null));
+ }});
+
+ Configuration mergedConfig = configurationMgr.merge(config, resourceId, FROM_STRUCTURED);
+
+ Configuration expectedConfig = new Configuration();
+ expectedConfig.addRawConfiguration(originalRaw);
+
+ assertStructuredMergedIntoRaws(mergedConfig, expectedConfig, "cannot merge into a null raw.");
}
- //@Test
- public void testLoadResourceConfiguration() {
- //TODO: Test goes here...
+ @Test
+ public void mergingStructuredIntoRawShouldDoNothingIfRawsAreNull() throws Exception {
+ RawConfiguration raw = createRawConfiguration("/tmp/foo.txt");
+
+ final Configuration config = new Configuration();
+ config.addRawConfiguration(raw);
+
+ final ResourceConfigurationFacet facet = context.mock(ResourceConfigurationFacet.class);
+
+ context.checking(new Expectations() {{
+ allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
+
+ atLeast(1).of(componentService).getComponent(resourceId,
+ ResourceConfigurationFacet.class,
+ FacetLockType.READ,
+ ConfigManagement.FACET_METHOD_TIMEOUT,
+ daemonThread,
+ onlyIfStarted);
+ will(returnValue(facet));
+
+ atLeast(1).of(facet).loadRawConfigurations(); will(returnValue(null));
+ }});
+
+ Configuration mergedConfig = configurationMgr.merge(config, resourceId, FROM_STRUCTURED);
+
+ Configuration expectedConfig = new Configuration();
+ expectedConfig.addRawConfiguration(raw);
+
+ assertStructuredMergedIntoRaws(
+ mergedConfig,
+ expectedConfig,
+ "Expected raw configs should not be modified when the facet does not return any raw configs."
+ );
}
- private class MockConfigurationManager extends ConfigurationManager {
- @Override
- protected ConfigurationFacet getConfigurationFacet(int resourceId, FacetLockType lockType) {
- return new MockConfigurationFacet();
- }
+ void assertStructuredMergedIntoRaws(Configuration actual, Configuration expected, String msg) {
+ Set<RawConfiguration> actualRaws = actual.getRawConfigurations();
+ Set<RawConfiguration> expectedRaws = expected.getRawConfigurations();
- @Override
- protected ResourceType getResourceType(int resourceId) {
- return new ResourceType();
+ assertEquals(
+ actualRaws.size(),
+ expectedRaws.size(),
+ "Merging structured into raws failed, got back the wrong number of raws. -- " + msg
+ );
+ for (RawConfiguration expectedRaw : expectedRaws) {
+ assertTrue(
+ actualRaws.contains(expectedRaw),
+ "Merging structured into raws failed, failed to find to find raw config [" + expectedRaw + "] -- " + msg
+ );
}
}
- private class MockConfigurationServerService implements ConfigurationServerService {
- public void completeConfigurationUpdate(ConfigurationUpdateResponse response) {
- if (response.getConfigurationUpdateId() == 1) {
- response.setStatus(ConfigurationUpdateStatus.SUCCESS);
- } else {
- response.setStatus(ConfigurationUpdateStatus.FAILURE);
- }
- }
+ @Test
+ public void mergingRawsIntoStructuredShouldUpdateLatestStructuredConfig() throws Exception {
+ final Configuration config = new Configuration();
+ config.put(new PropertySimple("x", "0"));
+ config.put(new PropertySimple("z", "3"));
- public void persistUpdatedResourceConfiguration(int resourceId, Configuration resourceConfiguration) {
- }
+ final RawConfiguration raw1 = createRawConfiguration("/tmp/foo.txt");
+ config.addRawConfiguration(raw1);
+
+ final RawConfiguration raw2 = createRawConfiguration("/tmp/bar.txt");
+ config.addRawConfiguration(raw2);
+
+ final Configuration latestStructured = new Configuration();
+ latestStructured.put(new PropertySimple("x", "1"));
+ latestStructured.put(new PropertySimple("y", "1"));
+
+ final ResourceConfigurationFacet facet = context.mock(ResourceConfigurationFacet.class);
+
+ context.checking(new Expectations() {{
+ allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
+
+ atLeast(1).of(componentService).getComponent(resourceId,
+ ResourceConfigurationFacet.class,
+ FacetLockType.READ,
+ ConfigManagement.FACET_METHOD_TIMEOUT,
+ daemonThread,
+ onlyIfStarted);
+ will(returnValue(facet));
+
+ atLeast(1).of(facet).loadStructuredConfiguration(); will(returnValue(latestStructured));
+ oneOf(facet).mergeStructuredConfiguration(raw1, config);
+ oneOf(facet).mergeStructuredConfiguration(raw2, config);
+ }});
+
+ Configuration mergedConfig = configurationMgr.merge(config, resourceId, FROM_RAW);
+
+ assertEquals(
+ mergedConfig.getAllProperties(),
+ latestStructured.getAllProperties(),
+ "Failed to merged raw into structured."
+ );
}
- private class MockConfigurationFacet implements ConfigurationFacet {
- public Configuration loadResourceConfiguration() {
- return null;
- }
+ @Test
+ public void mergingRawsIntoStructuredShouldIgnoreNull() throws Exception {
+ Configuration config = new Configuration();
+ config.addRawConfiguration(createRawConfiguration("/tmp/foo.txt"));
- public void updateResourceConfiguration(ConfigurationUpdateReport report) {
- Configuration config = report.getConfiguration();
- }
+ final ResourceConfigurationFacet facet = context.mock(ResourceConfigurationFacet.class);
+
+ context.checking(new Expectations() {{
+ allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
+
+ atLeast(1).of(componentService).getComponent(resourceId,
+ ResourceConfigurationFacet.class,
+ FacetLockType.READ,
+ ConfigManagement.FACET_METHOD_TIMEOUT,
+ daemonThread,
+ onlyIfStarted);
+ will(returnValue(facet));
+
+ atLeast(1).of(facet).loadStructuredConfiguration(); will(returnValue(null));
+ }});
+
+ Configuration mergedConfig = configurationMgr.merge(config, resourceId, FROM_RAW);
+
+ assertEquals(
+ mergedConfig,
+ config,
+ "Structured config should not be modified when the facet does not return a structured config."
+ );
}
-}
\ No newline at end of file
+
+}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerUnitTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerUnitTest.java
deleted file mode 100644
index 01aa641..0000000
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerUnitTest.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.core.pc.configuration;
-
-import static org.testng.Assert.*;
-
-import org.jmock.Expectations;
-import org.rhq.core.clientapi.agent.PluginContainerException;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.RawConfiguration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.pc.util.ComponentService;
-import org.rhq.core.pc.util.FacetLockType;
-import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.Set;
-
-public class ConfigurationManagerUnitTest extends ConfigManagementTest {
-
- static final String LEGACY_AMPS_VERSION = "2.0";
-
- static final String NON_LEGACY_AMPS_VERSION = "2.1";
-
- boolean FROM_STRUCTURED = true;
-
- boolean FROM_RAW = false;
-
- LoadResourceConfigurationFactory loadConfigFactory;
-
- ComponentService componentService;
-
- ConfigurationManager configurationMgr;
-
- @BeforeMethod
- public void setup() {
- loadConfigFactory = context.mock(LoadResourceConfigurationFactory.class);
-
- componentService = context.mock(ComponentService.class);
-
- configurationMgr = new ConfigurationManager();
- configurationMgr.setLoadConfigFactory(loadConfigFactory);
- configurationMgr.setComponentService(componentService);
- }
-
- @Test
- public void straegyShouldBeCalledToLoadConfig() throws Exception {
- final Configuration expectedConfig = new Configuration();
-
- final LoadResourceConfiguration loadConfig = context.mock(LoadResourceConfiguration.class);
-
- context.checking(new Expectations() {{
- atLeast(1).of(loadConfigFactory).getStrategy(resourceId); will(returnValue(loadConfig));
-
- atLeast(1).of(loadConfig).execute(resourceId); will(returnValue(expectedConfig));
- }});
-
- Configuration actualConfig = configurationMgr.loadResourceConfiguration(resourceId);
-
- assertNotNull(actualConfig, "Expected a non-null " + Configuration.class.getSimpleName() + " to be returned.");
- }
-
- @Test(expectedExceptions = {PluginContainerException.class})
- public void exceptionShouldBeThrownIfConfigIsNull() throws Exception {
- final LoadResourceConfiguration loadConfig = context.mock(LoadResourceConfiguration.class);
-
- context.checking(new Expectations() {{
- atLeast(1).of(loadConfigFactory).getStrategy(resourceId); will(returnValue(loadConfig));
-
- atLeast(1).of(loadConfig).execute(resourceId); will(returnValue(null));
-
- allowing(componentService).getResourceType(resourceId); will(returnValue(new ResourceType()));
- }});
-
- configurationMgr.loadResourceConfiguration(resourceId);
- }
-
- @Test(expectedExceptions = {PluginContainerException.class})
- public void exceptionShouldBeThrownWhenStrategyThrowsAnException() throws Exception {
- final LoadResourceConfiguration loadConfig = context.mock(LoadResourceConfiguration.class);
-
- context.checking(new Expectations() {{
- allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
-
- atLeast(1).of(loadConfigFactory).getStrategy(resourceId); will(returnValue(loadConfig));
-
- atLeast(1).of(loadConfig).execute(resourceId); will(throwException(new RuntimeException()));
- }});
-
- configurationMgr.loadResourceConfiguration(resourceId);
- }
-
- @Test
- public void mergingStucturedIntoRawShouldUpdateLatestRawConfigs() throws Exception {
- final Configuration config = new Configuration();
- config.addRawConfiguration(createRawConfiguration("/tmp/raw0.txt"));
-
- final RawConfiguration raw1 = createRawConfiguration("/tmp/raw1.txt");
- config.addRawConfiguration(raw1);
-
- final RawConfiguration raw2 = createRawConfiguration("/tmp/raw2.txt");
-
- final Set<RawConfiguration> latestRaws = toSet(raw1, raw2);
-
- final RawConfiguration mergedRaw1 = createRawConfiguration("/tmp/raw1.txt");
- final RawConfiguration mergedRaw2 = createRawConfiguration("/tmp/raw2.txt");
-
- final ResourceConfigurationFacet facet = context.mock(ResourceConfigurationFacet.class);
-
- context.checking(new Expectations() {{
- allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
-
- atLeast(1).of(componentService).getComponent(resourceId,
- ResourceConfigurationFacet.class,
- FacetLockType.READ,
- LoadResourceConfiguration.FACET_METHOD_TIMEOUT,
- daemonThread,
- onlyIfStarted);
- will(returnValue(facet));
-
- atLeast(1).of(facet).loadRawConfigurations(); will(returnValue(latestRaws));
-
- oneOf(facet).mergeRawConfiguration(config, raw1); will(returnValue(mergedRaw1));
- oneOf(facet).mergeRawConfiguration(config, raw2); will(returnValue(mergedRaw2));
- }});
-
- Configuration mergedConfig = configurationMgr.merge(config, resourceId, FROM_STRUCTURED);
-
- Configuration expectedConfig = new Configuration();
- expectedConfig.addRawConfiguration(mergedRaw1);
- expectedConfig.addRawConfiguration(mergedRaw2);
-
- assertStructuredMergedIntoRaws(mergedConfig, expectedConfig, "Failed to update existing raw configs");
- }
-
- @Test
- public void mergingStructuredIntoRawShouldIgnoreNulls() throws Exception {
- final Configuration config = new Configuration();
-
- final RawConfiguration originalRaw = createRawConfiguration("/tmp/raw.txt");
- config.addRawConfiguration(originalRaw);
-
- final Set<RawConfiguration> latestRaws = toSet(originalRaw);
-
- final ResourceConfigurationFacet facet = context.mock(ResourceConfigurationFacet.class);
-
- context.checking(new Expectations() {{
- allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
-
- atLeast(1).of(componentService).getComponent(resourceId,
- ResourceConfigurationFacet.class,
- FacetLockType.READ,
- LoadResourceConfiguration.FACET_METHOD_TIMEOUT,
- daemonThread,
- onlyIfStarted);
- will(returnValue(facet));
-
- atLeast(1).of(facet).loadRawConfigurations(); will(returnValue(latestRaws));
-
- oneOf(facet).mergeRawConfiguration(config, originalRaw); will(returnValue(null));
- }});
-
- Configuration mergedConfig = configurationMgr.merge(config, resourceId, FROM_STRUCTURED);
-
- Configuration expectedConfig = new Configuration();
- expectedConfig.addRawConfiguration(originalRaw);
-
- assertStructuredMergedIntoRaws(mergedConfig, expectedConfig, "cannot merge into a null raw.");
- }
-
- @Test
- public void mergingStructuredIntoRawShouldDoNothingIfRawsAreNull() throws Exception {
- RawConfiguration raw = createRawConfiguration("/tmp/foo.txt");
-
- final Configuration config = new Configuration();
- config.addRawConfiguration(raw);
-
- final ResourceConfigurationFacet facet = context.mock(ResourceConfigurationFacet.class);
-
- context.checking(new Expectations() {{
- allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
-
- atLeast(1).of(componentService).getComponent(resourceId,
- ResourceConfigurationFacet.class,
- FacetLockType.READ,
- LoadResourceConfiguration.FACET_METHOD_TIMEOUT,
- daemonThread,
- onlyIfStarted);
- will(returnValue(facet));
-
- atLeast(1).of(facet).loadRawConfigurations(); will(returnValue(null));
- }});
-
- Configuration mergedConfig = configurationMgr.merge(config, resourceId, FROM_STRUCTURED);
-
- Configuration expectedConfig = new Configuration();
- expectedConfig.addRawConfiguration(raw);
-
- assertStructuredMergedIntoRaws(
- mergedConfig,
- expectedConfig,
- "Expected raw configs should not be modified when the facet does not return any raw configs."
- );
- }
-
- void assertStructuredMergedIntoRaws(Configuration actual, Configuration expected, String msg) {
- Set<RawConfiguration> actualRaws = actual.getRawConfigurations();
- Set<RawConfiguration> expectedRaws = expected.getRawConfigurations();
-
- assertEquals(
- actualRaws.size(),
- expectedRaws.size(),
- "Merging structured into raws failed, got back the wrong number of raws. -- " + msg
- );
- for (RawConfiguration expectedRaw : expectedRaws) {
- assertTrue(
- actualRaws.contains(expectedRaw),
- "Merging structured into raws failed, failed to find to find raw config [" + expectedRaw + "] -- " + msg
- );
- }
- }
-
- @Test
- public void mergingRawsIntoStructuredShouldUpdateLatestStructuredConfig() throws Exception {
- final Configuration config = new Configuration();
- config.put(new PropertySimple("x", "0"));
- config.put(new PropertySimple("z", "3"));
-
- final RawConfiguration raw1 = createRawConfiguration("/tmp/foo.txt");
- config.addRawConfiguration(raw1);
-
- final RawConfiguration raw2 = createRawConfiguration("/tmp/bar.txt");
- config.addRawConfiguration(raw2);
-
- final Configuration latestStructured = new Configuration();
- latestStructured.put(new PropertySimple("x", "1"));
- latestStructured.put(new PropertySimple("y", "1"));
-
- final ResourceConfigurationFacet facet = context.mock(ResourceConfigurationFacet.class);
-
- context.checking(new Expectations() {{
- allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
-
- atLeast(1).of(componentService).getComponent(resourceId,
- ResourceConfigurationFacet.class,
- FacetLockType.READ,
- LoadResourceConfiguration.FACET_METHOD_TIMEOUT,
- daemonThread,
- onlyIfStarted);
- will(returnValue(facet));
-
- atLeast(1).of(facet).loadStructuredConfiguration(); will(returnValue(latestStructured));
-
- oneOf(facet).mergeStructuredConfiguration(raw1, config);
- oneOf(facet).mergeStructuredConfiguration(raw2, config);
- }});
-
- Configuration mergedConfig = configurationMgr.merge(config, resourceId, FROM_RAW);
-
- assertEquals(
- mergedConfig.getAllProperties(),
- latestStructured.getAllProperties(),
- "Failed to merged raw into structured."
- );
- }
-
- @Test
- public void mergingRawsIntoStructuredShouldIgnoreNull() throws Exception {
- Configuration config = new Configuration();
- config.addRawConfiguration(createRawConfiguration("/tmp/foo.txt"));
-
- final ResourceConfigurationFacet facet = context.mock(ResourceConfigurationFacet.class);
-
- context.checking(new Expectations() {{
- allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
-
- atLeast(1).of(componentService).getComponent(resourceId,
- ResourceConfigurationFacet.class,
- FacetLockType.READ,
- LoadResourceConfiguration.FACET_METHOD_TIMEOUT,
- daemonThread,
- onlyIfStarted);
- will(returnValue(facet));
-
- atLeast(1).of(facet).loadStructuredConfiguration(); will(returnValue(null));
- }});
-
- Configuration mergedConfig = configurationMgr.merge(config, resourceId, FROM_RAW);
-
- assertEquals(
- mergedConfig,
- config,
- "Structured config should not be modified when the facet does not return a structured config."
- );
- }
-
-}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadRawTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadRawTest.java
deleted file mode 100644
index f466801..0000000
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadRawTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.rhq.core.pc.configuration;
-
-import org.jmock.Expectations;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.RawConfiguration;
-import org.rhq.core.pc.util.ComponentService;
-import org.rhq.core.pc.util.FacetLockType;
-import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
-import static org.testng.Assert.assertNull;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import static java.util.Collections.EMPTY_SET;
-import java.util.Set;
-
-public class LoadRawTest extends ConfigManagementTest {
-
- ComponentService componentService;
-
- ConfigurationUtilityService configUtilityService;
-
- ResourceConfigurationFacet configFacet;
-
- LoadRaw loadRaw;
-
- @BeforeMethod
- public void setup() {
- componentService = context.mock(ComponentService.class);
- configUtilityService = context.mock(ConfigurationUtilityService.class);
-
- configFacet = context.mock(ResourceConfigurationFacet.class);
-
- loadRaw = new LoadRaw();
- loadRaw.setComponentService(componentService);
- loadRaw.setConfigurationUtilityService(configUtilityService);
- }
-
- @Test
- public void rawConfigsShouldGetLoaded() throws Exception {
- Set<RawConfiguration> rawConfigs = toSet(
- createRawConfiguration("/tmp/foo.txt"),
- createRawConfiguration("/tmp/bar.txt")
- );
-
- addDefaultExpectations(rawConfigs);
-
- Configuration loadedConfig = loadRaw.execute(resourceId);
-
- assertRawsLoaded(rawConfigs, loadedConfig);
- }
-
- @Test
- public void theConfigNotesShouldGetSet() throws Exception {
- final Configuration config = new Configuration();
- config.setNotes(null);
-
- addDefaultExpectations(EMPTY_SET);
-
- Configuration loadedConfig = loadRaw.execute(resourceId);
-
- assertNotesSetToDefault(loadedConfig);
- }
-
- @Test
- public void nullShouldBeReturnedWhenRawIsNull() throws Exception {
- Set<RawConfiguration> rawConfigs = null;
-
- addDefaultExpectations(rawConfigs);
-
- Configuration loadedConfig = loadRaw.execute(resourceId);
-
- assertNull(loadedConfig, "Expected null to be returned when facet returns null for raw.");
- }
-
- private void addDefaultExpectations(final Set<RawConfiguration> rawConfigs)
- throws Exception {
-
- context.checking(new Expectations() {{
- atLeast(1).of(componentService).getComponent(resourceId,
- ResourceConfigurationFacet.class,
- FacetLockType.READ,
- LoadResourceConfiguration.FACET_METHOD_TIMEOUT,
- daemonThread,
- onlyIfStarted);
- will(returnValue(configFacet));
-
- atLeast(1).of(configFacet).loadRawConfigurations(); will(returnValue(rawConfigs));
-
- allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
- }});
- }
-
-}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImplTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImplTest.java
index ef028d2..f22c4c1 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImplTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadResourceConfigurationFactoryImplTest.java
@@ -60,11 +60,11 @@ public class LoadResourceConfigurationFactoryImplTest extends JMockTest {
allowing(componentService).getAmpsVersion(resourceId); will(returnValue(LEGACY_AMPS_VERSION));
}});
- LoadResourceConfiguration loadConfig = factory.getStrategy(resourceId);
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
assertTrue(
- loadConfig instanceof LegacyLoadConfig,
- "Expected to get an instance of " + LegacyLoadConfig.class.getSimpleName() + " when the " +
+ loadConfig instanceof LegacyConfigManagement,
+ "Expected to get an instance of " + LegacyConfigManagement.class.getSimpleName() + " when the " +
"resource is from a plugin having an ampsVersion less than " + NON_LEGACY_AMPS_VERSION
);
}
@@ -75,7 +75,7 @@ public class LoadResourceConfigurationFactoryImplTest extends JMockTest {
allowing(componentService).getAmpsVersion(resourceId); will(returnValue(LEGACY_AMPS_VERSION));
}});
- LoadResourceConfiguration loadConfig = factory.getStrategy(resourceId);
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
assertComponentServiceInitialized(loadConfig);
}
@@ -86,7 +86,7 @@ public class LoadResourceConfigurationFactoryImplTest extends JMockTest {
allowing(componentService).getAmpsVersion(resourceId); will(returnValue(LEGACY_AMPS_VERSION));
}});
- LoadResourceConfiguration loadConfig = factory.getStrategy(resourceId);
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
assertConfigurationUtilityServiceInitialized(loadConfig);
}
@@ -100,7 +100,7 @@ public class LoadResourceConfigurationFactoryImplTest extends JMockTest {
will(returnValue(createResourceTypeThatSupportsStructured()));
}});
- LoadResourceConfiguration loadConfig = factory.getStrategy(resourceId);
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
assertTrue(
loadConfig instanceof LoadStructured,
@@ -119,7 +119,7 @@ public class LoadResourceConfigurationFactoryImplTest extends JMockTest {
will(returnValue(createResourceTypeThatSupportsStructured()));
}});
- LoadResourceConfiguration loadConfig = factory.getStrategy(resourceId);
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
assertComponentServiceInitialized(loadConfig);
}
@@ -133,7 +133,7 @@ public class LoadResourceConfigurationFactoryImplTest extends JMockTest {
will(returnValue(createResourceTypeThatSupportsStructured()));
}});
- LoadResourceConfiguration loadConfig = factory.getStrategy(resourceId);
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
assertConfigurationUtilityServiceInitialized(loadConfig);
}
@@ -147,11 +147,11 @@ public class LoadResourceConfigurationFactoryImplTest extends JMockTest {
will(returnValue(createResourceTypeThatSupportsRaw()));
}});
- LoadResourceConfiguration loadConfig = factory.getStrategy(resourceId);
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
assertTrue(
- loadConfig instanceof LoadRaw,
- "Expected to get an instance of " + LoadRaw.class.getSimpleName() + " when " +
+ loadConfig instanceof RawConfigManagement,
+ "Expected to get an instance of " + RawConfigManagement.class.getSimpleName() + " when " +
"resource is from a plugin having an ampsversion >= " + NON_LEGACY_AMPS_VERSION + " and the resource " +
"configuration format is raw."
);
@@ -166,7 +166,7 @@ public class LoadResourceConfigurationFactoryImplTest extends JMockTest {
will(returnValue(createResourceTypeThatSupportsStructured()));
}});
- LoadResourceConfiguration loadConfig = factory.getStrategy(resourceId);
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
assertComponentServiceInitialized(loadConfig);
}
@@ -180,7 +180,7 @@ public class LoadResourceConfigurationFactoryImplTest extends JMockTest {
will(returnValue(createResourceTypeThatSupportsStructured()));
}});
- LoadResourceConfiguration loadConfig = factory.getStrategy(resourceId);
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
assertConfigurationUtilityServiceInitialized(loadConfig);
}
@@ -194,7 +194,7 @@ public class LoadResourceConfigurationFactoryImplTest extends JMockTest {
will(returnValue(createResourceTypeThatSupportsStructuredAndRaw()));
}});
- LoadResourceConfiguration loadConfig = factory.getStrategy(resourceId);
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
assertTrue(
loadConfig instanceof LoadStructuredAndRaw,
@@ -213,7 +213,7 @@ public class LoadResourceConfigurationFactoryImplTest extends JMockTest {
will(returnValue(createResourceTypeThatSupportsStructured()));
}});
- LoadResourceConfiguration loadConfig = factory.getStrategy(resourceId);
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
assertComponentServiceInitialized(loadConfig);
}
@@ -227,17 +227,17 @@ public class LoadResourceConfigurationFactoryImplTest extends JMockTest {
will(returnValue(createResourceTypeThatSupportsStructured()));
}});
- LoadResourceConfiguration loadConfig = factory.getStrategy(resourceId);
+ ConfigManagement loadConfig = factory.getStrategy(resourceId);
assertConfigurationUtilityServiceInitialized(loadConfig);
}
- void assertComponentServiceInitialized(LoadResourceConfiguration loadConfig) {
+ void assertComponentServiceInitialized(ConfigManagement loadConfig) {
assertNotNull(loadConfig.getComponentService(), "The factory must initialize the componentService " +
"property of the loadConfig object.");
}
- void assertConfigurationUtilityServiceInitialized(LoadResourceConfiguration loadConfig) {
+ void assertConfigurationUtilityServiceInitialized(ConfigManagement loadConfig) {
assertNotNull(loadConfig.getConfigurationUtilityService(), "The factory must initialize the " +
"configurationUtilityService property of the loadConfig object.");
}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadStructuredAndRawTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadStructuredAndRawTest.java
index 824c05f..e275f82 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadStructuredAndRawTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadStructuredAndRawTest.java
@@ -145,7 +145,7 @@ public class LoadStructuredAndRawTest extends ConfigManagementTest {
atLeast(1).of(componentService).getComponent(resourceId,
ResourceConfigurationFacet.class,
FacetLockType.READ,
- LoadResourceConfiguration.FACET_METHOD_TIMEOUT,
+ ConfigManagement.FACET_METHOD_TIMEOUT,
daemonThread,
onlyIfStarted);
will(returnValue(configFacet));
@@ -169,7 +169,7 @@ public class LoadStructuredAndRawTest extends ConfigManagementTest {
atLeast(1).of(componentService).getComponent(resourceId,
ResourceConfigurationFacet.class,
FacetLockType.READ,
- LoadResourceConfiguration.FACET_METHOD_TIMEOUT,
+ ConfigManagement.FACET_METHOD_TIMEOUT,
daemonThread,
onlyIfStarted);
will(returnValue(configFacet));
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadStructuredTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadStructuredTest.java
index 59677c9..3941afd 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadStructuredTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/LoadStructuredTest.java
@@ -88,7 +88,7 @@ public class LoadStructuredTest extends ConfigManagementTest {
atLeast(1).of(componentService).getComponent(resourceId,
ResourceConfigurationFacet.class,
FacetLockType.READ,
- LoadResourceConfiguration.FACET_METHOD_TIMEOUT,
+ ConfigManagement.FACET_METHOD_TIMEOUT,
daemonThread,
onlyIfStarted);
will(returnValue(configFacet));
@@ -108,7 +108,7 @@ public class LoadStructuredTest extends ConfigManagementTest {
atLeast(1).of(componentService).getComponent(resourceId,
ResourceConfigurationFacet.class,
FacetLockType.READ,
- LoadResourceConfiguration.FACET_METHOD_TIMEOUT,
+ ConfigManagement.FACET_METHOD_TIMEOUT,
daemonThread,
onlyIfStarted);
will(returnValue(configFacet));
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/RawConfigManagementTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/RawConfigManagementTest.java
new file mode 100644
index 0000000..473ba1c
--- /dev/null
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/RawConfigManagementTest.java
@@ -0,0 +1,116 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.pc.configuration;
+
+import org.jmock.Expectations;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.RawConfiguration;
+import org.rhq.core.pc.util.ComponentService;
+import org.rhq.core.pc.util.FacetLockType;
+import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
+import static org.testng.Assert.assertNull;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import static java.util.Collections.EMPTY_SET;
+import java.util.Set;
+
+public class RawConfigManagementTest extends ConfigManagementTest {
+
+ ComponentService componentService;
+
+ ConfigurationUtilityService configUtilityService;
+
+ ResourceConfigurationFacet configFacet;
+
+ RawConfigManagement rawConfigMgmt;
+
+ @BeforeMethod
+ public void setup() {
+ componentService = context.mock(ComponentService.class);
+ configUtilityService = context.mock(ConfigurationUtilityService.class);
+
+ configFacet = context.mock(ResourceConfigurationFacet.class);
+
+ rawConfigMgmt = new RawConfigManagement();
+ rawConfigMgmt.setComponentService(componentService);
+ rawConfigMgmt.setConfigurationUtilityService(configUtilityService);
+ }
+
+ @Test
+ public void rawConfigsShouldGetLoaded() throws Exception {
+ Set<RawConfiguration> rawConfigs = toSet(
+ createRawConfiguration("/tmp/foo.txt"),
+ createRawConfiguration("/tmp/bar.txt")
+ );
+
+ addDefaultExpectations(rawConfigs);
+
+ Configuration loadedConfig = rawConfigMgmt.execute(resourceId);
+
+ assertRawsLoaded(rawConfigs, loadedConfig);
+ }
+
+ @Test
+ public void theConfigNotesShouldGetSet() throws Exception {
+ final Configuration config = new Configuration();
+ config.setNotes(null);
+
+ addDefaultExpectations(EMPTY_SET);
+
+ Configuration loadedConfig = rawConfigMgmt.execute(resourceId);
+
+ assertNotesSetToDefault(loadedConfig);
+ }
+
+ @Test
+ public void nullShouldBeReturnedWhenRawIsNull() throws Exception {
+ Set<RawConfiguration> rawConfigs = null;
+
+ addDefaultExpectations(rawConfigs);
+
+ Configuration loadedConfig = rawConfigMgmt.execute(resourceId);
+
+ assertNull(loadedConfig, "Expected null to be returned when facet returns null for raw.");
+ }
+
+ private void addDefaultExpectations(final Set<RawConfiguration> rawConfigs)
+ throws Exception {
+
+ context.checking(new Expectations() {{
+ atLeast(1).of(componentService).getComponent(resourceId,
+ ResourceConfigurationFacet.class,
+ FacetLockType.READ,
+ ConfigManagement.FACET_METHOD_TIMEOUT,
+ daemonThread,
+ onlyIfStarted);
+ will(returnValue(configFacet));
+
+ atLeast(1).of(configFacet).loadRawConfigurations(); will(returnValue(rawConfigs));
+
+ allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
+ }});
+ }
+
+}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/UpdateResourceConfigurationRunnerTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/UpdateResourceConfigurationRunnerTest.java
index 272d22e..48bf0ae 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/UpdateResourceConfigurationRunnerTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/UpdateResourceConfigurationRunnerTest.java
@@ -23,33 +23,66 @@
package org.rhq.core.pc.configuration;
-import static org.rhq.core.domain.configuration.ConfigurationUpdateStatus.*;
-import static org.rhq.test.AssertUtils.*;
-import org.rhq.test.jmock.PropertyMatcher;
-
-import org.testng.annotations.Test;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.jmock.Expectations;
+import org.jmock.api.Action;
+import org.jmock.api.Invocation;
+import org.rhq.core.clientapi.agent.configuration.ConfigurationUpdateRequest;
import org.rhq.core.clientapi.server.configuration.ConfigurationServerService;
import org.rhq.core.clientapi.server.configuration.ConfigurationUpdateResponse;
-import org.rhq.core.clientapi.agent.configuration.ConfigurationUpdateRequest;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import static org.rhq.core.domain.configuration.ConfigurationUpdateStatus.FAILURE;
+import static org.rhq.core.domain.configuration.ConfigurationUpdateStatus.INPROGRESS;
+import static org.rhq.core.domain.configuration.ConfigurationUpdateStatus.SUCCESS;
+import org.rhq.core.pc.util.ComponentService;
+import static org.rhq.core.pc.configuration.ConfigManagement.FACET_METHOD_TIMEOUT;
+import static org.rhq.core.pc.util.FacetLockType.WRITE;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
-import org.jmock.Expectations;
-import org.jmock.api.Action;
-import org.jmock.api.Invocation;
-import org.hamcrest.Description;
-import org.hamcrest.Matcher;
+import static org.rhq.test.AssertUtils.assertPropertiesMatch;
+import org.rhq.test.jmock.PropertyMatcher;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
public class UpdateResourceConfigurationRunnerTest extends ConfigManagementTest {
+ ComponentService componentService;
+
+ ConfigManagement configMgmt;
+
+ ConfigurationFacet facet;
+
+ @BeforeMethod
+ public void setup() throws Exception {
+ componentService = context.mock(ComponentService.class);
+ facet = context.mock(ConfigurationFacet.class);
+
+ configMgmt = new LegacyConfigManagement();
+ configMgmt.setComponentService(componentService);
+
+ setDefaultExpectations();
+ }
+
+ void setDefaultExpectations() throws Exception {
+ final boolean daemonThread = false;
+ final boolean onlyIfStarted = true;
+
+ context.checking(new Expectations() {{
+ allowing(componentService).getComponent(resourceId, ConfigurationFacet.class, WRITE, FACET_METHOD_TIMEOUT,
+ daemonThread, onlyIfStarted);
+ will(returnValue(facet));
+ }});
+ }
+
@Test
public void successfulUpdateShouldSendSuccessResponseToServer() throws Exception {
final Configuration config = createStructuredConfig();
final ConfigurationServerService configServerService = context.mock(ConfigurationServerService.class);
- final ConfigurationFacet facet = context.mock(ConfigurationFacet.class);
+ //final ConfigurationFacet facet = context.mock(ConfigurationFacet.class);
final ConfigurationUtilityService configUtilService = context.mock(ConfigurationUtilityService.class);
@@ -58,7 +91,7 @@ public class UpdateResourceConfigurationRunnerTest extends ConfigManagementTest
ConfigurationUpdateRequest updateRequest = new ConfigurationUpdateRequest(configUpdateId, config, resourceId);
UpdateResourceConfigurationRunner updateRunner = new UpdateResourceConfigurationRunner(configServerService,
- resourceType, facet, updateRequest);
+ resourceType, configMgmt, updateRequest);
updateRunner.setConfigUtilService(configUtilService);
final ConfigurationUpdateResponse successResponse = new ConfigurationUpdateResponse(configUpdateId, null,
@@ -81,7 +114,7 @@ public class UpdateResourceConfigurationRunnerTest extends ConfigManagementTest
public void successfulUpdateShouldReturnSuccessResponseInEmbeddedMode() throws Exception {
final Configuration config = createStructuredConfig();
- final ConfigurationFacet facet = context.mock(ConfigurationFacet.class);
+ //final ConfigurationFacet facet = context.mock(ConfigurationFacet.class);
final ConfigurationUtilityService configUtilService = context.mock(ConfigurationUtilityService.class);
@@ -90,7 +123,7 @@ public class UpdateResourceConfigurationRunnerTest extends ConfigManagementTest
ConfigurationUpdateRequest updateRequest = new ConfigurationUpdateRequest(configUpdateId, config, resourceId);
UpdateResourceConfigurationRunner updateRunner = new UpdateResourceConfigurationRunner(null, resourceType,
- facet, updateRequest);
+ configMgmt, updateRequest);
updateRunner.setConfigUtilService(configUtilService);
final ConfigurationUpdateResponse successResponse = new ConfigurationUpdateResponse(configUpdateId, null,
@@ -116,7 +149,7 @@ public class UpdateResourceConfigurationRunnerTest extends ConfigManagementTest
final ConfigurationServerService configServerService = context.mock(ConfigurationServerService.class);
- final ConfigurationFacet facet = context.mock(ConfigurationFacet.class);
+ //final ConfigurationFacet facet = context.mock(ConfigurationFacet.class);
final ConfigurationUtilityService configUtilService = context.mock(ConfigurationUtilityService.class);
@@ -125,7 +158,7 @@ public class UpdateResourceConfigurationRunnerTest extends ConfigManagementTest
ConfigurationUpdateRequest updateRequest = new ConfigurationUpdateRequest(configUpdateId, config, resourceId);
UpdateResourceConfigurationRunner updateRunner = new UpdateResourceConfigurationRunner(configServerService,
- resourceType, facet, updateRequest);
+ resourceType, configMgmt, updateRequest);
updateRunner.setConfigUtilService(configUtilService);
String errorMsg = "Configuration facet did not indicate success or failure - assuming failure.";
@@ -150,7 +183,7 @@ public class UpdateResourceConfigurationRunnerTest extends ConfigManagementTest
public void failedUpdateShouldReturnFailureResponseInEmbeddedMode() throws Exception {
final Configuration config = createStructuredConfig();
- final ConfigurationFacet facet = context.mock(ConfigurationFacet.class);
+ //final ConfigurationFacet facet = context.mock(ConfigurationFacet.class);
final ConfigurationUtilityService configUtilService = context.mock(ConfigurationUtilityService.class);
@@ -159,7 +192,7 @@ public class UpdateResourceConfigurationRunnerTest extends ConfigManagementTest
ConfigurationUpdateRequest updateRequest = new ConfigurationUpdateRequest(configUpdateId, config, resourceId);
UpdateResourceConfigurationRunner updateRunner = new UpdateResourceConfigurationRunner(null, resourceType,
- facet, updateRequest);
+ configMgmt, updateRequest);
updateRunner.setConfigUtilService(configUtilService);
String errorMsg = "Configuration facet did not indicate success or failure - assuming failure.";
@@ -186,14 +219,14 @@ public class UpdateResourceConfigurationRunnerTest extends ConfigManagementTest
final ConfigurationServerService configServerService = context.mock(ConfigurationServerService.class);
- final ConfigurationFacet facet = context.mock(ConfigurationFacet.class);
+ //final ConfigurationFacet facet = context.mock(ConfigurationFacet.class);
int configUpdateId = -1;
ConfigurationUpdateRequest updateRequest = new ConfigurationUpdateRequest(configUpdateId, config, resourceId);
UpdateResourceConfigurationRunner updateRunner = new UpdateResourceConfigurationRunner(configServerService,
- resourceType, facet, updateRequest);
+ resourceType, configMgmt, updateRequest);
final NullPointerException exception = new NullPointerException("Unexpected error during update");
@@ -214,14 +247,12 @@ public class UpdateResourceConfigurationRunnerTest extends ConfigManagementTest
public void failureResponseShouldBeReturnedWhenFacetThrowsAnExceptionInEmbeddedMode() throws Exception {
final Configuration config = createStructuredConfig();
- final ConfigurationFacet facet = context.mock(ConfigurationFacet.class);
-
int configUpdateId = -1;
ConfigurationUpdateRequest updateRequest = new ConfigurationUpdateRequest(configUpdateId, config, resourceId);
UpdateResourceConfigurationRunner updateRunner = new UpdateResourceConfigurationRunner(null, resourceType,
- facet, updateRequest);
+ configMgmt, updateRequest);
final NullPointerException exception = new NullPointerException("Unexpected error during update");
diff --git a/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java b/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
index 03581eb..b9bf46d 100644
--- a/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
+++ b/modules/test-utils/src/main/java/org/rhq/test/AssertUtils.java
@@ -25,6 +25,8 @@ package org.rhq.test;
import static org.testng.Assert.*;
+import java.util.Collection;
+
public class AssertUtils {
/**
@@ -47,4 +49,23 @@ public class AssertUtils {
assertTrue(result.isMatch(), msg + " -- " + result.getDetails());
}
+ /**
+ * Verifies that two collections are equal, according to the definition of <code>equals()</code> of the contained
+ * elements. Order is ignored as well as the runtime type of the collections.
+ *
+ * @param expected The expected collection to compare against
+ * @param actual The actual collection to compare against
+ * @param msg An error message
+ * @param <T> The type of the elements in the collections
+ */
+ public static <T> void assertCollectionEqualsNoOrder(Collection<T> expected, Collection<T> actual, String msg) {
+ CollectionEqualsChecker<T> checker = new CollectionEqualsChecker<T>();
+ checker.setExpected(expected);
+ checker.setActual(actual);
+
+ EqualsResult result = checker.execute();
+
+ assertTrue(result.isEqual(), msg + " -- " + result.getDetails());
+ }
+
}
diff --git a/modules/test-utils/src/main/java/org/rhq/test/CollectionEqualsChecker.java b/modules/test-utils/src/main/java/org/rhq/test/CollectionEqualsChecker.java
new file mode 100644
index 0000000..20539da
--- /dev/null
+++ b/modules/test-utils/src/main/java/org/rhq/test/CollectionEqualsChecker.java
@@ -0,0 +1,91 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.test;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class CollectionEqualsChecker<T> {
+
+ private Collection<T> expected;
+
+ private Collection<T> actual;
+
+ public void setExpected(Collection<T> expected) {
+ this.expected = expected;
+ }
+
+ public void setActual(Collection<T> actual) {
+ this.actual = actual;
+ }
+
+ public EqualsResult execute() {
+ boolean isMatch = true;
+ StringBuilder details = new StringBuilder();
+
+ if (expected.size() != actual.size()) {
+ isMatch = false;
+ details.append("Expected " + expected.size() + " elements but found " + actual.size() + " elements\n");
+ }
+
+ List<T> elementsThatShouldBePresent = findMissingElements(expected, actual);
+ if (!elementsThatShouldBePresent.isEmpty()) {
+ isMatch = false;
+ details.append("Expected to find the following elements:\n\t" +
+ toString(elementsThatShouldBePresent) + "\n\n");
+ }
+
+ List<T> elementsThatShouldNotBePresent = findMissingElements(actual, expected);
+ if (!elementsThatShouldNotBePresent.isEmpty()) {
+ isMatch = false;
+ details.append("Did not expect to find the following elements:\n\t" +
+ toString(elementsThatShouldNotBePresent) + "\n\n");
+ }
+
+ return new EqualsResult(isMatch, details.toString());
+ }
+
+ private List<T> findMissingElements(Collection<T> elementsToSearchFor, Collection<T> elementsToSearch) {
+ List<T> missingElements = new ArrayList<T>();
+ for (T element : elementsToSearchFor) {
+ if (!elementsToSearch.contains(element)) {
+ missingElements.add(element);
+ }
+ }
+ return missingElements;
+ }
+
+ private String toString(List<T> list) {
+ StringBuilder buffer = new StringBuilder("[");
+ for (T element : list) {
+ buffer.append(element.toString() + ", ");
+ }
+ buffer.delete(buffer.length() - 2, buffer.length());
+ buffer.append("]");
+
+ return buffer.toString();
+ }
+
+}
diff --git a/modules/test-utils/src/main/java/org/rhq/test/EqualsResult.java b/modules/test-utils/src/main/java/org/rhq/test/EqualsResult.java
new file mode 100644
index 0000000..a485efc
--- /dev/null
+++ b/modules/test-utils/src/main/java/org/rhq/test/EqualsResult.java
@@ -0,0 +1,44 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.test;
+
+public class EqualsResult {
+
+ private boolean isEqual;
+
+ private String details;
+
+ public EqualsResult(boolean equals, String details) {
+ isEqual = equals;
+ this.details = details;
+ }
+
+ public boolean isEqual() {
+ return isEqual;
+ }
+
+ public String getDetails() {
+ return details;
+ }
+}
14 years, 6 months
[rhq] Branch 'content' - modules/enterprise
by John Matthews
modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/PrimaryXML.java | 18 +++++++---
1 file changed, 13 insertions(+), 5 deletions(-)
New commits:
commit 9c4aa975cc40ae3e651e7b8cb8c9d615a4bc95f0
Author: John Matthews <jmatthew(a)redhat.com>
Date: Mon Nov 23 19:35:13 2009 -0500
1034 - fix for pkg install from yum client
When constructing the package metadata to send to yum,
we write epoch values of None as '0'.
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/PrimaryXML.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/PrimaryXML.java
index 6fe726b..ee94f40 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/PrimaryXML.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/PrimaryXML.java
@@ -21,6 +21,7 @@ package org.rhq.enterprise.server.plugins.rhnhosted;
import java.io.Serializable;
import java.util.List;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdom.Element;
@@ -104,7 +105,7 @@ public class PrimaryXML {
return "EQ";
}
- log.error("Unknown rpm sense value of " + sense + " which parsed to an integer of " + tmp);
+ log.debug("Unknown rpm sense value of " + sense + " which parsed to an integer of " + tmp);
return "";
}
@@ -140,7 +141,7 @@ public class PrimaryXML {
static public String getRelease(String version) {
int start = version.indexOf("-");
if (start < 0) {
- return ""; //unsure how to parse, return ""
+ return "";
}
start = start + 1; // go past the "-" character
return version.substring(start);
@@ -168,7 +169,12 @@ public class PrimaryXML {
version.setText(pkg.getVersion());
version.setAttribute("ver", pkg.getVersion());
version.setAttribute("rel", pkg.getRelease());
- version.setAttribute("epoch", pkg.getEpoch());
+ String epoch = pkg.getEpoch();
+ // Note, if epoch is empty we need to change it to a zero as that is what yum expects.
+ if (StringUtils.isBlank(epoch)) {
+ epoch = "0";
+ }
+ version.setAttribute("epoch", epoch);
top.addContent(version);
Element checksum = new Element("checksum");
@@ -211,8 +217,10 @@ public class PrimaryXML {
Element location = new Element("location");
//This value can not be empty and can not contain a "?".
//It's value is ignored by the RHQ processing for yum.
- //RHQ will append a series of request parameters to download the file.
- location.setAttribute("href", "getPackage");
+ //RHQ will append a series of request parameters to download the file.
+ String rpmName = RHNHelper.constructRpmName(pkg.getName(), pkg.getVersion(), pkg.getRelease(), pkg.getEpoch(),
+ pkg.getPackageArch());
+ location.setAttribute("href", rpmName);
top.addContent(location);
Element format = new Element("format");
14 years, 6 months