[rhq] Branch 'gwt' - modules/enterprise
by Greg Hinkle
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/RHQPortal.java | 6 +++++
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/server/inventory/resource/ResourceGWTServiceImpl.java | 11 +++++++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java | 4 +--
3 files changed, 18 insertions(+), 3 deletions(-)
New commits:
commit 2c82ad526b88b453d5a37a59d9258de3c130aeb4
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Wed Jan 27 16:23:17 2010 -0500
Fix the criteria query stuff and hibernate detach results.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/RHQPortal.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/RHQPortal.java
index 2e53e67..ddc0d38 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/RHQPortal.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/RHQPortal.java
@@ -68,6 +68,12 @@ public class RHQPortal implements EntryPoint {
}
public void onSuccess(PageList<Resource> result) {
+ mainPanel.clear();
+
+ for (Resource res : result) {
+ mainPanel.add(new Label(res.getName() + " (" + res.getId() + ")"));
+ }
+
Window.alert("Loaded resources " + result.size());
}
});
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/server/inventory/resource/ResourceGWTServiceImpl.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/server/inventory/resource/ResourceGWTServiceImpl.java
index 02d2fe7..a81fe57 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/server/inventory/resource/ResourceGWTServiceImpl.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/server/inventory/resource/ResourceGWTServiceImpl.java
@@ -27,6 +27,7 @@ import org.rhq.enterprise.gui.gwt.client.inventory.resource.ResourceGWTService;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+import org.rhq.enterprise.server.util.HibernateDetachUtility;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -38,7 +39,15 @@ public class ResourceGWTServiceImpl extends RemoteServiceServlet implements Reso
public PageList<Resource> findResourcesByCriteria(ResourceCriteria criteria) {
ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
- return resourceManager.findResourcesByCriteria(subjectManager.getOverlord(), criteria);
+ try {
+ PageList<Resource> result = resourceManager.findResourcesByCriteria(subjectManager.getOverlord(), criteria);
+ HibernateDetachUtility.nullOutUninitializedFields(result,
+ HibernateDetachUtility.SerializationType.SERIALIZATION);
+ return result;
+ } catch (Exception e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ throw new RuntimeException(e);
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
index 9c8ee46..1bc91f0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
@@ -302,7 +302,7 @@ public final class CriteriaQueryGenerator {
Object fetchFieldValue = null;
try {
fetchField.setAccessible(true);
- fetchFieldValue = fetchField.get(this);
+ fetchFieldValue = fetchField.get(criteria);
} catch (IllegalAccessException iae) {
throw new RuntimeException(iae);
}
@@ -349,7 +349,7 @@ public final class CriteriaQueryGenerator {
for (Field filterField : getFields(criteria, Criteria.Type.FILTER)) {
Object filterFieldValue = null;
try {
- filterFieldValue = filterField.get(this);
+ filterFieldValue = filterField.get(criteria);
} catch (IllegalAccessException iae) {
throw new RuntimeException(iae);
}
14 years, 4 months
[rhq] Branch 'raw-config' - 11 commits - modules/core modules/enterprise modules/plugins
by John Sanda
modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml | 2
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 2
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java | 6
modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java | 7
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java | 7
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java | 3
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java | 1
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java | 81 ++---
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml | 26 +
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml | 160 +++++-----
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/notificationTemplates.xhtml | 2
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml | 18 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java | 3
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java | 4
modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java | 4
modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml | 6
modules/plugins/kickstart/src/main/java/org/rhq/plugins/kickstart/KickstartServerComponent.java | 25 +
18 files changed, 211 insertions(+), 148 deletions(-)
New commits:
commit 1f67b2e63fe503b65420a07a860fc8b601ca1826
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jan 27 16:14:18 2010 -0500
Fixing merge error
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
index a6d33df..fc9fb63 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
@@ -282,10 +282,6 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
return "foo";
}
- public SyncProgressWeight getSyncProgressWeight() {
- return SyncProgressWeight.DEFAULT_WEIGHTS;
- }
-
/**
* Returns a list of repo names that were used to all calls to
* {@link #synchronizePackages(String, PackageSyncReport, Collection)}
commit 597c60cb164470972f798c239a48ff4057721714
Merge: f530c34... d291388...
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jan 27 15:21:15 2010 -0500
Merge branch 'master' into raw-config
commit d2913885ba5aeee5d6efcdca1350b0a70bbcff61
Merge: 2dde4f5... c5470ae...
Author: Justin Harris <jharris(a)redhat.com>
Date: Wed Jan 27 13:58:28 2010 -0500
Merge remote branch 'origin/master' into alertPlugin
commit c5470ae79abb7ba7d7814d0f4feb08776f9dc798
Author: Bryan Kearney <bkearney(a)redhat.com>
Date: Wed Jan 27 13:09:25 2010 -0500
Catch koan failures and record them
diff --git a/modules/plugins/kickstart/src/main/java/org/rhq/plugins/kickstart/KickstartServerComponent.java b/modules/plugins/kickstart/src/main/java/org/rhq/plugins/kickstart/KickstartServerComponent.java
index de56c4a..ed7f03d 100644
--- a/modules/plugins/kickstart/src/main/java/org/rhq/plugins/kickstart/KickstartServerComponent.java
+++ b/modules/plugins/kickstart/src/main/java/org/rhq/plugins/kickstart/KickstartServerComponent.java
@@ -61,9 +61,15 @@ public class KickstartServerComponent implements ResourceComponent, OperationFac
String virtName = configuration.getSimpleValue("name", "Guest " + System.currentTimeMillis());
String profile = configuration.getSimpleValue("profile", "profile");
String server = configuration.getSimpleValue("server", "localhost");
- ProcessExecutionResults pr = this.execute(command, "--virt", "--server", server, "--profile", profile,
- "--virt-name", virtName);
- res.setSimpleResult(pr.getExitCode().toString());
+ String[] argsString = { "--virt", "--server", server, "--profile", profile, "--virt-name", virtName };
+ ProcessExecutionResults pr = this.execute(command, argsString);
+ if (pr.getExitCode() > 0) {
+ log.error("Error executing command: " + this.buildCommandString(command, argsString));
+ res.setErrorMessage(pr.getCapturedOutput());
+ } else {
+ res.setSimpleResult(pr.getCapturedOutput());
+ }
+
}
return res;
@@ -72,10 +78,7 @@ public class KickstartServerComponent implements ResourceComponent, OperationFac
public ProcessExecutionResults execute(String process, String... args) {
List<String> argsList = Arrays.asList(args);
if (log.isDebugEnabled()) {
- String argsString = "";
- for (String arg : argsList)
- argsString = argsString + " " + arg;
- log.debug("Executing command " + process + argsString);
+ log.debug("Executing command " + this.buildCommandString(process, args));
}
ProcessExecution pe = new ProcessExecution(process);
pe.setCaptureOutput(true);
@@ -85,4 +88,12 @@ public class KickstartServerComponent implements ResourceComponent, OperationFac
log.debug("Result " + pr.getExitCode());
return pr;
}
+
+ private String buildCommandString(String process, String... argsList) {
+ String argsString = process;
+ for (String arg : argsList)
+ argsString = argsString + " " + arg;
+ return process;
+
+ }
}
commit 03ec3f8d46c55615ce0f256eee607302d4feed36
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 27 12:08:09 2010 -0500
trivial fix to a javadoc comment
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
index e77df6f..32a7398 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
@@ -289,10 +289,7 @@ public class AgentMain {
private boolean m_advancedSetup = false;
/**
- * If the agent was told to setup (via a command line option), this will be trueneeds to be setup when it is first
- * initialized, by default the basic setup will run which asks the user for some basic, minimal information
- * necessary to get the agent started. However, if this flag is <code>true</code>, the advanced setup will run as
- * opposed to the basic setup.
+ * If the agent was told to setup (via a command line option), this will be true.
*/
private boolean m_forcedSetup = false;
@@ -3312,4 +3309,4 @@ public class AgentMain {
return this.serverEndpoint + "@" + new Date(this.timestamp);
}
}
-}
\ No newline at end of file
+}
commit ebaf42d67c501e1383e8e08eaa95ae58fdc5f77e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 27 12:03:26 2010 -0500
change the blob column to clob since this really is text of the action script/receipt and not raw binary data
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
index d558c09..d1ae3ad 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -505,7 +505,7 @@
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="NAME" size="200" type="VARCHAR2" required="true"/>
<column name="VERSION" size="500" type="VARCHAR2" required="true"/>
- <column name="ACTION" type="BLOB" required="true"/>
+ <column name="ACTION" type="CLOB" required="true"/>
<column name="BUNDLE_ID" type="INTEGER" required="true" references="RHQ_BUNDLE"/>
<column name="DISTRIBUTION_ID" type="INTEGER" required="false" references="RHQ_DISTRIBUTION"/>
</table>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 3eca05e..dd16274 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2826,7 +2826,7 @@
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="NAME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="VERSION" columnType="VARCHAR2" precision="500" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="VERSION" nullable="FALSE" />
- <schema-addColumn table="RHQ_BUNDLE_VERSION" column="ACTION" columnType="BLOB" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="ACTION" columnType="CLOB" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="ACTION" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" nullable="FALSE" />
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
index a4c4d31..f2ea97c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
@@ -72,7 +72,7 @@ public class BundleVersion implements Serializable {
private String version;
@Column(name = "ACTION", nullable = false)
- private byte[] action;
+ private String action;
@JoinColumn(name = "BUNDLE_ID", referencedColumnName = "ID", nullable = false)
@ManyToOne(fetch = FetchType.LAZY)
@@ -116,11 +116,11 @@ public class BundleVersion implements Serializable {
this.version = version;
}
- public byte[] getAction() {
+ public String getAction() {
return action;
}
- public void setAction(byte[] action) {
+ public void setAction(String action) {
this.action = action;
}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
index f4ee5d4..0ac6459 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
@@ -22,7 +22,6 @@
*/
package org.rhq.core.domain.bundle.test;
-import java.util.Arrays;
import java.util.List;
import javax.persistence.EntityManager;
@@ -49,7 +48,7 @@ public class BundleTest extends AbstractEJB3Test {
int id;
String name = "BundleTest-testBundleVersionRepo";
- byte[] action = "action/script/recipe is here".getBytes();
+ String action = "action/script/recipe is here";
Repo repo1 = new Repo(name + "-Repo1");
Repo repo2 = new Repo(name + "-Repo2");
@@ -126,7 +125,7 @@ public class BundleTest extends AbstractEJB3Test {
int id;
String name = "BundleTest-testBundleVersion";
- byte[] action = "action/script/recipe is here".getBytes();
+ String action = "action/script/recipe is here";
BundleType bundleType = new BundleType(name + "-Type");
Bundle bundle = new Bundle(name + "-Bundle", bundleType);
@@ -155,7 +154,7 @@ public class BundleTest extends AbstractEJB3Test {
assert bvFind.getId() == bv.getId();
assert bvFind.getName().equals(bv.getName());
assert bvFind.getVersion().equals(bv.getVersion());
- assert Arrays.equals(bvFind.getAction(), bv.getAction());
+ assert bvFind.getAction().equals(bv.getAction());
assert bvFind.getBundle().equals(bv.getBundle());
assert bvFind.equals(bv);
assert bvFind.hashCode() == bv.hashCode();
commit 83590bcca95e79ea331bcb2a9c20737bee8d4321
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 11:33:40 2010 -0500
Fixed botched merge.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index 1fe5bab..fdddc60 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -101,6 +101,7 @@ import org.rhq.enterprise.server.core.EmailManagerLocal;
import org.rhq.enterprise.server.core.plugin.PluginDeploymentScannerMBean;
import org.rhq.enterprise.server.discovery.DiscoveryBossBean;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
+import org.rhq.enterprise.server.entitlement.EntitlementManagerLocal;
import org.rhq.enterprise.server.entitlement.EntitlementManagerBean;
import org.rhq.enterprise.server.event.EventManagerBean;
import org.rhq.enterprise.server.event.EventManagerLocal;
@@ -345,7 +346,7 @@ public final class LookupUtil {
return lookupLocal(EmailManagerBean.class);
}
- public static EntitlementStuffManagerLocal getEntitlementManagerBean() {
+ public static EntitlementManagerLocal getEntitlementManagerBean() {
return lookupLocal(EntitlementManagerBean.class);
}
commit 2dde4f55abe2517db8330f7a700816a6e68b8e57
Merge: 82d2bf3... 52e5199...
Author: Heiko W. Rupp <pilhuhn(a)fedorapeople.org>
Date: Wed Jan 27 12:31:09 2010 +0100
Merge branch 'alertPlugin' of ssh://git.fedorahosted.org/git/rhq/rhq into alertPlugin
commit 82d2bf38963877ec23fabe8452fa32ab53a34f4b
Author: Heiko W. Rupp <pilhuhn(a)fedorapeople.org>
Date: Wed Jan 27 12:19:23 2010 +0100
Add alert id BZ 555091, comment 10
diff --git a/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java b/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
index 341b1bf..a2795c8 100644
--- a/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
+++ b/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
@@ -51,7 +51,8 @@ public class MicroblogSender extends AlertSender {
Twitter twitter = new Twitter(user,password,baseUrl);
AlertManagerLocal alertManager = LookupUtil.getAlertManager();
twitter.setSource("Jopr");
- StringBuilder b = new StringBuilder("Alert: '");
+ StringBuilder b = new StringBuilder("Alert ");
+ b.append(alert.getId()).append(":'"); // Alert id
b.append(alert.getAlertDefinition().getResource().getName());
b.append("' (");
b.append(alert.getAlertDefinition().getResource().getId());
@@ -69,6 +70,7 @@ public class MicroblogSender extends AlertSender {
log.warn("Notification via Microblog failed for " + txt + " ", e);
result = new SenderResult(ResultState.FAILURE,"Sending failed :" + e.getMessage());
+
}
return result;
}
commit 52e5199beafae566462444a61033503a5a9a839a
Author: Justin Harris <jharris(a)redhat.com>
Date: Tue Jan 26 16:05:41 2010 -0500
Making lots of small cosmetic changes to the alert definition page.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml
index 2c9edb9..cd9e56c 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml
@@ -42,12 +42,14 @@
ignoreDupResponses="true"
requestDelay="25"
reRender="alertConfig,senderName"
- oncomplete="updateCustomContent();" />
+ oncomplete="updateCustomContent();"
+ onsubmit="showLoadConfig();" />
<a4j:support event="onkeyup"
ignoreDupResponses="true"
requestDelay="150"
reRender="alertConfig,senderName"
- oncomplete="updateCustomContent();" />
+ oncomplete="updateCustomContent();"
+ onsubmit="showLoadConfig();" />
<a4j:support event="onorderchanged"
ignoreDupResponses="true"
requestDelay="250"
@@ -78,6 +80,12 @@
</h:panelGroup>
<h:panelGroup>
+ <div id="configLoader" style="display: none; margin: auto;">
+ <strong><h:outputText value="Loading Configuration..." /></strong>
+ <br /><br />
+ <img src="/images/ajax-loader.gif" alt="Loading Configuration..." />
+ </div>
+
<h:form id="alertConfig">
<input type="hidden" name="id" value="${param.id}"/>
<input type="hidden" name="ad" value="${param.ad}"/>
@@ -108,77 +116,81 @@
</rich:panel>
<rich:modalPanel id="addAlertPanel" moveable="false" autosized="true">
- <f:facet name="header">
- <h:outputText value="Add Alert Notification" />
- </f:facet>
- <h:form id="newNotificationForm">
- <input type="hidden" name="id" value="${param.id}"/>
- <input type="hidden" name="ad" value="${param.ad}"/>
-
- <h:outputLabel for="alertNameInput" value="Alert Notification Name:" />
- <br />
- <h:inputText id="alertNameInput"
- value="#{alertNotificationsUIBean.newAlertName}"
- maxlength="100"
- required="true" />
-
- <h:message for="alertNameInput"
- infoClass="InfoBlock"
- warnClass="WarnBlock"
- errorClass="ErrorBlock"
- fatalClass="FatalBlock" />
- <br /><br />
-
- <h:outputLabel for="senderList" value="Alert Sender Type:" />
- <br />
- <h:selectOneMenu id="senderList" value="#{alertNotificationsUIBean.selectedNewSender}">
- <f:selectItems value="#{alertNotificationsUIBean.allAlertSenders}" />
- </h:selectOneMenu>
- <br /><br />
-
- <h:commandButton id="addAlertButton"
- value="Add Alert Notification"
- action="#{alertNotificationsUIBean.addAlertSender}"
- styleClass="buttonmed">
- </h:commandButton>
-
- <br /><br />
- <h:outputLink id="notificationCancelLink" styleClass="buttonmed" value="#">
- <h:outputText value="Cancel" />
- <rich:componentControl for="addAlertPanel" attachTo="notificationCancelLink" operation="hide" event="onclick" />
- </h:outputLink>
- </h:form>
- </rich:modalPanel>
+ <h:panelGrid columns="2" width="100%" columnClasses="col1,col2">
+ <rich:panel id="addNewAlertPanel">
+ <f:facet name="header">
+ <h:outputText value="Add New Alert Notifications"/>
+ </f:facet>
- <rich:panel id="addAlertFromTemplatePanel">
- <f:facet name="header">
- <h:outputText value="Add Alert Notifications from template"/>
- </f:facet>
+ <h:form id="newNotificationForm">
+ <input type="hidden" name="id" value="${param.id}"/>
+ <input type="hidden" name="ad" value="${param.ad}"/>
- <h:form id="newNotificationsFromTemplateForm">
- <input type="hidden" name="id" value="${param.id}"/>
- <input type="hidden" name="ad" value="${param.ad}"/>
+ <div style="height: 100px;">
+ <h:outputLabel for="alertNameInput" value="Alert Notification Name:" />
+ <br />
+ <h:inputText id="alertNameInput"
+ value="#{alertNotificationsUIBean.newAlertName}"
+ maxlength="100"
+ required="true" />
+
+ <h:message for="alertNameInput"
+ infoClass="InfoBlock"
+ warnClass="WarnBlock"
+ errorClass="ErrorBlock"
+ fatalClass="FatalBlock" />
+ <br /><br />
+
+ <h:outputLabel for="senderList" value="Alert Sender Type:" />
+ <br />
+ <h:selectOneMenu id="senderList" value="#{alertNotificationsUIBean.selectedNewSender}">
+ <f:selectItems value="#{alertNotificationsUIBean.allAlertSenders}" />
+ </h:selectOneMenu>
+ </div>
+
+ <h:commandButton id="addAlertButton"
+ value="Add Alert Notification"
+ action="#{alertNotificationsUIBean.addAlertSender}"
+ styleClass="buttonmed">
+ </h:commandButton>
+ </h:form>
+ </rich:panel>
- <h:selectOneMenu id="templateList" value="#{alertNotificationsUIBean.selectedTemplate}">
- <f:selectItems value="#{alertNotificationsUIBean.allNotificationTemplates}"/>
- </h:selectOneMenu>
+ <rich:panel id="addAlertFromTemplatePanel">
+ <f:facet name="header">
+ <h:outputText value="Add Alert Notifications from template"/>
+ </f:facet>
+ <h:form id="newNotificationsFromTemplateForm">
+ <input type="hidden" name="id" value="${param.id}"/>
+ <input type="hidden" name="ad" value="${param.ad}"/>
- <br/>
+ <div style="height: 100px;">
+ <h:selectOneMenu id="templateList" value="#{alertNotificationsUIBean.selectedTemplate}">
+ <f:selectItems value="#{alertNotificationsUIBean.allNotificationTemplates}"/>
+ </h:selectOneMenu>
- <h:selectBooleanCheckbox title="clearExisting" value="#{alertNotificationsUIBean.clearExistingNotifications}"/>
- <h:outputText value="Clear existing notifications"/>
+ <br/>
- <br /><br />
+ <h:selectBooleanCheckbox title="clearExisting" value="#{alertNotificationsUIBean.clearExistingNotifications}"/>
+ <h:outputText value="Clear existing notifications"/>
+ </div>
- <h:commandButton id="addTemplateButton"
- value="Add Alert Notification from Template"
- action="#{alertNotificationsUIBean.addAlertSenderFromTemplate}"
- styleClass="buttonmed">
- </h:commandButton>
- </h:form>
+ <h:commandButton id="addTemplateButton"
+ value="Add Alert Notification from Template"
+ action="#{alertNotificationsUIBean.addAlertSenderFromTemplate}"
+ styleClass="buttonmed"
+ style="margin-top: auto;">
+ </h:commandButton>
+ </h:form>
+ </rich:panel>
+ </h:panelGrid>
- </rich:panel>
+ <h:outputLink id="notificationCancelLink" styleClass="buttonmed" value="#" style="float: right;">
+ <h:outputText value="Cancel" />
+ <rich:componentControl for="addAlertPanel" attachTo="notificationCancelLink" operation="hide" event="onclick" />
+ </h:outputLink>
+ </rich:modalPanel>
<br />
<br />
@@ -189,16 +201,28 @@
- <script>
+ <script type="text/javascript">
function updateCustomContent() {
var sender = $('senderName').innerHTML;
new Ajax.Updater('customContentArea',
'notif/customContent.xhtml',
{ method: 'get',
- parameters: {'senderName': sender,
- 'ad': #{param.ad},
- 'id': #{param.id}}
+ parameters: {'senderName': sender, 'ad': #{param.ad}, 'id': #{param.id}}
});
+
+ hideLoadConfig();
+ }
+
+ function showLoadConfig() {
+ $('alertConfig').hide();
+ $('customContentArea').hide();
+ $('configLoader').show();
+ }
+
+ function hideLoadConfig() {
+ $('configLoader').hide();
+ $('alertConfig').show();
+ $('customContentArea').show();
}
Event.observe(window, 'load', function() {
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml
index 5b3e6d4..8716d01 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml
@@ -164,12 +164,12 @@
<input type="hidden" name="ad" value="#{param.ad}" />
<input type="hidden" name="id" value="#{param.id}" />
- <h:panelGrid columns="2" border="1" cellpadding="5">
+ <h:panelGrid columns="2" border="1" cellpadding="5" style="margin: 15px;">
<h:outputLabel for="alertNameInput" value="Name: " />
- <h:inputText id="alertNameInput" value="#{alertUIBean.alertDefinition.name}" />
+ <h:inputText id="alertNameInput" value="#{alertUIBean.alertDefinition.name}" style="width: 300px;" />
<h:outputLabel for="alertDescriptionInput" value="Description: " />
- <h:inputTextarea id="alertDescriptionInput" value="#{alertUIBean.alertDefinition.description}" />
+ <h:inputTextarea id="alertDescriptionInput" value="#{alertUIBean.alertDefinition.description}" style="width: 300px;" />
<h:outputLabel for="alertPriorityInput" value="Priority: " />
<h:selectOneMenu id="alertPriorityInput" value="#{alertUIBean.alertDefinition.priority}">
@@ -180,14 +180,14 @@
<h:selectBooleanCheckbox id="alertEnabledInput" value="#{alertUIBean.alertDefinition.enabled}" />
</h:panelGrid>
+ <h:outputLink id="cancelLink" styleClass="buttonmed" value="#" style="float: right;">
+ <h:outputText value="Cancel" />
+ <rich:componentControl for="editAlertDefinitionPanel" attachTo="cancelLink" operation="hide" event="onclick" />
+ </h:outputLink>
+
<h:commandButton id="saveButton" value="Save Changes" styleClass="buttonmed" action="#{alertUIBean.saveAlertDefinition}" />
</h:form>
-
- <br />
- <h:outputLink id="cancelLink" styleClass="buttonmed" value="#">
- <h:outputText value="Cancel" />
- <rich:componentControl for="editAlertDefinitionPanel" attachTo="cancelLink" operation="hide" event="onclick" />
- </h:outputLink>
+
</rich:modalPanel>
</ui:define>
commit a40c6a2f7f6f98c47891563b7f42f4a0808b3615
Author: Justin Harris <jharris(a)redhat.com>
Date: Tue Jan 26 13:55:56 2010 -0500
Altering navigation rules for notification templates.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java
index 53d5c19..208f15d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java
@@ -43,7 +43,7 @@ import javax.persistence.Table;
@NamedQueries({
@NamedQuery(name = NotificationTemplate.FIND_BY_NAME, query = "SELECT t FROM NotificationTemplate t WHERE t.name = :name"),
- @NamedQuery(name = NotificationTemplate.FIND_ALL, query = "SELECT t FROM NotificationTemplate t LEFT JOIN FETCH t.notifications")
+ @NamedQuery(name = NotificationTemplate.FIND_ALL, query = "SELECT t FROM NotificationTemplate AS t")
})
@Entity
@Table(name="RHQ_ALERT_NOTIF_TEMPL")
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java
index 2b6b2dd..b2b1df3 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.alert;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -49,7 +50,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
@Scope(ScopeType.PAGE)
@Name("alertNotificationsUIBean")
-public class AlertNotificationsUIBean {
+public class AlertNotificationsUIBean implements Serializable {
private final static String SUCCESS_OUTCOME = "success";
@RequestParameter("ad")
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java
index b11f958..4b01d25 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java
@@ -29,7 +29,6 @@ import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.datamodel.DataModel;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.log.Log;
import org.rhq.core.domain.alert.AlertCondition;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java
index b82c2d4..e9afb57 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java
@@ -38,7 +38,6 @@ import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.web.RequestParameter;
-import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.alert.notification.NotificationTemplate;
import org.rhq.core.domain.auth.Subject;
@@ -46,7 +45,6 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
-import org.rhq.enterprise.server.alert.AlertDefinitionManagerLocal;
import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -61,11 +59,12 @@ import org.rhq.enterprise.server.util.LookupUtil;
@SuppressWarnings("unused")
public class NotificationTemplatesUIBean implements Serializable {
- private final static String SUCCESS_OUTCOME = "success";
- @RequestParameter("ad")
- private Integer alertDefinitionId;
+ private final static String CONTINUE_OUTCOME = "continue";
+ private final static String NEW_OUTCOME = "new";
@RequestParameter("nid")
private Integer notificationId;
+ @RequestParameter("tid")
+ private Integer templateId;
private String opMode;
private List<AlertNotification> alertNotifications;
private Set<AlertNotification> selectedNotifications;
@@ -81,7 +80,7 @@ public class NotificationTemplatesUIBean implements Serializable {
private AlertNotificationConverter notificationConverter;
private AlertNotificationManagerLocal alertNotificationManager;
private static final String EDIT = "EDIT";
- private List<NotificationTemplate> listOfTemplates;
+ private List<NotificationTemplate> notificationTemplates;
NotificationTemplate selectedTemplate;
public List<AlertNotification> getAlertNotifications() {
@@ -192,6 +191,10 @@ public class NotificationTemplatesUIBean implements Serializable {
this.selectedTemplate = selectedTemplate;
}
+ public List<NotificationTemplate> getNotificationTemplates() {
+ return this.notificationTemplates;
+ }
+
private void lookupActiveConfigDefinition() {
System.out.println("lookupActiveConfigDef: activeNotification is " + activeNotification);
@@ -201,13 +204,6 @@ public class NotificationTemplatesUIBean implements Serializable {
}
}
- public AlertDefinition getAlertDefinition() {
- AlertDefinitionManagerLocal definitionManager = LookupUtil.getAlertDefinitionManager();
- Subject subject = EnterpriseFacesContextUtility.getSubject();
-
- return definitionManager.getAlertDefinitionById(subject, alertDefinitionId);
- }
-
@Create
public void initNotifications() {
this.alertNotificationManager = LookupUtil.getAlertNotificationManager();
@@ -218,10 +214,26 @@ public class NotificationTemplatesUIBean implements Serializable {
this.selectedNotifications = new HashSet<AlertNotification>();
this.notificationConverter = new AlertNotificationConverter();
this.notificationConverter.setAlertNotifications(alertNotifications);
+ this.notificationTemplates = alertNotificationManager.listNotificationTemplates(EnterpriseFacesContextUtility.getSubject());
+ selectActiveTemplate();
selectActiveNotification();
}
+ private void selectActiveTemplate() {
+ if (this.templateId != null) {
+ for (NotificationTemplate template : this.notificationTemplates) {
+ if (template.getId() == this.templateId) {
+ selectTemplate(template);
+
+ return;
+ }
+ }
+ }
+
+ opMode = "";
+ }
+
// Sets the initial state of the bean given the requrest parameters, this allows
// us to maintain the selected item across requests.
private void selectActiveNotification() {
@@ -271,7 +283,7 @@ public class NotificationTemplatesUIBean implements Serializable {
FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR,"Adding the sender failed: " + iae.getMessage() );
}
- return SUCCESS_OUTCOME;
+ return CONTINUE_OUTCOME;
}
public String saveConfiguration() {
@@ -281,7 +293,7 @@ public class NotificationTemplatesUIBean implements Serializable {
this.alertNotificationManager.updateAlertNotification(this.activeNotification);
}
- return SUCCESS_OUTCOME;
+ return CONTINUE_OUTCOME;
}
public String removeSelected() {
@@ -291,7 +303,7 @@ public class NotificationTemplatesUIBean implements Serializable {
alertNotificationManager.removeNotificationsFromTemplate(subject, selectedTemplate.getId(), toArray(ids));
- return SUCCESS_OUTCOME;
+ return CONTINUE_OUTCOME;
}
public String saveOrder() {
@@ -304,7 +316,7 @@ public class NotificationTemplatesUIBean implements Serializable {
this.alertNotificationManager.updateAlertNotification(notification);
}
- return SUCCESS_OUTCOME;
+ return CONTINUE_OUTCOME;
}
private List<Integer> getSelectedIds(Collection<AlertNotification> notifications) {
@@ -332,14 +344,7 @@ public class NotificationTemplatesUIBean implements Serializable {
return result;
}
- public List<NotificationTemplate> getNotificationTemplates() {
-
- List<NotificationTemplate> templates = alertNotificationManager.listNotificationTemplates(EnterpriseFacesContextUtility.getSubject());
- listOfTemplates = templates;
- return templates;
- }
-
- public String createNoticationTemplate() {
+ public String createNotificationTemplate() {
NotificationTemplate templ;
@@ -352,7 +357,7 @@ public class NotificationTemplatesUIBean implements Serializable {
FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR,"Creation of template failed: " + iae.getMessage());
}
- return SUCCESS_OUTCOME;
+ return NEW_OUTCOME;
}
public String deleteNotificationTemplate() {
@@ -362,7 +367,7 @@ public class NotificationTemplatesUIBean implements Serializable {
Iterator<Object> iter = selectedTemplates.getKeys();
while (iter.hasNext()) {
Integer row = (Integer) iter.next();
- NotificationTemplate templ = listOfTemplates.get(row);
+ NotificationTemplate templ = notificationTemplates.get(row);
ids.add(templ.getId());
}
@@ -375,26 +380,30 @@ public class NotificationTemplatesUIBean implements Serializable {
summary+="s";
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, summary);
- return SUCCESS_OUTCOME;
+ return NEW_OUTCOME;
}
- public String editNotificationTemplate() {
+ public void editNotificationTemplate() {
Subject subject = EnterpriseFacesContextUtility.getSubject();
System.out.println("in edit Template");
Iterator<Object> iter = selectedTemplates.getKeys();
if (selectedTemplates.size()==1) {
Integer row = (Integer) iter.next();
- selectedTemplate = listOfTemplates.get(row);
- alertNotifications = alertNotificationManager.getNotificationsForTemplate(subject,selectedTemplate.getId());
- this.notificationConverter.setAlertNotifications(alertNotifications);
- System.out.println("Selected template is " + selectedTemplate);
- opMode = EDIT;
+ selectTemplate(notificationTemplates.get(row));
}
- else
+ else {
opMode = "";
+ }
+ }
- return SUCCESS_OUTCOME;
+ private void selectTemplate(NotificationTemplate template) {
+ Subject subject = EnterpriseFacesContextUtility.getSubject();
+ selectedTemplate = template;
+ alertNotifications = alertNotificationManager.getNotificationsForTemplate(subject, selectedTemplate.getId());
+ this.notificationConverter.setAlertNotifications(alertNotifications);
+ System.out.println("Selected template is " + selectedTemplate);
+ opMode = EDIT;
}
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml
index fbff540..a760608 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml
@@ -106,5 +106,29 @@
</navigation-case>
</navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/rhq/resource/alert/notif/notificationTemplates.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-outcome>continue</from-outcome>
+ <to-view-id>/rhq/resource/alert/notif/notificationTemplates.xhtml?nid=#{notificationTemplateUIBean.activeNotification.id}&tid=#{notificationTemplateUIBean.selectedTemplate.id}</to-view-id>
+
+ <redirect />
+ </navigation-case>
+
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/rhq/resource/alert/notif/notificationTemplates.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-outcome>new</from-outcome>
+ <to-view-id>/rhq/resource/alert/notif/notificationTemplates.xhtml</to-view-id>
+
+ <redirect />
+ </navigation-case>
+
+ </navigation-rule>
-</faces-config>
\ No newline at end of file
+</faces-config>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/notificationTemplates.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/notificationTemplates.xhtml
index 18aedb0..17f5128 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/notificationTemplates.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/notificationTemplates.xhtml
@@ -102,7 +102,7 @@
<p/>
<h:commandButton id="newTemplateButton"
value="Create new Template"
- action="#{notificationTemplateUIBean.createNoticationTemplate}"
+ action="#{notificationTemplateUIBean.createNotificationTemplate}"
styleClass="buttonmed"/>
</h:form>
</rich:panel>
diff --git a/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml
index 8dba350..ae84d32 100644
--- a/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -17,7 +17,7 @@
<!-- Global preferences for all snmp alerts -->
<serverplugin:plugin-configuration>
- <c:simple-property name="snmpVersion" displayName="Snmp protcol version" type="string" required="false" default="1">
+ <c:simple-property name="snmpVersion" displayName="SNMP protcol version" type="string" required="false" default="1">
<c:property-options>
<c:option value="1"/>
<c:option value="2c"/>
@@ -28,7 +28,7 @@
<c:simple-property name="trapOid" displayName="Trap OID" description="OID for the trap sent" type="string" />
<c:simple-property name="community" type="string" default="public" description="Community - v1 and v2c only" required="false"/>
- <c:group name="1" displayName="Snmp version 1 properties" hiddenByDefault="true" >
+ <c:group name="1" displayName="SNMP version 1 properties" hiddenByDefault="true" >
<c:simple-property name="engineId" required="false"/>
<c:simple-property name="genericId" required="false"/>
<c:simple-property name="enterpriseOid" required="false"/>
@@ -40,7 +40,7 @@
Nothing special
</c:group>
-->
- <c:group name="3" displayName="Snmp version 3 properties" hiddenByDefault="true">
+ <c:group name="3" displayName="SNMP version 3 properties" hiddenByDefault="true">
<c:simple-property name="authProtocol" type="string" default="MD5">
<c:property-options>
<c:option value="none"/>
14 years, 4 months
[rhq] modules/core modules/enterprise
by jdob
modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/DynamicConfigurationPropertyValue.java | 70 ++++++++++
modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java | 2
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java | 5
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java | 9 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java | 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.java | 23 ++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java | 4
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java | 26 ++-
modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml | 21 ---
11 files changed, 125 insertions(+), 44 deletions(-)
New commits:
commit bcdc326ccd925beca43d12d336f575dc50583f26
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 15:49:25 2010 -0500
Refactored dynamic configuration properties to be retrieved with a display/value pair. This way, we are able to display "pretty" values to the user yet use different values programmatically.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java
index f10dc64..2aadf7d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java
@@ -184,7 +184,7 @@ import org.rhq.core.domain.util.serial.ExternalizableStrategy;
+ " AND s.fsystem = FALSE " //
+ " AND s.factive = TRUE"), //
@NamedQuery(name = Subject.QUERY_DYNAMIC_CONFIG_VALUES, query = "" //
- + "SELECT s.name FROM Subject AS s WHERE s.fsystem = false")
+ + "SELECT s.name, s.name FROM Subject AS s WHERE s.fsystem = false")
})
@SequenceGenerator(name = "RHQ_SUBJECT_ID_SEQ", sequenceName = "RHQ_SUBJECT_ID_SEQ")
@Table(name = "RHQ_SUBJECT")
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java
index 089ca55..482fa08 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java
@@ -92,7 +92,7 @@ import org.rhq.core.domain.auth.Subject;
+ " FROM RoleNotification rn" //
+ " WHERE rn.alertDefinition.id = :alertDefinitionId ) "), //
@NamedQuery(name = Role.QUERY_DYNAMIC_CONFIG_VALUES, query = "" //
- + "SELECT r.name FROM Role AS r")
+ + "SELECT r.name, r.name FROM Role AS r")
})
@SequenceGenerator(name = "RHQ_ROLE_ID_SEQ", sequenceName = "RHQ_ROLE_ID_SEQ")
@Table(name = "RHQ_ROLE")
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/DynamicConfigurationPropertyValue.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/DynamicConfigurationPropertyValue.java
new file mode 100644
index 0000000..433fe6a
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/DynamicConfigurationPropertyValue.java
@@ -0,0 +1,70 @@
+/*
+* 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.core.domain.configuration;
+
+/**
+ * Represents a single value that should be displayed to a user as an enumerated possibility for a dynamic
+ * configuration property. This object pairs a display name (shown to the user in the UI) with the programmatic
+ * value that is used if this value is selected.
+ *
+ * @author Jason Dobies
+ */
+public class DynamicConfigurationPropertyValue {
+
+ /**
+ * Display name to use for the value. This will be displayed to the user in the UI.
+ */
+ private String display;
+
+ /**
+ * Programmatic representation of the value that will be used when this value is selected by
+ * the user.
+ */
+ private String value;
+
+ public DynamicConfigurationPropertyValue(String display, String value) {
+ this.display = display;
+ this.value = value;
+ }
+
+ public String getDisplay() {
+ return display;
+ }
+
+ public void setDisplay(String display) {
+ this.display = display;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return "Value [Display = " + display + ", Value = " + value + "]";
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
index 3615a6a..4e4558e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
@@ -71,7 +71,7 @@ import org.rhq.core.domain.resource.ResourceType;
+ "JOIN pt.resourceType rt "
+ "LEFT JOIN FETCH pt.deploymentConfigurationDefinition cd "
+ "LEFT JOIN FETCH cd.templates cts " + "WHERE rt.id = :typeId AND pt.isCreationData = true"),
- @NamedQuery(name = PackageType.QUERY_DYNAMIC_CONFIG_VALUES, query = "SELECT pt.displayName FROM PackageType AS pt")
+ @NamedQuery(name = PackageType.QUERY_DYNAMIC_CONFIG_VALUES, query = "SELECT pt.displayName, pt.name FROM PackageType AS pt")
})
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_PACKAGE_TYPE_ID_SEQ")
@Table(name = "RHQ_PACKAGE_TYPE")
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java
index 1010cc7..9f90c44 100644
--- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java
@@ -24,6 +24,7 @@ package org.rhq.core.gui.configuration.helper;
import java.util.List;
+import org.rhq.core.domain.configuration.DynamicConfigurationPropertyValue;
import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
/**
@@ -32,7 +33,7 @@ import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
* <p/>
* <strong>In order to associate implementations of this interface with the rendering code, calls must be made to
* {@link PropertyRenderingUtility#putDynamicPropertyRetriever(org.rhq.core.domain.configuration.PropertyDynamicType,
- * DynamicPropertyRetriever)} to map the property type to the instance.</strong>
+ * DynamicPropertyRetriever)} to map the property type to the instance.</strong>
* <p/>
* This functionality is abstracted out to prevent the core-gui module from having to make non-core
* dependencies. Modules using core-gui can implement this interface using whatever means available,
@@ -48,5 +49,5 @@ public interface DynamicPropertyRetriever {
* @param propertyDefinition cannot be <code>null</code>
* @return list of values to use as both the name and value of the UI inputs; empty list if none are found
*/
- List<String> loadValues(PropertyDefinitionDynamic propertyDefinition);
+ List<DynamicConfigurationPropertyValue> loadValues(PropertyDefinitionDynamic propertyDefinition);
}
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
index c73205a..0d5531e 100644
--- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
@@ -44,6 +44,7 @@ import javax.faces.validator.ValidatorException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.rhq.core.domain.configuration.DynamicConfigurationPropertyValue;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
import org.rhq.core.domain.configuration.PropertyDynamicType;
@@ -129,11 +130,11 @@ public class PropertyRenderingUtility {
}
// Retrieve the values and load them into UI options
- List<String> values = retriever.loadValues(propertyDefinitionDynamic);
- for (String option : values) {
+ List<DynamicConfigurationPropertyValue> values = retriever.loadValues(propertyDefinitionDynamic);
+ for (DynamicConfigurationPropertyValue option : values) {
UISelectItem selectItem = FacesComponentUtility.createComponent(UISelectItem.class, null);
- selectItem.setItemLabel(option);
- selectItem.setItemValue(option);
+ selectItem.setItemLabel(option.getDisplay());
+ selectItem.setItemValue(option.getValue());
input.getChildren().add(selectItem);
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java
index 3dc4e3e..ff9d0ae 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java
@@ -24,6 +24,7 @@ package org.rhq.enterprise.gui.configuration;
import java.util.List;
+import org.rhq.core.domain.configuration.DynamicConfigurationPropertyValue;
import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
import org.rhq.core.gui.configuration.helper.DynamicPropertyRetriever;
import org.rhq.enterprise.server.configuration.DynamicConfigurationPropertyLocal;
@@ -36,10 +37,10 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class DatabaseDynamicPropertyRetriever implements DynamicPropertyRetriever {
- public List<String> loadValues(PropertyDefinitionDynamic propertyDefinition) {
+ public List<DynamicConfigurationPropertyValue> loadValues(PropertyDefinitionDynamic propertyDefinition) {
String key = propertyDefinition.getKey();
DynamicConfigurationPropertyLocal bean = LookupUtil.getDynamicConfigurationProperty();
- List<String> values = bean.lookupValues(key);
+ List<DynamicConfigurationPropertyValue> values = bean.lookupValues(key);
return values;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.java
index dd9f844..efe233e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.java
@@ -22,6 +22,7 @@
*/
package org.rhq.enterprise.server.configuration;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -33,11 +34,12 @@ import javax.persistence.Query;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.configuration.DynamicConfigurationPropertyValue;
import org.rhq.enterprise.server.RHQConstants;
/**
* @see DynamicConfigurationPropertyLocal
- *
+ *
* @author Jason Dobies
*/
@Stateless
@@ -49,7 +51,7 @@ public class DynamicConfigurationPropertyBean implements DynamicConfigurationPro
private EntityManager entityManager;
@SuppressWarnings("unchecked")
- public List<String> lookupValues(String key) {
+ public List<DynamicConfigurationPropertyValue> lookupValues(String key) {
String queryName = PropertyExpressionEvaluator.getQueryNameForKey(key);
@@ -62,8 +64,21 @@ public class DynamicConfigurationPropertyBean implements DynamicConfigurationPro
}
Query query = entityManager.createNamedQuery(queryName);
- List<String> results = query.getResultList();
+ List<Object[]> results = query.getResultList();
- return results;
+ List<DynamicConfigurationPropertyValue> values =
+ new ArrayList<DynamicConfigurationPropertyValue>(results.size());
+ for (Object[] result : results) {
+ DynamicConfigurationPropertyValue value = translate(result);
+ values.add(value);
+ }
+
+ return values;
+ }
+
+ public DynamicConfigurationPropertyValue translate(Object[] results) {
+ DynamicConfigurationPropertyValue value =
+ new DynamicConfigurationPropertyValue((String) results[0], (String) results[1]);
+ return value;
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java
index 613e28c..b2d847e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java
@@ -24,6 +24,8 @@ package org.rhq.enterprise.server.configuration;
import java.util.List;
+import org.rhq.core.domain.configuration.DynamicConfigurationPropertyValue;
+
/**
* Responsible for retrieving configuration property values from the database.
*
@@ -39,6 +41,6 @@ public interface DynamicConfigurationPropertyLocal {
* in {@link PropertyExpressionEvaluator}
* @return list of values matching the requested key; empty list if the key is not supported
*/
- List<String> lookupValues(String key);
+ List<DynamicConfigurationPropertyValue> lookupValues(String key);
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java
index 6367f92..088fb09 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java
@@ -35,6 +35,7 @@ import org.testng.annotations.Test;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.configuration.DynamicConfigurationPropertyValue;
import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
@@ -58,12 +59,12 @@ public class DynamicConfigurationPropertyBeanTest extends AbstractEJB3Test {
@Test(enabled = ENABLED)
public void invalidKey() throws Exception {
// Test
- List<String> stringList = bean.lookupValues("foo");
+ List<DynamicConfigurationPropertyValue> stringList = bean.lookupValues("foo");
- // Verify
- assert stringList != null;
+ //Verify
+ assert stringList !=null;
assert stringList.size() == 0;
- }
+ }
@Test(enabled = ENABLED)
public void user() throws Exception {
@@ -71,20 +72,22 @@ public class DynamicConfigurationPropertyBeanTest extends AbstractEJB3Test {
int existingUserCount = countForQuery(Subject.QUERY_FIND_ALL);
// Test
- List<String> users = bean.lookupValues(PropertyExpressionEvaluator.KEY_USERS);
+ List<DynamicConfigurationPropertyValue> users =
+ bean.lookupValues(PropertyExpressionEvaluator.KEY_USERS);
// Verify
outputList(users);
assert users.size() == existingUserCount : "Expected: " + existingUserCount + ", Found: " + users.size();
- }
+ }
@Test(enabled = ENABLED)
- public void roles() throws Exception {
+ public void roles() throws Exception{
// Setup
int existingRoleCount = countForQuery(Role.QUERY_FIND_ALL);
// Test
- List<String> roles = bean.lookupValues(PropertyExpressionEvaluator.KEY_ROLES);
+ List<DynamicConfigurationPropertyValue> roles =
+ bean.lookupValues(PropertyExpressionEvaluator.KEY_ROLES);
// Verify
outputList(roles);
@@ -117,7 +120,8 @@ public class DynamicConfigurationPropertyBeanTest extends AbstractEJB3Test {
assert existingPackageTypes > 0 : "Package type created in setup was not written correctly";
// Test
- List<String> types = bean.lookupValues(PropertyExpressionEvaluator.KEY_PACKAGE_TYPES);
+ List<DynamicConfigurationPropertyValue> types =
+ bean.lookupValues(PropertyExpressionEvaluator.KEY_PACKAGE_TYPES);
// Verify
assert types.size() == existingPackageTypes : "Expected: " + existingPackageTypes + ", Found: " + types.size();
@@ -155,9 +159,9 @@ public class DynamicConfigurationPropertyBeanTest extends AbstractEJB3Test {
return count;
}
- private void outputList(List<String> items) {
+ private void outputList(List<DynamicConfigurationPropertyValue> items) {
System.out.println("Items returned from lookupValues:");
- for (String item : items) {
+ for (DynamicConfigurationPropertyValue item : items) {
System.out.println(item);
}
}
diff --git a/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
index 8ed6e75..f9e4467 100644
--- a/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -25,21 +25,6 @@
<c:group name="General">
<c:simple-property name="rootDirectory" type="directory" required="true"
description="The root directory that contains all content that is to be served by this content provider. In an HA environment, this must be on a distributed file system that all servers can access."/>
-
- <c:dynamic-property name="users" displayName="User Display Name" description="TEST - List of all users in the system."
- required="true" activationPolicy="shutdown">
- <c:database-backing key="users"/>
- </c:dynamic-property>
-
- <c:dynamic-property name="roles" description="TEST - List of all roles in the system."
- readOnly="true" required="false">
- <c:database-backing key="roles"/>
- </c:dynamic-property>
-
- <c:dynamic-property name="packageTypes" description="TEST - List of all package types in the system."
- required="false" summary="true">
- <c:database-backing key="package-types"/>
- </c:dynamic-property>
</c:group>
<c:group name="Package Source">
@@ -47,8 +32,10 @@
type="boolean" description="Indicates if this instance of the plugin should act as a package source"/>
<c:simple-property name="filenameFilter" required="true" summary="true" default=".*"
description="A regular expression that identifies a file of this package type (e.g. '.*\.jar', '.*/i686/.*\.rpm$')"/>
- <c:simple-property name="packageTypeName" required="true" summary="true"
- description="The name that identifies the kind of package this type represents (e.g. 'ear', 'rpm')"/>
+ <c:dynamic-property name="packageTypeName" required="true" summary="true"
+ description="The name that identifies the kind of package this type represents (e.g. 'ear', 'rpm')">
+ <c:database-backing key="package-types"/>
+ </c:dynamic-property>
<c:simple-property name="architectureName" required="true" summary="true" default="noarch"
description="The specific hardware architecture this type of package can be deployed on. If there is no specific architecture required, use 'noarch'. (e.g. 'i686', 'amd64')"/>
<c:simple-property name="resourceTypeName" required="true" summary="true"
14 years, 4 months
[rhq] Branch 'content' - modules/core modules/enterprise
by jdob
modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/DynamicConfigurationPropertyValue.java | 70 ++++++++++
modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java | 2
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java | 5
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java | 9 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java | 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.java | 23 ++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java | 4
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java | 26 ++-
modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml | 21 ---
11 files changed, 125 insertions(+), 44 deletions(-)
New commits:
commit a5c6f1f22c0829eb1ee78ac2dff667bc8fb2ac8f
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 15:49:25 2010 -0500
Refactored dynamic configuration properties to be retrieved with a display/value pair. This way, we are able to display "pretty" values to the user yet use different values programmatically.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java
index f10dc64..2aadf7d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java
@@ -184,7 +184,7 @@ import org.rhq.core.domain.util.serial.ExternalizableStrategy;
+ " AND s.fsystem = FALSE " //
+ " AND s.factive = TRUE"), //
@NamedQuery(name = Subject.QUERY_DYNAMIC_CONFIG_VALUES, query = "" //
- + "SELECT s.name FROM Subject AS s WHERE s.fsystem = false")
+ + "SELECT s.name, s.name FROM Subject AS s WHERE s.fsystem = false")
})
@SequenceGenerator(name = "RHQ_SUBJECT_ID_SEQ", sequenceName = "RHQ_SUBJECT_ID_SEQ")
@Table(name = "RHQ_SUBJECT")
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java
index 089ca55..482fa08 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java
@@ -92,7 +92,7 @@ import org.rhq.core.domain.auth.Subject;
+ " FROM RoleNotification rn" //
+ " WHERE rn.alertDefinition.id = :alertDefinitionId ) "), //
@NamedQuery(name = Role.QUERY_DYNAMIC_CONFIG_VALUES, query = "" //
- + "SELECT r.name FROM Role AS r")
+ + "SELECT r.name, r.name FROM Role AS r")
})
@SequenceGenerator(name = "RHQ_ROLE_ID_SEQ", sequenceName = "RHQ_ROLE_ID_SEQ")
@Table(name = "RHQ_ROLE")
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/DynamicConfigurationPropertyValue.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/DynamicConfigurationPropertyValue.java
new file mode 100644
index 0000000..433fe6a
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/DynamicConfigurationPropertyValue.java
@@ -0,0 +1,70 @@
+/*
+* 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.core.domain.configuration;
+
+/**
+ * Represents a single value that should be displayed to a user as an enumerated possibility for a dynamic
+ * configuration property. This object pairs a display name (shown to the user in the UI) with the programmatic
+ * value that is used if this value is selected.
+ *
+ * @author Jason Dobies
+ */
+public class DynamicConfigurationPropertyValue {
+
+ /**
+ * Display name to use for the value. This will be displayed to the user in the UI.
+ */
+ private String display;
+
+ /**
+ * Programmatic representation of the value that will be used when this value is selected by
+ * the user.
+ */
+ private String value;
+
+ public DynamicConfigurationPropertyValue(String display, String value) {
+ this.display = display;
+ this.value = value;
+ }
+
+ public String getDisplay() {
+ return display;
+ }
+
+ public void setDisplay(String display) {
+ this.display = display;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return "Value [Display = " + display + ", Value = " + value + "]";
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
index 3615a6a..4e4558e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
@@ -71,7 +71,7 @@ import org.rhq.core.domain.resource.ResourceType;
+ "JOIN pt.resourceType rt "
+ "LEFT JOIN FETCH pt.deploymentConfigurationDefinition cd "
+ "LEFT JOIN FETCH cd.templates cts " + "WHERE rt.id = :typeId AND pt.isCreationData = true"),
- @NamedQuery(name = PackageType.QUERY_DYNAMIC_CONFIG_VALUES, query = "SELECT pt.displayName FROM PackageType AS pt")
+ @NamedQuery(name = PackageType.QUERY_DYNAMIC_CONFIG_VALUES, query = "SELECT pt.displayName, pt.name FROM PackageType AS pt")
})
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_PACKAGE_TYPE_ID_SEQ")
@Table(name = "RHQ_PACKAGE_TYPE")
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java
index 1010cc7..9f90c44 100644
--- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java
@@ -24,6 +24,7 @@ package org.rhq.core.gui.configuration.helper;
import java.util.List;
+import org.rhq.core.domain.configuration.DynamicConfigurationPropertyValue;
import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
/**
@@ -32,7 +33,7 @@ import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
* <p/>
* <strong>In order to associate implementations of this interface with the rendering code, calls must be made to
* {@link PropertyRenderingUtility#putDynamicPropertyRetriever(org.rhq.core.domain.configuration.PropertyDynamicType,
- * DynamicPropertyRetriever)} to map the property type to the instance.</strong>
+ * DynamicPropertyRetriever)} to map the property type to the instance.</strong>
* <p/>
* This functionality is abstracted out to prevent the core-gui module from having to make non-core
* dependencies. Modules using core-gui can implement this interface using whatever means available,
@@ -48,5 +49,5 @@ public interface DynamicPropertyRetriever {
* @param propertyDefinition cannot be <code>null</code>
* @return list of values to use as both the name and value of the UI inputs; empty list if none are found
*/
- List<String> loadValues(PropertyDefinitionDynamic propertyDefinition);
+ List<DynamicConfigurationPropertyValue> loadValues(PropertyDefinitionDynamic propertyDefinition);
}
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
index c73205a..0d5531e 100644
--- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
@@ -44,6 +44,7 @@ import javax.faces.validator.ValidatorException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.rhq.core.domain.configuration.DynamicConfigurationPropertyValue;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
import org.rhq.core.domain.configuration.PropertyDynamicType;
@@ -129,11 +130,11 @@ public class PropertyRenderingUtility {
}
// Retrieve the values and load them into UI options
- List<String> values = retriever.loadValues(propertyDefinitionDynamic);
- for (String option : values) {
+ List<DynamicConfigurationPropertyValue> values = retriever.loadValues(propertyDefinitionDynamic);
+ for (DynamicConfigurationPropertyValue option : values) {
UISelectItem selectItem = FacesComponentUtility.createComponent(UISelectItem.class, null);
- selectItem.setItemLabel(option);
- selectItem.setItemValue(option);
+ selectItem.setItemLabel(option.getDisplay());
+ selectItem.setItemValue(option.getValue());
input.getChildren().add(selectItem);
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java
index 3dc4e3e..ff9d0ae 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java
@@ -24,6 +24,7 @@ package org.rhq.enterprise.gui.configuration;
import java.util.List;
+import org.rhq.core.domain.configuration.DynamicConfigurationPropertyValue;
import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
import org.rhq.core.gui.configuration.helper.DynamicPropertyRetriever;
import org.rhq.enterprise.server.configuration.DynamicConfigurationPropertyLocal;
@@ -36,10 +37,10 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class DatabaseDynamicPropertyRetriever implements DynamicPropertyRetriever {
- public List<String> loadValues(PropertyDefinitionDynamic propertyDefinition) {
+ public List<DynamicConfigurationPropertyValue> loadValues(PropertyDefinitionDynamic propertyDefinition) {
String key = propertyDefinition.getKey();
DynamicConfigurationPropertyLocal bean = LookupUtil.getDynamicConfigurationProperty();
- List<String> values = bean.lookupValues(key);
+ List<DynamicConfigurationPropertyValue> values = bean.lookupValues(key);
return values;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.java
index dd9f844..efe233e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.java
@@ -22,6 +22,7 @@
*/
package org.rhq.enterprise.server.configuration;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -33,11 +34,12 @@ import javax.persistence.Query;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.configuration.DynamicConfigurationPropertyValue;
import org.rhq.enterprise.server.RHQConstants;
/**
* @see DynamicConfigurationPropertyLocal
- *
+ *
* @author Jason Dobies
*/
@Stateless
@@ -49,7 +51,7 @@ public class DynamicConfigurationPropertyBean implements DynamicConfigurationPro
private EntityManager entityManager;
@SuppressWarnings("unchecked")
- public List<String> lookupValues(String key) {
+ public List<DynamicConfigurationPropertyValue> lookupValues(String key) {
String queryName = PropertyExpressionEvaluator.getQueryNameForKey(key);
@@ -62,8 +64,21 @@ public class DynamicConfigurationPropertyBean implements DynamicConfigurationPro
}
Query query = entityManager.createNamedQuery(queryName);
- List<String> results = query.getResultList();
+ List<Object[]> results = query.getResultList();
- return results;
+ List<DynamicConfigurationPropertyValue> values =
+ new ArrayList<DynamicConfigurationPropertyValue>(results.size());
+ for (Object[] result : results) {
+ DynamicConfigurationPropertyValue value = translate(result);
+ values.add(value);
+ }
+
+ return values;
+ }
+
+ public DynamicConfigurationPropertyValue translate(Object[] results) {
+ DynamicConfigurationPropertyValue value =
+ new DynamicConfigurationPropertyValue((String) results[0], (String) results[1]);
+ return value;
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java
index 613e28c..b2d847e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java
@@ -24,6 +24,8 @@ package org.rhq.enterprise.server.configuration;
import java.util.List;
+import org.rhq.core.domain.configuration.DynamicConfigurationPropertyValue;
+
/**
* Responsible for retrieving configuration property values from the database.
*
@@ -39,6 +41,6 @@ public interface DynamicConfigurationPropertyLocal {
* in {@link PropertyExpressionEvaluator}
* @return list of values matching the requested key; empty list if the key is not supported
*/
- List<String> lookupValues(String key);
+ List<DynamicConfigurationPropertyValue> lookupValues(String key);
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java
index 6367f92..088fb09 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java
@@ -35,6 +35,7 @@ import org.testng.annotations.Test;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.configuration.DynamicConfigurationPropertyValue;
import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
@@ -58,12 +59,12 @@ public class DynamicConfigurationPropertyBeanTest extends AbstractEJB3Test {
@Test(enabled = ENABLED)
public void invalidKey() throws Exception {
// Test
- List<String> stringList = bean.lookupValues("foo");
+ List<DynamicConfigurationPropertyValue> stringList = bean.lookupValues("foo");
- // Verify
- assert stringList != null;
+ //Verify
+ assert stringList !=null;
assert stringList.size() == 0;
- }
+ }
@Test(enabled = ENABLED)
public void user() throws Exception {
@@ -71,20 +72,22 @@ public class DynamicConfigurationPropertyBeanTest extends AbstractEJB3Test {
int existingUserCount = countForQuery(Subject.QUERY_FIND_ALL);
// Test
- List<String> users = bean.lookupValues(PropertyExpressionEvaluator.KEY_USERS);
+ List<DynamicConfigurationPropertyValue> users =
+ bean.lookupValues(PropertyExpressionEvaluator.KEY_USERS);
// Verify
outputList(users);
assert users.size() == existingUserCount : "Expected: " + existingUserCount + ", Found: " + users.size();
- }
+ }
@Test(enabled = ENABLED)
- public void roles() throws Exception {
+ public void roles() throws Exception{
// Setup
int existingRoleCount = countForQuery(Role.QUERY_FIND_ALL);
// Test
- List<String> roles = bean.lookupValues(PropertyExpressionEvaluator.KEY_ROLES);
+ List<DynamicConfigurationPropertyValue> roles =
+ bean.lookupValues(PropertyExpressionEvaluator.KEY_ROLES);
// Verify
outputList(roles);
@@ -117,7 +120,8 @@ public class DynamicConfigurationPropertyBeanTest extends AbstractEJB3Test {
assert existingPackageTypes > 0 : "Package type created in setup was not written correctly";
// Test
- List<String> types = bean.lookupValues(PropertyExpressionEvaluator.KEY_PACKAGE_TYPES);
+ List<DynamicConfigurationPropertyValue> types =
+ bean.lookupValues(PropertyExpressionEvaluator.KEY_PACKAGE_TYPES);
// Verify
assert types.size() == existingPackageTypes : "Expected: " + existingPackageTypes + ", Found: " + types.size();
@@ -155,9 +159,9 @@ public class DynamicConfigurationPropertyBeanTest extends AbstractEJB3Test {
return count;
}
- private void outputList(List<String> items) {
+ private void outputList(List<DynamicConfigurationPropertyValue> items) {
System.out.println("Items returned from lookupValues:");
- for (String item : items) {
+ for (DynamicConfigurationPropertyValue item : items) {
System.out.println(item);
}
}
diff --git a/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
index 8ed6e75..f9e4467 100644
--- a/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -25,21 +25,6 @@
<c:group name="General">
<c:simple-property name="rootDirectory" type="directory" required="true"
description="The root directory that contains all content that is to be served by this content provider. In an HA environment, this must be on a distributed file system that all servers can access."/>
-
- <c:dynamic-property name="users" displayName="User Display Name" description="TEST - List of all users in the system."
- required="true" activationPolicy="shutdown">
- <c:database-backing key="users"/>
- </c:dynamic-property>
-
- <c:dynamic-property name="roles" description="TEST - List of all roles in the system."
- readOnly="true" required="false">
- <c:database-backing key="roles"/>
- </c:dynamic-property>
-
- <c:dynamic-property name="packageTypes" description="TEST - List of all package types in the system."
- required="false" summary="true">
- <c:database-backing key="package-types"/>
- </c:dynamic-property>
</c:group>
<c:group name="Package Source">
@@ -47,8 +32,10 @@
type="boolean" description="Indicates if this instance of the plugin should act as a package source"/>
<c:simple-property name="filenameFilter" required="true" summary="true" default=".*"
description="A regular expression that identifies a file of this package type (e.g. '.*\.jar', '.*/i686/.*\.rpm$')"/>
- <c:simple-property name="packageTypeName" required="true" summary="true"
- description="The name that identifies the kind of package this type represents (e.g. 'ear', 'rpm')"/>
+ <c:dynamic-property name="packageTypeName" required="true" summary="true"
+ description="The name that identifies the kind of package this type represents (e.g. 'ear', 'rpm')">
+ <c:database-backing key="package-types"/>
+ </c:dynamic-property>
<c:simple-property name="architectureName" required="true" summary="true" default="noarch"
description="The specific hardware architecture this type of package can be deployed on. If there is no specific architecture required, use 'noarch'. (e.g. 'i686', 'amd64')"/>
<c:simple-property name="resourceTypeName" required="true" summary="true"
14 years, 4 months
[rhq] 107 commits - .classpath modules/core modules/enterprise modules/plugins pom.xml .settings/org.eclipse.jdt.ui.prefs
by John Sanda
.classpath | 1
.settings/org.eclipse.jdt.ui.prefs | 4
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationAgentService.java | 22
modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml | 2
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 2
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ConfigurationUpdateStatus.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/RawConfiguration.java | 77 -
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationTest.java | 6
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationIntegrationTest.java | 2
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationTest.java | 81 -
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/ConfigurationTest.java | 2
modules/core/domain/src/test/resources/META-INF/persistence.xml | 37
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/MultiFileRenderer.java | 70 +
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/MultiFileUIComponent.java | 38
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigRenderer.java | 58 +
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java | 143 +++
modules/core/native-system/src/main/java/org/rhq/core/system/SystemInfoFactory.java | 43
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java | 3
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationUpdateException.java | 49 +
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementFactoryImpl.java | 68 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigManagementSupport.java | 4
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java | 165 ++-
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationUtilityServiceImpl.java | 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawConfigManagement.java | 15
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagement.java | 33
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredConfigManagement.java | 11
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigManagementFactoryImplTest.java | 155 +--
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigManagementTest.java | 24
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerTest.java | 268 +++---
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/RawConfigManagementTest.java | 113 ++
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagementTest.java | 100 +-
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredConfigManagementTest.java | 51 -
modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/UpdateResourceConfigurationRunnerTest.java | 5
modules/core/util/src/main/java/org/rhq/core/template/TemplateEngine.java | 54 +
modules/core/util/src/test/java/org/rhq/core/template/TemplateEngineTest.java | 62 +
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java | 439 ++++++----
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigDirectory.java | 55 +
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java | 99 ++
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/ViewRawTestConfigurationUIBean.java | 32
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java | 8
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml | 16
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-components/configuration-components.xml | 21
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/configuration-beans.xml | 20
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/test-beans.xml | 8
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml | 58 -
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tags/on.component.taglib.xml | 6
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml | 6
modules/enterprise/gui/portal-war/src/main/webapp/common/Login.jsp | 4
modules/enterprise/gui/portal-war/src/main/webapp/css/win.css | 25
modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js | 248 +++++
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml | 2
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml | 373 +++++++-
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/upload-modal.xhtml | 56 +
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml | 45 +
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml | 420 +++++----
modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit-raw-config.xhtml | 31
modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/edit.html | 30
modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/view.html | 32
modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/view-raw-config.xhtml | 52 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java | 49 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java | 4
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java | 71 -
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanUnitTest.java | 97 +-
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java | 4
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java | 6
modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java | 2
modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy | 42
modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy | 80 +
modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredServer.groovy | 13
modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml | 38
modules/plugins/raw-config-test/src/test/groovy/org/rhq/plugins/test/rawconfig/RawConfigServerTest.groovy | 12
modules/plugins/raw-config-test/src/test/groovy/org/rhq/plugins/test/rawconfig/RawServerTest.groovy | 2
pom.xml | 2
73 files changed, 3208 insertions(+), 1072 deletions(-)
New commits:
commit 597c60cb164470972f798c239a48ff4057721714
Merge: f530c34... d291388...
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jan 27 15:21:15 2010 -0500
Merge branch 'master' into raw-config
commit f530c34c291cde6ab03d94c457b05ba24ea671f5
Merge: 7640fd1... a98da0a...
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jan 27 12:35:23 2010 -0500
Merge branch 'raw-config' of ssh://jsanda@git.fedorahosted.org/git/rhq/rhq into raw-config
commit 7640fd1179c15b8b9da3f632fa5f114ddf070db9
Merge: b898ed3... af588cb...
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jan 27 12:34:11 2010 -0500
Merge branch 'master' into raw-config
Conflicts:
.classpath
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java
commit a98da0a8deb14774f961552a2b630ccdb888ccd4
Author: Adam Young <ayoung(a)redhat.com>
Date: Wed Jan 27 11:10:18 2010 -0500
Extracted construction of templating engine to pair it with SystemInfo
diff --git a/modules/core/native-system/src/main/java/org/rhq/core/system/SystemInfoFactory.java b/modules/core/native-system/src/main/java/org/rhq/core/system/SystemInfoFactory.java
index a7b2f12..3a29fff 100644
--- a/modules/core/native-system/src/main/java/org/rhq/core/system/SystemInfoFactory.java
+++ b/modules/core/native-system/src/main/java/org/rhq/core/system/SystemInfoFactory.java
@@ -29,9 +29,12 @@ import java.lang.reflect.Method;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
+import java.util.TreeMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.template.TemplateEngine;
import org.rhq.core.util.exception.ThrowableUtil;
/**
@@ -74,7 +77,8 @@ public class SystemInfoFactory {
nativeLibraryLoadable = true;
} catch (Throwable t) {
nativeLibraryLoadable = false; // can't load the native libs if we don't even have the JNI classes
- LOG.warn("System info API not accessible on this platform (native shared library not found in java.library.path).");
+ LOG
+ .warn("System info API not accessible on this platform (native shared library not found in java.library.path).");
LOG.trace("Stack trace...", t);
}
@@ -97,8 +101,8 @@ public class SystemInfoFactory {
if (isNativeSystemInfoAvailable() && !isNativeSystemInfoDisabled()) {
try {
version = "Version=" + invokeApi(NativeApi.VERSION_STRING) + " (" + invokeApi(NativeApi.BUILD_DATE)
- + "); Native version=" + invokeApi(NativeApi.NATIVE_VERSION_STRING) + " ("
- + invokeApi(NativeApi.NATIVE_BUILD_DATE) + ")";
+ + "); Native version=" + invokeApi(NativeApi.NATIVE_VERSION_STRING) + " ("
+ + invokeApi(NativeApi.NATIVE_BUILD_DATE) + ")";
} catch (Throwable t) {
error = t;
}
@@ -308,7 +312,7 @@ public class SystemInfoFactory {
rootDir = System.getProperty("rhq.native-libraries-root-directory");
if (rootDir == null) {
jarLocation = Class.forName(NATIVE_LIBRARY_CLASS_NAME).getProtectionDomain().getCodeSource()
- .getLocation();
+ .getLocation();
if (jarLocation != null) {
// the root directory where all JNI libraries are located is the
// same directory as where the SIGAR jar is found
@@ -319,7 +323,7 @@ public class SystemInfoFactory {
rootDir = jniLocation.getAbsolutePath();
} else {
throw new Exception("Native JNI libraries cannot be found: " + "jar-location=[" + jarLocation
- + "], jni-location=[" + jniLocation + "]");
+ + "], jni-location=[" + jniLocation + "]");
}
}
}
@@ -334,4 +338,33 @@ public class SystemInfoFactory {
*/
private SystemInfoFactory() {
}
+
+ public static TemplateEngine fetchTemplateEngine() {
+
+ SystemInfo systemInfo = createSystemInfo();
+
+ Map<String, String> tokens = new HashMap<String, String>();
+ tokens.put("rhq.hostname", systemInfo.getHostname());
+ tokens.put("rhq.os.name", systemInfo.getOperatingSystemName());
+ tokens.put("rhq.os.version", systemInfo.getOperatingSystemVersion());
+ tokens.put("rhq.os.type", systemInfo.getOperatingSystemType().toString());
+ tokens.put("rhq.cpu.count", Integer.toString(systemInfo.getNumberOfCpus()));
+ tokens.put("rhq.architecture", systemInfo.getSystemArchitecture());
+
+ for (NetworkAdapterInfo networkAdapter : systemInfo.getAllNetworkAdapters()) {
+ String key = "rhq.interfaces." + networkAdapter.getName();
+ tokens.put(key + ".mac", networkAdapter.getMacAddressString());
+ tokens.put(key + ".type", networkAdapter.getType());
+ tokens.put(key + ".flags", networkAdapter.getAllFlags());
+
+ if (!networkAdapter.getUnicastAddresses().isEmpty()) {
+ tokens.put(key + ".address", networkAdapter.getUnicastAddresses().get(0).getHostAddress());
+ }
+ if (!networkAdapter.getMulticastAddresses().isEmpty()) {
+ tokens.put(key + ".multicast.address", networkAdapter.getMulticastAddresses().get(0).getHostAddress());
+ }
+ }
+ TemplateEngine templateEngine = new TemplateEngine(tokens);
+ return templateEngine;
+ }
}
\ No newline at end of file
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 1181bea..580da62 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
@@ -24,7 +24,6 @@ package org.rhq.core.pc.configuration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-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;
@@ -33,8 +32,6 @@ import org.rhq.core.clientapi.server.configuration.ConfigurationUpdateResponse;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.RawConfiguration;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pc.ContainerService;
import org.rhq.core.pc.PluginContainer;
@@ -46,14 +43,12 @@ 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.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.system.SystemInfoFactory;
import org.rhq.core.template.TemplateEngine;
-import org.rhq.enterprise.client.proxy.ResourceClientProxy.Measurement;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;
-import java.util.TreeMap;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
@@ -74,8 +69,6 @@ public class ConfigurationManager extends AgentService implements ContainerServi
private static final int FACET_METHOD_TIMEOUT = 60 * 1000; // 60 seconds
- private static final ComparableVersion NON_LEGACY_VERSION = new ComparableVersion("2.1");
-
private PluginContainerConfiguration pluginContainerConfiguration;
private ScheduledExecutorService threadPool;
@@ -191,15 +184,14 @@ public class ConfigurationManager extends AgentService implements ContainerServi
private void mergeRawsIntoStructured(Configuration configuration, ResourceConfigurationFacet facet) {
Configuration structuredConfig = facet.loadStructuredConfiguration();
- TemplateEngine templateEngine = fetchTemplateEngine();
-
+ TemplateEngine templateEngine = SystemInfoFactory.fetchTemplateEngine();
if (structuredConfig != null) {
prepareConfigForMergeIntoStructured(configuration, structuredConfig);
for (RawConfiguration rawConfig : configuration.getRawConfigurations()) {
String contents = templateEngine.replaceTokens(new String(rawConfig.getContents()));
- rawConfig.setContents(contents.getBytes());
+ rawConfig.setContents(contents);
structuredConfig.addRawConfiguration(rawConfig);
facet.mergeStructuredConfiguration(rawConfig, configuration);
@@ -207,29 +199,7 @@ public class ConfigurationManager extends AgentService implements ContainerServi
}
}
- private TemplateEngine fetchTemplateEngine() {
- Resource platformResource = PluginContainer.getInstance().getInventoryManager().getPlatform();
- TreeMap<String, String> tokens = new TreeMap<String, String>();
- tokens.put("rhq.hostname", platformResource.getName());
-
-
- MeasurementFacet facet = componentService.getComponent(platformResource.getId(), MeasurementFacet.class,
- FacetLockType.READ, FACET_METHOD_TIMEOUT, daemonOnly, onlyIfStarted);
-
-
-
- for (Resource childResource : platformResource.getChildResources()) {
- if (childResource.getResourceType().getName().equals("Network Adapter" )){
- String key = "rhq.interfaces."+childResource.getName()+".mac";
- tokens.put(key ,childResource.getDescription());
- }
- }
-
-
- TemplateEngine templateEngine = new TemplateEngine(tokens);
- return templateEngine;
- }
-
+
private void prepareConfigForMergeIntoStructured(Configuration config, Configuration latestStructured) {
config.getAllProperties().clear();
for (Property property : latestStructured.getProperties()) {
commit b898ed3cce86c40d6369473b5f4af21bced14ef9
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jan 27 10:46:39 2010 -0500
Fixing rerendering logic to display updated path name label
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 7af5f2d..e40b9f1 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -204,9 +204,7 @@ THIS TEXT WILL BE REMOVED.
<rich:panelMenu mode="ajax"
expandMode="client"
iconCollapsedGroup="/images/icn_tree_folder.gif"
- iconExpandedGroup="/images/icn_tree_folder.gif"
- limitToList="true"
- reRender="fileContents">
+ iconExpandedGroup="/images/icn_tree_folder.gif">
<c:forEach items="#{rawConfigDirectories}"
var="rawConfigDir">
<rich:panelMenuGroup label="#{rawConfigDir.path}"
@@ -219,7 +217,7 @@ THIS TEXT WILL BE REMOVED.
oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationViewUIBean.select(rawConfigUIBean.path)}"
limitToList="true"
- reRender="fileContents,selectedFileHeader,modalEditor"/>
+ reRender="fileContents,selectedFileHeader,modalEditor,fileMenu"/>
</c:forEach>
</rich:panelMenuGroup>
</c:forEach>
@@ -241,7 +239,7 @@ THIS TEXT WILL BE REMOVED.
<a4j:status id="selectedFileHeader"
startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
- stopText="#{ExistingResourceConfigurationUIBean.current.path}"/>
+ stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
</h:panelGrid>
<rich:panel style="margin-left:1px; border: none;">
commit a91ec38042f668b5db1d74701988b18dffdf7aeb
Merge: d31a520... c435e7f...
Author: Adam Young <ayoung(a)redhat.com>
Date: Wed Jan 27 09:18:51 2010 -0500
Merge branch 'raw-config' of ssh://git.fedorahosted.org/git/rhq/rhq into raw-config-confirm
commit c435e7fc9cc1848c9a9c0d1f32cc1da30d5b3234
Merge: a15c771... 9ba9416...
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jan 26 13:38:36 2010 -0500
Merge branch 'master' into raw-config
Conflicts:
.classpath
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
diff --cc modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml
index 15424a2,f485fc7..126fb6f
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml
@@@ -16,17 -17,15 +17,25 @@@
<component class="org.jboss.seam.web.MultipartFilter">
- <property name="createTempFiles">false</property>
+ <property name="createTempFiles">true</property>
<property name="maxRequestSize">1000000</property>
+ <property name="urlPattern">*.xhtml</property>
</component>
- <!-- Load i18n bundles -->
+ <component class="org.rhq.enterprise.gui.configuration.resource.ExistingResourceConfigurationUIBean"
+ name="ExistingResourceConfigurationViewUIBean"
+ scope="page"/>
+
+ <component class="org.rhq.enterprise.gui.configuration.resource.ExistingResourceConfigurationUIBean"
+ name="ExistingResourceConfigurationUIBean"
+ scope="session"/>
+
++ <!-- Load i18n bundles -->
+ <core:resource-loader>
+ <core:bundle-names>
+ <value>messages</value>
+ <value>ApplicationResources</value>
+ </core:bundle-names>
- </core:resource-loader>
++ </core:resource-loader>
++
</components>
diff --cc modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
index 55d5751,ad0766d..7a9ebd9
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
@@@ -330,9 -318,4 +335,8 @@@ public class TestContentProvider implem
return null;
}
-
+ public SyncProgressWeight getSyncProgressWeight() {
+ return SyncProgressWeight.DEFAULT_WEIGHTS;
+ }
+
}
commit a15c771e767126dcf08873fc21dad50c55fbefd5
Merge: bb4bdd7... 8b86c0b...
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jan 26 13:29:47 2010 -0500
Merge branch 'raw-config' of ssh://jsanda@git.fedorahosted.org/git/rhq/rhq into raw-config
commit bb4bdd7e2b9c061ca663c75ee0b5a503c5ecbaa5
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jan 26 13:21:56 2010 -0500
Refactoring RawConfiguration entity to store file contents as a string instead of as an array of bytes
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
index 04d5fb3..947606e 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
@@ -114,7 +114,7 @@
<column name="ID" type="INTEGER" required="true" default="sequence-only" initial="10001" primarykey="true"/>
<column name="CONFIG_ID" type="INTEGER" required="true" references="RHQ_CONFIG(ID)"/>
<column name="PATH" type="VARCHAR2" required="false" size="512"/>
- <column name="CONTENTS" type="BLOB" required="true"/>
+ <column name="CONTENTS" type="CLOB" required="true"/>
<column name="SHA256" type="VARCHAR2" size="64" required="true"/>
<column name="CTIME" type="LONG" required="true"/>
<column name="MTIME" type="LONG" required="true"/>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 5e8a703..86b4aa4 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -1498,7 +1498,7 @@
<schema-addColumn table="RHQ_RAW_CONFIG" column="CONTENTS" columnType="BLOB"/>
<schema-alterColumn table="RHQ_RAW_CONFIG"
column="CONTENTS"
- columnType="BLOB"
+ columnType="CLOB"
nullable="false"/>
<schema-addColumn table="RHQ_RAW_CONFIG" column="SHA256" columnType="VARCHAR2"/>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/RawConfiguration.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/RawConfiguration.java
index 1bb27c9..e4e3d7e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/RawConfiguration.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/RawConfiguration.java
@@ -25,12 +25,14 @@ package org.rhq.core.domain.configuration;
import org.rhq.core.util.MessageDigestGenerator;
+import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
@@ -41,10 +43,8 @@ import java.io.Serializable;
/**
* Resources support structured configuration as well as raw configuration which is represented by this class. A raw
* configuration is typically in the form of a file on the file system. This could be httpd.conf in the case of apache.
- * Note however that while a raw configuration generally refers to some configuration file, this class does not limit
- * the actual configuration source to files.
* <p/>
- * A raw configuration is stored as an array of bytes and has a SHA-256 hash with which it can be uniquely identified.
+ * A raw configuration is stored as a CLOB and has a SHA-256 hash with which it can be uniquely identified.
* <p/>
* A RawConfiguration is always associated with its parent {@link org.rhq.core.domain.configuration.Configuration} which
* can be structured, raw, or both. A Configuration can have multiple RawConfigurations associated with it. Suppose for
@@ -67,8 +67,9 @@ public class RawConfiguration implements Serializable, DeepCopyable<RawConfigura
@Column(name = "PATH", nullable = true)
private String path;
+ @Lob
@Column(name = "CONTENTS", nullable = false)
- private byte[] contents;
+ private String contents;
@Column(name = "SHA256", nullable = false)
private String sha256;
@@ -83,6 +84,7 @@ public class RawConfiguration implements Serializable, DeepCopyable<RawConfigura
@JoinColumn(name = "CONFIG_ID", nullable = false)
private Configuration configuration;
+ /** @return The database identifier or primary key */
public int getId() {
return id;
}
@@ -91,77 +93,62 @@ public class RawConfiguration implements Serializable, DeepCopyable<RawConfigura
this.id = id;
}
+ /** @return The file system path of the configuration that this object represents */
public String getPath() {
return path;
}
+ /** @param path The new file system path of the configuration file represented by this object */
public void setPath(String path) {
this.path = path;
}
- /**
- * Returns a copy of the contents as an array of bytes. Modifications to the underlying array have to happen through
- * {@link #setContents(byte[])}; otherwise, we could wind up with an incorrect SHA-256 hash. This behavior is
- * enforced by returning a copy instead of a reference to the underlying array. By returning a copy, callers can only
- * modify the underlying array by calling the setter.
- *
- * @return A copy of the file contents as an array of bytes
- */
- public byte[] getContents() {
- return copy(contents);
+ /** @return The contents of the raw configuration which typically will be a file */
+ public String getContents() {
+ return contents;
}
/**
- * Replaces the contents of this raw config with a copy of the specified bytes. The SHA-256 hash returned from
- * {@link #getSha256()} will be changed as well, provided the contents actually changed in some way.
+ * Replaces the contents of the raw configuration. The SHA-256 hash returned from {@link #getSha256()} will be
+ * updated as well.
*
- * @param newContents The new bytes
+ * @param contents The new contents
*/
- public void setContents(byte[] newContents) {
- this.contents = copy(newContents);
+ public void setContents(String contents) {
+ this.contents = contents;
updateSha256();
}
- private byte[] copy(byte[] original) {
- byte[] copy = new byte[original.length];
- for (int i = 0; i < original.length; ++i) {
- copy[i] = original[i];
- }
- return copy;
- }
-
private void updateSha256() {
MessageDigestGenerator sha256Generator = new MessageDigestGenerator("SHA-256");
- sha256Generator.add(contents);
+ sha256Generator.add(contents.getBytes());
sha256 = sha256Generator.getDigestString();
}
- /** @return A SHA-256 hash of the bytes for this raw configuration, which can be accessed via {@link #getContents()} */
+ /**
+ * @return A SHA-256 hash of the contents for this raw configuration, which can be accessed via
+ * {@link #getContents()}
+ */
public String getSha256() {
return sha256;
}
+ /** @return A timestamp of when this object was created */
public long getCtime() {
return ctime;
}
- public void setCtime(long ctime) {
- this.ctime = ctime;
- }
-
+ /** @return A timestamp of when this object was last modified */
public long getMtime() {
return mtime;
}
- public void setMtime(long mtime) {
- this.mtime = mtime;
- }
-
/** @return The owning {@link org.rhq.core.domain.configuration.Configuration} object */
public Configuration getConfiguration() {
return configuration;
}
+ /** @param configuration The parent configuration object */
public void setConfiguration(Configuration configuration) {
this.configuration = configuration;
}
@@ -228,6 +215,15 @@ public class RawConfiguration implements Serializable, DeepCopyable<RawConfigura
return sha256.hashCode() * path.hashCode() * 37;
}
+ /**
+ * Returns a string representation of this object that is in the following format,
+ *
+ * <code>
+ * RawConfiguration[id=1, path=/foo/bar/raw.txt, sha256=13xcx9sd82e, configuration=<configuration.toString()>]
+ * </code>
+ *
+ * @return A string representation of this object
+ */
@Override
public String toString() {
return new StringBuilder()
@@ -240,6 +236,13 @@ public class RawConfiguration implements Serializable, DeepCopyable<RawConfigura
.toString();
}
+ /**
+ * Creates a deep copy of this object that includes all of the properties except for the parent configuration. If
+ * the <code>keepId</code> flag is <code>false</code>, then the id property is not copied.
+ *
+ * @param keepId A flag indicating whether or not the id should be copied
+ * @return A copy of this object
+ */
public RawConfiguration deepCopy(boolean keepId) {
RawConfiguration copy = new RawConfiguration();
if (keepId) {
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationTest.java
index c1aba0c..e9fa2d9 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ConfigurationTest.java
@@ -417,14 +417,14 @@ public class ConfigurationTest {
}
private RawConfiguration createRawConfiguration(String path) {
- byte[] contents = new byte[10];
+ byte[] bytes = new byte[10];
Random random = new Random();
- random.nextBytes(contents);
+ random.nextBytes(bytes);
RawConfiguration rawConfig = new RawConfiguration();
rawConfig.setPath(path);
- rawConfig.setContents(contents);
+ rawConfig.setContents(new String(bytes));
return rawConfig;
}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationIntegrationTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationIntegrationTest.java
index bbd9ff5..65a0773 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationIntegrationTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationIntegrationTest.java
@@ -40,7 +40,7 @@ public class RawConfigurationIntegrationTest extends AbstractEJB3Test {
RawConfiguration rawConfig = new RawConfiguration();
rawConfig.setConfiguration(config);
- rawConfig.setContents(new byte[] {1, 2, 3, 4, 5});
+ rawConfig.setContents("contents");
rawConfig.setPath("/tmp/foo.txt");
entityMgr.persist(rawConfig);
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationTest.java
index 3a373b2..12e7ed0 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/RawConfigurationTest.java
@@ -39,44 +39,9 @@ import java.io.IOException;
public class RawConfigurationTest {
@Test
- public void getContentsShouldReturnADeepCopyOfArray() {
- RawConfiguration rawConfig = new RawConfiguration();
- rawConfig.setContents(getBytes());
-
- byte[] contents = rawConfig.getContents();
- contents[0] = 5;
-
- assertEquals(
- rawConfig.getContents(),
- getBytes(),
- "The contents property should only be mutable through setContents(). Therefore getContents() must return a copy of the underlying array."
- );
- }
-
- @Test
- public void setContentsShouldUpdateContentsArrayWithCopyOfSpecifiedValue() {
- byte[] bytes = getBytes();
-
- RawConfiguration rawConfig = new RawConfiguration();
- rawConfig.setContents(bytes);
-
- bytes[0] = 9;
-
- assertEquals(
- rawConfig.getContents(),
- getBytes(),
- "setContents() should update the underlying array to refer to a copy of the incoming array to enforce the contents property being mutable only through setContents()."
- );
- }
-
- byte[] getBytes() {
- return new byte[] {1, 2, 3};
- }
-
- @Test
public void sha256ShouldChangeWhenContentsChange() throws Exception {
RawConfiguration rawConfig = new RawConfiguration();
- rawConfig.setContents(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
+ rawConfig.setContents("contents");
String actualSha256 = rawConfig.getSha256();
@@ -84,7 +49,7 @@ public class RawConfigurationTest {
assertEquals(actualSha256, expectedSha256, "Failed to calculate the SHA-256 correctly.");
- byte[] newContents = new byte[] {1, 3, 5, 7, 11, 13, 17, 19, 23};
+ String newContents = "new contents";
rawConfig.setContents(newContents);
actualSha256 = rawConfig.getSha256();
@@ -94,8 +59,8 @@ public class RawConfigurationTest {
assertEquals(actualSha256, expectedSha256, "Failed to update sha256 when contents property changes");
}
- String calculateSHA256(byte[] data) throws DecoderException {
- return DigestUtils.sha256Hex(data);
+ String calculateSHA256(String string) throws DecoderException {
+ return DigestUtils.sha256Hex(string);
}
@Test
@@ -124,7 +89,7 @@ public class RawConfigurationTest {
@Test
public void verifyEqualsWhenRawConfigurationArgHasNullContents() {
RawConfiguration r1 = new RawConfiguration();
- r1.setContents(getBytes());
+ r1.setContents("contents");
RawConfiguration r2 = new RawConfiguration();
@@ -134,11 +99,11 @@ public class RawConfigurationTest {
@Test
public void verifyEqualsWhenRawConfigurationArgHasNullPath() {
RawConfiguration r1 = new RawConfiguration();
- r1.setContents(getBytes());
+ r1.setContents("contents");
r1.setPath("/tmp/foo");
RawConfiguration r2 = new RawConfiguration();
- r2.setContents(getBytes());
+ r2.setContents("contents");
assertFalse(r1.equals(r2), "equals() should return false when one of the raw configs does not have its paths set");
}
@@ -153,10 +118,10 @@ public class RawConfigurationTest {
@Test
public void verifyEqualsAndHashCodeAreSymmetricWhenPathIsNull() {
RawConfiguration r1 = new RawConfiguration();
- r1.setContents(getBytes());
+ r1.setContents("contents");
RawConfiguration r2 = new RawConfiguration();
- r2.setContents(getBytes());
+ r2.setContents("contents");
assertTrue(r1.equals(r2), "equals() should be true when contents are the same and path is null for both.");
assertTrue(r2.equals(r1), "equals() should be symmetric.");
@@ -167,11 +132,11 @@ public class RawConfigurationTest {
@Test
public void verifyEqualsAndHashCodeAreSymmetricWhenPathIsNotNull() {
RawConfiguration r1 = new RawConfiguration();
- r1.setContents(getBytes());
+ r1.setContents("contents");
r1.setPath("/tmp/foo");
RawConfiguration r2 = new RawConfiguration();
- r2.setContents(getBytes());
+ r2.setContents("contents");
r2.setPath("/tmp/foo");
assertTrue(r1.equals(r2), "equals() should be true when contents and paths are the same.");
@@ -182,14 +147,16 @@ public class RawConfigurationTest {
@Test
public void verifyEqualsAndHashCodeTransitiveWhenPathIsNull() {
+ String contents = "contents";
+
RawConfiguration r1 = new RawConfiguration();
- r1.setContents(getBytes());
+ r1.setContents(contents);
RawConfiguration r2 = new RawConfiguration();
- r2.setContents(getBytes());
+ r2.setContents(contents);
RawConfiguration r3 = new RawConfiguration();
- r3.setContents(getBytes());
+ r3.setContents(contents);
assertTrue(r1.equals(r2) && r2.equals(r3), "equals() should be true when contents are the same and paths are null.");
assertTrue(r1.equals(r3), "equals() should be transitive when contents are the same and paths are null.");
@@ -199,16 +166,18 @@ public class RawConfigurationTest {
@Test
public void verifyEqualsAndHashCodeTransitiveWhenPathIsNotNull() {
+ String contents = "contents";
+
RawConfiguration r1 = new RawConfiguration();
- r1.setContents(getBytes());
+ r1.setContents(contents);
r1.setPath("/tmp/foo");
RawConfiguration r2 = new RawConfiguration();
- r2.setContents(getBytes());
+ r2.setContents(contents);
r2.setPath("/tmp/foo");
RawConfiguration r3 = new RawConfiguration();
- r3.setContents(getBytes());
+ r3.setContents(contents);
r3.setPath("/tmp/foo");
assertTrue(r1.equals(r2) && r2.equals(r3), "equals() should be true when contents and paths are the same.");
@@ -244,22 +213,22 @@ public class RawConfigurationTest {
@Test
public void deepCopyShouldCopyContentsWhenCopyingId() {
RawConfiguration original = new RawConfiguration();
- original.setContents(new byte[] {1, 2, 3, 4, 5});
+ original.setContents("contents");
RawConfiguration copy = original.deepCopy(true);
- assertFalse(original.getContents() == copy.getContents(), "The values in the contents array should be copied, not the reference to the original object.");
+ assertEquals(original.getContents(), copy.getContents(), "Failed to copy the contents property");
assertEquals(copy.getContents(), original.getContents(), "Failed to copy contents property.");
}
@Test
public void deepCopyShouldCopyContentsWhenNotCopyingId() {
RawConfiguration original = new RawConfiguration();
- original.setContents(new byte[] {1, 2, 3, 4, 5});
+ original.setContents("contents");
RawConfiguration copy = original.deepCopy(false);
- assertFalse(original.getContents() == copy.getContents(), "The values in the contents array should be copied, not the reference to the original object.");
+ assertEquals(original.getContents(), copy.getContents(), "Failed to copy the contents property");
assertEquals(copy.getContents(), original.getContents(), "Failed to copy contents property.");
}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/ConfigurationTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/ConfigurationTest.java
index 109031a..17920ec 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/ConfigurationTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/test/ConfigurationTest.java
@@ -255,7 +255,7 @@ public class ConfigurationTest extends AbstractEJB3Test {
RawConfiguration createRawConfiguration() {
RawConfiguration rawConfig = new RawConfiguration();
- rawConfig.setContents(new byte[] {1, 2, 3, 4, 5});
+ rawConfig.setContents("contents");
rawConfig.setPath("/tmp/foo");
return rawConfig;
diff --git a/modules/core/domain/src/test/resources/META-INF/persistence.xml b/modules/core/domain/src/test/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..018ea4d
--- /dev/null
+++ b/modules/core/domain/src/test/resources/META-INF/persistence.xml
@@ -0,0 +1,37 @@
+<!--
+ ~ 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.
+ -->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence">
+ <persistence-unit name="rhq-test" transaction-type="RESOURCE_LOCAL">
+ <jar-file>target/classes</jar-file>
+ <properties>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
+ <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
+ <property name="hibernate.connection.username" value="rhqadmin"/>
+ <property name="hibernate.connection.password" value="rhqadmin"/>
+ <property name="hibernate.connection.url" value="jdbc:postgresql://127.0.0.1:5432/rhq"/>
+ <property name="hibernate.jdbc.batch_size" value="30"/>
+ <property name="hibernate.cache.use_second_level_cache" value="false"/>
+ <property name="hibernate.show_sql" value="true" />
+ <property name="hibernate.format_sql" value="true" />
+ <property name="hibernate.use_sql_comments" value="true" />
+ <property name="hibernate.connection.autocommit" value="false"/>
+ </properties>
+ </persistence-unit>
+</persistence>
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
index 1f8b2b7..bccbc56 100644
--- 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
@@ -44,15 +44,15 @@ public class ConfigManagementFactoryImpl implements ConfigManagementFactory {
}
public ConfigManagement getStrategy(int resourceId) throws PluginContainerException {
- ConfigManagement loadConfig = createStrategy(resourceId);
- initStrategyDependencies(loadConfig);
+ ConfigManagement configManagement = createStrategy(resourceId);
+ initStrategyDependencies(configManagement);
- return loadConfig;
+ return configManagement;
}
- private void initStrategyDependencies(ConfigManagement loadConfig) {
- loadConfig.setComponentService(componentService);
- loadConfig.setConfigurationUtilityService(configUtilityService);
+ private void initStrategyDependencies(ConfigManagement configManagement) {
+ configManagement.setComponentService(componentService);
+ configManagement.setConfigurationUtilityService(configUtilityService);
}
private ConfigManagement createStrategy(int resourceId) throws PluginContainerException {
@@ -70,16 +70,16 @@ public class ConfigManagementFactoryImpl implements ConfigManagementFactory {
return new StructuredAndRawConfigManagement();
case STRUCTURED:
default:
- boolean daemonOnly = true;
- boolean onlyIfStarted = true;
- ResourceComponent resourceComponent = componentService.getComponent(resourceId,
- ResourceComponent .class, FacetLockType.READ, ConfigManagement.FACET_METHOD_TIMEOUT,
- daemonOnly, onlyIfStarted);
- if (resourceComponent instanceof ResourceConfigurationFacet){
- return new StructuredConfigManagement();
- }else{
- return new LegacyConfigManagement();
- }
+ boolean daemonOnly = true;
+ boolean onlyIfStarted = true;
+ ResourceComponent resourceComponent = componentService.getComponent(resourceId,
+ ResourceComponent.class, FacetLockType.READ, ConfigManagement.FACET_METHOD_TIMEOUT,
+ daemonOnly, onlyIfStarted);
+ if (resourceComponent instanceof ResourceConfigurationFacet){
+ return new StructuredConfigManagement();
+ } else{
+ return new LegacyConfigManagement();
+ }
}
}
}
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
index 4864fe2..32888ad 100644
--- 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
@@ -25,13 +25,13 @@ package org.rhq.core.pc.configuration;
import static org.testng.Assert.*;
+import org.rhq.core.pc.util.FacetLockType;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
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 ConfigManagementTest {
@@ -51,24 +51,17 @@ public class ConfigManagementFactoryImplTest extends ConfigManagementTest {
}
@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
- );
- }
+ public void factoryShouldInitializeLegacyConfigMgmtWithComponentService() throws Exception {
+ final boolean daemonOnly = true;
+ final ResourceComponent resourceComponent = context.mock(ResourceComponent.class);
- @Test
- public void factoryShouldInitializeLegacyLoadConfigWithComponentService() throws Exception {
context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(LEGACY_AMPS_VERSION));
+ allowing(componentService).getComponent(resourceId, ResourceComponent.class, FacetLockType.READ,
+ ConfigManagement.FACET_METHOD_TIMEOUT, daemonOnly, onlyIfStarted);
+ will(returnValue(resourceComponent));
+
+ allowing(componentService).getResourceType(resourceId);
+ will(returnValue(createResourceTypeThatSupportsStructured()));
}});
ConfigManagement loadConfig = factory.getStrategy(resourceId);
@@ -77,20 +70,14 @@ public class ConfigManagementFactoryImplTest extends ConfigManagementTest {
}
@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);
- }
+ public void factoryShouldInitializeLegacyConfigMgmtWithConfigurationUtilityService() throws Exception {
+ final boolean daemonOnly = true;
+ final ResourceComponent resourceComponent = context.mock(ResourceComponent.class);
- @Test
- public void factoryShouldReturnStructuredLoadConfigWhenAmpsVersionIs2dot1AndFormatIsStructured() throws Exception {
context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
+ allowing(componentService).getComponent(resourceId, ResourceComponent.class, FacetLockType.READ,
+ ConfigManagement.FACET_METHOD_TIMEOUT, daemonOnly, onlyIfStarted);
+ will(returnValue(resourceComponent));
allowing(componentService).getResourceType(resourceId);
will(returnValue(createResourceTypeThatSupportsStructured()));
@@ -98,18 +85,19 @@ public class ConfigManagementFactoryImplTest extends ConfigManagementTest {
ConfigManagement loadConfig = factory.getStrategy(resourceId);
- assertTrue(
- loadConfig instanceof StructuredConfigManagement,
- "Expected to get an instance of " + StructuredConfigManagement.class.getSimpleName() +
- "when resource is from a plugin having an ampsversion >= " + NON_LEGACY_AMPS_VERSION + " and the resource " +
- "configuration format is structured."
- );
+ assertConfigurationUtilityServiceInitialized(loadConfig);
}
@Test
- public void factoryShouldInitializeLoadStructuredWithComponentService() throws Exception {
+ public void factoryShouldInitializeStructuredConfigMgmtWithComponentService() throws Exception {
+ final ResourceComponent resourceComponent = context.mock(ResourceComponent.class);
+
context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
+ boolean daemonOnly = true;
+
+ allowing(componentService).getComponent(resourceId, ResourceComponent.class, FacetLockType.READ,
+ ConfigManagement.FACET_METHOD_TIMEOUT, daemonOnly, onlyIfStarted);
+ will(returnValue(resourceComponent));
allowing(componentService).getResourceType(resourceId);
will(returnValue(createResourceTypeThatSupportsStructured()));
@@ -121,9 +109,15 @@ public class ConfigManagementFactoryImplTest extends ConfigManagementTest {
}
@Test
- public void factoryShouldInitializeLoadStructuredWithConfigurationUtilityService() throws Exception {
+ public void factoryShouldInitializeStructuredConfigMgmtWithConfigurationUtilityService() throws Exception {
+ final boolean daemonOnly = true;
+
+ final ResourceComponent resourceComponent = context.mock(ResourceComponent.class);
+
context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
+ allowing(componentService).getComponent(resourceId, ResourceComponent.class, FacetLockType.READ,
+ ConfigManagement.FACET_METHOD_TIMEOUT, daemonOnly, onlyIfStarted);
+ will(returnValue(resourceComponent));
allowing(componentService).getResourceType(resourceId);
will(returnValue(createResourceTypeThatSupportsStructured()));
@@ -135,28 +129,15 @@ public class ConfigManagementFactoryImplTest extends ConfigManagementTest {
}
@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);
+ public void factoryShouldInitializeRawConfigMgmtWithComponentService() throws Exception {
+ final boolean daemonOnly = true;
- 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."
- );
- }
+ final ResourceComponent resourceComponent = context.mock(ResourceComponent.class);
- @Test
- public void factoryShouldInitializeLoadRawWithComponentService() throws Exception {
context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
+ allowing(componentService).getComponent(resourceId, ResourceComponent.class, FacetLockType.READ,
+ ConfigManagement.FACET_METHOD_TIMEOUT, daemonOnly, onlyIfStarted);
+ will(returnValue(resourceComponent));
allowing(componentService).getResourceType(resourceId);
will(returnValue(createResourceTypeThatSupportsStructured()));
@@ -168,9 +149,15 @@ public class ConfigManagementFactoryImplTest extends ConfigManagementTest {
}
@Test
- public void factoryShouldInitializeLoadRawWithConfigurationUtilityService() throws Exception {
+ public void factoryShouldInitializeRawConfigMgmtWithConfigurationUtilityService() throws Exception {
+ final boolean daemonOnly = true;
+
+ final ResourceComponent resourceComponent = context.mock(ResourceComponent.class);
+
context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
+ allowing(componentService).getComponent(resourceId, ResourceComponent.class, FacetLockType.READ,
+ ConfigManagement.FACET_METHOD_TIMEOUT, daemonOnly, onlyIfStarted);
+ will(returnValue(resourceComponent));
allowing(componentService).getResourceType(resourceId);
will(returnValue(createResourceTypeThatSupportsStructured()));
@@ -182,28 +169,15 @@ public class ConfigManagementFactoryImplTest extends ConfigManagementTest {
}
@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);
+ public void factoryShouldInitializeLoadStructuredAndRawWithComponentService() throws Exception {
+ final boolean daemonOnly = true;
- assertTrue(
- loadConfig instanceof StructuredAndRawConfigManagement,
- "Expected to get an instance of" + StructuredAndRawConfigManagement.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)."
- );
- }
+ final ResourceComponent resourceComponent = context.mock(ResourceComponent.class);
- @Test
- public void factoryShouldInitializeLoadStructuredAndRawWithComponentService() throws Exception {
context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
+ allowing(componentService).getComponent(resourceId, ResourceComponent.class, FacetLockType.READ,
+ ConfigManagement.FACET_METHOD_TIMEOUT, daemonOnly, onlyIfStarted);
+ will(returnValue(resourceComponent));
allowing(componentService).getResourceType(resourceId);
will(returnValue(createResourceTypeThatSupportsStructured()));
@@ -216,25 +190,32 @@ public class ConfigManagementFactoryImplTest extends ConfigManagementTest {
@Test
public void factoryShouldInitializeLoadStructuredAndRawWithConfigurationUtilityService() throws Exception {
+ final boolean daemonOnly = true;
+ final boolean onlyIfStarted = true;
+
+ final ResourceComponent resourceComponent = context.mock(ResourceComponent.class);
+
context.checking(new Expectations() {{
- allowing(componentService).getAmpsVersion(resourceId); will(returnValue(NON_LEGACY_AMPS_VERSION));
+ allowing(componentService).getComponent(resourceId, ResourceComponent.class, FacetLockType.READ,
+ ConfigManagement.FACET_METHOD_TIMEOUT, daemonOnly, onlyIfStarted);
+ will(returnValue(resourceComponent));
allowing(componentService).getResourceType(resourceId);
will(returnValue(createResourceTypeThatSupportsStructured()));
}});
- ConfigManagement loadConfig = factory.getStrategy(resourceId);
+ ConfigManagement configManagement = factory.getStrategy(resourceId);
- assertConfigurationUtilityServiceInitialized(loadConfig);
+ assertConfigurationUtilityServiceInitialized(configManagement);
}
- void assertComponentServiceInitialized(ConfigManagement loadConfig) {
- assertNotNull(loadConfig.getComponentService(), "The factory must initialize the componentService " +
+ void assertComponentServiceInitialized(ConfigManagement configMgmt) {
+ assertNotNull(configMgmt.getComponentService(), "The factory must initialize the componentService " +
"property of the loadConfig object.");
}
- void assertConfigurationUtilityServiceInitialized(ConfigManagement loadConfig) {
- assertNotNull(loadConfig.getConfigurationUtilityService(), "The factory must initialize the " +
+ void assertConfigurationUtilityServiceInitialized(ConfigManagement configMgmt) {
+ assertNotNull(configMgmt.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/ConfigManagementTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigManagementTest.java
index b9c3415..f55ca5a 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
@@ -77,7 +77,7 @@ public class ConfigManagementTest extends JMockTest {
RawConfiguration createRawConfiguration(String path) {
RawConfiguration rawConfig = new RawConfiguration();
- rawConfig.setContents(randomBytes());
+ rawConfig.setContents(new String(randomBytes()));
rawConfig.setPath(path);
return rawConfig;
@@ -103,11 +103,6 @@ public class ConfigManagementTest extends JMockTest {
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) {
@@ -116,12 +111,6 @@ public class ConfigManagementTest extends JMockTest {
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/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 98eec26..150f055 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -351,7 +351,7 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
} else {
current = new RawConfiguration();
current.setPath("/dev/null");
- current.setContents("".getBytes());
+ current.setContents("");
}
}
return current;
@@ -488,7 +488,7 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
String original = new String(getCurrent().getContents());
if (!updated.equals(original)) {
current = current.deepCopy(false);
- current.setContents(updated.getBytes());
+ current.setContents(updated);
markCurrentRawConfigUIBeanModified();
getModified().put(current.getPath(), current);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
index 4248ad6..bdeffb8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
@@ -1930,20 +1930,6 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
return update;
}
- public Collection<RawConfiguration> findRawConfigurationsByConfigurationId(int configId) {
- Configuration config = entityManager.find(Configuration.class, configId);
-
- if (config == null) {
- return Collections.EMPTY_LIST;
- }
-
- return config.getRawConfigurations();
- }
-
- public RawConfiguration findRawConfigurationById(int rawConfigId) {
- return entityManager.find(RawConfiguration.class, rawConfigId);
- }
-
public Configuration translateResourceConfiguration(Subject subject, int resourceId, Configuration configuration,
boolean fromStructured) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java
index f54254c..f3e7d8b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerLocal.java
@@ -482,10 +482,6 @@ public interface ConfigurationManagerLocal {
*/
ConfigurationDefinition getPackageTypeConfigurationDefinition(Subject subject, int packageTypeId);
- Collection<RawConfiguration> findRawConfigurationsByConfigurationId(int configId);
-
- RawConfiguration findRawConfigurationById(int rawConfigId);
-
Configuration translateResourceConfiguration(Subject subject, int resourceId, Configuration configuration,
boolean fromStructured) throws ResourceNotFoundException, TranslationNotSupportedException;
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java
index 9281e14..c3bad13 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java
@@ -932,72 +932,6 @@ public class ConfigurationManagerBeanTest extends AbstractEJB3Test {
}
}
- @Test
- public void testFindRawConfigurationById() throws Exception {
- Configuration config = persistNewConfigWithRawConfigs();
-
- getTransactionManager().begin();
- EntityManager entityMgr = getEntityManager();
-
- try {
- for (RawConfiguration rawConfig : config.getRawConfigurations()) {
- assertNotNull(
- "Failed to find raw config by id[" + rawConfig.getId() + "]",
- entityMgr.find(RawConfiguration.class, rawConfig.getId())
- );
- }
- }
- finally {
- getTransactionManager().rollback();
-
- getTransactionManager().begin();
- delete(config);
- getTransactionManager().commit();
- }
- }
-
- @Test
- public void testFindRawConfigurationsByConfigurationId() throws Exception {
- Configuration config = persistNewConfigWithRawConfigs();
-
- getTransactionManager().begin();
-
- try {
- Collection<RawConfiguration> rawConfigs = configurationManager.findRawConfigurationsByConfigurationId(
- config.getId());
-
- assertEquals("Failed to find raw configs for " + config, config.getRawConfigurations().size(), rawConfigs.size());
- }
- finally {
- getTransactionManager().rollback();
-
- getTransactionManager().begin();
- delete(config);
- getTransactionManager().commit();
- }
- }
-
- Configuration persistNewConfigWithRawConfigs() throws Exception {
- getTransactionManager().begin();
-
- Configuration config = new Configuration();
- config.addRawConfiguration(createRawConfiguration("12345"));
- config.addRawConfiguration(createRawConfiguration("54321"));
-
- persist(config);
-
- getTransactionManager().commit();
-
- return config;
- }
-
- RawConfiguration createRawConfiguration(String sha256) {
- RawConfiguration rawConfig = new RawConfiguration();
- rawConfig.setContents(new byte[] {});
-
- return rawConfig;
- }
-
void persist(Object entity) throws Exception {
EntityManager entityMgr = getEntityManager();
getEntityManager().persist(entity);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanUnitTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanUnitTest.java
index 5ba68e1..fa50d29 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanUnitTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanUnitTest.java
@@ -187,52 +187,55 @@ public class ConfigurationManagerBeanUnitTest extends JMockTest {
configurationMgr.updateResourceConfiguration(fixture.subject, fixture.resourceId, fixture.configuration);
}
- @Test
- public void updateResourceConfigShouldTranslateStructuredWhenStructredConfigHasEdits() throws Exception {
- final ResourceConfigUpdateFixture fixture = newStructuredAndRawResourceConfigUpdateFixture();
-
- final Configuration translatedConfig = fixture.configuration.deepCopy();
- translatedConfig.addRawConfiguration(new RawConfiguration());
-
- final ResourceConfigurationUpdate expectedUpdate = new ResourceConfigurationUpdate(fixture.resource,
- translatedConfig, fixture.subject.getName());
- expectedUpdate.setId(-1);
-
- final AgentClient agentClient = context.mock(AgentClient.class);
- final ConfigurationAgentService configAgentService = context.mock(ConfigurationAgentService.class);
-
- final ConfigurationUpdateRequest expectedUpdateRequest = new ConfigurationUpdateRequest(expectedUpdate.getId(),
- expectedUpdate.getConfiguration(), expectedUpdate.getResource().getId());
-
- final Sequence configUdpate = context.sequence("structured-config-update");
-
- context.checking(new Expectations() {{
- allowing(entityMgr).find(Resource.class, fixture.resourceId); will(returnValue(fixture.resource));
-
- allowing(authorizationMgr).canViewResource(fixture.subject, fixture.resourceId); will(returnValue(true));
-
- oneOf(configAgentService).merge(fixture.configuration, fixture.resourceId, FROM_STRUCTURED);
- will(returnValue(translatedConfig)); inSequence(configUdpate);
-
- oneOf(configurationMgrLocal).persistNewResourceConfigurationUpdateHistory(fixture.subject,
- fixture.resourceId, translatedConfig, INPROGRESS, fixture.subject.getName(),
- fixture.isPartOfGroupUpdate);
- will(returnValue(expectedUpdate));
- inSequence(configUdpate);
-
- allowing(agentMgr).getAgentClient(expectedUpdate.getResource().getAgent()); will(returnValue(agentClient));
-
- allowing(agentClient).getConfigurationAgentService(); will(returnValue(configAgentService));
-
- oneOf(configAgentService).updateResourceConfiguration(with(matchingUpdateRequest(expectedUpdateRequest)));
- inSequence(configUdpate);
- }});
-
- ResourceConfigurationUpdate actualUpdate = configurationMgr.updateStructuredOrRawConfiguration(fixture.subject,
- fixture.resourceId, fixture.configuration, FROM_STRUCTURED);
-
- assertSame(actualUpdate, expectedUpdate, "Expected to get back the persisted configuration update");
- }
+// @Test
+// public void updateResourceConfigShouldTranslateStructuredWhenStructredConfigHasEdits() throws Exception {
+// final ResourceConfigUpdateFixture fixture = newStructuredAndRawResourceConfigUpdateFixture();
+//
+// final Configuration translatedConfig = fixture.configuration.deepCopy();
+// translatedConfig.addRawConfiguration(new RawConfiguration());
+//
+// final ResourceConfigurationUpdate expectedUpdate = new ResourceConfigurationUpdate(fixture.resource,
+// translatedConfig, fixture.subject.getName());
+// expectedUpdate.setId(-1);
+//
+// final AgentClient agentClient = context.mock(AgentClient.class);
+// final ConfigurationAgentService configAgentService = context.mock(ConfigurationAgentService.class);
+//
+// final ConfigurationUpdateRequest expectedUpdateRequest = new ConfigurationUpdateRequest(expectedUpdate.getId(),
+// expectedUpdate.getConfiguration(), expectedUpdate.getResource().getId());
+//
+// final Sequence configUdpate = context.sequence("structured-config-update");
+//
+// context.checking(new Expectations() {{
+// allowing(entityMgr).find(Resource.class, fixture.resourceId); will(returnValue(fixture.resource));
+//
+// allowing(authorizationMgr).canViewResource(fixture.subject, fixture.resourceId); will(returnValue(true));
+//
+// oneOf(configAgentService).merge(fixture.configuration, fixture.resourceId, FROM_STRUCTURED);
+// will(returnValue(translatedConfig)); inSequence(configUdpate);
+//
+// oneOf(configurationMgrLocal).persistNewResourceConfigurationUpdateHistory(fixture.subject,
+// fixture.resourceId, translatedConfig, INPROGRESS, fixture.subject.getName(),
+// fixture.isPartOfGroupUpdate);
+// will(returnValue(expectedUpdate));
+// inSequence(configUdpate);
+//
+// allowing(agentMgr).getAgentClient(expectedUpdate.getResource().getAgent()); will(returnValue(agentClient));
+//
+// allowing(agentClient).getConfigurationAgentService(); will(returnValue(configAgentService));
+//
+// oneOf(configAgentService).validate(fixture.configuration, fixture.resourceId, FROM_STRUCTURED);
+// inSequence(configUdpate);
+//
+// oneOf(configAgentService).updateResourceConfiguration(with(matchingUpdateRequest(expectedUpdateRequest)));
+// inSequence(configUdpate);
+// }});
+//
+// ResourceConfigurationUpdate actualUpdate = configurationMgr.updateStructuredOrRawConfiguration(fixture.subject,
+// fixture.resourceId, fixture.configuration, FROM_STRUCTURED);
+//
+// assertSame(actualUpdate, expectedUpdate, "Expected to get back the persisted configuration update");
+// }
@Test
public void updateResourceConfigShouldNotTranslateStructuredWhenRawNotSupported() throws Exception {
@@ -311,6 +314,8 @@ public class ConfigurationManagerBeanUnitTest extends JMockTest {
allowing(agentClient).getConfigurationAgentService(); will(returnValue(configAgentService));
+ oneOf(configAgentService).validate(fixture.configuration, fixture.resourceId, FROM_RAW);
+
oneOf(configAgentService).updateResourceConfiguration(with(matchingUpdateRequest(expectedUpdateRequest)));
inSequence(configUdpate);
}});
diff --git a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
index 7c750d1..6d7b3f5 100644
--- a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
+++ b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
@@ -14,10 +14,6 @@ class RawServer implements ResourceComponent, ResourceConfigurationFacet {
File rawConfigDir
-// File rawConfig1
-// File rawConfig2
-// File rawConfig3
-
List rawConfigs = []
def ant = new AntBuilder()
@@ -34,15 +30,11 @@ class RawServer implements ResourceComponent, ResourceConfigurationFacet {
def index = 1
numberOfConfigFiles.times { rawConfigs << new File(rawConfigDir, "raw-test-${it + index++}.txt") }
-// rawConfig1 = new File(rawConfigDir, "raw-test-1.txt")
-// rawConfig2 = new File(rawConfigDir, "raw-test-2.txt")
-// rawConfig3 = new File(rawConfigDir, "raw-test-3.txt")
createRawConfigDir()
index = 1
rawConfigs.each { rawConfig -> createConfigFile(rawConfig, index++) }
-// createConfigFile()
}
def createRawConfigDir() {
@@ -75,14 +67,9 @@ class RawServer implements ResourceComponent, ResourceConfigurationFacet {
Set<RawConfiguration> loadRawConfigurations() {
def rawConfigSet = new HashSet()
- rawConfigs.each { rawConfigSet.add(new RawConfiguration(path: it.absolutePath, contents: it.readBytes())) }
+ rawConfigs.each { rawConfigSet.add(new RawConfiguration(path: it.absolutePath, contents: it.text)) }
return rawConfigSet
-
-// def rawConfigs = new HashSet()
-// rawConfigs.add(new RawConfiguration(path: rawConfig1.absolutePath, contents: rawConfig1.readBytes()))
-//
-// return rawConfigs
}
RawConfiguration mergeRawConfiguration(Configuration from, RawConfiguration to) {
diff --git a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy
index 2866427..f1a0455 100644
--- a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy
+++ b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy
@@ -109,10 +109,10 @@ class StructuredAndRawServer implements ResourceComponent, ResourceConfiguration
Set<RawConfiguration> loadRawConfigurations() {
def rawConfigs = new HashSet<RawConfiguration>()
- rawConfigs.add(new RawConfiguration(path: rawConfig1.absolutePath, contents: rawConfig1.readBytes()))
- rawConfigs.add(new RawConfiguration(path: rawConfig2.absolutePath, contents: rawConfig2.readBytes()))
- rawConfigs.add(new RawConfiguration(path: rawConfig3.absolutePath, contents: rawConfig3.readBytes()))
- rawConfigs.add(new RawConfiguration(path: rawConfig4.absolutePath, contents: rawConfig4.readBytes()))
+ rawConfigs.add(new RawConfiguration(path: rawConfig1.absolutePath, contents: rawConfig1.text))
+ rawConfigs.add(new RawConfiguration(path: rawConfig2.absolutePath, contents: rawConfig2.text))
+ rawConfigs.add(new RawConfiguration(path: rawConfig3.absolutePath, contents: rawConfig3.text))
+ rawConfigs.add(new RawConfiguration(path: rawConfig4.absolutePath, contents: rawConfig4.text))
return rawConfigs
}
@@ -130,17 +130,16 @@ class StructuredAndRawServer implements ResourceComponent, ResourceConfiguration
rawPropertiesConfig.setProperty(propertyName, property.stringValue)
}
- def stream = new ByteArrayOutputStream()
- rawPropertiesConfig.save(stream)
- rawConfiguration.contents = stream.toByteArray()
+ def writer = new StringWriter()
+ rawPropertiesConfig.save(writer)
+ rawConfiguration.contents = writer.toString()
return rawConfiguration
}
def loadRawPropertiesConfiguration(rawConfig) {
- def stream = new ByteArrayInputStream(rawConfig.contents)
def rawPropertiesConfig = new PropertiesConfiguration()
- rawPropertiesConfig.load(stream)
+ rawPropertiesConfig.load(new StringReader(rawConfig.contents))
return rawPropertiesConfig
}
@@ -186,7 +185,7 @@ class StructuredAndRawServer implements ResourceComponent, ResourceConfiguration
void validateStructuredConfiguration(Configuration config) {
def failValidation = resourceContext.pluginConfiguration.getSimple("failStructuredValidation")
if (failValidation.getBooleanValue()) {
- throw new RuntimeException("Validation failed for $configuration");
+ throw new RuntimeException("Validation failed for $confi153guration");
}
}
commit d31a520de773d483bc44b1932fc52380d3a79a96
Merge: da09882... 8b86c0b...
Author: Adam Young <ayoung(a)redhat.com>
Date: Tue Jan 26 09:29:15 2010 -0500
Merge branch 'raw-config' of ssh://git.fedorahosted.org/git/rhq/rhq into raw-config-confirm
commit da09882e2657b1b9ec51d19e0c2575c5d07fd722
Author: Adam Young <ayoung(a)redhat.com>
Date: Mon Jan 25 15:07:30 2010 -0500
Proof of concept for rhq template engine values.
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 9da62c0..1181bea 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
@@ -46,7 +46,9 @@ 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.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.template.TemplateEngine;
+import org.rhq.enterprise.client.proxy.ResourceClientProxy.Measurement;
import java.util.LinkedList;
import java.util.Queue;
@@ -205,17 +207,22 @@ public class ConfigurationManager extends AgentService implements ContainerServi
}
}
- private static TemplateEngine fetchTemplateEngine() {
+ private TemplateEngine fetchTemplateEngine() {
Resource platformResource = PluginContainer.getInstance().getInventoryManager().getPlatform();
TreeMap<String, String> tokens = new TreeMap<String, String>();
tokens.put("rhq.hostname", platformResource.getName());
+
+ MeasurementFacet facet = componentService.getComponent(platformResource.getId(), MeasurementFacet.class,
+ FacetLockType.READ, FACET_METHOD_TIMEOUT, daemonOnly, onlyIfStarted);
+
+
+
for (Resource childResource : platformResource.getChildResources()) {
if (childResource.getResourceType().getName().equals("Network Adapter" )){
String key = "rhq.interfaces."+childResource.getName()+".mac";
tokens.put(key ,childResource.getDescription());
- }
-
+ }
}
commit 8b86c0b07e73d2b7a8408c35abadf2ef225464f3
Author: John Sanda <john(a)localhost.localdomain>
Date: Mon Jan 25 09:29:56 2010 -0500
Disabling usage of flash for upload. It was set to auto but looked like it was still trying to use flash when it was not available.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/upload-modal.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/upload-modal.xhtml
index b5a356c..7c22818 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/upload-modal.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/upload-modal.xhtml
@@ -39,8 +39,7 @@
listHeight="50px"
fileUploadListener="#{fileUploader.fileUploadListener}"
addControlLabel="Browse"
- immediateUpload="false"
- allowFlash="auto">
+ immediateUpload="false">
<f:facet name="label">
<h:outputText value="{_KB}KB from {KB}KB uploaded --- {mm}:{ss}"/>
</f:facet>
@@ -54,4 +53,4 @@
</rich:modalPanel>
</f:subview>
-</ui:composition>
\ No newline at end of file
+</ui:composition>
commit b95c02c3829ab16f6dec78e218214845e72e81f7
Author: John Sanda <john(a)localhost.localdomain>
Date: Mon Jan 25 00:15:41 2010 -0500
Fixing <h:outputlink> tags for view full screen and upload links so that do not post back to server
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index bf83f76..f8e7bba 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -127,9 +127,9 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="4" style="width:100%;">
<h:outputLabel value=" "/>
- <h:outputLink onclick="#{rich:component('modalEditor')}.show()">View Full Screen</h:outputLink>
+ <h:outputLink value="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</h:outputLink>
- <h:outputLink onclick="#{rich:component('uploadWindow')}.show()">Upload New</h:outputLink>
+ <h:outputLink value="#" onclick="#{rich:component('uploadWindow')}.show()">Upload New</h:outputLink>
<h:commandLink action="#{ExistingResourceConfigurationUIBean.download}" value="Download">
<h:graphicImage value="/images/download.png"/>
@@ -170,8 +170,6 @@ THIS TEXT WILL BE REMOVED.
</h:panelGrid>
</rich:tab>
</rich:tabPanel>
- <ui:include src="upload-modal.xhtml"/>
- <ui:include src="view-raw-modal.xhtml"/>
</c:when>
<c:when test="${ExistingResourceConfigurationUIBean.structuredSupported}">
@@ -287,9 +285,9 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="4" style="width:100%;">
<h:outputLabel value=" "/>
- <h:outputLink onclick="#{rich:component('modalEditor')}.show()">View Full Screen</h:outputLink>
+ <h:outputLink value="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</h:outputLink>
- <h:outputLink onclick="#{rich:component('uploadWindow')}.show()">Upload New</h:outputLink>
+ <h:outputLink value="#" onclick="#{rich:component('uploadWindow')}.show()">Upload New</h:outputLink>
<h:commandLink action="#{ExistingResourceConfigurationUIBean.download}" value="Download">
<h:graphicImage value="/images/download.png"/>
@@ -330,12 +328,11 @@ THIS TEXT WILL BE REMOVED.
</h:panelGrid>
</rich:tab>
</rich:tabPanel>
-
- <ui:include src="upload-modal.xhtml"/>
- <ui:include src="view-raw-modal.xhtml"/>
</c:when>
</c:choose>
+ <ui:include src="upload-modal.xhtml"/>
+ <ui:include src="view-raw-modal.xhtml"/>
</h:form>
<h:panelGroup layout="block" styleClass="InfoBlock"
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
index 25cec92..e077962 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
@@ -8,7 +8,7 @@
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
- <f:subview id="subview">
+ <f:subview id="modalEditorSubview">
<rich:modalPanel id="modalEditor" width="800" height="600">
<f:facet name="header">
<h:panelGroup>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index d0850d8..7af5f2d 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -86,6 +86,7 @@ THIS TEXT WILL BE REMOVED.
onclick="cursor_wait();"
oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationViewUIBean.select(rawConfigUIBean.path)}"
+ limitToList="true"
reRender="fileContents,selectedFileHeader,modalEditor"/>
</c:forEach>
</rich:panelMenuGroup>
@@ -97,9 +98,9 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="4" style="width:100%;">
<h:outputLabel value=" "/>
- <h:outputLink onclick="#{rich:component('modalEditor')}.show()">View Full Screen</h:outputLink>
+ <h:outputLink value="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</h:outputLink>
- <h:outputLink onclick="#{rich:component('uploadWindow')}.show()">Upload New</h:outputLink>
+ <h:outputLink value="#" onclick="#{rich:component('uploadWindow')}.show()">Upload New</h:outputLink>
<h:commandLink action="#{ExistingResourceConfigurationViewUIBean.download}" value="Download">
<h:graphicImage value="/images/download.png"/>
@@ -217,6 +218,7 @@ THIS TEXT WILL BE REMOVED.
onclick="cursor_wait();"
oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationViewUIBean.select(rawConfigUIBean.path)}"
+ limitToList="true"
reRender="fileContents,selectedFileHeader,modalEditor"/>
</c:forEach>
</rich:panelMenuGroup>
@@ -228,9 +230,9 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="4" style="width:100%;">
<h:outputLabel value=" "/>
- <h:outputLink onclick="#{rich:component('modalEditor')}.show()">View Full Screen</h:outputLink>
+ <h:outputLink value="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</h:outputLink>
- <h:outputLink onclick="#{rich:component('uploadWindow')}.show()">Upload New</h:outputLink>
+ <h:outputLink value="#" onclick="#{rich:component('uploadWindow')}.show()">Upload New</h:outputLink>
<h:commandLink action="#{ExistingResourceConfigurationViewUIBean.download}" value="Download">
<h:graphicImage value="/images/download.png"/>
commit d0d773680c995cc94bddc96d39b2d0b0430739a5
Author: John Sanda <john(a)localhost.localdomain>
Date: Sat Jan 23 21:57:21 2010 -0500
Updating logic for displaying the number of files changed
The number of files changed was getting lost between translations since the modified cache
get purged on a translation call. I added a counter to keep track of the number of changed
files.
I also had to update some of the richfaces code on edit.xhtml so that both the upper and
the lower labels get rerendered when the file is edited.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index c2e4bf5..98eec26 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -77,6 +77,8 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
private String modalEditorContents;
+ private int numberOfModifiedFiles;
+
public ExistingResourceConfigurationUIBean() {
removeSessionScopedBeanIfInView("/rhq/resource/configuration/view.xhtml",
ExistingResourceConfigurationUIBean.class);
@@ -311,10 +313,14 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
RawConfiguration originalRaw = raws.get(editedRaw.getPath());
if (editedRaw.getSha256().equals(originalRaw.getSha256())) {
+ --numberOfModifiedFiles;
RawConfigUIBean rawUIBean = findRawConfigUIBeanByPath(editedRaw.getPath());
rawUIBean.setModified(false);
getModified().remove(editedRaw.getPath());
}
+ else {
+ ++numberOfModifiedFiles;
+ }
return null;
}
@@ -436,15 +442,15 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public String getModifiedFilesMsg() {
- if (!isDisplayChangedFilesLabel() || getModified().size() == 0) {
+ if (!isDisplayChangedFilesLabel() || numberOfModifiedFiles == 0) {
return "";
}
- if (getModified().size() == 1) {
+ if (numberOfModifiedFiles == 1) {
return "1 file changed in this configuration";
}
- return getModified().size() + " files changed in this configuration";
+ return numberOfModifiedFiles + " files changed in this configuration";
}
public boolean isModified(String path) {
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 3e96df8..bf83f76 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -229,7 +229,7 @@ THIS TEXT WILL BE REMOVED.
</rich:tab>
<rich:tab id="rawTab"
label="Advanced Mode"
- reRender="fileUpload,upperCommitPanel"
+ reRender="fileUpload,upperCommitPanel,lowerCommitPanel"
onlabelclick="cursor_wait();"
oncomplete="cursor_clear();">
<h:panelGrid columns="2"
@@ -254,7 +254,7 @@ THIS TEXT WILL BE REMOVED.
<rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
icon="#{rawConfigUIBean.icon}"
binding="#{rawConfigUIBean.panelMenuItem}"
- onclick="cursor_wait(); selectedFile = #{rawConfigUIBean.path};"
+ onclick="cursor_wait();"
oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
limitToList="true"
@@ -308,7 +308,7 @@ THIS TEXT WILL BE REMOVED.
readonly="false">
<a4j:support event="onkeyup"
ignoreDupeResponses="true"
- reRender="fileMenu,upperCommitPanel"
+ reRender="fileMenu,upperCommitPanel,lowerCommitPanel"
requestDelay="1000"
action="#{ExistingResourceConfigurationUIBean.editCurrent}"/>
</h:inputTextarea>
@@ -317,7 +317,7 @@ THIS TEXT WILL BE REMOVED.
</h:panelGrid>
<h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
- <h:panelGroup style="text-align:right">
+ <h:panelGroup id="lowerCommitPanel" style="text-align:right">
<h:outputText value="#{ExistingResourceConfigurationUIBean.modifiedFilesMsg}"
rendered="#{ExistingResourceConfigurationUIBean.rawMode}"
style="padding-right:10px"/>
commit 19e5f0e7fbe1a83dc2a0c1b3948327b349a03d37
Author: John Sanda <john(a)localhost.localdomain>
Date: Sat Jan 23 14:38:33 2010 -0500
Adding back call to update modified cache on tranlsation to raw
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index b552f22..c2e4bf5 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -148,7 +148,7 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
current = null;
setConfiguration(configuration);
-// updateModifiedCache();
+ updateModifiedCache();
mode = RAW_MODE;
return null;
}
commit c5136f8f0e0613dc1400358cc1ef40e3670dca1b
Author: John Sanda <john(a)localhost.localdomain>
Date: Sat Jan 23 14:28:34 2010 -0500
Moving the toolbar links one row above the file name label that appears before the text area
Moving the toolbar up gives more room for the file name label to so as to avoid wrapping
when long path names are encountered.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 0e252a3..3e96df8 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -125,17 +125,20 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
- <a4j:status id="selectedFileHeader"
- startText="Loading #{ExistingResourceConfigurationUIBean.current.path} ..."
- stopText="#{ExistingResourceConfigurationUIBean.current.path}"/>
- <a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
+ <h:outputLabel value=" "/>
+
+ <h:outputLink onclick="#{rich:component('modalEditor')}.show()">View Full Screen</h:outputLink>
- <a href="#" onclick="#{rich:component('uploadWindow')}.show()">Upload New</a>
+ <h:outputLink onclick="#{rich:component('uploadWindow')}.show()">Upload New</h:outputLink>
<h:commandLink action="#{ExistingResourceConfigurationUIBean.download}" value="Download">
<h:graphicImage value="/images/download.png"/>
<f:param name="id" value="#{ResourceUIBean.id}"/>
</h:commandLink>
+
+ <a4j:status id="selectedFileHeader"
+ startText="Loading #{ExistingResourceConfigurationUIBean.current.path} ..."
+ stopText="#{ExistingResourceConfigurationUIBean.current.path}"/>
</h:panelGrid>
<rich:panel style="margin-left:1px; border: none;">
@@ -282,17 +285,20 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
- <a4j:status id="selectedFileHeader"
- startText="Loading #{ExistingResourceConfigurationUIBean.current.path} ..."
- stopText="#{ExistingResourceConfigurationUIBean.current.path}"/>
- <a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
+ <h:outputLabel value=" "/>
+
+ <h:outputLink onclick="#{rich:component('modalEditor')}.show()">View Full Screen</h:outputLink>
- <a href="#" onclick="#{rich:component('uploadWindow')}.show()">Upload New</a>
+ <h:outputLink onclick="#{rich:component('uploadWindow')}.show()">Upload New</h:outputLink>
<h:commandLink action="#{ExistingResourceConfigurationUIBean.download}" value="Download">
<h:graphicImage value="/images/download.png"/>
<f:param name="id" value="#{ResourceUIBean.id}"/>
</h:commandLink>
+
+ <a4j:status id="selectedFileHeader"
+ startText="Loading #{ExistingResourceConfigurationUIBean.current.path} ..."
+ stopText="#{ExistingResourceConfigurationUIBean.current.path}"/>
</h:panelGrid>
<rich:panel id="fileContentsPanel" style="margin-left:1px; border: none;">
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 4abf675..d0850d8 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -95,17 +95,20 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
- <a4j:status id="selectedFileHeader"
- startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
- stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
- <a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
- <h:commandLink value="Upload New">
- <h:graphicImage value="/images/upload.png"/>
- </h:commandLink>
+ <h:outputLabel value=" "/>
+
+ <h:outputLink onclick="#{rich:component('modalEditor')}.show()">View Full Screen</h:outputLink>
+
+ <h:outputLink onclick="#{rich:component('uploadWindow')}.show()">Upload New</h:outputLink>
+
<h:commandLink action="#{ExistingResourceConfigurationViewUIBean.download}" value="Download">
<h:graphicImage value="/images/download.png"/>
<f:param name="id" value="#{ResourceUIBean.id}"/>
</h:commandLink>
+
+ <a4j:status id="selectedFileHeader"
+ startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
+ stopText="#{ExistingResourceConfigurationUIBean.current.path}"/>
</h:panelGrid>
<rich:panel style="margin-left:1px; border: none;">
@@ -223,17 +226,20 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
- <a4j:status id="selectedFileHeader"
- startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
- stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
- <a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
- <h:commandLink value="Upload New">
- <h:graphicImage value="/images/upload.png"/>
- </h:commandLink>
+ <h:outputLabel value=" "/>
+
+ <h:outputLink onclick="#{rich:component('modalEditor')}.show()">View Full Screen</h:outputLink>
+
+ <h:outputLink onclick="#{rich:component('uploadWindow')}.show()">Upload New</h:outputLink>
+
<h:commandLink action="#{ExistingResourceConfigurationViewUIBean.download}" value="Download">
<h:graphicImage value="/images/download.png"/>
<f:param name="id" value="#{ResourceUIBean.id}"/>
</h:commandLink>
+
+ <a4j:status id="selectedFileHeader"
+ startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
+ stopText="#{ExistingResourceConfigurationUIBean.current.path}"/>
</h:panelGrid>
<rich:panel style="margin-left:1px; border: none;">
commit 33381b04f5c74101bcbe01403abf90278c4989ee
Author: John Sanda <john(a)localhost.localdomain>
Date: Sat Jan 23 02:00:04 2010 -0500
Adding logic for generating the number of files changes message
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 0f92b49..b552f22 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -148,7 +148,7 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
current = null;
setConfiguration(configuration);
- updateModifiedCache();
+// updateModifiedCache();
mode = RAW_MODE;
return null;
}
@@ -313,6 +313,7 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
if (editedRaw.getSha256().equals(originalRaw.getSha256())) {
RawConfigUIBean rawUIBean = findRawConfigUIBeanByPath(editedRaw.getPath());
rawUIBean.setModified(false);
+ getModified().remove(editedRaw.getPath());
}
return null;
}
@@ -422,6 +423,30 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return mode == RAW_MODE;
}
+ public boolean isDisplayChangedFilesLabel() {
+ if (isStructuredMode()) {
+ return false;
+ }
+
+ if (isRawSupported()) {
+ return true;
+ }
+
+ return isRawMode();
+ }
+
+ public String getModifiedFilesMsg() {
+ if (!isDisplayChangedFilesLabel() || getModified().size() == 0) {
+ return "";
+ }
+
+ if (getModified().size() == 1) {
+ return "1 file changed in this configuration";
+ }
+
+ return getModified().size() + " files changed in this configuration";
+ }
+
public boolean isModified(String path) {
return getModified().keySet().contains(path);
}
commit 93f1d77ed02e4539b7c4dbcbf614dfa5137642a3
Author: John Sanda <john(a)localhost.localdomain>
Date: Sat Jan 23 01:57:15 2010 -0500
Adding logic to generate the number of files changed label that appears next to the commit button
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 6d6beec..0e252a3 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -36,6 +36,8 @@ THIS TEXT WILL BE REMOVED.
var currentFileModified = false;
+ var selectedFile = '';
+
function setCurrentFileModified() {
currentFileModified = true;
}
@@ -53,8 +55,11 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="2" style="width:100%">
<h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
- <h:panelGroup style="text-align:right">
- <h:outputText style="padding-right:10px">n files changed in this configuration</h:outputText>
+ <h:panelGroup id="upperCommitPanel" style="text-align:right">
+ <h:outputText id="changedFilesLabel"
+ rendered="#{ExistingResourceConfigurationUIBean.displayChangedFilesLabel}"
+ style="padding-right:10px"
+ value="#{ExistingResourceConfigurationUIBean.modifiedFilesMsg}"/>
<h:commandButton value="Commit"
action="#{ExistingResourceConfigurationUIBean.updateRawConfiguration}"
title="Click to Save Changes"
@@ -150,7 +155,9 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
<h:panelGroup style="text-align:right">
- <h:outputText style="padding-right:10px">n files changed in this configuration</h:outputText>
+ <h:outputText value="#{ExistingResourceConfigurationUIBean.modifiedFilesMsg}"
+ rendered="#{ExistingResourceConfigurationUIBean.rawMode}"
+ style="padding-right:10px"/>
<h:commandButton value="Commit"
action="#{ExistingResourceConfigurationUIBean.updateRawConfiguration}"
title="Click to Save Changes"
@@ -192,7 +199,7 @@ THIS TEXT WILL BE REMOVED.
valueChangeListener="#{ExistingResourceConfigurationUIBean.changeTabs}">
<rich:tab id="structuredTab"
label="Basic Mode"
- reRender="uploadForm"
+ reRender="fileUpload,upperCommitPanel"
onlabelclick="cursor_wait();"
oncomplete="cursor_clear();">
<onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}"
@@ -219,7 +226,7 @@ THIS TEXT WILL BE REMOVED.
</rich:tab>
<rich:tab id="rawTab"
label="Advanced Mode"
- reRender="uploadForm"
+ reRender="fileUpload,upperCommitPanel"
onlabelclick="cursor_wait();"
oncomplete="cursor_clear();">
<h:panelGrid columns="2"
@@ -244,7 +251,7 @@ THIS TEXT WILL BE REMOVED.
<rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
icon="#{rawConfigUIBean.icon}"
binding="#{rawConfigUIBean.panelMenuItem}"
- onclick="cursor_wait();"
+ onclick="cursor_wait(); selectedFile = #{rawConfigUIBean.path};"
oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
limitToList="true"
@@ -295,7 +302,7 @@ THIS TEXT WILL BE REMOVED.
readonly="false">
<a4j:support event="onkeyup"
ignoreDupeResponses="true"
- reRender="fileMenu"
+ reRender="fileMenu,upperCommitPanel"
requestDelay="1000"
action="#{ExistingResourceConfigurationUIBean.editCurrent}"/>
</h:inputTextarea>
@@ -305,7 +312,9 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
<h:panelGroup style="text-align:right">
- <h:outputText style="padding-right:10px">n files changed in this configuration</h:outputText>
+ <h:outputText value="#{ExistingResourceConfigurationUIBean.modifiedFilesMsg}"
+ rendered="#{ExistingResourceConfigurationUIBean.rawMode}"
+ style="padding-right:10px"/>
<h:commandButton value="Commit"
action="#{ExistingResourceConfigurationUIBean.updateRawConfiguration}"
title="Click to Save Changes"
commit 268aa150aeb81cccc3f9efb7234a70d8b2c46118
Author: Adam Young <ayoung(a)redhat.com>
Date: Fri Jan 22 16:06:05 2010 -0500
Proof of concept for templating
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 dc3955a..9da62c0 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
@@ -33,6 +33,8 @@ import org.rhq.core.clientapi.server.configuration.ConfigurationUpdateResponse;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.RawConfiguration;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pc.ContainerService;
import org.rhq.core.pc.PluginContainer;
@@ -44,10 +46,12 @@ 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.template.TemplateEngine;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;
+import java.util.TreeMap;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
@@ -185,16 +189,40 @@ public class ConfigurationManager extends AgentService implements ContainerServi
private void mergeRawsIntoStructured(Configuration configuration, ResourceConfigurationFacet facet) {
Configuration structuredConfig = facet.loadStructuredConfiguration();
+ TemplateEngine templateEngine = fetchTemplateEngine();
+
+
if (structuredConfig != null) {
prepareConfigForMergeIntoStructured(configuration, structuredConfig);
for (RawConfiguration rawConfig : configuration.getRawConfigurations()) {
+ String contents = templateEngine.replaceTokens(new String(rawConfig.getContents()));
+ rawConfig.setContents(contents.getBytes());
+
structuredConfig.addRawConfiguration(rawConfig);
facet.mergeStructuredConfiguration(rawConfig, configuration);
}
}
}
+ private static TemplateEngine fetchTemplateEngine() {
+ Resource platformResource = PluginContainer.getInstance().getInventoryManager().getPlatform();
+ TreeMap<String, String> tokens = new TreeMap<String, String>();
+ tokens.put("rhq.hostname", platformResource.getName());
+
+ for (Resource childResource : platformResource.getChildResources()) {
+ if (childResource.getResourceType().getName().equals("Network Adapter" )){
+ String key = "rhq.interfaces."+childResource.getName()+".mac";
+ tokens.put(key ,childResource.getDescription());
+ }
+
+ }
+
+
+ TemplateEngine templateEngine = new TemplateEngine(tokens);
+ return templateEngine;
+ }
+
private void prepareConfigForMergeIntoStructured(Configuration config, Configuration latestStructured) {
config.getAllProperties().clear();
for (Property property : latestStructured.getProperties()) {
diff --git a/modules/core/util/src/main/java/org/rhq/core/template/TemplateEngine.java b/modules/core/util/src/main/java/org/rhq/core/template/TemplateEngine.java
index 7c258b4..0e56625 100644
--- a/modules/core/util/src/main/java/org/rhq/core/template/TemplateEngine.java
+++ b/modules/core/util/src/main/java/org/rhq/core/template/TemplateEngine.java
@@ -38,7 +38,8 @@ public class TemplateEngine {
String next = matcher.group();
Matcher keyMatcher = keyPattern.matcher(next);
if (keyMatcher.find()) {
- String value = tokens.get(keyMatcher.group());
+ String key = keyMatcher.group();
+ String value = tokens.get(key);
if (value != null) {
next = value;
}
commit c6242c2d59ce4316edfed58630a7f51cd6bad185
Author: John Sanda <john(a)localhost.localdomain>
Date: Fri Jan 22 14:07:54 2010 -0500
Removing resource name that was directly above the tabs
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index d99ac30..6d6beec 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -52,7 +52,6 @@ THIS TEXT WILL BE REMOVED.
<input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
<h:panelGrid columns="2" style="width:100%">
- <h:outputText value="#{ResourceUIBean.name}"/>
<h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
<h:panelGroup style="text-align:right">
<h:outputText style="padding-right:10px">n files changed in this configuration</h:outputText>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 2e3864e..4abf675 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -46,7 +46,6 @@ THIS TEXT WILL BE REMOVED.
<input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
<h:panelGrid columns="2" style="width:100%">
- <h:outputText value="#{ResourceUIBean.name}"/>
<h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
<h:panelGroup style="text-align:right">
<h:commandButton value="Edit"
@@ -71,7 +70,7 @@ THIS TEXT WILL BE REMOVED.
<rich:panel style="width:100%">
<f:facet name="header">Files</f:facet>
<rich:panelMenu mode="ajax"
- expandMode="client"
+ expandMode="client"
iconCollapsedGroup="/images/icn_tree_folder.gif"
iconExpandedGroup="/images/icn_tree_folder.gif"
limitToList="true"
commit 3ec326edcbfb065d7952022e879f3d8d1d03efb3
Author: John Sanda <john(a)localhost.localdomain>
Date: Fri Jan 22 13:51:36 2010 -0500
Updating resource tree navigation logic for configuration UI
When you are on a configuration ui screen, be it a view or edit screen, and click on a
different resource in the resource tree, you will now be sent to view.xhtml for that
resource.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java
index 6fee523..18554d3 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeStateAdvisor.java
@@ -118,10 +118,12 @@ public class ResourceTreeStateAdvisor implements TreeStateAdvisor {
|| (path.startsWith("/rhq/resource/events") && !facets.isEvent())) {
// This resource doesn't support those facets
path = fallbackPath;
- } else if ((path.startsWith("/rhq/resource/configuration/edit.xhtml") ||
- path.startsWith("/rhq/resource/configuration/edit-raw.xhtml"))
- && facets.isConfiguration()) {
+ } else if ((path.startsWith("/rhq/resource/configuration/view-map.xhtml") ||
+ path.startsWith("/rhq/resource/configuration/edit-map.xhtml") ||
+ path.startsWith("/rhq/resource/configuration/add-map.xhtml") ||
+ path.startsWith("/rhq/resource/configuration/edit.xhtml") && facets.isConfiguration())) {
path = "/rhq/resource/configuration/view.xhtml";
+
} else if (!path.startsWith("/rhq/resource/content/view.xhtml")
&& path.startsWith("/rhq/resource/content/") && facets.isContent()) {
path = "/rhq/resource/content/view.xhtml";
commit 8515b0fb9adb688942b7b39ba3baba1a7646e548
Author: John Sanda <john(a)localhost.localdomain>
Date: Fri Jan 22 12:14:48 2010 -0500
Fixing download behavior so that the file name matches the file name listed on the page
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 17113c4..0f92b49 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -498,8 +498,10 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
public String download() {
try {
+ File file = new File(getCurrentPath());
+
HttpServletResponse response = FacesContextUtility.getResponse();
- response.setHeader("Content-Disposition", "attachment;filename=" + getCurrentPath());
+ response.setHeader("Content-Disposition", "attachment;filename=" + file.getName());
OutputStream ostream = response.getOutputStream();
ostream.write(getCurrentContents().getBytes());
ostream.flush();
commit d8e228989067835e680819482634fc564c69c396
Author: John Sanda <john(a)localhost.localdomain>
Date: Fri Jan 22 11:28:42 2010 -0500
Removing dead code
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index bb18d4c..17113c4 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -317,11 +317,6 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return null;
}
-// public String getComponentsToRerenderOnEdit() {
-// RawConfiguration editedRaw = getCurrent();
-// RawConfiguration
-// }
-
public void undoEdit(String path) {
modified.remove(path);
RawConfigUIBean bean = findRawConfigUIBeanByPath(path);
commit 00868bfc61dcadd37fa551aef6205b68b8c413cd
Author: John Sanda <john(a)localhost.localdomain>
Date: Thu Jan 21 22:00:02 2010 -0500
Updating logic for key events to indicate whether or not a file has been modified
When you start editing the contents of a raw config file, an event get fired off to the
server to determine if the edits have modified the file. If so, the file menu is updated
to reflect that the file has been modified. If you further edit the file to undo you
edits, the file menu will get updated to reflect that the file has been restored to
its original state.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
index 85f9617..7771834 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
@@ -69,7 +69,7 @@ public class RawConfigUIBean {
public void setModified(boolean modified) {
this.modified = modified;
-// panelMenuItem.setIcon(getIcon());
+ panelMenuItem.setIcon(getIcon());
}
public String getPath() {
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 18e08ca..d99ac30 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -73,38 +73,46 @@ THIS TEXT WILL BE REMOVED.
styleClass="raw-outer-table"
columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
<h:panelGrid columns="1">
- <rich:panel style="width:100%">
- <f:facet name="header">Files</f:facet>
-
- <rich:panelMenu id="fileMenu"
- mode="ajax"
- expandMode="client"
- iconCollapsedGroup="/images/icn_tree_folder.gif"
- iconExpandedGroup="/images/icn_tree_folder.gif">
- <c:forEach items="#{rawConfigDirectories}"
- var="rawConfigDir">
- <rich:panelMenuGroup label="#{rawConfigDir.path}"
- expanded="true"
- selectedChild="#{ExistingResourceConfigurationUIBean.currentPath}">
- <c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
- <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
- icon="#{rawConfigUIBean.icon}"
- onclick="cursor_wait();"
- oncomplete="cursor_clear();"
- action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
- reRender="fileContents,selectedFileHeader,modalEditor,fileMenu">
- <h:panelGroup>
- <h:outputText value="#{#rawConfigUIBean.fileName}"/>
- <c:if test="#{rawConfigUIBean.modified}">
- <h:commandButton value="Undo"/>
- </c:if>
- </h:panelGroup>
- </rich:panelMenuItem>
- </c:forEach>
- </rich:panelMenuGroup>
- </c:forEach>
- </rich:panelMenu>
- </rich:panel>
+ <rich:panel style="width:100%">
+ <f:facet name="header">Files</f:facet>
+
+ <rich:panelMenu id="fileMenu"
+ mode="ajax"
+ expandMode="client"
+ iconCollapsedGroup="/images/icn_tree_folder.gif"
+ iconExpandedGroup="/images/icn_tree_folder.gif">
+ <c:forEach items="#{rawConfigDirectories}"
+ var="rawConfigDir">
+ <rich:panelMenuGroup label="#{rawConfigDir.path}"
+ expanded="true"
+ selectedChild="#{ExistingResourceConfigurationUIBean.currentPath}">
+ <c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
+ <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
+ icon="#{rawConfigUIBean.icon}"
+ binding="#{rawConfigUIBean.panelMenuItem}"
+ onclick="cursor_wait();"
+ oncomplete="cursor_clear();"
+ action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
+ limitToList="true"
+ reRender="fileContents,selectedFileHeader,modalEditor,fileMenu">
+ <h:panelGroup>
+ <h:outputText value="#{#rawConfigUIBean.fileName}"/>
+ <h:commandButton value="Undo"
+ styleClass="buttonmed"
+ rendered="#{rawConfigUIBean.modified}">
+ <a4j:support event="onclick"
+ onsumbit="cursor_wait()"
+ oncomplete="cursor_clear()"
+ action="#{ExistingResourceConfigurationUIBean.undoEdit(rawConfigUIBean.path)}"
+ reRender="fileMenu,fileContents"/>
+ </h:commandButton>
+ </h:panelGroup>
+ </rich:panelMenuItem>
+ </c:forEach>
+ </rich:panelMenuGroup>
+ </c:forEach>
+ </rich:panelMenu>
+ </rich:panel>
<rich:panel style="border:none">
<h:graphicImage url="/images/star_on_24.png"/>
<h:outputText value="- Contains uncommitted changes"/>
@@ -119,7 +127,7 @@ THIS TEXT WILL BE REMOVED.
<a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
<a href="#" onclick="#{rich:component('uploadWindow')}.show()">Upload New</a>
-
+
<h:commandLink action="#{ExistingResourceConfigurationUIBean.download}" value="Download">
<h:graphicImage value="/images/download.png"/>
<f:param name="id" value="#{ResourceUIBean.id}"/>
@@ -131,7 +139,7 @@ THIS TEXT WILL BE REMOVED.
style="width:100%"
value="#{ExistingResourceConfigurationUIBean.currentContents}"
readonly="false">
- <a4j:support event="onkeypress"
+ <a4j:support event="onkeyup"
ignoreDupeResponses="true"
reRender="fileMenu"
requestDelay="1000"
@@ -244,15 +252,15 @@ THIS TEXT WILL BE REMOVED.
reRender="fileContents,selectedFileHeader,modalEditor,fileMenu">
<h:panelGroup>
<h:outputText value="#{#rawConfigUIBean.fileName}"/>
- <c:if test="#{rawConfigUIBean.modified}">
- <h:commandButton value="Undo" styleClass="buttonmed">
- <a4j:support event="onclick"
- onsumbit="cursor_wait()"
- oncomplete="cursor_clear()"
- action="#{ExistingResourceConfigurationUIBean.undoEdit(rawConfigUIBean.path)}"
- reRender="fileMenu"/>
- </h:commandButton>
- </c:if>
+ <h:commandButton value="Undo"
+ styleClass="buttonmed"
+ rendered="#{rawConfigUIBean.modified}">
+ <a4j:support event="onclick"
+ onsumbit="cursor_wait()"
+ oncomplete="cursor_clear()"
+ action="#{ExistingResourceConfigurationUIBean.undoEdit(rawConfigUIBean.path)}"
+ reRender="fileMenu,fileContents"/>
+ </h:commandButton>
</h:panelGroup>
</rich:panelMenuItem>
</c:forEach>
@@ -286,7 +294,7 @@ THIS TEXT WILL BE REMOVED.
style="width:100%"
value="#{ExistingResourceConfigurationUIBean.currentContents}"
readonly="false">
- <a4j:support event="onkeypress"
+ <a4j:support event="onkeyup"
ignoreDupeResponses="true"
reRender="fileMenu"
requestDelay="1000"
commit 73319df68d65c2150e92d24449a3374e73bbfddd
Author: Adam Young <ayoung(a)redhat.com>
Date: Thu Jan 21 18:38:01 2010 -0500
Made the member variable private.
diff --git a/modules/core/util/src/main/java/org/rhq/core/template/TemplateEngine.java b/modules/core/util/src/main/java/org/rhq/core/template/TemplateEngine.java
index 4181bba..7c258b4 100644
--- a/modules/core/util/src/main/java/org/rhq/core/template/TemplateEngine.java
+++ b/modules/core/util/src/main/java/org/rhq/core/template/TemplateEngine.java
@@ -5,7 +5,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TemplateEngine {
- public final Map<String, String> tokens;
+ private final Map<String, String> tokens;
/**
* In English, the open delimiter <%
commit 633a8a6f5a51ea12ee3ea93c3745edb78b672c1c
Author: Adam Young <ayoung(a)redhat.com>
Date: Thu Jan 21 16:34:25 2010 -0500
Using the more efficient Java Matcher and Pattern classes over the String.replaceAll approach.
diff --git a/modules/core/util/src/main/java/org/rhq/core/template/TemplateEngine.java b/modules/core/util/src/main/java/org/rhq/core/template/TemplateEngine.java
index eef1b8e..4181bba 100644
--- a/modules/core/util/src/main/java/org/rhq/core/template/TemplateEngine.java
+++ b/modules/core/util/src/main/java/org/rhq/core/template/TemplateEngine.java
@@ -1,24 +1,53 @@
package org.rhq.core.template;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
public class TemplateEngine {
- public final Map<String, String> tokens;
+ public final Map<String, String> tokens;
- public TemplateEngine(Map<String, String> tokens) {
- super();
- this.tokens = tokens;
- }
+ /**
+ * In English, the open delimiter <%
+ * zero or more white space characters
+ * The following pattern at least once:
+ * one or more word characters followed by an optional period
+ * zero or more white space characters
+ * The closing delimiter %>
+ * Thus <% rhq.system %> and <%rhq.system%> are equivalent
+ * <% rhq.platform.ip_address %> is Valid.
+ * <% & %> is not a valid token
+ *
+ */
- public String replaceTokens(String input){
-
- for (String token : tokens.keySet()) {
- //Since . is a special regex character,
- //replace it with \. before building the larger regex
- String regex = "<%\\s*" + token.replaceAll("\\.", "\\\\.") + "\\s*%>";
- input = input.replaceAll(regex, tokens.get(token) );
- }
-
- return input;
- }
+ static String tokenRegex = "<%\\s*(\\w+\\.?)+\\s*%>";
+ static String keyRegex = "(\\w+\\.?)+";
+
+ static Pattern tokenPattern = Pattern.compile(tokenRegex);
+ static Pattern keyPattern = Pattern.compile(keyRegex);
+
+ public TemplateEngine(Map<String, String> tokens) {
+ super();
+ this.tokens = tokens;
+ }
+
+ public String replaceTokens(String input) {
+ StringBuffer buffer = new StringBuffer();
+ Matcher matcher = tokenPattern.matcher(input);
+ while (matcher.find()) {
+ String next = matcher.group();
+ Matcher keyMatcher = keyPattern.matcher(next);
+ if (keyMatcher.find()) {
+ String value = tokens.get(keyMatcher.group());
+ if (value != null) {
+ next = value;
+ }
+ }
+ //If we didn't find a replacement for the key
+ //We leave the original value unchanged
+ matcher.appendReplacement(buffer, next);
+ }
+ matcher.appendTail(buffer);
+ return buffer.toString();
+ }
}
commit 3e930f2105a7da3b7f6e37d3687bf2726cf964b3
Author: John Sanda <john(a)localhost.localdomain>
Date: Thu Jan 21 15:53:50 2010 -0500
Adding initial support for marking a file modified based on keyboard events
When you start editing a config file, an ajax request is triggered from a keyboard event.
The server side code determines if there have been edits and if so, the current file in
the menu will be rerendered and marked updated.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 2b8bdc9..bb18d4c 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -307,10 +307,21 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public String editCurrent() {
- String changedContents = getCurrentContents();
+ RawConfiguration editedRaw = getCurrent();
+ RawConfiguration originalRaw = raws.get(editedRaw.getPath());
+
+ if (editedRaw.getSha256().equals(originalRaw.getSha256())) {
+ RawConfigUIBean rawUIBean = findRawConfigUIBeanByPath(editedRaw.getPath());
+ rawUIBean.setModified(false);
+ }
return null;
}
+// public String getComponentsToRerenderOnEdit() {
+// RawConfiguration editedRaw = getCurrent();
+// RawConfiguration
+// }
+
public void undoEdit(String path) {
modified.remove(path);
RawConfigUIBean bean = findRawConfigUIBeanByPath(path);
@@ -320,7 +331,6 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
bean.setIcon("/images/blank.png");
}
-
}
public int getConfigId() {
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 0bdbd47..18e08ca 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -130,7 +130,13 @@ THIS TEXT WILL BE REMOVED.
<h:inputTextarea id="fileContents"
style="width:100%"
value="#{ExistingResourceConfigurationUIBean.currentContents}"
- readonly="false"/>
+ readonly="false">
+ <a4j:support event="onkeypress"
+ ignoreDupeResponses="true"
+ reRender="fileMenu"
+ requestDelay="1000"
+ action="#{ExistingResourceConfigurationUIBean.editCurrent}"/>
+ </h:inputTextarea>
</rich:panel>
</h:panelGrid>
</h:panelGrid>
@@ -280,14 +286,11 @@ THIS TEXT WILL BE REMOVED.
style="width:100%"
value="#{ExistingResourceConfigurationUIBean.currentContents}"
readonly="false">
- <ui:remove>
- <a4j:support event="onkeydown"
- onsubmit="return !currentFileModified;"
- oncomplete="currentFileModified = true;"
+ <a4j:support event="onkeypress"
+ ignoreDupeResponses="true"
reRender="fileMenu"
- requestDelay="3000"
+ requestDelay="1000"
action="#{ExistingResourceConfigurationUIBean.editCurrent}"/>
- </ui:remove>
</h:inputTextarea>
</rich:panel>
</h:panelGrid>
commit b6a0d16a6f942c7a7c536b213ca0fd88629da291
Author: John Sanda <john(a)localhost.localdomain>
Date: Thu Jan 21 14:23:03 2010 -0500
Fixing upload for raw-only
In the case where raw-only is supported, I forgot to add in the subview that contains the
modal window with the upload component.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index e725134..0bdbd47 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -34,7 +34,7 @@ THIS TEXT WILL BE REMOVED.
document.body.style.cursor = 'default';
}
- var currentFileModifed = false;
+ var currentFileModified = false;
function setCurrentFileModified() {
currentFileModified = true;
@@ -147,6 +147,7 @@ THIS TEXT WILL BE REMOVED.
</h:panelGrid>
</rich:tab>
</rich:tabPanel>
+ <ui:include src="upload-modal.xhtml"/>
<ui:include src="view-raw-modal.xhtml"/>
</c:when>
@@ -279,10 +280,14 @@ THIS TEXT WILL BE REMOVED.
style="width:100%"
value="#{ExistingResourceConfigurationUIBean.currentContents}"
readonly="false">
+ <ui:remove>
<a4j:support event="onkeydown"
+ onsubmit="return !currentFileModified;"
+ oncomplete="currentFileModified = true;"
reRender="fileMenu"
requestDelay="3000"
action="#{ExistingResourceConfigurationUIBean.editCurrent}"/>
+ </ui:remove>
</h:inputTextarea>
</rich:panel>
</h:panelGrid>
commit 560f369dc44559f3f839180a9a6d0685b54b32bd
Merge: 4f9777a... c5351b1...
Author: Adam Young <ayoung(a)redhat.com>
Date: Thu Jan 21 13:55:58 2010 -0500
Merge branch 'raw-config' of ssh://git.fedorahosted.org/git/rhq/rhq into raw-config-confirm
commit c5351b10217dc42b367411a7e4aa5a3b6bcdc8bb
Author: John Sanda <john(a)localhost.localdomain>
Date: Thu Jan 21 12:49:05 2010 -0500
Adding new upload behavior for raw-only edit
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 17f968f..e725134 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -34,8 +34,14 @@ THIS TEXT WILL BE REMOVED.
document.body.style.cursor = 'default';
}
- function open_modal_editor() {
+ var currentFileModifed = false;
+ function setCurrentFileModified() {
+ currentFileModified = true;
+ }
+
+ function resetCurrentFile() {
+ currentFileModified;
}
</script>
@@ -111,9 +117,9 @@ THIS TEXT WILL BE REMOVED.
startText="Loading #{ExistingResourceConfigurationUIBean.current.path} ..."
stopText="#{ExistingResourceConfigurationUIBean.current.path}"/>
<a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
- <h:commandLink value="Upload New">
- <h:graphicImage value="/images/upload.png"/>
- </h:commandLink>
+
+ <a href="#" onclick="#{rich:component('uploadWindow')}.show()">Upload New</a>
+
<h:commandLink action="#{ExistingResourceConfigurationUIBean.download}" value="Download">
<h:graphicImage value="/images/download.png"/>
<f:param name="id" value="#{ResourceUIBean.id}"/>
@@ -261,11 +267,6 @@ THIS TEXT WILL BE REMOVED.
<a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
<a href="#" onclick="#{rich:component('uploadWindow')}.show()">Upload New</a>
- <ui:remove>
- <h:commandLink value="Upload New">
- <h:graphicImage value="/images/upload.png"/>
- </h:commandLink>
- </ui:remove>
<h:commandLink action="#{ExistingResourceConfigurationUIBean.download}" value="Download">
<h:graphicImage value="/images/download.png"/>
@@ -278,9 +279,9 @@ THIS TEXT WILL BE REMOVED.
style="width:100%"
value="#{ExistingResourceConfigurationUIBean.currentContents}"
readonly="false">
- <a4j:support event="onchange"
+ <a4j:support event="onkeydown"
reRender="fileMenu"
- requestDelay="1000"
+ requestDelay="3000"
action="#{ExistingResourceConfigurationUIBean.editCurrent}"/>
</h:inputTextarea>
</rich:panel>
commit 1b08277e41344cf82e62a830ee5c4c9668cebe08
Author: John Sanda <john(a)localhost.localdomain>
Date: Thu Jan 21 12:23:37 2010 -0500
Modifying upload functionality so that the upload component is now rendered in a modal window
The upload dialog/modal window is rendered on the edit page when you click the 'Upload New' link.
Once you upload the file, the modal window closes, the contents of the file in text area are
replaced with the contents of the uploaded file, and the file will be marked as being modified
in the file menu.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 9b9767b..2b8bdc9 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -291,8 +291,6 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
LookupUtil.getConfigurationManager().updateResourceConfiguration(subject, getResourceId(),
getMergedConfiguration());
- nullify();
-
return "/rhq/resource/configuration/view.xhtml?id=" + getResourceId();
}
@@ -308,36 +306,21 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return getConfiguration();
}
- public void undoEdit() {
-
+ public String editCurrent() {
+ String changedContents = getCurrentContents();
+ return null;
}
- public String discard() {
- nullify();
- return "/rhq/resource/configuration/view.xhtml?id=" + getResourceId();
- }
+ public void undoEdit(String path) {
+ modified.remove(path);
+ RawConfigUIBean bean = findRawConfigUIBeanByPath(path);
- public void fileUploadListener(UploadEvent event) throws Exception {
- File uploadFile;
- log.error("fileUploadListener called");
- uploadFile = event.getUploadItem().getFile();
- if (uploadFile != null) {
- log.debug("fileUploadListener got file named " + event.getUploadItem().getFileName());
- log.debug("content type is " + event.getUploadItem().getContentType());
- if (uploadFile != null) {
- try {
- FileReader fileReader = new FileReader(uploadFile);
- char[] buff = new char[1024];
- StringBuffer stringBuffer = new StringBuffer();
- for (int count = fileReader.read(buff); count != -1; count = fileReader.read(buff)) {
- stringBuffer.append(buff, 0, count);
- }
- setCurrentContents(stringBuffer.toString());
- } catch (IOException e) {
- log.error("problem reading uploaded file", e);
- }
- }
+ if (bean != null) {
+ bean.setModified(false);
+ bean.setIcon("/images/blank.png");
}
+
+
}
public int getConfigId() {
@@ -363,23 +346,7 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public String getCurrentContents() {
- try {
- if (fileUploader.getFileItem() != null) {
- UploadItem fileItem = fileUploader.getFileItem();
- if (fileItem.isTempFile()) {
- setCurrentContents(FileUtils.readFileToString(fileItem.getFile()));
- }
- else {
- setCurrentContents(new String(fileItem.getData()));
- }
- fileUploader.clear();
- }
-
- return new String(getCurrent().getContents());
- }
- catch (IOException e) {
- throw new RuntimeException(e);
- }
+ return new String(getCurrent().getContents());
}
public String getCurrentPath() {
@@ -470,10 +437,6 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return isRawSupported() || (isStructuredAndRawSupported() && isRawMode());
}
- void nullify() {
-
- }
-
/**
* Indicates which of the raw configuration files is currently selected.
* @param s
@@ -497,14 +460,21 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
private void markCurrentRawConfigUIBeanModified() {
+ RawConfigUIBean bean = findRawConfigUIBeanByPath(current.getPath());
+ if (bean != null) {
+ bean.setModified(true);
+ }
+ }
+
+ private RawConfigUIBean findRawConfigUIBeanByPath(String path) {
for (RawConfigDirectory dir : rawConfigDirectories) {
for (RawConfigUIBean bean : dir.getRawConfigUIBeans()) {
if (bean.getPath().equals(current.getPath())) {
- bean.setModified(true);
- return;
+ return bean;
}
}
}
+ return null;
}
public void setCurrentPath(String path) {
@@ -549,7 +519,23 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public String completeUpload() {
- return null;
+ try {
+ if (fileUploader.getFileItem() != null) {
+ UploadItem fileItem = fileUploader.getFileItem();
+ if (fileItem.isTempFile()) {
+ setCurrentContents(FileUtils.readFileToString(fileItem.getFile()));
+ }
+ else {
+ setCurrentContents(new String(fileItem.getData()));
+ }
+ fileUploader.clear();
+ }
+
+ return null;
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
void dumpProperties(Configuration conf, Log log) {
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
index 0514f32..85f9617 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
@@ -26,6 +26,7 @@ package org.rhq.enterprise.gui.configuration.resource;
import org.rhq.core.domain.configuration.RawConfiguration;
import org.richfaces.component.html.HtmlPanelMenuItem;
+import javax.faces.component.NamingContainer;
import java.io.File;
public class RawConfigUIBean {
@@ -75,6 +76,10 @@ public class RawConfigUIBean {
return rawConfiguration.getPath();
}
+ public String getPathAsId() {
+ return rawConfiguration.getPath().replace('/', NamingContainer.SEPARATOR_CHAR);
+ }
+
public String getFileName() {
File file = new File(rawConfiguration.getPath());
return file.getName();
@@ -87,4 +92,8 @@ public class RawConfigUIBean {
return "/images/blank.png";
}
+
+ public void setIcon(String icon) {
+ panelMenuItem.setIcon(icon);
+ }
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index b2fc562..17f968f 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -221,8 +221,7 @@ THIS TEXT WILL BE REMOVED.
expanded="true"
selectedChild="#{ExistingResourceConfigurationUIBean.currentPath}">
<c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
- <rich:panelMenuItem id="menuItem_#{rawConfigUIBean.rawConfiguration.sha256}"
- label="#{rawConfigUIBean.fileName}"
+ <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
icon="#{rawConfigUIBean.icon}"
binding="#{rawConfigUIBean.panelMenuItem}"
onclick="cursor_wait();"
@@ -233,7 +232,13 @@ THIS TEXT WILL BE REMOVED.
<h:panelGroup>
<h:outputText value="#{#rawConfigUIBean.fileName}"/>
<c:if test="#{rawConfigUIBean.modified}">
- <h:commandButton value="Undo" styleClass="buttonmed"/>
+ <h:commandButton value="Undo" styleClass="buttonmed">
+ <a4j:support event="onclick"
+ onsumbit="cursor_wait()"
+ oncomplete="cursor_clear()"
+ action="#{ExistingResourceConfigurationUIBean.undoEdit(rawConfigUIBean.path)}"
+ reRender="fileMenu"/>
+ </h:commandButton>
</c:if>
</h:panelGroup>
</rich:panelMenuItem>
@@ -255,20 +260,29 @@ THIS TEXT WILL BE REMOVED.
stopText="#{ExistingResourceConfigurationUIBean.current.path}"/>
<a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
+ <a href="#" onclick="#{rich:component('uploadWindow')}.show()">Upload New</a>
+ <ui:remove>
<h:commandLink value="Upload New">
<h:graphicImage value="/images/upload.png"/>
</h:commandLink>
+ </ui:remove>
+
<h:commandLink action="#{ExistingResourceConfigurationUIBean.download}" value="Download">
<h:graphicImage value="/images/download.png"/>
<f:param name="id" value="#{ResourceUIBean.id}"/>
</h:commandLink>
</h:panelGrid>
- <rich:panel style="margin-left:1px; border: none;">
+ <rich:panel id="fileContentsPanel" style="margin-left:1px; border: none;">
<h:inputTextarea id="fileContents"
style="width:100%"
value="#{ExistingResourceConfigurationUIBean.currentContents}"
- readonly="false"/>
+ readonly="false">
+ <a4j:support event="onchange"
+ reRender="fileMenu"
+ requestDelay="1000"
+ action="#{ExistingResourceConfigurationUIBean.editCurrent}"/>
+ </h:inputTextarea>
</rich:panel>
</h:panelGrid>
</h:panelGrid>
@@ -286,41 +300,13 @@ THIS TEXT WILL BE REMOVED.
</rich:tab>
</rich:tabPanel>
+ <ui:include src="upload-modal.xhtml"/>
<ui:include src="view-raw-modal.xhtml"/>
</c:when>
</c:choose>
</h:form>
- <!--
- Here I tried the file upload in a separate form. It has resulted in javascript errors. The latest error in the
- firefox error console is,
-
- Error: form.dispatchEvent is not a function
- Source File: http://localhost:7080/a4j/g/3_3_2.SR1org/ajax4jsf/javascript/scripts/form...
- Line: 6
- -->
- <h:form id="uploadForm" enctype="multipart/form-data">
- <rich:panel id="uploadPanel" rendered="#{ExistingResourceConfigurationUIBean.fileUploadAvailable}">
-
- <input type="hidden" name="currentResourceId" value="#{ResourceUIBean.id}"/>
-
- <rich:fileUpload id="fileUpload"
- listHeight="50px"
- fileUploadListener="#{fileUploader.fileUploadListener}"
- addControlLabel="Browse"
- immediateUpload="false"
- allowFlash="auto">
- <f:facet name="label">
- <h:outputText value="{_KB}KB from {KB}KB uploaded --- {mm}:{ss}" />
- </f:facet>
- <a4j:support event="onuploadcomplete"
- reRender="fileUpload,fileContents,menuItem_#{ExistingResourceConfigurationUIBean.current.sha256}"/>
- </rich:fileUpload>
-
- </rich:panel>
- </h:form>
-
<h:panelGroup layout="block" styleClass="InfoBlock"
rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}">
<b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/upload-modal.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/upload-modal.xhtml
new file mode 100644
index 0000000..b5a356c
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/upload-modal.xhtml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich">
+
+ <f:subview id="uploadSubview" rendered="#{ExistingResourceConfigurationUIBean.fileUploadAvailable}">
+
+ <script type="text/javascript">
+ function prepareFormForUpload() {
+ var form = document.getElementById('editResourceConfigurationForm');
+ form.encoding = 'multipart/form-data';
+ }
+ </script>
+
+ <rich:modalPanel id="uploadWindow" width="800" height="400">
+ <f:facet name="header">
+ <h:panelGroup>
+ <h:outputText value="#{ExistingResourceConfigurationUIBean.current.path}"/>
+ </h:panelGroup>
+ </f:facet>
+ <f:facet name="controls">
+ <h:panelGroup>
+ <h:graphicImage value="/images/close.png" styleClass="hidelink" id="hidelink"/>
+ <rich:componentControl for="uploadWindow" attachTo="hidelink" operation="hide" event="onclick"/>
+ </h:panelGroup>
+ </f:facet>
+
+
+ <rich:panel id="uploadPanel" rendered="#{ExistingResourceConfigurationUIBean.fileUploadAvailable}">
+
+ <input type="hidden" name="currentResourceId" value="#{ResourceUIBean.id}"/>
+
+ <rich:fileUpload id="fileUpload"
+ listHeight="50px"
+ fileUploadListener="#{fileUploader.fileUploadListener}"
+ addControlLabel="Browse"
+ immediateUpload="false"
+ allowFlash="auto">
+ <f:facet name="label">
+ <h:outputText value="{_KB}KB from {KB}KB uploaded --- {mm}:{ss}"/>
+ </f:facet>
+ <a4j:support event="onuploadcomplete"
+ action="#{ExistingResourceConfigurationUIBean.completeUpload}"
+ reRender="fileUpload,fileContents,fileMenu"
+ onsubmit="#{rich:component('uploadWindow')}.hide()"/>
+ </rich:fileUpload>
+
+ </rich:panel>
+ </rich:modalPanel>
+ </f:subview>
+
+</ui:composition>
\ No newline at end of file
commit 4f9777a0ea1cc20a7546fdafc3d05c19dcbd928f
Author: Adam Young <ayoung(a)redhat.com>
Date: Thu Jan 21 12:16:04 2010 -0500
added a simple template engine and test for it.
diff --git a/modules/core/util/src/main/java/org/rhq/core/template/TemplateEngine.java b/modules/core/util/src/main/java/org/rhq/core/template/TemplateEngine.java
new file mode 100644
index 0000000..eef1b8e
--- /dev/null
+++ b/modules/core/util/src/main/java/org/rhq/core/template/TemplateEngine.java
@@ -0,0 +1,24 @@
+package org.rhq.core.template;
+
+import java.util.Map;
+
+public class TemplateEngine {
+ public final Map<String, String> tokens;
+
+ public TemplateEngine(Map<String, String> tokens) {
+ super();
+ this.tokens = tokens;
+ }
+
+ public String replaceTokens(String input){
+
+ for (String token : tokens.keySet()) {
+ //Since . is a special regex character,
+ //replace it with \. before building the larger regex
+ String regex = "<%\\s*" + token.replaceAll("\\.", "\\\\.") + "\\s*%>";
+ input = input.replaceAll(regex, tokens.get(token) );
+ }
+
+ return input;
+ }
+}
diff --git a/modules/core/util/src/test/java/org/rhq/core/template/TemplateEngineTest.java b/modules/core/util/src/test/java/org/rhq/core/template/TemplateEngineTest.java
new file mode 100644
index 0000000..61af996
--- /dev/null
+++ b/modules/core/util/src/test/java/org/rhq/core/template/TemplateEngineTest.java
@@ -0,0 +1,62 @@
+package org.rhq.core.template;
+
+import java.util.TreeMap;
+
+import org.testng.annotations.Test;
+
+import junit.framework.TestCase;
+
+@Test
+public class TemplateEngineTest extends TestCase {
+ private static final String IPADDR = "192.168.22.153";
+ private static final String SUCCESSTOKEN1 = "successtoken1";
+ String noTokens = "This string should come through unchanged";
+ String justOneToken = "<%rhq.token1%>";
+ String oneTokenWhiteSpace = "<% rhq.token1 %>";
+ String multipleLogTokens = "This string has <%rhq.token1%>\n" + "<% rhq.unsettoken %>\n" + "<% nmsqt.token1 %>"
+ + "It also has <%rhq.platform.ethers.eth1.ipaddress %>";
+ String sameTokenTwice = "<%rhq.token1%><%rhq.token1%>";
+
+ TemplateEngine templateEngine;
+ TreeMap<String, String> tokens;
+
+ TreeMap<String, String> getTokens() {
+ if (null == tokens) {
+ tokens = new TreeMap<String, String>();
+ tokens.put("rhq.token1", SUCCESSTOKEN1);
+ tokens.put("rhq.platform.ethers.eth1.ipaddress", IPADDR);
+ }
+ return tokens;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ templateEngine = new TemplateEngine(getTokens());
+ }
+
+ public void testNoTokens() {
+ assertEquals(noTokens, templateEngine.replaceTokens(noTokens));
+ }
+
+ public void testOneToken() {
+ assertEquals(SUCCESSTOKEN1, templateEngine.replaceTokens(justOneToken));
+ }
+
+ public void testOneTokenWhiteSpace() {
+ assertEquals(SUCCESSTOKEN1, templateEngine.replaceTokens(oneTokenWhiteSpace));
+ }
+
+ public void testLongString() {
+ assertTrue(templateEngine.replaceTokens(multipleLogTokens).indexOf(SUCCESSTOKEN1) > 0);
+ assertTrue(templateEngine.replaceTokens(multipleLogTokens).indexOf(IPADDR) > 0);
+ }
+
+ public void testIgnore() {
+ assertTrue(templateEngine.replaceTokens(multipleLogTokens).indexOf("<% rhq.unsettoken %>") > 0);
+ assertTrue(templateEngine.replaceTokens(multipleLogTokens).indexOf("<% nmsqt.token1 %>") > 0);
+ }
+
+ public void testSameTokenTwice() {
+ assertEquals(SUCCESSTOKEN1 + SUCCESSTOKEN1, templateEngine.replaceTokens(sameTokenTwice));
+ }
+}
commit 5e857f7cc6053d8bbc0fd7e7519b06c69038da77
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Jan 20 13:46:52 2010 -0500
Adding logic to display status/progress bar of file upload
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index ec839a9..b2fc562 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -309,7 +309,11 @@ THIS TEXT WILL BE REMOVED.
listHeight="50px"
fileUploadListener="#{fileUploader.fileUploadListener}"
addControlLabel="Browse"
- immediateUpload="false">
+ immediateUpload="false"
+ allowFlash="auto">
+ <f:facet name="label">
+ <h:outputText value="{_KB}KB from {KB}KB uploaded --- {mm}:{ss}" />
+ </f:facet>
<a4j:support event="onuploadcomplete"
reRender="fileUpload,fileContents,menuItem_#{ExistingResourceConfigurationUIBean.current.sha256}"/>
</rich:fileUpload>
commit 931c34fe16b52a49bdeaf09dc84fdffd8e404461
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Jan 20 13:36:53 2010 -0500
Adding file upload to list of components to rerender after an upload has completed.
Without rerendered, you are unable to upload another file again since we are only allowing
a single file to be uploaded at a time.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index bf0ac96..ec839a9 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -311,7 +311,7 @@ THIS TEXT WILL BE REMOVED.
addControlLabel="Browse"
immediateUpload="false">
<a4j:support event="onuploadcomplete"
- reRender="fileContents,menuItem_#{ExistingResourceConfigurationUIBean.current.sha256}"/>
+ reRender="fileUpload,fileContents,menuItem_#{ExistingResourceConfigurationUIBean.current.sha256}"/>
</rich:fileUpload>
</rich:panel>
commit 5e0fbcc30ff8c6e6a382043c2b0de99afbe147cb
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Jan 20 13:11:50 2010 -0500
Fixing navigation rules so that you are redirected to the history page after making a config update.
Being redirected to the history page is actually the current behavior that I changed some where
along the way in a recent commit.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index e53d8a2..9b9767b 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -18,30 +18,12 @@
*/
package org.rhq.enterprise.gui.configuration.resource;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.event.ValueChangeEvent;
-import javax.servlet.http.HttpServletResponse;
-
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.Out;
import org.jetbrains.annotations.Nullable;
-import org.richfaces.event.UploadEvent;
-
-import org.jboss.seam.annotations.Create;
-
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.AbstractResourceConfigurationUpdate;
import org.rhq.core.domain.configuration.Configuration;
@@ -49,15 +31,30 @@ import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.RawConfiguration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.ConfigurationFormat;
-import org.rhq.enterprise.gui.common.upload.FileUploadUIBean;
import org.rhq.core.gui.configuration.ConfigurationMaskingUtility;
import org.rhq.core.gui.util.FacesContextUtility;
+import org.rhq.enterprise.gui.common.upload.FileUploadUIBean;
import org.rhq.enterprise.gui.configuration.AbstractConfigurationUIBean;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.server.configuration.ConfigurationManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
+import org.richfaces.event.UploadEvent;
import org.richfaces.model.UploadItem;
+import javax.faces.application.FacesMessage;
+import javax.faces.event.ValueChangeEvent;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
// This class is temporarily decleared in components.xml since it is declared under two names - ViewUIBean and
// UIBean. This class is undergoing some refactoring and part of that will include declaring the @Name and @Scope
// annotations again.
@@ -583,11 +580,10 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return raws;
}
- /**
- *
- */
String selectedPath;
+
private TreeMap<String, RawConfiguration> raws;
+
TreeMap<String, RawConfiguration> modified = new TreeMap<String, RawConfiguration>();
RawConfiguration current = null;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
index ff9c2de..0514f32 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
@@ -68,7 +68,7 @@ public class RawConfigUIBean {
public void setModified(boolean modified) {
this.modified = modified;
- panelMenuItem.setIcon(getIcon());
+// panelMenuItem.setIcon(getIcon());
}
public String getPath() {
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml
index 1ed069c..85def73 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml
@@ -4,28 +4,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
- <!--<navigation-rule>-->
- <!--<from-view-id>/rhq/resource/configuration/view.xhtml</from-view-id>-->
-
- <!--<navigation-case>-->
- <!--<from-action>#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}</from-action>-->
- <!--<from-outcome>success</from-outcome>-->
- <!--<to-view-id>/rhq/resource/configuration/edit.xhtml</to-view-id>-->
- <!--</navigation-case>-->
-
- <!--<navigation-case>-->
- <!--<from-action>#{ExistingResourceConfigurationUIBean.switchToraw}</from-action>-->
- <!--<to-view-id>/rhq/resource/configuration/view.xhtml</to-view-id>-->
- <!--</navigation-case>-->
- <!--</navigation-rule>-->
-
- <!--<navigation-rule>-->
- <!--<navigation-case>-->
- <!--<from-action>#{ExistingResourceConfigurationUIBean.editRawConfiguration}</from-action>-->
- <!--<to-view-id>/rhq/resource/configuration/edit.xhtml</to-view-id>-->
- <!--</navigation-case>-->
- <!--</navigation-rule>-->
-
<navigation-rule>
<navigation-case>
<from-action>#{ExistingResourceConfigurationUIBean.editConfiguration}</from-action>
@@ -43,49 +21,21 @@
<from-action>#{ConfigHelperUIBean.accessMap}</from-action>
<to-view-id>/rhq/resource/configuration/view-map.xhtml</to-view-id>
</navigation-case>
-
- <!--<navigation-case>-->
- <!--<from-action>#{ExistingResourceConfigurationViewUIBean.switchToStructured}</from-action>-->
- <!--<to-view-id>/rhq/resource/configuration/view.xhtml</to-view-id>-->
- <!--<redirect/>-->
- <!--</navigation-case>-->
-
- <!--<navigation-case>-->
- <!--<from-action>#{ExistingResourceConfigurationViewUIBean.switchToRaw}</from-action>-->
- <!--<to-view-id>/rhq/resource/configuration/view.xhtml</to-view-id>-->
- <!--<!–<redirect/>–>-->
- <!--</navigation-case>-->
-
</navigation-rule>
<navigation-rule>
- <from-view-id>/rhq/resource/configuration/edit-raw-full.xhtml</from-view-id>
- <navigation-case>
- <from-action>#{RawConfigCollection.update}</from-action>
- <to-view-id>/rhq/resource/configuration/edit-raw.xhtml?id=#{param.id}</to-view-id>
- </navigation-case>
- </navigation-rule>
-
- <navigation-rule>
- <from-view-id>/rhq/resource/configuration/edit-raw.xhtml</from-view-id>
-
- <navigation-case>
- <from-action>#{ExistingResourceConfigurationUIBean.updateRawConfiguration}</from-action>
+ <from-view-id>/rhq/resource/configuration/edit.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-action>#{ExistingResourceConfigurationUIBean.updateConfiguration}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/rhq/resource/configuration/history.xhtml?id=#{param.id}</to-view-id>
<redirect/>
</navigation-case>
-
- </navigation-rule>
-
- <navigation-rule>
-
- <from-view-id>/rhq/resource/configuration/edit.xhtml</from-view-id>
-
- <navigation-case>
- <from-action>#{ExistingResourceConfigurationUIBean.updateConfiguration}</from-action>
+ <navigation-case>
+ <from-action>#{ExistingResourceConfigurationUIBean.updateRawConfiguration}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/rhq/resource/configuration/history.xhtml?id=#{param.id}</to-view-id>
<redirect/>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index b6a7a26..bf0ac96 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -43,7 +43,7 @@ THIS TEXT WILL BE REMOVED.
onsubmit="prepareInputsForSubmission(this)"
rendered="#{!ViewResourceConfigurationUIBean.updateInProgress}">
- <input type="hidden" name="currentResourceId" value="#{ResourceUIBean.id}"/>
+ <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
<h:panelGrid columns="2" style="width:100%">
<h:outputText value="#{ResourceUIBean.name}"/>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 41648bf..2e3864e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -194,18 +194,6 @@ THIS TEXT WILL BE REMOVED.
rendered="#{!ResourceUIBean.permissions.configure}"/>
<h:panelGrid columns="2"
- styleClass="buttons-table"
- columnClasses="button-cell"
- rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
-
- <h:commandButton id="editRawButton"
- value="Edit"
- action="#{ExistingResourceConfigurationUIBean.editRawConfiguration}"
- title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
- </h:panelGrid>
-
- <h:panelGrid columns="2"
styleClass="raw-outer-table"
columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
<rich:panel style="width:100%">
commit 0f028b0b9be6bd58d205b39eea5d80d2f506ebdc
Author: Adam Young <ayoung(a)redhat.com>
Date: Wed Jan 20 10:21:52 2010 -0500
removed @Override annotation incorrectly added to interface implmentations
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
index c01828b..55d5751 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
@@ -330,7 +330,7 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
return null;
}
- @Override
+
public SyncProgressWeight getSyncProgressWeight() {
return SyncProgressWeight.DEFAULT_WEIGHTS;
}
diff --git a/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java b/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
index 8c3f163..1b46cfb 100644
--- a/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
+++ b/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
@@ -353,7 +353,7 @@ public class DiskSource implements ContentProvider, PackageSource, RepoSource {
public String resourceTypePluginName;
}
- @Override
+
public SyncProgressWeight getSyncProgressWeight() {
return new SyncProgressWeight(10, 1, 0, 0, 0);
}
diff --git a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
index c65a1b0..ed9d4ee 100644
--- a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
+++ b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
@@ -244,7 +244,7 @@ public class JBossSoftwareContentSourceAdapter implements ContentProvider, Packa
}
}
- @Override
+
public SyncProgressWeight getSyncProgressWeight() {
return SyncProgressWeight.DEFAULT_WEIGHTS;
}
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
index 9a6e9c0..38d54c2 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
@@ -357,7 +357,7 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
return helper.constructKickstartFileUrl(repoName, label, relativeFilename);
}
- @Override
+
public SyncProgressWeight getSyncProgressWeight() {
return new SyncProgressWeight(10, 1, 0, 0, 1);
}
diff --git a/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java b/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java
index 061f860..4cb6de9 100644
--- a/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java
+++ b/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java
@@ -393,7 +393,7 @@ public class UrlProvider implements ContentProvider, PackageSource {
return null; // the file doesn't match any known types for this content source
}
- @Override
+
public SyncProgressWeight getSyncProgressWeight() {
return SyncProgressWeight.DEFAULT_WEIGHTS;
}
diff --git a/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java b/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
index f45c0a4..fadb218 100644
--- a/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
+++ b/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
@@ -191,7 +191,6 @@ public class RepoProvider implements ContentProvider, PackageSource {
return path;
}
- @Override
public SyncProgressWeight getSyncProgressWeight() {
return SyncProgressWeight.DEFAULT_WEIGHTS;
}
commit db6156b14aa1dfe107ee866baeb51ad80396bd8b
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Jan 20 08:21:17 2010 -0500
Making edit button on view.xhtml consistent with placement of commit button on edit.xhtml
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 6539aae..41648bf 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -45,8 +45,16 @@ THIS TEXT WILL BE REMOVED.
<h:form id="viewResourceConfigurationForm">
<input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
- <h:panelGrid columns="2">
+ <h:panelGrid columns="2" style="width:100%">
<h:outputText value="#{ResourceUIBean.name}"/>
+ <h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
+ <h:panelGroup style="text-align:right">
+ <h:commandButton value="Edit"
+ action="#{ExistingResourceConfigurationUIBean.editRawConfiguration}"
+ title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
+ </h:panelGroup>
+ </h:panelGrid>
</h:panelGrid>
<c:choose>
@@ -58,17 +66,6 @@ THIS TEXT WILL BE REMOVED.
rendered="#{!ResourceUIBean.permissions.configure}"/>
<h:panelGrid columns="2"
- styleClass="buttons-table"
- columnClasses="button-cell"
- rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
-
- <h:commandButton value="Edit"
- action="#{ExistingResourceConfigurationUIBean.editRawConfiguration}"
- title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
- </h:panelGrid>
-
- <h:panelGrid columns="2"
styleClass="raw-outer-table"
columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
<rich:panel style="width:100%">
@@ -120,6 +117,15 @@ THIS TEXT WILL BE REMOVED.
</rich:panel>
</h:panelGrid>
</h:panelGrid>
+
+ <h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
+ <h:panelGroup style="text-align:right">
+ <h:commandButton value="Edit"
+ action="#{ExistingResourceConfigurationUIBean.editRawConfiguration}"
+ title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
+ </h:panelGroup>
+ </h:panelGrid>
</rich:tab>
</rich:tabPanel>
<ui:include src="view-raw-modal.xhtml"/>
@@ -131,18 +137,6 @@ THIS TEXT WILL BE REMOVED.
<h:outputText value=" #{messages.nopermissionedit}"
rendered="#{!ResourceUIBean.permissions.configure}"/>
- <h:panelGrid columns="2"
- styleClass="buttons-table"
- columnClasses="button-cell"
- rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
-
- <h:commandButton value="Edit"
- action="#{ExistingResourceConfigurationUIBean.editConfiguration}"
- title="Edit this Configuration"
- styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
- </h:panelGrid>
-
<onc:config
configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}"
configuration="#{ExistingResourceConfigurationViewUIBean.configuration}"
@@ -151,6 +145,15 @@ THIS TEXT WILL BE REMOVED.
nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}"
nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}"
prevalidate="true"/>
+
+ <h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
+ <h:panelGroup style="text-align:right">
+ <h:commandButton value="Edit"
+ action="#{ExistingResourceConfigurationUIBean.editConfiguration}"
+ title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
+ </h:panelGroup>
+ </h:panelGrid>
</rich:tab>
</rich:tabPanel>
</c:when>
@@ -164,16 +167,6 @@ THIS TEXT WILL BE REMOVED.
<h:outputText value=" #{messages.nopermissionedit}"
rendered="#{!ResourceUIBean.permissions.configure}"/>
- <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell"
- rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
-
- <h:commandButton id="editStructuredButton"
- value="Edit"
- action="#{ExistingResourceConfigurationUIBean.editConfiguration}"
- title="Edit this Configuration" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
- </h:panelGrid>
-
<onc:config
configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}"
configuration="#{ExistingResourceConfigurationViewUIBean.configuration}"
@@ -183,7 +176,16 @@ THIS TEXT WILL BE REMOVED.
nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}"
prevalidate="true"/>
+ <h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
+ <h:panelGroup style="text-align:right">
+ <h:commandButton value="Edit"
+ action="#{ExistingResourceConfigurationUIBean.editConfiguration}"
+ title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
+ </h:panelGroup>
+ </h:panelGrid>
</rich:tab>
+
<rich:tab id="rawTab"
label="Advanced Mode"
onlabelclick="cursor_wait();"
@@ -255,6 +257,15 @@ THIS TEXT WILL BE REMOVED.
</rich:panel>
</h:panelGrid>
</h:panelGrid>
+
+ <h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
+ <h:panelGroup style="text-align:right">
+ <h:commandButton value="Edit"
+ action="#{ExistingResourceConfigurationUIBean.editRawConfiguration}"
+ title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
+ </h:panelGroup>
+ </h:panelGrid>
</rich:tab>
</rich:tabPanel>
<ui:include src="view-raw-modal.xhtml"/>
commit 31c9810072508710b3ea66dc30c5970f0c53ad7e
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Jan 20 02:04:35 2010 -0500
Adding support in file upload to rerender the current file with the uploaded contents.
With this commit I have also attempted to update the file menu, showing the current fle as
modified; The file menu item is getting rendered again, but the icon is not showing up.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 23460e6..e53d8a2 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -21,31 +21,23 @@ package org.rhq.enterprise.gui.configuration.resource;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
import javax.faces.event.ValueChangeEvent;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
-import org.jboss.seam.annotations.Scope;
import org.jetbrains.annotations.Nullable;
-import org.richfaces.component.UISwitchablePanel;
-import org.richfaces.component.UITabPanel;
import org.richfaces.event.UploadEvent;
import org.jboss.seam.annotations.Create;
@@ -64,6 +56,7 @@ import org.rhq.enterprise.gui.configuration.AbstractConfigurationUIBean;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.server.configuration.ConfigurationManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
+import org.richfaces.model.UploadItem;
// This class is temporarily decleared in components.xml since it is declared under two names - ViewUIBean and
// UIBean. This class is undergoing some refactoring and part of that will include declaring the @Name and @Scope
@@ -373,7 +366,23 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public String getCurrentContents() {
- return new String(getCurrent().getContents());
+ try {
+ if (fileUploader.getFileItem() != null) {
+ UploadItem fileItem = fileUploader.getFileItem();
+ if (fileItem.isTempFile()) {
+ setCurrentContents(FileUtils.readFileToString(fileItem.getFile()));
+ }
+ else {
+ setCurrentContents(new String(fileItem.getData()));
+ }
+ fileUploader.clear();
+ }
+
+ return new String(getCurrent().getContents());
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
public String getCurrentPath() {
@@ -388,7 +397,6 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
if (modalEditorContents == null) {
modalEditorContents = getCurrentContents();
}
-// return getCurrentContents();
return modalEditorContents;
}
@@ -427,8 +435,8 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
/**
*
* @return the id associated with the resource.
- * The value Cached in order to be available on the upload page,
- * where seeing the resource id conflicts with the rich upload tag.
+ * The value Cached in order to be available on the completeUpload page,
+ * where seeing the resource id conflicts with the rich completeUpload tag.
*/
public int getResourceId() {
if (resourceId == null) {
@@ -481,7 +489,6 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public void setCurrentContents(String updated) {
-
String original = new String(getCurrent().getContents());
if (!updated.equals(original)) {
current = current.deepCopy(false);
@@ -537,14 +544,14 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
/**
- * This is a no-op, since the upload work was done by upload file
+ * This is a no-op, since the completeUpload work was done by completeUpload file
* But is kept as a target for the "save" icon from the full screen page
*/
public String update() {
return "/rhq/resource/configuration/edit-raw.xhtml?currentResourceId=" + getResourceId();
}
- public String upload() {
+ public String completeUpload() {
return null;
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
index 588c967..ff9c2de 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
@@ -24,6 +24,7 @@
package org.rhq.enterprise.gui.configuration.resource;
import org.rhq.core.domain.configuration.RawConfiguration;
+import org.richfaces.component.html.HtmlPanelMenuItem;
import java.io.File;
@@ -35,6 +36,8 @@ public class RawConfigUIBean {
private String modifiedContents;
+ private HtmlPanelMenuItem panelMenuItem;
+
public RawConfiguration getRawConfiguration() {
return rawConfiguration;
}
@@ -43,6 +46,14 @@ public class RawConfigUIBean {
this.rawConfiguration = rawConfiguration;
}
+ public HtmlPanelMenuItem getPanelMenuItem() {
+ return panelMenuItem;
+ }
+
+ public void setPanelMenuItem(HtmlPanelMenuItem panelMenuItem) {
+ this.panelMenuItem = panelMenuItem;
+ }
+
public String getModifiedContents() {
return modifiedContents;
}
@@ -57,6 +68,7 @@ public class RawConfigUIBean {
public void setModified(boolean modified) {
this.modified = modified;
+ panelMenuItem.setIcon(getIcon());
}
public String getPath() {
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
index c2825ba..d9e4078 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
@@ -209,7 +209,7 @@
<param-value>false</param-value>
</context-param>
- <!-- Allows upload of files through JSF (i.e. software uploads) -->
+ <!-- Allows completeUpload of files through JSF (i.e. software uploads) -->
<filter>
<filter-name>MultipartFilter</filter-name>
<filter-class>org.rhq.enterprise.gui.common.upload.MultipartFilter</filter-class>
@@ -234,7 +234,7 @@
<param-value>true</param-value>
</init-param>
<init-param>
- <!-- is 250MB the largest package we'll ever want to upload? -->
+ <!-- is 250MB the largest package we'll ever want to completeUpload? -->
<param-name>maxRequestSize</param-name>
<param-value>250000000</param-value>
</init-param>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 3515bf9..b6a7a26 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -206,7 +206,7 @@ THIS TEXT WILL BE REMOVED.
styleClass="raw-outer-table"
columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
<h:panelGrid columns="1">
- <rich:panel style="width:100%">
+ <rich:panel id="fileMenuPanel" style="width:100%">
<f:facet name="header">Files</f:facet>
@@ -221,8 +221,10 @@ THIS TEXT WILL BE REMOVED.
expanded="true"
selectedChild="#{ExistingResourceConfigurationUIBean.currentPath}">
<c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
- <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
+ <rich:panelMenuItem id="menuItem_#{rawConfigUIBean.rawConfiguration.sha256}"
+ label="#{rawConfigUIBean.fileName}"
icon="#{rawConfigUIBean.icon}"
+ binding="#{rawConfigUIBean.panelMenuItem}"
onclick="cursor_wait();"
oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
@@ -268,23 +270,6 @@ THIS TEXT WILL BE REMOVED.
value="#{ExistingResourceConfigurationUIBean.currentContents}"
readonly="false"/>
</rich:panel>
- <ui:remove>
- <!--
- Here I tried the file upload in the existing form. It does not generate any errors in the firefox
- error console, but the upload is not working.
- -->
- <rich:fileUpload id="fileUpload"
- fileUploadListener="#{ExistingResourceConfigurationUIBean.fileUploadListener}"
- maxFilesQuantity="1"
- noDuplicate="true"
- immediateUpload="true"
- autoclear="false"
- allowFlash="false"
- maxRequestSize="100000">
- <a4j:support event="onuploadcomplete"
- reRender="fileMenu,fileContents"/>
- </rich:fileUpload>
- </ui:remove>
</h:panelGrid>
</h:panelGrid>
@@ -324,8 +309,9 @@ THIS TEXT WILL BE REMOVED.
listHeight="50px"
fileUploadListener="#{fileUploader.fileUploadListener}"
addControlLabel="Browse"
- immediateUpload="true">
- <a4j:support event="onuploadcomplete" reRender="fileMenu,fileContents"/>
+ immediateUpload="false">
+ <a4j:support event="onuploadcomplete"
+ reRender="fileContents,menuItem_#{ExistingResourceConfigurationUIBean.current.sha256}"/>
</rich:fileUpload>
</rich:panel>
commit 6abdbe720a94b052b31b2ba19e046ca62fd5b5ac
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Jan 20 00:49:25 2010 -0500
Adding logic to display file upload panel only when on a raw edit page
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 852897a..23460e6 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -32,6 +32,7 @@ import java.util.Map;
import java.util.TreeMap;
import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
import javax.faces.event.ValueChangeEvent;
import javax.servlet.http.HttpServletResponse;
@@ -43,6 +44,8 @@ import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jetbrains.annotations.Nullable;
+import org.richfaces.component.UISwitchablePanel;
+import org.richfaces.component.UITabPanel;
import org.richfaces.event.UploadEvent;
import org.jboss.seam.annotations.Create;
@@ -417,7 +420,7 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public Object[] getPaths() {
-
+
return getRaws().keySet().toArray();
}
@@ -458,6 +461,10 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return getConfigurationDefinition().getConfigurationFormat() == ConfigurationFormat.STRUCTURED_AND_RAW;
}
+ public boolean isFileUploadAvailable() {
+ return isRawSupported() || (isStructuredAndRawSupported() && isRawMode());
+ }
+
void nullify() {
}
@@ -538,7 +545,6 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public String upload() {
-// return "/rhq/resource/configuration/edit-raw.xhtml?currentResourceId=" + getResourceId();
return null;
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 047bf7f..3515bf9 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -170,7 +170,11 @@ THIS TEXT WILL BE REMOVED.
selectedTab="#{ExistingResourceConfigurationUIBean.selectedTab}"
switchType="ajax"
valueChangeListener="#{ExistingResourceConfigurationUIBean.changeTabs}">
- <rich:tab id="structuredTab" label="Basic Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
+ <rich:tab id="structuredTab"
+ label="Basic Mode"
+ reRender="uploadForm"
+ onlabelclick="cursor_wait();"
+ oncomplete="cursor_clear();">
<onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}"
configuration="#{ExistingResourceConfigurationUIBean.configuration}"
nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}"
@@ -193,7 +197,11 @@ THIS TEXT WILL BE REMOVED.
styleClass="buttonmed"/>
</h:panelGrid>
</rich:tab>
- <rich:tab id="rawTab" label="Advanced Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
+ <rich:tab id="rawTab"
+ label="Advanced Mode"
+ reRender="uploadForm"
+ onlabelclick="cursor_wait();"
+ oncomplete="cursor_clear();">
<h:panelGrid columns="2"
styleClass="raw-outer-table"
columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
@@ -274,8 +282,7 @@ THIS TEXT WILL BE REMOVED.
allowFlash="false"
maxRequestSize="100000">
<a4j:support event="onuploadcomplete"
- reRender="fileContents"
- action="#{ExistingResourceConfigurationUIBean.upload}"/>
+ reRender="fileMenu,fileContents"/>
</rich:fileUpload>
</ui:remove>
</h:panelGrid>
@@ -309,13 +316,14 @@ THIS TEXT WILL BE REMOVED.
Line: 6
-->
<h:form id="uploadForm" enctype="multipart/form-data">
- <rich:panel>
+ <rich:panel id="uploadPanel" rendered="#{ExistingResourceConfigurationUIBean.fileUploadAvailable}">
<input type="hidden" name="currentResourceId" value="#{ResourceUIBean.id}"/>
<rich:fileUpload id="fileUpload"
- listHeight="100px"
+ listHeight="50px"
fileUploadListener="#{fileUploader.fileUploadListener}"
+ addControlLabel="Browse"
immediateUpload="true">
<a4j:support event="onuploadcomplete" reRender="fileMenu,fileContents"/>
</rich:fileUpload>
commit 8402b19db9295fe0906e6b776f479e81f8acf9bd
Author: John Sanda <john(a)localhost.localdomain>
Date: Tue Jan 19 22:28:57 2010 -0500
Fixing edit button for structured view so that it sends you to the edit page.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 3161efa..6539aae 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -137,7 +137,7 @@ THIS TEXT WILL BE REMOVED.
rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
<h:commandButton value="Edit"
- action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}"
+ action="#{ExistingResourceConfigurationUIBean.editConfiguration}"
title="Edit this Configuration"
styleClass="buttonmed"
rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
commit 04e7165bddf42aba84d7c0950e0477781a0fbe14
Author: John Sanda <john(a)localhost.localdomain>
Date: Tue Jan 19 22:26:00 2010 -0500
Fixing icon for unmodified files to be a blank image
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 36b1905..3161efa 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -221,6 +221,7 @@ THIS TEXT WILL BE REMOVED.
selectedChild="#{currentPath}">
<c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
<rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
+ icon="/images/blank.png"
onclick="cursor_wait();"
oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationViewUIBean.select(rawConfigUIBean.path)}"
commit 7c2203b4bc066ac1b271b7202bc85494f9e68795
Author: John Sanda <john(a)localhost.localdomain>
Date: Tue Jan 19 21:28:43 2010 -0500
A first pass of file upload working directly on edit.xhtml without going to a different page
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index d74d938..047bf7f 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -43,7 +43,7 @@ THIS TEXT WILL BE REMOVED.
onsubmit="prepareInputsForSubmission(this)"
rendered="#{!ViewResourceConfigurationUIBean.updateInProgress}">
- <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+ <input type="hidden" name="currentResourceId" value="#{ResourceUIBean.id}"/>
<h:panelGrid columns="2" style="width:100%">
<h:outputText value="#{ResourceUIBean.name}"/>
@@ -273,7 +273,9 @@ THIS TEXT WILL BE REMOVED.
autoclear="false"
allowFlash="false"
maxRequestSize="100000">
- <a4j:support event="onuploadcomplete" reRender="fileMenu,fileContents"/>
+ <a4j:support event="onuploadcomplete"
+ reRender="fileContents"
+ action="#{ExistingResourceConfigurationUIBean.upload}"/>
</rich:fileUpload>
</ui:remove>
</h:panelGrid>
@@ -298,7 +300,6 @@ THIS TEXT WILL BE REMOVED.
</h:form>
- <ui:remove>
<!--
Here I tried the file upload in a separate form. It has resulted in javascript errors. The latest error in the
firefox error console is,
@@ -307,11 +308,10 @@ THIS TEXT WILL BE REMOVED.
Source File: http://localhost:7080/a4j/g/3_3_2.SR1org/ajax4jsf/javascript/scripts/form...
Line: 6
-->
- <h:form id="uploadForm">
+ <h:form id="uploadForm" enctype="multipart/form-data">
<rich:panel>
- <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
- <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+ <input type="hidden" name="currentResourceId" value="#{ResourceUIBean.id}"/>
<rich:fileUpload id="fileUpload"
listHeight="100px"
@@ -322,7 +322,6 @@ THIS TEXT WILL BE REMOVED.
</rich:panel>
</h:form>
- </ui:remove>
<h:panelGroup layout="block" styleClass="InfoBlock"
rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}">
commit dbcc3f759a998237a577eccd26e1e60b20c459f2
Merge: b689286... 1fc3706...
Author: John Sanda <john(a)localhost.localdomain>
Date: Tue Jan 19 20:06:36 2010 -0500
Merge branch 'raw-config' of ssh://git.fedorahosted.org/git/rhq/rhq into raw-config
commit b6892868e463eca9e6ee120e8e183e94df301a51
Author: John Sanda <john(a)localhost.localdomain>
Date: Tue Jan 19 20:04:59 2010 -0500
Checking in some debug code for trying to get file upload working on edit.xhtml
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index d690293..852897a 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.configuration.resource;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Collections;
@@ -53,6 +54,7 @@ import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.RawConfiguration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.ConfigurationFormat;
+import org.rhq.enterprise.gui.common.upload.FileUploadUIBean;
import org.rhq.core.gui.configuration.ConfigurationMaskingUtility;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.enterprise.gui.configuration.AbstractConfigurationUIBean;
@@ -77,6 +79,9 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
@Out
private Collection<RawConfigDirectory> rawConfigDirectories;
+ @Out
+ private FileUploadUIBean fileUploader = new FileUploadUIBean();
+
private String modalEditorContents;
public ExistingResourceConfigurationUIBean() {
@@ -532,12 +537,9 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return "/rhq/resource/configuration/edit-raw.xhtml?currentResourceId=" + getResourceId();
}
- /**
- * This is a no-op, since the upload work was done by upload file
- * But is kept as a target for the "action" value
- */
public String upload() {
- return "/rhq/resource/configuration/edit-raw.xhtml?currentResourceId=" + getResourceId();
+// return "/rhq/resource/configuration/edit-raw.xhtml?currentResourceId=" + getResourceId();
+ return null;
}
void dumpProperties(Configuration conf, Log log) {
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml
index 8f7cfcc..15424a2 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml
@@ -16,8 +16,9 @@
<component class="org.jboss.seam.web.MultipartFilter">
- <property name="createTempFiles">false</property>
+ <property name="createTempFiles">true</property>
<property name="maxRequestSize">1000000</property>
+ <property name="urlPattern">*.xhtml</property>
</component>
<component class="org.rhq.enterprise.gui.configuration.resource.ExistingResourceConfigurationUIBean"
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
index 0038c7d..c2825ba 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
@@ -5,7 +5,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
- <display-name>RHQ</display-name>
+ <display-name>RHQ_FOO</display-name>
<!--=== Seam ===-->
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/common/Login.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/common/Login.jsp
index 7537fbd..946557d 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/common/Login.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/common/Login.jsp
@@ -80,7 +80,7 @@ input.button_submit {
</head>
<body>
- <jsp:include page="/rhq/common/ie6/ie6fix.xhtml"/>
+ <%--<jsp:include page="/rhq/common/ie6/ie6fix.xhtml"/>--%>
<div id="PageHeader">
<table width="100%" border="0" cellpadding="20" cellspacing="0" height="70px">
@@ -145,6 +145,6 @@ input.button_submit {
document.forms["LoginForm"].elements["j_username"].focus();
// -->
</script>
-<jsp:include page="/rhq/common/ie6/ie6loginfix.xhtml" />
+<%--<jsp:include page="/rhq/common/ie6/ie6loginfix.xhtml" />--%>
</body>
</html>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml
index 3bd4af6..c8f6d72 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml
@@ -12,7 +12,7 @@
<h:form>
- <ui:include src="/rhq/common/ie6/ie6fix.xhtml" />
+ <ui:remove><ui:include src="/rhq/common/ie6/ie6fix.xhtml" /></ui:remove>
<f:loadBundle
basename="ApplicationResources"
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 7e54120..d74d938 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -9,6 +9,7 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jstl/core"
+ xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:onc="http://jboss.org/on/component">
@@ -222,7 +223,7 @@ THIS TEXT WILL BE REMOVED.
<h:panelGroup>
<h:outputText value="#{#rawConfigUIBean.fileName}"/>
<c:if test="#{rawConfigUIBean.modified}">
- <h:commandButton value="Undo"/>
+ <h:commandButton value="Undo" styleClass="buttonmed"/>
</c:if>
</h:panelGroup>
</rich:panelMenuItem>
@@ -243,6 +244,7 @@ THIS TEXT WILL BE REMOVED.
startText="Loading #{ExistingResourceConfigurationUIBean.current.path} ..."
stopText="#{ExistingResourceConfigurationUIBean.current.path}"/>
<a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
+
<h:commandLink value="Upload New">
<h:graphicImage value="/images/upload.png"/>
</h:commandLink>
@@ -259,14 +261,20 @@ THIS TEXT WILL BE REMOVED.
readonly="false"/>
</rich:panel>
<ui:remove>
- <h:form id="uploadForm" enctype="multipart/form-data">
+ <!--
+ Here I tried the file upload in the existing form. It does not generate any errors in the firefox
+ error console, but the upload is not working.
+ -->
<rich:fileUpload id="fileUpload"
- listHeight="100px"
fileUploadListener="#{ExistingResourceConfigurationUIBean.fileUploadListener}"
- immediateUpload="true">
+ maxFilesQuantity="1"
+ noDuplicate="true"
+ immediateUpload="true"
+ autoclear="false"
+ allowFlash="false"
+ maxRequestSize="100000">
<a4j:support event="onuploadcomplete" reRender="fileMenu,fileContents"/>
</rich:fileUpload>
- </h:form>
</ui:remove>
</h:panelGrid>
</h:panelGrid>
@@ -291,14 +299,29 @@ THIS TEXT WILL BE REMOVED.
</h:form>
<ui:remove>
- <rich:panel>
- <rich:fileUpload id="fileUpload"
- listHeight="100px"
- fileUploadListener="#{ExistingResourceConfigurationUIBean.fileUploadListener}"
- immediateUpload="true">
- <a4j:support event="onuploadcomplete" reRender="fileMenu,fileContents"/>
- </rich:fileUpload>
- </rich:panel>
+ <!--
+ Here I tried the file upload in a separate form. It has resulted in javascript errors. The latest error in the
+ firefox error console is,
+
+ Error: form.dispatchEvent is not a function
+ Source File: http://localhost:7080/a4j/g/3_3_2.SR1org/ajax4jsf/javascript/scripts/form...
+ Line: 6
+ -->
+ <h:form id="uploadForm">
+ <rich:panel>
+
+ <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+ <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+
+ <rich:fileUpload id="fileUpload"
+ listHeight="100px"
+ fileUploadListener="#{fileUploader.fileUploadListener}"
+ immediateUpload="true">
+ <a4j:support event="onuploadcomplete" reRender="fileMenu,fileContents"/>
+ </rich:fileUpload>
+
+ </rich:panel>
+ </h:form>
</ui:remove>
<h:panelGroup layout="block" styleClass="InfoBlock"
diff --git a/pom.xml b/pom.xml
index 34487d0..134b444 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,7 +74,7 @@
<postgresql.version>8.4-701.jdbc3</postgresql.version>
<h2.version>1.1.117</h2.version>
<jtds.version>1.2.2</jtds.version>
- <richfaces.version>3.3.0.GA</richfaces.version>
+ <richfaces.version>3.3.2.SR1</richfaces.version>
<sigar.version>1.6.3.82</sigar.version>
<quartz.version>1.6.5</quartz.version>
<jna.version>3.2.2</jna.version>
commit 1fc37069d1173ca4e6ad4fcf4424ec9377386ebd
Author: Adam Young <ayoung(a)redhat.com>
Date: Tue Jan 19 14:40:30 2010 -0500
removed amps version, now just check what facet is supported for configuration.
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
index dbf131b..1f8b2b7 100644
--- 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
@@ -23,19 +23,18 @@
package org.rhq.core.pc.configuration;
-import org.apache.maven.artifact.versioning.ComparableVersion;
+
import org.rhq.core.clientapi.agent.PluginContainerException;
import org.rhq.core.domain.configuration.definition.ConfigurationFormat;
import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.composite.ResourceFacets;
import org.rhq.core.pc.util.ComponentService;
-
-import static org.rhq.core.domain.configuration.definition.ConfigurationFormat.RAW;
-import static org.rhq.core.domain.configuration.definition.ConfigurationFormat.STRUCTURED;
+import org.rhq.core.pc.util.FacetLockType;
+import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
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();
@@ -57,41 +56,30 @@ public class ConfigManagementFactoryImpl implements ConfigManagementFactory {
}
private ConfigManagement createStrategy(int resourceId) throws PluginContainerException {
- String ampsVersion = componentService.getAmpsVersion(resourceId);
-
- if (isLegacyVersion(ampsVersion)) {
- return new LegacyConfigManagement();
- }
-
ResourceType resourceType = componentService.getResourceType(resourceId);
-
ConfigurationFormat format = resourceType.getResourceConfigurationDefinition().getConfigurationFormat();
- switch (format) {
- case RAW: break;
- default: ;
- }
- if (isStructured(resourceType)) {
- return new StructuredConfigManagement();
+ if (null == format) {
+ return new LegacyConfigManagement();
}
- if (isRaw(resourceType)) {
+ switch (format) {
+ case RAW:
return new RawConfigManagement();
+ case STRUCTURED_AND_RAW:
+ return new StructuredAndRawConfigManagement();
+ case STRUCTURED:
+ default:
+ boolean daemonOnly = true;
+ boolean onlyIfStarted = true;
+ ResourceComponent resourceComponent = componentService.getComponent(resourceId,
+ ResourceComponent .class, FacetLockType.READ, ConfigManagement.FACET_METHOD_TIMEOUT,
+ daemonOnly, onlyIfStarted);
+ if (resourceComponent instanceof ResourceConfigurationFacet){
+ return new StructuredConfigManagement();
+ }else{
+ return new LegacyConfigManagement();
+ }
}
-
- // else format is both structured and raw
- return new StructuredAndRawConfigManagement();
- }
-
- 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);
}
}
commit f4ab35fae9af81208006801bd706fb04ba0f8286
Author: John Sanda <john(a)localhost.localdomain>
Date: Mon Jan 18 22:57:50 2010 -0500
Adding save/cancel buttons to modal editor
Clicking the cancel button simply closes the editor as a client-side operation. Clicking
the save button closes the editor but also fires an ajax request to the server to update
the on-page text editor. The modification will result in the file in the file menu
appearing as being updated as well.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 637ec4c..d690293 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -77,6 +77,8 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
@Out
private Collection<RawConfigDirectory> rawConfigDirectories;
+ private String modalEditorContents;
+
public ExistingResourceConfigurationUIBean() {
removeSessionScopedBeanIfInView("/rhq/resource/configuration/view.xhtml",
ExistingResourceConfigurationUIBean.class);
@@ -199,6 +201,10 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return updateConfiguration(false);
}
+ public void saveModalEditorContents() {
+ setCurrentContents(modalEditorContents);
+ }
+
public String updateConfiguration(boolean fromStructured) {
ConfigurationMaskingUtility.unmaskConfiguration(getConfiguration(), getConfigurationDefinition());
@@ -371,10 +377,15 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public String getModalEditorContents() {
- return getCurrentContents();
+ if (modalEditorContents == null) {
+ modalEditorContents = getCurrentContents();
+ }
+// return getCurrentContents();
+ return modalEditorContents;
}
public void setModalEditorContents(String contents) {
+ modalEditorContents = contents;
}
public TreeMap<String, RawConfiguration> getModified() {
@@ -454,6 +465,7 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
selectedPath = s;
setCurrentPath(selectedPath);
setCurrentContents(getCurrentContents());
+ modalEditorContents = getCurrentContents();
}
public void setCurrentContents(String updated) {
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index c87f4cb..7e54120 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -258,6 +258,16 @@ THIS TEXT WILL BE REMOVED.
value="#{ExistingResourceConfigurationUIBean.currentContents}"
readonly="false"/>
</rich:panel>
+ <ui:remove>
+ <h:form id="uploadForm" enctype="multipart/form-data">
+ <rich:fileUpload id="fileUpload"
+ listHeight="100px"
+ fileUploadListener="#{ExistingResourceConfigurationUIBean.fileUploadListener}"
+ immediateUpload="true">
+ <a4j:support event="onuploadcomplete" reRender="fileMenu,fileContents"/>
+ </rich:fileUpload>
+ </h:form>
+ </ui:remove>
</h:panelGrid>
</h:panelGrid>
@@ -280,6 +290,17 @@ THIS TEXT WILL BE REMOVED.
</h:form>
+ <ui:remove>
+ <rich:panel>
+ <rich:fileUpload id="fileUpload"
+ listHeight="100px"
+ fileUploadListener="#{ExistingResourceConfigurationUIBean.fileUploadListener}"
+ immediateUpload="true">
+ <a4j:support event="onuploadcomplete" reRender="fileMenu,fileContents"/>
+ </rich:fileUpload>
+ </rich:panel>
+ </ui:remove>
+
<h:panelGroup layout="block" styleClass="InfoBlock"
rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}">
<b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
index 8d8b046..25cec92 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
@@ -22,13 +22,23 @@
</h:panelGroup>
</f:facet>
<rich:panel style="margin-left:1px; border: none;">
- <h:inputTextarea id="fileContents"
+ <h:inputTextarea id="modalFileContents"
style="width:100%; height:100%; overflow:visible;"
rows="30"
cols="30"
value="#{ExistingResourceConfigurationUIBean.modalEditorContents}"
readonly="false"/>
</rich:panel>
+ <h:panelGrid columns="1" columnClasses="raw-edit-footer" style="width:100%">
+ <h:panelGroup style="text-align:right">
+ <a4j:commandButton value="Save"
+ action="#{ExistingResourceConfigurationUIBean.saveModalEditorContents}"
+ reRender="fileContents,fileMenu"
+ styleClass="buttonmed"
+ onclick="#{rich:component('modalEditor')}.hide()"/>
+ <a4j:commandButton value="Cancel" onclick="#{rich:component('modalEditor')}.hide()" styleClass="buttonmed"/>
+ </h:panelGroup>
+ </h:panelGrid>
</rich:modalPanel>
</f:subview>
commit fd7680ada5b7376fae1b770121510316f724dbb4
Author: Adam Young <ayoung(a)redhat.com>
Date: Mon Jan 18 17:23:40 2010 -0500
Modified error message for collected exceptions to match unit test expected value.
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 0bda29e..dc3955a 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
@@ -377,7 +377,7 @@ public class ConfigurationManager extends AgentService implements ContainerServi
if (null == errorMessage){
errorMessage = new StringBuilder();
}
- errorMessage.append("file " + rawConfiguration.getPath() +" failed validation with " + e.getMessage()+". " );
+ errorMessage.append("file " + rawConfiguration.getPath() +" failed validation with " + e.getMessage()+"." );
}
}
}catch(Throwable t){
commit 2ab5f6f7c086a490ca50bd65058be4f38ee8e55c
Author: Adam Young <ayoung(a)redhat.com>
Date: Mon Jan 18 17:17:53 2010 -0500
Somehow, a bad version of the error messaging generted code has not gotten changed. This attempts to fix it.
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 eb08ea3..0bda29e 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
@@ -382,7 +382,7 @@ public class ConfigurationManager extends AgentService implements ContainerServi
}
}catch(Throwable t){
errorMessage = new StringBuilder();
- errorMessage.append("configuation validation failed with" + t.getMessage()+"." );
+ errorMessage.append("configuation validation failed with" + t.getMessage()+".");
}
if (null != errorMessage){
throw new PluginContainerException(errorMessage.toString());
commit b9aa86fce93f2d1c98d82ded2125f67783ddf95d
Author: John Sanda <john(a)localhost.localdomain>
Date: Mon Jan 18 17:10:02 2010 -0500
Adding commit button and msg above text area and moving them to the right side of the screen.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 25b7801..637ec4c 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -138,25 +138,32 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public String switchToRaw() {
-// Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration(
-// EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), true);
Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration(
EnterpriseFacesContextUtility.getSubject(), getResourceId(), getConfiguration(), true);
setConfiguration(configuration);
- getModified().clear();
-
for (RawConfiguration raw : configuration.getRawConfigurations()) {
getRaws().put(raw.getPath(), raw);
}
current = null;
setConfiguration(configuration);
-
+ updateModifiedCache();
mode = RAW_MODE;
return null;
}
+ private void updateModifiedCache() {
+ Configuration configuration = getConfiguration();
+
+ for (RawConfiguration updatedRaw : configuration.getRawConfigurations()) {
+ RawConfiguration cachedRaw = modified.get(updatedRaw.getPath());
+ if (cachedRaw != null && !updatedRaw.getSha256().equals(cachedRaw.getSha256())) {
+ modified.remove(cachedRaw.getPath());
+ }
+ }
+ }
+
public String switchToStructured() {
Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration(
EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), false);
@@ -172,6 +179,12 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
current = null;
setConfiguration(configuration);
+ for (RawConfiguration raw : configuration.getRawConfigurations()) {
+ System.out.println(raw.getPath() + " -\n" + (new String(raw.getContents())) + "\n");
+ }
+
+ updateModifiedCache();
+
mode = STRUCTURED_MODE;
return null;
@@ -418,12 +431,10 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public boolean isRawSupported() {
-// return getConfigurationFormat().isRawSupported();
- return getConfigurationDefinition().getConfigurationFormat() == ConfigurationFormat.RAW;
+ return getConfigurationDefinition().getConfigurationFormat() == ConfigurationFormat.RAW;
}
public boolean isStructuredSupported() {
-// return getConfigurationFormat().isStructuredSupported();
return getConfigurationDefinition().getConfigurationFormat() == ConfigurationFormat.STRUCTURED;
}
@@ -499,7 +510,6 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
log.error("Failed to complete download request for " + getCurrentPath(), e);
throw new RuntimeException(e);
}
-// return "download";
}
/**
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/configuration-beans.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/configuration-beans.xml
index d2cd3f7..cb1a71e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/configuration-beans.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/configuration-beans.xml
@@ -12,11 +12,11 @@
<!--</managed-bean> -->
<!-- /rhq/resource/configuration/history.xhtml, /rhq/resource/configuration/edit.xhtml, and
/rhq/resource/configuration/edit-map.xhtml -->
- <managed-bean>
- <managed-bean-name>ExistingResourceConfigurationUIBean</managed-bean-name>
- <managed-bean-class>org.rhq.enterprise.gui.configuration.resource.ExistingResourceConfigurationUIBean</managed-bean-class>
- <managed-bean-scope>session</managed-bean-scope>
- </managed-bean>
+ <!--<managed-bean>-->
+ <!--<managed-bean-name>ExistingResourceConfigurationUIBean</managed-bean-name>-->
+ <!--<managed-bean-class>org.rhq.enterprise.gui.configuration.resource.ExistingResourceConfigurationUIBean</managed-bean-class>-->
+ <!--<managed-bean-scope>session</managed-bean-scope>-->
+ <!--</managed-bean> -->
<!-- /rhq/resource/configuration/add-new-simple.xhtml -->
<managed-bean>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index d9e5b18..c87f4cb 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -44,8 +44,18 @@ THIS TEXT WILL BE REMOVED.
<input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
- <h:panelGrid columns="2">
+ <h:panelGrid columns="2" style="width:100%">
<h:outputText value="#{ResourceUIBean.name}"/>
+ <h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
+ <h:panelGroup style="text-align:right">
+ <h:outputText style="padding-right:10px">n files changed in this configuration</h:outputText>
+ <h:commandButton value="Commit"
+ action="#{ExistingResourceConfigurationUIBean.updateRawConfiguration}"
+ title="Click to Save Changes"
+ styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure}"/>
+ </h:panelGroup>
+ </h:panelGrid>
</h:panelGrid>
<c:choose>
@@ -116,17 +126,17 @@ THIS TEXT WILL BE REMOVED.
readonly="false"/>
</rich:panel>
</h:panelGrid>
+ </h:panelGrid>
- <h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
- <h:panelGrid columns="2">
- <h:outputText>n files changed in this configuration</h:outputText>
- <h:commandButton value="Commit"
- action="#{ExistingResourceConfigurationUIBean.updateRawConfiguration}"
- title="Click to Save Changes"
- styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure}"/>
- </h:panelGrid>
- </h:panelGrid>
+ <h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
+ <h:panelGroup style="text-align:right">
+ <h:outputText style="padding-right:10px">n files changed in this configuration</h:outputText>
+ <h:commandButton value="Commit"
+ action="#{ExistingResourceConfigurationUIBean.updateRawConfiguration}"
+ title="Click to Save Changes"
+ styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure}"/>
+ </h:panelGroup>
</h:panelGrid>
</rich:tab>
</rich:tabPanel>
@@ -187,40 +197,40 @@ THIS TEXT WILL BE REMOVED.
styleClass="raw-outer-table"
columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
<h:panelGrid columns="1">
- <rich:panel style="width:100%">
- <f:facet name="header">Files</f:facet>
-
-
- <rich:panelMenu id="fileMenu"
- mode="ajax"
- expandMode="client"
- iconCollapsedGroup="/images/icn_tree_folder.gif"
- iconExpandedGroup="/images/icn_tree_folder.gif">
- <c:forEach items="#{rawConfigDirectories}"
- var="rawConfigDir">
- <rich:panelMenuGroup label="#{rawConfigDir.path}"
- expanded="true"
- selectedChild="#{ExistingResourceConfigurationUIBean.currentPath}">
- <c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
- <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
- icon="#{rawConfigUIBean.icon}"
- onclick="cursor_wait();"
- oncomplete="cursor_clear();"
- action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
- limitToList="true"
- reRender="fileContents,selectedFileHeader,modalEditor,fileMenu">
- <h:panelGroup>
- <h:outputText value="#{#rawConfigUIBean.fileName}"/>
- <c:if test="#{rawConfigUIBean.modified}">
- <h:commandButton value="Undo"/>
- </c:if>
- </h:panelGroup>
- </rich:panelMenuItem>
- </c:forEach>
- </rich:panelMenuGroup>
- </c:forEach>
- </rich:panelMenu>
- </rich:panel>
+ <rich:panel style="width:100%">
+ <f:facet name="header">Files</f:facet>
+
+
+ <rich:panelMenu id="fileMenu"
+ mode="ajax"
+ expandMode="client"
+ iconCollapsedGroup="/images/icn_tree_folder.gif"
+ iconExpandedGroup="/images/icn_tree_folder.gif">
+ <c:forEach items="#{rawConfigDirectories}"
+ var="rawConfigDir">
+ <rich:panelMenuGroup label="#{rawConfigDir.path}"
+ expanded="true"
+ selectedChild="#{ExistingResourceConfigurationUIBean.currentPath}">
+ <c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
+ <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
+ icon="#{rawConfigUIBean.icon}"
+ onclick="cursor_wait();"
+ oncomplete="cursor_clear();"
+ action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
+ limitToList="true"
+ reRender="fileContents,selectedFileHeader,modalEditor,fileMenu">
+ <h:panelGroup>
+ <h:outputText value="#{#rawConfigUIBean.fileName}"/>
+ <c:if test="#{rawConfigUIBean.modified}">
+ <h:commandButton value="Undo"/>
+ </c:if>
+ </h:panelGroup>
+ </rich:panelMenuItem>
+ </c:forEach>
+ </rich:panelMenuGroup>
+ </c:forEach>
+ </rich:panelMenu>
+ </rich:panel>
<rich:panel style="border:none">
<h:graphicImage url="/images/star_on_24.png"/>
<h:outputText value="- Contains uncommitted changes"/>
@@ -249,17 +259,17 @@ THIS TEXT WILL BE REMOVED.
readonly="false"/>
</rich:panel>
</h:panelGrid>
+ </h:panelGrid>
- <h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
- <h:panelGrid columns="2">
- <h:outputText>n files changed in this configuration</h:outputText>
- <h:commandButton value="Commit"
- action="#{ExistingResourceConfigurationUIBean.updateRawConfiguration}"
- title="Click to Save Changes"
- styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure}"/>
- </h:panelGrid>
- </h:panelGrid>
+ <h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
+ <h:panelGroup style="text-align:right">
+ <h:outputText style="padding-right:10px">n files changed in this configuration</h:outputText>
+ <h:commandButton value="Commit"
+ action="#{ExistingResourceConfigurationUIBean.updateRawConfiguration}"
+ title="Click to Save Changes"
+ styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure}"/>
+ </h:panelGroup>
</h:panelGrid>
</rich:tab>
</rich:tabPanel>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 7b34258..36b1905 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -63,7 +63,7 @@ THIS TEXT WILL BE REMOVED.
rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
<h:commandButton value="Edit"
- action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
+ action="#{ExistingResourceConfigurationUIBean.editRawConfiguration}"
title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
</h:panelGrid>
commit 39cbfc6f8090cd0402917509c1aa7c32033c08a3
Merge: 6e642f7... a09d1be...
Author: Adam Young <ayoung(a)redhat.com>
Date: Mon Jan 18 16:53:42 2010 -0500
Merge branch 'raw-config' of ssh://git.fedorahosted.org/git/rhq/rhq into raw-config-confirm
commit 6e642f7fbf773f863bcc5c8b8bb6c37f4de991cc
Author: Adam Young <ayoung(a)redhat.com>
Date: Mon Jan 18 16:25:31 2010 -0500
Update unit test.
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 8a51f2a..eb08ea3 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
@@ -382,7 +382,7 @@ public class ConfigurationManager extends AgentService implements ContainerServi
}
}catch(Throwable t){
errorMessage = new StringBuilder();
- errorMessage.append("configuation validation failed with" + t.getMessage()+". " );
+ errorMessage.append("configuation validation failed with" + t.getMessage()+"." );
}
if (null != errorMessage){
throw new PluginContainerException(errorMessage.toString());
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 0176ef0..619fe36 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
@@ -71,48 +71,62 @@ public class ConfigurationManagerTest extends ConfigManagementTest {
}
@Test
- public void straegyShouldBeCalledToLoadConfig() throws Exception {
+ public void strategyShouldBeCalledToLoadConfig() throws Exception {
final Configuration expectedConfig = new Configuration();
final ConfigManagement loadConfig = context.mock(ConfigManagement.class);
- context.checking(new Expectations() {{
- atLeast(1).of(configMgmtFactory).getStrategy(resourceId); will(returnValue(loadConfig));
+ context.checking(new Expectations() {
+ {
+ atLeast(1).of(configMgmtFactory).getStrategy(resourceId);
+ will(returnValue(loadConfig));
- atLeast(1).of(loadConfig).executeLoad(resourceId); will(returnValue(expectedConfig));
- }});
+ atLeast(1).of(loadConfig).executeLoad(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})
+ @Test(expectedExceptions = { PluginContainerException.class })
public void exceptionShouldBeThrownIfConfigIsNull() throws Exception {
final ConfigManagement loadConfig = context.mock(ConfigManagement.class);
- context.checking(new Expectations() {{
- atLeast(1).of(configMgmtFactory).getStrategy(resourceId); will(returnValue(loadConfig));
+ context.checking(new Expectations() {
+ {
+ atLeast(1).of(configMgmtFactory).getStrategy(resourceId);
+ will(returnValue(loadConfig));
- atLeast(1).of(loadConfig).executeLoad(resourceId); will(returnValue(null));
+ atLeast(1).of(loadConfig).executeLoad(resourceId);
+ will(returnValue(null));
- allowing(componentService).getResourceType(resourceId); will(returnValue(new ResourceType()));
- }});
+ allowing(componentService).getResourceType(resourceId);
+ will(returnValue(new ResourceType()));
+ }
+ });
configurationMgr.loadResourceConfiguration(resourceId);
}
- @Test(expectedExceptions = {PluginContainerException.class})
+ @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));
+ context.checking(new Expectations() {
+ {
+ allowing(componentService).getResourceType(resourceId);
+ will(returnValue(resourceType));
- atLeast(1).of(configMgmtFactory).getStrategy(resourceId); will(returnValue(loadConfig));
+ atLeast(1).of(configMgmtFactory).getStrategy(resourceId);
+ will(returnValue(loadConfig));
- atLeast(1).of(loadConfig).executeLoad(resourceId); will(throwException(new RuntimeException()));
- }});
+ atLeast(1).of(loadConfig).executeLoad(resourceId);
+ will(throwException(new RuntimeException()));
+ }
+ });
configurationMgr.loadResourceConfiguration(resourceId);
}
@@ -134,22 +148,24 @@ public class ConfigurationManagerTest extends ConfigManagementTest {
final ResourceConfigurationFacet facet = context.mock(ResourceConfigurationFacet.class);
- context.checking(new Expectations() {{
- allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
+ 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(componentService).getComponent(resourceId, ResourceConfigurationFacet.class,
+ FacetLockType.READ, ConfigManagement.FACET_METHOD_TIMEOUT, daemonThread, onlyIfStarted);
+ will(returnValue(facet));
- atLeast(1).of(facet).loadRawConfigurations(); will(returnValue(latestRaws));
+ atLeast(1).of(facet).loadRawConfigurations();
+ will(returnValue(latestRaws));
- oneOf(facet).mergeRawConfiguration(config, raw1); will(returnValue(mergedRaw1));
- oneOf(facet).mergeRawConfiguration(config, raw2); will(returnValue(mergedRaw2));
- }});
+ oneOf(facet).mergeRawConfiguration(config, raw1);
+ will(returnValue(mergedRaw1));
+ oneOf(facet).mergeRawConfiguration(config, raw2);
+ will(returnValue(mergedRaw2));
+ }
+ });
Configuration mergedConfig = configurationMgr.merge(config, resourceId, FROM_STRUCTURED);
@@ -171,28 +187,29 @@ public class ConfigurationManagerTest extends ConfigManagementTest {
final ResourceConfigurationFacet facet = context.mock(ResourceConfigurationFacet.class);
- context.checking(new Expectations() {{
- allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
+ 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(componentService).getComponent(resourceId, ResourceConfigurationFacet.class,
+ FacetLockType.READ, ConfigManagement.FACET_METHOD_TIMEOUT, daemonThread, onlyIfStarted);
+ will(returnValue(facet));
- atLeast(1).of(facet).loadRawConfigurations(); will(returnValue(latestRaws));
+ atLeast(1).of(facet).loadRawConfigurations();
+ will(returnValue(latestRaws));
- oneOf(facet).mergeRawConfiguration(config, originalRaw); will(returnValue(null));
- }});
+ 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.");
+ assertStructuredMergedIntoRaws(mergedConfig, expectedConfig, "cannot merge into a null raw.");
}
@Test
@@ -204,46 +221,39 @@ public class ConfigurationManagerTest extends ConfigManagementTest {
final ResourceConfigurationFacet facet = context.mock(ResourceConfigurationFacet.class);
- context.checking(new Expectations() {{
- allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
+ 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(componentService).getComponent(resourceId, ResourceConfigurationFacet.class,
+ FacetLockType.READ, ConfigManagement.FACET_METHOD_TIMEOUT, daemonThread, onlyIfStarted);
+ will(returnValue(facet));
- atLeast(1).of(facet).loadRawConfigurations(); will(returnValue(null));
- }});
+ 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."
- );
+ 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
- );
+ 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
- );
+ assertTrue(actualRaws.contains(expectedRaw),
+ "Merging structured into raws failed, failed to find to find raw config [" + expectedRaw + "] -- "
+ + msg);
}
}
@@ -265,38 +275,59 @@ public class ConfigurationManagerTest extends ConfigManagementTest {
final ResourceConfigurationFacet facet = context.mock(ResourceConfigurationFacet.class);
- context.checking(new Expectations() {{
- allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
+ 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(componentService).getComponent(resourceId, ResourceConfigurationFacet.class,
+ FacetLockType.READ, ConfigManagement.FACET_METHOD_TIMEOUT, daemonThread, onlyIfStarted);
+ will(returnValue(facet));
- atLeast(1).of(facet).loadStructuredConfiguration(); will(returnValue(latestStructured));
+ atLeast(1).of(facet).loadStructuredConfiguration();
+ will(returnValue(latestStructured));
- oneOf(facet).mergeStructuredConfiguration(raw1, config);
- oneOf(facet).mergeStructuredConfiguration(raw2, config);
- }});
+ 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."
- );
+ assertEquals(mergedConfig.getAllProperties(), latestStructured.getAllProperties(),
+ "Failed to merged raw into structured.");
}
@Test
- public void catchExceptionThrownByFailedValidationOfRawConfigS() throws Exception {
- assertTrue(false);
+ public void catchExceptionThrownByFailedValidationOfRawConfigs() throws Exception {
+
+ Configuration configuration = new Configuration();
+ final RawConfiguration rawConfiguration = createRawConfiguration("/tmp/foo.txt");
+ configuration.addRawConfiguration(rawConfiguration);
+ 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));
+
+ allowing(facet).validateRawConfiguration(rawConfiguration);
+ will(throwException(new IllegalArgumentException("message")));
+
+ }
+ });
+ try {
+ configurationMgr.validate(configuration, resourceId, false);
+ assertTrue(false);
+ } catch (PluginContainerException exception) {
+ assertEquals(exception.getMessage(), "file /tmp/foo.txt failed validation with message.");
+ }
}
-
-
+
@Test
public void mergingRawsIntoStructuredShouldIgnoreNull() throws Exception {
Configuration config = new Configuration();
@@ -304,27 +335,24 @@ public class ConfigurationManagerTest extends ConfigManagementTest {
final ResourceConfigurationFacet facet = context.mock(ResourceConfigurationFacet.class);
- context.checking(new Expectations() {{
- allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
+ 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(componentService).getComponent(resourceId, ResourceConfigurationFacet.class,
+ FacetLockType.READ, ConfigManagement.FACET_METHOD_TIMEOUT, daemonThread, onlyIfStarted);
+ will(returnValue(facet));
- atLeast(1).of(facet).loadStructuredConfiguration(); will(returnValue(null));
- }});
+ 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."
- );
+ assertEquals(mergedConfig, config,
+ "Structured config should not be modified when the facet does not return a structured config.");
}
@Test
@@ -348,16 +376,20 @@ public class ConfigurationManagerTest extends ConfigManagementTest {
configurationMgr.setConfiguration(containerConfig);
- final UpdateResourceConfigurationRunner updateRunner = new UpdateResourceConfigurationRunner(configServerService,
- resourceType, configMgmt, request);
+ final UpdateResourceConfigurationRunner updateRunner = new UpdateResourceConfigurationRunner(
+ configServerService, resourceType, configMgmt, request);
- context.checking(new Expectations() {{
- allowing(componentService).getResourceType(resourceId); will(returnValue(resourceType));
+ context.checking(new Expectations() {
+ {
+ allowing(componentService).getResourceType(resourceId);
+ will(returnValue(resourceType));
- atLeast(1).of(configMgmtFactory).getStrategy(resourceId); will(returnValue(configMgmt));
+ atLeast(1).of(configMgmtFactory).getStrategy(resourceId);
+ will(returnValue(configMgmt));
- oneOf(threadPool).submit((Runnable)with(matchingUpdateRunner(updateRunner)));
- }});
+ oneOf(threadPool).submit((Runnable) with(matchingUpdateRunner(updateRunner)));
+ }
+ });
configurationMgr.updateResourceConfiguration(request);
}
commit e007d081188e8b458300294f4d2a5b8e3ce850ad
Merge: dc91b94... 56e8acf...
Author: Adam Young <ayoung(a)redhat.com>
Date: Mon Jan 18 13:02:56 2010 -0500
Cleaned up bad merge.
diff --cc modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java
index b76b310,54a7d8d..38a3f59
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java
@@@ -44,6 -44,6 +44,5 @@@ public interface ResourceConfigurationF
void validateStructuredConfiguration(Configuration configuration);
- void validateRawConfiguration(RawConfiguration rawConfiguration) throws IllegalArgumentException;
-
+ void validateRawConfiguration(RawConfiguration rawConfiguration) throws RuntimeException;
-
}
diff --cc modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java
index 9b3cc55,974055b..8a51f2a
--- 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
@@@ -368,25 -368,21 +368,25 @@@ public class ConfigurationManager exten
return;
} else {
StringBuilder errorMessage = null;
-
- for (RawConfiguration rawConfiguration : configuration.getRawConfigurations()) {
- try {
- facet.validateRawConfiguration(rawConfiguration);
- } catch (Exception e) {
- if (null == errorMessage){
- errorMessage = new StringBuilder();
++
+ try{
+ for (RawConfiguration rawConfiguration : configuration.getRawConfigurations()) {
+ try {
+ facet.validateRawConfiguration(rawConfiguration);
+ } catch (IllegalArgumentException e) {
+ if (null == errorMessage){
+ errorMessage = new StringBuilder();
+ }
+ errorMessage.append("file " + rawConfiguration.getPath() +" failed validation with " + e.getMessage()+". " );
}
- errorMessage.append("file " + rawConfiguration.getPath() +" failed validation with " + e.getMessage()+". " );
-
- }
- if (null != errorMessage){
- throw new PluginContainerException(errorMessage.toString());
}
- }
- }
+ }catch(Throwable t){
+ errorMessage = new StringBuilder();
+ errorMessage.append("configuation validation failed with" + t.getMessage()+". " );
- }
- if (null != errorMessage){
- throw new PluginContainerException(errorMessage.toString());
- }
- }
- }
++ }
++ if (null != errorMessage){
++ throw new PluginContainerException(errorMessage.toString());
++ }
++ }
}
-
+ }
diff --cc modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/ConfigurationManagerTest.java
index b43a892,b43a892..0176ef0
--- 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
@@@ -292,6 -292,6 +292,12 @@@ public class ConfigurationManagerTest e
}
@Test
++ public void catchExceptionThrownByFailedValidationOfRawConfigS() throws Exception {
++ assertTrue(false);
++ }
++
++
++ @Test
public void mergingRawsIntoStructuredShouldIgnoreNull() throws Exception {
Configuration config = new Configuration();
config.addRawConfiguration(createRawConfiguration("/tmp/foo.txt"));
commit a09d1bea01050e70913796e78518a0cf7464a7c6
Author: John Sanda <john(a)localhost.localdomain>
Date: Mon Jan 18 11:10:33 2010 -0500
Refactoring to put config files into multiple directories
diff --git a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy
index d82fb5e..2866427 100644
--- a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy
+++ b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy
@@ -15,6 +15,10 @@ class StructuredAndRawServer implements ResourceComponent, ResourceConfiguration
File rawConfigDir
+ File rawConfigSubdir1
+
+ File rawConfigSubdir2
+
File rawConfig1
File rawConfig2
@@ -29,20 +33,24 @@ class StructuredAndRawServer implements ResourceComponent, ResourceConfiguration
resourceContext = context
rawConfigDir = new File("${System.getProperty('java.io.tmpdir')}/raw-config-test")
- rawConfig1 = new File(rawConfigDir, "structured-and-raw-test-1.txt")
- rawConfig2 = new File(rawConfigDir, "structured-and-raw-test-2.txt")
- rawConfig3 = new File(rawConfigDir, "structured-and-raw-test-3.txt")
- rawConfig4 = new File(rawConfigDir, "structured-and-raw-test-4.txt")
+ rawConfigSubdir1 = new File(rawConfigDir, "structured-and-raw-1")
+ rawConfigSubdir2 = new File(rawConfigDir, "structured-and-raw-2")
+
+ rawConfig1 = new File(rawConfigSubdir1, "structured-and-raw-test-1.txt")
+ rawConfig2 = new File(rawConfigSubdir1, "structured-and-raw-test-2.txt")
+ rawConfig3 = new File(rawConfigSubdir2, "structured-and-raw-test-3.txt")
+ rawConfig4 = new File(rawConfigSubdir2, "structured-and-raw-test-4.txt")
- createRawConfigDir()
+ createRawConfigDirs()
createConfigFile(rawConfig1, ["x": "1", "y": "2", "z": "3"])
createConfigFile(rawConfig2, ["username": "rhqadmin", "password": "rhqadmin"])
createConfigFile(rawConfig3, ["rhq.server.hostname": "localhost", "rhq.server.port": "7080"])
createConfigFile(rawConfig4, ["raw.only.x": "foo", "raw.only.y": "bar"])
}
- def createRawConfigDir() {
- rawConfigDir.mkdirs()
+ def createRawConfigDirs() {
+ rawConfigSubdir1.mkdirs()
+ rawConfigSubdir2.mkdirs()
}
def createConfigFile(File rawConfig, Map properties) {
commit 9a9156058a84bb2babd5f7e7fe60c285c651d39f
Author: John Sanda <john(a)localhost.localdomain>
Date: Mon Jan 18 11:01:27 2010 -0500
Adding another config file for StructuredAndRawServer that is managed only via the raw and not structured
diff --git a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy
index 359c615..d82fb5e 100644
--- a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy
+++ b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy
@@ -21,6 +21,8 @@ class StructuredAndRawServer implements ResourceComponent, ResourceConfiguration
File rawConfig3
+ File rawConfig4
+
def ant = new AntBuilder()
void start(ResourceContext context) {
@@ -30,11 +32,13 @@ class StructuredAndRawServer implements ResourceComponent, ResourceConfiguration
rawConfig1 = new File(rawConfigDir, "structured-and-raw-test-1.txt")
rawConfig2 = new File(rawConfigDir, "structured-and-raw-test-2.txt")
rawConfig3 = new File(rawConfigDir, "structured-and-raw-test-3.txt")
+ rawConfig4 = new File(rawConfigDir, "structured-and-raw-test-4.txt")
createRawConfigDir()
createConfigFile(rawConfig1, ["x": "1", "y": "2", "z": "3"])
createConfigFile(rawConfig2, ["username": "rhqadmin", "password": "rhqadmin"])
createConfigFile(rawConfig3, ["rhq.server.hostname": "localhost", "rhq.server.port": "7080"])
+ createConfigFile(rawConfig4, ["raw.only.x": "foo", "raw.only.y": "bar"])
}
def createRawConfigDir() {
@@ -100,11 +104,16 @@ class StructuredAndRawServer implements ResourceComponent, ResourceConfiguration
rawConfigs.add(new RawConfiguration(path: rawConfig1.absolutePath, contents: rawConfig1.readBytes()))
rawConfigs.add(new RawConfiguration(path: rawConfig2.absolutePath, contents: rawConfig2.readBytes()))
rawConfigs.add(new RawConfiguration(path: rawConfig3.absolutePath, contents: rawConfig3.readBytes()))
+ rawConfigs.add(new RawConfiguration(path: rawConfig4.absolutePath, contents: rawConfig4.readBytes()))
return rawConfigs
}
RawConfiguration mergeRawConfiguration(Configuration configuration, RawConfiguration rawConfiguration) {
+ if (rawConfiguration.path == rawConfig4.absolutePath) {
+ return rawConfiguration
+ }
+
def rawPropertiesConfig = loadRawPropertiesConfiguration(rawConfiguration)
def propertyNames = getPropertyNames(rawConfiguration)
@@ -129,6 +138,10 @@ class StructuredAndRawServer implements ResourceComponent, ResourceConfiguration
}
void mergeStructuredConfiguration(RawConfiguration rawConfiguration, Configuration configuration) {
+ if (rawConfiguration.path == rawConfig4.absolutePath) {
+ return
+ }
+
def rawPropertiesConfig = loadRawPropertiesConfiguration(rawConfiguration)
def propertyNames = getPropertyNames(rawConfiguration)
commit 996a27d87231385b2a6b113732c8949c1493f153
Author: John Sanda <john(a)localhost.localdomain>
Date: Mon Jan 18 10:49:47 2010 -0500
Updating logic so that when you click on the edit button, you go to the edit page but remain on the same tab
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index ac0b460..25b7801 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -117,6 +117,7 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public String editConfiguration() {
+ mode = STRUCTURED_MODE;
return SUCCESS_OUTCOME;
}
@@ -128,9 +129,11 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
public void changeTabs(ValueChangeEvent event) {
if (event.getNewValue().equals("rawTab")) {
switchToRaw();
+ mode = RAW_MODE;
}
else if (event.getNewValue().equals("structuredTab")) {
switchToStructured();
+ mode = STRUCTURED_MODE;
}
}
@@ -368,6 +371,22 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return modified;
}
+ public String getSelectedTab() {
+ if (mode == STRUCTURED_MODE) {
+ return "structuredTab";
+ }
+ return "rawTab";
+ }
+
+ public void setSelectedTab(String tab) {
+ if (tab.equals("structuredTab")) {
+ mode = STRUCTURED_MODE;
+ }
+ else {
+ mode = RAW_MODE;
+ }
+ }
+
public Object[] getPaths() {
return getRaws().keySet().toArray();
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml
index 39270b7..1ed069c 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml
@@ -28,13 +28,13 @@
<navigation-rule>
<navigation-case>
- <from-action>#{ExistingResourceConfigurationViewUIBean.editConfiguration}</from-action>
+ <from-action>#{ExistingResourceConfigurationUIBean.editConfiguration}</from-action>
<to-view-id>/rhq/resource/configuration/edit.xhtml?id=#{param.id}</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
- <from-action>#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}</from-action>
+ <from-action>#{ExistingResourceConfigurationUIBean.editRawConfiguration}</from-action>
<to-view-id>/rhq/resource/configuration/edit.xhtml?id=#{param.id}</to-view-id>
<redirect/>
</navigation-case>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 36effa3..d9e5b18 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -156,6 +156,7 @@ THIS TEXT WILL BE REMOVED.
<c:when test="${ExistingResourceConfigurationUIBean.structuredAndRawSupported}">
<rich:tabPanel id="configTabPanel"
+ selectedTab="#{ExistingResourceConfigurationUIBean.selectedTab}"
switchType="ajax"
valueChangeListener="#{ExistingResourceConfigurationUIBean.changeTabs}">
<rich:tab id="structuredTab" label="Basic Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 7d3bc58..7b34258 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -157,7 +157,10 @@ THIS TEXT WILL BE REMOVED.
<c:when test="${ExistingResourceConfigurationViewUIBean.structuredAndRawSupported}">
<rich:tabPanel switchType="ajax" valueChangeListener="changeTabs">
- <rich:tab label="Basic Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
+ <rich:tab id="structuredTab"
+ label="Basic Mode"
+ onlabelclick="cursor_wait();"
+ oncomplete="cursor_clear();">
<h:outputText value=" #{messages.nopermissionedit}"
rendered="#{!ResourceUIBean.permissions.configure}"/>
@@ -166,7 +169,7 @@ THIS TEXT WILL BE REMOVED.
<h:commandButton id="editStructuredButton"
value="Edit"
- action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}"
+ action="#{ExistingResourceConfigurationUIBean.editConfiguration}"
title="Edit this Configuration" styleClass="buttonmed"
rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
</h:panelGrid>
@@ -181,7 +184,10 @@ THIS TEXT WILL BE REMOVED.
prevalidate="true"/>
</rich:tab>
- <rich:tab label="Advanced Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
+ <rich:tab id="rawTab"
+ label="Advanced Mode"
+ onlabelclick="cursor_wait();"
+ oncomplete="cursor_clear();">
<h:outputText value=" #{messages.nopermissionedit}"
rendered="#{!ResourceUIBean.permissions.configure}"/>
@@ -192,7 +198,7 @@ THIS TEXT WILL BE REMOVED.
<h:commandButton id="editRawButton"
value="Edit"
- action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
+ action="#{ExistingResourceConfigurationUIBean.editRawConfiguration}"
title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
</h:panelGrid>
commit b5c9f6e8fc7f559757456bec29dcfe22893da1da
Merge: 7b13390... dc91b94...
Author: John Sanda <john(a)localhost.localdomain>
Date: Sun Jan 17 21:11:39 2010 -0500
Merge branch 'raw-config' of ssh://git.fedorahosted.org/git/rhq/rhq into raw-config
commit 7b13390ea02ba3c7c17ab164afe35e84a9257143
Author: John Sanda <john(a)localhost.localdomain>
Date: Sun Jan 17 20:52:56 2010 -0500
Fixing a bug that breaks translating from structured to raw
There has been a lingering bug in the UI bean code that appears to break translating from
structured to raw. An initial translation from structured to raw works fine. It happens on
subsequent translations.
The UI bean mantains a cache of modified raw config values. When translating from structured
to raw, the cache of modified values was not getting updated correctly. It was retaining
stale values. Then on the raw edit (Advanced) tab, when you select a file for editing that
has a property that was modified on structured side, the UI bean code first looks in the cache
of modified values. If the raw config file has a modified value in the cache, that value is
rendered. The problem though was that the cache had stale values and should have been getting
flushed when translating from structured to raw the translated values are now newer than
whats in the cache.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 3079b5c..bd53936 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -135,11 +135,15 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public String switchToRaw() {
+// Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration(
+// EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), true);
Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration(
- EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), true);
+ EnterpriseFacesContextUtility.getSubject(), getResourceId(), getConfiguration(), true);
setConfiguration(configuration);
+ getModified().clear();
+
for (RawConfiguration raw : configuration.getRawConfigurations()) {
getRaws().put(raw.getPath(), raw);
}
@@ -280,6 +284,10 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return getConfiguration();
}
+ public void undoEdit() {
+
+ }
+
public String discard() {
nullify();
return "/rhq/resource/configuration/view.xhtml?id=" + getResourceId();
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
index 9694bab..588c967 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
@@ -33,6 +33,8 @@ public class RawConfigUIBean {
private boolean modified;
+ private String modifiedContents;
+
public RawConfiguration getRawConfiguration() {
return rawConfiguration;
}
@@ -41,6 +43,14 @@ public class RawConfigUIBean {
this.rawConfiguration = rawConfiguration;
}
+ public String getModifiedContents() {
+ return modifiedContents;
+ }
+
+ public void setModifiedContents(String contents) {
+ modifiedContents = contents;
+ }
+
public boolean isModified() {
return modified;
}
commit dc91b941881b78569d0553011ddbd27b0cc66863
Author: Adam Young <ayoung(a)redhat.com>
Date: Fri Jan 15 16:19:56 2010 -0500
If an excpetion bypassed the catch block of the inner loop, there was no string builder allocated to build the error message.
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 aafea70..9b3cc55 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
@@ -380,6 +380,7 @@ public class ConfigurationManager extends AgentService implements ContainerServi
}
}
}catch(Throwable t){
+ errorMessage = new StringBuilder();
errorMessage.append("configuation validation failed with" + t.getMessage()+". " );
}
if (null != errorMessage){
diff --git a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
index 23af194..7c750d1 100644
--- a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
+++ b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
@@ -115,7 +115,7 @@ class RawServer implements ResourceComponent, ResourceConfigurationFacet {
void validateRawConfiguration(RawConfiguration rawConfiguration) {
def failValidation = resourceContext.pluginConfiguration.getSimple("failValidation")
if (failValidation.getBooleanValue()) {
- throw new RuntimeException("Validation failed for ${rawConfiguration.path}");
+ throw new IllegalArgumentException("Validation failed for ${rawConfiguration.path}");
}
}
commit 8a27dcdaaf7767ef8ecc3e31cbb772136f96c667
Author: Adam Young <ayoung(a)redhat.com>
Date: Fri Jan 15 15:19:57 2010 -0500
cleaned up exception handling.
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 a695616..aafea70 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
@@ -359,30 +359,33 @@ public class ConfigurationManager extends AgentService implements ContainerServi
}
public void validate(Configuration configuration, int resourceId, boolean isStructured)
- throws PluginContainerException {
+ throws PluginContainerException {
boolean daemonOnly = true;
boolean onlyIfStarted = true;
ResourceConfigurationFacet facet = componentService.getComponent(resourceId, ResourceConfigurationFacet.class,
- FacetLockType.READ, FACET_METHOD_TIMEOUT, daemonOnly, onlyIfStarted);
+ FacetLockType.READ, FACET_METHOD_TIMEOUT, daemonOnly, onlyIfStarted);
if (isStructured) {
return;
} else {
StringBuilder errorMessage = null;
-
- for (RawConfiguration rawConfiguration : configuration.getRawConfigurations()) {
- try {
- facet.validateRawConfiguration(rawConfiguration);
- } catch (Throwable e) {
- if (null == errorMessage){
- errorMessage = new StringBuilder();
+ try{
+ for (RawConfiguration rawConfiguration : configuration.getRawConfigurations()) {
+ try {
+ facet.validateRawConfiguration(rawConfiguration);
+ } catch (IllegalArgumentException e) {
+ if (null == errorMessage){
+ errorMessage = new StringBuilder();
+ }
+ errorMessage.append("file " + rawConfiguration.getPath() +" failed validation with " + e.getMessage()+". " );
+ }
+ }
+ }catch(Throwable t){
+ errorMessage.append("configuation validation failed with" + t.getMessage()+". " );
}
- errorMessage.append("file " + rawConfiguration.getPath() +" failed validation with " + e.getMessage()+". " );
-
- }
if (null != errorMessage){
throw new PluginContainerException(errorMessage.toString());
}
}
}
}
-}
+
commit d486f956042b24ba69363f97f938b5961513c957
Author: Adam Young <ayoung(a)redhat.com>
Date: Fri Jan 15 11:46:54 2010 -0500
changing the exception handling strategy for the validation code on the agent side.
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java
index 54a7d8d..b76b310 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java
@@ -44,6 +44,6 @@ public interface ResourceConfigurationFacet {
void validateStructuredConfiguration(Configuration configuration);
- void validateRawConfiguration(RawConfiguration rawConfiguration) throws RuntimeException;
+ void validateRawConfiguration(RawConfiguration rawConfiguration) throws IllegalArgumentException;
}
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 974055b..a695616 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
@@ -372,7 +372,7 @@ public class ConfigurationManager extends AgentService implements ContainerServi
for (RawConfiguration rawConfiguration : configuration.getRawConfigurations()) {
try {
facet.validateRawConfiguration(rawConfiguration);
- } catch (Exception e) {
+ } catch (Throwable e) {
if (null == errorMessage){
errorMessage = new StringBuilder();
}
commit edb2b662b18c00dbcb9aa8315c274131676decae
Author: Adam Young <ayoung(a)redhat.com>
Date: Thu Jan 14 21:20:19 2010 -0500
Cleaned up exception handling.
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 c0d0dac..974055b 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
@@ -85,17 +85,14 @@ public class ConfigurationManager extends AgentService implements ContainerServi
LoggingThreadFactory threadFactory = new LoggingThreadFactory(SENDER_THREAD_POOL_NAME, true);
threadPool = new ScheduledThreadPoolExecutor(1, threadFactory);
- ConfigurationCheckExecutor configurationChecker =
- new ConfigurationCheckExecutor(this, getConfigurationServerService(),
- PluginContainer.getInstance().getInventoryManager());
+ ConfigurationCheckExecutor configurationChecker = new ConfigurationCheckExecutor(this,
+ getConfigurationServerService(), PluginContainer.getInstance().getInventoryManager());
if (pluginContainerConfiguration.getConfigurationDiscoveryPeriod() > 0
- && pluginContainerConfiguration.isInsideAgent()) {
- threadPool.scheduleAtFixedRate(
- configurationChecker,
- pluginContainerConfiguration.getConfigurationDiscoveryInitialDelay(),
- pluginContainerConfiguration.getConfigurationDiscoveryPeriod(),
- TimeUnit.SECONDS);
+ && pluginContainerConfiguration.isInsideAgent()) {
+ threadPool.scheduleAtFixedRate(configurationChecker, pluginContainerConfiguration
+ .getConfigurationDiscoveryInitialDelay(), pluginContainerConfiguration
+ .getConfigurationDiscoveryPeriod(), TimeUnit.SECONDS);
}
}
@@ -154,8 +151,8 @@ public class ConfigurationManager extends AgentService implements ContainerServi
Callable<ConfigurationUpdateResponse> runner;
- runner = new UpdateResourceConfigurationRunner(configurationServerService, resourceType,
- configMgmt, request);
+ runner = new UpdateResourceConfigurationRunner(configurationServerService, resourceType, configMgmt,
+ request);
response = getThreadPool().submit(runner).get();
} catch (Exception e) {
@@ -178,8 +175,7 @@ public class ConfigurationManager extends AgentService implements ContainerServi
if (fromStructured) {
mergedStructuredIntoRaws(configuration, facet);
- }
- else {
+ } else {
mergeRawsIntoStructured(configuration, facet);
}
@@ -234,15 +230,13 @@ public class ConfigurationManager extends AgentService implements ContainerServi
}
}
- private void updateRawConfig(Configuration configuration, RawConfiguration originalRaw,
- RawConfiguration mergedRaw) {
+ private void updateRawConfig(Configuration configuration, RawConfiguration originalRaw, RawConfiguration mergedRaw) {
configuration.removeRawConfiguration(originalRaw);
configuration.addRawConfiguration(mergedRaw);
}
- public Configuration loadResourceConfiguration(int resourceId)
- throws PluginContainerException {
+ public Configuration loadResourceConfiguration(int resourceId) throws PluginContainerException {
ConfigManagement loadConfig = configMgmtFactory.getStrategy(resourceId);
Configuration configuration = null;
@@ -263,43 +257,43 @@ public class ConfigurationManager extends AgentService implements ContainerServi
private String createErrorMsg(int resourceId, String msg) throws PluginContainerException {
ResourceType resourceType = componentService.getResourceType(resourceId);
- return "Plugin Error: Resource Component for [" + resourceType.getName() + "] Resource with id [" +
- resourceId + "]: " + msg;
+ return "Plugin Error: Resource Component for [" + resourceType.getName() + "] Resource with id [" + resourceId
+ + "]: " + msg;
}
-// public Configuration loadResourceConfiguration(int resourceId) throws PluginContainerException {
-// ResourceType resourceType = getResourceType(resourceId);
-// ConfigurationFacet configComponent = getConfigurationFacet(resourceId, FacetLockType.READ);
-// try {
-// Configuration configuration = configComponent.loadResourceConfiguration();
-// if (configuration == null) {
-// throw new PluginContainerException("Plugin Error: Resource Component for [" + resourceType.getName()
-// + "] Resource with id [" + resourceId + "] returned a null Configuration.");
-// }
-//
-// // 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;
-// } catch (Throwable t) {
-// //noinspection ThrowableInstanceNeverThrown
-// throw new PluginContainerException("Cannot load Resource configuration for [" + resourceId + "]",
-// new WrappedRemotingException(t));
-// }
-// }
+ // public Configuration loadResourceConfiguration(int resourceId) throws PluginContainerException {
+ // ResourceType resourceType = getResourceType(resourceId);
+ // ConfigurationFacet configComponent = getConfigurationFacet(resourceId, FacetLockType.READ);
+ // try {
+ // Configuration configuration = configComponent.loadResourceConfiguration();
+ // if (configuration == null) {
+ // throw new PluginContainerException("Plugin Error: Resource Component for [" + resourceType.getName()
+ // + "] Resource with id [" + resourceId + "] returned a null Configuration.");
+ // }
+ //
+ // // 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;
+ // } catch (Throwable t) {
+ // //noinspection ThrowableInstanceNeverThrown
+ // throw new PluginContainerException("Cannot load Resource configuration for [" + resourceId + "]",
+ // new WrappedRemotingException(t));
+ // }
+ // }
/**
* Returns a thread pool that this object will use when asychronously executing configuration operations on a
@@ -333,7 +327,8 @@ public class ConfigurationManager extends AgentService implements ContainerServi
protected ConfigurationFacet getConfigurationFacet(int resourceId, FacetLockType lockType)
throws PluginContainerException {
boolean daemonThread = (lockType != FacetLockType.WRITE);
- return ComponentUtil.getComponent(resourceId, ConfigurationFacet.class, lockType, FACET_METHOD_TIMEOUT, daemonThread, true);
+ return ComponentUtil.getComponent(resourceId, ConfigurationFacet.class, lockType, FACET_METHOD_TIMEOUT,
+ daemonThread, true);
}
/**
@@ -372,12 +367,21 @@ public class ConfigurationManager extends AgentService implements ContainerServi
if (isStructured) {
return;
} else {
+ StringBuilder errorMessage = null;
+
for (RawConfiguration rawConfiguration : configuration.getRawConfigurations()) {
try {
facet.validateRawConfiguration(rawConfiguration);
- } catch (IllegalArgumentException e) {
- throw new PluginContainerException(e);
+ } catch (Exception e) {
+ if (null == errorMessage){
+ errorMessage = new StringBuilder();
+ }
+ errorMessage.append("file " + rawConfiguration.getPath() +" failed validation with " + e.getMessage()+". " );
+
}
+ if (null != errorMessage){
+ throw new PluginContainerException(errorMessage.toString());
+ }
}
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
index 2acf803..4248ad6 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
@@ -991,13 +991,12 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
if (isRawSupported(resourceId)){
try{
validateResourceConfiguration(subject, resourceId, newConfiguration,false);
- } catch(RuntimeException e){
+ } catch(PluginContainerException e){
ResourceConfigurationUpdate response = new ResourceConfigurationUpdate(null, newConfiguration, subject.getName());
response.setErrorMessage(e.getMessage());
+ response.setStatus(ConfigurationUpdateStatus.UNSENT);
return response;
- } catch (PluginContainerException e) {
- return null;
- }
+ }
}
ResourceConfigurationUpdate newUpdate =
commit ade23f1eb6eec8a22c7a846d7c70e22dace2e5f2
Author: Adam Young <ayoung(a)redhat.com>
Date: Thu Jan 14 13:56:06 2010 -0500
Validate prior to recording for Update.
diff --git a/.classpath b/.classpath
index c8e2a2d..e6c678b 100644
--- a/.classpath
+++ b/.classpath
@@ -114,7 +114,6 @@
<classpathentry kind="src" path="modules/plugins/byteman/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/lsof/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/jdbctrace/src/main/java"/>
- <classpathentry kind="src" path="modules/plugins/antlr-config/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/antlr-config/src/main/antlr3"/>
<classpathentry kind="src" path="modules/plugins/augeas/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/augeas/src/test/java"/>
@@ -217,9 +216,6 @@
<classpathentry exported="true" kind="var" path="M2_REPO/commons-codec/commons-codec/1.4/commons-codec-1.4.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/pircbot/pircbot/1.4.2/pircbot-1.4.2.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/net/homeip/yusuke/twitter4j/2.0.9/twitter4j-2.0.9.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.2.1/byteman-1.2.1.jar"/>
<classpathentry exported="true" kind="lib" path="modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-1.4.0-SNAPSHOT/wsconsume-output"/>
<classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs
index 8291766..10d36a9 100644
--- a/.settings/org.eclipse.jdt.ui.prefs
+++ b/.settings/org.eclipse.jdt.ui.prefs
@@ -1,4 +1,4 @@
-#Thu Nov 05 13:19:01 GMT-05:00 2009
+#Thu Jan 14 12:59:22 EST 2010
cleanup.add_default_serial_version_id=true
cleanup.add_generated_serial_version_id=false
cleanup.add_missing_annotations=true
@@ -52,7 +52,7 @@ cleanup.use_this_for_non_static_method_access_only_if_necessary=true
cleanup_profile=_RHQ
cleanup_settings_version=2
eclipse.preferences.version=1
-editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=false
formatter_profile=_RHQ
formatter_settings_version=11
org.eclipse.jdt.ui.exception.name=e
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationAgentService.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationAgentService.java
index 32a3dd4..c5ee507 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationAgentService.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationAgentService.java
@@ -98,4 +98,26 @@ public interface ConfigurationAgentService {
*/
Configuration merge(Configuration configuration, int resourceId, boolean fromStructured)
throws PluginContainerException;
+
+
+ /**
+ * If the <code>fromStructured</code> flag is <code>true</code>, then the s
+ * Configuration.properties</code>) is merged into the latest raw configura
+ * Configuration object returned will consist of the structured configurati
+ * configurations. If <code>fromStructured</code> is <code>false</code>, th
+ * Configuration.rawConfigurations</code>) is merged into the latest struct
+ * plugin. The returned Configuration will then consist of the raw configur
+ * configuration.
+ *
+ * @param configuration The Configuration with the changes to be merged
+ * @param resourceId The id of the resource to which the configuration belo
+ * @param A flag that if <code>true</code> indicates the Structured configu
+ * validates the raw
+ * @return The <strong>merged</strong> configuration, where a merge consist
+ * followed by the values of the side merging from being applied to the sid
+ * @throws PluginContainerException
+ * @throws PluginContainerException if a runtime or plugin error occurs.
+ */
+ void validate(Configuration configuration, int resourceId, boolean isStructured) throws PluginContainerException;
+
}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ConfigurationUpdateStatus.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ConfigurationUpdateStatus.java
index f8f01bc..d28327f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ConfigurationUpdateStatus.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ConfigurationUpdateStatus.java
@@ -30,7 +30,7 @@ package org.rhq.core.domain.configuration;
* @author John Mazzitelli
*/
public enum ConfigurationUpdateStatus {
- INPROGRESS("In Progress"), SUCCESS("Success"), FAILURE("Failure");
+ INPROGRESS("In Progress"), SUCCESS("Success"), FAILURE("Failure"),UNSENT("unsent");
private String displayName;
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java
index 4a14c67..54a7d8d 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java
@@ -44,6 +44,6 @@ public interface ResourceConfigurationFacet {
void validateStructuredConfiguration(Configuration configuration);
- void validateRawConfiguration(RawConfiguration rawConfiguration);
+ void validateRawConfiguration(RawConfiguration rawConfiguration) throws RuntimeException;
}
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 5a0e155..c0d0dac 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
@@ -362,4 +362,23 @@ public class ConfigurationManager extends AgentService implements ContainerServi
return null;
}
+
+ public void validate(Configuration configuration, int resourceId, boolean isStructured)
+ throws PluginContainerException {
+ boolean daemonOnly = true;
+ boolean onlyIfStarted = true;
+ ResourceConfigurationFacet facet = componentService.getComponent(resourceId, ResourceConfigurationFacet.class,
+ FacetLockType.READ, FACET_METHOD_TIMEOUT, daemonOnly, onlyIfStarted);
+ if (isStructured) {
+ return;
+ } else {
+ for (RawConfiguration rawConfiguration : configuration.getRawConfigurations()) {
+ try {
+ facet.validateRawConfiguration(rawConfiguration);
+ } catch (IllegalArgumentException e) {
+ throw new PluginContainerException(e);
+ }
+ }
+ }
+ }
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 3079b5c..244d19b 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -199,7 +199,11 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Configuration update request with id "
+ updateRequest.getId() + " failed.", updateRequest.getErrorMessage());
return FAILURE_OUTCOME;
- }
+ case UNSENT:
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Configuration update was not valid"
+ , updateRequest.getErrorMessage());
+ return FAILURE_OUTCOME;
+ }
} else {
FacesContextUtility.addMessage(FacesMessage.SEVERITY_WARN, "No changes were made to the configuration, so "
+ "no update request has been sent to the Agent.");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
index fbae47d..2acf803 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
@@ -988,14 +988,46 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
fromStructured);
}
+ if (isRawSupported(resourceId)){
+ try{
+ validateResourceConfiguration(subject, resourceId, newConfiguration,false);
+ } catch(RuntimeException e){
+ ResourceConfigurationUpdate response = new ResourceConfigurationUpdate(null, newConfiguration, subject.getName());
+ response.setErrorMessage(e.getMessage());
+ return response;
+ } catch (PluginContainerException e) {
+ return null;
+ }
+ }
+
ResourceConfigurationUpdate newUpdate =
configurationManager.persistNewResourceConfigurationUpdateHistory(subject, resourceId, configToUpdate,
ConfigurationUpdateStatus.INPROGRESS, subject.getName(), false);
-
executeResourceConfigurationUpdate(newUpdate, fromStructured);
-
return newUpdate;
}
+ private void validateResourceConfiguration(Subject subject, int resourceId, Configuration configuration,boolean isStructured) throws PluginContainerException {
+ Resource resource = entityManager.find(Resource.class, resourceId);
+ if (resource == null) {
+ throw new NoResultException("Cannot get live configuration for unknown resource [" + resourceId + "]");
+ }
+ if (!authorizationManager.canViewResource(subject, resource.getId())) {
+ throw new PermissionException("User [" + subject.getName()
+ + "] does not have permission to view resource configuration for [" + resource + "]");
+ }
+ Agent agent = resource.getAgent();
+ AgentClient agentClient = this.agentManager.getAgentClient(agent);
+ ConfigurationAgentService configService = agentClient.getConfigurationAgentService();
+ configService.validate(configuration, resourceId, isStructured);
+ }
+
+ private boolean isRawSupported(int resourceId) {
+ Resource resource = entityManager.find(Resource.class, resourceId);
+ ConfigurationDefinition configDef = resource.getResourceType().getResourceConfigurationDefinition();
+
+ return (ConfigurationFormat.STRUCTURED_AND_RAW == configDef.getConfigurationFormat() || (ConfigurationFormat.RAW == configDef.getConfigurationFormat()));
+ }
+
private boolean isStructuredAndRawSupported(int resourceId) {
Resource resource = entityManager.find(Resource.class, resourceId);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java
index 77bf269..9281e14 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java
@@ -1153,5 +1153,8 @@ public class ConfigurationManagerBeanTest extends AbstractEJB3Test {
@Asynchronous(guaranteedDelivery = true)
public void synchronizeInventory(ResourceSyncInfo syncInfo) {
}
+ public void validate(Configuration configuration, int resourceId, boolean isStructured)
+ throws PluginContainerException {
+ }
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
index 56b6741..2c13eb6 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
@@ -254,4 +254,8 @@ public class TestAgentClient implements AgentClient, ContentAgentService, Resour
public InputStream getSnapshotReport(int resourceId, String name, String description) throws Exception {
return null;
}
-}
\ No newline at end of file
+
+ public void validate(Configuration configuration, int resourceId, boolean isStructured)
+ throws PluginContainerException {
+ }
+}
commit 9f214af77b6bdcf02c0353dd8b6e4e6a24416e06
Author: John Sanda <john(a)localhost.localdomain>
Date: Fri Jan 15 00:49:12 2010 -0500
Adding logic to display an 'undo' button next to files in the file menu that have modifications
The undo button is not yet wired to an action method with this commit.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 2e9b517..36effa3 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -75,7 +75,14 @@ THIS TEXT WILL BE REMOVED.
onclick="cursor_wait();"
oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
- reRender="fileContents,selectedFileHeader,modalEditor,fileMenu"/>
+ reRender="fileContents,selectedFileHeader,modalEditor,fileMenu">
+ <h:panelGroup>
+ <h:outputText value="#{#rawConfigUIBean.fileName}"/>
+ <c:if test="#{rawConfigUIBean.modified}">
+ <h:commandButton value="Undo"/>
+ </c:if>
+ </h:panelGroup>
+ </rich:panelMenuItem>
</c:forEach>
</rich:panelMenuGroup>
</c:forEach>
@@ -200,7 +207,14 @@ THIS TEXT WILL BE REMOVED.
oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
limitToList="true"
- reRender="fileContents,selectedFileHeader,modalEditor,fileMenu"/>
+ reRender="fileContents,selectedFileHeader,modalEditor,fileMenu">
+ <h:panelGroup>
+ <h:outputText value="#{#rawConfigUIBean.fileName}"/>
+ <c:if test="#{rawConfigUIBean.modified}">
+ <h:commandButton value="Undo"/>
+ </c:if>
+ </h:panelGroup>
+ </rich:panelMenuItem>
</c:forEach>
</rich:panelMenuGroup>
</c:forEach>
commit 2e98f67f8ab7fcec4133cd31853fcdfdc699851b
Author: John Sanda <john(a)localhost.localdomain>
Date: Fri Jan 15 00:26:03 2010 -0500
Updating file menu to display icon next to file that has been modified in the file menu.
Previously one of the default icons was always being displayed next to files in the file
menu. Now an icon is rendered only when the file has modifications and you switch to a
different file in the editor.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 40d5ba1..3079b5c 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -420,11 +420,23 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
if (!updated.equals(original)) {
current = current.deepCopy(false);
current.setContents(updated.getBytes());
- //TODO update other values like MD5
+
+ markCurrentRawConfigUIBeanModified();
getModified().put(current.getPath(), current);
}
}
+ private void markCurrentRawConfigUIBeanModified() {
+ for (RawConfigDirectory dir : rawConfigDirectories) {
+ for (RawConfigUIBean bean : dir.getRawConfigUIBeans()) {
+ if (bean.getPath().equals(current.getPath())) {
+ bean.setModified(true);
+ return;
+ }
+ }
+ }
+ }
+
public void setCurrentPath(String path) {
RawConfiguration raw = getModified().get(path);
if (null == raw) {
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
index 21b7d41..9694bab 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
@@ -57,4 +57,12 @@ public class RawConfigUIBean {
File file = new File(rawConfiguration.getPath());
return file.getName();
}
+
+ public String getIcon() {
+ if (isModified()) {
+ return "/images/star_on_24.png";
+ }
+
+ return "/images/blank.png";
+ }
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index bf146f8..2e9b517 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -59,12 +59,11 @@ THIS TEXT WILL BE REMOVED.
<rich:panel style="width:100%">
<f:facet name="header">Files</f:facet>
- <rich:panelMenu mode="ajax"
+ <rich:panelMenu id="fileMenu"
+ mode="ajax"
expandMode="client"
iconCollapsedGroup="/images/icn_tree_folder.gif"
- iconExpandedGroup="/images/icn_tree_folder.gif"
- limitToList="true"
- reRender="fileContents">
+ iconExpandedGroup="/images/icn_tree_folder.gif">
<c:forEach items="#{rawConfigDirectories}"
var="rawConfigDir">
<rich:panelMenuGroup label="#{rawConfigDir.path}"
@@ -72,16 +71,20 @@ THIS TEXT WILL BE REMOVED.
selectedChild="#{ExistingResourceConfigurationUIBean.currentPath}">
<c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
<rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
+ icon="#{rawConfigUIBean.icon}"
onclick="cursor_wait();"
oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
- reRender="fileContents,selectedFileHeader,modalEditor"/>
+ reRender="fileContents,selectedFileHeader,modalEditor,fileMenu"/>
</c:forEach>
</rich:panelMenuGroup>
</c:forEach>
</rich:panelMenu>
</rich:panel>
- * - Contains uncommitted changes
+ <rich:panel style="border:none">
+ <h:graphicImage url="/images/star_on_24.png"/>
+ <h:outputText value="- Contains uncommitted changes"/>
+ </rich:panel>
</h:panelGrid>
<h:panelGrid columns="1" style="width:100%;">
@@ -180,7 +183,8 @@ THIS TEXT WILL BE REMOVED.
<f:facet name="header">Files</f:facet>
- <rich:panelMenu mode="ajax"
+ <rich:panelMenu id="fileMenu"
+ mode="ajax"
expandMode="client"
iconCollapsedGroup="/images/icn_tree_folder.gif"
iconExpandedGroup="/images/icn_tree_folder.gif">
@@ -191,17 +195,21 @@ THIS TEXT WILL BE REMOVED.
selectedChild="#{ExistingResourceConfigurationUIBean.currentPath}">
<c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
<rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
+ icon="#{rawConfigUIBean.icon}"
onclick="cursor_wait();"
oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
limitToList="true"
- reRender="fileContents,selectedFileHeader,modalEditor"/>
+ reRender="fileContents,selectedFileHeader,modalEditor,fileMenu"/>
</c:forEach>
</rich:panelMenuGroup>
</c:forEach>
</rich:panelMenu>
</rich:panel>
- * - Contains uncommitted changes
+ <rich:panel style="border:none">
+ <h:graphicImage url="/images/star_on_24.png"/>
+ <h:outputText value="- Contains uncommitted changes"/>
+ </rich:panel>
</h:panelGrid>
<h:panelGrid columns="1" style="width:100%;">
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index ce5f228..7d3bc58 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -86,6 +86,7 @@ THIS TEXT WILL BE REMOVED.
selectedChild="#{currentPath}">
<c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
<rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
+ icon="/images/blank.png"
onclick="cursor_wait();"
oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationViewUIBean.select(rawConfigUIBean.path)}"
commit 56e8acf16cf81a654a0144a0bb3f520e9541d70d
Merge: 7020f5a... e45b2f8...
Author: Adam Young <ayoung(a)redhat.com>
Date: Thu Jan 14 21:26:55 2010 -0500
Merge branch 'raw-config' of ssh://git.fedorahosted.org/git/rhq/rhq into raw-config-confirm
commit 7020f5a959eb4ba055352a6dbd14382fc5cdabea
Author: Adam Young <ayoung(a)redhat.com>
Date: Thu Jan 14 21:20:19 2010 -0500
Cleaned up exception handling.
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 c0d0dac..974055b 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
@@ -85,17 +85,14 @@ public class ConfigurationManager extends AgentService implements ContainerServi
LoggingThreadFactory threadFactory = new LoggingThreadFactory(SENDER_THREAD_POOL_NAME, true);
threadPool = new ScheduledThreadPoolExecutor(1, threadFactory);
- ConfigurationCheckExecutor configurationChecker =
- new ConfigurationCheckExecutor(this, getConfigurationServerService(),
- PluginContainer.getInstance().getInventoryManager());
+ ConfigurationCheckExecutor configurationChecker = new ConfigurationCheckExecutor(this,
+ getConfigurationServerService(), PluginContainer.getInstance().getInventoryManager());
if (pluginContainerConfiguration.getConfigurationDiscoveryPeriod() > 0
- && pluginContainerConfiguration.isInsideAgent()) {
- threadPool.scheduleAtFixedRate(
- configurationChecker,
- pluginContainerConfiguration.getConfigurationDiscoveryInitialDelay(),
- pluginContainerConfiguration.getConfigurationDiscoveryPeriod(),
- TimeUnit.SECONDS);
+ && pluginContainerConfiguration.isInsideAgent()) {
+ threadPool.scheduleAtFixedRate(configurationChecker, pluginContainerConfiguration
+ .getConfigurationDiscoveryInitialDelay(), pluginContainerConfiguration
+ .getConfigurationDiscoveryPeriod(), TimeUnit.SECONDS);
}
}
@@ -154,8 +151,8 @@ public class ConfigurationManager extends AgentService implements ContainerServi
Callable<ConfigurationUpdateResponse> runner;
- runner = new UpdateResourceConfigurationRunner(configurationServerService, resourceType,
- configMgmt, request);
+ runner = new UpdateResourceConfigurationRunner(configurationServerService, resourceType, configMgmt,
+ request);
response = getThreadPool().submit(runner).get();
} catch (Exception e) {
@@ -178,8 +175,7 @@ public class ConfigurationManager extends AgentService implements ContainerServi
if (fromStructured) {
mergedStructuredIntoRaws(configuration, facet);
- }
- else {
+ } else {
mergeRawsIntoStructured(configuration, facet);
}
@@ -234,15 +230,13 @@ public class ConfigurationManager extends AgentService implements ContainerServi
}
}
- private void updateRawConfig(Configuration configuration, RawConfiguration originalRaw,
- RawConfiguration mergedRaw) {
+ private void updateRawConfig(Configuration configuration, RawConfiguration originalRaw, RawConfiguration mergedRaw) {
configuration.removeRawConfiguration(originalRaw);
configuration.addRawConfiguration(mergedRaw);
}
- public Configuration loadResourceConfiguration(int resourceId)
- throws PluginContainerException {
+ public Configuration loadResourceConfiguration(int resourceId) throws PluginContainerException {
ConfigManagement loadConfig = configMgmtFactory.getStrategy(resourceId);
Configuration configuration = null;
@@ -263,43 +257,43 @@ public class ConfigurationManager extends AgentService implements ContainerServi
private String createErrorMsg(int resourceId, String msg) throws PluginContainerException {
ResourceType resourceType = componentService.getResourceType(resourceId);
- return "Plugin Error: Resource Component for [" + resourceType.getName() + "] Resource with id [" +
- resourceId + "]: " + msg;
+ return "Plugin Error: Resource Component for [" + resourceType.getName() + "] Resource with id [" + resourceId
+ + "]: " + msg;
}
-// public Configuration loadResourceConfiguration(int resourceId) throws PluginContainerException {
-// ResourceType resourceType = getResourceType(resourceId);
-// ConfigurationFacet configComponent = getConfigurationFacet(resourceId, FacetLockType.READ);
-// try {
-// Configuration configuration = configComponent.loadResourceConfiguration();
-// if (configuration == null) {
-// throw new PluginContainerException("Plugin Error: Resource Component for [" + resourceType.getName()
-// + "] Resource with id [" + resourceId + "] returned a null Configuration.");
-// }
-//
-// // 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;
-// } catch (Throwable t) {
-// //noinspection ThrowableInstanceNeverThrown
-// throw new PluginContainerException("Cannot load Resource configuration for [" + resourceId + "]",
-// new WrappedRemotingException(t));
-// }
-// }
+ // public Configuration loadResourceConfiguration(int resourceId) throws PluginContainerException {
+ // ResourceType resourceType = getResourceType(resourceId);
+ // ConfigurationFacet configComponent = getConfigurationFacet(resourceId, FacetLockType.READ);
+ // try {
+ // Configuration configuration = configComponent.loadResourceConfiguration();
+ // if (configuration == null) {
+ // throw new PluginContainerException("Plugin Error: Resource Component for [" + resourceType.getName()
+ // + "] Resource with id [" + resourceId + "] returned a null Configuration.");
+ // }
+ //
+ // // 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;
+ // } catch (Throwable t) {
+ // //noinspection ThrowableInstanceNeverThrown
+ // throw new PluginContainerException("Cannot load Resource configuration for [" + resourceId + "]",
+ // new WrappedRemotingException(t));
+ // }
+ // }
/**
* Returns a thread pool that this object will use when asychronously executing configuration operations on a
@@ -333,7 +327,8 @@ public class ConfigurationManager extends AgentService implements ContainerServi
protected ConfigurationFacet getConfigurationFacet(int resourceId, FacetLockType lockType)
throws PluginContainerException {
boolean daemonThread = (lockType != FacetLockType.WRITE);
- return ComponentUtil.getComponent(resourceId, ConfigurationFacet.class, lockType, FACET_METHOD_TIMEOUT, daemonThread, true);
+ return ComponentUtil.getComponent(resourceId, ConfigurationFacet.class, lockType, FACET_METHOD_TIMEOUT,
+ daemonThread, true);
}
/**
@@ -372,12 +367,21 @@ public class ConfigurationManager extends AgentService implements ContainerServi
if (isStructured) {
return;
} else {
+ StringBuilder errorMessage = null;
+
for (RawConfiguration rawConfiguration : configuration.getRawConfigurations()) {
try {
facet.validateRawConfiguration(rawConfiguration);
- } catch (IllegalArgumentException e) {
- throw new PluginContainerException(e);
+ } catch (Exception e) {
+ if (null == errorMessage){
+ errorMessage = new StringBuilder();
+ }
+ errorMessage.append("file " + rawConfiguration.getPath() +" failed validation with " + e.getMessage()+". " );
+
}
+ if (null != errorMessage){
+ throw new PluginContainerException(errorMessage.toString());
+ }
}
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
index 2acf803..4248ad6 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
@@ -991,13 +991,12 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
if (isRawSupported(resourceId)){
try{
validateResourceConfiguration(subject, resourceId, newConfiguration,false);
- } catch(RuntimeException e){
+ } catch(PluginContainerException e){
ResourceConfigurationUpdate response = new ResourceConfigurationUpdate(null, newConfiguration, subject.getName());
response.setErrorMessage(e.getMessage());
+ response.setStatus(ConfigurationUpdateStatus.UNSENT);
return response;
- } catch (PluginContainerException e) {
- return null;
- }
+ }
}
ResourceConfigurationUpdate newUpdate =
commit e45b2f8bff457bb665ae6713e93b26f9d326f520
Author: John Sanda <john(a)localhost.localdomain>
Date: Thu Jan 14 20:59:18 2010 -0500
Updating modal dialog editor to display the correct header and contents after a file selection
The modal dialog change has been made only for the edit page so far. On view.xhtml the modal editor
still does not get updated because it is referencing the wrong backing bean.
Adding folder icon for directories in the file menu.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 2f48509..40d5ba1 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -338,6 +338,10 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return getCurrent().getPath();
}
+ public String getModalEditorHeader() {
+ return getCurrentPath();
+ }
+
public String getModalEditorContents() {
return getCurrentContents();
}
@@ -353,6 +357,7 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public Object[] getPaths() {
+
return getRaws().keySet().toArray();
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 4ff5b06..bf146f8 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -55,12 +55,14 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="2"
styleClass="raw-outer-table"
columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
+ <h:panelGrid columns="1">
<rich:panel style="width:100%">
<f:facet name="header">Files</f:facet>
<rich:panelMenu mode="ajax"
expandMode="client"
- iconCollapsedGroup="disc"
+ iconCollapsedGroup="/images/icn_tree_folder.gif"
+ iconExpandedGroup="/images/icn_tree_folder.gif"
limitToList="true"
reRender="fileContents">
<c:forEach items="#{rawConfigDirectories}"
@@ -79,6 +81,8 @@ THIS TEXT WILL BE REMOVED.
</c:forEach>
</rich:panelMenu>
</rich:panel>
+ * - Contains uncommitted changes
+ </h:panelGrid>
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
@@ -116,6 +120,7 @@ THIS TEXT WILL BE REMOVED.
</h:panelGrid>
</rich:tab>
</rich:tabPanel>
+ <ui:include src="view-raw-modal.xhtml"/>
</c:when>
<c:when test="${ExistingResourceConfigurationUIBean.structuredSupported}">
@@ -170,13 +175,15 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="2"
styleClass="raw-outer-table"
columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
+ <h:panelGrid columns="1">
<rich:panel style="width:100%">
<f:facet name="header">Files</f:facet>
<rich:panelMenu mode="ajax"
expandMode="client"
- iconCollapsedGroup="disc">
+ iconCollapsedGroup="/images/icn_tree_folder.gif"
+ iconExpandedGroup="/images/icn_tree_folder.gif">
<c:forEach items="#{rawConfigDirectories}"
var="rawConfigDir">
<rich:panelMenuGroup label="#{rawConfigDir.path}"
@@ -194,6 +201,8 @@ THIS TEXT WILL BE REMOVED.
</c:forEach>
</rich:panelMenu>
</rich:panel>
+ * - Contains uncommitted changes
+ </h:panelGrid>
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
@@ -229,15 +238,13 @@ THIS TEXT WILL BE REMOVED.
</h:panelGrid>
</h:panelGrid>
</h:panelGrid>
-
- <ui:include src="view-raw-modal.xhtml"/>
</rich:tab>
</rich:tabPanel>
+
+ <ui:include src="view-raw-modal.xhtml"/>
</c:when>
</c:choose>
-
-
</h:form>
<h:panelGroup layout="block" styleClass="InfoBlock"
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
index 8aed4f3..8d8b046 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
@@ -12,7 +12,7 @@
<rich:modalPanel id="modalEditor" width="800" height="600">
<f:facet name="header">
<h:panelGroup>
- <h:outputText value="#{ExistingResourceConfiguratioUIBean.currentPath}"/>
+ <h:outputText value="#{ExistingResourceConfigurationUIBean.modalEditorHeader}"/>
</h:panelGroup>
</f:facet>
<f:facet name="controls">
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 8e605da..ce5f228 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -75,7 +75,8 @@ THIS TEXT WILL BE REMOVED.
<f:facet name="header">Files</f:facet>
<rich:panelMenu mode="ajax"
expandMode="client"
- iconCollapsedGroup="disc"
+ iconCollapsedGroup="/images/icn_tree_folder.gif"
+ iconExpandedGroup="/images/icn_tree_folder.gif"
limitToList="true"
reRender="fileContents">
<c:forEach items="#{rawConfigDirectories}"
@@ -120,6 +121,7 @@ THIS TEXT WILL BE REMOVED.
</h:panelGrid>
</rich:tab>
</rich:tabPanel>
+ <ui:include src="view-raw-modal.xhtml"/>
</c:when>
<c:when test="${ExistingResourceConfigurationViewUIBean.structuredSupported}">
@@ -201,7 +203,8 @@ THIS TEXT WILL BE REMOVED.
<f:facet name="header">Files</f:facet>
<rich:panelMenu mode="ajax"
expandMode="client"
- iconCollapsedGroup="disc"
+ iconCollapsedGroup="/images/icn_tree_folder.gif"
+ iconExpandedGroup="/images/icn_tree_folder.gif"
limitToList="true"
reRender="fileContents">
<c:forEach items="#{rawConfigDirectories}"
@@ -219,7 +222,7 @@ THIS TEXT WILL BE REMOVED.
</rich:panelMenuGroup>
</c:forEach>
</rich:panelMenu>
- </rich:panel>
+ </rich:panel>
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
@@ -244,15 +247,11 @@ THIS TEXT WILL BE REMOVED.
</rich:panel>
</h:panelGrid>
</h:panelGrid>
-
- <ui:include src="view-raw-modal.xhtml"/>
</rich:tab>
</rich:tabPanel>
+ <ui:include src="view-raw-modal.xhtml"/>
</c:when>
</c:choose>
-
-
-
</h:form>
<h:panelGroup layout="block" styleClass="InfoBlock"
commit 0301452395f085420fd7904cec31e1b7b487e2d6
Merge: 4192ecb... e2f84e3...
Author: Adam Young <ayoung(a)redhat.com>
Date: Thu Jan 14 14:39:57 2010 -0500
Merge branch 'raw-config' of ssh://git.fedorahosted.org/git/rhq/rhq into raw-config-confirm
commit 4192ecb358067c1fd49ba2557b29763ce97ef63f
Author: Adam Young <ayoung(a)redhat.com>
Date: Thu Jan 14 13:56:06 2010 -0500
Validate prior to recording for Update.
diff --git a/.classpath b/.classpath
index c8e2a2d..e6c678b 100644
--- a/.classpath
+++ b/.classpath
@@ -114,7 +114,6 @@
<classpathentry kind="src" path="modules/plugins/byteman/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/lsof/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/jdbctrace/src/main/java"/>
- <classpathentry kind="src" path="modules/plugins/antlr-config/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/antlr-config/src/main/antlr3"/>
<classpathentry kind="src" path="modules/plugins/augeas/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/augeas/src/test/java"/>
@@ -217,9 +216,6 @@
<classpathentry exported="true" kind="var" path="M2_REPO/commons-codec/commons-codec/1.4/commons-codec-1.4.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/pircbot/pircbot/1.4.2/pircbot-1.4.2.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/net/homeip/yusuke/twitter4j/2.0.9/twitter4j-2.0.9.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.2.1/byteman-1.2.1.jar"/>
<classpathentry exported="true" kind="lib" path="modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-1.4.0-SNAPSHOT/wsconsume-output"/>
<classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs
index 8291766..10d36a9 100644
--- a/.settings/org.eclipse.jdt.ui.prefs
+++ b/.settings/org.eclipse.jdt.ui.prefs
@@ -1,4 +1,4 @@
-#Thu Nov 05 13:19:01 GMT-05:00 2009
+#Thu Jan 14 12:59:22 EST 2010
cleanup.add_default_serial_version_id=true
cleanup.add_generated_serial_version_id=false
cleanup.add_missing_annotations=true
@@ -52,7 +52,7 @@ cleanup.use_this_for_non_static_method_access_only_if_necessary=true
cleanup_profile=_RHQ
cleanup_settings_version=2
eclipse.preferences.version=1
-editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=false
formatter_profile=_RHQ
formatter_settings_version=11
org.eclipse.jdt.ui.exception.name=e
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationAgentService.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationAgentService.java
index 32a3dd4..c5ee507 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationAgentService.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationAgentService.java
@@ -98,4 +98,26 @@ public interface ConfigurationAgentService {
*/
Configuration merge(Configuration configuration, int resourceId, boolean fromStructured)
throws PluginContainerException;
+
+
+ /**
+ * If the <code>fromStructured</code> flag is <code>true</code>, then the s
+ * Configuration.properties</code>) is merged into the latest raw configura
+ * Configuration object returned will consist of the structured configurati
+ * configurations. If <code>fromStructured</code> is <code>false</code>, th
+ * Configuration.rawConfigurations</code>) is merged into the latest struct
+ * plugin. The returned Configuration will then consist of the raw configur
+ * configuration.
+ *
+ * @param configuration The Configuration with the changes to be merged
+ * @param resourceId The id of the resource to which the configuration belo
+ * @param A flag that if <code>true</code> indicates the Structured configu
+ * validates the raw
+ * @return The <strong>merged</strong> configuration, where a merge consist
+ * followed by the values of the side merging from being applied to the sid
+ * @throws PluginContainerException
+ * @throws PluginContainerException if a runtime or plugin error occurs.
+ */
+ void validate(Configuration configuration, int resourceId, boolean isStructured) throws PluginContainerException;
+
}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ConfigurationUpdateStatus.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ConfigurationUpdateStatus.java
index f8f01bc..d28327f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ConfigurationUpdateStatus.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/ConfigurationUpdateStatus.java
@@ -30,7 +30,7 @@ package org.rhq.core.domain.configuration;
* @author John Mazzitelli
*/
public enum ConfigurationUpdateStatus {
- INPROGRESS("In Progress"), SUCCESS("Success"), FAILURE("Failure");
+ INPROGRESS("In Progress"), SUCCESS("Success"), FAILURE("Failure"),UNSENT("unsent");
private String displayName;
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java
index 4a14c67..54a7d8d 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationFacet.java
@@ -44,6 +44,6 @@ public interface ResourceConfigurationFacet {
void validateStructuredConfiguration(Configuration configuration);
- void validateRawConfiguration(RawConfiguration rawConfiguration);
+ void validateRawConfiguration(RawConfiguration rawConfiguration) throws RuntimeException;
}
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 5a0e155..c0d0dac 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
@@ -362,4 +362,23 @@ public class ConfigurationManager extends AgentService implements ContainerServi
return null;
}
+
+ public void validate(Configuration configuration, int resourceId, boolean isStructured)
+ throws PluginContainerException {
+ boolean daemonOnly = true;
+ boolean onlyIfStarted = true;
+ ResourceConfigurationFacet facet = componentService.getComponent(resourceId, ResourceConfigurationFacet.class,
+ FacetLockType.READ, FACET_METHOD_TIMEOUT, daemonOnly, onlyIfStarted);
+ if (isStructured) {
+ return;
+ } else {
+ for (RawConfiguration rawConfiguration : configuration.getRawConfigurations()) {
+ try {
+ facet.validateRawConfiguration(rawConfiguration);
+ } catch (IllegalArgumentException e) {
+ throw new PluginContainerException(e);
+ }
+ }
+ }
+ }
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 971d581..59b7f68 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -193,7 +193,11 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Configuration update request with id "
+ updateRequest.getId() + " failed.", updateRequest.getErrorMessage());
return FAILURE_OUTCOME;
- }
+ case UNSENT:
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Configuration update was not valid"
+ , updateRequest.getErrorMessage());
+ return FAILURE_OUTCOME;
+ }
} else {
FacesContextUtility.addMessage(FacesMessage.SEVERITY_WARN, "No changes were made to the configuration, so "
+ "no update request has been sent to the Agent.");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
index fbae47d..2acf803 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
@@ -988,14 +988,46 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
fromStructured);
}
+ if (isRawSupported(resourceId)){
+ try{
+ validateResourceConfiguration(subject, resourceId, newConfiguration,false);
+ } catch(RuntimeException e){
+ ResourceConfigurationUpdate response = new ResourceConfigurationUpdate(null, newConfiguration, subject.getName());
+ response.setErrorMessage(e.getMessage());
+ return response;
+ } catch (PluginContainerException e) {
+ return null;
+ }
+ }
+
ResourceConfigurationUpdate newUpdate =
configurationManager.persistNewResourceConfigurationUpdateHistory(subject, resourceId, configToUpdate,
ConfigurationUpdateStatus.INPROGRESS, subject.getName(), false);
-
executeResourceConfigurationUpdate(newUpdate, fromStructured);
-
return newUpdate;
}
+ private void validateResourceConfiguration(Subject subject, int resourceId, Configuration configuration,boolean isStructured) throws PluginContainerException {
+ Resource resource = entityManager.find(Resource.class, resourceId);
+ if (resource == null) {
+ throw new NoResultException("Cannot get live configuration for unknown resource [" + resourceId + "]");
+ }
+ if (!authorizationManager.canViewResource(subject, resource.getId())) {
+ throw new PermissionException("User [" + subject.getName()
+ + "] does not have permission to view resource configuration for [" + resource + "]");
+ }
+ Agent agent = resource.getAgent();
+ AgentClient agentClient = this.agentManager.getAgentClient(agent);
+ ConfigurationAgentService configService = agentClient.getConfigurationAgentService();
+ configService.validate(configuration, resourceId, isStructured);
+ }
+
+ private boolean isRawSupported(int resourceId) {
+ Resource resource = entityManager.find(Resource.class, resourceId);
+ ConfigurationDefinition configDef = resource.getResourceType().getResourceConfigurationDefinition();
+
+ return (ConfigurationFormat.STRUCTURED_AND_RAW == configDef.getConfigurationFormat() || (ConfigurationFormat.RAW == configDef.getConfigurationFormat()));
+ }
+
private boolean isStructuredAndRawSupported(int resourceId) {
Resource resource = entityManager.find(Resource.class, resourceId);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java
index 77bf269..9281e14 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java
@@ -1153,5 +1153,8 @@ public class ConfigurationManagerBeanTest extends AbstractEJB3Test {
@Asynchronous(guaranteedDelivery = true)
public void synchronizeInventory(ResourceSyncInfo syncInfo) {
}
+ public void validate(Configuration configuration, int resourceId, boolean isStructured)
+ throws PluginContainerException {
+ }
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
index 56b6741..2c13eb6 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
@@ -254,4 +254,8 @@ public class TestAgentClient implements AgentClient, ContentAgentService, Resour
public InputStream getSnapshotReport(int resourceId, String name, String description) throws Exception {
return null;
}
-}
\ No newline at end of file
+
+ public void validate(Configuration configuration, int resourceId, boolean isStructured)
+ throws PluginContainerException {
+ }
+}
commit e2f84e3cf31ca90530a297222e05591250a98cb7
Author: John Sanda <john(a)localhost.localdomain>
Date: Thu Jan 14 10:59:25 2010 -0500
Adding logic to properly initialize the rawConfigDirectories property in the UI backing bean.
The rawConfigDirectories property is only used for configs that support raw so a check needed to be
added to only initialize it if raw is supported. Previously we were attempting to always
initialize it, and when raw was not supported it caused a NPE. When raw is not supported it
gets initialized to an empty collection since it is annotated with @Out and Seam will not
allow an @Out to be null.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 971d581..2f48509 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -23,6 +23,7 @@ import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -83,7 +84,12 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
@Create
public void begin() {
- initConfigDirectories();
+ if (isRawSupported() || isStructuredAndRawSupported()) {
+ initConfigDirectories();
+ }
+ else {
+ rawConfigDirectories = Collections.EMPTY_LIST;
+ }
}
private void initConfigDirectories() {
commit 04c56bcb72c98e43cd94fbabc790991f7f42a62d
Author: John Sanda <john(a)localhost.localdomain>
Date: Thu Jan 14 08:54:48 2010 -0500
Fixing another translation/file selection issue in which modifications were getting overwritten
A backing bean being property, currentContents was being references in view-raw-moal.xhtml and it's
older, non-updated value was overwriting the modified value. This was happening because different
components were referencing the same backing bean property.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 3a81c03..971d581 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -332,6 +332,13 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return getCurrent().getPath();
}
+ public String getModalEditorContents() {
+ return getCurrentContents();
+ }
+
+ public void setModalEditorContents(String contents) {
+ }
+
public TreeMap<String, RawConfiguration> getModified() {
if (modified == null) {
modified = new TreeMap<String, RawConfiguration>();
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index ea3fe76..4ff5b06 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -229,12 +229,14 @@ THIS TEXT WILL BE REMOVED.
</h:panelGrid>
</h:panelGrid>
</h:panelGrid>
+
+ <ui:include src="view-raw-modal.xhtml"/>
</rich:tab>
</rich:tabPanel>
</c:when>
</c:choose>
- <ui:include src="view-raw-modal.xhtml"/>
+
</h:form>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
index f0e8b25..8aed4f3 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
@@ -26,7 +26,7 @@
style="width:100%; height:100%; overflow:visible;"
rows="30"
cols="30"
- value="#{ExistingResourceConfigurationUIBean.currentContents}"
+ value="#{ExistingResourceConfigurationUIBean.modalEditorContents}"
readonly="false"/>
</rich:panel>
</rich:modalPanel>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 6e68e0c..8e605da 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -244,12 +244,14 @@ THIS TEXT WILL BE REMOVED.
</rich:panel>
</h:panelGrid>
</h:panelGrid>
+
+ <ui:include src="view-raw-modal.xhtml"/>
</rich:tab>
</rich:tabPanel>
</c:when>
</c:choose>
- <ui:include src="view-raw-modal.xhtml"/>
+
</h:form>
commit 56cbca2bb02f3af03c21f65dffcf63feb53522a1
Author: John Sanda <john(a)localhost.localdomain>
Date: Thu Jan 14 00:26:46 2010 -0500
Fixing regression that broke translation and changing files from the raw file menu
I introduced a regression earlier today when adding support for the modal file editor that resulted in
breaking the translation when switching back and forth between the structured and raw tabs. Selecting
a file in the raw file menu triggers a partial page update. The modal editor is in a subview on the page and
it was not getting updating during the ajax request. It was holding onto an older value of the selected
file which in turn was overwriting the corresponding property in the backing bean.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index a6366a4..3a81c03 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -120,10 +120,10 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public void changeTabs(ValueChangeEvent event) {
- if (event.getNewValue().equals("Advanced Mode")) {
+ if (event.getNewValue().equals("rawTab")) {
switchToRaw();
}
- else if (event.getNewValue().equals("Basic Mode")) {
+ else if (event.getNewValue().equals("structuredTab")) {
switchToStructured();
}
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 139b5b3..ea3fe76 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -67,13 +67,13 @@ THIS TEXT WILL BE REMOVED.
var="rawConfigDir">
<rich:panelMenuGroup label="#{rawConfigDir.path}"
expanded="true"
- selectedChild="#{currentPath}">
+ selectedChild="#{ExistingResourceConfigurationUIBean.currentPath}">
<c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
<rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
onclick="cursor_wait();"
oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
- reRender="fileContents,selectFileHeader"/>
+ reRender="fileContents,selectedFileHeader,modalEditor"/>
</c:forEach>
</rich:panelMenuGroup>
</c:forEach>
@@ -83,8 +83,8 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
<a4j:status id="selectedFileHeader"
- startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
- stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
+ startText="Loading #{ExistingResourceConfigurationUIBean.current.path} ..."
+ stopText="#{ExistingResourceConfigurationUIBean.current.path}"/>
<a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
<h:commandLink value="Upload New">
<h:graphicImage value="/images/upload.png"/>
@@ -140,8 +140,10 @@ THIS TEXT WILL BE REMOVED.
</c:when>
<c:when test="${ExistingResourceConfigurationUIBean.structuredAndRawSupported}">
- <rich:tabPanel switchType="ajax" valueChangeListener="changeTabs">
- <rich:tab label="Basic Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
+ <rich:tabPanel id="configTabPanel"
+ switchType="ajax"
+ valueChangeListener="#{ExistingResourceConfigurationUIBean.changeTabs}">
+ <rich:tab id="structuredTab" label="Basic Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
<onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}"
configuration="#{ExistingResourceConfigurationUIBean.configuration}"
nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}"
@@ -164,7 +166,7 @@ THIS TEXT WILL BE REMOVED.
styleClass="buttonmed"/>
</h:panelGrid>
</rich:tab>
- <rich:tab label="Advanced Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
+ <rich:tab id="rawTab" label="Advanced Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
<h:panelGrid columns="2"
styleClass="raw-outer-table"
columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
@@ -174,20 +176,19 @@ THIS TEXT WILL BE REMOVED.
<rich:panelMenu mode="ajax"
expandMode="client"
- iconCollapsedGroup="disc"
- limitToList="true"
- reRender="fileContents">
+ iconCollapsedGroup="disc">
<c:forEach items="#{rawConfigDirectories}"
var="rawConfigDir">
<rich:panelMenuGroup label="#{rawConfigDir.path}"
expanded="true"
- selectedChild="#{currentPath}">
+ selectedChild="#{ExistingResourceConfigurationUIBean.currentPath}">
<c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
<rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
onclick="cursor_wait();"
oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
- reRender="fileContents,selectFileHeader"/>
+ limitToList="true"
+ reRender="fileContents,selectedFileHeader,modalEditor"/>
</c:forEach>
</rich:panelMenuGroup>
</c:forEach>
@@ -197,8 +198,8 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
<a4j:status id="selectedFileHeader"
- startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
- stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
+ startText="Loading #{ExistingResourceConfigurationUIBean.current.path} ..."
+ stopText="#{ExistingResourceConfigurationUIBean.current.path}"/>
<a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
<h:commandLink value="Upload New">
<h:graphicImage value="/images/upload.png"/>
@@ -233,33 +234,6 @@ THIS TEXT WILL BE REMOVED.
</c:when>
</c:choose>
- <ui:remove>
- <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.structuredAndRawSupported}">
- <h:outputText value=" #{messages.switch2}"/>
- <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchToRaw}">
- <f:param name="conversationId" value="#{conversation.id}"/>
- <f:param name="id" value="#{ResourceUIBean.id}"/>
- <h:outputText value=" files mode"/>
- </h:commandLink>
- </h:panelGroup>
-
-
- <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}"
- configuration="#{ExistingResourceConfigurationUIBean.configuration}"
- nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}"
- nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}"
- prevalidate="true"/>
-
- <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell"
- rendered="#{ExistingResourceConfigurationUIBean.configuration != null}">
- <h:commandButton value="SAVE" action="#{ExistingResourceConfigurationUIBean.updateConfiguration}"
- title="Click to Save Changes" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure}"/>
- <h:commandButton value="RESET" type="reset" immediate="true"
- title="Click to Reset Fields" styleClass="buttonmed"/>
- </h:panelGrid>
- </ui:remove>
-
<ui:include src="view-raw-modal.xhtml"/>
</h:form>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
index ddbce3b..f0e8b25 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
@@ -12,7 +12,7 @@
<rich:modalPanel id="modalEditor" width="800" height="600">
<f:facet name="header">
<h:panelGroup>
- <h:outputText value="#{ExistingResourceConfigurationViewUIBean.currentPath}"/>
+ <h:outputText value="#{ExistingResourceConfiguratioUIBean.currentPath}"/>
</h:panelGroup>
</f:facet>
<f:facet name="controls">
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 81fdb1b..6e68e0c 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -88,7 +88,7 @@ THIS TEXT WILL BE REMOVED.
onclick="cursor_wait();"
oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationViewUIBean.select(rawConfigUIBean.path)}"
- reRender="fileContents,selectFileHeader"/>
+ reRender="fileContents,selectedFileHeader,modalEditor"/>
</c:forEach>
</rich:panelMenuGroup>
</c:forEach>
@@ -214,7 +214,7 @@ THIS TEXT WILL BE REMOVED.
onclick="cursor_wait();"
oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationViewUIBean.select(rawConfigUIBean.path)}"
- reRender="fileContents,selectFileHeader"/>
+ reRender="fileContents,selectedFileHeader,modalEditor"/>
</c:forEach>
</rich:panelMenuGroup>
</c:forEach>
commit 25dca64eee9ea55165d31e10539abf3e46751637
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Jan 13 14:08:12 2010 -0500
Adding javascript on edit page to change cursor to wait icon when switching between tabs
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index d82efd7..139b5b3 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -34,7 +34,7 @@ THIS TEXT WILL BE REMOVED.
}
function open_modal_editor() {
-
+
}
</script>
@@ -52,185 +52,182 @@ THIS TEXT WILL BE REMOVED.
<c:when test="${ExistingResourceConfigurationUIBean.rawSupported}">
<rich:tabPanel switchType="ajax" valueChangeListener="changeTabs">
<rich:tab label="Advanced Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
- <h:panelGrid columns="2"
- styleClass="raw-outer-table"
- columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
- <rich:panel style="width:100%">
- <f:facet name="header">Files</f:facet>
-
- <rich:panelMenu mode="ajax"
- expandMode="client"
- iconCollapsedGroup="disc"
- limitToList="true"
- reRender="fileContents">
- <c:forEach items="#{rawConfigDirectories}"
- var="rawConfigDir">
- <rich:panelMenuGroup label="#{rawConfigDir.path}"
- expanded="true"
- selectedChild="#{currentPath}">
- <c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
- <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
- onclick="cursor_wait();"
- oncomplete="cursor_clear();"
- action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
- reRender="fileContents,selectFileHeader"/>
+ <h:panelGrid columns="2"
+ styleClass="raw-outer-table"
+ columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
+ <rich:panel style="width:100%">
+ <f:facet name="header">Files</f:facet>
+
+ <rich:panelMenu mode="ajax"
+ expandMode="client"
+ iconCollapsedGroup="disc"
+ limitToList="true"
+ reRender="fileContents">
+ <c:forEach items="#{rawConfigDirectories}"
+ var="rawConfigDir">
+ <rich:panelMenuGroup label="#{rawConfigDir.path}"
+ expanded="true"
+ selectedChild="#{currentPath}">
+ <c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
+ <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
+ onclick="cursor_wait();"
+ oncomplete="cursor_clear();"
+ action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
+ reRender="fileContents,selectFileHeader"/>
+ </c:forEach>
+ </rich:panelMenuGroup>
</c:forEach>
- </rich:panelMenuGroup>
- </c:forEach>
- </rich:panelMenu>
- </rich:panel>
-
- <h:panelGrid columns="1" style="width:100%;">
- <h:panelGrid columns="4" style="width:100%;">
- <a4j:status id="selectedFileHeader"
- startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
- stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
- <a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
- <h:commandLink value="Upload New">
- <h:graphicImage value="/images/upload.png"/>
- </h:commandLink>
- <h:commandLink action="#{ExistingResourceConfigurationUIBean.download}" value="Download">
- <h:graphicImage value="/images/download.png"/>
- <f:param name="id" value="#{ResourceUIBean.id}"/>
- </h:commandLink>
- </h:panelGrid>
+ </rich:panelMenu>
+ </rich:panel>
- <rich:panel style="margin-left:1px; border: none;">
- <h:inputTextarea id="fileContents"
- style="width:100%"
- value="#{ExistingResourceConfigurationUIBean.currentContents}"
- readonly="false"/>
- </rich:panel>
- </h:panelGrid>
-
- <h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
- <h:panelGrid columns="2">
- <h:outputText>n files changed in this configuration</h:outputText>
- <h:commandButton value="Commit"
- action="#{ExistingResourceConfigurationUIBean.updateRawConfiguration}"
- title="Click to Save Changes"
- styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure}"/>
+ <h:panelGrid columns="1" style="width:100%;">
+ <h:panelGrid columns="4" style="width:100%;">
+ <a4j:status id="selectedFileHeader"
+ startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
+ stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
+ <a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
+ <h:commandLink value="Upload New">
+ <h:graphicImage value="/images/upload.png"/>
+ </h:commandLink>
+ <h:commandLink action="#{ExistingResourceConfigurationUIBean.download}" value="Download">
+ <h:graphicImage value="/images/download.png"/>
+ <f:param name="id" value="#{ResourceUIBean.id}"/>
+ </h:commandLink>
+ </h:panelGrid>
+
+ <rich:panel style="margin-left:1px; border: none;">
+ <h:inputTextarea id="fileContents"
+ style="width:100%"
+ value="#{ExistingResourceConfigurationUIBean.currentContents}"
+ readonly="false"/>
+ </rich:panel>
+ </h:panelGrid>
+
+ <h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
+ <h:panelGrid columns="2">
+ <h:outputText>n files changed in this configuration</h:outputText>
+ <h:commandButton value="Commit"
+ action="#{ExistingResourceConfigurationUIBean.updateRawConfiguration}"
+ title="Click to Save Changes"
+ styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure}"/>
+ </h:panelGrid>
+ </h:panelGrid>
</h:panelGrid>
- </h:panelGrid>
- </h:panelGrid>
- </rich:tab>
+ </rich:tab>
</rich:tabPanel>
</c:when>
<c:when test="${ExistingResourceConfigurationUIBean.structuredSupported}">
<rich:tabPanel switchType="ajax" valueChangeListener="changeTabs">
<rich:tab label="Basic Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
- <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}"
- configuration="#{ExistingResourceConfigurationUIBean.configuration}"
- nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}"
- nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}"
- prevalidate="true"/>
-
- <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell"
- rendered="#{ExistingResourceConfigurationUIBean.configuration != null}">
- <h:commandButton value="SAVE" action="#{ExistingResourceConfigurationUIBean.updateConfiguration}"
- title="Click to Save Changes" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure}"/>
- <h:commandButton value="RESET" type="reset" immediate="true"
- title="Click to Reset Fields" styleClass="buttonmed"/>
- </h:panelGrid>
- </rich:tab>
+ <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}"
+ configuration="#{ExistingResourceConfigurationUIBean.configuration}"
+ nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}"
+ nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}"
+ prevalidate="true"/>
+
+ <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell"
+ rendered="#{ExistingResourceConfigurationUIBean.configuration != null}">
+ <h:commandButton value="SAVE" action="#{ExistingResourceConfigurationUIBean.updateConfiguration}"
+ title="Click to Save Changes" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure}"/>
+ <h:commandButton value="RESET" type="reset" immediate="true"
+ title="Click to Reset Fields" styleClass="buttonmed"/>
+ </h:panelGrid>
+ </rich:tab>
</rich:tabPanel>
</c:when>
<c:when test="${ExistingResourceConfigurationUIBean.structuredAndRawSupported}">
- <h:panelGrid columns="2">
- <h:outputText value="#{ResourceUIBean.name}"/>
- </h:panelGrid>
<rich:tabPanel switchType="ajax" valueChangeListener="changeTabs">
- <rich:tab label="Basic Mode">
+ <rich:tab label="Basic Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
<onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}"
- configuration="#{ExistingResourceConfigurationUIBean.configuration}"
- nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}"
- nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}"
- prevalidate="true"/>
-
- <h:panelGrid columns="2"
- styleClass="buttons-table"
- columnClasses="button-cell"
- rendered="#{ExistingResourceConfigurationUIBean.configuration != null}">
- <h:commandButton value="SAVE"
- action="#{ExistingResourceConfigurationUIBean.updateConfiguration}"
- title="Click to Save Changes"
- styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure}"/>
- <h:commandButton value="RESET"
- type="reset"
- immediate="true"
- title="Click to Reset Fields"
- styleClass="buttonmed"/>
- </h:panelGrid>
+ configuration="#{ExistingResourceConfigurationUIBean.configuration}"
+ nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}"
+ nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}"
+ prevalidate="true"/>
+
+ <h:panelGrid columns="2"
+ styleClass="buttons-table"
+ columnClasses="button-cell"
+ rendered="#{ExistingResourceConfigurationUIBean.configuration != null}">
+ <h:commandButton value="SAVE"
+ action="#{ExistingResourceConfigurationUIBean.updateConfiguration}"
+ title="Click to Save Changes"
+ styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure}"/>
+ <h:commandButton value="RESET"
+ type="reset"
+ immediate="true"
+ title="Click to Reset Fields"
+ styleClass="buttonmed"/>
+ </h:panelGrid>
</rich:tab>
- <rich:tab label="Advanced Mode">
+ <rich:tab label="Advanced Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
<h:panelGrid columns="2"
- styleClass="raw-outer-table"
- columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
- <rich:panel style="width:100%">
- <f:facet name="header">Files</f:facet>
-
-
- <rich:panelMenu mode="ajax"
- expandMode="client"
- iconCollapsedGroup="disc"
- limitToList="true"
- reRender="fileContents">
- <c:forEach items="#{rawConfigDirectories}"
+ styleClass="raw-outer-table"
+ columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
+ <rich:panel style="width:100%">
+ <f:facet name="header">Files</f:facet>
+
+
+ <rich:panelMenu mode="ajax"
+ expandMode="client"
+ iconCollapsedGroup="disc"
+ limitToList="true"
+ reRender="fileContents">
+ <c:forEach items="#{rawConfigDirectories}"
var="rawConfigDir">
- <rich:panelMenuGroup label="#{rawConfigDir.path}"
- expanded="true"
- selectedChild="#{currentPath}">
- <c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
- <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
- onclick="cursor_wait();"
- oncomplete="cursor_clear();"
- action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
- reRender="fileContents,selectFileHeader"/>
- </c:forEach>
- </rich:panelMenuGroup>
- </c:forEach>
- </rich:panelMenu>
+ <rich:panelMenuGroup label="#{rawConfigDir.path}"
+ expanded="true"
+ selectedChild="#{currentPath}">
+ <c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
+ <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
+ onclick="cursor_wait();"
+ oncomplete="cursor_clear();"
+ action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
+ reRender="fileContents,selectFileHeader"/>
+ </c:forEach>
+ </rich:panelMenuGroup>
+ </c:forEach>
+ </rich:panelMenu>
</rich:panel>
- <h:panelGrid columns="1" style="width:100%;">
- <h:panelGrid columns="4" style="width:100%;">
- <a4j:status id="selectedFileHeader"
- startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
- stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
- <a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
- <h:commandLink value="Upload New">
- <h:graphicImage value="/images/upload.png"/>
- </h:commandLink>
- <h:commandLink action="#{ExistingResourceConfigurationUIBean.download}" value="Download">
- <h:graphicImage value="/images/download.png"/>
- <f:param name="id" value="#{ResourceUIBean.id}"/>
- </h:commandLink>
+ <h:panelGrid columns="1" style="width:100%;">
+ <h:panelGrid columns="4" style="width:100%;">
+ <a4j:status id="selectedFileHeader"
+ startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
+ stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
+ <a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
+ <h:commandLink value="Upload New">
+ <h:graphicImage value="/images/upload.png"/>
+ </h:commandLink>
+ <h:commandLink action="#{ExistingResourceConfigurationUIBean.download}" value="Download">
+ <h:graphicImage value="/images/download.png"/>
+ <f:param name="id" value="#{ResourceUIBean.id}"/>
+ </h:commandLink>
+ </h:panelGrid>
+
+ <rich:panel style="margin-left:1px; border: none;">
+ <h:inputTextarea id="fileContents"
+ style="width:100%"
+ value="#{ExistingResourceConfigurationUIBean.currentContents}"
+ readonly="false"/>
+ </rich:panel>
</h:panelGrid>
- <rich:panel style="margin-left:1px; border: none;">
- <h:inputTextarea id="fileContents"
- style="width:100%"
- value="#{ExistingResourceConfigurationUIBean.currentContents}"
- readonly="false"/>
- </rich:panel>
- </h:panelGrid>
-
- <h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
- <h:panelGrid columns="2">
- <h:outputText>n files changed in this configuration</h:outputText>
- <h:commandButton value="Commit"
- action="#{ExistingResourceConfigurationUIBean.updateRawConfiguration}"
- title="Click to Save Changes"
- styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure}"/>
+ <h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
+ <h:panelGrid columns="2">
+ <h:outputText>n files changed in this configuration</h:outputText>
+ <h:commandButton value="Commit"
+ action="#{ExistingResourceConfigurationUIBean.updateRawConfiguration}"
+ title="Click to Save Changes"
+ styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure}"/>
+ </h:panelGrid>
</h:panelGrid>
</h:panelGrid>
- </h:panelGrid>
</rich:tab>
</rich:tabPanel>
</c:when>
commit f2216a80c0e71c1ea5adfe95d6e8addc3552b8d8
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Jan 13 13:50:31 2010 -0500
Using tabs on the view/edit pages regardless of the supported config format to be consistent
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 4ec4a1e..d82efd7 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -44,8 +44,14 @@ THIS TEXT WILL BE REMOVED.
<input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+ <h:panelGrid columns="2">
+ <h:outputText value="#{ResourceUIBean.name}"/>
+ </h:panelGrid>
+
<c:choose>
<c:when test="${ExistingResourceConfigurationUIBean.rawSupported}">
+ <rich:tabPanel switchType="ajax" valueChangeListener="changeTabs">
+ <rich:tab label="Advanced Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
<h:panelGrid columns="2"
styleClass="raw-outer-table"
columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
@@ -108,9 +114,13 @@ THIS TEXT WILL BE REMOVED.
</h:panelGrid>
</h:panelGrid>
</h:panelGrid>
+ </rich:tab>
+ </rich:tabPanel>
</c:when>
<c:when test="${ExistingResourceConfigurationUIBean.structuredSupported}">
+ <rich:tabPanel switchType="ajax" valueChangeListener="changeTabs">
+ <rich:tab label="Basic Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
<onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}"
configuration="#{ExistingResourceConfigurationUIBean.configuration}"
nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}"
@@ -125,6 +135,8 @@ THIS TEXT WILL BE REMOVED.
<h:commandButton value="RESET" type="reset" immediate="true"
title="Click to Reset Fields" styleClass="buttonmed"/>
</h:panelGrid>
+ </rich:tab>
+ </rich:tabPanel>
</c:when>
<c:when test="${ExistingResourceConfigurationUIBean.structuredAndRawSupported}">
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 37c0100..81fdb1b 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -44,201 +44,213 @@ THIS TEXT WILL BE REMOVED.
<h:form id="viewResourceConfigurationForm">
<input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+
+ <h:panelGrid columns="2">
+ <h:outputText value="#{ResourceUIBean.name}"/>
+ </h:panelGrid>
+
<c:choose>
<c:when test="${ExistingResourceConfigurationViewUIBean.rawSupported}">
- <h:outputText value=" #{messages.nopermissionedit}"
- rendered="#{!ResourceUIBean.permissions.configure}"/>
-
- <h:panelGrid columns="2"
- styleClass="buttons-table"
- columnClasses="button-cell"
- rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
-
- <h:commandButton value="#{messages.editraw}"
- action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
- title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
- </h:panelGrid>
-
- <h:panelGrid columns="2"
- styleClass="raw-outer-table"
- columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
- <rich:panel style="width:100%">
- <f:facet name="header">Files</f:facet>
- <rich:panelMenu mode="ajax"
- expandMode="client"
- iconCollapsedGroup="disc"
- limitToList="true"
- reRender="fileContents">
- <c:forEach items="#{rawConfigDirectories}"
- var="rawConfigDir">
- <rich:panelMenuGroup label="#{rawConfigDir.path}"
- expanded="true"
- selectedChild="#{currentPath}">
- <c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
- <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
- onclick="cursor_wait();"
- oncomplete="cursor_clear();"
- action="#{ExistingResourceConfigurationViewUIBean.select(rawConfigUIBean.path)}"
- reRender="fileContents,selectFileHeader"/>
- </c:forEach>
- </rich:panelMenuGroup>
- </c:forEach>
- </rich:panelMenu>
- </rich:panel>
-
- <h:panelGrid columns="1" style="width:100%;">
- <h:panelGrid columns="4" style="width:100%;">
- <a4j:status id="selectedFileHeader"
- startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
- stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
- <a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
- <h:commandLink value="Upload New">
- <h:graphicImage value="/images/upload.png"/>
- </h:commandLink>
- <h:commandLink action="#{ExistingResourceConfigurationViewUIBean.download}" value="Download">
- <h:graphicImage value="/images/download.png"/>
- <f:param name="id" value="#{ResourceUIBean.id}"/>
- </h:commandLink>
+
+ <rich:tabPanel switchType="ajax" valueChangeListener="changeTabs">
+ <rich:tab label="Advanced Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
+ <h:outputText value=" #{messages.nopermissionedit}"
+ rendered="#{!ResourceUIBean.permissions.configure}"/>
+
+ <h:panelGrid columns="2"
+ styleClass="buttons-table"
+ columnClasses="button-cell"
+ rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
+
+ <h:commandButton value="Edit"
+ action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
+ title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
</h:panelGrid>
- <rich:panel style="margin-left:1px; border: none;">
- <h:inputTextarea id="fileContents"
- style="width:100%"
- value="#{ExistingResourceConfigurationViewUIBean.currentContents}"
- readonly="true"/>
- </rich:panel>
- </h:panelGrid>
- </h:panelGrid>
+ <h:panelGrid columns="2"
+ styleClass="raw-outer-table"
+ columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
+ <rich:panel style="width:100%">
+ <f:facet name="header">Files</f:facet>
+ <rich:panelMenu mode="ajax"
+ expandMode="client"
+ iconCollapsedGroup="disc"
+ limitToList="true"
+ reRender="fileContents">
+ <c:forEach items="#{rawConfigDirectories}"
+ var="rawConfigDir">
+ <rich:panelMenuGroup label="#{rawConfigDir.path}"
+ expanded="true"
+ selectedChild="#{currentPath}">
+ <c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
+ <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
+ onclick="cursor_wait();"
+ oncomplete="cursor_clear();"
+ action="#{ExistingResourceConfigurationViewUIBean.select(rawConfigUIBean.path)}"
+ reRender="fileContents,selectFileHeader"/>
+ </c:forEach>
+ </rich:panelMenuGroup>
+ </c:forEach>
+ </rich:panelMenu>
+ </rich:panel>
+
+ <h:panelGrid columns="1" style="width:100%;">
+ <h:panelGrid columns="4" style="width:100%;">
+ <a4j:status id="selectedFileHeader"
+ startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
+ stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
+ <a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
+ <h:commandLink value="Upload New">
+ <h:graphicImage value="/images/upload.png"/>
+ </h:commandLink>
+ <h:commandLink action="#{ExistingResourceConfigurationViewUIBean.download}" value="Download">
+ <h:graphicImage value="/images/download.png"/>
+ <f:param name="id" value="#{ResourceUIBean.id}"/>
+ </h:commandLink>
+ </h:panelGrid>
+
+ <rich:panel style="margin-left:1px; border: none;">
+ <h:inputTextarea id="fileContents"
+ style="width:100%"
+ value="#{ExistingResourceConfigurationViewUIBean.currentContents}"
+ readonly="true"/>
+ </rich:panel>
+ </h:panelGrid>
+ </h:panelGrid>
+ </rich:tab>
+ </rich:tabPanel>
</c:when>
+
<c:when test="${ExistingResourceConfigurationViewUIBean.structuredSupported}">
- <h:outputText value=" #{messages.nopermissionedit}"
- rendered="#{!ResourceUIBean.permissions.configure}"/>
-
- <h:panelGrid columns="2"
- styleClass="buttons-table"
- columnClasses="button-cell"
- rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
-
- <h:commandButton value="#{messages.editstructured}"
- action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}"
- title="Edit this Configuration"
- styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
- </h:panelGrid>
-
- <onc:config
- configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}"
- configuration="#{ExistingResourceConfigurationViewUIBean.configuration}"
- accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}"
- readOnly="true"
- nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}"
- nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}"
- prevalidate="true"/>
+ <rich:tabPanel switchType="ajax" valueChangeListener="changeTabs">
+ <rich:tab label="Basic Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
+ <h:outputText value=" #{messages.nopermissionedit}"
+ rendered="#{!ResourceUIBean.permissions.configure}"/>
+
+ <h:panelGrid columns="2"
+ styleClass="buttons-table"
+ columnClasses="button-cell"
+ rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
+
+ <h:commandButton value="Edit"
+ action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}"
+ title="Edit this Configuration"
+ styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
+ </h:panelGrid>
+ <onc:config
+ configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}"
+ configuration="#{ExistingResourceConfigurationViewUIBean.configuration}"
+ accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}"
+ readOnly="true"
+ nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}"
+ nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}"
+ prevalidate="true"/>
+ </rich:tab>
+ </rich:tabPanel>
</c:when>
+
<c:when test="${ExistingResourceConfigurationViewUIBean.structuredAndRawSupported}">
- <h:panelGrid columns="2">
- <h:outputText value="#{ResourceUIBean.name}"/>
- </h:panelGrid>
<rich:tabPanel switchType="ajax" valueChangeListener="changeTabs">
<rich:tab label="Basic Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
- <h:outputText value=" #{messages.nopermissionedit}"
- rendered="#{!ResourceUIBean.permissions.configure}"/>
-
- <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell"
- rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
-
- <h:commandButton id="editStructuredButton"
- value="Edit"
- action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}"
- title="Edit this Configuration" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
- </h:panelGrid>
-
- <onc:config
- configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}"
- configuration="#{ExistingResourceConfigurationViewUIBean.configuration}"
- accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}"
- readOnly="true"
- nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}"
- nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}"
- prevalidate="true"/>
+ <h:outputText value=" #{messages.nopermissionedit}"
+ rendered="#{!ResourceUIBean.permissions.configure}"/>
+
+ <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell"
+ rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
+
+ <h:commandButton id="editStructuredButton"
+ value="Edit"
+ action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}"
+ title="Edit this Configuration" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
+ </h:panelGrid>
+
+ <onc:config
+ configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}"
+ configuration="#{ExistingResourceConfigurationViewUIBean.configuration}"
+ accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}"
+ readOnly="true"
+ nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}"
+ nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}"
+ prevalidate="true"/>
</rich:tab>
<rich:tab label="Advanced Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
<h:outputText value=" #{messages.nopermissionedit}"
- rendered="#{!ResourceUIBean.permissions.configure}"/>
-
- <h:panelGrid columns="2"
- styleClass="buttons-table"
- columnClasses="button-cell"
- rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
-
- <h:commandButton id="editRawButton"
- value="Edit"
- action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
- title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
- </h:panelGrid>
-
- <h:panelGrid columns="2"
- styleClass="raw-outer-table"
- columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
- <rich:panel style="width:100%">
- <f:facet name="header">Files</f:facet>
- <rich:panelMenu mode="ajax"
- expandMode="client"
- iconCollapsedGroup="disc"
- limitToList="true"
- reRender="fileContents">
- <c:forEach items="#{rawConfigDirectories}"
- var="rawConfigDir">
- <rich:panelMenuGroup label="#{rawConfigDir.path}"
- expanded="true"
- selectedChild="#{currentPath}">
- <c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
- <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
- onclick="cursor_wait();"
- oncomplete="cursor_clear();"
- action="#{ExistingResourceConfigurationViewUIBean.select(rawConfigUIBean.path)}"
- reRender="fileContents,selectFileHeader"/>
- </c:forEach>
- </rich:panelMenuGroup>
- </c:forEach>
- </rich:panelMenu>
- </rich:panel>
-
- <h:panelGrid columns="1" style="width:100%;">
- <h:panelGrid columns="4" style="width:100%;">
- <a4j:status id="selectedFileHeader"
- startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
- stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
- <a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
- <h:commandLink value="Upload New">
- <h:graphicImage value="/images/upload.png"/>
- </h:commandLink>
- <h:commandLink action="#{ExistingResourceConfigurationViewUIBean.download}" value="Download">
- <h:graphicImage value="/images/download.png"/>
- <f:param name="id" value="#{ResourceUIBean.id}"/>
- </h:commandLink>
- </h:panelGrid>
+ rendered="#{!ResourceUIBean.permissions.configure}"/>
+
+ <h:panelGrid columns="2"
+ styleClass="buttons-table"
+ columnClasses="button-cell"
+ rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
+
+ <h:commandButton id="editRawButton"
+ value="Edit"
+ action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
+ title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
+ </h:panelGrid>
- <rich:panel style="margin-left:1px; border: none;">
- <h:inputTextarea id="fileContents"
- style="width:100%"
- value="#{ExistingResourceConfigurationViewUIBean.currentContents}"
- readonly="true"/>
+ <h:panelGrid columns="2"
+ styleClass="raw-outer-table"
+ columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
+ <rich:panel style="width:100%">
+ <f:facet name="header">Files</f:facet>
+ <rich:panelMenu mode="ajax"
+ expandMode="client"
+ iconCollapsedGroup="disc"
+ limitToList="true"
+ reRender="fileContents">
+ <c:forEach items="#{rawConfigDirectories}"
+ var="rawConfigDir">
+ <rich:panelMenuGroup label="#{rawConfigDir.path}"
+ expanded="true"
+ selectedChild="#{currentPath}">
+ <c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
+ <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
+ onclick="cursor_wait();"
+ oncomplete="cursor_clear();"
+ action="#{ExistingResourceConfigurationViewUIBean.select(rawConfigUIBean.path)}"
+ reRender="fileContents,selectFileHeader"/>
+ </c:forEach>
+ </rich:panelMenuGroup>
+ </c:forEach>
+ </rich:panelMenu>
</rich:panel>
+
+ <h:panelGrid columns="1" style="width:100%;">
+ <h:panelGrid columns="4" style="width:100%;">
+ <a4j:status id="selectedFileHeader"
+ startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
+ stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
+ <a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
+ <h:commandLink value="Upload New">
+ <h:graphicImage value="/images/upload.png"/>
+ </h:commandLink>
+ <h:commandLink action="#{ExistingResourceConfigurationViewUIBean.download}" value="Download">
+ <h:graphicImage value="/images/download.png"/>
+ <f:param name="id" value="#{ResourceUIBean.id}"/>
+ </h:commandLink>
+ </h:panelGrid>
+
+ <rich:panel style="margin-left:1px; border: none;">
+ <h:inputTextarea id="fileContents"
+ style="width:100%"
+ value="#{ExistingResourceConfigurationViewUIBean.currentContents}"
+ readonly="true"/>
+ </rich:panel>
+ </h:panelGrid>
</h:panelGrid>
- </h:panelGrid>
</rich:tab>
</rich:tabPanel>
</c:when>
</c:choose>
<ui:include src="view-raw-modal.xhtml"/>
-
+
</h:form>
<h:panelGroup layout="block" styleClass="InfoBlock"
commit f53dfc6ad315a723c22ceab61a31dfec92f92dbf
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Jan 13 13:15:01 2010 -0500
Adding initial support for full screen, modal raw config editor
With this commit, we can view a config file in a modal window. Still need to add functionality for
applying updates from the modal window.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index ec75f22..4ec4a1e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -32,6 +32,10 @@ THIS TEXT WILL BE REMOVED.
function cursor_clear() {
document.body.style.cursor = 'default';
}
+
+ function open_modal_editor() {
+
+ }
</script>
<h:form id="editResourceConfigurationForm"
@@ -75,7 +79,7 @@ THIS TEXT WILL BE REMOVED.
<a4j:status id="selectedFileHeader"
startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
- <h:commandLink value="View Full Screen"/>
+ <a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
<h:commandLink value="Upload New">
<h:graphicImage value="/images/upload.png"/>
</h:commandLink>
@@ -179,34 +183,14 @@ THIS TEXT WILL BE REMOVED.
</rich:panelMenuGroup>
</c:forEach>
</rich:panelMenu>
-
-
- <ui:remove>
- <rich:panelMenu mode="ajax"
- expandMode="client"
- iconCollapsedGroup="disc"
- limitToList="true"
- reRender="fileContents">
- <rich:panelMenuGroup label="/tmp/raw-config" expanded="true">
- <c:forEach items="#{ExistingResourceConfigurationUIBean.configuration.rawConfigurations}"
- var="rawConfig">
- <rich:panelMenuItem label="#{rawConfig.path}"
- action="#{ExistingResourceConfigurationUIBean.select(rawConfig.path)}"
- styleClass="raw-menu-item"
- tableBorderColor="blue"
- reRender="fileContents,selectedFileHeader"/>
- </c:forEach>
- </rich:panelMenuGroup>
- </rich:panelMenu>
- </ui:remove>
- </rich:panel>
+ </rich:panel>
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
<a4j:status id="selectedFileHeader"
startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
- <h:commandLink value="View Full Screen"/>
+ <a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
<h:commandLink value="Upload New">
<h:graphicImage value="/images/upload.png"/>
</h:commandLink>
@@ -267,6 +251,8 @@ THIS TEXT WILL BE REMOVED.
</h:panelGrid>
</ui:remove>
+ <ui:include src="view-raw-modal.xhtml"/>
+
</h:form>
<h:panelGroup layout="block" styleClass="InfoBlock"
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
new file mode 100644
index 0000000..ddbce3b
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view-raw-modal.xhtml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich">
+
+ <f:subview id="subview">
+ <rich:modalPanel id="modalEditor" width="800" height="600">
+ <f:facet name="header">
+ <h:panelGroup>
+ <h:outputText value="#{ExistingResourceConfigurationViewUIBean.currentPath}"/>
+ </h:panelGroup>
+ </f:facet>
+ <f:facet name="controls">
+ <h:panelGroup>
+ <h:graphicImage value="/images/close.png" styleClass="hidelink" id="hidelink"/>
+ <rich:componentControl for="modalEditor" attachTo="hidelink" operation="hide" event="onclick"/>
+ </h:panelGroup>
+ </f:facet>
+ <rich:panel style="margin-left:1px; border: none;">
+ <h:inputTextarea id="fileContents"
+ style="width:100%; height:100%; overflow:visible;"
+ rows="30"
+ cols="30"
+ value="#{ExistingResourceConfigurationUIBean.currentContents}"
+ readonly="false"/>
+ </rich:panel>
+ </rich:modalPanel>
+ </f:subview>
+
+</ui:composition>
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index b9d13b9..37c0100 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -92,7 +92,7 @@ THIS TEXT WILL BE REMOVED.
<a4j:status id="selectedFileHeader"
startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
- <h:commandLink value="View Full Screen"/>
+ <a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
<h:commandLink value="Upload New">
<h:graphicImage value="/images/upload.png"/>
</h:commandLink>
@@ -214,7 +214,7 @@ THIS TEXT WILL BE REMOVED.
<a4j:status id="selectedFileHeader"
startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
- <h:commandLink value="View Full Screen"/>
+ <a href="#" onclick="#{rich:component('modalEditor')}.show()">View Full Screen</a>
<h:commandLink value="Upload New">
<h:graphicImage value="/images/upload.png"/>
</h:commandLink>
@@ -236,6 +236,9 @@ THIS TEXT WILL BE REMOVED.
</rich:tabPanel>
</c:when>
</c:choose>
+
+ <ui:include src="view-raw-modal.xhtml"/>
+
</h:form>
<h:panelGroup layout="block" styleClass="InfoBlock"
commit f5630e163bfea70d1fc5629a67310ab0ccccd689
Merge: f9ce225... 776bbc9...
Author: John Sanda <john(a)localhost.localdomain>
Date: Tue Jan 12 21:54:45 2010 -0500
Merge branch 'raw-config' of ssh://git.fedorahosted.org/git/rhq/rhq into raw-config
commit f9ce225efdf75887f6a2abb16ab2696e1f569579
Author: John Sanda <john(a)localhost.localdomain>
Date: Tue Jan 12 21:48:34 2010 -0500
Adding javascript and file grouping on the raw view and on the edit pages
The files in the file menu are now grouped by directory in all views where it is rendered. JavaScript has
been added in places as well to change the cursor style to wait when a new config is selected and is
loading.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 027ce1d..a6366a4 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -59,11 +59,12 @@ import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.server.configuration.ConfigurationManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
-/**
- * @author Ian Springer
- */
-@Name(value = "ExistingResourceConfigurationViewUIBean")
-(a)Scope(ScopeType.PAGE)
+// This class is temporarily decleared in components.xml since it is declared under two names - ViewUIBean and
+// UIBean. This class is undergoing some refactoring and part of that will include declaring the @Name and @Scope
+// annotations again.
+//
+//@Name(value = "ExistingResourceConfigurationViewUIBean")
+//(a)Scope(ScopeType.PAGE)
public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUIBean {
public static final String MANAGED_BEAN_NAME = "ExistingResourceConfigurationUIBean";
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml
index 64bd31e..8f7cfcc 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/components.xml
@@ -19,4 +19,13 @@
<property name="createTempFiles">false</property>
<property name="maxRequestSize">1000000</property>
</component>
+
+ <component class="org.rhq.enterprise.gui.configuration.resource.ExistingResourceConfigurationUIBean"
+ name="ExistingResourceConfigurationViewUIBean"
+ scope="page"/>
+
+ <component class="org.rhq.enterprise.gui.configuration.resource.ExistingResourceConfigurationUIBean"
+ name="ExistingResourceConfigurationUIBean"
+ scope="session"/>
+
</components>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 02ef0c1..ec75f22 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -24,6 +24,15 @@ THIS TEXT WILL BE REMOVED.
<ui:param name="selectedTabName" value="Configuration.Current"/>
<ui:define name="content">
+ <script type="text/javascript">
+ function cursor_wait() {
+ document.body.style.cursor = 'wait';
+ }
+
+ function cursor_clear() {
+ document.body.style.cursor = 'default';
+ }
+ </script>
<h:form id="editResourceConfigurationForm"
onsubmit="prepareInputsForSubmission(this)"
@@ -38,29 +47,34 @@ THIS TEXT WILL BE REMOVED.
columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
<rich:panel style="width:100%">
<f:facet name="header">Files</f:facet>
+
<rich:panelMenu mode="ajax"
expandMode="client"
iconCollapsedGroup="disc"
limitToList="true"
reRender="fileContents">
- <rich:panelMenuGroup label="/tmp/raw-config" expanded="true">
- <c:forEach items="#{ExistingResourceConfigurationUIBean.configuration.rawConfigurations}"
- var="rawConfig">
- <rich:panelMenuItem label="#{rawConfig.path}"
- action="#{ExistingResourceConfigurationUIBean.select(rawConfig.path)}"
- styleClass="raw-menu-item"
- tableBorderColor="blue"
- reRender="fileContents,selectedFileHeader"/>
- </c:forEach>
- </rich:panelMenuGroup>
+ <c:forEach items="#{rawConfigDirectories}"
+ var="rawConfigDir">
+ <rich:panelMenuGroup label="#{rawConfigDir.path}"
+ expanded="true"
+ selectedChild="#{currentPath}">
+ <c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
+ <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
+ onclick="cursor_wait();"
+ oncomplete="cursor_clear();"
+ action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
+ reRender="fileContents,selectFileHeader"/>
+ </c:forEach>
+ </rich:panelMenuGroup>
+ </c:forEach>
</rich:panelMenu>
</rich:panel>
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
<a4j:status id="selectedFileHeader"
- startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
- stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
+ startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
+ stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
<h:commandLink value="View Full Screen"/>
<h:commandLink value="Upload New">
<h:graphicImage value="/images/upload.png"/>
@@ -143,6 +157,31 @@ THIS TEXT WILL BE REMOVED.
columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
<rich:panel style="width:100%">
<f:facet name="header">Files</f:facet>
+
+
+ <rich:panelMenu mode="ajax"
+ expandMode="client"
+ iconCollapsedGroup="disc"
+ limitToList="true"
+ reRender="fileContents">
+ <c:forEach items="#{rawConfigDirectories}"
+ var="rawConfigDir">
+ <rich:panelMenuGroup label="#{rawConfigDir.path}"
+ expanded="true"
+ selectedChild="#{currentPath}">
+ <c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
+ <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
+ onclick="cursor_wait();"
+ oncomplete="cursor_clear();"
+ action="#{ExistingResourceConfigurationUIBean.select(rawConfigUIBean.path)}"
+ reRender="fileContents,selectFileHeader"/>
+ </c:forEach>
+ </rich:panelMenuGroup>
+ </c:forEach>
+ </rich:panelMenu>
+
+
+ <ui:remove>
<rich:panelMenu mode="ajax"
expandMode="client"
iconCollapsedGroup="disc"
@@ -159,6 +198,7 @@ THIS TEXT WILL BE REMOVED.
</c:forEach>
</rich:panelMenuGroup>
</rich:panelMenu>
+ </ui:remove>
</rich:panel>
<h:panelGrid columns="1" style="width:100%;">
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 64ea957..b9d13b9 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -28,8 +28,6 @@ THIS TEXT WILL BE REMOVED.
<ui:define name="content">
<script type="text/javascript">
- var curentFile =
-
function cursor_wait() {
document.body.style.cursor = 'wait';
}
@@ -48,13 +46,6 @@ THIS TEXT WILL BE REMOVED.
<input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
<c:choose>
<c:when test="${ExistingResourceConfigurationViewUIBean.rawSupported}">
- <script>
- window.onbeforeunload = confirmExit;
-
- function confirmExit() {
- }
- </script>
-
<h:outputText value=" #{messages.nopermissionedit}"
rendered="#{!ResourceUIBean.permissions.configure}"/>
@@ -75,19 +66,25 @@ THIS TEXT WILL BE REMOVED.
<rich:panel style="width:100%">
<f:facet name="header">Files</f:facet>
<rich:panelMenu mode="ajax"
- expandMode="client"
- iconCollapsedGroup="disc"
- limitToList="true"
- reRender="fileContents">
- <rich:panelMenuGroup label="/tmp/raw-config" expanded="true">
- <c:forEach items="#{ExistingResourceConfigurationViewUIBean.configuration.rawConfigurations}"
- var="rawConfig">
- <rich:panelMenuItem label="#{rawConfig.path}"
- action="#{ExistingResourceConfigurationViewUIBean.select(rawConfig.path)}"
- reRender="fileContents,selectedFileHeader"/>
+ expandMode="client"
+ iconCollapsedGroup="disc"
+ limitToList="true"
+ reRender="fileContents">
+ <c:forEach items="#{rawConfigDirectories}"
+ var="rawConfigDir">
+ <rich:panelMenuGroup label="#{rawConfigDir.path}"
+ expanded="true"
+ selectedChild="#{currentPath}">
+ <c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
+ <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
+ onclick="cursor_wait();"
+ oncomplete="cursor_clear();"
+ action="#{ExistingResourceConfigurationViewUIBean.select(rawConfigUIBean.path)}"
+ reRender="fileContents,selectFileHeader"/>
+ </c:forEach>
+ </rich:panelMenuGroup>
</c:forEach>
- </rich:panelMenuGroup>
- </rich:panelMenu>
+ </rich:panelMenu>
</rich:panel>
<h:panelGrid columns="1" style="width:100%;">
@@ -209,17 +206,6 @@ THIS TEXT WILL BE REMOVED.
</c:forEach>
</rich:panelMenuGroup>
</c:forEach>
- <ui:remove>
- <rich:panelMenuGroup label="/tmp/raw-config" expanded="true" selectedChild="#{currentPath}">
- <c:forEach items="#{ExistingResourceConfigurationViewUIBean.configuration.rawConfigurations}"
- var="rawConfig">
- <rich:panelMenuItem id="raw_#{rawConfig.sha256}"
- label="#{rawConfig.path}"
- action="#{ExistingResourceConfigurationViewUIBean.select(rawConfig.path)}"
- reRender="fileContents,selectedFileHeader"/>
- </c:forEach>
- </rich:panelMenuGroup>
- </ui:remove>
</rich:panelMenu>
</rich:panel>
commit 10a71f8118aa9cce36351a96dd423966cda88723
Author: John Sanda <john(a)localhost.localdomain>
Date: Tue Jan 12 21:12:34 2010 -0500
Add javascript to change cursor to a wait cursor when changing tabs or when selecting a new file
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 25b4693..64ea957 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -27,6 +27,18 @@ THIS TEXT WILL BE REMOVED.
<ui:param name="selectedTabName" value="Configuration.Current"/>
<ui:define name="content">
+ <script type="text/javascript">
+ var curentFile =
+
+ function cursor_wait() {
+ document.body.style.cursor = 'wait';
+ }
+
+ function cursor_clear() {
+ document.body.style.cursor = 'default';
+ }
+ </script>
+
<h:panelGroup layout="block" styleClass="InfoBlock"
rendered="#{ExistingResourceConfigurationViewUIBean.updateInProgress}">
<b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']}
@@ -133,7 +145,7 @@ THIS TEXT WILL BE REMOVED.
<h:outputText value="#{ResourceUIBean.name}"/>
</h:panelGrid>
<rich:tabPanel switchType="ajax" valueChangeListener="changeTabs">
- <rich:tab label="Basic Mode">
+ <rich:tab label="Basic Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
<h:outputText value=" #{messages.nopermissionedit}"
rendered="#{!ResourceUIBean.permissions.configure}"/>
@@ -157,7 +169,7 @@ THIS TEXT WILL BE REMOVED.
prevalidate="true"/>
</rich:tab>
- <rich:tab label="Advanced Mode">
+ <rich:tab label="Advanced Mode" onlabelclick="cursor_wait();" oncomplete="cursor_clear();">
<h:outputText value=" #{messages.nopermissionedit}"
rendered="#{!ResourceUIBean.permissions.configure}"/>
@@ -190,6 +202,8 @@ THIS TEXT WILL BE REMOVED.
selectedChild="#{currentPath}">
<c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
<rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
+ onclick="cursor_wait();"
+ oncomplete="cursor_clear();"
action="#{ExistingResourceConfigurationViewUIBean.select(rawConfigUIBean.path)}"
reRender="fileContents,selectFileHeader"/>
</c:forEach>
commit f76599305b5e8ac96fcdd3f23a3ddbcb40527119
Author: John Sanda <john(a)localhost.localdomain>
Date: Tue Jan 12 17:00:28 2010 -0500
Deleting unused file that was accidentally included in a previous commit
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigDirectoryListing.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigDirectoryListing.java
deleted file mode 100644
index 89b2236..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigDirectoryListing.java
+++ /dev/null
@@ -1,42 +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.enterprise.gui.configuration.resource;
-
-import org.rhq.core.domain.configuration.RawConfiguration;
-
-import java.util.List;
-
-public class RawConfigDirectoryListing {
-
-// private List<>
-
- public void addRawConfiguration(RawConfiguration rawConfig) {
-
- }
-
-// private
-//
-// private List<RawConfiguration> get
-
-}
commit f6924d42284e00d9c3e4a6b59bb0d94e20d6fb54
Author: John Sanda <john(a)localhost.localdomain>
Date: Tue Jan 12 16:57:16 2010 -0500
Adding logic to group files by directory in the file menu
Right now this logic is only in place on the view page. Initial commit for RawConfigDirectory which is just
a container for raw config files to group them by directory. This is the initial commit for
RawConfigUIBean as well which provides properties used in the view, like displaying the short name
of the config file for instance.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 6576c05..027ce1d 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -23,19 +23,22 @@ import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.TreeMap;
import javax.faces.application.FacesMessage;
-import javax.faces.component.html.HtmlPanelGroup;
import javax.faces.event.ValueChangeEvent;
-import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jetbrains.annotations.Nullable;
import org.richfaces.event.UploadEvent;
@@ -69,23 +72,48 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
private boolean mode = STRUCTURED_MODE;
- // =========== actions ===========
+ @Out
+ private Collection<RawConfigDirectory> rawConfigDirectories;
public ExistingResourceConfigurationUIBean() {
removeSessionScopedBeanIfInView("/rhq/resource/configuration/view.xhtml",
ExistingResourceConfigurationUIBean.class);
}
- public String editConfiguration() {
- return SUCCESS_OUTCOME;
+ @Create
+ public void begin() {
+ initConfigDirectories();
}
- public String editRawConfiguration() {
- mode = RAW_MODE;
+ private void initConfigDirectories() {
+ Map<String, RawConfigDirectory> dirs = new HashMap<String, RawConfigDirectory>();
+
+ for (RawConfiguration rawConfig : getConfiguration().getRawConfigurations()) {
+ String parentDirPath = getParentDir(rawConfig);
+ RawConfigDirectory dir = dirs.get(parentDirPath);
+
+ if (dir == null) {
+ dir = new RawConfigDirectory();
+ dir.setPath(parentDirPath);
+ }
+
+ dir.addRawConfig(rawConfig);
+ dirs.put(parentDirPath, dir);
+ }
+
+ rawConfigDirectories = dirs.values();
+ }
+
+ private String getParentDir(RawConfiguration rawConfig) {
+ File file = new File(rawConfig.getPath());
+ return file.getParentFile().getAbsolutePath();
+ }
+
+ public String editConfiguration() {
return SUCCESS_OUTCOME;
}
- public String editRaw() {
+ public String editRawConfiguration() {
mode = RAW_MODE;
return SUCCESS_OUTCOME;
}
@@ -95,23 +123,44 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
switchToRaw();
}
else if (event.getNewValue().equals("Basic Mode")) {
- switchTostructured();
+ switchToStructured();
}
}
public String switchToRaw() {
-// ConfigurationMaskingUtility.unmaskConfiguration(getConfiguration(), getConfigurationDefinition());
-// int resourceId = EnterpriseFacesContextUtility.getResource().getId();
-// Configuration configuration =
-// configurationManager.translateResourceConfiguration(EnterpriseFacesContextUtility.getSubject(),
-// resourceId, getConfiguration(), true);
-//
-// setConfiguration(configuration);
-//
-// mode = RAW_MODE;
-//
-// return null;
- return switchToraw();
+ Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration(
+ EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), true);
+
+ setConfiguration(configuration);
+
+ for (RawConfiguration raw : configuration.getRawConfigurations()) {
+ getRaws().put(raw.getPath(), raw);
+ }
+ current = null;
+ setConfiguration(configuration);
+
+ mode = RAW_MODE;
+ return null;
+ }
+
+ public String switchToStructured() {
+ Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration(
+ EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), false);
+
+ for (Property property : configuration.getAllProperties().values()) {
+ property.setConfiguration(configuration);
+ }
+
+ for (RawConfiguration raw : configuration.getRawConfigurations()) {
+ getRaws().put(raw.getPath(), raw);
+ setConfiguration(configuration);
+ }
+ current = null;
+ setConfiguration(configuration);
+
+ mode = STRUCTURED_MODE;
+
+ return null;
}
public String updateConfiguration() {
@@ -256,27 +305,6 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return getConfiguration().getId();
}
- /*
- public Configuration getConfiguration() {
- if (null == configuration) {
-
- Subject subject = EnterpriseFacesContextUtility.getSubject();
- int resourceId = EnterpriseFacesContextUtility.getResource().getId();
- AbstractResourceConfigurationUpdate configurationUpdate = LookupUtil.getConfigurationManager()
- .getLatestResourceConfigurationUpdate(subject, resourceId);
- Configuration configuration = (configurationUpdate != null) ? configurationUpdate.getConfiguration() : null;
- if (configuration != null) {
- //ConfigurationMaskingUtility.maskConfiguration(configuration, getConfigurationDefinition());
- }
-
- return configuration;
-
- }
- return configuration;
-
- }
- */
-
private ConfigurationFormat getConfigurationFormat() {
return getConfigurationDefinition().getConfigurationFormat();
}
@@ -296,9 +324,7 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public String getCurrentContents() {
- String currentContents = new String(getCurrent().getContents());
- return currentContents;
-// return new String(getCurrent().getContents());
+ return new String(getCurrent().getContents());
}
public String getCurrentPath() {
@@ -329,17 +355,6 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return resourceId;
}
- /**
- * Hack Alert. This bean needs to be initialized on one of the pages that has id or resourceId set
- * In order to capture the resource. It will then Keep track of that particular resources until
- * commit is called. Ideally, this should be a conversation scoped bean, but that has other issues
- *
- */
- @Create
- public void init() {
-
- }
-
public boolean isStructuredMode() {
return mode == STRUCTURED_MODE;
}
@@ -441,57 +456,12 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return "/rhq/resource/configuration/edit-raw.xhtml?currentResourceId=" + getResourceId();
}
- public String switchToraw() {
- log.error("switch2raw called");
- dumpProperties(getConfiguration(), log);
- Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration(
- EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), true);
- log.error("switch2raw post merge");
- dumpProperties(getConfiguration(), log);
-
- setConfiguration(configuration);
- for (RawConfiguration raw : configuration.getRawConfigurations()) {
- getRaws().put(raw.getPath(), raw);
- }
- current = null;
- setConfiguration(configuration);
-
- mode = RAW_MODE;
- return null;
- }
-
void dumpProperties(Configuration conf, Log log) {
for (String key : conf.getAllProperties().keySet()) {
log.error("property=" + conf.getAllProperties().get(key));
}
}
- public String switchTostructured() {
- log.error("switch2structured called");
-
- dumpProperties(getConfiguration(), log);
- Configuration configuration = LookupUtil.getConfigurationManager().translateResourceConfiguration(
- EnterpriseFacesContextUtility.getSubject(), getResourceId(), getMergedConfiguration(), false);
- log.error("switch2structured post merge");
-
- dumpProperties(configuration, log);
-
- for (Property property : configuration.getAllProperties().values()) {
- property.setConfiguration(configuration);
- }
-
- for (RawConfiguration raw : configuration.getRawConfigurations()) {
- getRaws().put(raw.getPath(), raw);
- setConfiguration(configuration);
- }
- current = null;
- setConfiguration(configuration);
-
- mode = STRUCTURED_MODE;
-
- return null;
- }
-
void populateRaws() {
Collection<RawConfiguration> rawConfigurations = getConfiguration().getRawConfigurations();
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigDirectory.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigDirectory.java
new file mode 100644
index 0000000..fe346dd
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigDirectory.java
@@ -0,0 +1,55 @@
+/*
+ * 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.enterprise.gui.configuration.resource;
+
+import org.rhq.core.domain.configuration.RawConfiguration;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+public class RawConfigDirectory {
+
+ private String path;
+
+ private List<RawConfigUIBean> rawConfigUIBeans = new ArrayList<RawConfigUIBean>();
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public List<RawConfigUIBean> getRawConfigUIBeans() {
+ return rawConfigUIBeans;
+ }
+
+ public void addRawConfig(RawConfiguration rawConfig) {
+ RawConfigUIBean bean = new RawConfigUIBean();
+ bean.setRawConfiguration(rawConfig);
+ rawConfigUIBeans.add(bean);
+ }
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigDirectoryListing.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigDirectoryListing.java
new file mode 100644
index 0000000..89b2236
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigDirectoryListing.java
@@ -0,0 +1,42 @@
+/*
+ * 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.enterprise.gui.configuration.resource;
+
+import org.rhq.core.domain.configuration.RawConfiguration;
+
+import java.util.List;
+
+public class RawConfigDirectoryListing {
+
+// private List<>
+
+ public void addRawConfiguration(RawConfiguration rawConfig) {
+
+ }
+
+// private
+//
+// private List<RawConfiguration> get
+
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
new file mode 100644
index 0000000..21b7d41
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/RawConfigUIBean.java
@@ -0,0 +1,60 @@
+/*
+ * 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.enterprise.gui.configuration.resource;
+
+import org.rhq.core.domain.configuration.RawConfiguration;
+
+import java.io.File;
+
+public class RawConfigUIBean {
+
+ private RawConfiguration rawConfiguration;
+
+ private boolean modified;
+
+ public RawConfiguration getRawConfiguration() {
+ return rawConfiguration;
+ }
+
+ public void setRawConfiguration(RawConfiguration rawConfiguration) {
+ this.rawConfiguration = rawConfiguration;
+ }
+
+ public boolean isModified() {
+ return modified;
+ }
+
+ public void setModified(boolean modified) {
+ this.modified = modified;
+ }
+
+ public String getPath() {
+ return rawConfiguration.getPath();
+ }
+
+ public String getFileName() {
+ File file = new File(rawConfiguration.getPath());
+ return file.getName();
+ }
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml
index 0357e87..39270b7 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml
@@ -45,7 +45,7 @@
</navigation-case>
<!--<navigation-case>-->
- <!--<from-action>#{ExistingResourceConfigurationViewUIBean.switchTostructured}</from-action>-->
+ <!--<from-action>#{ExistingResourceConfigurationViewUIBean.switchToStructured}</from-action>-->
<!--<to-view-id>/rhq/resource/configuration/view.xhtml</to-view-id>-->
<!--<redirect/>-->
<!--</navigation-case>-->
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index ca24152..02ef0c1 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -46,12 +46,11 @@ THIS TEXT WILL BE REMOVED.
<rich:panelMenuGroup label="/tmp/raw-config" expanded="true">
<c:forEach items="#{ExistingResourceConfigurationUIBean.configuration.rawConfigurations}"
var="rawConfig">
- <rich:panelMenuItem action="#{ExistingResourceConfigurationUIBean.select(rawConfig.path)}"
+ <rich:panelMenuItem label="#{rawConfig.path}"
+ action="#{ExistingResourceConfigurationUIBean.select(rawConfig.path)}"
styleClass="raw-menu-item"
tableBorderColor="blue"
- reRender="fileContents,selectedFileHeader">
- #{rawConfig.path}
- </rich:panelMenuItem>
+ reRender="fileContents,selectedFileHeader"/>
</c:forEach>
</rich:panelMenuGroup>
</rich:panelMenu>
@@ -156,9 +155,7 @@ THIS TEXT WILL BE REMOVED.
action="#{ExistingResourceConfigurationUIBean.select(rawConfig.path)}"
styleClass="raw-menu-item"
tableBorderColor="blue"
- reRender="fileContents,selectedFileHeader">
- <f:param name="current" value="#{rawConfig.path}"/>
- </rich:panelMenuItem>
+ reRender="fileContents,selectedFileHeader"/>
</c:forEach>
</rich:panelMenuGroup>
</rich:panelMenu>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index adbe47e..25b4693 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -72,9 +72,7 @@ THIS TEXT WILL BE REMOVED.
var="rawConfig">
<rich:panelMenuItem label="#{rawConfig.path}"
action="#{ExistingResourceConfigurationViewUIBean.select(rawConfig.path)}"
- reRender="fileContents,selectedFileHeader">
- <f:param name="current" value="#{rawConfig.path}"/>
- </rich:panelMenuItem>
+ reRender="fileContents,selectedFileHeader"/>
</c:forEach>
</rich:panelMenuGroup>
</rich:panelMenu>
@@ -103,55 +101,6 @@ THIS TEXT WILL BE REMOVED.
</rich:panel>
</h:panelGrid>
</h:panelGrid>
-
- <ui:remove>
- <table class="summary-props-table" style="">
- <tr>
- <td bgcolor="#a4b2b9" width="25%" valign="top">Files
- <h:panelGroup id="changedFiles" layout="vertical">
- <h:form>
- <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
- <ui:repeat value="#{ExistingResourceConfigurationViewUIBean.paths}" var="path">
- <div>
- <h:commandLink
- action="#{ExistingResourceConfigurationViewUIBean.select(path)}"
- value="#{path}"
- rendered="#{path != ExistingResourceConfigurationViewUIBean.current.path}">
- <f:param name="currentPath" value="#{path}"/>
- </h:commandLink>
- <h:outputText value="#{path}"
- rendered="#{path == ExistingResourceConfigurationViewUIBean.current.path}"/>
- </div>
- </ui:repeat>
- </h:form>
- </h:panelGroup>
- <div>______________________________________</div>
- <div>* File contains uncommitted changes.</div>
- </td>
- <td>
- <div>
- Current File:
- <h:outputText value="#{ExistingResourceConfigurationViewUIBean.current.path}"
- styleClass="outhello"/>
- </div>
- <h:outputLink value="view-raw-full.xhtml" action="navigateToUpload">
- <img src="/images/viewfullscreen.png"/>
- <h:outputText value=" Full Screen "/>
- <f:param name="id" value="#{ResourceUIBean.id}"/>
- </h:outputLink>
- <s:link action="#{ExistingResourceConfigurationViewUIBean.download}">
- <img src="/images/download.png"/>
- <h:outputText value=" Download "/>
- <f:param name="id" value="#{ResourceUIBean.id}"/>
- </s:link>
- <div>
- <pre><h:outputText
- value="#{ExistingResourceConfigurationViewUIBean.currentContents}"/></pre>
- </div>
- </td>
- </tr>
- </table>
- </ui:remove>
</c:when>
<c:when test="${ExistingResourceConfigurationViewUIBean.structuredSupported}">
<h:outputText value=" #{messages.nopermissionedit}"
@@ -234,17 +183,29 @@ THIS TEXT WILL BE REMOVED.
iconCollapsedGroup="disc"
limitToList="true"
reRender="fileContents">
+ <c:forEach items="#{rawConfigDirectories}"
+ var="rawConfigDir">
+ <rich:panelMenuGroup label="#{rawConfigDir.path}"
+ expanded="true"
+ selectedChild="#{currentPath}">
+ <c:forEach items="#{rawConfigDir.rawConfigUIBeans}" var="rawConfigUIBean">
+ <rich:panelMenuItem label="#{rawConfigUIBean.fileName}"
+ action="#{ExistingResourceConfigurationViewUIBean.select(rawConfigUIBean.path)}"
+ reRender="fileContents,selectFileHeader"/>
+ </c:forEach>
+ </rich:panelMenuGroup>
+ </c:forEach>
+ <ui:remove>
<rich:panelMenuGroup label="/tmp/raw-config" expanded="true" selectedChild="#{currentPath}">
<c:forEach items="#{ExistingResourceConfigurationViewUIBean.configuration.rawConfigurations}"
var="rawConfig">
<rich:panelMenuItem id="raw_#{rawConfig.sha256}"
label="#{rawConfig.path}"
action="#{ExistingResourceConfigurationViewUIBean.select(rawConfig.path)}"
- reRender="fileContents,selectedFileHeader">
- <f:param name="current" value="#{rawConfig.path}"/>
- </rich:panelMenuItem>
+ reRender="fileContents,selectedFileHeader"/>
</c:forEach>
</rich:panelMenuGroup>
+ </ui:remove>
</rich:panelMenu>
</rich:panel>
commit d089f1c82ea348f8986d75c8d45599ba34121510
Author: John Sanda <john(a)localhost.localdomain>
Date: Tue Jan 12 14:19:43 2010 -0500
Adding tabs to switch between structured and raw on edit.xhtml.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 2e4a3c1..ca24152 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -111,17 +111,12 @@ THIS TEXT WILL BE REMOVED.
</c:when>
<c:when test="${ExistingResourceConfigurationUIBean.structuredAndRawSupported}">
- <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.structuredMode}">
- <h:outputText value="#{messages.youareviewingstructured}"/>
-
- <h:panelGroup>
- <h:outputText value=" #{messages.switch2}"/>
- <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchToRaw}">
- <h:outputText value=" files mode"/>
- </h:commandLink>
- </h:panelGroup>
-
- <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}"
+ <h:panelGrid columns="2">
+ <h:outputText value="#{ResourceUIBean.name}"/>
+ </h:panelGrid>
+ <rich:tabPanel switchType="ajax" valueChangeListener="changeTabs">
+ <rich:tab label="Basic Mode">
+ <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}"
configuration="#{ExistingResourceConfigurationUIBean.configuration}"
nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}"
nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}"
@@ -142,18 +137,9 @@ THIS TEXT WILL BE REMOVED.
title="Click to Reset Fields"
styleClass="buttonmed"/>
</h:panelGrid>
- </h:panelGroup>
- <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.rawMode}">
- <h:outputText value="#{messages.youareviewingraw}"/>
-
- <h:panelGroup>
- <h:outputText value=" #{messages.switch2}"/>
- <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchTostructured}">
- <h:outputText value=" #{messages.structured}"/>
- </h:commandLink>
- </h:panelGroup>
-
- <h:panelGrid columns="2"
+ </rich:tab>
+ <rich:tab label="Advanced Mode">
+ <h:panelGrid columns="2"
styleClass="raw-outer-table"
columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
<rich:panel style="width:100%">
@@ -212,7 +198,8 @@ THIS TEXT WILL BE REMOVED.
</h:panelGrid>
</h:panelGrid>
</h:panelGrid>
- </h:panelGroup>
+ </rich:tab>
+ </rich:tabPanel>
</c:when>
</c:choose>
commit 55407222bc09c9d577d14465d09ec0f09da237e3
Author: John Sanda <john(a)localhost.localdomain>
Date: Tue Jan 12 14:00:55 2010 -0500
Adding tabs to switch back and forth between structured and raw on view.xhtml
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index dbdc167..6576c05 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -28,6 +28,7 @@ import java.util.TreeMap;
import javax.faces.application.FacesMessage;
import javax.faces.component.html.HtmlPanelGroup;
+import javax.faces.event.ValueChangeEvent;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -89,6 +90,15 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return SUCCESS_OUTCOME;
}
+ public void changeTabs(ValueChangeEvent event) {
+ if (event.getNewValue().equals("Advanced Mode")) {
+ switchToRaw();
+ }
+ else if (event.getNewValue().equals("Basic Mode")) {
+ switchTostructured();
+ }
+ }
+
public String switchToRaw() {
// ConfigurationMaskingUtility.unmaskConfiguration(getConfiguration(), getConfigurationDefinition());
// int resourceId = EnterpriseFacesContextUtility.getResource().getId();
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index d92e747..adbe47e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -180,49 +180,36 @@ THIS TEXT WILL BE REMOVED.
</c:when>
<c:when test="${ExistingResourceConfigurationViewUIBean.structuredAndRawSupported}">
- <h:panelGroup id="structuredGroup" rendered="#{ExistingResourceConfigurationViewUIBean.structuredMode}">
- <h:outputText value="#{messages.youareviewingstructured}"/>
- <h:panelGroup>
- <h:outputText value=" #{messages.switch2}"/>
- <h:commandLink action="#{ExistingResourceConfigurationViewUIBean.switchToRaw}">
- <h:outputText value=" files mode"/>
- </h:commandLink>
- </h:panelGroup>
-
- <h:outputText value=" #{messages.nopermissionedit}"
- rendered="#{!ResourceUIBean.permissions.configure}"/>
-
- <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell"
- rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
-
- <h:commandButton id="editStructuredButton"
- value="Edit"
- action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}"
- title="Edit this Configuration" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
- </h:panelGrid>
-
- <onc:config
- configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}"
- configuration="#{ExistingResourceConfigurationViewUIBean.configuration}"
- accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}"
- readOnly="true"
- nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}"
- nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}"
- prevalidate="true"/>
-
- </h:panelGroup>
- <h:panelGroup id="rawGroup" rendered="#{ExistingResourceConfigurationViewUIBean.rawMode}">
- <h:outputText value="#{messages.youareviewingraw}"/>
-
- <h:panelGroup>
- <h:outputText value=" #{messages.switch2}"/>
- <h:commandLink action="#{ExistingResourceConfigurationViewUIBean.switchTostructured}">
- <h:outputText value=" #{messages.structured}"/>
- </h:commandLink>
- </h:panelGroup>
-
- <h:outputText value=" #{messages.nopermissionedit}"
+ <h:panelGrid columns="2">
+ <h:outputText value="#{ResourceUIBean.name}"/>
+ </h:panelGrid>
+ <rich:tabPanel switchType="ajax" valueChangeListener="changeTabs">
+ <rich:tab label="Basic Mode">
+ <h:outputText value=" #{messages.nopermissionedit}"
+ rendered="#{!ResourceUIBean.permissions.configure}"/>
+
+ <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell"
+ rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
+
+ <h:commandButton id="editStructuredButton"
+ value="Edit"
+ action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}"
+ title="Edit this Configuration" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
+ </h:panelGrid>
+
+ <onc:config
+ configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}"
+ configuration="#{ExistingResourceConfigurationViewUIBean.configuration}"
+ accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}"
+ readOnly="true"
+ nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}"
+ nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}"
+ prevalidate="true"/>
+
+ </rich:tab>
+ <rich:tab label="Advanced Mode">
+ <h:outputText value=" #{messages.nopermissionedit}"
rendered="#{!ResourceUIBean.permissions.configure}"/>
<h:panelGrid columns="2"
@@ -284,7 +271,8 @@ THIS TEXT WILL BE REMOVED.
</rich:panel>
</h:panelGrid>
</h:panelGrid>
- </h:panelGroup>
+ </rich:tab>
+ </rich:tabPanel>
</c:when>
</c:choose>
</h:form>
commit 5ed1d23e977a743d237216c6db7535cda65a3293
Author: John Sanda <john(a)localhost.localdomain>
Date: Tue Jan 12 13:20:45 2010 -0500
Seam-ifying backing bean in order to work around request scope issue with JSF
On view.xhtml, when the user clicks the links to change back and forth between structured
and raw, it results in a postback with an action method invoked to perform the translation.
A problem I encountered was that once the view rendered after the postback the backing bean
which was in request scope was no longer available to the view. Consequetly, clicking any
commandLink or commandButton did not invoke any of the specified actions. Making the backing
bean a Seam component with page scope resolved this issue.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index 555bf43..dbdc167 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -27,11 +27,15 @@ import java.util.Iterator;
import java.util.TreeMap;
import javax.faces.application.FacesMessage;
+import javax.faces.component.html.HtmlPanelGroup;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
import org.jetbrains.annotations.Nullable;
import org.richfaces.event.UploadEvent;
@@ -54,8 +58,8 @@ import org.rhq.enterprise.server.util.LookupUtil;
/**
* @author Ian Springer
*/
-//@ Name(value = "ExistingResourceConfigurationUIBean")
-//@ Scope(ScopeType.PAGE)
+@Name(value = "ExistingResourceConfigurationViewUIBean")
+(a)Scope(ScopeType.PAGE)
public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUIBean {
public static final String MANAGED_BEAN_NAME = "ExistingResourceConfigurationUIBean";
@@ -76,6 +80,12 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public String editRawConfiguration() {
+ mode = RAW_MODE;
+ return SUCCESS_OUTCOME;
+ }
+
+ public String editRaw() {
+ mode = RAW_MODE;
return SUCCESS_OUTCOME;
}
@@ -143,8 +153,6 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
return SUCCESS_OUTCOME;
}
- // =========== impls of superclass abstract methods ===========
-
protected int getConfigurationDefinitionKey() {
return EnterpriseFacesContextUtility.getResource().getResourceType().getId();
}
@@ -440,7 +448,6 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
mode = RAW_MODE;
return null;
-// return SUCCESS_OUTCOME;
}
void dumpProperties(Configuration conf, Log log) {
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/configuration-beans.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/configuration-beans.xml
index 70d3f99..d2cd3f7 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/configuration-beans.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/configuration-beans.xml
@@ -5,11 +5,11 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
<!-- /rhq/resource/configuration/view.xhtml, /rhq/resource/configuration/view-map.xhtml -->
- <managed-bean>
- <managed-bean-name>ExistingResourceConfigurationViewUIBean</managed-bean-name>
- <managed-bean-class>org.rhq.enterprise.gui.configuration.resource.ExistingResourceConfigurationUIBean</managed-bean-class>
- <managed-bean-scope>request</managed-bean-scope>
- </managed-bean>
+ <!--<managed-bean>-->
+ <!--<managed-bean-name>ExistingResourceConfigurationViewUIBean</managed-bean-name>-->
+ <!--<managed-bean-class>org.rhq.enterprise.gui.configuration.resource.ExistingResourceConfigurationUIBean</managed-bean-class>-->
+ <!--<managed-bean-scope>request</managed-bean-scope>-->
+ <!--</managed-bean> -->
<!-- /rhq/resource/configuration/history.xhtml, /rhq/resource/configuration/edit.xhtml, and
/rhq/resource/configuration/edit-map.xhtml -->
<managed-bean>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml
index bc26600..0357e87 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml
@@ -4,20 +4,27 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
- <navigation-rule>
- <from-view-id>/rhq/resource/configuration/view.xhtml</from-view-id>
-
- <navigation-case>
- <from-action>#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}</from-action>
- <from-outcome>success</from-outcome>
- <to-view-id>/rhq/resource/configuration/edit.xhtml</to-view-id>
- </navigation-case>
-
- <navigation-case>
- <from-action>#{ExistingResourceConfigurationUIBean.switchToraw}</from-action>
- <to-view-id>/rhq/resource/configuration/view.xhtml</to-view-id>
- </navigation-case>
- </navigation-rule>
+ <!--<navigation-rule>-->
+ <!--<from-view-id>/rhq/resource/configuration/view.xhtml</from-view-id>-->
+
+ <!--<navigation-case>-->
+ <!--<from-action>#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}</from-action>-->
+ <!--<from-outcome>success</from-outcome>-->
+ <!--<to-view-id>/rhq/resource/configuration/edit.xhtml</to-view-id>-->
+ <!--</navigation-case>-->
+
+ <!--<navigation-case>-->
+ <!--<from-action>#{ExistingResourceConfigurationUIBean.switchToraw}</from-action>-->
+ <!--<to-view-id>/rhq/resource/configuration/view.xhtml</to-view-id>-->
+ <!--</navigation-case>-->
+ <!--</navigation-rule>-->
+
+ <!--<navigation-rule>-->
+ <!--<navigation-case>-->
+ <!--<from-action>#{ExistingResourceConfigurationUIBean.editRawConfiguration}</from-action>-->
+ <!--<to-view-id>/rhq/resource/configuration/edit.xhtml</to-view-id>-->
+ <!--</navigation-case>-->
+ <!--</navigation-rule>-->
<navigation-rule>
<navigation-case>
@@ -26,30 +33,28 @@
<redirect/>
</navigation-case>
- <!--
<navigation-case>
<from-action>#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}</from-action>
<to-view-id>/rhq/resource/configuration/edit.xhtml?id=#{param.id}</to-view-id>
<redirect/>
</navigation-case>
- -->
-
+
<navigation-case>
<from-action>#{ConfigHelperUIBean.accessMap}</from-action>
<to-view-id>/rhq/resource/configuration/view-map.xhtml</to-view-id>
</navigation-case>
- <navigation-case>
- <from-action>#{ExistingResourceConfigurationUIBean.switchTostructured}</from-action>
- <to-view-id>/rhq/resource/configuration/edit.xhtml?id=#{param.id}</to-view-id>
- <redirect/>
- </navigation-case>
-
- <navigation-case>
- <from-action>#{ExistingResourceConfigurationUIBean.switchToraw}</from-action>
- <to-view-id>/rhq/resource/configuration/edit.xhtml</to-view-id>
+ <!--<navigation-case>-->
+ <!--<from-action>#{ExistingResourceConfigurationViewUIBean.switchTostructured}</from-action>-->
+ <!--<to-view-id>/rhq/resource/configuration/view.xhtml</to-view-id>-->
<!--<redirect/>-->
- </navigation-case>
+ <!--</navigation-case>-->
+
+ <!--<navigation-case>-->
+ <!--<from-action>#{ExistingResourceConfigurationViewUIBean.switchToRaw}</from-action>-->
+ <!--<to-view-id>/rhq/resource/configuration/view.xhtml</to-view-id>-->
+ <!--<!–<redirect/>–>-->
+ <!--</navigation-case>-->
</navigation-rule>
@@ -170,8 +175,7 @@
<navigation-case>
<from-action>#{ConfigHelperUIBean.accessMap}</from-action>
<to-view-id>/rhq/resource/configuration/history-view-map.xhtml</to-view-id>
- </navigation-case>
-
+ </navigation-case>
</navigation-rule>
</faces-config>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 8af5b00..2e4a3c1 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -59,7 +59,9 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
- <h:outputText id="selectedFileHeader" value="#{ExistingResourceConfigurationUIBean.current.path}"/>
+ <a4j:status id="selectedFileHeader"
+ startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
+ stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
<h:commandLink value="View Full Screen"/>
<h:commandLink value="Upload New">
<h:graphicImage value="/images/upload.png"/>
@@ -178,7 +180,9 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
- <h:outputText id="selectedFileHeader" value="#{ExistingResourceConfigurationUIBean.current.path}"/>
+ <a4j:status id="selectedFileHeader"
+ startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
+ stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
<h:commandLink value="View Full Screen"/>
<h:commandLink value="Upload New">
<h:graphicImage value="/images/upload.png"/>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 4154521..d92e747 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -28,24 +28,23 @@ THIS TEXT WILL BE REMOVED.
<ui:define name="content">
<h:panelGroup layout="block" styleClass="InfoBlock"
- rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}">
+ rendered="#{ExistingResourceConfigurationViewUIBean.updateInProgress}">
<b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']}
</h:panelGroup>
- <c:choose>
- <c:when test="${ExistingResourceConfigurationViewUIBean.rawSupported}">
- <script>
- window.onbeforeunload = confirmExit;
+ <h:form id="viewResourceConfigurationForm">
+ <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+ <c:choose>
+ <c:when test="${ExistingResourceConfigurationViewUIBean.rawSupported}">
+ <script>
+ window.onbeforeunload = confirmExit;
- function confirmExit() {
- }
- </script>
+ function confirmExit() {
+ }
+ </script>
- <h:outputText value=" #{messages.nopermissionedit}"
- rendered="#{!ResourceUIBean.permissions.configure}"/>
-
- <h:form id="viewResourceConfigurationFormRaw">
- <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+ <h:outputText value=" #{messages.nopermissionedit}"
+ rendered="#{!ResourceUIBean.permissions.configure}"/>
<h:panelGrid columns="2"
styleClass="buttons-table"
@@ -55,12 +54,8 @@ THIS TEXT WILL BE REMOVED.
<h:commandButton value="#{messages.editraw}"
action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationUIBean.updateInProgress}"/>
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
</h:panelGrid>
- </h:form>
-
- <h:form>
- <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
<h:panelGrid columns="2"
styleClass="raw-outer-table"
@@ -88,8 +83,8 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
<a4j:status id="selectedFileHeader"
- startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
- stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
+ startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
+ stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
<h:commandLink value="View Full Screen"/>
<h:commandLink value="Upload New">
<h:graphicImage value="/images/upload.png"/>
@@ -108,63 +103,59 @@ THIS TEXT WILL BE REMOVED.
</rich:panel>
</h:panelGrid>
</h:panelGrid>
- </h:form>
-
- <ui:remove>
- <table class="summary-props-table" style="">
- <tr>
- <td bgcolor="#a4b2b9" width="25%" valign="top">Files
- <h:panelGroup id="changedFiles" layout="vertical">
- <h:form>
- <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
- <ui:repeat value="#{ExistingResourceConfigurationViewUIBean.paths}" var="path">
- <div>
- <h:commandLink
- action="#{ExistingResourceConfigurationViewUIBean.select(path)}"
- value="#{path}"
- rendered="#{path != ExistingResourceConfigurationViewUIBean.current.path}">
- <f:param name="currentPath" value="#{path}"/>
- </h:commandLink>
- <h:outputText value="#{path}"
- rendered="#{path == ExistingResourceConfigurationViewUIBean.current.path}"/>
- </div>
- </ui:repeat>
- </h:form>
- </h:panelGroup>
- <div>______________________________________</div>
- <div>* File contains uncommitted changes.</div>
- </td>
- <td>
- <div>
- Current File:
- <h:outputText value="#{ExistingResourceConfigurationViewUIBean.current.path}"
- styleClass="outhello"/>
- </div>
- <h:outputLink value="view-raw-full.xhtml" action="navigateToUpload">
- <img src="/images/viewfullscreen.png"/>
- <h:outputText value=" Full Screen "/>
- <f:param name="id" value="#{ResourceUIBean.id}"/>
- </h:outputLink>
- <s:link action="#{ExistingResourceConfigurationViewUIBean.download}">
- <img src="/images/download.png"/>
- <h:outputText value=" Download "/>
- <f:param name="id" value="#{ResourceUIBean.id}"/>
- </s:link>
- <div>
+
+ <ui:remove>
+ <table class="summary-props-table" style="">
+ <tr>
+ <td bgcolor="#a4b2b9" width="25%" valign="top">Files
+ <h:panelGroup id="changedFiles" layout="vertical">
+ <h:form>
+ <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+ <ui:repeat value="#{ExistingResourceConfigurationViewUIBean.paths}" var="path">
+ <div>
+ <h:commandLink
+ action="#{ExistingResourceConfigurationViewUIBean.select(path)}"
+ value="#{path}"
+ rendered="#{path != ExistingResourceConfigurationViewUIBean.current.path}">
+ <f:param name="currentPath" value="#{path}"/>
+ </h:commandLink>
+ <h:outputText value="#{path}"
+ rendered="#{path == ExistingResourceConfigurationViewUIBean.current.path}"/>
+ </div>
+ </ui:repeat>
+ </h:form>
+ </h:panelGroup>
+ <div>______________________________________</div>
+ <div>* File contains uncommitted changes.</div>
+ </td>
+ <td>
+ <div>
+ Current File:
+ <h:outputText value="#{ExistingResourceConfigurationViewUIBean.current.path}"
+ styleClass="outhello"/>
+ </div>
+ <h:outputLink value="view-raw-full.xhtml" action="navigateToUpload">
+ <img src="/images/viewfullscreen.png"/>
+ <h:outputText value=" Full Screen "/>
+ <f:param name="id" value="#{ResourceUIBean.id}"/>
+ </h:outputLink>
+ <s:link action="#{ExistingResourceConfigurationViewUIBean.download}">
+ <img src="/images/download.png"/>
+ <h:outputText value=" Download "/>
+ <f:param name="id" value="#{ResourceUIBean.id}"/>
+ </s:link>
+ <div>
<pre><h:outputText
value="#{ExistingResourceConfigurationViewUIBean.currentContents}"/></pre>
- </div>
- </td>
- </tr>
- </table>
- </ui:remove>
- </c:when>
- <c:when test="${ExistingResourceConfigurationViewUIBean.structuredSupported}">
- <h:outputText value=" #{messages.nopermissionedit}"
- rendered="#{!ResourceUIBean.permissions.configure}"/>
- <h:form id="viewResourceConfigurationFormStructured">
- <!-- TODO remove the id version -->
- <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </ui:remove>
+ </c:when>
+ <c:when test="${ExistingResourceConfigurationViewUIBean.structuredSupported}">
+ <h:outputText value=" #{messages.nopermissionedit}"
+ rendered="#{!ResourceUIBean.permissions.configure}"/>
<h:panelGrid columns="2"
styleClass="buttons-table"
@@ -187,13 +178,9 @@ THIS TEXT WILL BE REMOVED.
nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}"
prevalidate="true"/>
- </h:form>
- </c:when>
- <c:when test="${ExistingResourceConfigurationViewUIBean.structuredAndRawSupported}">
- <h:form id="viewResourceConfigurationFormStructuredAndRaw">
- <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
-
- <h:panelGroup rendered="#{ExistingResourceConfigurationViewUIBean.structuredMode}">
+ </c:when>
+ <c:when test="${ExistingResourceConfigurationViewUIBean.structuredAndRawSupported}">
+ <h:panelGroup id="structuredGroup" rendered="#{ExistingResourceConfigurationViewUIBean.structuredMode}">
<h:outputText value="#{messages.youareviewingstructured}"/>
<h:panelGroup>
<h:outputText value=" #{messages.switch2}"/>
@@ -208,10 +195,11 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell"
rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
- <h:commandButton value="Edit"
+ <h:commandButton id="editStructuredButton"
+ value="Edit"
action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}"
title="Edit this Configuration" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
</h:panelGrid>
<onc:config
@@ -224,12 +212,12 @@ THIS TEXT WILL BE REMOVED.
prevalidate="true"/>
</h:panelGroup>
- <h:panelGroup rendered="#{ExistingResourceConfigurationViewUIBean.rawMode}">
+ <h:panelGroup id="rawGroup" rendered="#{ExistingResourceConfigurationViewUIBean.rawMode}">
<h:outputText value="#{messages.youareviewingraw}"/>
<h:panelGroup>
<h:outputText value=" #{messages.switch2}"/>
- <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchTostructured}">
+ <h:commandLink action="#{ExistingResourceConfigurationViewUIBean.switchTostructured}">
<h:outputText value=" #{messages.structured}"/>
</h:commandLink>
</h:panelGroup>
@@ -242,10 +230,11 @@ THIS TEXT WILL BE REMOVED.
columnClasses="button-cell"
rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
- <h:commandButton value="Edit"
+ <h:commandButton id="editRawButton"
+ value="Edit"
action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationUIBean.updateInProgress}"/>
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
</h:panelGrid>
<h:panelGrid columns="2"
@@ -295,12 +284,10 @@ THIS TEXT WILL BE REMOVED.
</rich:panel>
</h:panelGrid>
</h:panelGrid>
-
-
</h:panelGroup>
- </h:form>
- </c:when>
- </c:choose>
+ </c:when>
+ </c:choose>
+ </h:form>
<h:panelGroup layout="block" styleClass="InfoBlock"
rendered="#{ExistingResourceConfigurationViewUIBean.updateInProgress}">
commit 827523e2a0afc078733b98222cf772cdce8eb94b
Author: John Sanda <john(a)localhost.localdomain>
Date: Mon Jan 11 09:38:51 2010 -0500
Adding status msg to show which file is loading.
Also making an initial attempt to tell the panelMenu component which item is selected. It is
not working as of this commit. The documentation on this is not very clear so I am
uncertain as to whether or not I am specifying the selected menu item incorrectly.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 4eaae7b..4154521 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -87,7 +87,9 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
- <h:outputText id="selectedFileHeader" value="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
+ <a4j:status id="selectedFileHeader"
+ startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
+ stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
<h:commandLink value="View Full Screen"/>
<h:commandLink value="Upload New">
<h:graphicImage value="/images/upload.png"/>
@@ -256,10 +258,11 @@ THIS TEXT WILL BE REMOVED.
iconCollapsedGroup="disc"
limitToList="true"
reRender="fileContents">
- <rich:panelMenuGroup label="/tmp/raw-config" expanded="true">
+ <rich:panelMenuGroup label="/tmp/raw-config" expanded="true" selectedChild="#{currentPath}">
<c:forEach items="#{ExistingResourceConfigurationViewUIBean.configuration.rawConfigurations}"
var="rawConfig">
- <rich:panelMenuItem label="#{rawConfig.path}"
+ <rich:panelMenuItem id="raw_#{rawConfig.sha256}"
+ label="#{rawConfig.path}"
action="#{ExistingResourceConfigurationViewUIBean.select(rawConfig.path)}"
reRender="fileContents,selectedFileHeader">
<f:param name="current" value="#{rawConfig.path}"/>
@@ -271,8 +274,9 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
- <h:outputText id="selectedFileHeader"
- value="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
+ <a4j:status id="selectedFileHeader"
+ startText="Loading #{ExistingResourceConfigurationViewUIBean.current.path} ..."
+ stopText="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
<h:commandLink value="View Full Screen"/>
<h:commandLink value="Upload New">
<h:graphicImage value="/images/upload.png"/>
commit 3d3ce3cadc44a5f10e87684f4803e5d1d20863df
Author: John Sanda <john(a)localhost.localdomain>
Date: Mon Jan 11 09:08:32 2010 -0500
Updating controls so that there is only a single 'Edit' button
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index f7f6f7d..4eaae7b 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -206,14 +206,10 @@ THIS TEXT WILL BE REMOVED.
<h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell"
rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
- <h:commandButton value="#{messages.editstructured}"
+ <h:commandButton value="Edit"
action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}"
title="Edit this Configuration" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
- <h:commandButton value="#{messages.editraw}"
- action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
- title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
</h:panelGrid>
<onc:config
@@ -244,7 +240,7 @@ THIS TEXT WILL BE REMOVED.
columnClasses="button-cell"
rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
- <h:commandButton value="#{messages.editraw}"
+ <h:commandButton value="Edit"
action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationUIBean.updateInProgress}"/>
commit 159b6e8a62a92c83a165eda57050ee819660fbff
Author: John Sanda <john(a)localhost.localdomain>
Date: Mon Jan 11 09:00:11 2010 -0500
Adding support to switch between structured and raw in view mode
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 56afa23..f7f6f7d 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -158,7 +158,6 @@ THIS TEXT WILL BE REMOVED.
</ui:remove>
</c:when>
<c:when test="${ExistingResourceConfigurationViewUIBean.structuredSupported}">
- <h:outputText value="#{messages.youareviewingstructured}"/>
<h:outputText value=" #{messages.nopermissionedit}"
rendered="#{!ResourceUIBean.permissions.configure}"/>
<h:form id="viewResourceConfigurationFormStructured">
@@ -189,42 +188,116 @@ THIS TEXT WILL BE REMOVED.
</h:form>
</c:when>
<c:when test="${ExistingResourceConfigurationViewUIBean.structuredAndRawSupported}">
- <h:outputText value="#{messages.youareviewingstructured}"/>
- <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.rawSupported}">
- <h:outputText value=" #{messages.switch2}"/>
- <h:outputLink value="view-raw.xhtml">
- <f:param name="id" value="#{ResourceUIBean.id}"/>
- <h:outputText value=" #{messages.raw}"/>
- </h:outputLink>
- </h:panelGroup>
- <h:outputText value=" #{messages.nopermissionedit}"
- rendered="#{!ResourceUIBean.permissions.configure}"/>
<h:form id="viewResourceConfigurationFormStructuredAndRaw">
- <!-- TODO remove the id version -->
<input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+
+ <h:panelGroup rendered="#{ExistingResourceConfigurationViewUIBean.structuredMode}">
+ <h:outputText value="#{messages.youareviewingstructured}"/>
+ <h:panelGroup>
+ <h:outputText value=" #{messages.switch2}"/>
+ <h:commandLink action="#{ExistingResourceConfigurationViewUIBean.switchToRaw}">
+ <h:outputText value=" files mode"/>
+ </h:commandLink>
+ </h:panelGroup>
+
+ <h:outputText value=" #{messages.nopermissionedit}"
+ rendered="#{!ResourceUIBean.permissions.configure}"/>
+
+ <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell"
+ rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
+
+ <h:commandButton value="#{messages.editstructured}"
+ action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}"
+ title="Edit this Configuration" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
+ <h:commandButton value="#{messages.editraw}"
+ action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
+ title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
+ </h:panelGrid>
- <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell"
- rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
+ <onc:config
+ configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}"
+ configuration="#{ExistingResourceConfigurationViewUIBean.configuration}"
+ accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}"
+ readOnly="true"
+ nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}"
+ nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}"
+ prevalidate="true"/>
+
+ </h:panelGroup>
+ <h:panelGroup rendered="#{ExistingResourceConfigurationViewUIBean.rawMode}">
+ <h:outputText value="#{messages.youareviewingraw}"/>
+
+ <h:panelGroup>
+ <h:outputText value=" #{messages.switch2}"/>
+ <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchTostructured}">
+ <h:outputText value=" #{messages.structured}"/>
+ </h:commandLink>
+ </h:panelGroup>
+
+ <h:outputText value=" #{messages.nopermissionedit}"
+ rendered="#{!ResourceUIBean.permissions.configure}"/>
+
+ <h:panelGrid columns="2"
+ styleClass="buttons-table"
+ columnClasses="button-cell"
+ rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
+
+ <h:commandButton value="#{messages.editraw}"
+ action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
+ title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationUIBean.updateInProgress}"/>
+ </h:panelGrid>
- <h:commandButton value="#{messages.editstructured}"
- action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}"
- title="Edit this Configuration" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
- <h:commandButton value="#{messages.editraw}"
- action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
- title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
- </h:panelGrid>
+ <h:panelGrid columns="2"
+ styleClass="raw-outer-table"
+ columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
+ <rich:panel style="width:100%">
+ <f:facet name="header">Files</f:facet>
+ <rich:panelMenu mode="ajax"
+ expandMode="client"
+ iconCollapsedGroup="disc"
+ limitToList="true"
+ reRender="fileContents">
+ <rich:panelMenuGroup label="/tmp/raw-config" expanded="true">
+ <c:forEach items="#{ExistingResourceConfigurationViewUIBean.configuration.rawConfigurations}"
+ var="rawConfig">
+ <rich:panelMenuItem label="#{rawConfig.path}"
+ action="#{ExistingResourceConfigurationViewUIBean.select(rawConfig.path)}"
+ reRender="fileContents,selectedFileHeader">
+ <f:param name="current" value="#{rawConfig.path}"/>
+ </rich:panelMenuItem>
+ </c:forEach>
+ </rich:panelMenuGroup>
+ </rich:panelMenu>
+ </rich:panel>
+
+ <h:panelGrid columns="1" style="width:100%;">
+ <h:panelGrid columns="4" style="width:100%;">
+ <h:outputText id="selectedFileHeader"
+ value="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
+ <h:commandLink value="View Full Screen"/>
+ <h:commandLink value="Upload New">
+ <h:graphicImage value="/images/upload.png"/>
+ </h:commandLink>
+ <h:commandLink action="#{ExistingResourceConfigurationViewUIBean.download}" value="Download">
+ <h:graphicImage value="/images/download.png"/>
+ <f:param name="id" value="#{ResourceUIBean.id}"/>
+ </h:commandLink>
+ </h:panelGrid>
+
+ <rich:panel style="margin-left:1px; border: none;">
+ <h:inputTextarea id="fileContents"
+ style="width:100%"
+ value="#{ExistingResourceConfigurationViewUIBean.currentContents}"
+ readonly="true"/>
+ </rich:panel>
+ </h:panelGrid>
+ </h:panelGrid>
- <onc:config
- configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}"
- configuration="#{ExistingResourceConfigurationViewUIBean.configuration}"
- accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}"
- readOnly="true"
- nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}"
- nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}"
- prevalidate="true"/>
+ </h:panelGroup>
</h:form>
</c:when>
</c:choose>
commit b98f1271336983503559f58b2c55cb2899068b42
Author: John Sanda <john(a)localhost.localdomain>
Date: Mon Jan 11 08:28:29 2010 -0500
More refactoring to combine the structured and raw ui into edit.xhtml
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index cd9a6ce..555bf43 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -59,6 +59,11 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUIBean {
public static final String MANAGED_BEAN_NAME = "ExistingResourceConfigurationUIBean";
+ private static final boolean STRUCTURED_MODE = true;
+ private static final boolean RAW_MODE = false;
+
+ private boolean mode = STRUCTURED_MODE;
+
// =========== actions ===========
public ExistingResourceConfigurationUIBean() {
@@ -75,12 +80,18 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public String switchToRaw() {
- ConfigurationMaskingUtility.unmaskConfiguration(getConfiguration(), getConfigurationDefinition());
- int resourceId = EnterpriseFacesContextUtility.getResource().getId();
- this.configurationManager.translateResourceConfiguration(EnterpriseFacesContextUtility.getSubject(),
- resourceId, getConfiguration(), true);
-
- return SUCCESS_OUTCOME;
+// ConfigurationMaskingUtility.unmaskConfiguration(getConfiguration(), getConfigurationDefinition());
+// int resourceId = EnterpriseFacesContextUtility.getResource().getId();
+// Configuration configuration =
+// configurationManager.translateResourceConfiguration(EnterpriseFacesContextUtility.getSubject(),
+// resourceId, getConfiguration(), true);
+//
+// setConfiguration(configuration);
+//
+// mode = RAW_MODE;
+//
+// return null;
+ return switchToraw();
}
public String updateConfiguration() {
@@ -267,7 +278,9 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
public String getCurrentContents() {
- return new String(getCurrent().getContents());
+ String currentContents = new String(getCurrent().getContents());
+ return currentContents;
+// return new String(getCurrent().getContents());
}
public String getCurrentPath() {
@@ -309,6 +322,14 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
}
+ public boolean isStructuredMode() {
+ return mode == STRUCTURED_MODE;
+ }
+
+ public boolean isRawMode() {
+ return mode == RAW_MODE;
+ }
+
public boolean isModified(String path) {
return getModified().keySet().contains(path);
}
@@ -417,7 +438,9 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
current = null;
setConfiguration(configuration);
- return SUCCESS_OUTCOME;
+ mode = RAW_MODE;
+ return null;
+// return SUCCESS_OUTCOME;
}
void dumpProperties(Configuration conf, Log log) {
@@ -447,7 +470,9 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
current = null;
setConfiguration(configuration);
- return SUCCESS_OUTCOME;
+ mode = STRUCTURED_MODE;
+
+ return null;
}
void populateRaws() {
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml
index 3c21035..bc26600 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/configuration-navigation.xml
@@ -4,20 +4,35 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
- <navigation-rule>
+ <navigation-rule>
+ <from-view-id>/rhq/resource/configuration/view.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-action>#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}</from-action>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/rhq/resource/configuration/edit.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
+ <from-action>#{ExistingResourceConfigurationUIBean.switchToraw}</from-action>
+ <to-view-id>/rhq/resource/configuration/view.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+ <navigation-rule>
<navigation-case>
<from-action>#{ExistingResourceConfigurationViewUIBean.editConfiguration}</from-action>
<to-view-id>/rhq/resource/configuration/edit.xhtml?id=#{param.id}</to-view-id>
<redirect/>
</navigation-case>
+ <!--
<navigation-case>
<from-action>#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}</from-action>
- <to-view-id>/rhq/resource/configuration/edit-raw.xhtml?id=#{param.id}</to-view-id>
+ <to-view-id>/rhq/resource/configuration/edit.xhtml?id=#{param.id}</to-view-id>
<redirect/>
</navigation-case>
+ -->
<navigation-case>
<from-action>#{ConfigHelperUIBean.accessMap}</from-action>
@@ -32,8 +47,8 @@
<navigation-case>
<from-action>#{ExistingResourceConfigurationUIBean.switchToraw}</from-action>
- <to-view-id>/rhq/resource/configuration/edit-raw.xhtml?id=#{param.id}</to-view-id>
- <redirect/>
+ <to-view-id>/rhq/resource/configuration/edit.xhtml</to-view-id>
+ <!--<redirect/>-->
</navigation-case>
</navigation-rule>
@@ -71,6 +86,11 @@
<redirect/>
</navigation-case>
+ <navigation-case>
+ <from-action>#{ExistingResourceConfigurationUIBean.switchToraw}</from-action>
+ <to-view-id>/rhq/resource/configuration/edit.xhtml</to-view-id>
+ </navigation-case>
+
<navigation-case>
<from-action>#{ConfigHelperUIBean.accessMap}</from-action>
<to-view-id>/rhq/resource/configuration/edit-map.xhtml</to-view-id>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/css/win.css b/modules/enterprise/gui/portal-war/src/main/webapp/css/win.css
index 3c20d29..cd273fd 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/css/win.css
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/css/win.css
@@ -1730,6 +1730,14 @@ P.compact {
vertical-align: top;
}
+.rich-pmenu-selected-element {
+ background-color: #D8D8D8;
+}
+
+.raw-edit-footer {
+ text-align: right;
+}
+
/*--- Configuration ---------------------*/
.property-group-header {
padding: 4px;
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
index 9a8dec6..8af5b00 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/edit.xhtml
@@ -1,64 +1,251 @@
<?xml version="1.0"?>
<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jstl/core"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:a4j="http://richfaces.org/a4j"
xmlns:onc="http://jboss.org/on/component">
THIS TEXT WILL BE REMOVED.
<ui:composition template="/rhq/resource/layout/main.xhtml">
- THIS TEXT WILL BE REMOVED AS WELL.
-
- <ui:param name="pageTitle" value="#{ResourceUIBean.resourceType.name} '#{ResourceUIBean.name}' - Edit Configuration"/>
-
- <ui:param name="selectedTabName" value="Configuration.Current"/>
-
- <ui:define name="content">
-
- <h:form id="editResourceConfigurationForm" onsubmit="prepareInputsForSubmission(this)" rendered="#{!ViewResourceConfigurationUIBean.updateInProgress}">
-
-
- <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
-
- <h:outputText value="#{messages.youareviewingstructured}" />
-
- <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.structuredAndRawSupported}" >
- <h:outputText value=" #{messages.switch2}" />
- <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchToraw}" >
- <f:param name="conversationId" value="#{conversation.id}"/>
- <f:param name="id" value="#{ResourceUIBean.id}"/>
- <h:outputText value=" files mode"/>
- </h:commandLink>
- </h:panelGroup>
-
- <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}"
- configuration="#{ExistingResourceConfigurationUIBean.configuration}"
- nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}"
- nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}"
- prevalidate="true"/>
-
- <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell" rendered="#{ExistingResourceConfigurationUIBean.configuration != null}">
+ THIS TEXT WILL BE REMOVED AS WELL.
+
+ <ui:param name="pageTitle" value="#{ResourceUIBean.resourceType.name} '#{ResourceUIBean.name}' - Edit Configuration"/>
+
+ <ui:param name="selectedTabName" value="Configuration.Current"/>
+
+ <ui:define name="content">
+
+ <h:form id="editResourceConfigurationForm"
+ onsubmit="prepareInputsForSubmission(this)"
+ rendered="#{!ViewResourceConfigurationUIBean.updateInProgress}">
+
+ <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+
+ <c:choose>
+ <c:when test="${ExistingResourceConfigurationUIBean.rawSupported}">
+ <h:panelGrid columns="2"
+ styleClass="raw-outer-table"
+ columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
+ <rich:panel style="width:100%">
+ <f:facet name="header">Files</f:facet>
+ <rich:panelMenu mode="ajax"
+ expandMode="client"
+ iconCollapsedGroup="disc"
+ limitToList="true"
+ reRender="fileContents">
+ <rich:panelMenuGroup label="/tmp/raw-config" expanded="true">
+ <c:forEach items="#{ExistingResourceConfigurationUIBean.configuration.rawConfigurations}"
+ var="rawConfig">
+ <rich:panelMenuItem action="#{ExistingResourceConfigurationUIBean.select(rawConfig.path)}"
+ styleClass="raw-menu-item"
+ tableBorderColor="blue"
+ reRender="fileContents,selectedFileHeader">
+ #{rawConfig.path}
+ </rich:panelMenuItem>
+ </c:forEach>
+ </rich:panelMenuGroup>
+ </rich:panelMenu>
+ </rich:panel>
+
+ <h:panelGrid columns="1" style="width:100%;">
+ <h:panelGrid columns="4" style="width:100%;">
+ <h:outputText id="selectedFileHeader" value="#{ExistingResourceConfigurationUIBean.current.path}"/>
+ <h:commandLink value="View Full Screen"/>
+ <h:commandLink value="Upload New">
+ <h:graphicImage value="/images/upload.png"/>
+ </h:commandLink>
+ <h:commandLink action="#{ExistingResourceConfigurationUIBean.download}" value="Download">
+ <h:graphicImage value="/images/download.png"/>
+ <f:param name="id" value="#{ResourceUIBean.id}"/>
+ </h:commandLink>
+ </h:panelGrid>
+
+ <rich:panel style="margin-left:1px; border: none;">
+ <h:inputTextarea id="fileContents"
+ style="width:100%"
+ value="#{ExistingResourceConfigurationUIBean.currentContents}"
+ readonly="false"/>
+ </rich:panel>
+ </h:panelGrid>
+
+ <h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
+ <h:panelGrid columns="2">
+ <h:outputText>n files changed in this configuration</h:outputText>
+ <h:commandButton value="Commit"
+ action="#{ExistingResourceConfigurationUIBean.updateRawConfiguration}"
+ title="Click to Save Changes"
+ styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure}"/>
+ </h:panelGrid>
+ </h:panelGrid>
+ </h:panelGrid>
+ </c:when>
+
+ <c:when test="${ExistingResourceConfigurationUIBean.structuredSupported}">
+ <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}"
+ configuration="#{ExistingResourceConfigurationUIBean.configuration}"
+ nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}"
+ nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}"
+ prevalidate="true"/>
+
+ <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell"
+ rendered="#{ExistingResourceConfigurationUIBean.configuration != null}">
<h:commandButton value="SAVE" action="#{ExistingResourceConfigurationUIBean.updateConfiguration}"
title="Click to Save Changes" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure}" />
- <h:commandButton value="RESET" type="reset" immediate="true"
+ rendered="${ResourceUIBean.permissions.configure}"/>
+ <h:commandButton value="RESET" type="reset" immediate="true"
title="Click to Reset Fields" styleClass="buttonmed"/>
- </h:panelGrid>
-
- </h:form>
-
- <h:panelGroup layout="block" styleClass="InfoBlock" rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}">
- <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']}
- </h:panelGroup>
- </ui:define>
+ </h:panelGrid>
+ </c:when>
+
+ <c:when test="${ExistingResourceConfigurationUIBean.structuredAndRawSupported}">
+ <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.structuredMode}">
+ <h:outputText value="#{messages.youareviewingstructured}"/>
+
+ <h:panelGroup>
+ <h:outputText value=" #{messages.switch2}"/>
+ <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchToRaw}">
+ <h:outputText value=" files mode"/>
+ </h:commandLink>
+ </h:panelGroup>
+
+ <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}"
+ configuration="#{ExistingResourceConfigurationUIBean.configuration}"
+ nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}"
+ nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}"
+ prevalidate="true"/>
+
+ <h:panelGrid columns="2"
+ styleClass="buttons-table"
+ columnClasses="button-cell"
+ rendered="#{ExistingResourceConfigurationUIBean.configuration != null}">
+ <h:commandButton value="SAVE"
+ action="#{ExistingResourceConfigurationUIBean.updateConfiguration}"
+ title="Click to Save Changes"
+ styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure}"/>
+ <h:commandButton value="RESET"
+ type="reset"
+ immediate="true"
+ title="Click to Reset Fields"
+ styleClass="buttonmed"/>
+ </h:panelGrid>
+ </h:panelGroup>
+ <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.rawMode}">
+ <h:outputText value="#{messages.youareviewingraw}"/>
+
+ <h:panelGroup>
+ <h:outputText value=" #{messages.switch2}"/>
+ <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchTostructured}">
+ <h:outputText value=" #{messages.structured}"/>
+ </h:commandLink>
+ </h:panelGroup>
+
+ <h:panelGrid columns="2"
+ styleClass="raw-outer-table"
+ columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
+ <rich:panel style="width:100%">
+ <f:facet name="header">Files</f:facet>
+ <rich:panelMenu mode="ajax"
+ expandMode="client"
+ iconCollapsedGroup="disc"
+ limitToList="true"
+ reRender="fileContents">
+ <rich:panelMenuGroup label="/tmp/raw-config" expanded="true">
+ <c:forEach items="#{ExistingResourceConfigurationUIBean.configuration.rawConfigurations}"
+ var="rawConfig">
+ <rich:panelMenuItem label="#{rawConfig.path}"
+ action="#{ExistingResourceConfigurationUIBean.select(rawConfig.path)}"
+ styleClass="raw-menu-item"
+ tableBorderColor="blue"
+ reRender="fileContents,selectedFileHeader">
+ <f:param name="current" value="#{rawConfig.path}"/>
+ </rich:panelMenuItem>
+ </c:forEach>
+ </rich:panelMenuGroup>
+ </rich:panelMenu>
+ </rich:panel>
+
+ <h:panelGrid columns="1" style="width:100%;">
+ <h:panelGrid columns="4" style="width:100%;">
+ <h:outputText id="selectedFileHeader" value="#{ExistingResourceConfigurationUIBean.current.path}"/>
+ <h:commandLink value="View Full Screen"/>
+ <h:commandLink value="Upload New">
+ <h:graphicImage value="/images/upload.png"/>
+ </h:commandLink>
+ <h:commandLink action="#{ExistingResourceConfigurationUIBean.download}" value="Download">
+ <h:graphicImage value="/images/download.png"/>
+ <f:param name="id" value="#{ResourceUIBean.id}"/>
+ </h:commandLink>
+ </h:panelGrid>
+
+ <rich:panel style="margin-left:1px; border: none;">
+ <h:inputTextarea id="fileContents"
+ style="width:100%"
+ value="#{ExistingResourceConfigurationUIBean.currentContents}"
+ readonly="false"/>
+ </rich:panel>
+ </h:panelGrid>
+
+ <h:panelGrid columns="1" style="width:100%" columnClasses="raw-edit-footer">
+ <h:panelGrid columns="2">
+ <h:outputText>n files changed in this configuration</h:outputText>
+ <h:commandButton value="Commit"
+ action="#{ExistingResourceConfigurationUIBean.updateRawConfiguration}"
+ title="Click to Save Changes"
+ styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure}"/>
+ </h:panelGrid>
+ </h:panelGrid>
+ </h:panelGrid>
+ </h:panelGroup>
+ </c:when>
+ </c:choose>
+
+ <ui:remove>
+ <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.structuredAndRawSupported}">
+ <h:outputText value=" #{messages.switch2}"/>
+ <h:commandLink action="#{ExistingResourceConfigurationUIBean.switchToRaw}">
+ <f:param name="conversationId" value="#{conversation.id}"/>
+ <f:param name="id" value="#{ResourceUIBean.id}"/>
+ <h:outputText value=" files mode"/>
+ </h:commandLink>
+ </h:panelGroup>
+
+
+ <onc:config configurationDefinition="#{ExistingResourceConfigurationUIBean.configurationDefinition}"
+ configuration="#{ExistingResourceConfigurationUIBean.configuration}"
+ nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationDefinitionMessage}"
+ nullConfigurationMessage="#{ExistingResourceConfigurationUIBean.nullConfigurationMessage}"
+ prevalidate="true"/>
+
+ <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell"
+ rendered="#{ExistingResourceConfigurationUIBean.configuration != null}">
+ <h:commandButton value="SAVE" action="#{ExistingResourceConfigurationUIBean.updateConfiguration}"
+ title="Click to Save Changes" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure}"/>
+ <h:commandButton value="RESET" type="reset" immediate="true"
+ title="Click to Reset Fields" styleClass="buttonmed"/>
+ </h:panelGrid>
+ </ui:remove>
+
+ </h:form>
+
+ <h:panelGroup layout="block" styleClass="InfoBlock"
+ rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}">
+ <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']}
+ </h:panelGroup>
+ </ui:define>
</ui:composition>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index c6cb972..56afa23 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -41,9 +41,9 @@ THIS TEXT WILL BE REMOVED.
}
</script>
- <h:outputText value="#{messages.youareviewingraw}"/>
<h:outputText value=" #{messages.nopermissionedit}"
rendered="#{!ResourceUIBean.permissions.configure}"/>
+
<h:form id="viewResourceConfigurationFormRaw">
<input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
@@ -72,21 +72,19 @@ THIS TEXT WILL BE REMOVED.
iconCollapsedGroup="disc"
limitToList="true"
reRender="fileContents">
- <rich:panelMenuGroup label="/etc/httpd/conf">
- <rich:panelMenuItem>httpd.conf</rich:panelMenuItem>
- <rich:panelMenuItem>php.conf</rich:panelMenuItem>
- </rich:panelMenuGroup>
- <rich:panelMenuGroup label="/tmp/raw-config">
+ <rich:panelMenuGroup label="/tmp/raw-config" expanded="true">
<c:forEach items="#{ExistingResourceConfigurationViewUIBean.configuration.rawConfigurations}"
var="rawConfig">
- <rich:panelMenuItem action="#{ExistingResourceConfigurationViewUIBean.select(rawConfig.path)}"
+ <rich:panelMenuItem label="#{rawConfig.path}"
+ action="#{ExistingResourceConfigurationViewUIBean.select(rawConfig.path)}"
reRender="fileContents,selectedFileHeader">
- #{rawConfig.path}
+ <f:param name="current" value="#{rawConfig.path}"/>
</rich:panelMenuItem>
</c:forEach>
</rich:panelMenuGroup>
</rich:panelMenu>
</rich:panel>
+
<h:panelGrid columns="1" style="width:100%;">
<h:panelGrid columns="4" style="width:100%;">
<h:outputText id="selectedFileHeader" value="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
@@ -94,18 +92,17 @@ THIS TEXT WILL BE REMOVED.
<h:commandLink value="Upload New">
<h:graphicImage value="/images/upload.png"/>
</h:commandLink>
-
-
-
<h:commandLink action="#{ExistingResourceConfigurationViewUIBean.download}" value="Download">
<h:graphicImage value="/images/download.png"/>
<f:param name="id" value="#{ResourceUIBean.id}"/>
</h:commandLink>
</h:panelGrid>
+
<rich:panel style="margin-left:1px; border: none;">
<h:inputTextarea id="fileContents"
style="width:100%"
- value="#{ExistingResourceConfigurationViewUIBean.currentContents}"/>
+ value="#{ExistingResourceConfigurationViewUIBean.currentContents}"
+ readonly="true"/>
</rich:panel>
</h:panelGrid>
</h:panelGrid>
commit d7e8d0bd77d9437a86328c0d769a65e1a99e920d
Author: John Sanda <john(a)localhost.localdomain>
Date: Fri Jan 8 15:16:17 2010 -0500
Initial commit for raw config ui changes. This is just a protoype.
At this point thing raw config ui is broken as I am trying to learn how to rebuild the UI
with faclets and richfaces. I have the config files rendering in a rich panel menu, and
selecting a file in the menu will cause its contents to be displayed in the text area.
Selecting the file will also cause the path name to change and appear above the text area
on the upper left. The download functionality has been pushed into a backing bean method.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
index fd89fab..cd9a6ce 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/resource/ExistingResourceConfigurationUIBean.java
@@ -21,11 +21,14 @@ package org.rhq.enterprise.gui.configuration.resource;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
+import java.io.OutputStream;
import java.util.Collection;
import java.util.Iterator;
import java.util.TreeMap;
import javax.faces.application.FacesMessage;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -335,6 +338,7 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
public void select(String s) {
selectedPath = s;
setCurrentPath(selectedPath);
+ setCurrentContents(getCurrentContents());
}
public void setCurrentContents(String updated) {
@@ -362,6 +366,26 @@ public class ExistingResourceConfigurationUIBean extends AbstractConfigurationUI
getModified().put(raw.getPath(), raw);
}
+ public String download() {
+ try {
+ HttpServletResponse response = FacesContextUtility.getResponse();
+ response.setHeader("Content-Disposition", "attachment;filename=" + getCurrentPath());
+ OutputStream ostream = response.getOutputStream();
+ ostream.write(getCurrentContents().getBytes());
+ ostream.flush();
+ ostream.close();
+
+ FacesContextUtility.getFacesContext().responseComplete();
+
+ return null;
+ }
+ catch (IOException e) {
+ log.error("Failed to complete download request for " + getCurrentPath(), e);
+ throw new RuntimeException(e);
+ }
+// return "download";
+ }
+
/**
* This is a no-op, since the upload work was done by upload file
* But is kept as a target for the "save" icon from the full screen page
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/css/win.css b/modules/enterprise/gui/portal-war/src/main/webapp/css/win.css
index d9a8046..3c20d29 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/css/win.css
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/css/win.css
@@ -1713,6 +1713,23 @@ P.compact {
vertical-align: top;
}
+/**--- Raw Config ---------------------*/
+.raw-outer-table {
+ width: 100%;
+}
+
+.raw-outer-table-left-col {
+ width: 25%;
+ vertical-align: top;
+}
+
+.raw-outer-table-right-col {
+ /*width: 75%;*/
+ margin-left: 10px;
+ margin-right: 10px;
+ vertical-align: top;
+}
+
/*--- Configuration ---------------------*/
.property-group-header {
padding: 4px;
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
index 8a39f83..c6cb972 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/configuration/view.xhtml
@@ -10,6 +10,8 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:onc="http://jboss.org/on/component"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:a4j="http://richfaces.org/a4j"
xmlns:s="http://jboss.com/products/seam/taglib">
@@ -17,172 +19,226 @@ THIS TEXT WILL BE REMOVED.
<ui:composition template="/rhq/resource/layout/main.xhtml">
- THIS TEXT WILL BE REMOVED AS WELL.
-
- <ui:param name="pageTitle"
- value="#{ResourceUIBean.resourceType.name} '#{ResourceUIBean.name}' - View Configuration"/>
-
- <ui:param name="selectedTabName" value="Configuration.Current"/>
-
- <ui:define name="content">
- <h:panelGroup layout="block" styleClass="InfoBlock"
- rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}">
- <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']}
- </h:panelGroup>
-
- <c:choose>
- <c:when test="${ExistingResourceConfigurationViewUIBean.rawSupported}">
- <script>
- window.onbeforeunload = confirmExit;
-
- function confirmExit() {
- }
- </script>
-
- <h:outputText value="#{messages.youareviewingraw}"/>
- <h:outputText value=" #{messages.nopermissionedit}"
- rendered="#{!ResourceUIBean.permissions.configure}"/>
- <h:form id="viewResourceConfigurationFormRaw">
- <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
-
- <h:panelGrid columns="2"
- styleClass="buttons-table"
- columnClasses="button-cell"
- rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
-
- <h:commandButton value="#{messages.editraw}"
- action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
- title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationUIBean.updateInProgress}"/>
- </h:panelGrid>
- </h:form>
-
- <table class="summary-props-table" style="">
- <tr>
- <td bgcolor="#a4b2b9" width="25%" valign="top">Files
- <h:panelGroup id="changedFiles" layout="vertical">
- <h:form>
- <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
- <ui:repeat value="#{ExistingResourceConfigurationViewUIBean.paths}" var="path">
- <div>
- <h:commandLink
- action="#{ExistingResourceConfigurationViewUIBean.select(path)}"
- value="#{path}"
- rendered="#{path != ExistingResourceConfigurationViewUIBean.current.path}">
- <f:param name="currentPath" value="#{path}"/>
- </h:commandLink>
- <h:outputText value="#{path}"
- rendered="#{path == ExistingResourceConfigurationViewUIBean.current.path}"/>
- </div>
- </ui:repeat>
- </h:form>
- </h:panelGroup>
- <div>______________________________________</div>
- <div>* File contains uncommitted changes.</div>
- </td>
- <td>
- <div>
- Current File:
- <h:outputText value="#{ExistingResourceConfigurationViewUIBean.current.path}"
- styleClass="outhello"/>
- </div>
- <h:outputLink value="view-raw-full.xhtml" action="navigateToUpload">
- <img src="/images/viewfullscreen.png"/>
- <h:outputText value=" Full Screen "/>
- <f:param name="id" value="#{ResourceUIBean.id}"/>
- </h:outputLink>
- <s:link action="#{ExistingResourceConfigurationViewUIBean.download}">
- <img src="/images/download.png"/>
- <h:outputText value=" Download "/>
- <f:param name="id" value="#{ResourceUIBean.id}"/>
- </s:link>
- <div>
+ THIS TEXT WILL BE REMOVED AS WELL.
+
+ <ui:param name="pageTitle"
+ value="#{ResourceUIBean.resourceType.name} '#{ResourceUIBean.name}' - View Configuration"/>
+
+ <ui:param name="selectedTabName" value="Configuration.Current"/>
+
+ <ui:define name="content">
+ <h:panelGroup layout="block" styleClass="InfoBlock"
+ rendered="#{ExistingResourceConfigurationUIBean.updateInProgress}">
+ <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']}
+ </h:panelGroup>
+
+ <c:choose>
+ <c:when test="${ExistingResourceConfigurationViewUIBean.rawSupported}">
+ <script>
+ window.onbeforeunload = confirmExit;
+
+ function confirmExit() {
+ }
+ </script>
+
+ <h:outputText value="#{messages.youareviewingraw}"/>
+ <h:outputText value=" #{messages.nopermissionedit}"
+ rendered="#{!ResourceUIBean.permissions.configure}"/>
+ <h:form id="viewResourceConfigurationFormRaw">
+ <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+
+ <h:panelGrid columns="2"
+ styleClass="buttons-table"
+ columnClasses="button-cell"
+ rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
+
+ <h:commandButton value="#{messages.editraw}"
+ action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
+ title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationUIBean.updateInProgress}"/>
+ </h:panelGrid>
+ </h:form>
+
+ <h:form>
+ <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+
+ <h:panelGrid columns="2"
+ styleClass="raw-outer-table"
+ columnClasses="raw-outer-table-left-col,raw-outer-table-right-col">
+ <rich:panel style="width:100%">
+ <f:facet name="header">Files</f:facet>
+ <rich:panelMenu mode="ajax"
+ expandMode="client"
+ iconCollapsedGroup="disc"
+ limitToList="true"
+ reRender="fileContents">
+ <rich:panelMenuGroup label="/etc/httpd/conf">
+ <rich:panelMenuItem>httpd.conf</rich:panelMenuItem>
+ <rich:panelMenuItem>php.conf</rich:panelMenuItem>
+ </rich:panelMenuGroup>
+ <rich:panelMenuGroup label="/tmp/raw-config">
+ <c:forEach items="#{ExistingResourceConfigurationViewUIBean.configuration.rawConfigurations}"
+ var="rawConfig">
+ <rich:panelMenuItem action="#{ExistingResourceConfigurationViewUIBean.select(rawConfig.path)}"
+ reRender="fileContents,selectedFileHeader">
+ #{rawConfig.path}
+ </rich:panelMenuItem>
+ </c:forEach>
+ </rich:panelMenuGroup>
+ </rich:panelMenu>
+ </rich:panel>
+ <h:panelGrid columns="1" style="width:100%;">
+ <h:panelGrid columns="4" style="width:100%;">
+ <h:outputText id="selectedFileHeader" value="#{ExistingResourceConfigurationViewUIBean.current.path}"/>
+ <h:commandLink value="View Full Screen"/>
+ <h:commandLink value="Upload New">
+ <h:graphicImage value="/images/upload.png"/>
+ </h:commandLink>
+
+
+
+ <h:commandLink action="#{ExistingResourceConfigurationViewUIBean.download}" value="Download">
+ <h:graphicImage value="/images/download.png"/>
+ <f:param name="id" value="#{ResourceUIBean.id}"/>
+ </h:commandLink>
+ </h:panelGrid>
+ <rich:panel style="margin-left:1px; border: none;">
+ <h:inputTextarea id="fileContents"
+ style="width:100%"
+ value="#{ExistingResourceConfigurationViewUIBean.currentContents}"/>
+ </rich:panel>
+ </h:panelGrid>
+ </h:panelGrid>
+ </h:form>
+
+ <ui:remove>
+ <table class="summary-props-table" style="">
+ <tr>
+ <td bgcolor="#a4b2b9" width="25%" valign="top">Files
+ <h:panelGroup id="changedFiles" layout="vertical">
+ <h:form>
+ <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+ <ui:repeat value="#{ExistingResourceConfigurationViewUIBean.paths}" var="path">
+ <div>
+ <h:commandLink
+ action="#{ExistingResourceConfigurationViewUIBean.select(path)}"
+ value="#{path}"
+ rendered="#{path != ExistingResourceConfigurationViewUIBean.current.path}">
+ <f:param name="currentPath" value="#{path}"/>
+ </h:commandLink>
+ <h:outputText value="#{path}"
+ rendered="#{path == ExistingResourceConfigurationViewUIBean.current.path}"/>
+ </div>
+ </ui:repeat>
+ </h:form>
+ </h:panelGroup>
+ <div>______________________________________</div>
+ <div>* File contains uncommitted changes.</div>
+ </td>
+ <td>
+ <div>
+ Current File:
+ <h:outputText value="#{ExistingResourceConfigurationViewUIBean.current.path}"
+ styleClass="outhello"/>
+ </div>
+ <h:outputLink value="view-raw-full.xhtml" action="navigateToUpload">
+ <img src="/images/viewfullscreen.png"/>
+ <h:outputText value=" Full Screen "/>
+ <f:param name="id" value="#{ResourceUIBean.id}"/>
+ </h:outputLink>
+ <s:link action="#{ExistingResourceConfigurationViewUIBean.download}">
+ <img src="/images/download.png"/>
+ <h:outputText value=" Download "/>
+ <f:param name="id" value="#{ResourceUIBean.id}"/>
+ </s:link>
+ <div>
<pre><h:outputText
value="#{ExistingResourceConfigurationViewUIBean.currentContents}"/></pre>
- </div>
- </td>
- </tr>
- </table>
- </c:when>
- <c:when test="${ExistingResourceConfigurationViewUIBean.structuredSupported}">
- <h:outputText value="#{messages.youareviewingstructured}"/>
- <h:outputText value=" #{messages.nopermissionedit}"
- rendered="#{!ResourceUIBean.permissions.configure}"/>
- <h:form id="viewResourceConfigurationFormStructured">
- <!-- TODO remove the id version -->
- <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
-
- <h:panelGrid columns="2"
- styleClass="buttons-table"
- columnClasses="button-cell"
- rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
-
- <h:commandButton value="#{messages.editstructured}"
- action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}"
- title="Edit this Configuration"
- styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
- </h:panelGrid>
-
- <onc:config
- configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}"
- configuration="#{ExistingResourceConfigurationViewUIBean.configuration}"
- accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}"
- readOnly="true"
- nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}"
- nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}"
- prevalidate="true"/>
-
- </h:form>
- </c:when>
- <c:when test="${ExistingResourceConfigurationViewUIBean.structuredAndRawSupported}">
- <h:outputText value="#{messages.youareviewingstructured}"/>
- <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.rawSupported}">
- <h:outputText value=" #{messages.switch2}"/>
- <h:outputLink value="view-raw.xhtml">
- <f:param name="id" value="#{ResourceUIBean.id}"/>
- <h:outputText value=" #{messages.raw}"/>
- </h:outputLink>
- </h:panelGroup>
- <h:outputText value=" #{messages.nopermissionedit}"
- rendered="#{!ResourceUIBean.permissions.configure}"/>
- <h:form id="viewResourceConfigurationFormStructuredAndRaw">
- <!-- TODO remove the id version -->
- <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
-
- <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell"
- rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
-
- <h:commandButton value="#{messages.editstructured}"
- action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}"
- title="Edit this Configuration" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
- <h:commandButton value="#{messages.editraw}"
- action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
- title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
- rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
- </h:panelGrid>
-
- <onc:config
- configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}"
- configuration="#{ExistingResourceConfigurationViewUIBean.configuration}"
- accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}"
- readOnly="true"
- nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}"
- nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}"
- prevalidate="true"/>
-
- </h:form>
- </c:when>
- </c:choose>
-
- <h:panelGroup layout="block" styleClass="InfoBlock"
- rendered="#{ExistingResourceConfigurationViewUIBean.updateInProgress}">
- <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']}
+ </div>
+ </td>
+ </tr>
+ </table>
+ </ui:remove>
+ </c:when>
+ <c:when test="${ExistingResourceConfigurationViewUIBean.structuredSupported}">
+ <h:outputText value="#{messages.youareviewingstructured}"/>
+ <h:outputText value=" #{messages.nopermissionedit}"
+ rendered="#{!ResourceUIBean.permissions.configure}"/>
+ <h:form id="viewResourceConfigurationFormStructured">
+ <!-- TODO remove the id version -->
+ <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+
+ <h:panelGrid columns="2"
+ styleClass="buttons-table"
+ columnClasses="button-cell"
+ rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
+
+ <h:commandButton value="#{messages.editstructured}"
+ action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}"
+ title="Edit this Configuration"
+ styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
+ </h:panelGrid>
+
+ <onc:config
+ configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}"
+ configuration="#{ExistingResourceConfigurationViewUIBean.configuration}"
+ accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}"
+ readOnly="true"
+ nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}"
+ nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}"
+ prevalidate="true"/>
+
+ </h:form>
+ </c:when>
+ <c:when test="${ExistingResourceConfigurationViewUIBean.structuredAndRawSupported}">
+ <h:outputText value="#{messages.youareviewingstructured}"/>
+ <h:panelGroup rendered="#{ExistingResourceConfigurationUIBean.rawSupported}">
+ <h:outputText value=" #{messages.switch2}"/>
+ <h:outputLink value="view-raw.xhtml">
+ <f:param name="id" value="#{ResourceUIBean.id}"/>
+ <h:outputText value=" #{messages.raw}"/>
+ </h:outputLink>
</h:panelGroup>
-
-
- </ui:define>
+ <h:outputText value=" #{messages.nopermissionedit}"
+ rendered="#{!ResourceUIBean.permissions.configure}"/>
+ <h:form id="viewResourceConfigurationFormStructuredAndRaw">
+ <!-- TODO remove the id version -->
+ <input type="hidden" name="id" value="#{ResourceUIBean.id}"/>
+
+ <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell"
+ rendered="#{ExistingResourceConfigurationViewUIBean.configuration != null and !ExistingResourceConfigurationViewUIBean.updateInProgress}">
+
+ <h:commandButton value="#{messages.editstructured}"
+ action="#{ExistingResourceConfigurationViewUIBean.editConfiguration}"
+ title="Edit this Configuration" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
+ <h:commandButton value="#{messages.editraw}"
+ action="#{ExistingResourceConfigurationViewUIBean.editRawConfiguration}"
+ title="Advanced Mode Edit of Raw Configuration Files" styleClass="buttonmed"
+ rendered="${ResourceUIBean.permissions.configure and !ExistingResourceConfigurationViewUIBean.updateInProgress}"/>
+ </h:panelGrid>
+
+ <onc:config
+ configurationDefinition="#{ExistingResourceConfigurationViewUIBean.configurationDefinition}"
+ configuration="#{ExistingResourceConfigurationViewUIBean.configuration}"
+ accessMapActionExpression="#{ExistingResourceConfigurationViewUIBean.accessMap}"
+ readOnly="true"
+ nullConfigurationDefinitionMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationDefinitionMessage}"
+ nullConfigurationMessage="#{ExistingResourceConfigurationViewUIBean.nullConfigurationMessage}"
+ prevalidate="true"/>
+
+ </h:form>
+ </c:when>
+ </c:choose>
+
+ <h:panelGroup layout="block" styleClass="InfoBlock"
+ rendered="#{ExistingResourceConfigurationViewUIBean.updateInProgress}">
+ <b>${msg['note']}</b> ${msg['resource.config.Current.updateInProgress']}
+ </h:panelGroup>
+
+
+ </ui:define>
</ui:composition>
commit 241126f8eaf5dcf04e3d10cb0a80419d6cfcfee7
Author: John Sanda <john(a)localhost.localdomain>
Date: Fri Jan 8 15:07:31 2010 -0500
Initial commit for raw config ui changes
At this point thing raw config ui is broken as I am trying to learn how to rebuild the UI
with faclets and richfaces. I have the config files rendering in a rich panel menu, and
selecting a file in the menu will cause its contents to be displayed in the text area.
Selecting the file will also cause the path name to change and appear above the text area
on the upper left. The download functionality has been pushed into a backing bean method.
Updating raw-config-test plugin so that RawServer supports multiple raw files now.
diff --git a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
index e0a5d64..23af194 100644
--- a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
+++ b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
@@ -14,35 +14,50 @@ class RawServer implements ResourceComponent, ResourceConfigurationFacet {
File rawConfigDir
- File rawConfig1
+// File rawConfig1
+// File rawConfig2
+// File rawConfig3
+
+ List rawConfigs = []
def ant = new AntBuilder()
void start(ResourceContext context) {
resourceContext = context;
+ def numberOfConfigFiles = 3
+
ant = new AntBuilder()
rawConfigDir = new File("${System.getProperty('java.io.tmpdir')}/raw-config-test")
- rawConfig1 = new File(rawConfigDir, "raw-test-1.txt")
+
+ def index = 1
+
+ numberOfConfigFiles.times { rawConfigs << new File(rawConfigDir, "raw-test-${it + index++}.txt") }
+// rawConfig1 = new File(rawConfigDir, "raw-test-1.txt")
+// rawConfig2 = new File(rawConfigDir, "raw-test-2.txt")
+// rawConfig3 = new File(rawConfigDir, "raw-test-3.txt")
createRawConfigDir()
- createConfigFile()
+
+ index = 1
+ rawConfigs.each { rawConfig -> createConfigFile(rawConfig, index++) }
+// createConfigFile()
}
def createRawConfigDir() {
rawConfigDir.mkdirs()
}
- def createConfigFile() {
- if (rawConfig1.exists()) {
+ def createConfigFile(rawConfig, index) {
+ if (rawConfig.exists()) {
return null
}
- def properties = ["a": 1, "b": 2, "c": "3"]
+ def properties = ["raw${index}.a": 1, "raw${index}.b": 2, "raw${index}.c": "3"]
- rawConfig1.createNewFile()
- rawConfig1.withWriter { writer ->
+ rawConfig.createNewFile()
+ rawConfig.withWriter { writer ->
properties.each { key, value -> writer.writeLine("${key}=${value}") }
}
}
@@ -59,10 +74,15 @@ class RawServer implements ResourceComponent, ResourceConfigurationFacet {
}
Set<RawConfiguration> loadRawConfigurations() {
- def rawConfigs = new HashSet()
- rawConfigs.add(new RawConfiguration(path: rawConfig1.absolutePath, contents: rawConfig1.readBytes()))
+ def rawConfigSet = new HashSet()
+ rawConfigs.each { rawConfigSet.add(new RawConfiguration(path: it.absolutePath, contents: it.readBytes())) }
+
+ return rawConfigSet
- return rawConfigs
+// def rawConfigs = new HashSet()
+// rawConfigs.add(new RawConfiguration(path: rawConfig1.absolutePath, contents: rawConfig1.readBytes()))
+//
+// return rawConfigs
}
RawConfiguration mergeRawConfiguration(Configuration from, RawConfiguration to) {
commit 776bbc9717f14c39b2e56aeb38ac0606332f2ecb
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jan 7 12:38:37 2010 -0500
Fixing typo
diff --git a/modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml
index 64e3cb1..c4001c1 100644
--- a/modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml
@@ -17,7 +17,7 @@
<plugin-configuration>
<c:group name="Structured">
- <c:simple-property name="faidStructuredValidation" type="boolean" default="false"/>
+ <c:simple-property name="failStructuredValidation" type="boolean" default="false"/>
<c:simple-property name="failStructuredUpdate" type="boolean" default="false"/>
</c:group>
@@ -78,4 +78,4 @@
<c:simple-property name="bam"/>
</resource-configuration>
</server>
-</plugin>
\ No newline at end of file
+</plugin>
commit 500bfae124198c5cee01f6fe9079401e109e0b96
Merge: 2750b5e... b9e3538...
Author: John Sanda <john(a)localhost.localdomain>
Date: Thu Jan 7 10:26:48 2010 -0500
Merge branch 'master' into raw-config
Conflicts:
.classpath
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
diff --cc .classpath
index c530af4,a07522a..c8e2a2d
--- a/.classpath
+++ b/.classpath
@@@ -14,7 -16,7 +16,7 @@@
<classpathentry kind="src" path="modules/plugins/tomcat/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/jboss-cache/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/jboss-cache-v3/src/main/java"/>
- <classpathentry kind="src" path="modules/plugins/antlr-config/src/main/java"/>
- <classpathentry kind="src" path="etc/samples/perspectives/sample-perspective/app/src/main/java"/>
++ <classpathentry excluding="org/rhq/plugins/antlrconfig/" kind="src" path="modules/plugins/antlr-config/src/main/java"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.SP1/jboss-profileservice-spi-5.1.0.SP1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.1.1.GA/jboss-managed-2.1.1.GA.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.1.1.GA/jboss-metatype-2.1.1.GA.jar"/>
@@@ -210,9 -217,10 +217,13 @@@
<classpathentry exported="true" kind="var" path="M2_REPO/commons-codec/commons-codec/1.4/commons-codec-1.4.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/pircbot/pircbot/1.4.2/pircbot-1.4.2.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/net/homeip/yusuke/twitter4j/2.0.9/twitter4j-2.0.9.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.2.1/byteman-1.2.1.jar"/>
<classpathentry exported="true" kind="lib" path="modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-1.4.0-SNAPSHOT/wsconsume-output"/>
+ <classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
commit 2750b5e564f66c4594d6026942d897303d871c50
Author: John Sanda <john(a)localhost.localdomain>
Date: Thu Jan 7 09:20:47 2010 -0500
Adding groups for plugin configuration properties
diff --git a/modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml
index e59d833..64e3cb1 100644
--- a/modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml
@@ -16,20 +16,26 @@
description="A fake server component that supports both structured and raw configuration">
<plugin-configuration>
- <c:simple-property name="faidStructuredValidation" type="boolean" default="false"/>
- <c:simple-property name="failStructuredUpdate" type="boolean" default="false"/>
+ <c:group name="Structured">
+ <c:simple-property name="faidStructuredValidation" type="boolean" default="false"/>
+ <c:simple-property name="failStructuredUpdate" type="boolean" default="false"/>
+ </c:group>
- <c:simple-property name="failRawValidation" type="boolean" default="false"/>
- <c:simple-property name="filesToFailValidation"
- description="A comma-delimited list of file names for which validation will fail. The entire
- path does not need to be specified. Simple matching will be done starting from
- the end of the path. For a path of /foo/bar.txt, you could specify bar.txt."/>
+ <c:group name="Raw Validation">
+ <c:simple-property name="failRawValidation" type="boolean" default="false"/>
+ <c:simple-property name="filesToFailValidation"
+ description="A whitespace-separated list of file names for which validation will fail. The entire
+ path does not need to be specified. Simple matching will be done starting from
+ the end of the path. For a path of /foo/bar.txt, you could specify bar.txt."/>
+ </c:group>
- <c:simple-property name="failRawUpdate" type="boolean" default="false"/>
- <c:simple-property name="filesToFailUpdate"
- description="A comma-delimited list of file names for which the update will fail. The entire
- path does not need to be specified. Simple matching will be done starting from
- the end of the path. For a path of /foo/bar.txt, you could specify bar.txt."/>
+ <c:group name="Raw Update">
+ <c:simple-property name="failRawUpdate" type="boolean" default="false"/>
+ <c:simple-property name="filesToFailUpdate"
+ description="A whitespace-separated list of file names for which the update will fail. The entire
+ path does not need to be specified. Simple matching will be done starting from
+ the end of the path. For a path of /foo/bar.txt, you could specify bar.txt."/>
+ </c:group>
</plugin-configuration>
<resource-configuration configurationFormat="both">
commit 9d0ee5cc056c3d555f5c0d2fa684ef760acb857e
Author: John Sanda <john(a)localhost.localdomain>
Date: Thu Jan 7 06:40:50 2010 -0500
Removing unused classes and cleaning up imports
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
index 8389c41..dbf131b 100644
--- 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
@@ -23,13 +23,14 @@
package org.rhq.core.pc.configuration;
-import static org.rhq.core.domain.configuration.definition.ConfigurationFormat.*;
-
+import org.apache.maven.artifact.versioning.ComparableVersion;
+import org.rhq.core.clientapi.agent.PluginContainerException;
import 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;
+import org.rhq.core.pc.util.ComponentService;
+
+import static org.rhq.core.domain.configuration.definition.ConfigurationFormat.RAW;
+import static org.rhq.core.domain.configuration.definition.ConfigurationFormat.STRUCTURED;
public class ConfigManagementFactoryImpl implements ConfigManagementFactory {
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
index 5ab7269..104f41c 100644
--- 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
@@ -23,11 +23,11 @@
package org.rhq.core.pc.configuration;
+import org.rhq.core.clientapi.agent.PluginContainerException;
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;
+import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
public abstract class ConfigManagementSupport implements ConfigManagement {
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 b360858..5a0e155 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,35 +22,38 @@
*/
package org.rhq.core.pc.configuration;
-import java.util.Set;
-import java.util.Queue;
-import java.util.LinkedList;
-import java.util.concurrent.*;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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.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.RawConfiguration;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pc.ContainerService;
-import org.rhq.core.pc.PluginContainerConfiguration;
import org.rhq.core.pc.PluginContainer;
-import org.rhq.core.pc.util.ComponentService;
+import org.rhq.core.pc.PluginContainerConfiguration;
import org.rhq.core.pc.agent.AgentService;
+import org.rhq.core.pc.util.ComponentService;
import org.rhq.core.pc.util.ComponentUtil;
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 java.util.LinkedList;
+import java.util.Queue;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
/**
* Manages configuration of all resources across all plugins.
*
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationUtilityServiceImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationUtilityServiceImpl.java
index 771b0b5..2f14f17 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationUtilityServiceImpl.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationUtilityServiceImpl.java
@@ -23,9 +23,9 @@
package org.rhq.core.pc.configuration;
+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.clientapi.agent.configuration.ConfigurationUtility;
import java.util.List;
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
index 98ec1c6..5f6b6ab 100644
--- 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
@@ -28,13 +28,9 @@ 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.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
-import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
-import java.util.LinkedList;
-import java.util.List;
import java.util.Set;
public class RawConfigManagement extends ConfigManagementSupport {
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawUpdateErrorDetail.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawUpdateErrorDetail.java
deleted file mode 100644
index 7e8f9ca..0000000
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawUpdateErrorDetail.java
+++ /dev/null
@@ -1,57 +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.domain.configuration.RawConfiguration;
-
-public class RawUpdateErrorDetail {
-
- private RawConfiguration rawConfig;
-
- private Throwable error;
-
- public RawUpdateErrorDetail() {
- }
-
- public RawUpdateErrorDetail(RawConfiguration rawConfig, Throwable error) {
- this.rawConfig = rawConfig;
- this.error = error;
- }
-
- public RawConfiguration getRawConfiguration() {
- return rawConfig;
- }
-
- public void setRawConfiguration(RawConfiguration rawConfig) {
- this.rawConfig = rawConfig;
- }
-
- public Throwable getError() {
- return error;
- }
-
- public void setError(Throwable error) {
- this.error = error;
- }
-}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawUpdateException.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawUpdateException.java
deleted file mode 100644
index 22ba9f1..0000000
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawUpdateException.java
+++ /dev/null
@@ -1,53 +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 java.util.LinkedList;
-import java.util.List;
-
-public class RawUpdateException extends ConfigurationUpdateException {
-
- private List<RawUpdateErrorDetail> details = new LinkedList<RawUpdateErrorDetail>();
-
- public RawUpdateException(List<RawUpdateErrorDetail> errors) {
- details = errors;
- }
-
- public RawUpdateException(String message, List<RawUpdateErrorDetail> errors) {
- super(message);
- details = errors;
- }
-
- public RawUpdateException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public RawUpdateException(Throwable cause) {
- super(cause);
- }
-
- public List<RawUpdateErrorDetail> getDetails() {
- return details;
- }
-}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagement.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagement.java
index b0b1728..957c973 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagement.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagement.java
@@ -23,19 +23,19 @@
package org.rhq.core.pc.configuration;
-import static java.util.Collections.EMPTY_SET;
-
+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.clientapi.agent.PluginContainerException;
import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import java.util.List;
import java.util.Set;
+import static java.util.Collections.EMPTY_SET;
+
public class StructuredAndRawConfigManagement extends ConfigManagementSupport {
private final Log log = LogFactory.getLog(StructuredAndRawConfigManagement.class);
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredConfigManagement.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredConfigManagement.java
index 85023a4..e2b1bb7 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredConfigManagement.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredConfigManagement.java
@@ -74,7 +74,6 @@ public class StructuredConfigManagement extends ConfigManagementSupport {
facet.persistStructuredConfiguration(configuration);
}
catch (Throwable t) {
-// throw new StructuredUpdateException(t);
throw new ConfigurationUpdateException(t.getMessage());
}
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredUpdateException.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredUpdateException.java
deleted file mode 100644
index c0ba380..0000000
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredUpdateException.java
+++ /dev/null
@@ -1,43 +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;
-
-public class StructuredUpdateException extends ConfigurationUpdateException {
-
- public StructuredUpdateException() {
- super();
- }
-
- public StructuredUpdateException(String message) {
- super(message);
- }
-
- public StructuredUpdateException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public StructuredUpdateException(Throwable cause) {
- super(cause);
- }
-}
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 1ad81f6..b9c3415 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
@@ -23,24 +23,25 @@
package org.rhq.core.pc.configuration;
+import org.rhq.core.clientapi.server.configuration.ConfigurationUpdateResponse;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
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.core.clientapi.server.configuration.ConfigurationUpdateResponse;
-import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pc.util.ComponentService;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.test.JMockTest;
-
-import static org.rhq.test.AssertUtils.*;
-import static org.testng.Assert.assertEquals;
import org.testng.annotations.BeforeMethod;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
+import static org.rhq.test.AssertUtils.assertCollectionEqualsNoOrder;
+import static org.rhq.test.AssertUtils.assertPropertiesMatch;
+import static org.testng.Assert.assertEquals;
+
public class ConfigManagementTest extends JMockTest {
Random random = new Random();
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 6418922..b43a892 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
@@ -23,28 +23,30 @@
package org.rhq.core.pc.configuration;
-import static org.testng.Assert.*;
-
+import org.hamcrest.Matcher;
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.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.RawConfiguration;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.RawConfiguration;
import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.pc.util.FacetLockType;
import org.rhq.core.pc.PluginContainerConfiguration;
import org.rhq.core.pc.ServerServices;
+import org.rhq.core.pc.util.FacetLockType;
import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
import org.rhq.test.jmock.PropertyMatcher;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import org.hamcrest.Matcher;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
public class ConfigurationManagerTest extends ConfigManagementTest {
static final String LEGACY_AMPS_VERSION = "2.0";
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
index e093d68..5db3fd1 100644
--- 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
@@ -23,21 +23,19 @@
package org.rhq.core.pc.configuration;
-import static org.testng.Assert.*;
-import static java.util.Collections.EMPTY_SET;
-
import org.jmock.Expectations;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.RawConfiguration;
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 java.util.List;
import java.util.Set;
+import static java.util.Collections.EMPTY_SET;
+import static org.testng.Assert.assertNull;
+
public class RawConfigManagementTest extends ConfigManagementTest {
ResourceConfigurationFacet configFacet;
@@ -126,7 +124,6 @@ public class RawConfigManagementTest extends ConfigManagementTest {
rawConfigMgmt.executeUpdate(resourceId, config);
}
-// @Test(expectedExceptions = {RawUpdateException.class})
@Test(expectedExceptions = {ConfigurationUpdateException.class})
public void exceptionShouldBeThrownWhenValidationFailsForSingleRaw() throws Exception {
final RawConfiguration raw = createRawConfiguration("/tmp/raw.txt");
@@ -143,7 +140,6 @@ public class RawConfigManagementTest extends ConfigManagementTest {
rawConfigMgmt.executeUpdate(resourceId, config);
}
-// @Test(expectedExceptions = {RawUpdateException.class})
@Test(expectedExceptions = {ConfigurationUpdateException.class})
public void exceptionShouldBeThrownWhenUpdateFailsForSingleRaw() throws Exception {
final RawConfiguration raw = createRawConfiguration("/tmp/raw.txt");
@@ -186,7 +182,6 @@ public class RawConfigManagementTest extends ConfigManagementTest {
rawConfigMgmt.executeUpdate(resourceId, config);
}
-// @Test
@Test(expectedExceptions = {ConfigurationUpdateException.class})
public void secondRawShouldStillGetUpdatedWhenFirstRawFailsValidation() throws Exception {
final RawConfiguration raw1 = createRawConfiguration("/tmp/raw1.txt");
@@ -207,30 +202,8 @@ public class RawConfigManagementTest extends ConfigManagementTest {
}});
rawConfigMgmt.executeUpdate(resourceId, config);
-
-// RawUpdateException exception = null;
-//
-// try {
-// rawConfigMgmt.executeUpdate(resourceId, config);
-// }
-// catch (RawUpdateException e) {
-// exception = e;
-// }
-//
-// assertNotNull(exception, "Expected a " + RawUpdateException.class.getSimpleName() + " to be thrown when " +
-// " validation fails");
-//
-// List<RawUpdateErrorDetail> errors = exception.getDetails();
-//
-// assertEquals(errors.size(), 1, "Expected to find only a single error since only the update of one raw failed");
-// assertEquals(
-// errors.get(0).getRawConfiguration(),
-// raw1,
-// "Expected to find " + raw1 + " since validation for it failed"
-// );
}
-// @Test
@Test(expectedExceptions = {ConfigurationUpdateException.class})
public void secondRawShouldStillGetUpdateWhenFirstRawUpdateFails() throws Exception {
final RawConfiguration raw1 = createRawConfiguration("/tmp/raw1.txt");
@@ -253,30 +226,8 @@ public class RawConfigManagementTest extends ConfigManagementTest {
}});
rawConfigMgmt.executeUpdate(resourceId, config);
-
-// RawUpdateException exception = null;
-//
-// try {
-// rawConfigMgmt.executeUpdate(resourceId, config);
-// }
-// catch (RawUpdateException e) {
-// exception = e;
-// }
-//
-// assertNotNull(exception, "Expected a " + RawUpdateException.class.getSimpleName() + " to be thrown when " +
-// " update fails");
-//
-// List<RawUpdateErrorDetail> errors = exception.getDetails();
-//
-// assertEquals(errors.size(), 1, "Expected to find only a single error since only the update of one raw failed");
-// assertEquals(
-// errors.get(0).getRawConfiguration(),
-// raw1,
-// "Expected to find " + raw1 + " since update for it failed"
-// );
}
-// @Test
@Test(expectedExceptions = {ConfigurationUpdateException.class})
public void noUpdatesShouldHappenWhenValidationFailsForBothRaws() throws Exception {
final RawConfiguration raw1 = createRawConfiguration("/tmp/raw1.txt");
@@ -295,33 +246,6 @@ public class RawConfigManagementTest extends ConfigManagementTest {
}});
rawConfigMgmt.executeUpdate(resourceId, config);
-
-// RawUpdateException exception = null;
-//
-// try {
-// rawConfigMgmt.executeUpdate(resourceId, config);
-// }
-// catch (RawUpdateException e) {
-// exception = e;
-// }
-//
-// assertNotNull(exception, "Expected a " + RawUpdateException.class.getSimpleName() + " to be thrown when " +
-// " update fails");
-//
-// List<RawUpdateErrorDetail> errors = exception.getDetails();
-//
-// assertEquals(errors.size(), 2, "Expected to find two errors since validation failed for both raw config files");
-// assertErrorDetailsContainsRawConfig(errors, raw1);
-// assertErrorDetailsContainsRawConfig(errors, raw2);
- }
-
- private void assertErrorDetailsContainsRawConfig(List<RawUpdateErrorDetail> errors, RawConfiguration rawConfig) {
- for (RawUpdateErrorDetail detail : errors) {
- if (detail.getRawConfiguration().equals(rawConfig)) {
- return;
- }
- }
- fail("Expected to find " + rawConfig + " in update error details");
}
private void addDefaultExpectationsForUpdate() throws Exception {
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagementTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagementTest.java
index b53fd00..b8903ea 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagementTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagementTest.java
@@ -23,22 +23,22 @@
package org.rhq.core.pc.configuration;
-import static org.testng.Assert.*;
-import static java.util.Collections.*;
-
-import org.rhq.core.pc.util.FacetLockType;
-import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
+import org.jmock.Expectations;
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.configuration.RawConfiguration;
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.ResourceConfigurationFacet;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import org.jmock.Expectations;
import java.util.Set;
+import static java.util.Collections.EMPTY_SET;
+import static org.testng.Assert.assertNull;
+
public class StructuredAndRawConfigManagementTest extends ConfigManagementTest {
ResourceConfigurationFacet configFacet;
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredConfigManagementTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredConfigManagementTest.java
index 43d5c73..b869569 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredConfigManagementTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredConfigManagementTest.java
@@ -28,10 +28,11 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
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 org.testng.Assert.assertNull;
+
public class StructuredConfigManagementTest extends ConfigManagementTest {
ResourceConfigurationFacet configFacet;
@@ -128,7 +129,6 @@ public class StructuredConfigManagementTest extends ConfigManagementTest {
structuredMgmt.executeUpdate(resourceId, config);
}
-// @Test(expectedExceptions = {StructuredUpdateException.class})
@Test(expectedExceptions = {ConfigurationUpdateException.class})
public void exceptionShouldBeThrownWhenValidationFails() throws Exception {
final Configuration config = new Configuration();
@@ -142,7 +142,6 @@ public class StructuredConfigManagementTest extends ConfigManagementTest {
structuredMgmt.executeUpdate(resourceId, config);
}
-// @Test(expectedExceptions = {StructuredUpdateException.class})
@Test(expectedExceptions = {ConfigurationUpdateException.class})
public void exceptionShouldBeThrownWhenUpdateFails() throws Exception {
final Configuration config = new Configuration();
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 7dd18b0..54edf77 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
@@ -33,13 +33,14 @@ 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 static org.rhq.core.domain.configuration.ConfigurationUpdateStatus.FAILURE;
-import static org.rhq.core.domain.configuration.ConfigurationUpdateStatus.SUCCESS;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.test.jmock.PropertyMatcher;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import static org.rhq.core.domain.configuration.ConfigurationUpdateStatus.FAILURE;
+import static org.rhq.core.domain.configuration.ConfigurationUpdateStatus.SUCCESS;
+
public class UpdateResourceConfigurationRunnerTest extends ConfigManagementTest {
ConfigManagement configMgmt;
commit 6513411790aa5f03ebd26213cda8272d010c1b37
Author: John Sanda <john(a)localhost.localdomain>
Date: Thu Jan 7 06:19:40 2010 -0500
Updating/adding validation support for configs that support structured and raw
Updating logic that generates the various ConfigurationUpdateExceptions to just return the
error message as an unformatted string, not as an xml document. No longer using
StructuredUpdateException or RawUpdateException as they do not seem necessary.
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationUpdateException.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationUpdateException.java
new file mode 100644
index 0000000..fdc3018
--- /dev/null
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/configuration/ResourceConfigurationUpdateException.java
@@ -0,0 +1,49 @@
+/*
+ * 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.pluginapi.configuration;
+
+
+/**
+ * This exception can be thrown by instances of {@link ResourceConfigurationFacet} to indicate an update failed. This
+ * exception can be throw by the validateXXX methods to indicate that validation failed or by the persistXXX method to
+ * indicate that the actual update failed.
+ * <br/><br/>
+ * Any unchecked exception thrown from the validateXXX or from the persistXXX methods will be treated as an update
+ * failure. When a ResourceConfigurationUpdateException is thrown, only the error messages associated with it are sent
+ * back to the server whereas with any other exception, the entire stack trace is sent up to the server. The reason for
+ * this is that with a ResourceConfigurationUpdateException, the plugin container assumes that the failure has been
+ * handled in some fashion. For instance, catching any exceptions that might thrown from attempting to apply the update.
+ * Or consider a scenario in which applying the update involves calling out to an external program. The failed update
+ * might only be reported back with some error code.
+ * <br/><br/>
+ * With any other exception, the plugin container cannot reasonably assume that any errors were handled and as such
+ * reports the entire stack trace back to the server to provide additional information for debugging if necessary.
+ */
+public class ResourceConfigurationUpdateException extends RuntimeException {
+
+ public ResourceConfigurationUpdateException(String message) {
+ super(message);
+ }
+
+}
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
index 6193fd2..8389c41 100644
--- 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
@@ -25,6 +25,7 @@ package org.rhq.core.pc.configuration;
import static org.rhq.core.domain.configuration.definition.ConfigurationFormat.*;
+import 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;
@@ -63,6 +64,12 @@ public class ConfigManagementFactoryImpl implements ConfigManagementFactory {
ResourceType resourceType = componentService.getResourceType(resourceId);
+ ConfigurationFormat format = resourceType.getResourceConfigurationDefinition().getConfigurationFormat();
+ switch (format) {
+ case RAW: break;
+ default: ;
+ }
+
if (isStructured(resourceType)) {
return new StructuredConfigManagement();
}
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
index 1a9b21c..98ec1c6 100644
--- 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
@@ -67,7 +67,7 @@ public class RawConfigManagement extends ConfigManagementSupport {
throws PluginContainerException {
ResourceConfigurationFacet facet = loadResourceConfigFacetWithWriteLock(resourceId);
- List<RawUpdateErrorDetail> errors = new LinkedList<RawUpdateErrorDetail>();
+ StringBuilder errors = new StringBuilder();
for (RawConfiguration rawConfig : configuration.getRawConfigurations()) {
try {
@@ -76,12 +76,12 @@ public class RawConfigManagement extends ConfigManagementSupport {
}
catch (Throwable t) {
// TODO Might want to specify in the error detail whether the validate or update call failed
- errors.add(new RawUpdateErrorDetail(rawConfig, t));
+ errors.append(t.getMessage()).append("\n\n");
}
}
- if (errors.size() > 0) {
- throw new RawUpdateException(errors);
+ if (errors.length() > 0) {
+ throw new ConfigurationUpdateException(errors.toString());
}
}
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagement.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagement.java
index 3f976c7..b0b1728 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagement.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagement.java
@@ -87,9 +87,28 @@ public class StructuredAndRawConfigManagement extends ConfigManagementSupport {
public void executeUpdate(int resourceId, Configuration configuration) throws PluginContainerException {
ResourceConfigurationFacet facet = loadResourceConfigFacetWithWriteLock(resourceId);
- facet.persistStructuredConfiguration(configuration);
+ StringBuilder errors = new StringBuilder();
+
+ try {
+ facet.validateStructuredConfiguration(configuration);
+ facet.persistStructuredConfiguration(configuration);
+ }
+ catch (Throwable t) {
+ errors.append(t.getMessage());
+ }
+
for (RawConfiguration rawConfig : configuration.getRawConfigurations()) {
- facet.persistRawConfiguration(rawConfig);
+ try {
+ facet.validateRawConfiguration(rawConfig);
+ facet.persistRawConfiguration(rawConfig);
+ }
+ catch (Throwable t) {
+ errors.append(t.getMessage()).append("\n\n");
+ }
+ }
+
+ if (errors.length() > 0) {
+ throw new ConfigurationUpdateException(errors.toString());
}
}
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredConfigManagement.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredConfigManagement.java
index 7cd57b7..85023a4 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredConfigManagement.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredConfigManagement.java
@@ -74,7 +74,8 @@ public class StructuredConfigManagement extends ConfigManagementSupport {
facet.persistStructuredConfiguration(configuration);
}
catch (Throwable t) {
- throw new StructuredUpdateException(t);
+// throw new StructuredUpdateException(t);
+ throw new ConfigurationUpdateException(t.getMessage());
}
}
}
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
index c1ac859..e093d68 100644
--- 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
@@ -126,7 +126,8 @@ public class RawConfigManagementTest extends ConfigManagementTest {
rawConfigMgmt.executeUpdate(resourceId, config);
}
- @Test(expectedExceptions = {RawUpdateException.class})
+// @Test(expectedExceptions = {RawUpdateException.class})
+ @Test(expectedExceptions = {ConfigurationUpdateException.class})
public void exceptionShouldBeThrownWhenValidationFailsForSingleRaw() throws Exception {
final RawConfiguration raw = createRawConfiguration("/tmp/raw.txt");
@@ -142,7 +143,8 @@ public class RawConfigManagementTest extends ConfigManagementTest {
rawConfigMgmt.executeUpdate(resourceId, config);
}
- @Test(expectedExceptions = {RawUpdateException.class})
+// @Test(expectedExceptions = {RawUpdateException.class})
+ @Test(expectedExceptions = {ConfigurationUpdateException.class})
public void exceptionShouldBeThrownWhenUpdateFailsForSingleRaw() throws Exception {
final RawConfiguration raw = createRawConfiguration("/tmp/raw.txt");
@@ -184,7 +186,8 @@ public class RawConfigManagementTest extends ConfigManagementTest {
rawConfigMgmt.executeUpdate(resourceId, config);
}
- @Test
+// @Test
+ @Test(expectedExceptions = {ConfigurationUpdateException.class})
public void secondRawShouldStillGetUpdatedWhenFirstRawFailsValidation() throws Exception {
final RawConfiguration raw1 = createRawConfiguration("/tmp/raw1.txt");
final RawConfiguration raw2 = createRawConfiguration("/tmp/raw2.txt");
@@ -203,29 +206,32 @@ public class RawConfigManagementTest extends ConfigManagementTest {
oneOf(configFacet).persistRawConfiguration(raw2);
}});
- RawUpdateException exception = null;
-
- try {
- rawConfigMgmt.executeUpdate(resourceId, config);
- }
- catch (RawUpdateException e) {
- exception = e;
- }
-
- assertNotNull(exception, "Expected a " + RawUpdateException.class.getSimpleName() + " to be thrown when " +
- " validation fails");
-
- List<RawUpdateErrorDetail> errors = exception.getDetails();
+ rawConfigMgmt.executeUpdate(resourceId, config);
- assertEquals(errors.size(), 1, "Expected to find only a single error since only the update of one raw failed");
- assertEquals(
- errors.get(0).getRawConfiguration(),
- raw1,
- "Expected to find " + raw1 + " since validation for it failed"
- );
+// RawUpdateException exception = null;
+//
+// try {
+// rawConfigMgmt.executeUpdate(resourceId, config);
+// }
+// catch (RawUpdateException e) {
+// exception = e;
+// }
+//
+// assertNotNull(exception, "Expected a " + RawUpdateException.class.getSimpleName() + " to be thrown when " +
+// " validation fails");
+//
+// List<RawUpdateErrorDetail> errors = exception.getDetails();
+//
+// assertEquals(errors.size(), 1, "Expected to find only a single error since only the update of one raw failed");
+// assertEquals(
+// errors.get(0).getRawConfiguration(),
+// raw1,
+// "Expected to find " + raw1 + " since validation for it failed"
+// );
}
- @Test
+// @Test
+ @Test(expectedExceptions = {ConfigurationUpdateException.class})
public void secondRawShouldStillGetUpdateWhenFirstRawUpdateFails() throws Exception {
final RawConfiguration raw1 = createRawConfiguration("/tmp/raw1.txt");
final RawConfiguration raw2 = createRawConfiguration("/tmp/raw2.txt");
@@ -246,29 +252,32 @@ public class RawConfigManagementTest extends ConfigManagementTest {
oneOf(configFacet).persistRawConfiguration(raw2);
}});
- RawUpdateException exception = null;
-
- try {
- rawConfigMgmt.executeUpdate(resourceId, config);
- }
- catch (RawUpdateException e) {
- exception = e;
- }
-
- assertNotNull(exception, "Expected a " + RawUpdateException.class.getSimpleName() + " to be thrown when " +
- " update fails");
-
- List<RawUpdateErrorDetail> errors = exception.getDetails();
+ rawConfigMgmt.executeUpdate(resourceId, config);
- assertEquals(errors.size(), 1, "Expected to find only a single error since only the update of one raw failed");
- assertEquals(
- errors.get(0).getRawConfiguration(),
- raw1,
- "Expected to find " + raw1 + " since update for it failed"
- );
+// RawUpdateException exception = null;
+//
+// try {
+// rawConfigMgmt.executeUpdate(resourceId, config);
+// }
+// catch (RawUpdateException e) {
+// exception = e;
+// }
+//
+// assertNotNull(exception, "Expected a " + RawUpdateException.class.getSimpleName() + " to be thrown when " +
+// " update fails");
+//
+// List<RawUpdateErrorDetail> errors = exception.getDetails();
+//
+// assertEquals(errors.size(), 1, "Expected to find only a single error since only the update of one raw failed");
+// assertEquals(
+// errors.get(0).getRawConfiguration(),
+// raw1,
+// "Expected to find " + raw1 + " since update for it failed"
+// );
}
- @Test
+// @Test
+ @Test(expectedExceptions = {ConfigurationUpdateException.class})
public void noUpdatesShouldHappenWhenValidationFailsForBothRaws() throws Exception {
final RawConfiguration raw1 = createRawConfiguration("/tmp/raw1.txt");
final RawConfiguration raw2 = createRawConfiguration("/tmp/raw2.txt");
@@ -285,23 +294,25 @@ public class RawConfigManagementTest extends ConfigManagementTest {
oneOf(configFacet).validateRawConfiguration(raw2); will(throwException(new RuntimeException()));
}});
- RawUpdateException exception = null;
-
- try {
- rawConfigMgmt.executeUpdate(resourceId, config);
- }
- catch (RawUpdateException e) {
- exception = e;
- }
-
- assertNotNull(exception, "Expected a " + RawUpdateException.class.getSimpleName() + " to be thrown when " +
- " update fails");
-
- List<RawUpdateErrorDetail> errors = exception.getDetails();
+ rawConfigMgmt.executeUpdate(resourceId, config);
- assertEquals(errors.size(), 2, "Expected to find two errors since validation failed for both raw config files");
- assertErrorDetailsContainsRawConfig(errors, raw1);
- assertErrorDetailsContainsRawConfig(errors, raw2);
+// RawUpdateException exception = null;
+//
+// try {
+// rawConfigMgmt.executeUpdate(resourceId, config);
+// }
+// catch (RawUpdateException e) {
+// exception = e;
+// }
+//
+// assertNotNull(exception, "Expected a " + RawUpdateException.class.getSimpleName() + " to be thrown when " +
+// " update fails");
+//
+// List<RawUpdateErrorDetail> errors = exception.getDetails();
+//
+// assertEquals(errors.size(), 2, "Expected to find two errors since validation failed for both raw config files");
+// assertErrorDetailsContainsRawConfig(errors, raw1);
+// assertErrorDetailsContainsRawConfig(errors, raw2);
}
private void assertErrorDetailsContainsRawConfig(List<RawUpdateErrorDetail> errors, RawConfiguration rawConfig) {
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagementTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagementTest.java
index b3b5882..b53fd00 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagementTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredAndRawConfigManagementTest.java
@@ -189,6 +189,86 @@ public class StructuredAndRawConfigManagementTest extends ConfigManagementTest {
config.addRawConfiguration(raw1);
config.addRawConfiguration(raw2);
+ addDefaultExpectationsForUpdate();
+
+ context.checking(new Expectations() {{
+ oneOf(configFacet).validateStructuredConfiguration(config);
+ oneOf(configFacet).persistStructuredConfiguration(config);
+
+ oneOf(configFacet).validateRawConfiguration(raw1);
+ oneOf(configFacet).persistRawConfiguration(raw1);
+
+ oneOf(configFacet).validateRawConfiguration(raw2);
+ oneOf(configFacet).persistRawConfiguration(raw2);
+ }});
+
+ structuredAndRawConfigManagement.executeUpdate(resourceId, config);
+ }
+
+ @Test(expectedExceptions = {ConfigurationUpdateException.class})
+ public void exceptionShouldBeThrownWhenStructuredValidationFails() throws Exception {
+ final RawConfiguration raw = createRawConfiguration("/tmp/raw.txt");
+
+ final Configuration config = new Configuration();
+ config.addRawConfiguration(raw);
+
+ addDefaultExpectationsForUpdate();
+
+ context.checking(new Expectations() {{
+ oneOf(configFacet).validateStructuredConfiguration(config); will(throwException(new RuntimeException()));
+
+ oneOf(configFacet).validateRawConfiguration(raw);
+ oneOf(configFacet).persistRawConfiguration(raw);
+ }});
+
+ structuredAndRawConfigManagement.executeUpdate(resourceId, config);
+ }
+
+ @Test(expectedExceptions = {ConfigurationUpdateException.class})
+ public void exceptionShouldBeThrownWhenStructuredUpdateFails() throws Exception {
+ final RawConfiguration raw = createRawConfiguration("/tmp/raw.txt");
+
+ final Configuration config = new Configuration();
+ config.addRawConfiguration(raw);
+
+ addDefaultExpectationsForUpdate();
+
+ context.checking(new Expectations() {{
+ oneOf(configFacet).validateStructuredConfiguration(config);
+ oneOf(configFacet).persistStructuredConfiguration(config); will(throwException(new RuntimeException()));
+
+ oneOf(configFacet).validateRawConfiguration(raw);
+ oneOf(configFacet).persistRawConfiguration(raw);
+ }});
+
+ structuredAndRawConfigManagement.executeUpdate(resourceId, config);
+ }
+
+ @Test(expectedExceptions = {ConfigurationUpdateException.class})
+ public void structuredAndSecondRawShouldStillGetUpdatedWhenFirstRawValidationFails() throws Exception {
+ final RawConfiguration raw1 = createRawConfiguration("/tmp/raw1.txt");
+ final RawConfiguration raw2 = createRawConfiguration("/tmp/raw2.txt");
+
+ final Configuration config = new Configuration();
+ config.addRawConfiguration(raw1);
+ config.addRawConfiguration(raw2);
+
+ addDefaultExpectationsForUpdate();
+
+ context.checking(new Expectations() {{
+ oneOf(configFacet).validateStructuredConfiguration(config);
+ oneOf(configFacet).persistStructuredConfiguration(config);
+
+ oneOf(configFacet).validateRawConfiguration(raw1); will(throwException(new RuntimeException()));
+
+ oneOf(configFacet).validateRawConfiguration(raw2);
+ oneOf(configFacet).persistRawConfiguration(raw2);
+ }});
+
+ structuredAndRawConfigManagement.executeUpdate(resourceId, config);
+ }
+
+ private void addDefaultExpectationsForUpdate() throws Exception {
final boolean isDaemonThread = false;
context.checking(new Expectations() {{
@@ -199,13 +279,7 @@ public class StructuredAndRawConfigManagementTest extends ConfigManagementTest {
isDaemonThread,
onlyIfStarted);
will(returnValue(configFacet));
-
- oneOf(configFacet).persistStructuredConfiguration(config);
- oneOf(configFacet).persistRawConfiguration(raw1);
- oneOf(configFacet).persistRawConfiguration(raw2);
}});
-
- structuredAndRawConfigManagement.executeUpdate(resourceId, config);
}
}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredConfigManagementTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredConfigManagementTest.java
index 5260ed5..43d5c73 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredConfigManagementTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredConfigManagementTest.java
@@ -128,7 +128,8 @@ public class StructuredConfigManagementTest extends ConfigManagementTest {
structuredMgmt.executeUpdate(resourceId, config);
}
- @Test(expectedExceptions = {StructuredUpdateException.class})
+// @Test(expectedExceptions = {StructuredUpdateException.class})
+ @Test(expectedExceptions = {ConfigurationUpdateException.class})
public void exceptionShouldBeThrownWhenValidationFails() throws Exception {
final Configuration config = new Configuration();
@@ -141,7 +142,8 @@ public class StructuredConfigManagementTest extends ConfigManagementTest {
structuredMgmt.executeUpdate(resourceId, config);
}
- @Test(expectedExceptions = {StructuredUpdateException.class})
+// @Test(expectedExceptions = {StructuredUpdateException.class})
+ @Test(expectedExceptions = {ConfigurationUpdateException.class})
public void exceptionShouldBeThrownWhenUpdateFails() throws Exception {
final Configuration config = new Configuration();
diff --git a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
index ea676c4..e0a5d64 100644
--- a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
+++ b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
@@ -76,7 +76,7 @@ class RawServer implements ResourceComponent, ResourceConfigurationFacet {
}
void persistRawConfiguration(RawConfiguration rawConfiguration) {
- def failValidation = resourceContext.pluginConfiguration.getSimple("failValidation")
+ def failValidation = resourceContext.pluginConfiguration.getSimple("failUpdate")
if (failValidation.getBooleanValue()) {
throw new RuntimeException("Update failed for ${rawConfiguration.path}");
}
diff --git a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy
index 5e19aee..359c615 100644
--- a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy
+++ b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredAndRawServer.groovy
@@ -8,10 +8,11 @@ import org.rhq.core.domain.configuration.Configuration
import org.rhq.core.domain.configuration.RawConfiguration
import org.rhq.core.domain.configuration.PropertySimple
import org.apache.commons.configuration.PropertiesConfiguration
-import groovy.util.AntBuilder
class StructuredAndRawServer implements ResourceComponent, ResourceConfigurationFacet {
+ ResourceContext resourceContext
+
File rawConfigDir
File rawConfig1
@@ -23,6 +24,8 @@ class StructuredAndRawServer implements ResourceComponent, ResourceConfiguration
def ant = new AntBuilder()
void start(ResourceContext context) {
+ resourceContext = context
+
rawConfigDir = new File("${System.getProperty('java.io.tmpdir')}/raw-config-test")
rawConfig1 = new File(rawConfigDir, "structured-and-raw-test-1.txt")
rawConfig2 = new File(rawConfigDir, "structured-and-raw-test-2.txt")
@@ -148,15 +151,42 @@ class StructuredAndRawServer implements ResourceComponent, ResourceConfiguration
}
void validateRawConfiguration(RawConfiguration rawConfig) {
+ def failValidation = resourceContext.pluginConfiguration.getSimple("failRawValidation")
+ if (failValidation.getBooleanValue()) {
+ def fileNames = resourceContext.pluginConfiguration.getSimple("filesToFailValidation").stringValue.split()
+ def match = fileNames.find { rawConfig.path.endsWith(it) }
+
+ if (match) {
+ throw new RuntimeException("Validation failed for ${rawConfig.path}");
+ }
+ }
}
void validateStructuredConfiguration(Configuration config) {
+ def failValidation = resourceContext.pluginConfiguration.getSimple("failStructuredValidation")
+ if (failValidation.getBooleanValue()) {
+ throw new RuntimeException("Validation failed for $configuration");
+ }
}
void persistStructuredConfiguration(Configuration config) {
+ def failValidation = resourceContext.pluginConfiguration.getSimple("failStructuredUpdate")
+ if (failValidation.getBooleanValue()) {
+ throw new RuntimeException("Update failed for $configuration");
+ }
}
void persistRawConfiguration(RawConfiguration rawConfig) {
+ def failUpdate = resourceContext.pluginConfiguration.getSimple("failRawUpdate")
+ if (failUpdate.getBooleanValue()) {
+ def fileNames = resourceContext.pluginConfiguration.getSimple("filesToFailUpdate").stringValue.split()
+ def match = fileNames.find { rawConfig.path.endsWith(it) }
+
+ if (match) {
+ throw new RuntimeException("Update failed for ${rawConfig.path}");
+ }
+ }
+
ant.copy(file: rawConfig.path, tofile: "${rawConfig.path}.orig")
ant.delete(file: rawConfig.path)
diff --git a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredServer.groovy b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredServer.groovy
index d92714f..e210d8d 100644
--- a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredServer.groovy
+++ b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/StructuredServer.groovy
@@ -12,6 +12,8 @@ import groovy.util.AntBuilder
class StructuredServer implements ResourceComponent, ResourceConfigurationFacet {
+ ResourceContext resourceContext
+
File configDir
File structuredConfigFile
@@ -19,6 +21,8 @@ class StructuredServer implements ResourceComponent, ResourceConfigurationFacet
def ant = new AntBuilder()
void start(ResourceContext context) {
+ resourceContext = context
+
configDir = new File("${System.getProperty('java.io.tmpdir')}/raw-config-test")
structuredConfigFile = new File(configDir, "structured-test-1.txt")
@@ -73,6 +77,11 @@ class StructuredServer implements ResourceComponent, ResourceConfigurationFacet
}
void persistStructuredConfiguration(Configuration configuration) {
+ def failValidation = resourceContext.pluginConfiguration.getSimple("failUpdate")
+ if (failValidation.getBooleanValue()) {
+ throw new RuntimeException("Validation failed for $configuration");
+ }
+
ant.copy(file: structuredConfigFile.absolutePath, tofile: "${structuredConfigFile.absolutePath}.orig")
ant.delete(file: structuredConfigFile)
@@ -89,6 +98,10 @@ class StructuredServer implements ResourceComponent, ResourceConfigurationFacet
}
void validateStructuredConfiguration(Configuration configuration) {
+ def failValidation = resourceContext.pluginConfiguration.getSimple("failValidation")
+ if (failValidation.getBooleanValue()) {
+ throw new RuntimeException("Validation failed for $configuration");
+ }
}
void validateRawConfiguration(RawConfiguration rawConfiguration) {
diff --git a/modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml
index e43262b..e59d833 100644
--- a/modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml
@@ -14,6 +14,24 @@
class="StructuredAndRawServer"
discovery="StructuredAndRawDiscoveryComponent"
description="A fake server component that supports both structured and raw configuration">
+
+ <plugin-configuration>
+ <c:simple-property name="faidStructuredValidation" type="boolean" default="false"/>
+ <c:simple-property name="failStructuredUpdate" type="boolean" default="false"/>
+
+ <c:simple-property name="failRawValidation" type="boolean" default="false"/>
+ <c:simple-property name="filesToFailValidation"
+ description="A comma-delimited list of file names for which validation will fail. The entire
+ path does not need to be specified. Simple matching will be done starting from
+ the end of the path. For a path of /foo/bar.txt, you could specify bar.txt."/>
+
+ <c:simple-property name="failRawUpdate" type="boolean" default="false"/>
+ <c:simple-property name="filesToFailUpdate"
+ description="A comma-delimited list of file names for which the update will fail. The entire
+ path does not need to be specified. Simple matching will be done starting from
+ the end of the path. For a path of /foo/bar.txt, you could specify bar.txt."/>
+ </plugin-configuration>
+
<resource-configuration configurationFormat="both">
<c:simple-property name="x"/>
<c:simple-property name="y"/>
diff --git a/modules/plugins/raw-config-test/src/test/groovy/org/rhq/plugins/test/rawconfig/RawConfigServerTest.groovy b/modules/plugins/raw-config-test/src/test/groovy/org/rhq/plugins/test/rawconfig/RawConfigServerTest.groovy
deleted file mode 100644
index 52b9b68..0000000
--- a/modules/plugins/raw-config-test/src/test/groovy/org/rhq/plugins/test/rawconfig/RawConfigServerTest.groovy
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.rhq.plugins.test.rawconfig
-/**
- * Created by IntelliJ IDEA.
- * User: john
- * Date: Nov 13, 2009
- * Time: 8:26:14 AM
- * To change this template use File | Settings | File Templates.
- */
-
-public class RawConfigServerTest {
-
-}
\ No newline at end of file
diff --git a/modules/plugins/raw-config-test/src/test/groovy/org/rhq/plugins/test/rawconfig/RawServerTest.groovy b/modules/plugins/raw-config-test/src/test/groovy/org/rhq/plugins/test/rawconfig/RawServerTest.groovy
index ebb84c2..efaa475 100644
--- a/modules/plugins/raw-config-test/src/test/groovy/org/rhq/plugins/test/rawconfig/RawServerTest.groovy
+++ b/modules/plugins/raw-config-test/src/test/groovy/org/rhq/plugins/test/rawconfig/RawServerTest.groovy
@@ -5,7 +5,7 @@ import org.rhq.core.domain.configuration.RawConfiguration
class RawServerTest {
- @Test
+// @Test
void testPersistRawConfiguration() {
def rawFileName = "raw-test.txt"
def rawFile = new File(confDir, rawFileName)
commit 71f8eebf06f34e3fb3f83270ae41968356555e0f
Merge: e505346... 28dbc2f...
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Jan 6 02:05:32 2010 -0500
Merge branch 'raw-config' of ssh://git.fedorahosted.org/git/rhq/rhq into raw-config
commit e50534652de3a0d177ad55a8252ed586d601ae1c
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Jan 6 02:02:30 2010 -0500
[US 7] Adding initial support in test plugin for validation
Validation/update failure can be turned on or off through the resource's connection
properties. Currently implemented for RawServer.
diff --git a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
index 9acbbd8..ea676c4 100644
--- a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
+++ b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
@@ -10,6 +10,8 @@ import groovy.util.AntBuilder
class RawServer implements ResourceComponent, ResourceConfigurationFacet {
+ ResourceContext resourceContext
+
File rawConfigDir
File rawConfig1
@@ -17,6 +19,8 @@ class RawServer implements ResourceComponent, ResourceConfigurationFacet {
def ant = new AntBuilder()
void start(ResourceContext context) {
+ resourceContext = context;
+
ant = new AntBuilder()
rawConfigDir = new File("${System.getProperty('java.io.tmpdir')}/raw-config-test")
@@ -72,6 +76,11 @@ class RawServer implements ResourceComponent, ResourceConfigurationFacet {
}
void persistRawConfiguration(RawConfiguration rawConfiguration) {
+ def failValidation = resourceContext.pluginConfiguration.getSimple("failValidation")
+ if (failValidation.getBooleanValue()) {
+ throw new RuntimeException("Update failed for ${rawConfiguration.path}");
+ }
+
ant.copy(file: rawConfiguration.path, tofile: "${rawConfiguration.path}.orig")
ant.delete(file: rawConfiguration.path)
@@ -84,6 +93,10 @@ class RawServer implements ResourceComponent, ResourceConfigurationFacet {
}
void validateRawConfiguration(RawConfiguration rawConfiguration) {
+ def failValidation = resourceContext.pluginConfiguration.getSimple("failValidation")
+ if (failValidation.getBooleanValue()) {
+ throw new RuntimeException("Validation failed for ${rawConfiguration.path}");
+ }
}
}
diff --git a/modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml
index 897e4f3..e43262b 100644
--- a/modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/raw-config-test/src/main/resources/META-INF/rhq-plugin.xml
@@ -29,6 +29,12 @@
class="RawServer"
discovery="RawDiscoveryComponent"
description="A fake server component that supports raw configuration">
+
+ <plugin-configuration>
+ <c:simple-property name="failValidation" type="boolean" default="false"/>
+ <c:simple-property name="failUpdate" type="boolean" default="false"/>
+ </plugin-configuration>
+
<resource-configuration configurationFormat="raw"/>
</server>
@@ -36,6 +42,12 @@
class="StructuredServer"
discovery="StructuredDiscoveryComponent"
description="A fake server component that supports structured configuration">
+
+ <plugin-configuration>
+ <c:simple-property name="failValidation" type="boolean" default="false"/>
+ <c:simple-property name="failUpdate" type="boolean" default="false"/>
+ </plugin-configuration>
+
<resource-configuration configurationFormat="structured">
<c:simple-property name="foo"/>
<c:simple-property name="bar"/>
commit 1e94edabaa930c09d6bc30ae170d389436dfc102
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Jan 6 01:59:38 2010 -0500
[US 7] Adding initial support for validation of raw config in plugin container
This commit adds initial validation support for raw only and structured only. Still need
to add support for structured and raw and send back validation errors as an xml document
that can be easily parsed and displayed in the UI.
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
index 5514784..1a9b21c 100644
--- 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
@@ -33,6 +33,8 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Set;
public class RawConfigManagement extends ConfigManagementSupport {
@@ -65,10 +67,21 @@ public class RawConfigManagement extends ConfigManagementSupport {
throws PluginContainerException {
ResourceConfigurationFacet facet = loadResourceConfigFacetWithWriteLock(resourceId);
+ List<RawUpdateErrorDetail> errors = new LinkedList<RawUpdateErrorDetail>();
for (RawConfiguration rawConfig : configuration.getRawConfigurations()) {
- facet.persistRawConfiguration(rawConfig);
+ try {
+ facet.validateRawConfiguration(rawConfig);
+ facet.persistRawConfiguration(rawConfig);
+ }
+ catch (Throwable t) {
+ // TODO Might want to specify in the error detail whether the validate or update call failed
+ errors.add(new RawUpdateErrorDetail(rawConfig, t));
+ }
}
+ if (errors.size() > 0) {
+ throw new RawUpdateException(errors);
+ }
}
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawUpdateErrorDetail.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawUpdateErrorDetail.java
new file mode 100644
index 0000000..7e8f9ca
--- /dev/null
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawUpdateErrorDetail.java
@@ -0,0 +1,57 @@
+/*
+ * 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.domain.configuration.RawConfiguration;
+
+public class RawUpdateErrorDetail {
+
+ private RawConfiguration rawConfig;
+
+ private Throwable error;
+
+ public RawUpdateErrorDetail() {
+ }
+
+ public RawUpdateErrorDetail(RawConfiguration rawConfig, Throwable error) {
+ this.rawConfig = rawConfig;
+ this.error = error;
+ }
+
+ public RawConfiguration getRawConfiguration() {
+ return rawConfig;
+ }
+
+ public void setRawConfiguration(RawConfiguration rawConfig) {
+ this.rawConfig = rawConfig;
+ }
+
+ public Throwable getError() {
+ return error;
+ }
+
+ public void setError(Throwable error) {
+ this.error = error;
+ }
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawUpdateException.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawUpdateException.java
new file mode 100644
index 0000000..22ba9f1
--- /dev/null
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/RawUpdateException.java
@@ -0,0 +1,53 @@
+/*
+ * 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 java.util.LinkedList;
+import java.util.List;
+
+public class RawUpdateException extends ConfigurationUpdateException {
+
+ private List<RawUpdateErrorDetail> details = new LinkedList<RawUpdateErrorDetail>();
+
+ public RawUpdateException(List<RawUpdateErrorDetail> errors) {
+ details = errors;
+ }
+
+ public RawUpdateException(String message, List<RawUpdateErrorDetail> errors) {
+ super(message);
+ details = errors;
+ }
+
+ public RawUpdateException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public RawUpdateException(Throwable cause) {
+ super(cause);
+ }
+
+ public List<RawUpdateErrorDetail> getDetails() {
+ return details;
+ }
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredConfigManagement.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredConfigManagement.java
index f807e72..7cd57b7 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredConfigManagement.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredConfigManagement.java
@@ -68,8 +68,13 @@ public class StructuredConfigManagement extends ConfigManagementSupport {
}
public void executeUpdate(int resourceId, Configuration configuration) throws PluginContainerException {
- ResourceConfigurationFacet facet = loadResourceConfigFacetWithWriteLock(resourceId);
-
- facet.persistStructuredConfiguration(configuration);
+ try {
+ ResourceConfigurationFacet facet = loadResourceConfigFacetWithWriteLock(resourceId);
+ facet.validateStructuredConfiguration(configuration);
+ facet.persistStructuredConfiguration(configuration);
+ }
+ catch (Throwable t) {
+ throw new StructuredUpdateException(t);
+ }
}
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredUpdateException.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredUpdateException.java
new file mode 100644
index 0000000..c0ba380
--- /dev/null
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/StructuredUpdateException.java
@@ -0,0 +1,43 @@
+/*
+ * 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;
+
+public class StructuredUpdateException extends ConfigurationUpdateException {
+
+ public StructuredUpdateException() {
+ super();
+ }
+
+ public StructuredUpdateException(String message) {
+ super(message);
+ }
+
+ public StructuredUpdateException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public StructuredUpdateException(Throwable cause) {
+ super(cause);
+ }
+}
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
index 8d1ec7a..c1ac859 100644
--- 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
@@ -23,6 +23,7 @@
package org.rhq.core.pc.configuration;
+import static org.testng.Assert.*;
import static java.util.Collections.EMPTY_SET;
import org.jmock.Expectations;
@@ -34,6 +35,7 @@ import static org.testng.Assert.assertNull;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.util.List;
import java.util.Set;
public class RawConfigManagementTest extends ConfigManagementTest {
@@ -116,12 +118,48 @@ public class RawConfigManagementTest extends ConfigManagementTest {
addDefaultExpectationsForUpdate();
context.checking(new Expectations() {{
+ oneOf(configFacet).validateRawConfiguration(raw);
+
oneOf(configFacet).persistRawConfiguration(raw);
}});
rawConfigMgmt.executeUpdate(resourceId, config);
}
+ @Test(expectedExceptions = {RawUpdateException.class})
+ public void exceptionShouldBeThrownWhenValidationFailsForSingleRaw() throws Exception {
+ final RawConfiguration raw = createRawConfiguration("/tmp/raw.txt");
+
+ final Configuration config = new Configuration();
+ config.addRawConfiguration(raw);
+
+ addDefaultExpectationsForUpdate();
+
+ context.checking(new Expectations() {{
+ oneOf(configFacet).validateRawConfiguration(raw); will(throwException(new RuntimeException()));
+ }});
+
+ rawConfigMgmt.executeUpdate(resourceId, config);
+ }
+
+ @Test(expectedExceptions = {RawUpdateException.class})
+ public void exceptionShouldBeThrownWhenUpdateFailsForSingleRaw() throws Exception {
+ final RawConfiguration raw = createRawConfiguration("/tmp/raw.txt");
+
+ final Configuration config = new Configuration();
+ config.addRawConfiguration(raw);
+
+ addDefaultExpectationsForUpdate();
+
+ context.checking(new Expectations() {{
+ oneOf(configFacet).validateRawConfiguration(raw);
+
+ oneOf(configFacet).persistRawConfiguration(raw); will(throwException(new RuntimeException()));
+ }});
+
+ rawConfigMgmt.executeUpdate(resourceId, config);
+ }
+
@Test
public void facetShouldBeCalledToUpdateMultipleRaws() throws Exception {
final RawConfiguration raw1 = createRawConfiguration("/tmp/raw1.txt");
@@ -134,13 +172,147 @@ public class RawConfigManagementTest extends ConfigManagementTest {
addDefaultExpectationsForUpdate();
context.checking(new Expectations() {{
+ oneOf(configFacet).validateRawConfiguration(raw1);
+
oneOf(configFacet).persistRawConfiguration(raw1);
+
+ oneOf(configFacet).validateRawConfiguration(raw2);
+
oneOf(configFacet).persistRawConfiguration(raw2);
}});
rawConfigMgmt.executeUpdate(resourceId, config);
}
+ @Test
+ public void secondRawShouldStillGetUpdatedWhenFirstRawFailsValidation() throws Exception {
+ final RawConfiguration raw1 = createRawConfiguration("/tmp/raw1.txt");
+ final RawConfiguration raw2 = createRawConfiguration("/tmp/raw2.txt");
+
+ final Configuration config = new Configuration();
+ config.addRawConfiguration(raw1);
+ config.addRawConfiguration(raw2);
+
+ addDefaultExpectationsForUpdate();
+
+ context.checking(new Expectations() {{
+ oneOf(configFacet).validateRawConfiguration(raw1); will(throwException(new RuntimeException()));
+
+ oneOf(configFacet).validateRawConfiguration(raw2);
+
+ oneOf(configFacet).persistRawConfiguration(raw2);
+ }});
+
+ RawUpdateException exception = null;
+
+ try {
+ rawConfigMgmt.executeUpdate(resourceId, config);
+ }
+ catch (RawUpdateException e) {
+ exception = e;
+ }
+
+ assertNotNull(exception, "Expected a " + RawUpdateException.class.getSimpleName() + " to be thrown when " +
+ " validation fails");
+
+ List<RawUpdateErrorDetail> errors = exception.getDetails();
+
+ assertEquals(errors.size(), 1, "Expected to find only a single error since only the update of one raw failed");
+ assertEquals(
+ errors.get(0).getRawConfiguration(),
+ raw1,
+ "Expected to find " + raw1 + " since validation for it failed"
+ );
+ }
+
+ @Test
+ public void secondRawShouldStillGetUpdateWhenFirstRawUpdateFails() throws Exception {
+ final RawConfiguration raw1 = createRawConfiguration("/tmp/raw1.txt");
+ final RawConfiguration raw2 = createRawConfiguration("/tmp/raw2.txt");
+
+ final Configuration config = new Configuration();
+ config.addRawConfiguration(raw1);
+ config.addRawConfiguration(raw2);
+
+ addDefaultExpectationsForUpdate();
+
+ context.checking(new Expectations() {{
+ oneOf(configFacet).validateRawConfiguration(raw1);
+
+ oneOf(configFacet).persistRawConfiguration(raw1); will(throwException(new RuntimeException()));
+
+ oneOf(configFacet).validateRawConfiguration(raw2);
+
+ oneOf(configFacet).persistRawConfiguration(raw2);
+ }});
+
+ RawUpdateException exception = null;
+
+ try {
+ rawConfigMgmt.executeUpdate(resourceId, config);
+ }
+ catch (RawUpdateException e) {
+ exception = e;
+ }
+
+ assertNotNull(exception, "Expected a " + RawUpdateException.class.getSimpleName() + " to be thrown when " +
+ " update fails");
+
+ List<RawUpdateErrorDetail> errors = exception.getDetails();
+
+ assertEquals(errors.size(), 1, "Expected to find only a single error since only the update of one raw failed");
+ assertEquals(
+ errors.get(0).getRawConfiguration(),
+ raw1,
+ "Expected to find " + raw1 + " since update for it failed"
+ );
+ }
+
+ @Test
+ public void noUpdatesShouldHappenWhenValidationFailsForBothRaws() throws Exception {
+ final RawConfiguration raw1 = createRawConfiguration("/tmp/raw1.txt");
+ final RawConfiguration raw2 = createRawConfiguration("/tmp/raw2.txt");
+
+ final Configuration config = new Configuration();
+ config.addRawConfiguration(raw1);
+ config.addRawConfiguration(raw2);
+
+ addDefaultExpectationsForUpdate();
+
+ context.checking(new Expectations() {{
+ oneOf(configFacet).validateRawConfiguration(raw1); will(throwException(new RuntimeException()));
+
+ oneOf(configFacet).validateRawConfiguration(raw2); will(throwException(new RuntimeException()));
+ }});
+
+ RawUpdateException exception = null;
+
+ try {
+ rawConfigMgmt.executeUpdate(resourceId, config);
+ }
+ catch (RawUpdateException e) {
+ exception = e;
+ }
+
+ assertNotNull(exception, "Expected a " + RawUpdateException.class.getSimpleName() + " to be thrown when " +
+ " update fails");
+
+ List<RawUpdateErrorDetail> errors = exception.getDetails();
+
+ assertEquals(errors.size(), 2, "Expected to find two errors since validation failed for both raw config files");
+ assertErrorDetailsContainsRawConfig(errors, raw1);
+ assertErrorDetailsContainsRawConfig(errors, raw2);
+ }
+
+ private void assertErrorDetailsContainsRawConfig(List<RawUpdateErrorDetail> errors, RawConfiguration rawConfig) {
+ for (RawUpdateErrorDetail detail : errors) {
+ if (detail.getRawConfiguration().equals(rawConfig)) {
+ return;
+ }
+ }
+ fail("Expected to find " + rawConfig + " in update error details");
+ }
+
private void addDefaultExpectationsForUpdate() throws Exception {
final boolean isDaemonThread = false;
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredConfigManagementTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredConfigManagementTest.java
index 9b24df7..5260ed5 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredConfigManagementTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/configuration/StructuredConfigManagementTest.java
@@ -74,8 +74,6 @@ public class StructuredConfigManagementTest extends ConfigManagementTest {
@Test
public void nullShouldBeReturnedWhenStructuredIsNull() throws Exception {
- final Configuration config = null;
-
context.checking(new Expectations() {{
atLeast(1).of(componentService).getComponent(resourceId,
ResourceConfigurationFacet.class,
@@ -117,8 +115,48 @@ public class StructuredConfigManagementTest extends ConfigManagementTest {
@Test
public void facetShouldBeCalledToUpdateStructured() throws Exception {
- final Configuration structuredConfig = new Configuration();
+ final Configuration config = new Configuration();
+
+ addDefaultExpectationsForUpdate();
+
+ context.checking(new Expectations() {{
+ oneOf(configFacet).validateStructuredConfiguration(config);
+
+ oneOf(configFacet).persistStructuredConfiguration(config);
+ }});
+
+ structuredMgmt.executeUpdate(resourceId, config);
+ }
+
+ @Test(expectedExceptions = {StructuredUpdateException.class})
+ public void exceptionShouldBeThrownWhenValidationFails() throws Exception {
+ final Configuration config = new Configuration();
+
+ addDefaultExpectationsForUpdate();
+
+ context.checking(new Expectations() {{
+ oneOf(configFacet).validateStructuredConfiguration(config); will(throwException(new RuntimeException()));
+ }});
+
+ structuredMgmt.executeUpdate(resourceId, config);
+ }
+
+ @Test(expectedExceptions = {StructuredUpdateException.class})
+ public void exceptionShouldBeThrownWhenUpdateFails() throws Exception {
+ final Configuration config = new Configuration();
+
+ addDefaultExpectationsForUpdate();
+
+ context.checking(new Expectations() {{
+ oneOf(configFacet).validateStructuredConfiguration(config);
+
+ oneOf(configFacet).persistStructuredConfiguration(config); will(throwException(new RuntimeException()));
+ }});
+ structuredMgmt.executeUpdate(resourceId, config);
+ }
+
+ private void addDefaultExpectationsForUpdate() throws Exception {
final boolean isDaemonThread = false;
context.checking(new Expectations() {{
@@ -129,11 +167,7 @@ public class StructuredConfigManagementTest extends ConfigManagementTest {
isDaemonThread,
onlyIfStarted);
will(returnValue(configFacet));
-
- oneOf(configFacet).persistStructuredConfiguration(structuredConfig);
}});
-
- structuredMgmt.executeUpdate(resourceId, structuredConfig);
}
}
commit 28dbc2fc74f2b27dd8d829b15a9d463b20077bde
Author: Adam Young <ayoung(a)redhat.com>
Date: Tue Jan 5 20:50:04 2010 -0500
minor tweaks for spacing and removing the controls from the xhtml test page.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js b/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
index 89e12be..3bcf887 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
@@ -136,6 +136,7 @@ function MultiFileEdit() {
document.write("<tr id='file-row-" + i + "'class='" + divclass
+ "'>");
document.write("<td>");
+ document.write("<span style=\"visibility:hidden; \" > XX </span>");
document.write("<span id='dirty-span-" + i
+ "' style=\"visibility:hidden;\" > * </span>");
document.write("</td><td>");
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit-raw-config.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit-raw-config.xhtml
index 4bca60b..1db3aee 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit-raw-config.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit-raw-config.xhtml
@@ -22,8 +22,6 @@ THIS TEXT WILL BE REMOVED.
<a href="view-raw-config.xhtml">View</a>
<form id="testForm">
<onc:multifile></onc:multifile>
- <input type="submit" value="Commit"/>
- <input type="reset" onclick="multiFileEdit.resetArchive();" />
</form>
</ui:define>
</ui:composition>
commit 00aaa905fd6f524df1e626ca206dbb63571de62b
Author: Adam Young <ayoung(a)redhat.com>
Date: Tue Jan 5 20:40:38 2010 -0500
Fixed the Undo button colors and made the entire rendered area into a table, including the submit and reset buttons.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js b/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
index 6de5fe8..89e12be 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
@@ -34,7 +34,6 @@ function MultiFileEdit() {
}
}
}
-
this.setTextAreaValue = function(id) {
if (this.currentIndex % 2 == 0) {
@@ -59,20 +58,15 @@ function MultiFileEdit() {
document.getElementById("reset-span-" + i).style.visibility = "hidden";
}
}
-
this.resetFile = function(index){
-
if (index >= this.originalCopies.length) return;
if (index < 0 ) return;
var original = this.originalCopies[index];
this.archive[index] = new ArchiveFile(original.path,original.contents);
-
document.getElementById("dirty-span-" + index).style.visibility = "hidden";
document.getElementById("reset-span-" + index).style.visibility = "hidden";
-
this.setTextAreaValue(index);
-
}
function askConfirm() {
@@ -80,7 +74,6 @@ function MultiFileEdit() {
}
this.updateArchive = function() {
-
window.onbeforeunload = askConfirm;
this.archive[this.currentIndex].contents = document
.getElementById("testForm").textarea.value;
@@ -89,14 +82,48 @@ function MultiFileEdit() {
document.getElementById("reset-span-" + this.currentIndex).style.visibility = "visible";
}
+ this.download= function() {
+ var generator = window.open(this.downloadUrl,'');
+ }
+
+ this.upload = function(){
+ alert("upload called");
+ }
+
+ this.commit = function(){
+ alert("commit called");
+ return false;
+ }
+
+ this.drawStyleSheet = function(){
+ document.write("<style type=\"text/css\">");
+ document.write("td.multi-edit-table {");
+ document.write("vertical-align: top;");
+ document.write("valign: top;");
+ document.write("height: = 300;");
+ document.write("}");
+ document.write("tr.EvenRow {")
+ document.write("background-color:#a4b2b9;");
+ document.write("}");
+ document.write("tr.OddRow {");
+ document.write("background-color:grey;");
+ document.write("}");
+ document.write("tr.SelectedRow {");
+ document.write("background-color:white;");
+ document.write("}");
+ document.write("span.reset {");
+ document.write("background-color:grey; color:white; visibility:hidden; ");
+ document.write("}");
+
+ document.write("</style>");
+ }
+
this.generateLinks = function() {
var i = 0;
var style = 0;
var divclass = "";
- document
- .write("<table BORDER=0 RULES=NONE FRAME=BOX><th><td>Configuration File Paths</td><td></td></th>");
+ document.write("<table BORDER=0 RULES=NONE FRAME=BOX><th><td>Configuration File Paths</td><td></td></th>");
for (i = 0; i < multiFileEdit.archive.length; i++) {
-
if (i == 0) {
divclass = "SelectedRow"
} else if (style != 0) {
@@ -106,49 +133,27 @@ function MultiFileEdit() {
style = 1;
divclass = "EvenRow"
}
-
document.write("<tr id='file-row-" + i + "'class='" + divclass
+ "'>");
document.write("<td>");
document.write("<span id='dirty-span-" + i
+ "' style=\"visibility:hidden;\" > * </span>");
document.write("</td><td>");
- document
- .write("<a href=\"#\" onclick='multiFileEdit.setTextAreaValue("
+ document.write("<a href=\"#\" onclick='multiFileEdit.setTextAreaValue("
+ i + ")' >" + multiFileEdit.archive[i].path);
document.write("</a>");
-
- document.write(" <span id='reset-span-" + i
- + "' style=\"visibility:hidden;\" >");
- document.write("<a href='#' onclick=' multiFileEdit.resetFile("+i+");' >reset</a> </span>");
-
-
+ document.write("<span class='reset' id='reset-span-" + i + "' ");
+ document.write(" onmouseup=' multiFileEdit.resetFile("+i+");'>");
+ document.write(" Undo</span>");
document.write("</td></tr>");
}
document.write("</table>");
-
}
this.drawTable = function() {
this.initializeArchive();
+ this.drawStyleSheet();
- document.write("<style type=\"text/css\">");
- document.write("td.multi-edit-table {");
- document.write("vertical-align: top;");
- document.write("valign: top;");
- document.write("height: = 300;");
- document.write("}");
- document.write("tr.EvenRow {")
- document.write("background-color:#a4b2b9;");
- document.write("}");
- document.write("tr.OddRow {");
- document.write("background-color:grey;");
- document.write("}");
- document.write("tr.SelectedRow {");
- document.write("background-color:white;");
- document.write("}");
-
- document.write("</style>");
document
.write("<table class='multi-edit-table' border='0' cellpadding='0' >");
document.write("<tbody>");
@@ -175,16 +180,29 @@ function MultiFileEdit() {
.write("onkeyup='multiFileEdit.updateArchive();' cols='80' rows='25'>");
document.write(multiFileEdit.archive[0].contents);
document.write("</textarea>");
-
- document.write("<div>upload New Version</div>");
- document.write("<div>Select A File: <input type='file' onchange='alert(\"onchange called\");' /> </div>");
-
- document.write("</form>");
+ if (!this.disabled){
+ document.write("<div>upload New Version</div>");
+ document.write("<div>Select A File: <input type='file' onchange='multiFileEdit.upload();' /> </div>");
+ }
document.write("</td>");
document.write("</tr>");
+
+ document.write("<tr>");
+ document.write("<td>");
+ if (!this.disabled){
+ document.write("<input type='submit' value='commit' onclick='multiFileEdit.commit();'/>");
+ document.write("<input type='reset' onclick='multiFileEdit.resetArchive();' />");
+ }
+ document.write("</td>");
+ document.write("<td></td>");
+ document.write("</tr>");
+
document.write("</tbody>");
document.write("</table>");
+
+
+
}
@@ -219,9 +237,6 @@ function MultiFileEdit() {
generator.document.close();
}
- this.download= function() {
- var generator = window.open(this.downloadUrl,'');
- }
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/edit.html b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/edit.html
index 4acac4b..d860d1a 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/edit.html
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/edit.html
@@ -23,10 +23,8 @@
multiFileEdit.downloadUrl = "download.html";
multiFileEdit.drawTable();
-</script> <input type="submit" /><input type="reset"
- onclick="multiFileEdit.resetArchive();" /></form>
-
-
-
+</script>
+
+</form>
</body>
</html>
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/view.html b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/view.html
index c1084fa..a6d15d3 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/view.html
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/view.html
@@ -1,17 +1,31 @@
<html><head><title>Next Page,</title>
</head>
-<body>View Results
+<body>
<a href="edit.html">Edit</a>
-<script language="JavaScript" type="text/javascript" src="multi-file-edit.js"></script>
+
+<form id="testForm" name="viewTestConfigurationForm" method="post"
+ action="view.html" enctype="application/x-www-form-urlencoded">
+
+<script language="JavaScript" type="text/javascript"
+ src="../../../../js/multi-file-edit.js"></script>
<form id="testForm" name="viewTestConfigurationForm" method="post"
action="view.html" enctype="application/x-www-form-urlencoded">
<script type="text/javascript">
-var multiFileEdit = new MultiFileEdit();
-multiFileEdit.disabled=1;
-multiFileEdit.drawTable();
+ var multiFileEdit = new MultiFileEdit();
+ multiFileEdit.disabled=1;
+
+ for (i=0; i < 6 ;i++)
+ {
+ multiFileEdit.addArchive("/tmp/file/"+i,
+ "/tmp/file"+i +" archive = "+ i);
+ }
+ multiFileEdit.downloadUrl = "download.html";
+ multiFileEdit.drawTable();
+
</script>
+
</form>
</html>
commit 251585325bba4f982a779a6c1289bb40eab067f6
Author: Adam Young <ayoung(a)redhat.com>
Date: Tue Jan 5 17:19:26 2010 -0500
added reset on file by file basis. Added Renderer and component for MultiFile, and changed the names in the tag library. The RawConfigRenderer and ConfigUIComponent are still there, but have no component names or tags
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/MultiFileRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/MultiFileRenderer.java
new file mode 100644
index 0000000..ada4926
--- /dev/null
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/MultiFileRenderer.java
@@ -0,0 +1,70 @@
+/*
+ * 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.gui.configuration;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+
+/**
+ * A renderer that renders an {@link RawConfigurationComponent} component as XHTML.
+ *
+ * @author Adam Young
+ */
+public class MultiFileRenderer extends Renderer {
+
+ @Override
+ public void decode(FacesContext context, UIComponent component) {
+ super.decode(context, component);
+ }
+
+ @Override
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ @Override
+ public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+
+ writer
+ .write("<script language=\"JavaScript\" type=\"text/javascript\" src=\"/js/multi-file-edit.js\" ></script>\n");
+
+ writer.write("<script type=\"text/javascript\">\n");
+ writer.write("var multiFileEdit = new MultiFileEdit();\n");
+
+ for (int i = 0; i < 6; i++) {
+ writer.write("multiFileEdit.addArchive(\"/tmp/file/" + i + "\",\"/tmp/file" + i + " archive = " + i
+ + "\");");
+ }
+
+ writer.write("multiFileEdit.downloadUrl = \"download.jsp\";\n");
+
+ writer.write("multiFileEdit.drawTable();\n");
+ writer.write("</script>\n");
+
+ }
+}
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/MultiFileUIComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/MultiFileUIComponent.java
new file mode 100644
index 0000000..07acaab
--- /dev/null
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/MultiFileUIComponent.java
@@ -0,0 +1,38 @@
+/*
+ * 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.gui.configuration;
+
+import javax.faces.component.UIComponentBase;
+
+/**
+ * @author Adam Young
+ */
+public class MultiFileUIComponent extends UIComponentBase {
+
+ private static final String family = "rhq";
+
+ @Override
+ public String getFamily() {
+ return family;
+ }
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-components/configuration-components.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-components/configuration-components.xml
index 8bb4c13..49345f6 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-components/configuration-components.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-components/configuration-components.xml
@@ -10,16 +10,14 @@
</component>
<component>
- <component-type>org.jboss.on.RawConfig</component-type>
- <component-class>org.rhq.core.gui.configuration.RawConfigUIComponent</component-class>
+ <component-type>org.jboss.on.MultiFile</component-type>
+ <component-class>org.rhq.core.gui.configuration.MultiFileUIComponent</component-class>
</component>
-
-
- <component>
- <component-type>org.rhq.ConfigurationSet</component-type>
- <component-class>org.rhq.core.gui.configuration.propset.ConfigurationSetComponent</component-class>
- </component>
+ <component>
+ <component-type>org.rhq.ConfigurationSet</component-type>
+ <component-class>org.rhq.core.gui.configuration.propset.ConfigurationSetComponent</component-class>
+ </component>
<render-kit>
<renderer>
@@ -30,10 +28,10 @@
</renderer>
<renderer>
- <description>renderer for Raw Config components</description>
+ <description>renderer for Multi-File Editor</description>
<component-family>rhq</component-family>
- <renderer-type>org.jboss.on.RawConfig</renderer-type>
- <renderer-class>org.rhq.core.gui.configuration.RawConfigRenderer</renderer-class>
+ <renderer-type>org.jboss.on.MultiFile</renderer-type>
+ <renderer-class>org.rhq.core.gui.configuration.MultiFileRenderer</renderer-class>
</renderer>
</render-kit>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tags/on.component.taglib.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tags/on.component.taglib.xml
index 0870441..1fc9928 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tags/on.component.taglib.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tags/on.component.taglib.xml
@@ -65,10 +65,10 @@
</tag>
<tag>
- <tag-name>rawconfig</tag-name>
+ <tag-name>multifile</tag-name>
<component>
- <component-type>org.jboss.on.RawConfig</component-type>
- <renderer-type>org.jboss.on.RawConfig</renderer-type>
+ <component-type>org.jboss.on.MultiFile</component-type>
+ <renderer-type>org.jboss.on.MultiFile</renderer-type>
</component>
</tag>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js b/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
index c474326..6de5fe8 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
@@ -1,103 +1,137 @@
-function ArchiveFile(p,c) {
- this.path = p;
- this.dirty = 0;
- this.contents = c;
+function ArchiveFile(p, c) {
+ this.path = p;
+ this.dirty = 0;
+ this.contents = c;
}
-
-
-
-
/*
* This is a class for editing a collection of files, represented by a map.
- * There is a list of links in the left column, each which represent a file,
- * a textarea input that changes based on which link is selected
+ * There is a list of links in the left column, each which represent a file, a
+ * textarea input that changes based on which link is selected
*/
-function MultiFileEdit(){
+function MultiFileEdit() {
this.currentIndex = 0;
- this.isDirty = 0;
- this.archive = new Array();
- this.disabled=0;
+ this.archive = [];
+ this.originalCopies = [];
+ this.disabled = 0;
+ this.uploadUrl = "upload.html";
+ this.downloadUrl = "#";
- this.initializeArchive = function(){
- var i=0;
- for (i=0; i < 6 ;i++)
- {
- this.archive[i] = new ArchiveFile("/tmp/file/"+i, "/tmp/file/"+i +" archive = "+ this.archive.length);
+
+ this.addArchive = function(p,c){
+ this.originalCopies.push( new ArchiveFile(p,c));
+ }
+
+ this.initializeArchive = function() {
+ this.archive = [];
+ if ( this.originalCopies.length < 1){
+ this.archive.push(new ArchiveFile("/dev/null","No files specified"));
+ }else {
+ var i;
+ for (i=0; i < this.originalCopies.length ;i++){
+ var original = this.originalCopies[i];
+ this.archive.push(new ArchiveFile(original.path,original.contents));
+ }
}
}
- this.setTextAreaValue = function(id)
- {
- if (this.currentIndex % 2 == 0){
- document.getElementById("file-row-"+this.currentIndex).className = "OddRow";
- }else{
- document.getElementById("file-row-"+this.currentIndex).className = "EvenRow";
+
+ this.setTextAreaValue = function(id) {
+ if (this.currentIndex % 2 == 0) {
+ document.getElementById("file-row-" + this.currentIndex).className = "OddRow";
+ } else {
+ document.getElementById("file-row-" + this.currentIndex).className = "EvenRow";
}
-
+
this.currentIndex = id;
document.getElementById("testForm").textarea.value = multiFileEdit.archive[this.currentIndex].contents;
- document.getElementById("file-row-"+id).className = "SelectedRow";
+ document.getElementById("file-row-" + id).className = "SelectedRow";
document.getElementById("testForm").textarea.focus();
document.getElementById("current-path-span").firstChild.data = multiFileEdit.archive[this.currentIndex].path;
}
-
-
- this.resetArchive = function(){
+
+ this.resetArchive = function() {
this.initializeArchive();
this.setTextAreaValue(0);
- this.isDirty = 0;
- for (i=0; i < this.archive.length ;i++)
- {
- document.getElementById("dirty-span-"+i).style.visibility="hidden";
+ window.onbeforeunload = 0;
+ for (i = 0; i < this.archive.length; i++) {
+ document.getElementById("dirty-span-" + i).style.visibility = "hidden";
+ document.getElementById("reset-span-" + i).style.visibility = "hidden";
}
}
- function askConfirm(){
+
+ this.resetFile = function(index){
+
+ if (index >= this.originalCopies.length) return;
+ if (index < 0 ) return;
+ var original = this.originalCopies[index];
+ this.archive[index] = new ArchiveFile(original.path,original.contents);
+
+ document.getElementById("dirty-span-" + index).style.visibility = "hidden";
+ document.getElementById("reset-span-" + index).style.visibility = "hidden";
+
+ this.setTextAreaValue(index);
+
+ }
+
+ function askConfirm() {
return "You have unsaved changes.";
}
-
- this.updateArchive = function(){
-
+ this.updateArchive = function() {
+
window.onbeforeunload = askConfirm;
-
- this.isDirty = 1;
- this.archive[this.currentIndex].contents = document.getElementById("testForm").textarea.value;
+ this.archive[this.currentIndex].contents = document
+ .getElementById("testForm").textarea.value;
this.archive[this.currentIndex].dirty = 1;
- document.getElementById("dirty-span-"+this.currentIndex).style.visibility="visible";
- }
+ document.getElementById("dirty-span-" + this.currentIndex).style.visibility = "visible";
+ document.getElementById("reset-span-" + this.currentIndex).style.visibility = "visible";
+ }
- this.generateLinks = function(){
- var i=0;
- var style =0;
+ this.generateLinks = function() {
+ var i = 0;
+ var style = 0;
var divclass = "";
- document.write("<table BORDER=0 RULES=NONE FRAME=BOX><th><td>Configuration File Paths</td><td></td></th>");
- for (i=0; i < multiFileEdit.archive.length ;i++){
-
- if (i == 0){
- divclass="SelectedRow"
- }else if (style != 0){
+ document
+ .write("<table BORDER=0 RULES=NONE FRAME=BOX><th><td>Configuration File Paths</td><td></td></th>");
+ for (i = 0; i < multiFileEdit.archive.length; i++) {
+
+ if (i == 0) {
+ divclass = "SelectedRow"
+ } else if (style != 0) {
style = 0;
- divclass="OddRow"
- }else{
+ divclass = "OddRow"
+ } else {
style = 1;
- divclass="EvenRow"
+ divclass = "EvenRow"
}
-
- document.write("<tr id='file-row-"+i+"'class='"+ divclass +"'>");
+
+ document.write("<tr id='file-row-" + i + "'class='" + divclass
+ + "'>");
document.write("<td>");
- document.write("<span id='dirty-span-"+i+"' style=\"visibility:hidden;\" > * </span>");
+ document.write("<span id='dirty-span-" + i
+ + "' style=\"visibility:hidden;\" > * </span>");
document.write("</td><td>");
- document.write("<a href=\"#\" onclick='multiFileEdit.setTextAreaValue("+i+")' >"+ multiFileEdit.archive[i].path);
- document.write("</a>");
+ document
+ .write("<a href=\"#\" onclick='multiFileEdit.setTextAreaValue("
+ + i + ")' >" + multiFileEdit.archive[i].path);
+ document.write("</a>");
+
+ document.write(" <span id='reset-span-" + i
+ + "' style=\"visibility:hidden;\" >");
+ document.write("<a href='#' onclick=' multiFileEdit.resetFile("+i+");' >reset</a> </span>");
+
+
document.write("</td></tr>");
}
- document.write("</table>");
-
+ document.write("</table>");
+
}
- this.drawTable = function(){
+ this.drawTable = function() {
+ this.initializeArchive();
+
document.write("<style type=\"text/css\">");
document.write("td.multi-edit-table {");
document.write("vertical-align: top;");
@@ -113,76 +147,86 @@ function MultiFileEdit(){
document.write("tr.SelectedRow {");
document.write("background-color:white;");
document.write("}");
-
-
+
document.write("</style>");
- document.write("<table class='multi-edit-table' border='0' cellpadding='0' >");
+ document
+ .write("<table class='multi-edit-table' border='0' cellpadding='0' >");
document.write("<tbody>");
document.write("<tr>");
document.write("<td class='multi-edit-table' bgcolor='#a4b2b9'>");
this.generateLinks();
document.write("</td>");
document.write("<td>");
- document.write("<div><span id='current-path-span'>Current File Name Goes here</span> ..................");
- document.write("<a href=\"#\"><img src='/images/download.png'/> Download</a>");
- document.write("<a href=\"#\" ");
- document.write("onclick=\"multiFileEdit.fullscreen()\"> ");
+ document.write("<div><span id='current-path-span'>");
+ document.write(multiFileEdit.archive[this.currentIndex].path);
+ document.write("</span> ..................");
+ document.write("<a href='#'");
+ document.write("onclick=\"multiFileEdit.download()\"> ");
+ document.write("<img src='/images/download.png'/> Download</a>");
+ document.write("<a href='#' ");
+ document.write("onclick=\"multiFileEdit.fullscreen()\"> ");
document.write("<img src='/images/viewfullscreen.png'/> Full Screen</a>")
document.write("</div>");
- document.write("<textarea id='textarea' ");
- if (this.disabled){
+ document.write("<textarea id='textarea' ");
+ if (this.disabled) {
document.write("disabled ");
}
- document.write("onkeyup='multiFileEdit.updateArchive();' cols='80' rows='40'>");
+ document
+ .write("onkeyup='multiFileEdit.updateArchive();' cols='80' rows='25'>");
document.write(multiFileEdit.archive[0].contents);
document.write("</textarea>");
document.write("<div>upload New Version</div>");
- document.write("<div>Select A File: <input type='file'/> </div>");
+ document.write("<div>Select A File: <input type='file' onchange='alert(\"onchange called\");' /> </div>");
+
+ document.write("</form>");
+
document.write("</td>");
document.write("</tr>");
document.write("</tbody>");
- document.write("</table>");
-
- }
-
- this.fullscreen= function()
- {
-
- var generator=window.open('','full screen','width=1024,height=768,left=0,top=100,screenX=0,screenY=0');
- generator.document.write('<html><head><title>Popup</title>');
- generator.document.write('<link rel="stylesheet" href="style.css">');
- generator.document.write('<script language="JavaScript" type="text/javascript" src="/js/multi-file-edit.js"></script>');
- generator.document.write('</head><body>');
- generator.document.write("<form id='full-screen-edit-form'>");
- generator.document.write("<div><span id='current-path-span'>" +multiFileEdit.archive[this.currentIndex].path+"</span> ");
- generator.document.write("<a href=\"javascript:self.close();\" >Close</a>..................");
- generator.document.write("</div>");
- generator.document.write("<textarea id='textarea' onkeyup='update_parent();' ");
- if (this.disabled){
- generator.document.write("disabled ");
- }
- generator.document.write("cols='200' rows='45'>");
- generator.document.write(multiFileEdit.archive[this.currentIndex].contents);
- generator.document.write("</textarea>");
- generator.document.write("</form>");
- generator.document.write('</body></html>');
-
- generator.document.getElementById("full-screen-edit-form").textarea.focus();
-
- generator.document.close();
-
+ document.write("</table>");
}
-
- this.initializeArchive();
-}
+ this.fullscreen = function() {
+
+ var generator = window.open('', 'full screen',
+ 'width=1024,height=768,left=0,top=100,screenX=0,screenY=0');
+ generator.document.write('<html><head><title>Popup</title>');
+ generator.document.write('<link rel="stylesheet" href="style.css">');
+ generator.document
+ .write('<script language="JavaScript" type="text/javascript" src="/js/multi-file-edit.js"></script>');
+ generator.document.write('</head><body>');
+ generator.document.write("<form id='full-screen-edit-form'>");
+ generator.document.write("<div><span id='current-path-span'>"
+ + multiFileEdit.archive[this.currentIndex].path + "</span> ");
+ generator.document
+ .write("<a href=\"javascript:self.close();\" >Close</a>..................");
+ generator.document.write("</div>");
+ generator.document
+ .write("<textarea id='textarea' onkeyup='update_parent();' ");
+ if (this.disabled) {
+ generator.document.write("disabled ");
+ }
+ generator.document.write("cols='200' rows='45'>");
+ generator.document
+ .write(multiFileEdit.archive[this.currentIndex].contents);
+ generator.document.write("</textarea>");
+ generator.document.write("</form>");
+ generator.document.write('</body></html>');
+ generator.document.getElementById("full-screen-edit-form").textarea
+ .focus();
+ generator.document.close();
+ }
-function update_parent(){
- opener.document.getElementById("testForm").textarea.value = document.getElementById("full-screen-edit-form").textarea.value;
- opener.multiFileEdit.updateArchive()
+ this.download= function() {
+ var generator = window.open(this.downloadUrl,'');
+ }
+
}
-
-
+function update_parent() {
+ opener.document.getElementById("testForm").textarea.value = document
+ .getElementById("full-screen-edit-form").textarea.value;
+ opener.multiFileEdit.updateArchive()
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit-raw-config.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit-raw-config.xhtml
index b0ccb55..4bca60b 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit-raw-config.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit-raw-config.xhtml
@@ -17,24 +17,15 @@ THIS TEXT WILL BE REMOVED.
THIS TEXT WILL BE REMOVED AS WELL.
- <ui:param name="pageTitle" value="View Test Configuration"/>
-
+ <ui:param name="pageTitle" value=" Raw Edit Configuration Test"/>
<ui:define name="body">
- <a href="view-raw-config.xhtml">View</a>
- <script language="JavaScript" type="text/javascript" src="/js/multi-file-edit.js"></script>
-
-
- <form id="testForm">
- <script type="text/javascript">
- var multiFileEdit = new MultiFileEdit();
- multiFileEdit.drawTable();
- </script>
- <input type="submit" />
- <input type="reset" onclick="multiFileEdit.resetArchive();" />
- </form>
-
+ <a href="view-raw-config.xhtml">View</a>
+ <form id="testForm">
+ <onc:multifile></onc:multifile>
+ <input type="submit" value="Commit"/>
+ <input type="reset" onclick="multiFileEdit.resetArchive();" />
+ </form>
</ui:define>
-
</ui:composition>
THIS TEXT WILL BE REMOVED AS WELL.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/edit.html b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/edit.html
index 4b41986..4acac4b 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/edit.html
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/edit.html
@@ -8,15 +8,23 @@
<a href="view.html">View</a>
-<script language="JavaScript" type="text/javascript" src="../../../../js/multi-file-edit.js"></script>
+<script language="JavaScript" type="text/javascript"
+ src="../../../../js/multi-file-edit.js"></script>
<form id="testForm" name="viewTestConfigurationForm" method="post"
action="view.html" enctype="application/x-www-form-urlencoded">
<script type="text/javascript">
var multiFileEdit = new MultiFileEdit();
+ for (i=0; i < 6 ;i++)
+ {
+ multiFileEdit.addArchive("/tmp/file/"+i,
+ "/tmp/file"+i +" archive = "+ i);
+ }
+ multiFileEdit.downloadUrl = "download.html";
multiFileEdit.drawTable();
-</script>
-<input type="submit" /><input type="reset" onclick="multiFileEdit.resetArchive();" /></form>
+
+</script> <input type="submit" /><input type="reset"
+ onclick="multiFileEdit.resetArchive();" /></form>
commit 5a1348549eb334763745e05fbcc2e26a03a80ee4
Author: Adam Young <ayoung(a)redhat.com>
Date: Mon Jan 4 20:17:08 2010 -0500
an intermediate checkin of some half completed custom tag for the raw config work.
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigRenderer.java
new file mode 100644
index 0000000..823d693
--- /dev/null
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigRenderer.java
@@ -0,0 +1,58 @@
+/*
+ * 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.gui.configuration;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.render.Renderer;
+
+/**
+ * A renderer that renders an {@link RawConfigurationComponent} component as XHTML.
+ *
+ * @author Adam Young
+ */
+public class RawConfigRenderer extends Renderer {
+
+ @Override
+ public void decode(FacesContext context, UIComponent component) {
+ // TODO Auto-generated method stub
+ super.decode(context, component);
+ }
+
+ @Override
+ public boolean getRendersChildren() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ @Override
+ public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
+ // TODO Auto-generated method stub
+ component.encodeBegin(context);
+
+ super.encodeBegin(context, component);
+ }
+
+}
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java
new file mode 100644
index 0000000..3694f09
--- /dev/null
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/RawConfigUIComponent.java
@@ -0,0 +1,143 @@
+/*
+ * 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.gui.configuration;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Vector;
+
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIPanel;
+import javax.faces.component.UIParameter;
+import javax.faces.component.html.HtmlCommandLink;
+import javax.faces.component.html.HtmlInputTextarea;
+import javax.faces.component.html.HtmlPanelGrid;
+import javax.faces.context.FacesContext;
+
+import org.rhq.core.gui.util.FacesComponentIdFactory;
+import org.rhq.core.gui.util.FacesComponentUtility;
+
+/**
+
+ * @author Adam Young
+ */
+public class RawConfigUIComponent extends UIComponentBase {
+ private static final String family = "rhq";
+ private static final CharSequence TABLE_STYLE = "<style type=\"text/css\">" + "td.raw-config-table {"
+ + "vertical-align: top;" + "valign: top;" + "}" + "</style>";
+ private FacesComponentIdFactory idFactory;
+ private HtmlInputTextarea inputTextarea;
+ private ArrayList<String> configPathList;
+ public HtmlCommandLink saveLink;
+ private Vector<HtmlCommandLink> pathCommandLinks;
+ private ArrayList<UIParameter> readOnlyParms;
+ private boolean readOnly;
+
+ @Override
+ public String getFamily() {
+ return family;
+ }
+
+ private void buildChildren() {
+
+ if (getChildCount() > 0) {
+ return;
+ }
+
+ FacesComponentUtility.addVerbatimText(this, TABLE_STYLE);
+
+ UIPanel rawPanel = FacesComponentUtility.addBlockPanel(this, idFactory, "");
+
+ HtmlPanelGrid grid = FacesComponentUtility.addPanelGrid(rawPanel, idFactory, 2, "summary-props-table");
+ grid.setParent(this);
+
+ grid.setColumnClasses("raw-config-table");
+
+ HtmlPanelGrid panelLeft = FacesComponentUtility.addPanelGrid(grid, idFactory, 1, "summary-props-table");
+ panelLeft.setBgcolor("#a4b2b9");
+
+ FacesComponentUtility.addOutputText(panelLeft, idFactory, "Raw Configurations Paths", "");
+
+ int rawCount = 0;
+
+ configPathList = new ArrayList<String>();
+ Collections.sort(configPathList);
+ String oldDirname = "";
+
+ pathCommandLinks = new Vector<HtmlCommandLink>();
+ for (String s : configPathList) {
+
+ String dirname = s.substring(0, s.lastIndexOf("/") + 1);
+ String basename = s.substring(s.lastIndexOf("/") + 1, s.length());
+ if (!dirname.equals(oldDirname)) {
+ FacesComponentUtility.addOutputText(panelLeft, idFactory, dirname, "");
+ oldDirname = dirname;
+ }
+ UIPanel nextPath = FacesComponentUtility.addBlockPanel(panelLeft, idFactory, "");
+ HtmlCommandLink link = FacesComponentUtility.addCommandLink(nextPath, idFactory);
+ FacesComponentUtility.addOutputText(link, idFactory, "", "");
+ FacesComponentUtility.addOutputText(link, idFactory, basename, "");
+ FacesComponentUtility.addParameter(link, idFactory, "path", s);
+ FacesComponentUtility.addParameter(link, idFactory, "whichRaw", Integer.toString(rawCount++));
+ FacesComponentUtility.addParameter(link, idFactory, "showRaw", Boolean.TRUE.toString());
+ readOnlyParms.add(FacesComponentUtility.addParameter(link, idFactory, "readOnly", Boolean
+ .toString(readOnly)));
+
+ pathCommandLinks.add(link);
+ }
+
+ UIPanel panelRight = FacesComponentUtility.addBlockPanel(grid, idFactory, "summary-props-table");
+ UIPanel editPanel = FacesComponentUtility.addBlockPanel(panelRight, idFactory, "summary-props-table");
+ this.inputTextarea = createConfigTextArea(readOnly);
+ editPanel.getChildren().add(this.inputTextarea);
+ inputTextarea.setParent(editPanel);
+
+ }
+
+ @Override
+ public void encodeBegin(FacesContext context) throws IOException {
+ // TODO Auto-generated method stub
+ buildChildren();
+
+ }
+
+ public ArrayList<String> getConfigPathList() {
+ return configPathList;
+ }
+
+ public void setConfigPathList(ArrayList<String> configPathList) {
+ this.configPathList = configPathList;
+ }
+
+ private HtmlInputTextarea createConfigTextArea(boolean readOnly) {
+ HtmlInputTextarea inputTextarea = new HtmlInputTextarea();
+ inputTextarea.setId("rawconfigtextarea");
+ inputTextarea.setCols(80);
+ inputTextarea.setRows(40);
+ inputTextarea.setReadonly(readOnly);
+
+ return inputTextarea;
+ }
+
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/ViewRawTestConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/ViewRawTestConfigurationUIBean.java
new file mode 100644
index 0000000..b2b6900
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/ViewRawTestConfigurationUIBean.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 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.gui.configuration.test;
+
+import org.rhq.enterprise.gui.common.Outcomes;
+
+/**
+ * @author Adam Young
+ */
+public class ViewRawTestConfigurationUIBean extends AbstractTestConfigurationUIBean {
+ public static final String MANAGED_BEAN_NAME = ViewRawTestConfigurationUIBean.class.getSimpleName();
+
+ public String editConfiguration() {
+ return Outcomes.SUCCESS;
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-components/configuration-components.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-components/configuration-components.xml
index 1f7918f..8bb4c13 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-components/configuration-components.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-components/configuration-components.xml
@@ -9,6 +9,13 @@
<component-class>org.rhq.core.gui.configuration.ConfigUIComponent</component-class>
</component>
+ <component>
+ <component-type>org.jboss.on.RawConfig</component-type>
+ <component-class>org.rhq.core.gui.configuration.RawConfigUIComponent</component-class>
+ </component>
+
+
+
<component>
<component-type>org.rhq.ConfigurationSet</component-type>
<component-class>org.rhq.core.gui.configuration.propset.ConfigurationSetComponent</component-class>
@@ -21,6 +28,14 @@
<renderer-type>org.jboss.on.Config</renderer-type>
<renderer-class>org.rhq.core.gui.configuration.ConfigRenderer</renderer-class>
</renderer>
+
+ <renderer>
+ <description>renderer for Raw Config components</description>
+ <component-family>rhq</component-family>
+ <renderer-type>org.jboss.on.RawConfig</renderer-type>
+ <renderer-class>org.rhq.core.gui.configuration.RawConfigRenderer</renderer-class>
+ </renderer>
+
</render-kit>
<component>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/test-beans.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/test-beans.xml
index 3ec6058..daec506 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/test-beans.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/test-beans.xml
@@ -11,6 +11,14 @@
</managed-bean>
<managed-bean>
+ <managed-bean-name>ViewRawTestConfigurationUIBean</managed-bean-name>
+ <managed-bean-class>org.rhq.enterprise.gui.configuration.test.ViewRawTestConfigurationUIBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
+
+
+ <managed-bean>
<managed-bean-name>EditTestConfigurationUIBean</managed-bean-name>
<managed-bean-class>org.rhq.enterprise.gui.configuration.test.EditTestConfigurationUIBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/edit.html b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/edit.html
new file mode 100644
index 0000000..4b41986
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/edit.html
@@ -0,0 +1,24 @@
+<html>
+<head>
+<title>Test multi-edit control</title>
+</head>
+
+
+<body>
+
+<a href="view.html">View</a>
+
+<script language="JavaScript" type="text/javascript" src="../../../../js/multi-file-edit.js"></script>
+
+<form id="testForm" name="viewTestConfigurationForm" method="post"
+ action="view.html" enctype="application/x-www-form-urlencoded">
+<script type="text/javascript">
+ var multiFileEdit = new MultiFileEdit();
+ multiFileEdit.drawTable();
+</script>
+<input type="submit" /><input type="reset" onclick="multiFileEdit.resetArchive();" /></form>
+
+
+
+</body>
+</html>
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/view.html b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/view.html
new file mode 100644
index 0000000..c1084fa
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/raw/view.html
@@ -0,0 +1,18 @@
+<html><head><title>Next Page,</title>
+</head>
+<body>View Results
+
+<a href="edit.html">Edit</a>
+<script language="JavaScript" type="text/javascript" src="multi-file-edit.js"></script>
+
+<form id="testForm" name="viewTestConfigurationForm" method="post"
+ action="view.html" enctype="application/x-www-form-urlencoded">
+<script type="text/javascript">
+var multiFileEdit = new MultiFileEdit();
+multiFileEdit.disabled=1;
+multiFileEdit.drawTable();
+</script>
+</form>
+
+</html>
+</body>
commit 038e268f4eb32afa9dcf3f60092bf75beaa67f30
Author: Adam Young <ayoung(a)redhat.com>
Date: Mon Jan 4 20:12:48 2010 -0500
Made necessary changes so the javscript multi-file-edit works inside a webapp.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js b/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
index f06e7e5..c474326 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
@@ -4,6 +4,10 @@ function ArchiveFile(p,c) {
this.contents = c;
}
+
+
+
+
/*
* This is a class for editing a collection of files, represented by a map.
* There is a list of links in the left column, each which represent a file,
@@ -29,7 +33,6 @@ function MultiFileEdit(){
document.getElementById("file-row-"+this.currentIndex).className = "OddRow";
}else{
document.getElementById("file-row-"+this.currentIndex).className = "EvenRow";
-
}
this.currentIndex = id;
@@ -60,7 +63,7 @@ function MultiFileEdit(){
window.onbeforeunload = askConfirm;
this.isDirty = 1;
- this.archive[this.currentIndex].contents = textarea.value ;
+ this.archive[this.currentIndex].contents = document.getElementById("testForm").textarea.value;
this.archive[this.currentIndex].dirty = 1;
document.getElementById("dirty-span-"+this.currentIndex).style.visibility="visible";
}
@@ -124,13 +127,13 @@ function MultiFileEdit(){
document.write("<a href=\"#\"><img src='/images/download.png'/> Download</a>");
document.write("<a href=\"#\" ");
document.write("onclick=\"multiFileEdit.fullscreen()\"> ");
- document.write("<img src='/images/fullscreen.png'/> Full Screen</a>")
+ document.write("<img src='/images/viewfullscreen.png'/> Full Screen</a>")
document.write("</div>");
document.write("<textarea id='textarea' ");
if (this.disabled){
document.write("disabled ");
}
- document.write("onkeyup='multiFileEdit.updateArchive()' cols='80' rows='40'>");
+ document.write("onkeyup='multiFileEdit.updateArchive();' cols='80' rows='40'>");
document.write(multiFileEdit.archive[0].contents);
document.write("</textarea>");
@@ -145,16 +148,15 @@ function MultiFileEdit(){
this.fullscreen= function()
{
-
var generator=window.open('','full screen','width=1024,height=768,left=0,top=100,screenX=0,screenY=0');
generator.document.write('<html><head><title>Popup</title>');
generator.document.write('<link rel="stylesheet" href="style.css">');
- generator.document.write('<script language="JavaScript" type="text/javascript" src="multi-file-edit.js"></script>');
+ generator.document.write('<script language="JavaScript" type="text/javascript" src="/js/multi-file-edit.js"></script>');
generator.document.write('</head><body>');
generator.document.write("<form id='full-screen-edit-form'>");
generator.document.write("<div><span id='current-path-span'>" +multiFileEdit.archive[this.currentIndex].path+"</span> ");
- generator.document.write("<a href=\"javascript:self.close();\">Close</a>..................");
+ generator.document.write("<a href=\"javascript:self.close();\" >Close</a>..................");
generator.document.write("</div>");
generator.document.write("<textarea id='textarea' onkeyup='update_parent();' ");
if (this.disabled){
@@ -181,3 +183,6 @@ function update_parent(){
opener.document.getElementById("testForm").textarea.value = document.getElementById("full-screen-edit-form").textarea.value;
opener.multiFileEdit.updateArchive()
}
+
+
+
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit-raw-config.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit-raw-config.xhtml
index ac8521a..b0ccb55 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit-raw-config.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit-raw-config.xhtml
@@ -24,23 +24,13 @@ THIS TEXT WILL BE REMOVED.
<script language="JavaScript" type="text/javascript" src="/js/multi-file-edit.js"></script>
- <h:messages showSummary="true"
- showDetail="true"
- errorClass="ErrorBlock"
- warnClass="ErrorBlock"
- infoClass="ConfirmationBlock"
- globalOnly="true"
- layout="table"
- width="100%"/>
<form id="testForm">
<script type="text/javascript">
var multiFileEdit = new MultiFileEdit();
multiFileEdit.drawTable();
- multiFileEdit.setTextAreaValue(0);
</script>
<input type="submit" />
<input type="reset" onclick="multiFileEdit.resetArchive();" />
- <a href="next-page.html" onclick="checkDirty()">Go to next Page</a>
</form>
</ui:define>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/view-raw-config.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/view-raw-config.xhtml
index fa8b2b3..238ccb4 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/view-raw-config.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/view-raw-config.xhtml
@@ -38,7 +38,6 @@ THIS TEXT WILL BE REMOVED.
var multiFileEdit = new MultiFileEdit();
multiFileEdit.disabled=1;
multiFileEdit.drawTable();
- multiFileEdit.setTextAreaValue(0);
</script>
<input type="submit" />
<input type="reset" onclick="multiFileEdit.resetArchive();" />
commit a28c91ba90b5d5caddc3a13baf06beb15def7718
Author: Adam Young <ayoung(a)redhat.com>
Date: Wed Dec 23 20:03:26 2009 -0500
Use of visibility attribute to hide/show asterix
Modified icon paths so that they show in webapp
Initialized document in fullscreen view
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js b/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
index fee0065..f06e7e5 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
@@ -46,7 +46,7 @@ function MultiFileEdit(){
this.isDirty = 0;
for (i=0; i < this.archive.length ;i++)
{
- document.getElementById("dirty-span-"+i).firstChild.data = "O ";
+ document.getElementById("dirty-span-"+i).style.visibility="hidden";
}
}
@@ -62,14 +62,14 @@ function MultiFileEdit(){
this.isDirty = 1;
this.archive[this.currentIndex].contents = textarea.value ;
this.archive[this.currentIndex].dirty = 1;
- document.getElementById("dirty-span-"+this.currentIndex).firstChild.data = "X ";
+ document.getElementById("dirty-span-"+this.currentIndex).style.visibility="visible";
}
this.generateLinks = function(){
var i=0;
var style =0;
var divclass = "";
- document.write("<table><th><td>Configuration File Paths</td><td></td></th>");
+ document.write("<table BORDER=0 RULES=NONE FRAME=BOX><th><td>Configuration File Paths</td><td></td></th>");
for (i=0; i < multiFileEdit.archive.length ;i++){
if (i == 0){
@@ -84,7 +84,7 @@ function MultiFileEdit(){
document.write("<tr id='file-row-"+i+"'class='"+ divclass +"'>");
document.write("<td>");
- document.write("<span id='dirty-span-"+i+"'>O </span>");
+ document.write("<span id='dirty-span-"+i+"' style=\"visibility:hidden;\" > * </span>");
document.write("</td><td>");
document.write("<a href=\"#\" onclick='multiFileEdit.setTextAreaValue("+i+")' >"+ multiFileEdit.archive[i].path);
document.write("</a>");
@@ -111,6 +111,7 @@ function MultiFileEdit(){
document.write("background-color:white;");
document.write("}");
+
document.write("</style>");
document.write("<table class='multi-edit-table' border='0' cellpadding='0' >");
document.write("<tbody>");
@@ -120,10 +121,10 @@ function MultiFileEdit(){
document.write("</td>");
document.write("<td>");
document.write("<div><span id='current-path-span'>Current File Name Goes here</span> ..................");
- document.write("<a href=\"#\"><img src='images/download.png'/> Download</a>");
+ document.write("<a href=\"#\"><img src='/images/download.png'/> Download</a>");
document.write("<a href=\"#\" ");
document.write("onclick=\"multiFileEdit.fullscreen()\"> ");
- document.write("<img src='images/fullscreen.png'/> Full Screen</a>")
+ document.write("<img src='/images/fullscreen.png'/> Full Screen</a>")
document.write("</div>");
document.write("<textarea id='textarea' ");
if (this.disabled){
@@ -143,36 +144,32 @@ function MultiFileEdit(){
}
this.fullscreen= function()
- {
+ {
+
+
var generator=window.open('','full screen','width=1024,height=768,left=0,top=100,screenX=0,screenY=0');
generator.document.write('<html><head><title>Popup</title>');
- generator.document.write('<link rel="stylesheet" href="style.css">');
-
+ generator.document.write('<link rel="stylesheet" href="style.css">');
generator.document.write('<script language="JavaScript" type="text/javascript" src="multi-file-edit.js"></script>');
-
- generator.document.write('</head><body>');
-
+ generator.document.write('</head><body>');
generator.document.write("<form id='full-screen-edit-form'>");
- generator.document.write("<div><span id='current-path-span'>Current File Name Goes here</span> ");
+ generator.document.write("<div><span id='current-path-span'>" +multiFileEdit.archive[this.currentIndex].path+"</span> ");
generator.document.write("<a href=\"javascript:self.close();\">Close</a>..................");
generator.document.write("</div>");
generator.document.write("<textarea id='textarea' onkeyup='update_parent();' ");
-
if (this.disabled){
generator.document.write("disabled ");
- }
-
+ }
generator.document.write("cols='200' rows='45'>");
+ generator.document.write(multiFileEdit.archive[this.currentIndex].contents);
generator.document.write("</textarea>");
- generator.document.write("</form>");
-
+ generator.document.write("</form>");
generator.document.write('</body></html>');
- generator.document.getElementById("current-path-span").firstChild.data = multiFileEdit.archive[this.currentIndex].path;
- generator.document.getElementById("full-screen-edit-form").textarea.value = multiFileEdit.archive[this.currentIndex].contents;
generator.document.getElementById("full-screen-edit-form").textarea.focus();
-
+
generator.document.close();
+
}
commit 4b1bece8d110645b65381629180c7a2429b80e03
Author: Adam Young <ayoung(a)redhat.com>
Date: Wed Dec 23 15:22:54 2009 -0500
Classpath changes, mostly for sources.
diff --git a/.classpath b/.classpath
index 5166ebf..c530af4 100644
--- a/.classpath
+++ b/.classpath
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="modules/common/jboss-as/src/main/java"/>
+ <classpathentry kind="src" path="modules/test-utils/src/main/java"/>
<classpathentry kind="src" path="modules/common/jboss-as/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/jboss-as/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/jboss-as/src/test/java"/>
@@ -13,7 +14,7 @@
<classpathentry kind="src" path="modules/plugins/tomcat/src/test/java"/>
<classpathentry kind="src" path="modules/plugins/jboss-cache/src/main/java"/>
<classpathentry kind="src" path="modules/plugins/jboss-cache-v3/src/main/java"/>
- <classpathentry excluding="org/rhq/plugins/antlrconfig/" kind="src" path="modules/plugins/antlr-config/src/main/java"/>
+ <classpathentry kind="src" path="modules/plugins/antlr-config/src/main/java"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.SP1/jboss-profileservice-spi-5.1.0.SP1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.1.1.GA/jboss-managed-2.1.1.GA.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.1.1.GA/jboss-metatype-2.1.1.GA.jar"/>
@@ -110,7 +111,6 @@
<classpathentry kind="src" path="modules/plugins/antlr-config/src/main/antlr3"/>
<classpathentry kind="src" path="modules/plugins/antlr-config/target/generated-sources/antlr3"/>
<classpathentry kind="src" path="modules/plugins/augeas/src/main/java"/>
- <classpathentry kind="src" path="modules/plugins/augeas/src/test/java"/>
<classpathentry kind="src" path="modules/helpers/rtfilter/src/main/java"/>
<classpathentry kind="src" path="modules/helpers/pluginAnnotations/src/main/java"/>
<classpathentry kind="src" path="modules/helpers/pluginGen/src/main/java"/>
@@ -211,5 +211,8 @@
<classpathentry exported="true" kind="var" path="M2_REPO/pircbot/pircbot/1.4.2/pircbot-1.4.2.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/net/homeip/yusuke/twitter4j/2.0.9/twitter4j-2.0.9.jar"/>
<classpathentry exported="true" kind="lib" path="modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-1.4.0-SNAPSHOT/wsconsume-output"/>
+ <classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
commit bc566390a996f9839387290cb4b58153176c76cb
Author: Adam Young <ayoung(a)redhat.com>
Date: Wed Dec 23 15:22:32 2009 -0500
Added a javascript based proof of concept for raw config UI and two test pages to view.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js b/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
new file mode 100644
index 0000000..fee0065
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/js/multi-file-edit.js
@@ -0,0 +1,186 @@
+function ArchiveFile(p,c) {
+ this.path = p;
+ this.dirty = 0;
+ this.contents = c;
+}
+
+/*
+ * This is a class for editing a collection of files, represented by a map.
+ * There is a list of links in the left column, each which represent a file,
+ * a textarea input that changes based on which link is selected
+ */
+function MultiFileEdit(){
+ this.currentIndex = 0;
+ this.isDirty = 0;
+ this.archive = new Array();
+ this.disabled=0;
+
+ this.initializeArchive = function(){
+ var i=0;
+ for (i=0; i < 6 ;i++)
+ {
+ this.archive[i] = new ArchiveFile("/tmp/file/"+i, "/tmp/file/"+i +" archive = "+ this.archive.length);
+ }
+ }
+
+ this.setTextAreaValue = function(id)
+ {
+ if (this.currentIndex % 2 == 0){
+ document.getElementById("file-row-"+this.currentIndex).className = "OddRow";
+ }else{
+ document.getElementById("file-row-"+this.currentIndex).className = "EvenRow";
+
+ }
+
+ this.currentIndex = id;
+ document.getElementById("testForm").textarea.value = multiFileEdit.archive[this.currentIndex].contents;
+ document.getElementById("file-row-"+id).className = "SelectedRow";
+ document.getElementById("testForm").textarea.focus();
+ document.getElementById("current-path-span").firstChild.data = multiFileEdit.archive[this.currentIndex].path;
+ }
+
+
+ this.resetArchive = function(){
+ this.initializeArchive();
+ this.setTextAreaValue(0);
+ this.isDirty = 0;
+ for (i=0; i < this.archive.length ;i++)
+ {
+ document.getElementById("dirty-span-"+i).firstChild.data = "O ";
+ }
+ }
+
+ function askConfirm(){
+ return "You have unsaved changes.";
+ }
+
+
+ this.updateArchive = function(){
+
+ window.onbeforeunload = askConfirm;
+
+ this.isDirty = 1;
+ this.archive[this.currentIndex].contents = textarea.value ;
+ this.archive[this.currentIndex].dirty = 1;
+ document.getElementById("dirty-span-"+this.currentIndex).firstChild.data = "X ";
+ }
+
+ this.generateLinks = function(){
+ var i=0;
+ var style =0;
+ var divclass = "";
+ document.write("<table><th><td>Configuration File Paths</td><td></td></th>");
+ for (i=0; i < multiFileEdit.archive.length ;i++){
+
+ if (i == 0){
+ divclass="SelectedRow"
+ }else if (style != 0){
+ style = 0;
+ divclass="OddRow"
+ }else{
+ style = 1;
+ divclass="EvenRow"
+ }
+
+ document.write("<tr id='file-row-"+i+"'class='"+ divclass +"'>");
+ document.write("<td>");
+ document.write("<span id='dirty-span-"+i+"'>O </span>");
+ document.write("</td><td>");
+ document.write("<a href=\"#\" onclick='multiFileEdit.setTextAreaValue("+i+")' >"+ multiFileEdit.archive[i].path);
+ document.write("</a>");
+ document.write("</td></tr>");
+ }
+ document.write("</table>");
+
+ }
+
+ this.drawTable = function(){
+ document.write("<style type=\"text/css\">");
+ document.write("td.multi-edit-table {");
+ document.write("vertical-align: top;");
+ document.write("valign: top;");
+ document.write("height: = 300;");
+ document.write("}");
+ document.write("tr.EvenRow {")
+ document.write("background-color:#a4b2b9;");
+ document.write("}");
+ document.write("tr.OddRow {");
+ document.write("background-color:grey;");
+ document.write("}");
+ document.write("tr.SelectedRow {");
+ document.write("background-color:white;");
+ document.write("}");
+
+ document.write("</style>");
+ document.write("<table class='multi-edit-table' border='0' cellpadding='0' >");
+ document.write("<tbody>");
+ document.write("<tr>");
+ document.write("<td class='multi-edit-table' bgcolor='#a4b2b9'>");
+ this.generateLinks();
+ document.write("</td>");
+ document.write("<td>");
+ document.write("<div><span id='current-path-span'>Current File Name Goes here</span> ..................");
+ document.write("<a href=\"#\"><img src='images/download.png'/> Download</a>");
+ document.write("<a href=\"#\" ");
+ document.write("onclick=\"multiFileEdit.fullscreen()\"> ");
+ document.write("<img src='images/fullscreen.png'/> Full Screen</a>")
+ document.write("</div>");
+ document.write("<textarea id='textarea' ");
+ if (this.disabled){
+ document.write("disabled ");
+ }
+ document.write("onkeyup='multiFileEdit.updateArchive()' cols='80' rows='40'>");
+ document.write(multiFileEdit.archive[0].contents);
+ document.write("</textarea>");
+
+ document.write("<div>upload New Version</div>");
+ document.write("<div>Select A File: <input type='file'/> </div>");
+ document.write("</td>");
+ document.write("</tr>");
+ document.write("</tbody>");
+ document.write("</table>");
+
+ }
+
+ this.fullscreen= function()
+ {
+ var generator=window.open('','full screen','width=1024,height=768,left=0,top=100,screenX=0,screenY=0');
+ generator.document.write('<html><head><title>Popup</title>');
+ generator.document.write('<link rel="stylesheet" href="style.css">');
+
+ generator.document.write('<script language="JavaScript" type="text/javascript" src="multi-file-edit.js"></script>');
+
+ generator.document.write('</head><body>');
+
+ generator.document.write("<form id='full-screen-edit-form'>");
+ generator.document.write("<div><span id='current-path-span'>Current File Name Goes here</span> ");
+ generator.document.write("<a href=\"javascript:self.close();\">Close</a>..................");
+ generator.document.write("</div>");
+ generator.document.write("<textarea id='textarea' onkeyup='update_parent();' ");
+
+ if (this.disabled){
+ generator.document.write("disabled ");
+ }
+
+ generator.document.write("cols='200' rows='45'>");
+ generator.document.write("</textarea>");
+ generator.document.write("</form>");
+
+ generator.document.write('</body></html>');
+
+ generator.document.getElementById("current-path-span").firstChild.data = multiFileEdit.archive[this.currentIndex].path;
+ generator.document.getElementById("full-screen-edit-form").textarea.value = multiFileEdit.archive[this.currentIndex].contents;
+ generator.document.getElementById("full-screen-edit-form").textarea.focus();
+
+ generator.document.close();
+
+ }
+
+ this.initializeArchive();
+}
+
+
+function update_parent(){
+ opener.document.getElementById("testForm").textarea.value = document.getElementById("full-screen-edit-form").textarea.value;
+ opener.multiFileEdit.updateArchive()
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit-raw-config.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit-raw-config.xhtml
new file mode 100644
index 0000000..ac8521a
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/edit-raw-config.xhtml
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:rich="http://richfaces.ajax4jsf.org/rich"
+ xmlns:onc="http://jboss.org/on/component">
+
+THIS TEXT WILL BE REMOVED.
+
+<ui:composition template="/rhq/layout/main.xhtml">
+
+ THIS TEXT WILL BE REMOVED AS WELL.
+
+ <ui:param name="pageTitle" value="View Test Configuration"/>
+
+ <ui:define name="body">
+ <a href="view-raw-config.xhtml">View</a>
+ <script language="JavaScript" type="text/javascript" src="/js/multi-file-edit.js"></script>
+
+
+ <h:messages showSummary="true"
+ showDetail="true"
+ errorClass="ErrorBlock"
+ warnClass="ErrorBlock"
+ infoClass="ConfirmationBlock"
+ globalOnly="true"
+ layout="table"
+ width="100%"/>
+ <form id="testForm">
+ <script type="text/javascript">
+ var multiFileEdit = new MultiFileEdit();
+ multiFileEdit.drawTable();
+ multiFileEdit.setTextAreaValue(0);
+ </script>
+ <input type="submit" />
+ <input type="reset" onclick="multiFileEdit.resetArchive();" />
+ <a href="next-page.html" onclick="checkDirty()">Go to next Page</a>
+ </form>
+
+ </ui:define>
+
+</ui:composition>
+
+THIS TEXT WILL BE REMOVED AS WELL.
+
+</html>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/view-raw-config.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/view-raw-config.xhtml
new file mode 100644
index 0000000..fa8b2b3
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/test/config/view-raw-config.xhtml
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:rich="http://richfaces.ajax4jsf.org/rich"
+ xmlns:onc="http://jboss.org/on/component">
+
+THIS TEXT WILL BE REMOVED.
+
+<ui:composition template="/rhq/layout/main.xhtml">
+
+ THIS TEXT WILL BE REMOVED AS WELL.
+
+ <ui:param name="pageTitle" value="View Test Configuration"/>
+
+ <ui:define name="body">
+
+ <script language="JavaScript" type="text/javascript" src="/js/multi-file-edit.js"></script>
+
+ <h:messages showSummary="true"
+ showDetail="true"
+ errorClass="ErrorBlock"
+ warnClass="ErrorBlock"
+ infoClass="ConfirmationBlock"
+ globalOnly="true"
+ layout="table"
+ width="100%"/>
+ <a href="edit-raw-config.xhtml">Edit</a>
+
+ <form id="testForm">
+ <script type="text/javascript">
+ var multiFileEdit = new MultiFileEdit();
+ multiFileEdit.disabled=1;
+ multiFileEdit.drawTable();
+ multiFileEdit.setTextAreaValue(0);
+ </script>
+ <input type="submit" />
+ <input type="reset" onclick="multiFileEdit.resetArchive();" />
+ </form>
+
+ </ui:define>
+
+</ui:composition>
+
+THIS TEXT WILL BE REMOVED AS WELL.
+
+</html>
commit b5fa8688432aaefa4509a9ca55acc7d4ac4dca7d
Author: Adam Young <ayoung(a)redhat.com>
Date: Wed Dec 23 15:19:22 2009 -0500
removed Overload tags. The functionas are defined in an interface, thus these are not properly overloads, but rather implementations. Eclipse complained.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 88858cf..0a39438 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -287,7 +287,6 @@ public class WebservicesManagerBean implements WebservicesRemote {
return repoManager.findPackageVersionsInRepoByCriteria(subject, criteria);
}
- @Override
public int synchronizeRepos(Subject subject, Integer[] repoIds) {
return repoManager.synchronizeRepos(subject, repoIds);
}
@@ -372,8 +371,8 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public ResourceConfigurationUpdate updateStructuredOrRawConfiguration(Subject subject, int resourceId,
- Configuration newConfiguration, boolean fromStructured)
- throws ResourceNotFoundException, ConfigurationUpdateStillInProgressException {
+ Configuration newConfiguration, boolean fromStructured) throws ResourceNotFoundException,
+ ConfigurationUpdateStillInProgressException {
return configurationManager.updateStructuredOrRawConfiguration(subject, resourceId, newConfiguration,
fromStructured);
}
commit 274b4f5769bf16369eff507fcbdcfaae945d937d
Author: Adam Young <ayoung(a)redhat.com>
Date: Wed Dec 23 15:12:34 2009 -0500
removed Overload tags. The functionas are defined in an interface, thus these are not properly overloads, but rather implementations. Eclipse complained.
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java
index f3c75e2..004608a 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java
@@ -32,12 +32,10 @@ public class ApacheXmlRpcExecutor implements XmlRpcExecutor {
this.client = clientIn;
}
- @Override
public Object execute(String methodName, Object[] params) throws XmlRpcException {
return client.execute(methodName, params);
}
- @Override
public Object execute(String pMethodName, List pParams) throws XmlRpcException {
return client.execute(pMethodName, pParams);
}
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java b/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java
index bcdfe41..c4cf6c7 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/test/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/MockRhnXmlRpcExecutor.java
@@ -70,7 +70,6 @@ public class MockRhnXmlRpcExecutor implements XmlRpcExecutor {
/* (non-Javadoc)
* @see org.rhq.enterprise.server.plugins.rhnhosted.xmlrpc.XmlRpcExecutor#execute(java.lang.String, java.lang.Object[])
*/
- @Override
public Object execute(String methodName, Object[] params) throws XmlRpcException {
//for (Object object : params) {
// System.out.println("parm: " + object);
@@ -242,7 +241,6 @@ public class MockRhnXmlRpcExecutor implements XmlRpcExecutor {
}
- @Override
public Object execute(String pMethodName, List pParams) throws XmlRpcException {
return execute(pMethodName, pParams.toArray());
}
14 years, 4 months
[rhq] Branch 'linux-config' - 103 commits - .classpath modules/core modules/enterprise modules/plugins
by Partha Aji
.classpath | 6
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java | 4
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java | 26
modules/core/client-api/src/main/resources/rhq-configuration.xsd | 50
modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml | 4
modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml | 67
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 238 +++
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java | 7
modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java | 7
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java | 150 ++
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleConfig.java | 156 ++
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java | 134 +
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentPK.java | 122 +
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleFile.java | 169 ++
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleType.java | 125 +
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java | 195 ++
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersionRepo.java | 132 +
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersionRepoPK.java | 122 +
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyDefinitionDynamic.java | 82 +
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyDynamicType.java | 33
modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java | 11
modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryBuglist.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryPackage.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java | 10
modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java | 14
modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java | 11
modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java | 41
modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java | 17
modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java | 68 +
modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/SubscribedRepo.java | 47
modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java | 345 +++++
modules/core/domain/src/test/java/org/rhq/core/domain/content/test/RepoTest.java | 54
modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java | 15
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractPropertyBagUIComponentTreeFactory.java | 66
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java | 52
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java | 107 +
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/PropertySetRenderer.java | 15
modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java | 8
modules/core/util/src/test/java/org/rhq/core/util/progresswatch/ProgressWatcherTest.java | 10
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java | 7
modules/enterprise/gui/content_http-war/pom.xml | 292 ++++
modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java | 42
modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java | 680 ++++++++++
modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/EntitlementException.java | 62
modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java | 122 +
modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/YumMetadata.java | 167 ++
modules/enterprise/gui/content_http-war/src/main/webapp/WEB-INF/jboss-web.xml | 5
modules/enterprise/gui/content_http-war/src/main/webapp/WEB-INF/web.xml | 33
modules/enterprise/gui/content_http-war/src/main/webapp/icons/back.gif |binary
modules/enterprise/gui/content_http-war/src/main/webapp/icons/blank.gif |binary
modules/enterprise/gui/content_http-war/src/main/webapp/icons/bomb.gif |binary
modules/enterprise/gui/content_http-war/src/main/webapp/icons/folder.gif |binary
modules/enterprise/gui/content_http-war/src/main/webapp/icons/text.gif |binary
modules/enterprise/gui/content_http-war/src/main/webapp/icons/unknown.gif |binary
modules/enterprise/gui/content_http-war/src/main/webapp/testfile | 2
modules/enterprise/gui/content_http-war/src/main/webapp/testfile2 | 2
modules/enterprise/gui/pom.xml | 3
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java | 3
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java | 1
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java | 81 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PageControlView.java | 3
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java | 46
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java | 38
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/ResourceUpdatePackageVersionsUIBean.java | 71 +
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java | 87 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java | 22
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java | 15
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/content-beans.xml | 5
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml | 26
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/content-navigation.xml | 20
modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml | 89 +
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml | 160 +-
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/notificationTemplates.xhtml | 2
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml | 18
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/update.xhtml | 154 ++
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/layout/main-no-leftnav.xhtml | 1
modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java | 41
modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml | 10
modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/WsRepoManagerTest.java | 33
modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java | 118 +
modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsDistributionManagerTest.java | 90 +
modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java | 76 +
modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsUnitTestBase.java | 72 +
modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java | 118 +
modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsSubjectUtility.java | 153 ++
modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml | 2
modules/enterprise/server/ear/pom.xml | 16
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.java | 69 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java | 44
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/PropertyExpressionEvaluator.java | 75 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java | 61
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerLocal.java | 12
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java | 19
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java | 77 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerLocal.java | 51
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java | 129 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerLocal.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java | 20
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java | 20
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java | 22
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DummyLoader.java | 63
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java | 38
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerLocal.java | 25
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerRemote.java | 29
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java | 89 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java | 18
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerRemote.java | 14
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/AdvisorySource.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java | 530 ++++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentServerPluginContainer.java | 103 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/DistributionSource.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/PackageSource.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncException.java | 35
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncTracker.java | 10
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ThreadUtil.java | 17
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java | 16
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/DistributionSourceSynchronizer.java | 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/PackageSourceSynchronizer.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationException.java | 38
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java | 243 +++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerLocal.java | 52
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerRemote.java | 52
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/ReleaseRepoMapping.java | 76 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 19
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/RepoSyncJob.java | 51
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java | 25
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java | 14
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java | 183 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java | 14
modules/enterprise/server/jar/src/test/java/javax/ejb/EJBTransactionRolledbackException.java | 58
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java | 164 ++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/QuartzScheduleFormatTest.java | 55
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java | 38
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java | 47
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java | 140 +-
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java | 113 +
modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java | 4
modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml | 6
modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java | 20
modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml | 17
modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java | 31
modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/RssFeedParser.java | 23
modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNHelper.java | 42
modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java | 55
modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java | 2
modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java | 16
modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java | 8
modules/plugins/kickstart/src/main/java/org/rhq/plugins/kickstart/KickstartServerComponent.java | 25
modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java | 52
153 files changed, 8151 insertions(+), 869 deletions(-)
New commits:
commit 642e623979ae0132afb2de4cd88a3a5afac381d2
Merge: 8ab6acb... d291388...
Author: Partha Aji <paji(a)redhat.com>
Date: Wed Jan 27 15:27:20 2010 -0500
Fixed merge conflicts
diff --cc modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
index d8be5f2,1162a69..67dbe94
--- a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
+++ b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
@@@ -76,13 -79,13 +79,14 @@@ public class RemoteClient
ContentManager(ContentManagerRemote.class), //
DataAccessManager(DataAccessManagerRemote.class), //
DiscoveryBoss(DiscoveryBossRemote.class), //
- DistributionManager(DistributionManagerRemote.class),//
++ DistributionManager(DistributionManagerRemote.class), //
EventManager(EventManagerRemote.class), //
MeasurementBaselineManager(MeasurementBaselineManagerRemote.class), //
MeasurementDataManager(MeasurementDataManagerRemote.class), //
- MeasurementDefinitionManager(MeasurementDefinitionManagerRemote.class), //
+ MeasurementDefinitionManager(MeasurementDefinitionManagerRemote.class), //
MeasurementScheduleManager(MeasurementScheduleManagerRemote.class), //
OperationManager(OperationManagerRemote.class), //
+ PerspectiveManager(PerspectiveManagerRemote.class), //
ResourceManager(ResourceManagerRemote.class), //
ResourceFactoryManager(ResourceFactoryManagerRemote.class), //
ResourceGroupManager(ResourceGroupManagerRemote.class), //
@@@ -212,10 -215,15 +216,9 @@@
/**
* Connects to the remote server but does not establish a user session. This can be used
* with the limited API that does not require a Subject.
- *
+ *
* After successfully executing this, {@link #isConnected()} will be <code>true</code>
* and {@link #getSubject()} will return the subject that this method returns.
- *
- *
- * @param user
- * @param password
- *
- * @return the logged in user
- *
* @throws Exception if failed to connect to the server or log in
*/
public void connect() throws Exception {
commit d2913885ba5aeee5d6efcdca1350b0a70bbcff61
Merge: 2dde4f5... c5470ae...
Author: Justin Harris <jharris(a)redhat.com>
Date: Wed Jan 27 13:58:28 2010 -0500
Merge remote branch 'origin/master' into alertPlugin
commit c5470ae79abb7ba7d7814d0f4feb08776f9dc798
Author: Bryan Kearney <bkearney(a)redhat.com>
Date: Wed Jan 27 13:09:25 2010 -0500
Catch koan failures and record them
diff --git a/modules/plugins/kickstart/src/main/java/org/rhq/plugins/kickstart/KickstartServerComponent.java b/modules/plugins/kickstart/src/main/java/org/rhq/plugins/kickstart/KickstartServerComponent.java
index de56c4a..ed7f03d 100644
--- a/modules/plugins/kickstart/src/main/java/org/rhq/plugins/kickstart/KickstartServerComponent.java
+++ b/modules/plugins/kickstart/src/main/java/org/rhq/plugins/kickstart/KickstartServerComponent.java
@@ -61,9 +61,15 @@ public class KickstartServerComponent implements ResourceComponent, OperationFac
String virtName = configuration.getSimpleValue("name", "Guest " + System.currentTimeMillis());
String profile = configuration.getSimpleValue("profile", "profile");
String server = configuration.getSimpleValue("server", "localhost");
- ProcessExecutionResults pr = this.execute(command, "--virt", "--server", server, "--profile", profile,
- "--virt-name", virtName);
- res.setSimpleResult(pr.getExitCode().toString());
+ String[] argsString = { "--virt", "--server", server, "--profile", profile, "--virt-name", virtName };
+ ProcessExecutionResults pr = this.execute(command, argsString);
+ if (pr.getExitCode() > 0) {
+ log.error("Error executing command: " + this.buildCommandString(command, argsString));
+ res.setErrorMessage(pr.getCapturedOutput());
+ } else {
+ res.setSimpleResult(pr.getCapturedOutput());
+ }
+
}
return res;
@@ -72,10 +78,7 @@ public class KickstartServerComponent implements ResourceComponent, OperationFac
public ProcessExecutionResults execute(String process, String... args) {
List<String> argsList = Arrays.asList(args);
if (log.isDebugEnabled()) {
- String argsString = "";
- for (String arg : argsList)
- argsString = argsString + " " + arg;
- log.debug("Executing command " + process + argsString);
+ log.debug("Executing command " + this.buildCommandString(process, args));
}
ProcessExecution pe = new ProcessExecution(process);
pe.setCaptureOutput(true);
@@ -85,4 +88,12 @@ public class KickstartServerComponent implements ResourceComponent, OperationFac
log.debug("Result " + pr.getExitCode());
return pr;
}
+
+ private String buildCommandString(String process, String... argsList) {
+ String argsString = process;
+ for (String arg : argsList)
+ argsString = argsString + " " + arg;
+ return process;
+
+ }
}
commit 03ec3f8d46c55615ce0f256eee607302d4feed36
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 27 12:08:09 2010 -0500
trivial fix to a javadoc comment
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
index e77df6f..32a7398 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
@@ -289,10 +289,7 @@ public class AgentMain {
private boolean m_advancedSetup = false;
/**
- * If the agent was told to setup (via a command line option), this will be trueneeds to be setup when it is first
- * initialized, by default the basic setup will run which asks the user for some basic, minimal information
- * necessary to get the agent started. However, if this flag is <code>true</code>, the advanced setup will run as
- * opposed to the basic setup.
+ * If the agent was told to setup (via a command line option), this will be true.
*/
private boolean m_forcedSetup = false;
@@ -3312,4 +3309,4 @@ public class AgentMain {
return this.serverEndpoint + "@" + new Date(this.timestamp);
}
}
-}
\ No newline at end of file
+}
commit ebaf42d67c501e1383e8e08eaa95ae58fdc5f77e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 27 12:03:26 2010 -0500
change the blob column to clob since this really is text of the action script/receipt and not raw binary data
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
index d558c09..d1ae3ad 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -505,7 +505,7 @@
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="NAME" size="200" type="VARCHAR2" required="true"/>
<column name="VERSION" size="500" type="VARCHAR2" required="true"/>
- <column name="ACTION" type="BLOB" required="true"/>
+ <column name="ACTION" type="CLOB" required="true"/>
<column name="BUNDLE_ID" type="INTEGER" required="true" references="RHQ_BUNDLE"/>
<column name="DISTRIBUTION_ID" type="INTEGER" required="false" references="RHQ_DISTRIBUTION"/>
</table>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 3eca05e..dd16274 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2826,7 +2826,7 @@
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="NAME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="VERSION" columnType="VARCHAR2" precision="500" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="VERSION" nullable="FALSE" />
- <schema-addColumn table="RHQ_BUNDLE_VERSION" column="ACTION" columnType="BLOB" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="ACTION" columnType="CLOB" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="ACTION" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" nullable="FALSE" />
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
index a4c4d31..f2ea97c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
@@ -72,7 +72,7 @@ public class BundleVersion implements Serializable {
private String version;
@Column(name = "ACTION", nullable = false)
- private byte[] action;
+ private String action;
@JoinColumn(name = "BUNDLE_ID", referencedColumnName = "ID", nullable = false)
@ManyToOne(fetch = FetchType.LAZY)
@@ -116,11 +116,11 @@ public class BundleVersion implements Serializable {
this.version = version;
}
- public byte[] getAction() {
+ public String getAction() {
return action;
}
- public void setAction(byte[] action) {
+ public void setAction(String action) {
this.action = action;
}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
index f4ee5d4..0ac6459 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
@@ -22,7 +22,6 @@
*/
package org.rhq.core.domain.bundle.test;
-import java.util.Arrays;
import java.util.List;
import javax.persistence.EntityManager;
@@ -49,7 +48,7 @@ public class BundleTest extends AbstractEJB3Test {
int id;
String name = "BundleTest-testBundleVersionRepo";
- byte[] action = "action/script/recipe is here".getBytes();
+ String action = "action/script/recipe is here";
Repo repo1 = new Repo(name + "-Repo1");
Repo repo2 = new Repo(name + "-Repo2");
@@ -126,7 +125,7 @@ public class BundleTest extends AbstractEJB3Test {
int id;
String name = "BundleTest-testBundleVersion";
- byte[] action = "action/script/recipe is here".getBytes();
+ String action = "action/script/recipe is here";
BundleType bundleType = new BundleType(name + "-Type");
Bundle bundle = new Bundle(name + "-Bundle", bundleType);
@@ -155,7 +154,7 @@ public class BundleTest extends AbstractEJB3Test {
assert bvFind.getId() == bv.getId();
assert bvFind.getName().equals(bv.getName());
assert bvFind.getVersion().equals(bv.getVersion());
- assert Arrays.equals(bvFind.getAction(), bv.getAction());
+ assert bvFind.getAction().equals(bv.getAction());
assert bvFind.getBundle().equals(bv.getBundle());
assert bvFind.equals(bv);
assert bvFind.hashCode() == bv.hashCode();
commit 83590bcca95e79ea331bcb2a9c20737bee8d4321
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 11:33:40 2010 -0500
Fixed botched merge.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index 1fe5bab..fdddc60 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -101,6 +101,7 @@ import org.rhq.enterprise.server.core.EmailManagerLocal;
import org.rhq.enterprise.server.core.plugin.PluginDeploymentScannerMBean;
import org.rhq.enterprise.server.discovery.DiscoveryBossBean;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
+import org.rhq.enterprise.server.entitlement.EntitlementManagerLocal;
import org.rhq.enterprise.server.entitlement.EntitlementManagerBean;
import org.rhq.enterprise.server.event.EventManagerBean;
import org.rhq.enterprise.server.event.EventManagerLocal;
@@ -345,7 +346,7 @@ public final class LookupUtil {
return lookupLocal(EmailManagerBean.class);
}
- public static EntitlementStuffManagerLocal getEntitlementManagerBean() {
+ public static EntitlementManagerLocal getEntitlementManagerBean() {
return lookupLocal(EntitlementManagerBean.class);
}
commit af588cb39b0696357217014771036e5a164c5137
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 10:19:12 2010 -0500
Turns out, when merging master into content there were two EJBs named EntitlementManagerBean. This really, really makes JBoss unhappy. Temporarily moved the prototype one out of the way.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
deleted file mode 100644
index 999a655..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.rhq.enterprise.server.content;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ejb.Stateless;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.core.domain.content.transfer.EntitlementCertificate;
-import org.rhq.enterprise.server.authz.RequiredPermission;
-
-@Stateless
-public class EntitlementManagerBean implements EntitlementManagerLocal, EntitlementManagerRemote {
-
- private final Log log = LogFactory.getLog(EntitlementManagerBean.class);
-
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
- List<EntitlementCertificate> list = new ArrayList<EntitlementCertificate>();
- DummyLoader loader = new DummyLoader();
- try {
- list.add(loader.load(resourceId));
-
- } catch (Exception ex) {
- log.warn("x.509 cert for: " //
- + resourceId //
- + " not-found in: " //
- + DummyLoader.dir);
- }
- return list;
- }
-
-}
-
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerLocal.java
deleted file mode 100644
index 8fe2554..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerLocal.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.rhq.enterprise.server.content;
-
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.content.transfer.EntitlementCertificate;
-
-/**
- *
- * @author jortel
- *
- */
-@Local
-public interface EntitlementManagerLocal {
-
- /**
- * Get a list of entitlement certificates for the specified resources.
- * @param subject The logged in user's subject.
- * @param resourceId The resource id.
- * @return A list of certificates.
- */
- List<EntitlementCertificate> getCertificates(Subject subject, int resourceId);
-}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerRemote.java
deleted file mode 100644
index 16f1a0a..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerRemote.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.rhq.enterprise.server.content;
-
-import java.util.List;
-
-import javax.ejb.Remote;
-import javax.jws.WebMethod;
-import javax.jws.WebParam;
-import javax.jws.WebService;
-import javax.jws.soap.SOAPBinding;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.content.transfer.EntitlementCertificate;
-import org.rhq.enterprise.server.system.ServerVersion;
-
-@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
-@WebService(targetNamespace = ServerVersion.namespace)
-@Remote
-public interface EntitlementManagerRemote {
- /**
- * Get a list of entitlement certificates for the specified resources.
- * @param subject The logged in user's subject.
- * @param resourceId The resource id.
- * @return A list of certificates.
- */
- @WebMethod
- List<EntitlementCertificate> getCertificates( //
- @WebParam(name = "subject") Subject subject, //
- @WebParam(name = "resourceId") int resourceId);
-}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java
new file mode 100644
index 0000000..9e3e69e
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java
@@ -0,0 +1,38 @@
+package org.rhq.enterprise.server.content;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Stateless;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
+import org.rhq.enterprise.server.authz.RequiredPermission;
+
+@Stateless
+public class EntitlementStuffManagerBean implements EntitlementStuffManagerLocal, EntitlementStuffManagerRemote {
+
+ private final Log log = LogFactory.getLog(EntitlementStuffManagerBean.class);
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
+ List<EntitlementCertificate> list = new ArrayList<EntitlementCertificate>();
+ DummyLoader loader = new DummyLoader();
+ try {
+ list.add(loader.load(resourceId));
+
+ } catch (Exception ex) {
+ log.warn("x.509 cert for: " //
+ + resourceId //
+ + " not-found in: " //
+ + DummyLoader.dir);
+ }
+ return list;
+ }
+
+}
+
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerLocal.java
new file mode 100644
index 0000000..7eb4f8c
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerLocal.java
@@ -0,0 +1,25 @@
+package org.rhq.enterprise.server.content;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
+
+/**
+ *
+ * @author jortel
+ *
+ */
+@Local
+public interface EntitlementStuffManagerLocal {
+
+ /**
+ * Get a list of entitlement certificates for the specified resources.
+ * @param subject The logged in user's subject.
+ * @param resourceId The resource id.
+ * @return A list of certificates.
+ */
+ List<EntitlementCertificate> getCertificates(Subject subject, int resourceId);
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerRemote.java
new file mode 100644
index 0000000..6050a70
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerRemote.java
@@ -0,0 +1,29 @@
+package org.rhq.enterprise.server.content;
+
+import java.util.List;
+
+import javax.ejb.Remote;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
+import org.rhq.enterprise.server.system.ServerVersion;
+
+@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
+@WebService(targetNamespace = ServerVersion.namespace)
+@Remote
+public interface EntitlementStuffManagerRemote {
+ /**
+ * Get a list of entitlement certificates for the specified resources.
+ * @param subject The logged in user's subject.
+ * @param resourceId The resource id.
+ * @return A list of certificates.
+ */
+ @WebMethod
+ List<EntitlementCertificate> getCertificates( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "resourceId") int resourceId);
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index e11d8b7..1fe5bab 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -87,8 +87,8 @@ import org.rhq.enterprise.server.content.ContentUIManagerBean;
import org.rhq.enterprise.server.content.ContentUIManagerLocal;
import org.rhq.enterprise.server.content.DistributionManagerBean;
import org.rhq.enterprise.server.content.DistributionManagerLocal;
-import org.rhq.enterprise.server.content.EntitlementManagerBean;
-import org.rhq.enterprise.server.content.EntitlementManagerLocal;
+import org.rhq.enterprise.server.content.EntitlementStuffManagerBean;
+import org.rhq.enterprise.server.content.EntitlementStuffManagerLocal;
import org.rhq.enterprise.server.content.RepoManagerBean;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.content.metadata.ContentSourceMetadataManagerBean;
@@ -101,6 +101,7 @@ import org.rhq.enterprise.server.core.EmailManagerLocal;
import org.rhq.enterprise.server.core.plugin.PluginDeploymentScannerMBean;
import org.rhq.enterprise.server.discovery.DiscoveryBossBean;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
+import org.rhq.enterprise.server.entitlement.EntitlementManagerBean;
import org.rhq.enterprise.server.event.EventManagerBean;
import org.rhq.enterprise.server.event.EventManagerLocal;
import org.rhq.enterprise.server.measurement.AvailabilityManagerBean;
@@ -344,7 +345,7 @@ public final class LookupUtil {
return lookupLocal(EmailManagerBean.class);
}
- public static EntitlementManagerLocal getEntitlementManagerBean() {
+ public static EntitlementStuffManagerLocal getEntitlementManagerBean() {
return lookupLocal(EntitlementManagerBean.class);
}
@@ -432,8 +433,8 @@ public final class LookupUtil {
return lookupLocal(RepoManagerBean.class);
}
- public static EntitlementManagerLocal getEntitlementManager() {
- return lookupLocal(EntitlementManagerBean.class);
+ public static EntitlementStuffManagerLocal getEntitlementManager() {
+ return lookupLocal(EntitlementStuffManagerBean.class);
}
public static DistributionManagerLocal getDistributionManagerLocal() {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index b427713..a111f46 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -117,7 +117,7 @@ import org.rhq.enterprise.server.content.AdvisoryManagerLocal;
import org.rhq.enterprise.server.content.ContentManagerLocal;
import org.rhq.enterprise.server.content.DistributionException;
import org.rhq.enterprise.server.content.DistributionManagerLocal;
-import org.rhq.enterprise.server.content.EntitlementManagerLocal;
+import org.rhq.enterprise.server.content.EntitlementStuffManagerLocal;
import org.rhq.enterprise.server.content.RepoException;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
@@ -196,7 +196,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
private SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
private SupportManagerLocal supportManager = LookupUtil.getSupportManager();
private SystemManagerLocal systemManager = LookupUtil.getSystemManager();
- private EntitlementManagerLocal entitlementManager = LookupUtil.getEntitlementManager();
+ private EntitlementStuffManagerLocal entitlementManager = LookupUtil.getEntitlementManager();
//ADVISORYMANAGER: BEGIN ------------------------------------------
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
index 86d48cf..8ddfc49 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
@@ -12,7 +12,7 @@ import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
import org.rhq.enterprise.server.content.AdvisoryManagerRemote;
import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.DistributionManagerRemote;
-import org.rhq.enterprise.server.content.EntitlementManagerRemote;
+import org.rhq.enterprise.server.content.EntitlementStuffManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
@@ -43,7 +43,7 @@ public interface WebservicesRemote extends //
AvailabilityManagerRemote,//
CallTimeDataManagerRemote,//
RepoManagerRemote,//
- EntitlementManagerRemote, //
+ EntitlementStuffManagerRemote, //
ConfigurationManagerRemote,//
ContentManagerRemote,//
//Removed as it was problematic for WS clients. Not sure if this well be re-enabled.
commit a80b205dafc0a1f196f9a9a1b60fd8bac05ca250
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 09:43:27 2010 -0500
Oops, my IDE accidentally added some testing changes to the index, undoing part of that last commit.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DummyLoader.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DummyLoader.java
new file mode 100644
index 0000000..63dbb7b
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DummyLoader.java
@@ -0,0 +1,63 @@
+/*
+* 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.content;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
+
+/**
+ * @author Jason Dobies
+ */
+public class DummyLoader {
+
+ static final String dir = "/etc/pki/rhq";
+
+ EntitlementCertificate load(int resourceId) throws IOException {
+ String name = String.valueOf(resourceId);
+ EntitlementCertificate x509 = load("client");
+ x509.setName(name);
+ return x509;
+ }
+
+ EntitlementCertificate load(String name) throws IOException {
+ String key = read(name + ".key");
+ String pem = read(name + ".pem");
+ return new EntitlementCertificate(name, key, pem);
+ }
+
+ private String read(String fn) throws IOException {
+ String path = dir + File.separator + fn;
+ File f = new File(path);
+ byte[] buffer = new byte[(int) f.length()];
+ BufferedInputStream istr = new BufferedInputStream(new FileInputStream(f));
+ istr.read(buffer);
+ String result = new String(buffer);
+ istr.close();
+ return result;
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java
deleted file mode 100644
index 6620486..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.rhq.enterprise.server.content;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ejb.Stateless;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.core.domain.content.transfer.EntitlementCertificate;
-import org.rhq.enterprise.server.authz.RequiredPermission;
-
-@Stateless
-public class EntitlementStuffManagerBean implements EntitlementManagerLocal, EntitlementManagerRemote {
-
- private final Log log = LogFactory.getLog(EntitlementStuffManagerBean.class);
-
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
- List<EntitlementCertificate> list = new ArrayList<EntitlementCertificate>();
- DummyLoader loader = new DummyLoader();
- try {
- list.add(loader.load(resourceId));
-
- } catch (Exception ex) {
- log.warn("x.509 cert for: " //
- + resourceId //
- + " not-found in: " //
- + DummyLoader.dir);
- }
- return list;
- }
-
-}
-
commit 3fef1f546e7d1df40bd5007dfca79c0b34070768
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 09:41:12 2010 -0500
This needs to return the bean, not the local interface.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
index 7220970..999a655 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
@@ -1,9 +1,5 @@
package org.rhq.enterprise.server.content;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -37,33 +33,6 @@ public class EntitlementManagerBean implements EntitlementManagerLocal, Entitlem
}
return list;
}
-}
-
-class DummyLoader {
-
- static final String dir = "/etc/pki/rhq";
-
- EntitlementCertificate load(int resourceId) throws IOException {
- String name = String.valueOf(resourceId);
- EntitlementCertificate x509 = load("client");
- x509.setName(name);
- return x509;
- }
- EntitlementCertificate load(String name) throws IOException {
- String key = read(name + ".key");
- String pem = read(name + ".pem");
- return new EntitlementCertificate(name, key, pem);
- }
-
- private String read(String fn) throws IOException {
- String path = dir + File.separator + fn;
- File f = new File(path);
- byte[] buffer = new byte[(int) f.length()];
- BufferedInputStream istr = new BufferedInputStream(new FileInputStream(f));
- istr.read(buffer);
- String result = new String(buffer);
- istr.close();
- return result;
- }
}
+
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java
new file mode 100644
index 0000000..6620486
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java
@@ -0,0 +1,38 @@
+package org.rhq.enterprise.server.content;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Stateless;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
+import org.rhq.enterprise.server.authz.RequiredPermission;
+
+@Stateless
+public class EntitlementStuffManagerBean implements EntitlementManagerLocal, EntitlementManagerRemote {
+
+ private final Log log = LogFactory.getLog(EntitlementStuffManagerBean.class);
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
+ List<EntitlementCertificate> list = new ArrayList<EntitlementCertificate>();
+ DummyLoader loader = new DummyLoader();
+ try {
+ list.add(loader.load(resourceId));
+
+ } catch (Exception ex) {
+ log.warn("x.509 cert for: " //
+ + resourceId //
+ + " not-found in: " //
+ + DummyLoader.dir);
+ }
+ return list;
+ }
+
+}
+
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index fb185c8..e11d8b7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -345,7 +345,7 @@ public final class LookupUtil {
}
public static EntitlementManagerLocal getEntitlementManagerBean() {
- return lookupLocal(EntitlementManagerLocal.class);
+ return lookupLocal(EntitlementManagerBean.class);
}
public static EntityManagerFacadeLocal getEntityManagerFacade() {
commit 99c5d3d471d195eac0cdfec4ba92952e451979d0
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 09:03:06 2010 -0500
Fixed incorrect logger declaration.
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java
index 0904ee5..f61ca7b 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java
@@ -7,11 +7,9 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.enterprise.server.content.EntitlementManagerBean;
-
public class ContentFilter {
- private final Log log = LogFactory.getLog(EntitlementManagerBean.class);
+ private final Log log = LogFactory.getLog(ContentFilter.class);
static final String CERTS = "javax.servlet.request.X509Certificate";
commit e8345020f585e0780a91a628fede0c90ad5919c2
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 08:36:12 2010 -0500
Removed invalid import.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index cd14ebc..fb185c8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -101,7 +101,6 @@ import org.rhq.enterprise.server.core.EmailManagerLocal;
import org.rhq.enterprise.server.core.plugin.PluginDeploymentScannerMBean;
import org.rhq.enterprise.server.discovery.DiscoveryBossBean;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
-import org.rhq.enterprise.server.entitlement.EntitlementManagerLocal;
import org.rhq.enterprise.server.event.EventManagerBean;
import org.rhq.enterprise.server.event.EventManagerLocal;
import org.rhq.enterprise.server.measurement.AvailabilityManagerBean;
commit d8fd6998dee8eeaa2d337412f839943221624825
Merge: d50e6c3... 9ba9416...
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 08:25:52 2010 -0500
Merge branch 'master' into content
Conflicts:
.classpath
modules/core/dbutils/pom.xml
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml
diff --cc modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 6da02b6,21cd3c7..3eca05e
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@@ -2757,242 -2757,25 +2757,262 @@@
</schema-directSQL>
</schemaSpec>
+ <schemaSpec version="2.75">
+ <schema-addColumn table="RHQ_REPO" column="SYNC_SCHEDULE" columnType="VARCHAR2" precision="64" />
+ </schemaSpec>
+
+ <schemaSpec version="2.76">
+ <schema-addColumn table="RHQ_CONFIG_PROP_DEF" column="DYNAMIC_TYPE" columnType="VARCHAR2" precision="20" />
+ <schema-addColumn table="RHQ_CONFIG_PROP_DEF" column="DYNAMIC_KEY" columnType="VARCHAR2" precision="128" />
+ </schemaSpec>
+
+ <schemaSpec version="2.76.1">
+ <!-- RHQ_BUNDLE_TYPE -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_TYPE">
+ CREATE TABLE RHQ_BUNDLE_TYPE ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_TYPE" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_TYPE_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_TYPE">
+ ALTER TABLE RHQ_BUNDLE_TYPE ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_TYPE" column="NAME" columnType="VARCHAR2" precision="200" />
+ <schema-alterColumn table="RHQ_BUNDLE_TYPE" column="NAME" nullable="FALSE" />
+
+ <!-- RHQ_BUNDLE -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE">
+ CREATE TABLE RHQ_BUNDLE ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE">
+ ALTER TABLE RHQ_BUNDLE ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE" column="NAME" columnType="VARCHAR2" precision="200" />
+ <schema-alterColumn table="RHQ_BUNDLE" column="NAME" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE" column="BUNDLE_TYPE_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE" column="BUNDLE_TYPE_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE foreign key relation to RHQ_BUNDLE_TYPE">
+ ALTER TABLE RHQ_BUNDLE
+ ADD CONSTRAINT RHQ_BUNDLE_TYPE_ID_FK
+ FOREIGN KEY (BUNDLE_TYPE_ID)
+ REFERENCES RHQ_BUNDLE_TYPE (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_VERSION -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_VERSION">
+ CREATE TABLE RHQ_BUNDLE_VERSION ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_VERSION_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_VERSION ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="NAME" columnType="VARCHAR2" precision="200" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="NAME" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="VERSION" columnType="VARCHAR2" precision="500" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="VERSION" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="ACTION" columnType="BLOB" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="ACTION" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION foreign key relation to RHQ_BUNDLE">
+ ALTER TABLE RHQ_BUNDLE_VERSION
+ ADD CONSTRAINT RHQ_BUNDLE_ID_FK
+ FOREIGN KEY (BUNDLE_ID)
+ REFERENCES RHQ_BUNDLE (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="DISTRIBUTION_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION foreign key relation to RHQ_DISTRIBUTION">
+ ALTER TABLE RHQ_BUNDLE_VERSION
+ ADD CONSTRAINT RHQ_DISTRIBUTION_ID_FK
+ FOREIGN KEY (DISTRIBUTION_ID)
+ REFERENCES RHQ_DISTRIBUTION (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_VERSION_REPO -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_VERSION_REPO">
+ CREATE TABLE RHQ_BUNDLE_VERSION_REPO ( BUNDLE_VERSION_ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION_REPO" column="BUNDLE_VERSION_ID" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION_REPO" column="REPO_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION_REPO" column="REPO_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_VERSION_REPO">
+ ALTER TABLE RHQ_BUNDLE_VERSION_REPO ADD PRIMARY KEY ( BUNDLE_VERSION_ID, REPO_ID )
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION_REPO foreign key relation to RHQ_BUNDLE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_VERSION_REPO
+ ADD CONSTRAINT RHQ_BUNDLE_VERSION_ID_FK
+ FOREIGN KEY (BUNDLE_VERSION_ID)
+ REFERENCES RHQ_BUNDLE_VERSION (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION_REPO foreign key relation to RHQ_REPO">
+ ALTER TABLE RHQ_BUNDLE_VERSION_REPO
+ ADD CONSTRAINT RHQ_REPO_ID_FK
+ FOREIGN KEY (REPO_ID)
+ REFERENCES RHQ_REPO (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_FILE -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_FILE">
+ CREATE TABLE RHQ_BUNDLE_FILE ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_FILE" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_FILE_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_FILE">
+ ALTER TABLE RHQ_BUNDLE_FILE ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_FILE" column="BUNDLE_VERSION_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_FILE" column="BUNDLE_VERSION_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_BUNDLE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_FILE
+ ADD CONSTRAINT RHQ_BUNDLE_VERSION_ID_FK
+ FOREIGN KEY (BUNDLE_VERSION_ID)
+ REFERENCES RHQ_BUNDLE_VERSION (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_FILE" column="PACKAGE_VERSION_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_PACKAGE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_FILE
+ ADD CONSTRAINT RHQ_PACKAGE_VERSION_ID_FK
+ FOREIGN KEY (PACKAGE_VERSION_ID)
+ REFERENCES RHQ_PACKAGE_VERSION (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_FILE" column="PACKAGE_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_PACKAGE">
+ ALTER TABLE RHQ_BUNDLE_FILE
+ ADD CONSTRAINT RHQ_PACKAGE_ID_FK
+ FOREIGN KEY (PACKAGE_ID)
+ REFERENCES RHQ_PACKAGE (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_CONFIG -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_CONFIG">
+ CREATE TABLE RHQ_BUNDLE_CONFIG ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_CONFIG" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_CONFIG_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_CONFIG">
+ ALTER TABLE RHQ_BUNDLE_CONFIG ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_CONFIG" column="CONFIG_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_CONFIG foreign key relation to RHQ_CONFIG">
+ ALTER TABLE RHQ_BUNDLE_CONFIG
+ ADD CONSTRAINT RHQ_CONFIG_ID_FK
+ FOREIGN KEY (CONFIG_ID)
+ REFERENCES RHQ_CONFIG (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_CONFIG" column="BUNDLE_VERSION_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_CONFIG foreign key relation to RHQ_BUNDLE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_CONFIG
+ ADD CONSTRAINT RHQ_BUNDLE_VERSION_ID_FK
+ FOREIGN KEY (BUNDLE_VERSION_ID)
+ REFERENCES RHQ_BUNDLE_VERSION (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_CONFIG" column="BUNDLE_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_CONFIG foreign key relation to RHQ_BUNDLE">
+ ALTER TABLE RHQ_BUNDLE_CONFIG
+ ADD CONSTRAINT RHQ_BUNDLE_ID_FK
+ FOREIGN KEY (BUNDLE_ID)
+ REFERENCES RHQ_BUNDLE (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_DEPLOYMENT -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_DEPLOYMENT">
+ CREATE TABLE RHQ_BUNDLE_DEPLOYMENT ( BUNDLE_CONFIG_ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_DEPLOYMENT" column="BUNDLE_CONFIG_ID" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_DEPLOYMENT" column="RESOURCE_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_DEPLOYMENT" column="RESOURCE_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_DEPLOYMENT">
+ ALTER TABLE RHQ_BUNDLE_DEPLOYMENT ADD PRIMARY KEY ( BUNDLE_CONFIG_ID, RESOURCE_ID )
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_DEPLOYMENT foreign key relation to RHQ_BUNDLE_CONFIG">
+ ALTER TABLE RHQ_BUNDLE_DEPLOYMENT
+ ADD CONSTRAINT RHQ_BUNDLE_CONFIG_ID_FK
+ FOREIGN KEY (BUNDLE_CONFIG_ID)
+ REFERENCES RHQ_BUNDLE_CONFIG (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_DEPLOYMENT foreign key relation to RHQ_RESOURCE">
+ ALTER TABLE RHQ_BUNDLE_DEPLOYMENT
+ ADD CONSTRAINT RHQ_RESOURCE_ID_FK
+ FOREIGN KEY (RESOURCE_ID)
+ REFERENCES RHQ_RESOURCE (ID)
+ </statement>
+ </schema-directSQL>
++ </schemaSpec>
+
+ <schemaSpec version="2.77">
+ <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIF_TEMPLATE_ID" columnType="INTEGER"/>
+ <schema-directSQL>
+ <statement>
+ ALTER TABLE RHQ_ALERT_NOTIFICATION
+ ADD CONSTRAINT RHQ_NOTIF_TEMPL_ID_FKEY
+ FOREIGN KEY (NOTIF_TEMPLATE_ID)
+ REFERENCES RHQ_ALERT_NOTIF_TEMPL(ID)
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
+ <schemaSpec version="2.77.1">
+ <schema-createSequence name="RHQ_ALERT_NOTIF_TEMPL_ID_SEQ" initial="10001"/>
+ </schemaSpec>
+ <schemaSpec version="2.77.2">
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_host"/>
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_port"/>
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_oid"/>
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="email_address"/>
</schemaSpec>
</dbupgrade>
</target>
diff --cc modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml
index 873b26a,2844bcb..71dda8a
--- 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
@@@ -779,32 -790,25 +790,31 @@@
placement="firstChild" />
</tab>
- <tab name="Content.New" displayName="New" url="/rhq/resource/content/deploy.xhtml">
+ <tab name="Content.New" displayName="Install" url="/rhq/resource/content/deploy.xhtml">
<position
-
+
name="Content.Deployed"
placement="after" />
</tab>
--
- <tab name="Content.Subscriptions" displayName="Subscriptions" url="/rhq/resource/content/subscription.xhtml">
+ <tab name="Content.Update" displayName="Update" url="/rhq/resource/content/update.xhtml">
<position
name="Content.New"
placement="after" />
- </tab>
+ </tab>
+ <tab name="Content.Subscriptions" displayName="Subscriptions" url="/rhq/resource/content/subscription.xhtml">
+ <position
+
+ name="Content.Update"
+ placement="after" />
- </tab>
++ </tab>
+
<tab name="Content.History" displayName="History" url="/rhq/resource/content/history.xhtml">
<position
-
+
name="Content.Subscriptions"
placement="after" />
- </tab>
-
+ </tab>
+
</perspectivePlugin>
commit d50e6c3146963b2304d541ad92e51110738645ad
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 08:15:13 2010 -0500
Fixed test to be self-sufficient. Prior to this change, the test relied on the server being started at least once to populate the database with the default plugins' metadata.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
index fe4b61e..4e6dd5d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
@@ -34,6 +34,7 @@ import org.jboss.annotation.IgnoreDependency;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.InventoryStatus;
@@ -84,7 +85,14 @@ public class RegistrationManagerBean implements RegistrationManagerLocal, Regist
ConfigurationDefinition configDefinition = configManager.getPluginConfigurationDefinitionForResourceType(user,
resourceType.getId());
- Configuration platformConfig = configDefinition.getDefaultTemplate().getConfiguration();
+ Configuration platformConfig = null;
+ if (configDefinition != null) {
+ ConfigurationTemplate template = configDefinition.getDefaultTemplate();
+
+ if (template != null) {
+ platformConfig = template.getConfiguration();
+ }
+ }
platform.setPluginConfiguration(platformConfig);
platform.setInventoryStatus(InventoryStatus.COMMITTED);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
index 8571aa9..3dc9696 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
@@ -21,12 +21,14 @@ package org.rhq.enterprise.server.registration.test;
import javax.persistence.EntityManager;
+import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.server.registration.RegistrationManagerLocal;
import org.rhq.enterprise.server.registration.ReleaseRepoMapping;
@@ -47,9 +49,29 @@ public class RegistrationBeanTest extends AbstractEJB3Test {
this.registrationManager = LookupUtil.getRegistrationManager();
this.resourceTypeManager = LookupUtil.getResourceTypeManager();
this.overlord = LookupUtil.getSubjectManager().getOverlord();
+
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+
+ platformType = new ResourceType("RegistrationBeanTest.testRegisterPlatform",
+ "RegistrationBeanTest.testRegisterPlatform", ResourceCategory.PLATFORM, null);
+ em.persist(platformType);
+
+ getTransactionManager().commit();
+ }
+
+ @AfterClass
+ public void afterClass() throws Exception {
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+
+ platformType = em.find(ResourceType.class, platformType.getId());
+ em.remove(platformType);
+
+ getTransactionManager().commit();
}
- @Test(groups = "integration.ejb3")
+ @Test
public void testRegisterPlatform() throws Exception {
getTransactionManager().begin();
EntityManager em = getEntityManager();
@@ -57,7 +79,6 @@ public class RegistrationBeanTest extends AbstractEJB3Test {
createAgent(em);
em.flush();
- platformType = getPlatformResourceType();
Resource platform = new Resource("alpha", "platform", platformType);
registrationManager.registerPlatform(overlord, platform, parentId);
@@ -73,14 +94,14 @@ public class RegistrationBeanTest extends AbstractEJB3Test {
String arch = "x86_64";
ReleaseRepoMapping repomap = new ReleaseRepoMapping(release, version, arch);
String repo = repomap.getCompatibleRepo();
- assert (repo == "rhel-x86_64-server-5");
+ assert repo.equals("rhel-x86_64-server-5");
String release2 = "5Client";
String arch2 = "x86_64";
String version2 = "5.4.0";
ReleaseRepoMapping repomap2 = new ReleaseRepoMapping(release2, version2, arch2);
String repo2 = repomap2.getCompatibleRepo();
- assert (repo2 == "rhel-x86_64-client-5");
+ assert repo2.equals("rhel-x86_64-client-5");
}
@@ -89,9 +110,4 @@ public class RegistrationBeanTest extends AbstractEJB3Test {
em.persist(agent);
}
- private ResourceType getPlatformResourceType() {
-
- return resourceTypeManager.getResourceTypeByNameAndPlugin(overlord, "Linux", "Platforms");
- }
-
}
commit 2dde4f55abe2517db8330f7a700816a6e68b8e57
Merge: 82d2bf3... 52e5199...
Author: Heiko W. Rupp <pilhuhn(a)fedorapeople.org>
Date: Wed Jan 27 12:31:09 2010 +0100
Merge branch 'alertPlugin' of ssh://git.fedorahosted.org/git/rhq/rhq into alertPlugin
commit 82d2bf38963877ec23fabe8452fa32ab53a34f4b
Author: Heiko W. Rupp <pilhuhn(a)fedorapeople.org>
Date: Wed Jan 27 12:19:23 2010 +0100
Add alert id BZ 555091, comment 10
diff --git a/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java b/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
index 341b1bf..a2795c8 100644
--- a/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
+++ b/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
@@ -51,7 +51,8 @@ public class MicroblogSender extends AlertSender {
Twitter twitter = new Twitter(user,password,baseUrl);
AlertManagerLocal alertManager = LookupUtil.getAlertManager();
twitter.setSource("Jopr");
- StringBuilder b = new StringBuilder("Alert: '");
+ StringBuilder b = new StringBuilder("Alert ");
+ b.append(alert.getId()).append(":'"); // Alert id
b.append(alert.getAlertDefinition().getResource().getName());
b.append("' (");
b.append(alert.getAlertDefinition().getResource().getId());
@@ -69,6 +70,7 @@ public class MicroblogSender extends AlertSender {
log.warn("Notification via Microblog failed for " + txt + " ", e);
result = new SenderResult(ResultState.FAILURE,"Sending failed :" + e.getMessage());
+
}
return result;
}
commit 54b75fe1df36921d1162b7fd985eaf8817e624fc
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 27 03:13:18 2010 -0500
new bundle config/file/deployment entities
these might not be finished - unsure if we want to use discriminators
to support multiple enties depending on relationship with package or package version
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleConfig.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleConfig.java
new file mode 100644
index 0000000..443a276
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleConfig.java
@@ -0,0 +1,156 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+import org.rhq.core.domain.configuration.Configuration;
+
+/**
+ * Defines a set of configuration values that can be used to deploy a bundle version somewhere.
+ *
+ * @author John Mazzitelli
+ */
+@Entity
+@NamedQueries( { @NamedQuery(name = BundleConfig.QUERY_FIND_ALL, query = "SELECT bc FROM BundleConfig bc") //
+})
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_BUNDLE_CONFIG_ID_SEQ")
+@Table(name = "RHQ_BUNDLE_CONFIG")
+(a)XmlAccessorType(XmlAccessType.FIELD)
+public class BundleConfig implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_FIND_ALL = "BundleConfig.findAll";
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
+ @Id
+ private int id;
+
+ @JoinColumn(name = "CONFIG_ID", referencedColumnName = "ID", nullable = true)
+ @ManyToOne(fetch = FetchType.LAZY)
+ private Configuration configuration;
+
+ @JoinColumn(name = "BUNDLE_VERSION_ID", referencedColumnName = "ID", nullable = true)
+ @ManyToOne(fetch = FetchType.LAZY)
+ private BundleVersion bundleVersion;
+
+ @JoinColumn(name = "BUNDLE_ID", referencedColumnName = "ID", nullable = true)
+ @ManyToOne(fetch = FetchType.LAZY)
+ private Bundle bundle;
+
+ public BundleConfig() {
+ // for JPA use
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public Configuration getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(Configuration config) {
+ this.configuration = config;
+ }
+
+ public BundleVersion getBundleVersion() {
+ return bundleVersion;
+ }
+
+ public void setBundleVersion(BundleVersion bundleVersion) {
+ this.bundleVersion = bundleVersion;
+ }
+
+ public Bundle getBundle() {
+ return bundle;
+ }
+
+ public void setBundle(Bundle bundle) {
+ this.bundle = bundle;
+ }
+
+ @Override
+ public String toString() {
+ return "BundleConfig[id=" + id + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((bundleVersion == null) ? 0 : bundleVersion.hashCode());
+ result = prime * result + ((bundle == null) ? 0 : bundle.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof BundleConfig)) {
+ return false;
+ }
+
+ BundleConfig other = (BundleConfig) obj;
+
+ if (bundleVersion == null) {
+ if (other.bundleVersion != null) {
+ return false;
+ }
+ } else if (!bundleVersion.equals(other.bundleVersion)) {
+ return false;
+ }
+
+ if (bundle == null) {
+ if (other.bundle != null) {
+ return false;
+ }
+ } else if (!bundle.equals(other.bundle)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
new file mode 100644
index 0000000..702c6eb
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
@@ -0,0 +1,134 @@
+/*
+ * 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+import org.rhq.core.domain.resource.Resource;
+
+/**
+ * This is the many-to-many entity that correlates a bundle configuration with a resource where
+ * that bundle config is installed. A bundle configuration is essentially a bundle version with
+ * the custom configuration settings that were used to determine how/where that bundle version
+ * was deployed to the resource.
+ *
+ * @author John Mazzitelli
+ */
+@Entity
+(a)IdClass(BundleDeploymentPK.class)
+@NamedQueries( {
+ @NamedQuery(name = BundleDeployment.QUERY_FIND_BY_BUNDLE_CONFIG_ID_NO_FETCH, query = "SELECT bd FROM BundleDeployment bd WHERE bd.bundleConfig.id = :id "),
+ @NamedQuery(name = BundleDeployment.QUERY_FIND_BY_RESOURCE_ID_NO_FETCH, query = "SELECT bd FROM BundleDeployment bd WHERE bd.resource.id = :id ") })
+@Table(name = "RHQ_BUNDLE_DEPLOYMENT")
+public class BundleDeployment implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_FIND_BY_BUNDLE_CONFIG_ID_NO_FETCH = "BundleDeployment.findByBundleConfigIdNoFetch";
+ public static final String QUERY_FIND_BY_RESOURCE_ID_NO_FETCH = "BundleDeployment.findByResourceIdNoFetch";
+
+ /*
+ * http://opensource.atlassian.com/projects/hibernate/browse/EJB-286 Hibernate seems to want these mappings in the
+ * @IdClass and ignore these here, even though the mappings should be here and no mappings should be needed in the
+ * @IdClass.
+ */
+ @Id
+ // @ManyToOne
+ // @JoinColumn(name = "BUNDLE_VERSION_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
+ private BundleConfig bundleConfig;
+
+ @Id
+ // @ManyToOne
+ // @JoinColumn(name = "REPO_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
+ private Resource resource;
+
+ protected BundleDeployment() {
+ }
+
+ public BundleDeployment(BundleConfig bundleConfig, Resource repo) {
+ this.bundleConfig = bundleConfig;
+ this.resource = repo;
+ }
+
+ public BundleDeploymentPK getBundleVersionRepoPK() {
+ return new BundleDeploymentPK(bundleConfig, resource);
+ }
+
+ public void setBundleVersionRepoPK(BundleDeploymentPK pk) {
+ this.bundleConfig = pk.getBundleConfig();
+ this.resource = pk.getResource();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder str = new StringBuilder("BundleDeployment: ");
+ str.append(", bc=[").append(this.bundleConfig).append("]");
+ str.append(", resource=[").append(this.resource).append("]");
+ return str.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 1;
+ result = (31 * result) + ((bundleConfig == null) ? 0 : bundleConfig.hashCode());
+ result = (31 * result) + ((resource == null) ? 0 : resource.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if ((obj == null) || (!(obj instanceof BundleDeployment))) {
+ return false;
+ }
+
+ final BundleDeployment other = (BundleDeployment) obj;
+
+ if (bundleConfig == null) {
+ if (bundleConfig != null) {
+ return false;
+ }
+ } else if (!bundleConfig.equals(other.bundleConfig)) {
+ return false;
+ }
+
+ if (resource == null) {
+ if (resource != null) {
+ return false;
+ }
+ } else if (!resource.equals(other.resource)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentPK.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentPK.java
new file mode 100644
index 0000000..3549360
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentPK.java
@@ -0,0 +1,122 @@
+/*
+ * 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+
+import org.rhq.core.domain.resource.Resource;
+
+/**
+ * This is the composite primary key for the {@link BundleDeployment} entity. That entity is an explicit
+ * many-to-many mapping table, so this composite key is simply the foreign keys to both ends of that relationship.
+ *
+ * @author John Mazzitelli
+ */
+public class BundleDeploymentPK implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /*
+ * http://opensource.atlassian.com/projects/hibernate/browse/EJB-286 Hibernate seems to want these mappings here,
+ * even though this class is an @IdClass and it should not need the mappings here. The mappings belong in the
+ * entity itself.
+ */
+ @JoinColumn(name = "BUNDLE_CONFIG_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne
+ // persist so we can add the version as soon as we map it
+ private BundleConfig bundleConfig;
+
+ @JoinColumn(name = "RESOURCE_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne
+ private Resource resource;
+
+ public BundleDeploymentPK() {
+ }
+
+ public BundleDeploymentPK(BundleConfig bc, Resource r) {
+ bundleConfig = bc;
+ resource = r;
+ }
+
+ public BundleConfig getBundleConfig() {
+ return bundleConfig;
+ }
+
+ public void setBundleConfig(BundleConfig bc) {
+ this.bundleConfig = bc;
+ }
+
+ public Resource getResource() {
+ return resource;
+ }
+
+ public void setResource(Resource resource) {
+ this.resource = resource;
+ }
+
+ @Override
+ public String toString() {
+ return "BundleDeploymentPK: bundleConfig=[" + bundleConfig + "]; resource=[" + resource + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 1;
+ result = (31 * result) + ((bundleConfig == null) ? 0 : bundleConfig.hashCode());
+ result = (31 * result) + ((resource == null) ? 0 : resource.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (!(obj instanceof BundleDeploymentPK)) {
+ return false;
+ }
+
+ final BundleDeploymentPK other = (BundleDeploymentPK) obj;
+
+ if (bundleConfig == null) {
+ if (other.bundleConfig != null) {
+ return false;
+ }
+ } else if (!bundleConfig.equals(other.bundleConfig)) {
+ return false;
+ }
+
+ if (resource == null) {
+ if (other.resource != null) {
+ return false;
+ }
+ } else if (!resource.equals(other.resource)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleFile.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleFile.java
new file mode 100644
index 0000000..2eacd4e
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleFile.java
@@ -0,0 +1,169 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+import org.rhq.core.domain.content.Package;
+import org.rhq.core.domain.content.PackageVersion;
+
+/**
+ * Defines a bundle file that is part of a bundle version.
+ *
+ * @author John Mazzitelli
+ */
+@Entity
+@NamedQueries( {
+ @NamedQuery(name = BundleFile.QUERY_FIND_ALL, query = "SELECT bf FROM BundleFile bf"), //
+ @NamedQuery(name = BundleFile.QUERY_FIND_BY_BUNDLE_VERSION_ID, query = "SELECT bf FROM BundleFile bf WHERE bf.bundleVersion.id = :id") //
+})
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_BUNDLE_CONFIG_ID_SEQ")
+@Table(name = "RHQ_BUNDLE_FILE")
+(a)XmlAccessorType(XmlAccessType.FIELD)
+public class BundleFile implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_FIND_ALL = "BundleFile.findAll";
+ public static final String QUERY_FIND_BY_BUNDLE_VERSION_ID = "BundleFile.findByBundleVersionId";
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
+ @Id
+ private int id;
+
+ @JoinColumn(name = "BUNDLE_VERSION_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne(fetch = FetchType.LAZY)
+ private BundleVersion bundleVersion;
+
+ @JoinColumn(name = "PACKAGE_ID", referencedColumnName = "ID", nullable = true)
+ @ManyToOne(fetch = FetchType.LAZY)
+ private Package pkg;
+
+ @JoinColumn(name = "PACKAGE_VERSION_ID", referencedColumnName = "ID", nullable = true)
+ @ManyToOne(fetch = FetchType.LAZY)
+ private PackageVersion packageVersion;
+
+ public BundleFile() {
+ // for JPA use
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public BundleVersion getBundleVersion() {
+ return bundleVersion;
+ }
+
+ public void setBundleVersion(BundleVersion bundleVersion) {
+ this.bundleVersion = bundleVersion;
+ }
+
+ public Package getPackage() {
+ return pkg;
+ }
+
+ public void setPackage(Package pkg) {
+ this.pkg = pkg;
+ }
+
+ public PackageVersion getPackageVersion() {
+ return packageVersion;
+ }
+
+ public void setPackageVersion(PackageVersion packageVersion) {
+ this.packageVersion = packageVersion;
+ }
+
+ @Override
+ public String toString() {
+ return "BundleFile[id=" + id + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((bundleVersion == null) ? 0 : bundleVersion.hashCode());
+ result = prime * result + ((pkg == null) ? 0 : pkg.hashCode());
+ result = prime * result + ((packageVersion == null) ? 0 : packageVersion.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof BundleFile)) {
+ return false;
+ }
+
+ BundleFile other = (BundleFile) obj;
+
+ if (bundleVersion == null) {
+ if (other.bundleVersion != null) {
+ return false;
+ }
+ } else if (!bundleVersion.equals(other.bundleVersion)) {
+ return false;
+ }
+
+ if (pkg == null) {
+ if (other.pkg != null) {
+ return false;
+ }
+ } else if (!pkg.equals(other.pkg)) {
+ return false;
+ }
+
+ if (packageVersion == null) {
+ if (other.packageVersion != null) {
+ return false;
+ }
+ } else if (!packageVersion.equals(other.packageVersion)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
index 28d1994..1a40205 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
@@ -53,6 +53,9 @@ import org.rhq.core.domain.auth.Principal;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.bundle.Bundle;
+import org.rhq.core.domain.bundle.BundleConfig;
+import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.bundle.BundleFile;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.bundle.BundleVersionRepo;
@@ -148,12 +151,14 @@ public class QueryAllTest extends AbstractEJB3Test {
ContentSource.class.getSimpleName(), ContentSourceType.class.getSimpleName(),
InstalledPackage.class.getSimpleName(), Package.class.getSimpleName(), PackageBits.class.getSimpleName(),
PackageInstallationStep.class.getSimpleName(), PackageType.class.getSimpleName(),
- PackageVersion.class.getSimpleName(), PackageVersionContentSource.class.getSimpleName(),
+ PackageVersion.class.getSimpleName(),
+ PackageVersionContentSource.class.getSimpleName(),
ContentSourceSyncResults.class.getSimpleName(),
// bundle stuff
BundleType.class.getSimpleName(), Bundle.class.getSimpleName(), BundleVersion.class.getSimpleName(),
- BundleVersionRepo.class.getSimpleName(),
+ BundleVersionRepo.class.getSimpleName(), BundleConfig.class.getSimpleName(), BundleFile.class.getSimpleName(),
+ BundleDeployment.class.getSimpleName(),
// group stuff
GroupDefinition.class.getSimpleName(), ResourceGroup.class.getSimpleName(),
commit 26828e1f1e0e60e34e05106b851657edede3e0df
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 27 02:36:28 2010 -0500
BundleVersionRepo entity and unit tests
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersionRepo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersionRepo.java
new file mode 100644
index 0000000..45beeb8
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersionRepo.java
@@ -0,0 +1,132 @@
+/*
+ * 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+import org.rhq.core.domain.content.Repo;
+
+/**
+ * This is the many-to-many entity that correlates a bundle version with a repo that has content
+ * needed by the bundle.
+ *
+ * @author John Mazzitelli
+ */
+@Entity
+(a)IdClass(BundleVersionRepoPK.class)
+@NamedQueries( {
+ @NamedQuery(name = BundleVersionRepo.QUERY_FIND_BY_REPO_ID_NO_FETCH, query = "SELECT bvr FROM BundleVersionRepo bvr WHERE bvr.repo.id = :id "),
+ @NamedQuery(name = BundleVersionRepo.QUERY_FIND_BY_BUNDLE_VERSION_ID_NO_FETCH, query = "SELECT bvr FROM BundleVersionRepo bvr WHERE bvr.bundleVersion.id = :id ") })
+@Table(name = "RHQ_BUNDLE_VERSION_REPO")
+public class BundleVersionRepo implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_FIND_BY_REPO_ID_NO_FETCH = "BundleVersionRepo.findByRepoIdNoFetch";
+ public static final String QUERY_FIND_BY_BUNDLE_VERSION_ID_NO_FETCH = "BundleVersionRepo.findByBundleVersionIdNoFetch";
+
+ /*
+ * http://opensource.atlassian.com/projects/hibernate/browse/EJB-286 Hibernate seems to want these mappings in the
+ * @IdClass and ignore these here, even though the mappings should be here and no mappings should be needed in the
+ * @IdClass.
+ */
+ @Id
+ // @ManyToOne
+ // @JoinColumn(name = "BUNDLE_VERSION_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
+ private BundleVersion bundleVersion;
+
+ @Id
+ // @ManyToOne
+ // @JoinColumn(name = "REPO_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
+ private Repo repo;
+
+ protected BundleVersionRepo() {
+ }
+
+ public BundleVersionRepo(BundleVersion bundleVersion, Repo repo) {
+ this.bundleVersion = bundleVersion;
+ this.repo = repo;
+ }
+
+ public BundleVersionRepoPK getBundleVersionRepoPK() {
+ return new BundleVersionRepoPK(bundleVersion, repo);
+ }
+
+ public void setBundleVersionRepoPK(BundleVersionRepoPK pk) {
+ this.bundleVersion = pk.getBundleVersion();
+ this.repo = pk.getRepo();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder str = new StringBuilder("BVR: ");
+ str.append(", bv=[").append(this.bundleVersion).append("]");
+ str.append(", repo=[").append(this.repo).append("]");
+ return str.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 1;
+ result = (31 * result) + ((bundleVersion == null) ? 0 : bundleVersion.hashCode());
+ result = (31 * result) + ((repo == null) ? 0 : repo.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if ((obj == null) || (!(obj instanceof BundleVersionRepo))) {
+ return false;
+ }
+
+ final BundleVersionRepo other = (BundleVersionRepo) obj;
+
+ if (bundleVersion == null) {
+ if (bundleVersion != null) {
+ return false;
+ }
+ } else if (!bundleVersion.equals(other.bundleVersion)) {
+ return false;
+ }
+
+ if (repo == null) {
+ if (repo != null) {
+ return false;
+ }
+ } else if (!repo.equals(other.repo)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersionRepoPK.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersionRepoPK.java
new file mode 100644
index 0000000..ca11031
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersionRepoPK.java
@@ -0,0 +1,122 @@
+/*
+ * 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+
+import org.rhq.core.domain.content.Repo;
+
+/**
+ * This is the composite primary key for the {@link BundleVersionRepo} entity. That entity is an explicit
+ * many-to-many mapping table, so this composite key is simply the foreign keys to both ends of that relationship.
+ *
+ * @author John Mazzitelli
+ */
+public class BundleVersionRepoPK implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /*
+ * http://opensource.atlassian.com/projects/hibernate/browse/EJB-286 Hibernate seems to want these mappings here,
+ * even though this class is an @IdClass and it should not need the mappings here. The mappings belong in the
+ * entity itself.
+ */
+ @JoinColumn(name = "BUNDLE_VERSION_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne
+ // persist so we can add the version as soon as we map it
+ private BundleVersion bundleVersion;
+
+ @JoinColumn(name = "REPO_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne
+ private Repo repo;
+
+ public BundleVersionRepoPK() {
+ }
+
+ public BundleVersionRepoPK(BundleVersion bv, Repo r) {
+ bundleVersion = bv;
+ repo = r;
+ }
+
+ public BundleVersion getBundleVersion() {
+ return bundleVersion;
+ }
+
+ public void setBundleVersion(BundleVersion bv) {
+ this.bundleVersion = bv;
+ }
+
+ public Repo getRepo() {
+ return repo;
+ }
+
+ public void setRepo(Repo repo) {
+ this.repo = repo;
+ }
+
+ @Override
+ public String toString() {
+ return "BundleVersionRepoPK: bundleVersion=[" + bundleVersion + "]; repo=[" + repo + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 1;
+ result = (31 * result) + ((repo == null) ? 0 : repo.hashCode());
+ result = (31 * result) + ((bundleVersion == null) ? 0 : bundleVersion.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if ((obj == null) || (!(obj instanceof BundleVersionRepoPK))) {
+ return false;
+ }
+
+ final BundleVersionRepoPK other = (BundleVersionRepoPK) obj;
+
+ if (repo == null) {
+ if (other.repo != null) {
+ return false;
+ }
+ } else if (!repo.equals(other.repo)) {
+ return false;
+ }
+
+ if (bundleVersion == null) {
+ if (other.bundleVersion != null) {
+ return false;
+ }
+ } else if (!bundleVersion.equals(other.bundleVersion)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
index cff2a27..f4ee5d4 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
@@ -23,6 +23,7 @@
package org.rhq.core.domain.bundle.test;
import java.util.Arrays;
+import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
@@ -32,12 +33,91 @@ import org.testng.annotations.Test;
import org.rhq.core.domain.bundle.Bundle;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.core.domain.bundle.BundleVersionRepo;
+import org.rhq.core.domain.bundle.BundleVersionRepoPK;
import org.rhq.core.domain.content.Distribution;
import org.rhq.core.domain.content.DistributionType;
+import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.test.AbstractEJB3Test;
@Test
public class BundleTest extends AbstractEJB3Test {
+ public void testBundleVersionRepo() throws Throwable {
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ try {
+ int id;
+
+ String name = "BundleTest-testBundleVersionRepo";
+ byte[] action = "action/script/recipe is here".getBytes();
+
+ Repo repo1 = new Repo(name + "-Repo1");
+ Repo repo2 = new Repo(name + "-Repo2");
+ em.persist(repo1);
+ em.persist(repo2);
+ assert repo1.getId() > 0;
+ assert repo2.getId() > 0;
+
+ Query q = em.createNamedQuery(BundleVersionRepo.QUERY_FIND_BY_REPO_ID_NO_FETCH);
+ q.setParameter("id", repo1.getId());
+ assert q.getResultList().size() == 0 : "should not have repo1 mapping in the db yet";
+ q.setParameter("id", repo2.getId());
+ assert q.getResultList().size() == 0 : "should not have repo2 mapping in the db yet";
+
+ BundleType bundleType = new BundleType(name + "-Type");
+ Bundle bundle = new Bundle(name + "-Bundle", bundleType);
+ em.persist(bundle);
+ BundleVersion bundleVersion = new BundleVersion(name, "1.0.0.BETA", bundle);
+ bundleVersion.setAction(action);
+ em.persist(bundleVersion);
+ id = bundleVersion.getId();
+ assert id > 0;
+ assert bundleVersion.getBundle().getId() != 0 : "bundle should have been cascade persisted too";
+ assert bundleVersion.getBundle().getBundleType().getId() != 0 : "bundleType should have been cascade persisted too";
+
+ BundleVersionRepo bvr1 = new BundleVersionRepo(bundleVersion, repo1);
+ BundleVersionRepo bvr2 = new BundleVersionRepo(bundleVersion, repo2);
+ em.persist(bvr1);
+ em.persist(bvr2);
+
+ q = em.createNamedQuery(BundleVersionRepo.QUERY_FIND_BY_REPO_ID_NO_FETCH);
+ q.setParameter("id", repo1.getId());
+ assert q.getResultList().size() == 1;
+ assert ((BundleVersionRepo) q.getSingleResult()).getBundleVersionRepoPK().getBundleVersion().equals(
+ bundleVersion);
+ assert ((BundleVersionRepo) q.getSingleResult()).getBundleVersionRepoPK().getRepo().equals(repo1);
+
+ q.setParameter("id", repo2.getId());
+ assert q.getResultList().size() == 1;
+ assert ((BundleVersionRepo) q.getSingleResult()).getBundleVersionRepoPK().getBundleVersion().equals(
+ bundleVersion);
+ assert ((BundleVersionRepo) q.getSingleResult()).getBundleVersionRepoPK().getRepo().equals(repo2);
+
+ q = em.createNamedQuery(BundleVersionRepo.QUERY_FIND_BY_BUNDLE_VERSION_ID_NO_FETCH);
+ q.setParameter("id", bundleVersion.getId());
+ List<BundleVersionRepo> resultList = q.getResultList();
+ assert resultList.size() == 2;
+ BundleVersionRepoPK pk1 = new BundleVersionRepoPK(bundleVersion, repo1);
+ BundleVersionRepoPK pk2 = new BundleVersionRepoPK(bundleVersion, repo2);
+ if (resultList.get(0).getBundleVersionRepoPK().getRepo().equals(repo1)) {
+ assert bvr1.equals(resultList.get(0));
+ assert bvr2.equals(resultList.get(1));
+ assert pk1.equals(resultList.get(0).getBundleVersionRepoPK());
+ assert pk2.equals(resultList.get(1).getBundleVersionRepoPK());
+ } else {
+ assert bvr1.equals(resultList.get(1));
+ assert bvr2.equals(resultList.get(0));
+ assert pk1.equals(resultList.get(1).getBundleVersionRepoPK());
+ assert pk2.equals(resultList.get(0).getBundleVersionRepoPK());
+ }
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw t;
+ } finally {
+ getTransactionManager().rollback();
+ }
+ }
+
public void testBundleVersion() throws Throwable {
boolean done = false;
getTransactionManager().begin();
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
index 07dd5a6..28d1994 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
@@ -55,6 +55,7 @@ import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.bundle.Bundle;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.core.domain.bundle.BundleVersionRepo;
import org.rhq.core.domain.cloud.Server;
import org.rhq.core.domain.common.SystemConfiguration;
import org.rhq.core.domain.content.Architecture;
@@ -152,6 +153,7 @@ public class QueryAllTest extends AbstractEJB3Test {
// bundle stuff
BundleType.class.getSimpleName(), Bundle.class.getSimpleName(), BundleVersion.class.getSimpleName(),
+ BundleVersionRepo.class.getSimpleName(),
// group stuff
GroupDefinition.class.getSimpleName(), ResourceGroup.class.getSimpleName(),
commit eab83513506c54961a77d8d208d4381a6b89c581
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 27 01:57:00 2010 -0500
start of the bundle domain objects along with unit tests
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
index 46d3822..d558c09 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -505,6 +505,7 @@
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="NAME" size="200" type="VARCHAR2" required="true"/>
<column name="VERSION" size="500" type="VARCHAR2" required="true"/>
+ <column name="ACTION" type="BLOB" required="true"/>
<column name="BUNDLE_ID" type="INTEGER" required="true" references="RHQ_BUNDLE"/>
<column name="DISTRIBUTION_ID" type="INTEGER" required="false" references="RHQ_DISTRIBUTION"/>
</table>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 75abe81..6da02b6 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2826,6 +2826,8 @@
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="NAME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="VERSION" columnType="VARCHAR2" precision="500" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="VERSION" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="ACTION" columnType="BLOB" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="ACTION" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" nullable="FALSE" />
<schema-directSQL>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
new file mode 100644
index 0000000..8faec6c
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
@@ -0,0 +1,150 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+/**
+ * Defines a bundle of content that can be versioned.
+ *
+ * @author John Mazzitelli
+ */
+@Entity
+@NamedQueries( { @NamedQuery(name = Bundle.QUERY_FIND_ALL, query = "SELECT b FROM Bundle b"), //
+ @NamedQuery(name = Bundle.QUERY_FIND_BY_NAME, query = "SELECT b FROM Bundle b WHERE b.name = :name") //
+})
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_BUNDLE_ID_SEQ")
+@Table(name = "RHQ_BUNDLE")
+(a)XmlAccessorType(XmlAccessType.FIELD)
+public class Bundle implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_FIND_ALL = "Bundle.findAll";
+ public static final String QUERY_FIND_BY_NAME = "Bundle.findByName";
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
+ @Id
+ private int id;
+
+ @Column(name = "NAME", nullable = false)
+ private String name;
+
+ @JoinColumn(name = "BUNDLE_TYPE_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST)
+ private BundleType bundleType;
+
+ public Bundle() {
+ // for JPA use
+ }
+
+ public Bundle(String name, BundleType type) {
+ setName(name);
+ setBundleType(type);
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public BundleType getBundleType() {
+ return bundleType;
+ }
+
+ public void setBundleType(BundleType bundleType) {
+ this.bundleType = bundleType;
+ }
+
+ @Override
+ public String toString() {
+ return "Bundle[id=" + id + ",name=" + name + ",bundleType=" + bundleType + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = (prime * result) + ((name == null) ? 0 : name.hashCode());
+ result = (prime * result) + ((bundleType == null) ? 0 : bundleType.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (!(obj instanceof Bundle)) {
+ return false;
+ }
+
+ final Bundle other = (Bundle) obj;
+
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+
+ if (bundleType == null) {
+ if (other.bundleType != null) {
+ return false;
+ }
+ } else if (!bundleType.equals(other.bundleType)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleType.java
new file mode 100644
index 0000000..6433df4
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleType.java
@@ -0,0 +1,125 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+/**
+ * Defines a type of bundle that can exist in the system. Bundle types are used to determine
+ * how a bundle is to be processed.
+ *
+ * @author John Mazzitelli
+ */
+@Entity
+@NamedQueries( { @NamedQuery(name = BundleType.QUERY_FIND_ALL, query = "SELECT bt FROM BundleType bt"), //
+ @NamedQuery(name = BundleType.QUERY_FIND_BY_NAME, query = "SELECT bt FROM BundleType bt WHERE bt.name = :name") //
+})
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_BUNDLE_TYPE_ID_SEQ")
+@Table(name = "RHQ_BUNDLE_TYPE")
+(a)XmlAccessorType(XmlAccessType.FIELD)
+public class BundleType implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_FIND_ALL = "BundleType.findAll";
+ public static final String QUERY_FIND_BY_NAME = "BundleType.findByName";
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
+ @Id
+ private int id;
+
+ @Column(name = "NAME", nullable = false)
+ private String name;
+
+ public BundleType() {
+ // for JPA use
+ }
+
+ public BundleType(String name) {
+ setName(name);
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return "BundleType[id=" + id + ",name=" + name + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = (prime * result) + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (!(obj instanceof BundleType)) {
+ return false;
+ }
+
+ final BundleType other = (BundleType) obj;
+
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
new file mode 100644
index 0000000..a4c4d31
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
@@ -0,0 +1,195 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+import org.rhq.core.domain.content.Distribution;
+
+/**
+ * Defines a versioned bundle of content that can be provisioned somewhere.
+ *
+ * @author John Mazzitelli
+ */
+@Entity
+@NamedQueries( {
+ @NamedQuery(name = BundleVersion.QUERY_FIND_ALL, query = "SELECT bv FROM BundleVersion bv"), //
+ @NamedQuery(name = BundleVersion.QUERY_FIND_BY_NAME, query = "SELECT bv FROM BundleVersion bv WHERE bv.name = :name") //
+})
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_BUNDLE_VERSION_ID_SEQ")
+@Table(name = "RHQ_BUNDLE_VERSION")
+(a)XmlAccessorType(XmlAccessType.FIELD)
+public class BundleVersion implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_FIND_ALL = "BundleVersion.findAll";
+ public static final String QUERY_FIND_BY_NAME = "BundleVersion.findByName";
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
+ @Id
+ private int id;
+
+ @Column(name = "NAME", nullable = false)
+ private String name;
+
+ @Column(name = "VERSION", nullable = false)
+ private String version;
+
+ @Column(name = "ACTION", nullable = false)
+ private byte[] action;
+
+ @JoinColumn(name = "BUNDLE_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne(fetch = FetchType.LAZY)
+ private Bundle bundle;
+
+ @JoinColumn(name = "DISTRIBUTION_ID", referencedColumnName = "ID", nullable = true)
+ @ManyToOne(fetch = FetchType.LAZY)
+ private Distribution distribution;
+
+ public BundleVersion() {
+ // for JPA use
+ }
+
+ public BundleVersion(String name, String version, Bundle bundle) {
+ setName(name);
+ setVersion(version);
+ setBundle(bundle);
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public byte[] getAction() {
+ return action;
+ }
+
+ public void setAction(byte[] action) {
+ this.action = action;
+ }
+
+ public Bundle getBundle() {
+ return bundle;
+ }
+
+ public void setBundle(Bundle bundle) {
+ this.bundle = bundle;
+ }
+
+ public Distribution getDistribution() {
+ return distribution;
+ }
+
+ public void setDistribution(Distribution distribution) {
+ this.distribution = distribution;
+ }
+
+ @Override
+ public String toString() {
+ return "BundleVersion[id=" + id + ",name=" + name + ",version=" + version + ",bundle=" + bundle + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((version == null) ? 0 : version.hashCode());
+ result = prime * result + ((bundle == null) ? 0 : bundle.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof BundleVersion)) {
+ return false;
+ }
+
+ BundleVersion other = (BundleVersion) obj;
+
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+
+ if (version == null) {
+ if (other.version != null) {
+ return false;
+ }
+ } else if (!version.equals(other.version)) {
+ return false;
+ }
+
+ if (bundle == null) {
+ if (other.bundle != null) {
+ return false;
+ }
+ } else if (!bundle.equals(other.bundle)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
new file mode 100644
index 0000000..cff2a27
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
@@ -0,0 +1,266 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.domain.bundle.test;
+
+import java.util.Arrays;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.bundle.Bundle;
+import org.rhq.core.domain.bundle.BundleType;
+import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.core.domain.content.Distribution;
+import org.rhq.core.domain.content.DistributionType;
+import org.rhq.core.domain.test.AbstractEJB3Test;
+
+@Test
+public class BundleTest extends AbstractEJB3Test {
+ public void testBundleVersion() throws Throwable {
+ boolean done = false;
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ try {
+ int id;
+
+ String name = "BundleTest-testBundleVersion";
+ byte[] action = "action/script/recipe is here".getBytes();
+
+ BundleType bundleType = new BundleType(name + "-Type");
+ Bundle bundle = new Bundle(name + "-Bundle", bundleType);
+ em.persist(bundle);
+ id = bundle.getId();
+ assert id > 0;
+ assert bundle.getBundleType().getId() != 0 : "bundleType should have been cascade persisted too";
+
+ BundleVersion bv = new BundleVersion(name, "1.0.0.BETA", bundle);
+ bv.setAction(action);
+ Query q = em.createNamedQuery(BundleVersion.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bv.getName());
+ assert q.getResultList().size() == 0; // not in the db yet
+
+ em.persist(bv);
+ id = bv.getId();
+ assert id > 0;
+
+ q = em.createNamedQuery(BundleVersion.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bv.getName());
+ assert q.getResultList().size() == 1;
+ assert ((BundleVersion) q.getSingleResult()).getName().equals(bv.getName());
+
+ BundleVersion bvFind = em.find(BundleVersion.class, id);
+ assert bvFind != null;
+ assert bvFind.getId() == bv.getId();
+ assert bvFind.getName().equals(bv.getName());
+ assert bvFind.getVersion().equals(bv.getVersion());
+ assert Arrays.equals(bvFind.getAction(), bv.getAction());
+ assert bvFind.getBundle().equals(bv.getBundle());
+ assert bvFind.equals(bv);
+ assert bvFind.hashCode() == bv.hashCode();
+ assert bvFind.getDistribution() == null;
+
+ // update it with a distro, then null out the distro, checking along the way
+ DistributionType distroType = new DistributionType(name + "-DistroType");
+ Distribution distro = new Distribution(name + "-Distro", "basepathIn", distroType);
+ em.persist(distro);
+ assert distro.getId() > 0;
+ assert distro.getDistributionType().getId() > 0;
+ bvFind.setDistribution(distro);
+ em.flush();
+ bvFind = em.find(BundleVersion.class, id);
+ assert bvFind.getDistribution().equals(distro);
+ bvFind.setDistribution(null);
+ em.flush();
+ bvFind = em.find(BundleVersion.class, id);
+ assert bvFind.getDistribution() == null;
+ em.remove(distro);
+ em.remove(distroType);
+
+ // clean up - delete our test entity
+ em.close();
+ getTransactionManager().commit();
+ getTransactionManager().begin();
+ em = getEntityManager();
+ q = em.createNamedQuery(BundleVersion.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bv.getName());
+ BundleVersion doomed = (BundleVersion) q.getSingleResult();
+ doomed = em.getReference(BundleVersion.class, doomed.getId());
+ em.remove(doomed);
+ assert q.getResultList().size() == 0 : "didn't remove the entity";
+ em.close();
+ getTransactionManager().commit();
+
+ // make sure we didn't delete the bundle - it should not be cascade deleted
+ getTransactionManager().begin();
+ em = getEntityManager();
+ q = em.createNamedQuery(Bundle.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bundle.getName());
+ assert q.getResultList().size() == 1;
+ bundle = (Bundle) q.getSingleResult();
+ bundleType = bundle.getBundleType();
+ em.remove(bundle);
+ em.remove(bundleType);
+ assert q.getResultList().size() == 0 : "didn't clean up test bundle";
+ assert em.find(BundleType.class, bundleType.getId()) == null : "didn't clean up bundle type";
+ em.close();
+ getTransactionManager().commit();
+
+ done = true;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw t;
+ } finally {
+ if (!done) {
+ getTransactionManager().rollback();
+ }
+ }
+ }
+
+ public void testBundle() throws Throwable {
+ boolean done = false;
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ try {
+ int id;
+
+ String name = "BundleTest-testBundle";
+
+ BundleType bundleType = new BundleType(name + "-Type");
+ Bundle b = new Bundle(name, bundleType);
+
+ Query q = em.createNamedQuery(Bundle.QUERY_FIND_BY_NAME);
+ q.setParameter("name", b.getName());
+ assert q.getResultList().size() == 0; // not in the db yet
+
+ em.persist(b);
+ id = b.getId();
+ assert id > 0;
+ assert b.getBundleType().getId() != 0 : "bundleType should have been cascade persisted too";
+
+ q = em.createNamedQuery(Bundle.QUERY_FIND_BY_NAME);
+ q.setParameter("name", b.getName());
+ assert q.getResultList().size() == 1;
+ assert ((Bundle) q.getSingleResult()).getName().equals(b.getName());
+
+ Bundle bFind = em.find(Bundle.class, id);
+ assert bFind != null;
+ assert bFind.getId() == b.getId();
+ assert bFind.getName().equals(b.getName());
+ assert bFind.getBundleType().equals(b.getBundleType());
+ assert bFind.equals(b);
+ assert bFind.hashCode() == b.hashCode();
+
+ // clean up - delete our test entity
+ em.close();
+ getTransactionManager().commit();
+ getTransactionManager().begin();
+ em = getEntityManager();
+ q = em.createNamedQuery(Bundle.QUERY_FIND_BY_NAME);
+ q.setParameter("name", b.getName());
+ Bundle doomed = (Bundle) q.getSingleResult();
+ doomed = em.getReference(Bundle.class, doomed.getId());
+ em.remove(doomed);
+ assert q.getResultList().size() == 0 : "didn't remove the entity";
+ em.close();
+ getTransactionManager().commit();
+
+ // make sure we didn't delete the bundle type - it should not be cascade deleted
+ getTransactionManager().begin();
+ em = getEntityManager();
+ q = em.createNamedQuery(BundleType.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bFind.getBundleType().getName());
+ assert q.getResultList().size() == 1;
+ BundleType bt = (BundleType) q.getSingleResult();
+ em.remove(bt);
+ assert q.getResultList().size() == 0 : "didn't clean up test bundle type";
+ em.close();
+ getTransactionManager().commit();
+
+ done = true;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw t;
+ } finally {
+ if (!done) {
+ getTransactionManager().rollback();
+ }
+ }
+ }
+
+ public void testBundleType() throws Throwable {
+ boolean done = false;
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ try {
+ int id;
+
+ String name = "BundleTest-testBundleType";
+
+ BundleType bt = new BundleType(name);
+
+ Query q = em.createNamedQuery(BundleType.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bt.getName());
+ assert q.getResultList().size() == 0; // not in the db yet
+
+ em.persist(bt);
+ id = bt.getId();
+ assert id > 0;
+
+ q = em.createNamedQuery(BundleType.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bt.getName());
+ assert q.getResultList().size() == 1;
+ assert ((BundleType) q.getSingleResult()).getName().equals(bt.getName());
+
+ BundleType btFind = em.find(BundleType.class, id);
+ assert btFind != null;
+ assert btFind.getId() == bt.getId();
+ assert btFind.getName().equals(bt.getName());
+ assert btFind.equals(bt);
+ assert btFind.hashCode() == bt.hashCode();
+
+ // clean up - delete our test entity
+ em.close();
+ getTransactionManager().commit();
+ getTransactionManager().begin();
+ em = getEntityManager();
+ q = em.createNamedQuery(BundleType.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bt.getName());
+ BundleType doomed = (BundleType) q.getSingleResult();
+ doomed = em.getReference(BundleType.class, doomed.getId());
+ em.remove(doomed);
+ assert q.getResultList().size() == 0 : "didn't remove the entity";
+ em.close();
+ getTransactionManager().commit();
+ done = true;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw t;
+ } finally {
+ if (!done) {
+ getTransactionManager().rollback();
+ }
+ }
+ }
+}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
index e559830..07dd5a6 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
@@ -52,6 +52,9 @@ import org.rhq.core.domain.alert.notification.SubjectNotification;
import org.rhq.core.domain.auth.Principal;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.bundle.Bundle;
+import org.rhq.core.domain.bundle.BundleType;
+import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.cloud.Server;
import org.rhq.core.domain.common.SystemConfiguration;
import org.rhq.core.domain.content.Architecture;
@@ -147,6 +150,9 @@ public class QueryAllTest extends AbstractEJB3Test {
PackageVersion.class.getSimpleName(), PackageVersionContentSource.class.getSimpleName(),
ContentSourceSyncResults.class.getSimpleName(),
+ // bundle stuff
+ BundleType.class.getSimpleName(), Bundle.class.getSimpleName(), BundleVersion.class.getSimpleName(),
+
// group stuff
GroupDefinition.class.getSimpleName(), ResourceGroup.class.getSimpleName(),
commit 87fec52f40bb2c586cb1a17722292c15266f5350
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jan 26 23:49:40 2010 -0500
add bundle schema to db setup/upgrade scripts
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 256f287..fd906cf 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.76</db.schema.version>
+ <db.schema.version>2.76.1</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
index 261ac25..46d3822 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -487,6 +487,71 @@
</constraint>
</table>
+ <!-- BUNDLE_TYPE is things like "Cobbler profile" or "file-based bundle" or "puppet recipe" -->
+ <table name="RHQ_BUNDLE_TYPE">
+ <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
+ <column name="NAME" size="200" type="VARCHAR2" required="true"/>
+ </table>
+
+ <!-- BUNDLE is a named piece of content that can be versioned and installed somewhere -->
+ <table name="RHQ_BUNDLE">
+ <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
+ <column name="NAME" size="200" type="VARCHAR2" required="true"/>
+ <column name="BUNDLE_TYPE_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_TYPE"/>
+ </table>
+
+ <!-- BUNDLE_VERSION represents an actual piece of content that needs to be installed somewhere -->
+ <table name="RHQ_BUNDLE_VERSION">
+ <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
+ <column name="NAME" size="200" type="VARCHAR2" required="true"/>
+ <column name="VERSION" size="500" type="VARCHAR2" required="true"/>
+ <column name="BUNDLE_ID" type="INTEGER" required="true" references="RHQ_BUNDLE"/>
+ <column name="DISTRIBUTION_ID" type="INTEGER" required="false" references="RHQ_DISTRIBUTION"/>
+ </table>
+
+ <!-- Many-to-many table that links many repos to a particular bundle version -->
+ <table name="RHQ_BUNDLE_VERSION_REPO">
+ <column name="BUNDLE_VERSION_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_VERSION"/>
+ <column name="REPO_ID" type="INTEGER" required="true" references="RHQ_REPO"/>
+
+ <constraint name="RHQ_BUNDLE_VERSION_REPO_KEY">
+ <primaryKey>
+ <field ref="BUNDLE_VERSION_ID"/>
+ <field ref="REPO_ID"/>
+ </primaryKey>
+ </constraint>
+ </table>
+
+ <!-- BUNDLE_FILE represents a file that is associated with (possibly bundled inside) a bundle version -->
+ <table name="RHQ_BUNDLE_FILE">
+ <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
+ <column name="BUNDLE_VERSION_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_VERSION"/>
+ <!-- this probably needs a DTYPE discriminator so we know if its a package or a specific package version -->
+ <column name="PACKAGE_VERSION_ID" type="INTEGER" required="false" references="RHQ_PACKAGE_VERSION"/>
+ <column name="PACKAGE_ID" type="INTEGER" required="false" references="RHQ_PACKAGE"/>
+ </table>
+
+ <!-- A set of configuration values that are used to customize how/where a bundle version is installed -->
+ <table name="RHQ_BUNDLE_CONFIG">
+ <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
+ <column name="CONFIG_ID" type="INTEGER" required="false" references="RHQ_CONFIG" />
+ <!-- this probably needs a DTYPE discriminator so we know if its a bundle or a specific bundle version -->
+ <column name="BUNDLE_VERSION_ID" type="INTEGER" required="false" references="RHQ_BUNDLE_VERSION"/>
+ <column name="BUNDLE_ID" type="INTEGER" required="false" references="RHQ_BUNDLE"/>
+ </table>
+
+ <!-- Represents a bundle version that is deployed on a resource -->
+ <table name="RHQ_BUNDLE_DEPLOYMENT">
+ <column name="BUNDLE_CONFIG_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_CONFIG"/>
+ <column name="RESOURCE_ID" type="INTEGER" required="true" references="RHQ_RESOURCE" />
+
+ <constraint name="RHQ_BUNDLE_DEPLOYMENT_KEY">
+ <primaryKey>
+ <field ref="BUNDLE_CONFIG_ID"/>
+ <field ref="RESOURCE_ID"/>
+ </primaryKey>
+ </constraint>
+ </table>
</dbsetup>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 144c793..75abe81 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2766,6 +2766,232 @@
<schema-addColumn table="RHQ_CONFIG_PROP_DEF" column="DYNAMIC_KEY" columnType="VARCHAR2" precision="128" />
</schemaSpec>
+ <schemaSpec version="2.76.1">
+ <!-- RHQ_BUNDLE_TYPE -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_TYPE">
+ CREATE TABLE RHQ_BUNDLE_TYPE ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_TYPE" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_TYPE_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_TYPE">
+ ALTER TABLE RHQ_BUNDLE_TYPE ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_TYPE" column="NAME" columnType="VARCHAR2" precision="200" />
+ <schema-alterColumn table="RHQ_BUNDLE_TYPE" column="NAME" nullable="FALSE" />
+
+ <!-- RHQ_BUNDLE -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE">
+ CREATE TABLE RHQ_BUNDLE ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE">
+ ALTER TABLE RHQ_BUNDLE ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE" column="NAME" columnType="VARCHAR2" precision="200" />
+ <schema-alterColumn table="RHQ_BUNDLE" column="NAME" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE" column="BUNDLE_TYPE_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE" column="BUNDLE_TYPE_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE foreign key relation to RHQ_BUNDLE_TYPE">
+ ALTER TABLE RHQ_BUNDLE
+ ADD CONSTRAINT RHQ_BUNDLE_TYPE_ID_FK
+ FOREIGN KEY (BUNDLE_TYPE_ID)
+ REFERENCES RHQ_BUNDLE_TYPE (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_VERSION -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_VERSION">
+ CREATE TABLE RHQ_BUNDLE_VERSION ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_VERSION_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_VERSION ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="NAME" columnType="VARCHAR2" precision="200" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="NAME" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="VERSION" columnType="VARCHAR2" precision="500" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="VERSION" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION foreign key relation to RHQ_BUNDLE">
+ ALTER TABLE RHQ_BUNDLE_VERSION
+ ADD CONSTRAINT RHQ_BUNDLE_ID_FK
+ FOREIGN KEY (BUNDLE_ID)
+ REFERENCES RHQ_BUNDLE (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="DISTRIBUTION_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION foreign key relation to RHQ_DISTRIBUTION">
+ ALTER TABLE RHQ_BUNDLE_VERSION
+ ADD CONSTRAINT RHQ_DISTRIBUTION_ID_FK
+ FOREIGN KEY (DISTRIBUTION_ID)
+ REFERENCES RHQ_DISTRIBUTION (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_VERSION_REPO -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_VERSION_REPO">
+ CREATE TABLE RHQ_BUNDLE_VERSION_REPO ( BUNDLE_VERSION_ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION_REPO" column="BUNDLE_VERSION_ID" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION_REPO" column="REPO_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION_REPO" column="REPO_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_VERSION_REPO">
+ ALTER TABLE RHQ_BUNDLE_VERSION_REPO ADD PRIMARY KEY ( BUNDLE_VERSION_ID, REPO_ID )
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION_REPO foreign key relation to RHQ_BUNDLE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_VERSION_REPO
+ ADD CONSTRAINT RHQ_BUNDLE_VERSION_ID_FK
+ FOREIGN KEY (BUNDLE_VERSION_ID)
+ REFERENCES RHQ_BUNDLE_VERSION (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION_REPO foreign key relation to RHQ_REPO">
+ ALTER TABLE RHQ_BUNDLE_VERSION_REPO
+ ADD CONSTRAINT RHQ_REPO_ID_FK
+ FOREIGN KEY (REPO_ID)
+ REFERENCES RHQ_REPO (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_FILE -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_FILE">
+ CREATE TABLE RHQ_BUNDLE_FILE ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_FILE" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_FILE_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_FILE">
+ ALTER TABLE RHQ_BUNDLE_FILE ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_FILE" column="BUNDLE_VERSION_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_FILE" column="BUNDLE_VERSION_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_BUNDLE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_FILE
+ ADD CONSTRAINT RHQ_BUNDLE_VERSION_ID_FK
+ FOREIGN KEY (BUNDLE_VERSION_ID)
+ REFERENCES RHQ_BUNDLE_VERSION (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_FILE" column="PACKAGE_VERSION_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_PACKAGE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_FILE
+ ADD CONSTRAINT RHQ_PACKAGE_VERSION_ID_FK
+ FOREIGN KEY (PACKAGE_VERSION_ID)
+ REFERENCES RHQ_PACKAGE_VERSION (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_FILE" column="PACKAGE_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_PACKAGE">
+ ALTER TABLE RHQ_BUNDLE_FILE
+ ADD CONSTRAINT RHQ_PACKAGE_ID_FK
+ FOREIGN KEY (PACKAGE_ID)
+ REFERENCES RHQ_PACKAGE (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_CONFIG -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_CONFIG">
+ CREATE TABLE RHQ_BUNDLE_CONFIG ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_CONFIG" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_CONFIG_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_CONFIG">
+ ALTER TABLE RHQ_BUNDLE_CONFIG ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_CONFIG" column="CONFIG_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_CONFIG foreign key relation to RHQ_CONFIG">
+ ALTER TABLE RHQ_BUNDLE_CONFIG
+ ADD CONSTRAINT RHQ_CONFIG_ID_FK
+ FOREIGN KEY (CONFIG_ID)
+ REFERENCES RHQ_CONFIG (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_CONFIG" column="BUNDLE_VERSION_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_CONFIG foreign key relation to RHQ_BUNDLE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_CONFIG
+ ADD CONSTRAINT RHQ_BUNDLE_VERSION_ID_FK
+ FOREIGN KEY (BUNDLE_VERSION_ID)
+ REFERENCES RHQ_BUNDLE_VERSION (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_CONFIG" column="BUNDLE_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_CONFIG foreign key relation to RHQ_BUNDLE">
+ ALTER TABLE RHQ_BUNDLE_CONFIG
+ ADD CONSTRAINT RHQ_BUNDLE_ID_FK
+ FOREIGN KEY (BUNDLE_ID)
+ REFERENCES RHQ_BUNDLE (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_DEPLOYMENT -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_DEPLOYMENT">
+ CREATE TABLE RHQ_BUNDLE_DEPLOYMENT ( BUNDLE_CONFIG_ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_DEPLOYMENT" column="BUNDLE_CONFIG_ID" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_DEPLOYMENT" column="RESOURCE_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_DEPLOYMENT" column="RESOURCE_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_DEPLOYMENT">
+ ALTER TABLE RHQ_BUNDLE_DEPLOYMENT ADD PRIMARY KEY ( BUNDLE_CONFIG_ID, RESOURCE_ID )
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_DEPLOYMENT foreign key relation to RHQ_BUNDLE_CONFIG">
+ ALTER TABLE RHQ_BUNDLE_DEPLOYMENT
+ ADD CONSTRAINT RHQ_BUNDLE_CONFIG_ID_FK
+ FOREIGN KEY (BUNDLE_CONFIG_ID)
+ REFERENCES RHQ_BUNDLE_CONFIG (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_DEPLOYMENT foreign key relation to RHQ_RESOURCE">
+ ALTER TABLE RHQ_BUNDLE_DEPLOYMENT
+ ADD CONSTRAINT RHQ_RESOURCE_ID_FK
+ FOREIGN KEY (RESOURCE_ID)
+ REFERENCES RHQ_RESOURCE (ID)
+ </statement>
+ </schema-directSQL>
+
+ </schemaSpec>
</dbupgrade>
</target>
</project>
commit 52e5199beafae566462444a61033503a5a9a839a
Author: Justin Harris <jharris(a)redhat.com>
Date: Tue Jan 26 16:05:41 2010 -0500
Making lots of small cosmetic changes to the alert definition page.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml
index 2c9edb9..cd9e56c 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml
@@ -42,12 +42,14 @@
ignoreDupResponses="true"
requestDelay="25"
reRender="alertConfig,senderName"
- oncomplete="updateCustomContent();" />
+ oncomplete="updateCustomContent();"
+ onsubmit="showLoadConfig();" />
<a4j:support event="onkeyup"
ignoreDupResponses="true"
requestDelay="150"
reRender="alertConfig,senderName"
- oncomplete="updateCustomContent();" />
+ oncomplete="updateCustomContent();"
+ onsubmit="showLoadConfig();" />
<a4j:support event="onorderchanged"
ignoreDupResponses="true"
requestDelay="250"
@@ -78,6 +80,12 @@
</h:panelGroup>
<h:panelGroup>
+ <div id="configLoader" style="display: none; margin: auto;">
+ <strong><h:outputText value="Loading Configuration..." /></strong>
+ <br /><br />
+ <img src="/images/ajax-loader.gif" alt="Loading Configuration..." />
+ </div>
+
<h:form id="alertConfig">
<input type="hidden" name="id" value="${param.id}"/>
<input type="hidden" name="ad" value="${param.ad}"/>
@@ -108,77 +116,81 @@
</rich:panel>
<rich:modalPanel id="addAlertPanel" moveable="false" autosized="true">
- <f:facet name="header">
- <h:outputText value="Add Alert Notification" />
- </f:facet>
- <h:form id="newNotificationForm">
- <input type="hidden" name="id" value="${param.id}"/>
- <input type="hidden" name="ad" value="${param.ad}"/>
-
- <h:outputLabel for="alertNameInput" value="Alert Notification Name:" />
- <br />
- <h:inputText id="alertNameInput"
- value="#{alertNotificationsUIBean.newAlertName}"
- maxlength="100"
- required="true" />
-
- <h:message for="alertNameInput"
- infoClass="InfoBlock"
- warnClass="WarnBlock"
- errorClass="ErrorBlock"
- fatalClass="FatalBlock" />
- <br /><br />
-
- <h:outputLabel for="senderList" value="Alert Sender Type:" />
- <br />
- <h:selectOneMenu id="senderList" value="#{alertNotificationsUIBean.selectedNewSender}">
- <f:selectItems value="#{alertNotificationsUIBean.allAlertSenders}" />
- </h:selectOneMenu>
- <br /><br />
-
- <h:commandButton id="addAlertButton"
- value="Add Alert Notification"
- action="#{alertNotificationsUIBean.addAlertSender}"
- styleClass="buttonmed">
- </h:commandButton>
-
- <br /><br />
- <h:outputLink id="notificationCancelLink" styleClass="buttonmed" value="#">
- <h:outputText value="Cancel" />
- <rich:componentControl for="addAlertPanel" attachTo="notificationCancelLink" operation="hide" event="onclick" />
- </h:outputLink>
- </h:form>
- </rich:modalPanel>
+ <h:panelGrid columns="2" width="100%" columnClasses="col1,col2">
+ <rich:panel id="addNewAlertPanel">
+ <f:facet name="header">
+ <h:outputText value="Add New Alert Notifications"/>
+ </f:facet>
- <rich:panel id="addAlertFromTemplatePanel">
- <f:facet name="header">
- <h:outputText value="Add Alert Notifications from template"/>
- </f:facet>
+ <h:form id="newNotificationForm">
+ <input type="hidden" name="id" value="${param.id}"/>
+ <input type="hidden" name="ad" value="${param.ad}"/>
- <h:form id="newNotificationsFromTemplateForm">
- <input type="hidden" name="id" value="${param.id}"/>
- <input type="hidden" name="ad" value="${param.ad}"/>
+ <div style="height: 100px;">
+ <h:outputLabel for="alertNameInput" value="Alert Notification Name:" />
+ <br />
+ <h:inputText id="alertNameInput"
+ value="#{alertNotificationsUIBean.newAlertName}"
+ maxlength="100"
+ required="true" />
+
+ <h:message for="alertNameInput"
+ infoClass="InfoBlock"
+ warnClass="WarnBlock"
+ errorClass="ErrorBlock"
+ fatalClass="FatalBlock" />
+ <br /><br />
+
+ <h:outputLabel for="senderList" value="Alert Sender Type:" />
+ <br />
+ <h:selectOneMenu id="senderList" value="#{alertNotificationsUIBean.selectedNewSender}">
+ <f:selectItems value="#{alertNotificationsUIBean.allAlertSenders}" />
+ </h:selectOneMenu>
+ </div>
+
+ <h:commandButton id="addAlertButton"
+ value="Add Alert Notification"
+ action="#{alertNotificationsUIBean.addAlertSender}"
+ styleClass="buttonmed">
+ </h:commandButton>
+ </h:form>
+ </rich:panel>
- <h:selectOneMenu id="templateList" value="#{alertNotificationsUIBean.selectedTemplate}">
- <f:selectItems value="#{alertNotificationsUIBean.allNotificationTemplates}"/>
- </h:selectOneMenu>
+ <rich:panel id="addAlertFromTemplatePanel">
+ <f:facet name="header">
+ <h:outputText value="Add Alert Notifications from template"/>
+ </f:facet>
+ <h:form id="newNotificationsFromTemplateForm">
+ <input type="hidden" name="id" value="${param.id}"/>
+ <input type="hidden" name="ad" value="${param.ad}"/>
- <br/>
+ <div style="height: 100px;">
+ <h:selectOneMenu id="templateList" value="#{alertNotificationsUIBean.selectedTemplate}">
+ <f:selectItems value="#{alertNotificationsUIBean.allNotificationTemplates}"/>
+ </h:selectOneMenu>
- <h:selectBooleanCheckbox title="clearExisting" value="#{alertNotificationsUIBean.clearExistingNotifications}"/>
- <h:outputText value="Clear existing notifications"/>
+ <br/>
- <br /><br />
+ <h:selectBooleanCheckbox title="clearExisting" value="#{alertNotificationsUIBean.clearExistingNotifications}"/>
+ <h:outputText value="Clear existing notifications"/>
+ </div>
- <h:commandButton id="addTemplateButton"
- value="Add Alert Notification from Template"
- action="#{alertNotificationsUIBean.addAlertSenderFromTemplate}"
- styleClass="buttonmed">
- </h:commandButton>
- </h:form>
+ <h:commandButton id="addTemplateButton"
+ value="Add Alert Notification from Template"
+ action="#{alertNotificationsUIBean.addAlertSenderFromTemplate}"
+ styleClass="buttonmed"
+ style="margin-top: auto;">
+ </h:commandButton>
+ </h:form>
+ </rich:panel>
+ </h:panelGrid>
- </rich:panel>
+ <h:outputLink id="notificationCancelLink" styleClass="buttonmed" value="#" style="float: right;">
+ <h:outputText value="Cancel" />
+ <rich:componentControl for="addAlertPanel" attachTo="notificationCancelLink" operation="hide" event="onclick" />
+ </h:outputLink>
+ </rich:modalPanel>
<br />
<br />
@@ -189,16 +201,28 @@
- <script>
+ <script type="text/javascript">
function updateCustomContent() {
var sender = $('senderName').innerHTML;
new Ajax.Updater('customContentArea',
'notif/customContent.xhtml',
{ method: 'get',
- parameters: {'senderName': sender,
- 'ad': #{param.ad},
- 'id': #{param.id}}
+ parameters: {'senderName': sender, 'ad': #{param.ad}, 'id': #{param.id}}
});
+
+ hideLoadConfig();
+ }
+
+ function showLoadConfig() {
+ $('alertConfig').hide();
+ $('customContentArea').hide();
+ $('configLoader').show();
+ }
+
+ function hideLoadConfig() {
+ $('configLoader').hide();
+ $('alertConfig').show();
+ $('customContentArea').show();
}
Event.observe(window, 'load', function() {
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml
index 5b3e6d4..8716d01 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml
@@ -164,12 +164,12 @@
<input type="hidden" name="ad" value="#{param.ad}" />
<input type="hidden" name="id" value="#{param.id}" />
- <h:panelGrid columns="2" border="1" cellpadding="5">
+ <h:panelGrid columns="2" border="1" cellpadding="5" style="margin: 15px;">
<h:outputLabel for="alertNameInput" value="Name: " />
- <h:inputText id="alertNameInput" value="#{alertUIBean.alertDefinition.name}" />
+ <h:inputText id="alertNameInput" value="#{alertUIBean.alertDefinition.name}" style="width: 300px;" />
<h:outputLabel for="alertDescriptionInput" value="Description: " />
- <h:inputTextarea id="alertDescriptionInput" value="#{alertUIBean.alertDefinition.description}" />
+ <h:inputTextarea id="alertDescriptionInput" value="#{alertUIBean.alertDefinition.description}" style="width: 300px;" />
<h:outputLabel for="alertPriorityInput" value="Priority: " />
<h:selectOneMenu id="alertPriorityInput" value="#{alertUIBean.alertDefinition.priority}">
@@ -180,14 +180,14 @@
<h:selectBooleanCheckbox id="alertEnabledInput" value="#{alertUIBean.alertDefinition.enabled}" />
</h:panelGrid>
+ <h:outputLink id="cancelLink" styleClass="buttonmed" value="#" style="float: right;">
+ <h:outputText value="Cancel" />
+ <rich:componentControl for="editAlertDefinitionPanel" attachTo="cancelLink" operation="hide" event="onclick" />
+ </h:outputLink>
+
<h:commandButton id="saveButton" value="Save Changes" styleClass="buttonmed" action="#{alertUIBean.saveAlertDefinition}" />
</h:form>
-
- <br />
- <h:outputLink id="cancelLink" styleClass="buttonmed" value="#">
- <h:outputText value="Cancel" />
- <rich:componentControl for="editAlertDefinitionPanel" attachTo="cancelLink" operation="hide" event="onclick" />
- </h:outputLink>
+
</rich:modalPanel>
</ui:define>
commit a40c6a2f7f6f98c47891563b7f42f4a0808b3615
Author: Justin Harris <jharris(a)redhat.com>
Date: Tue Jan 26 13:55:56 2010 -0500
Altering navigation rules for notification templates.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java
index 53d5c19..208f15d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java
@@ -43,7 +43,7 @@ import javax.persistence.Table;
@NamedQueries({
@NamedQuery(name = NotificationTemplate.FIND_BY_NAME, query = "SELECT t FROM NotificationTemplate t WHERE t.name = :name"),
- @NamedQuery(name = NotificationTemplate.FIND_ALL, query = "SELECT t FROM NotificationTemplate t LEFT JOIN FETCH t.notifications")
+ @NamedQuery(name = NotificationTemplate.FIND_ALL, query = "SELECT t FROM NotificationTemplate AS t")
})
@Entity
@Table(name="RHQ_ALERT_NOTIF_TEMPL")
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java
index 2b6b2dd..b2b1df3 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.alert;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -49,7 +50,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
@Scope(ScopeType.PAGE)
@Name("alertNotificationsUIBean")
-public class AlertNotificationsUIBean {
+public class AlertNotificationsUIBean implements Serializable {
private final static String SUCCESS_OUTCOME = "success";
@RequestParameter("ad")
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java
index b11f958..4b01d25 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java
@@ -29,7 +29,6 @@ import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.datamodel.DataModel;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.log.Log;
import org.rhq.core.domain.alert.AlertCondition;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java
index b82c2d4..e9afb57 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java
@@ -38,7 +38,6 @@ import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.web.RequestParameter;
-import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.alert.notification.NotificationTemplate;
import org.rhq.core.domain.auth.Subject;
@@ -46,7 +45,6 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
-import org.rhq.enterprise.server.alert.AlertDefinitionManagerLocal;
import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -61,11 +59,12 @@ import org.rhq.enterprise.server.util.LookupUtil;
@SuppressWarnings("unused")
public class NotificationTemplatesUIBean implements Serializable {
- private final static String SUCCESS_OUTCOME = "success";
- @RequestParameter("ad")
- private Integer alertDefinitionId;
+ private final static String CONTINUE_OUTCOME = "continue";
+ private final static String NEW_OUTCOME = "new";
@RequestParameter("nid")
private Integer notificationId;
+ @RequestParameter("tid")
+ private Integer templateId;
private String opMode;
private List<AlertNotification> alertNotifications;
private Set<AlertNotification> selectedNotifications;
@@ -81,7 +80,7 @@ public class NotificationTemplatesUIBean implements Serializable {
private AlertNotificationConverter notificationConverter;
private AlertNotificationManagerLocal alertNotificationManager;
private static final String EDIT = "EDIT";
- private List<NotificationTemplate> listOfTemplates;
+ private List<NotificationTemplate> notificationTemplates;
NotificationTemplate selectedTemplate;
public List<AlertNotification> getAlertNotifications() {
@@ -192,6 +191,10 @@ public class NotificationTemplatesUIBean implements Serializable {
this.selectedTemplate = selectedTemplate;
}
+ public List<NotificationTemplate> getNotificationTemplates() {
+ return this.notificationTemplates;
+ }
+
private void lookupActiveConfigDefinition() {
System.out.println("lookupActiveConfigDef: activeNotification is " + activeNotification);
@@ -201,13 +204,6 @@ public class NotificationTemplatesUIBean implements Serializable {
}
}
- public AlertDefinition getAlertDefinition() {
- AlertDefinitionManagerLocal definitionManager = LookupUtil.getAlertDefinitionManager();
- Subject subject = EnterpriseFacesContextUtility.getSubject();
-
- return definitionManager.getAlertDefinitionById(subject, alertDefinitionId);
- }
-
@Create
public void initNotifications() {
this.alertNotificationManager = LookupUtil.getAlertNotificationManager();
@@ -218,10 +214,26 @@ public class NotificationTemplatesUIBean implements Serializable {
this.selectedNotifications = new HashSet<AlertNotification>();
this.notificationConverter = new AlertNotificationConverter();
this.notificationConverter.setAlertNotifications(alertNotifications);
+ this.notificationTemplates = alertNotificationManager.listNotificationTemplates(EnterpriseFacesContextUtility.getSubject());
+ selectActiveTemplate();
selectActiveNotification();
}
+ private void selectActiveTemplate() {
+ if (this.templateId != null) {
+ for (NotificationTemplate template : this.notificationTemplates) {
+ if (template.getId() == this.templateId) {
+ selectTemplate(template);
+
+ return;
+ }
+ }
+ }
+
+ opMode = "";
+ }
+
// Sets the initial state of the bean given the requrest parameters, this allows
// us to maintain the selected item across requests.
private void selectActiveNotification() {
@@ -271,7 +283,7 @@ public class NotificationTemplatesUIBean implements Serializable {
FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR,"Adding the sender failed: " + iae.getMessage() );
}
- return SUCCESS_OUTCOME;
+ return CONTINUE_OUTCOME;
}
public String saveConfiguration() {
@@ -281,7 +293,7 @@ public class NotificationTemplatesUIBean implements Serializable {
this.alertNotificationManager.updateAlertNotification(this.activeNotification);
}
- return SUCCESS_OUTCOME;
+ return CONTINUE_OUTCOME;
}
public String removeSelected() {
@@ -291,7 +303,7 @@ public class NotificationTemplatesUIBean implements Serializable {
alertNotificationManager.removeNotificationsFromTemplate(subject, selectedTemplate.getId(), toArray(ids));
- return SUCCESS_OUTCOME;
+ return CONTINUE_OUTCOME;
}
public String saveOrder() {
@@ -304,7 +316,7 @@ public class NotificationTemplatesUIBean implements Serializable {
this.alertNotificationManager.updateAlertNotification(notification);
}
- return SUCCESS_OUTCOME;
+ return CONTINUE_OUTCOME;
}
private List<Integer> getSelectedIds(Collection<AlertNotification> notifications) {
@@ -332,14 +344,7 @@ public class NotificationTemplatesUIBean implements Serializable {
return result;
}
- public List<NotificationTemplate> getNotificationTemplates() {
-
- List<NotificationTemplate> templates = alertNotificationManager.listNotificationTemplates(EnterpriseFacesContextUtility.getSubject());
- listOfTemplates = templates;
- return templates;
- }
-
- public String createNoticationTemplate() {
+ public String createNotificationTemplate() {
NotificationTemplate templ;
@@ -352,7 +357,7 @@ public class NotificationTemplatesUIBean implements Serializable {
FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR,"Creation of template failed: " + iae.getMessage());
}
- return SUCCESS_OUTCOME;
+ return NEW_OUTCOME;
}
public String deleteNotificationTemplate() {
@@ -362,7 +367,7 @@ public class NotificationTemplatesUIBean implements Serializable {
Iterator<Object> iter = selectedTemplates.getKeys();
while (iter.hasNext()) {
Integer row = (Integer) iter.next();
- NotificationTemplate templ = listOfTemplates.get(row);
+ NotificationTemplate templ = notificationTemplates.get(row);
ids.add(templ.getId());
}
@@ -375,26 +380,30 @@ public class NotificationTemplatesUIBean implements Serializable {
summary+="s";
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, summary);
- return SUCCESS_OUTCOME;
+ return NEW_OUTCOME;
}
- public String editNotificationTemplate() {
+ public void editNotificationTemplate() {
Subject subject = EnterpriseFacesContextUtility.getSubject();
System.out.println("in edit Template");
Iterator<Object> iter = selectedTemplates.getKeys();
if (selectedTemplates.size()==1) {
Integer row = (Integer) iter.next();
- selectedTemplate = listOfTemplates.get(row);
- alertNotifications = alertNotificationManager.getNotificationsForTemplate(subject,selectedTemplate.getId());
- this.notificationConverter.setAlertNotifications(alertNotifications);
- System.out.println("Selected template is " + selectedTemplate);
- opMode = EDIT;
+ selectTemplate(notificationTemplates.get(row));
}
- else
+ else {
opMode = "";
+ }
+ }
- return SUCCESS_OUTCOME;
+ private void selectTemplate(NotificationTemplate template) {
+ Subject subject = EnterpriseFacesContextUtility.getSubject();
+ selectedTemplate = template;
+ alertNotifications = alertNotificationManager.getNotificationsForTemplate(subject, selectedTemplate.getId());
+ this.notificationConverter.setAlertNotifications(alertNotifications);
+ System.out.println("Selected template is " + selectedTemplate);
+ opMode = EDIT;
}
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml
index fbff540..a760608 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml
@@ -106,5 +106,29 @@
</navigation-case>
</navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/rhq/resource/alert/notif/notificationTemplates.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-outcome>continue</from-outcome>
+ <to-view-id>/rhq/resource/alert/notif/notificationTemplates.xhtml?nid=#{notificationTemplateUIBean.activeNotification.id}&tid=#{notificationTemplateUIBean.selectedTemplate.id}</to-view-id>
+
+ <redirect />
+ </navigation-case>
+
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/rhq/resource/alert/notif/notificationTemplates.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-outcome>new</from-outcome>
+ <to-view-id>/rhq/resource/alert/notif/notificationTemplates.xhtml</to-view-id>
+
+ <redirect />
+ </navigation-case>
+
+ </navigation-rule>
-</faces-config>
\ No newline at end of file
+</faces-config>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/notificationTemplates.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/notificationTemplates.xhtml
index 18aedb0..17f5128 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/notificationTemplates.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/notificationTemplates.xhtml
@@ -102,7 +102,7 @@
<p/>
<h:commandButton id="newTemplateButton"
value="Create new Template"
- action="#{notificationTemplateUIBean.createNoticationTemplate}"
+ action="#{notificationTemplateUIBean.createNotificationTemplate}"
styleClass="buttonmed"/>
</h:form>
</rich:panel>
diff --git a/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml
index 8dba350..ae84d32 100644
--- a/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -17,7 +17,7 @@
<!-- Global preferences for all snmp alerts -->
<serverplugin:plugin-configuration>
- <c:simple-property name="snmpVersion" displayName="Snmp protcol version" type="string" required="false" default="1">
+ <c:simple-property name="snmpVersion" displayName="SNMP protcol version" type="string" required="false" default="1">
<c:property-options>
<c:option value="1"/>
<c:option value="2c"/>
@@ -28,7 +28,7 @@
<c:simple-property name="trapOid" displayName="Trap OID" description="OID for the trap sent" type="string" />
<c:simple-property name="community" type="string" default="public" description="Community - v1 and v2c only" required="false"/>
- <c:group name="1" displayName="Snmp version 1 properties" hiddenByDefault="true" >
+ <c:group name="1" displayName="SNMP version 1 properties" hiddenByDefault="true" >
<c:simple-property name="engineId" required="false"/>
<c:simple-property name="genericId" required="false"/>
<c:simple-property name="enterpriseOid" required="false"/>
@@ -40,7 +40,7 @@
Nothing special
</c:group>
-->
- <c:group name="3" displayName="Snmp version 3 properties" hiddenByDefault="true">
+ <c:group name="3" displayName="SNMP version 3 properties" hiddenByDefault="true">
<c:simple-property name="authProtocol" type="string" default="MD5">
<c:property-options>
<c:option value="none"/>
commit 75418428d87c9b6d6f33b8194b9720ae00c42619
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Tue Jan 26 10:38:12 2010 -0500
fixing unittests for registration bean
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
index 3293933..8571aa9 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
@@ -27,15 +27,16 @@ import org.testng.annotations.Test;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.server.registration.RegistrationManagerLocal;
import org.rhq.enterprise.server.registration.ReleaseRepoMapping;
+import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
public class RegistrationBeanTest extends AbstractEJB3Test {
private RegistrationManagerLocal registrationManager;
+ private ResourceTypeManagerLocal resourceTypeManager;
private ResourceType platformType;
private Agent agent;
private int parentId = -1;
@@ -44,6 +45,7 @@ public class RegistrationBeanTest extends AbstractEJB3Test {
@BeforeClass
public void beforeClass() throws Exception {
this.registrationManager = LookupUtil.getRegistrationManager();
+ this.resourceTypeManager = LookupUtil.getResourceTypeManager();
this.overlord = LookupUtil.getSubjectManager().getOverlord();
}
@@ -52,10 +54,10 @@ public class RegistrationBeanTest extends AbstractEJB3Test {
getTransactionManager().begin();
EntityManager em = getEntityManager();
try {
- createResourceTypes(em);
createAgent(em);
em.flush();
+ platformType = getPlatformResourceType();
Resource platform = new Resource("alpha", "platform", platformType);
registrationManager.registerPlatform(overlord, platform, parentId);
@@ -87,10 +89,9 @@ public class RegistrationBeanTest extends AbstractEJB3Test {
em.persist(agent);
}
- private void createResourceTypes(EntityManager entityManager) {
- platformType = new ResourceType("test platform", "test", ResourceCategory.PLATFORM, null);
+ private ResourceType getPlatformResourceType() {
- entityManager.persist(platformType);
+ return resourceTypeManager.getResourceTypeByNameAndPlugin(overlord, "Linux", "Platforms");
}
}
commit 41c75f85e39431f5997ac3a2d1ec95120a656a2f
Author: Sayli Karmarkar <skarmark(a)redhat.com>
Date: Mon Jan 25 13:28:52 2010 -0500
Adding sorting for install and update lists
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
index d229f93..d7b3e0a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
@@ -19,6 +19,8 @@
package org.rhq.enterprise.server.content;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -266,6 +268,15 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
}
}
+ Collections.sort(modifiedResults, new Comparator() {
+
+ public int compare(Object o1, Object o2) {
+ PackageVersionComposite p1 = (PackageVersionComposite) o1;
+ PackageVersionComposite p2 = (PackageVersionComposite) o2;
+ return p1.getPackageName().compareToIgnoreCase(p2.getPackageName());
+ }
+ });
+
return new PageList<PackageVersionComposite>(modifiedResults, (int) count, pc);
}
@@ -343,6 +354,15 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
}
}
+ Collections.sort(finalResults, new Comparator() {
+
+ public int compare(Object o1, Object o2) {
+ PackageVersionComposite p1 = (PackageVersionComposite) o1;
+ PackageVersionComposite p2 = (PackageVersionComposite) o2;
+ return p1.getPackageName().compareToIgnoreCase(p2.getPackageName());
+ }
+ });
+
return new PageList<PackageVersionComposite>(finalResults, (int) count, pc);
}
commit d5b19c721b6883da0c3813260327166a22ddfbc9
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Mon Jan 25 08:40:40 2010 -0800
0000 - switching to previous method for refreshing status bar
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
index b4855ce..dea6e98 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
@@ -48,7 +48,7 @@ public class RepoDetailsUIBean {
return "edit";
}
- public boolean getShowProgressBar() {
+ public boolean getCurrentlySyncing() {
String syncStatus = getSyncStatus();
if (!syncStatus.equals(ContentSyncStatus.SUCCESS.toString())
&& !syncStatus.equals(ContentSyncStatus.FAILURE.toString())
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
index 5b5a5ae..8837813 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
@@ -115,13 +115,12 @@
value="#{RepoDetailsUIBean.percentComplete}" />
</td>
</tr>
- <!--
<tr>
- <td align="right"><b>Synchronization Progress 1:</b></td>
+ <td align="right"><b>Synchronization Progress :</b></td>
<td align="left">
<c:choose>
<c:when
- test="#{RepoDetailsUIBean.showProgressBar}">
+ test="#{RepoDetailsUIBean.currentlySyncing}">
<rich:progressBar id="syncProgress"
value="#{RepoDetailsUIBean.percentComplete}"
label="#{RepoDetailsUIBean.percentComplete} %"
@@ -137,7 +136,7 @@
</c:choose>
</td>
</tr>
- -->
+ <!--
<tr>
<td align="right"><b>Synchronization Progress:</b></td>
<td align="left">
@@ -154,6 +153,7 @@
</rich:progressBar>
</td>
</tr>
+ -->
<tr>
<td align="right"><b>Synchronization Results:</b></td>
<td align="left"><h:outputLink
@@ -196,7 +196,7 @@
<h:commandButton rendered="${mode ne 'edit'}"
value="SYNCHRONIZE" action="#{RepoDetailsUIBean.sync}"
alt="Synchronize" styleClass="buttonmed" id="syncButton" />
- <h:commandButton rendered="${mode ne 'edit'}"
+ <h:commandButton rendered="#{RepoDetailsUIBean.currentlySyncing}"
value="CANCEL SYNCH" action="#{RepoDetailsUIBean.cancelSync}"
alt="Cancel Synch" styleClass="buttonmed" id="cancelSyncButton" />
<h:commandButton rendered="${mode eq 'edit'}" value="SAVE"
commit 67945293742b8ade2f9c3faf7bc134696be53ccd
Author: Jeff Ortel <jortel(a)redhat.com>
Date: Mon Jan 25 10:08:26 2010 -0600
Look for cert named client for demo instead of by resource id.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
index 3ec181f..7220970 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
@@ -28,6 +28,7 @@ public class EntitlementManagerBean implements EntitlementManagerLocal, Entitlem
DummyLoader loader = new DummyLoader();
try {
list.add(loader.load(resourceId));
+
} catch (Exception ex) {
log.warn("x.509 cert for: " //
+ resourceId //
@@ -44,6 +45,12 @@ class DummyLoader {
EntitlementCertificate load(int resourceId) throws IOException {
String name = String.valueOf(resourceId);
+ EntitlementCertificate x509 = load("client");
+ x509.setName(name);
+ return x509;
+ }
+
+ EntitlementCertificate load(String name) throws IOException {
String key = read(name + ".key");
String pem = read(name + ".pem");
return new EntitlementCertificate(name, key, pem);
commit 4ed31cc2dad1547e51102d143135b3cd41828a86
Author: Sayli Karmarkar <skarmark(a)redhat.com>
Date: Mon Jan 25 02:11:43 2010 -0500
1364 - Update list should show only the most recent packageversion and not all versions > installed package
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
index e003579..d229f93 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
@@ -295,7 +295,6 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
query.setParameter("resourceId", resourceId);
query.setParameter("filter", filter);
- long count = 0;
List<PackageVersionComposite> results = query.getResultList();
List<PackageVersionComposite> modifiedResults = new ArrayList<PackageVersionComposite>();
String packageName = new String();
@@ -307,12 +306,44 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
if (installedPackageNameAndVersion.get(packageName).compareTo(result.getPackageVersion().getVersion()) < 0) {
modifiedResults.add(result);
- count++;
}
+ }
+ }
+
+ List<PackageVersionComposite> testResults = new ArrayList<PackageVersionComposite>();
+ for (PackageVersionComposite result : modifiedResults) {
+ testResults.add(result);
+ }
+ List<PackageVersionComposite> latestResults = new ArrayList<PackageVersionComposite>();
+
+ PackageVersionComposite latestPackage = null;
+
+ for (PackageVersionComposite newPackage : modifiedResults) {
+ latestPackage = newPackage;
+
+ for (PackageVersionComposite pack : testResults) {
+ if (pack.getPackageName().equals(latestPackage.getPackageName())
+ && latestPackage.getPackageVersion().getVersion().compareTo(pack.getPackageVersion().getVersion()) < 0) {
+ latestPackage = pack;
+ }
}
+ latestResults.add(latestPackage);
}
- return new PageList<PackageVersionComposite>(modifiedResults, (int) count, pc);
+
+ List<PackageVersionComposite> finalResults = new ArrayList<PackageVersionComposite>();
+
+ long count = 0;
+ for (PackageVersionComposite pack : latestResults) {
+ if (finalResults.contains(pack)) {
+ continue;
+ } else {
+ finalResults.add(pack);
+ count++;
+ }
+ }
+
+ return new PageList<PackageVersionComposite>(finalResults, (int) count, pc);
}
public PackageVersionComposite loadPackageVersionComposite(Subject user, int packageVersionId) {
commit a99b8f2f463779bb4fe3d92857ed9ae541009737
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Fri Jan 22 16:23:23 2010 -0800
0000 - temp fix to alleviate timeouts during long syncs
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 f819aa0..b222f2e 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
@@ -38,6 +38,7 @@ import org.quartz.CronExpression;
import org.quartz.SchedulerException;
import org.jboss.annotation.IgnoreDependency;
+import org.jboss.annotation.ejb.TransactionTimeout;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
@@ -1030,6 +1031,8 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
}
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ // TEMPORARY TIMEOUT DEFINED WHILE WE PROPERLY FIGURE OUT TIMEOUTS
+ @TransactionTimeout(86400)
public int internalSynchronizeRepos(Subject subject, Integer[] repoIds) throws InterruptedException {
ContentServerPluginContainer pc;
try {
commit a892dcc85e71a7280bc958b428dfab3c92df0976
Author: Jeff Ortel <jortel(a)redhat.com>
Date: Fri Jan 22 16:28:39 2010 -0600
Allow access to content via http w/o cert. For now, only validate cert when presented.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
index 602c5a9..b5fa4f1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
@@ -25,17 +25,6 @@ public class EntitlementCertificate {
}
/**
- *
- * @param certificate
- * @param key
- */
- public EntitlementCertificate(String certificate, String key) {
- this.name = "client";
- this.certificate = certificate;
- this.key = key;
- }
-
- /**
* @return the certificate
*/
public String getCertificate() {
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java
index 46b5119..0904ee5 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java
@@ -4,14 +4,22 @@ import java.security.cert.X509Extension;
import javax.servlet.http.HttpServletRequest;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.enterprise.server.content.EntitlementManagerBean;
+
public class ContentFilter {
+ private final Log log = LogFactory.getLog(EntitlementManagerBean.class);
+
static final String CERTS = "javax.servlet.request.X509Certificate";
void filter(HttpServletRequest request, int repoId) throws EntitlementException {
X509Extension[] certificates = (X509Extension[]) request.getAttribute(CERTS);
if (certificates == null) {
- throw new EntitlementException("client x.509 cert not passed");
+ log.warn("x509 client certificate not passed, not-checked.");
+ return;
}
String oid = objectIdentifier(repoId);
for (X509Extension x509 : certificates) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
index cb2d21d..3ec181f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
@@ -25,59 +25,28 @@ public class EntitlementManagerBean implements EntitlementManagerLocal, Entitlem
@RequiredPermission(Permission.MANAGE_INVENTORY)
public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
List<EntitlementCertificate> list = new ArrayList<EntitlementCertificate>();
- if (resourceId % 2 == 0) {
- list.add(getEven());
- } else {
- list.add(getOdd());
- }
- return list;
- }
-
- /**
- * Get certificate for even numbered resource ids.
- * @return The cert.
- * @note This is a prototype hack.
- */
- private EntitlementCertificate getOdd() {
DummyLoader loader = new DummyLoader();
try {
- return loader.getOdd();
+ list.add(loader.load(resourceId));
} catch (Exception ex) {
- log.error("Certificate (ODD), not-found", ex);
+ log.warn("x.509 cert for: " //
+ + resourceId //
+ + " not-found in: " //
+ + DummyLoader.dir);
}
- return null;
- }
-
- /**
- * Get certificate for odd numbered resource ids.
- * @return The cert.
- * @note This is a prototype hack.
- */
- private EntitlementCertificate getEven() {
- DummyLoader loader = new DummyLoader();
- try {
- return loader.getEven();
- } catch (Exception ex) {
- log.error("Certificate (EVEN), not-found", ex);
- }
- return null;
+ return list;
}
}
class DummyLoader {
- private static final String dir = "/etc/pki/yum/rhq";
-
- EntitlementCertificate getOdd() throws IOException {
- String key = read("odd.key");
- String pem = read("odd.pem");
- return new EntitlementCertificate(key, pem);
- }
+ static final String dir = "/etc/pki/rhq";
- EntitlementCertificate getEven() throws IOException {
- String key = read("even.key");
- String pem = read("even.pem");
- return new EntitlementCertificate(key, pem);
+ EntitlementCertificate load(int resourceId) throws IOException {
+ String name = String.valueOf(resourceId);
+ String key = read(name + ".key");
+ String pem = read(name + ".pem");
+ return new EntitlementCertificate(name, key, pem);
}
private String read(String fn) throws IOException {
commit 17aafa6f54b45a200adba6293fda78ec8b290316
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Fri Jan 22 13:57:54 2010 -0800
removing system.out
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
index 09b049d..b4855ce 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
@@ -65,7 +65,6 @@ public class RepoDetailsUIBean {
Subject subject = EnterpriseFacesContextUtility.getSubject();
Integer id = FacesContextUtility.getRequiredRequestParameter("id", Integer.class);
String retval = LookupUtil.getRepoManagerLocal().calculateSyncStatus(subject, id);
- System.out.println("getSyncStatus: " + retval);
return retval;
}
@@ -85,7 +84,6 @@ public class RepoDetailsUIBean {
} else {
retval = "0";
}
- System.out.println("getPercentComplete: " + retval);
return retval;
}
commit a168b7fa13aa1e888f8aee85a4e2321e91b53766
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Fri Jan 22 13:50:20 2010 -0800
0000 - various bugfixes
- Fixing some refresh issues with repo details page but still isn't
perfect
- Chaqnging ContentSourceManagerBean to redownload any package that has
a missmatched md5 sum. before we would error out
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
index cdf7b25..09b049d 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
@@ -64,7 +64,9 @@ public class RepoDetailsUIBean {
public String getSyncStatus() {
Subject subject = EnterpriseFacesContextUtility.getSubject();
Integer id = FacesContextUtility.getRequiredRequestParameter("id", Integer.class);
- return LookupUtil.getRepoManagerLocal().calculateSyncStatus(subject, id);
+ String retval = LookupUtil.getRepoManagerLocal().calculateSyncStatus(subject, id);
+ System.out.println("getSyncStatus: " + retval);
+ return retval;
}
public RepoSyncResults getSyncResults() {
@@ -77,11 +79,14 @@ public class RepoDetailsUIBean {
Subject subject = EnterpriseFacesContextUtility.getSubject();
Integer id = FacesContextUtility.getRequiredRequestParameter("id", Integer.class);
RepoSyncResults r = LookupUtil.getRepoManagerLocal().getMostRecentSyncResults(subject, id);
+ String retval;
if (r != null && r.getPercentComplete() != null) {
- return r.getPercentComplete().toString();
+ retval = r.getPercentComplete().toString();
} else {
- return "0";
+ retval = "0";
}
+ System.out.println("getPercentComplete: " + retval);
+ return retval;
}
public String sync() {
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
index 5f93c10..5b5a5ae 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
@@ -89,17 +89,18 @@
timeZone="#{ServerInfoUIBean.timeZone}" />
</h:outputText></td>
</tr>
+
+ <!-- ******* START AJAX REFRESH/POLLING BLOCK ****** -->
+ <a4j:region>
+ <a4j:poll id="statusPoll" interval="1005"
+ reRender="syncPercent,syncStatus" />
<tr>
<td align="right"><b>Synchronization Status:</b></td>
<td align="left"><c:choose>
<c:when
test="#{RepoDetailsUIBean.percentComplete != '100'}">
- <a4j:region>
- <a4j:poll id="statusPoll" interval="1000"
- reRender="syncStatus" />
<h:outputText id="syncStatus"
value="#{RepoDetailsUIBean.syncStatus}" />
- </a4j:region>
</c:when>
<c:otherwise>
<h:outputText id="syncStatus"
@@ -107,26 +108,21 @@
</c:otherwise>
</c:choose></td>
</tr>
- <!--
<tr>
<td align="right"><b>Raw Percentage :</b></td>
<td align="left">
- <a4j:region>
- <a4j:poll id="percentPoll" interval="1005"
- reRender="syncPercent" />
<h:outputText id="syncPercent"
value="#{RepoDetailsUIBean.percentComplete}" />
- </a4j:region>
</td>
</tr>
- -->
+ <!--
<tr>
- <td align="right"><b>Synchronization Progress:</b></td>
+ <td align="right"><b>Synchronization Progress 1:</b></td>
<td align="left">
<c:choose>
<c:when
test="#{RepoDetailsUIBean.showProgressBar}">
- <rich:progressBar
+ <rich:progressBar id="syncProgress"
value="#{RepoDetailsUIBean.percentComplete}"
label="#{RepoDetailsUIBean.percentComplete} %"
interval="999" minValue="-1" maxValue="99">
@@ -141,6 +137,23 @@
</c:choose>
</td>
</tr>
+ -->
+ <tr>
+ <td align="right"><b>Synchronization Progress:</b></td>
+ <td align="left">
+ <rich:progressBar id="syncProgress"
+ value="#{RepoDetailsUIBean.percentComplete}"
+ label="#{RepoDetailsUIBean.percentComplete} %"
+ interval="999" minValue="-1" maxValue="99">
+ <f:facet name="complete">
+ <h:outputText value="Synchronizing Complete" />
+ </f:facet>
+ <f:facet name="initial">
+ <h:outputText value="Not Synching" />
+ </f:facet>
+ </rich:progressBar>
+ </td>
+ </tr>
<tr>
<td align="right"><b>Synchronization Results:</b></td>
<td align="left"><h:outputLink
@@ -167,16 +180,11 @@
operation="hide" event="onclick" />
</h:panelGroup>
</f:facet>
- <a4j:region>
- <a4j:poll id="resultsPoll" interval="2000"
- reRender="syncResults" />
- <PRE><h:outputText id="syncResults"
- value="#{RepoDetailsUIBean.syncResults.results}" /></PRE>
- </a4j:region>
-
-
+ <PRE><h:outputText value="#{RepoDetailsUIBean.syncResults.results}" /></PRE>
</rich:modalPanel></td>
</tr>
+ </a4j:region>
+ <!-- ******* END AJAX REFRESH/POLLING BLOCK ****** -->
</table>
</rich:panel>
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 1f9c62e..cc1b11b 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
@@ -847,23 +847,32 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
// store content to local file system
File outputFile = getPackageBitsLocalFileAndCreateParentDir(pv.getId(), pv.getFileName());
log.info("OutPutFile is located at: " + outputFile);
+ boolean download = false;
+
if (outputFile.exists()) {
// hmmm... it already exists, maybe we already have it?
// if the MD5's match, just ignore this download request and continue on
+ // If they are different we re-download
String expectedMD5 = (pv.getMD5() != null) ? pv.getMD5() : "<unspecified MD5>";
String actualMD5 = MessageDigestGenerator.getDigestString(outputFile);
if (!expectedMD5.trim().toLowerCase().equals(actualMD5.toLowerCase())) {
- throw new Exception("Already have package bits for [" + pv + "] located at [" + outputFile
+ log.error("Already have package bits for [" + pv + "] located at [" + outputFile
+ "] but the MD5 hashcodes do not match. Expected MD5=[" + expectedMD5
- + "], Actual MD5=[" + actualMD5 + "]");
+ + "], Actual MD5=[" + actualMD5 + "] - redownloading package");
+ download = true;
} else {
log.info("Asked to download package bits but we already have it at [" + outputFile
+ "] with matching MD5 of [" + actualMD5 + "]");
+ download = false;
}
} else {
+ download = true;
+ }
+ if (download) {
StreamUtil.copy(bitsStream, new FileOutputStream(outputFile), true);
bitsStream = null;
}
+
}
} finally {
if (ps != null) {
commit b069b2977163477e1d95cd91b36168471b5e8569
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Fri Jan 22 15:55:05 2010 -0500
Adding logic to populate the default plugin configuration at the registration time. If not, the inventory -> connection tab will show up as empty as it sets to null
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
index 49b6334..fe4b61e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
@@ -32,6 +32,8 @@ import org.apache.commons.logging.LogFactory;
import org.jboss.annotation.IgnoreDependency;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.InventoryStatus;
@@ -39,6 +41,7 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
+import org.rhq.enterprise.server.configuration.ConfigurationManagerLocal;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.core.AgentManagerLocal;
import org.rhq.enterprise.server.resource.ResourceAlreadyExistsException;
@@ -56,6 +59,9 @@ public class RegistrationManagerBean implements RegistrationManagerLocal, Regist
@IgnoreDependency
private ResourceManagerLocal resourceManager;
@EJB
+ @IgnoreDependency
+ private ConfigurationManagerLocal configManager;
+ @EJB
private SubjectManagerLocal subjectManager;
@EJB
private AgentManagerLocal agentManager;
@@ -74,6 +80,13 @@ public class RegistrationManagerBean implements RegistrationManagerLocal, Regist
throw new IllegalStateException(e);
}
+ ResourceType resourceType = platform.getResourceType();
+ ConfigurationDefinition configDefinition = configManager.getPluginConfigurationDefinitionForResourceType(user,
+ resourceType.getId());
+
+ Configuration platformConfig = configDefinition.getDefaultTemplate().getConfiguration();
+
+ platform.setPluginConfiguration(platformConfig);
platform.setInventoryStatus(InventoryStatus.COMMITTED);
Agent agent = createFakeAgent(platform);
commit a41355483ee63f14bc7d8fe3ddd655c3f141005e
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Fri Jan 22 15:25:29 2010 -0500
Incorrect mapping of webservice bean to logic bean.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 698621d..b427713 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -227,7 +227,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public void deleteCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "cveId") int cveId) {
- advisoryManager.deleteAdvisoryCVE(user, cveId);
+ advisoryManager.deleteCVE(user, cveId);
}
public void deleteAdvisoryCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "advId") int advId) {
commit de17114d9d1e65efeba2059e1415e4f5a85709c5
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Fri Jan 22 15:15:12 2010 -0500
Changes to allow advisory operations over web services
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java
index 86155b0..32d2518 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java
@@ -96,9 +96,6 @@ public class Advisory implements Serializable {
private long lastModifiedDate;
@OneToMany(mappedBy = "advisory", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
- private Set<AdvisoryCVE> advisorycves;
-
- @OneToMany(mappedBy = "advisory", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private Set<AdvisoryPackage> advisorypkgs;
@OneToMany(mappedBy = "advisory", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@@ -220,14 +217,6 @@ public class Advisory implements Serializable {
return lastModifiedDate;
}
- public Set<AdvisoryCVE> getAdvisorycves() {
- return advisorycves;
- }
-
- public void setAdvisorycves(Set<AdvisoryCVE> advisorycves) {
- this.advisorycves = advisorycves;
- }
-
public Set<AdvisoryPackage> getAdvisorypkgs() {
return advisorypkgs;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java
index bc9ad68..346880c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java
@@ -66,7 +66,6 @@ public class AdvisoryCVE implements Serializable {
@Id
private int id;
- @XmlTransient
@ManyToOne
@JoinColumn(name = "ADVISORY_ID", referencedColumnName = "ID", nullable = false)
private Advisory advisory;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java
index 72313da..db349f3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java
@@ -36,7 +36,7 @@ import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.util.StringUtils;
/**
- *
+ *
* @author Pradeep Kilambi
*
*/
@@ -54,7 +54,6 @@ public class AdvisoryDetailsComposite implements Serializable {
private final String severity;
private final Date updateDate;
private final Date issueDate;
- private final String cve;
private final List<PackageVersion> pkgs;
private String bugid;
@@ -70,7 +69,6 @@ public class AdvisoryDetailsComposite implements Serializable {
this.severity = severity;
this.updateDate = new Date(updateDate.longValue() * 1000L);
this.issueDate = new Date(issueDate.longValue() * 1000L);
- this.cve = getAdvisoryCVE();
this.pkgs = getAdvisoryPackages();
this.bugid = getBugid();
@@ -85,15 +83,6 @@ public class AdvisoryDetailsComposite implements Serializable {
return pkges;
}
- private String getAdvisoryCVE() {
- List<String> cves = new ArrayList<String>();
- Set<AdvisoryCVE> acves = advisory.getAdvisorycves();
- for (AdvisoryCVE acve : acves) {
- cves.add(acve.getCVE().getName());
- }
- return StringUtils.getListAsString(cves, " ");
- }
-
public static long getSerialversionuid() {
return serialVersionUID;
}
@@ -130,10 +119,6 @@ public class AdvisoryDetailsComposite implements Serializable {
return severity;
}
- public String getCve() {
- return cve;
- }
-
public List<PackageVersion> getPkgs() {
return pkgs;
}
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java
index 3f22fa0..48cf125 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java
@@ -22,9 +22,14 @@
*/
package org.rhq.enterprise.server.ws.test;
+import java.util.List;
+
import org.testng.annotations.Test;
import org.rhq.enterprise.server.ws.Advisory;
+import org.rhq.enterprise.server.ws.AdvisoryCVE;
+import org.rhq.enterprise.server.ws.Cve;
+import org.rhq.enterprise.server.ws.PageControl;
import org.rhq.enterprise.server.ws.Subject;
/**
@@ -42,7 +47,7 @@ public class WsAdvisoryManagerTest extends WsUnitTestBase {
// Setup
String label = "WsAdvisoryManagerTest.createGetDeleteAdvisory.label";
- String synopsis = "WsAdvisoryManagerTest.createGetDeleteAdvisory.name";
+ String synopsis = "WsAdvisoryManagerTest.createGetDeleteAdvisory.synopsis";
String type = "bugfix";
Subject admin = subjectUtil.admin();
@@ -71,4 +76,43 @@ public class WsAdvisoryManagerTest extends WsUnitTestBase {
assert retrieved == null;
}
+ @Test(enabled = TESTS_ENABLED)
+ public void createMapDeleteCve() throws Exception {
+
+ // Setup
+ String advLabel = "WsAdvisoryManagerTest.createMapDeleteCve.label";
+ String advSynopsis = "WsAdvisoryManagerTest.createMapDeleteCve.synopsis";
+ String advType = "bugfix";
+
+ String cveName = "WsAdvisoryManagerTest.createMapDeleteCve.name";
+
+ Subject admin = subjectUtil.admin();
+
+ PageControl pc = objectFactory.createPageControl();
+
+ // Test & Verify
+ Advisory createdAdvisory = service.createAdvisory(admin, advLabel, advType, advSynopsis);
+ assert createdAdvisory != null;
+
+ Cve createdCve = service.createCVE(admin, cveName);
+ assert createdCve != null;
+
+ AdvisoryCVE createdMapping = service.createAdvisoryCVE(admin, createdAdvisory, createdCve);
+ assert createdMapping != null;
+
+ assert advLabel.equals(createdMapping.getAdvisory().getAdvisory());
+
+ List<AdvisoryCVE> cveList = service.getAdvisoryCVEByAdvId(admin, createdAdvisory.getId(), pc);
+ assert cveList.size() == 1 : "Found: " + cveList.size();
+
+ service.deleteAdvisoryCVE(admin, createdAdvisory.getId());
+
+ List<AdvisoryCVE> deletedMappings = service.getAdvisoryCVEByAdvId(admin, createdAdvisory.getId(), pc);
+ assert deletedMappings != null;
+ assert deletedMappings.size() == 0;
+
+ // Cleanup
+ service.deleteCVE(admin, createdCve.getId());
+ service.deleteAdvisoryByAdvId(admin, createdAdvisory.getId());
+ }
}
commit 1764ede1f24ab601dead72a57737c1d216333de4
Author: Jeff Ortel <jortel(a)redhat.com>
Date: Fri Jan 22 13:58:10 2010 -0600
add (name) to cert.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
index 9315cda..602c5a9 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
@@ -1,8 +1,8 @@
package org.rhq.core.domain.content.transfer;
-
public class EntitlementCertificate {
+ private String name;
private String certificate;
private String key;
@@ -14,11 +14,23 @@ public class EntitlementCertificate {
}
/**
+ *
+ * @param certificate
+ * @param key
+ */
+ public EntitlementCertificate(String name, String certificate, String key) {
+ this.name = name;
+ this.certificate = certificate;
+ this.key = key;
+ }
+
+ /**
*
* @param certificate
* @param key
*/
public EntitlementCertificate(String certificate, String key) {
+ this.name = "client";
this.certificate = certificate;
this.key = key;
}
@@ -38,6 +50,20 @@ public class EntitlementCertificate {
}
/**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
* @return the private key
*/
public String getKey() {
commit 577c56cd2570a8f6034cbf5ef5e7e5a0e6cfd206
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jan 22 14:12:11 2010 -0500
merge changes if a cobbler distro needs to be changed
diff --git a/modules/enterprise/server/plugins/cobbler/src/main/java/org/rhq/enterprise/server/plugins/cobbler/CobblerServerPluginComponent.java b/modules/enterprise/server/plugins/cobbler/src/main/java/org/rhq/enterprise/server/plugins/cobbler/CobblerServerPluginComponent.java
index 30537c5..12cd116 100644
--- a/modules/enterprise/server/plugins/cobbler/src/main/java/org/rhq/enterprise/server/plugins/cobbler/CobblerServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/cobbler/src/main/java/org/rhq/enterprise/server/plugins/cobbler/CobblerServerPluginComponent.java
@@ -183,23 +183,26 @@ public class CobblerServerPluginComponent implements ServerPluginComponent, Cont
for (Distribution distribution : repoEntry.getValue().values()) {
- Distro cobblerDistro = cobblerDistros.get(distribution.getLabel());
- if (cobblerDistro == null) {
- String distroRootUrl = rootUrl + repoName + "/distributions/" + distribution.getLabel();
-
- cobblerDistro = new Distro(conn);
- cobblerDistro.setName(distribution.getLabel());
- cobblerDistro.setComment(COMMENT_MARKER + " " + distribution.getLabel());
- cobblerDistro.setKernel(distroRootUrl + "/images/pxeboot/vmlinuz"); // TODO what about other arches
- cobblerDistro.setInitrd(distroRootUrl + "/images/pxeboot/initrd.img"); // TODO what about other arches
- Map<String, String> ksmeta = new HashMap<String, String>();
- ksmeta.put("tree", distroRootUrl);
- cobblerDistro.setKsMeta(ksmeta);
- cobblerDistro.commit();
- log.info("Added distro to Cobbler: [" + distribution.getLabel() + "]");
+ Distro existingCobblerDistro = cobblerDistros.get(distribution.getLabel());
+ Distro desiredCobblerDistro = instantiateCobblerDistro(conn, distribution, repoName, rootUrl);
+
+ if (existingCobblerDistro != null) {
+ // cobbler already has a distro with the name we are looking for.
+ // let's make sure its data is the same, otherwise, we need to upgrade it.
+ // but first, we need to take it out of our map, because whatever is left in this map will be removed from Cobbler later.
+ cobblerDistros.remove(existingCobblerDistro.getName());
+
+ if (!compareCobblerDistros(existingCobblerDistro, desiredCobblerDistro)) {
+ // the one Cobbler has is old and needs to be updated with the latest data.
+ updateCobblerDistro(existingCobblerDistro, desiredCobblerDistro);
+ existingCobblerDistro.commit();
+ log.info("Updated existing Cobbler distro [" + distribution.getLabel() + "]");
+ } else {
+ log.debug("Cobbler already has distro [" + distribution.getLabel() + "]; keeping it");
+ }
} else {
- cobblerDistros.remove(cobblerDistro.getName());
- log.debug("Cobbler already has distro [" + distribution.getLabel() + "]");
+ desiredCobblerDistro.commit();
+ log.info("Added new distro to Cobbler: [" + distribution.getLabel() + "]");
}
}
}
@@ -208,17 +211,102 @@ public class CobblerServerPluginComponent implements ServerPluginComponent, Cont
for (Distro doomed : cobblerDistros.values()) {
if (doomed.getComment().startsWith(COMMENT_MARKER)) {
doomed.remove();
- log.info("Removed distro from Cobbler: [" + doomed.getName() + "]");
+ log.info("Removed obsolete distro from Cobbler: [" + doomed.getName() + "]");
}
}
} catch (Throwable t) {
- // TODO what should we do?
- t.printStackTrace();
+ log.error("Failed to synchronize distributions to Cobbler server", t);
} finally {
this.syncInProgress = false;
}
}
+ @SuppressWarnings("unchecked")
+ private void updateCobblerDistro(Distro existingCobblerDistro, Distro desiredCobblerDistro) {
+ existingCobblerDistro.setName(desiredCobblerDistro.getName());
+ existingCobblerDistro.setComment(desiredCobblerDistro.getComment());
+ existingCobblerDistro.setKernel(desiredCobblerDistro.getKernel());
+ existingCobblerDistro.setInitrd(desiredCobblerDistro.getInitrd());
+
+ Map<String, String> ksMetaDesired = desiredCobblerDistro.getKsMeta();
+ if (ksMetaDesired != null) {
+ Map<String, String> ksMetaExisting = existingCobblerDistro.getKsMeta();
+ if (ksMetaExisting == null) {
+ ksMetaExisting = new HashMap<String, String>(ksMetaDesired.size());
+ existingCobblerDistro.setKsMeta(ksMetaExisting);
+ }
+ ksMetaExisting.clear();
+ ksMetaExisting.putAll(ksMetaDesired);
+ } else {
+ existingCobblerDistro.setKsMeta(null);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private boolean compareCobblerDistros(Distro cobblerDistro1, Distro cobblerDistro2) {
+ if (!compareObjects(cobblerDistro1.getName(), cobblerDistro2.getName())) {
+ return false;
+ }
+ if (!compareObjects(cobblerDistro1.getComment(), cobblerDistro2.getComment())) {
+ return false;
+ }
+ if (!compareObjects(cobblerDistro1.getKernel(), cobblerDistro2.getKernel())) {
+ return false;
+ }
+ if (!compareObjects(cobblerDistro1.getInitrd(), cobblerDistro2.getInitrd())) {
+ return false;
+ }
+
+ Map<String, String> ksMeta1 = cobblerDistro1.getKsMeta();
+ Map<String, String> ksMeta2 = cobblerDistro2.getKsMeta();
+ String tree1 = null;
+ String tree2 = null;
+ if (ksMeta1 != null) {
+ tree1 = ksMeta1.get("tree");
+ }
+ if (ksMeta2 != null) {
+ tree2 = ksMeta2.get("tree");
+ }
+ if (!compareObjects(tree1, tree2)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Given a RHQ distribution domaon object, this instantiates a Cobbler Distro object
+ * that can allow Cobbler to access the distribution content.
+ * NOTE: this does NOT create the Distro on the Cobbler server, this only instantiates
+ * a Distro class object and returns it.
+ *
+ * @param conn a connection to the Cobbler server
+ * @param distribution the RHQ distribution data
+ * @param repoName the name of the repository that the distribution is associated with
+ * @param rootUrl the root URL where the distribution content can be found
+ * @return an instance of a Cobbler Distro object
+ */
+ private Distro instantiateCobblerDistro(CobblerConnection conn, Distribution distribution, String repoName,
+ String rootUrl) {
+
+ Distro cobblerDistro;
+ String distroRootUrl = rootUrl + repoName + "/distributions/" + distribution.getLabel();
+ String kernel = distroRootUrl + "/images/pxeboot/vmlinuz"; // TODO what about other arches
+ String initrd = distroRootUrl + "/images/pxeboot/initrd.img"; // TODO what about other arches
+ String ksTree = distroRootUrl;
+
+ cobblerDistro = new Distro(conn);
+ cobblerDistro.setName(distribution.getLabel());
+ cobblerDistro.setComment(COMMENT_MARKER + " " + distribution.getLabel());
+ cobblerDistro.setKernel(kernel);
+ cobblerDistro.setInitrd(initrd);
+ Map<String, String> ksmeta = new HashMap<String, String>();
+ ksmeta.put("tree", ksTree);
+ cobblerDistro.setKsMeta(ksmeta);
+
+ return cobblerDistro;
+ }
+
@Override
public String toString() {
if (this.context == null) {
@@ -345,4 +433,13 @@ public class CobblerServerPluginComponent implements ServerPluginComponent, Cont
}
return results;
}
+
+ private boolean compareObjects(Object o1, Object o2) {
+ // this ensures we don't throw an NPE if either is null
+ if (o1 != null) {
+ return o1.equals(o2);
+ } else {
+ return o2 == null;
+ }
+ }
}
commit d56f4706b452c08dd2f3d103c10d9783499ad690
Author: Jeff Ortel <jortel(a)redhat.com>
Date: Fri Jan 22 12:51:48 2010 -0600
change rhq.server.tomcat.security.client-auth to (want) to support x.509 authorization for content via https.
diff --git a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
index cf7e575..cd6f94a 100644
--- a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
@@ -501,7 +501,7 @@ rhq.communications.multicast-detector.port=16162
# Server-side SSL Security Configuration for HTTPS thru Tomcat
# These are used for browser https: access and for incoming messages from agents over sslservlet transport
# [you cannot use ${x} variables - see https://jira.jboss.org/jira/browse/JBWEB-74]
-rhq.server.tomcat.security.client-auth-mode=false
+rhq.server.tomcat.security.client-auth-mode=want
rhq.server.tomcat.security.secure-socket-protocol=TLS
rhq.server.tomcat.security.algorithm=SunX509
rhq.server.tomcat.security.keystore.alias=RHQ
commit a61266b71bff54650bf0db559b8fe82929379610
Author: Jeff Ortel <jortel(a)redhat.com>
Date: Thu Jan 21 17:32:38 2010 -0600
Refactor x509 entitlement certificates stuff to new EntitlementManager SLSB.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
index e734083..9315cda 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
@@ -1,9 +1,5 @@
package org.rhq.core.domain.content.transfer;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
public class EntitlementCertificate {
@@ -11,34 +7,6 @@ public class EntitlementCertificate {
private String key;
/**
- * Get certificate for even numbered resource ids.
- * @return The cert.
- * @note This is a prototype hack.
- */
- public static EntitlementCertificate getOdd() {
- DummyLoader loader = new DummyLoader();
- try {
- return loader.getOdd();
- } catch (Exception ex) {
- }
- return null;
- }
-
- /**
- * Get certificate for odd numbered resource ids.
- * @return The cert.
- * @note This is a prototype hack.
- */
- public static EntitlementCertificate getEven() {
- DummyLoader loader = new DummyLoader();
- try {
- return loader.getEven();
- } catch (Exception ex) {
- }
- return null;
- }
-
- /**
*
*/
public EntitlementCertificate() {
@@ -82,32 +50,4 @@ public class EntitlementCertificate {
public void setKey(String key) {
this.key = key;
}
-}
-
-class DummyLoader {
-
- private static final String dir = "/etc/pki/yum/rhq";
-
- EntitlementCertificate getOdd() throws IOException {
- String key = read("odd.key");
- String pem = read("odd.pem");
- return new EntitlementCertificate(key, pem);
- }
-
- EntitlementCertificate getEven() throws IOException {
- String key = read("even.key");
- String pem = read("even.pem");
- return new EntitlementCertificate(key, pem);
- }
-
- private String read(String fn) throws IOException {
- String path = dir + File.separator + fn;
- File f = new File(path);
- byte[] buffer = new byte[(int) f.length()];
- BufferedInputStream istr = new BufferedInputStream(new FileInputStream(f));
- istr.read(buffer);
- String result = new String(buffer);
- istr.close();
- return result;
- }
-}
+}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
new file mode 100644
index 0000000..cb2d21d
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
@@ -0,0 +1,93 @@
+package org.rhq.enterprise.server.content;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Stateless;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
+import org.rhq.enterprise.server.authz.RequiredPermission;
+
+@Stateless
+public class EntitlementManagerBean implements EntitlementManagerLocal, EntitlementManagerRemote {
+
+ private final Log log = LogFactory.getLog(EntitlementManagerBean.class);
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
+ List<EntitlementCertificate> list = new ArrayList<EntitlementCertificate>();
+ if (resourceId % 2 == 0) {
+ list.add(getEven());
+ } else {
+ list.add(getOdd());
+ }
+ return list;
+ }
+
+ /**
+ * Get certificate for even numbered resource ids.
+ * @return The cert.
+ * @note This is a prototype hack.
+ */
+ private EntitlementCertificate getOdd() {
+ DummyLoader loader = new DummyLoader();
+ try {
+ return loader.getOdd();
+ } catch (Exception ex) {
+ log.error("Certificate (ODD), not-found", ex);
+ }
+ return null;
+ }
+
+ /**
+ * Get certificate for odd numbered resource ids.
+ * @return The cert.
+ * @note This is a prototype hack.
+ */
+ private EntitlementCertificate getEven() {
+ DummyLoader loader = new DummyLoader();
+ try {
+ return loader.getEven();
+ } catch (Exception ex) {
+ log.error("Certificate (EVEN), not-found", ex);
+ }
+ return null;
+ }
+}
+
+class DummyLoader {
+
+ private static final String dir = "/etc/pki/yum/rhq";
+
+ EntitlementCertificate getOdd() throws IOException {
+ String key = read("odd.key");
+ String pem = read("odd.pem");
+ return new EntitlementCertificate(key, pem);
+ }
+
+ EntitlementCertificate getEven() throws IOException {
+ String key = read("even.key");
+ String pem = read("even.pem");
+ return new EntitlementCertificate(key, pem);
+ }
+
+ private String read(String fn) throws IOException {
+ String path = dir + File.separator + fn;
+ File f = new File(path);
+ byte[] buffer = new byte[(int) f.length()];
+ BufferedInputStream istr = new BufferedInputStream(new FileInputStream(f));
+ istr.read(buffer);
+ String result = new String(buffer);
+ istr.close();
+ return result;
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerLocal.java
new file mode 100644
index 0000000..8fe2554
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerLocal.java
@@ -0,0 +1,25 @@
+package org.rhq.enterprise.server.content;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
+
+/**
+ *
+ * @author jortel
+ *
+ */
+@Local
+public interface EntitlementManagerLocal {
+
+ /**
+ * Get a list of entitlement certificates for the specified resources.
+ * @param subject The logged in user's subject.
+ * @param resourceId The resource id.
+ * @return A list of certificates.
+ */
+ List<EntitlementCertificate> getCertificates(Subject subject, int resourceId);
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerRemote.java
new file mode 100644
index 0000000..16f1a0a
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerRemote.java
@@ -0,0 +1,29 @@
+package org.rhq.enterprise.server.content;
+
+import java.util.List;
+
+import javax.ejb.Remote;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
+import org.rhq.enterprise.server.system.ServerVersion;
+
+@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
+@WebService(targetNamespace = ServerVersion.namespace)
+@Remote
+public interface EntitlementManagerRemote {
+ /**
+ * Get a list of entitlement certificates for the specified resources.
+ * @param subject The logged in user's subject.
+ * @param resourceId The resource id.
+ * @return A list of certificates.
+ */
+ @WebMethod
+ List<EntitlementCertificate> getCertificates( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "resourceId") int resourceId);
+}
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 4c5177c..f819aa0 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
@@ -60,7 +60,6 @@ import org.rhq.core.domain.content.RepoRepoRelationship;
import org.rhq.core.domain.content.RepoSyncResults;
import org.rhq.core.domain.content.ResourceRepo;
import org.rhq.core.domain.content.composite.RepoComposite;
-import org.rhq.core.domain.content.transfer.EntitlementCertificate;
import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
@@ -245,17 +244,6 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
return list;
}
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
- List<EntitlementCertificate> list = new ArrayList<EntitlementCertificate>();
- if (resourceId % 2 == 0) {
- list.add(EntitlementCertificate.getEven());
- } else {
- list.add(EntitlementCertificate.getOdd());
- }
- return list;
- }
-
@SuppressWarnings("unchecked")
@RequiredPermission(Permission.MANAGE_INVENTORY)
public PageList<RepoComposite> findAvailableResourceSubscriptions(Subject subject, int resourceId, PageControl pc) {
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 187021d..aea0ef2 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
@@ -32,7 +32,6 @@ import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
import org.rhq.core.domain.content.RepoSyncResults;
import org.rhq.core.domain.content.composite.RepoComposite;
-import org.rhq.core.domain.content.transfer.EntitlementCertificate;
import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
@@ -389,12 +388,4 @@ public interface RepoManagerLocal {
* @return
*/
List<SubscribedRepo> findSubscriptions(Subject subject, int resourceId);
-
- /**
- * Get a list of entitlement certificates for the specified resources.
- * @param subject The logged in user's subject.
- * @param resourceId The resource id.
- * @return
- */
- List<EntitlementCertificate> getCertificates(Subject subject, int resourceId);
}
\ 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 6aefbac..0acbced 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
@@ -33,7 +33,6 @@ import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
-import org.rhq.core.domain.content.transfer.EntitlementCertificate;
import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
@@ -298,15 +297,4 @@ public interface RepoManagerRemote {
List<SubscribedRepo> findSubscriptions( //
@WebParam(name = "subject") Subject subject, //
@WebParam(name = "resourceId") int resourceId);
-
- /**
- * Get a list of entitlement certificates for the specified resources.
- * @param subject The logged in user's subject.
- * @param resourceId The resource id.
- * @return
- */
- @WebMethod
- List<EntitlementCertificate> getCertificates( //
- @WebParam(name = "subject") Subject subject, //
- @WebParam(name = "resourceId") int resourceId);
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index 9d2a8aa..3188ea2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -87,6 +87,8 @@ import org.rhq.enterprise.server.content.ContentUIManagerBean;
import org.rhq.enterprise.server.content.ContentUIManagerLocal;
import org.rhq.enterprise.server.content.DistributionManagerBean;
import org.rhq.enterprise.server.content.DistributionManagerLocal;
+import org.rhq.enterprise.server.content.EntitlementManagerBean;
+import org.rhq.enterprise.server.content.EntitlementManagerLocal;
import org.rhq.enterprise.server.content.RepoManagerBean;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.content.metadata.ContentSourceMetadataManagerBean;
@@ -426,6 +428,10 @@ public final class LookupUtil {
return lookupLocal(RepoManagerBean.class);
}
+ public static EntitlementManagerLocal getEntitlementManager() {
+ return lookupLocal(EntitlementManagerBean.class);
+ }
+
public static DistributionManagerLocal getDistributionManagerLocal() {
return lookupLocal(DistributionManagerBean.class);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 479f8b3..698621d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -117,6 +117,7 @@ import org.rhq.enterprise.server.content.AdvisoryManagerLocal;
import org.rhq.enterprise.server.content.ContentManagerLocal;
import org.rhq.enterprise.server.content.DistributionException;
import org.rhq.enterprise.server.content.DistributionManagerLocal;
+import org.rhq.enterprise.server.content.EntitlementManagerLocal;
import org.rhq.enterprise.server.content.RepoException;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
@@ -195,13 +196,13 @@ public class WebservicesManagerBean implements WebservicesRemote {
private SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
private SupportManagerLocal supportManager = LookupUtil.getSupportManager();
private SystemManagerLocal systemManager = LookupUtil.getSystemManager();
+ private EntitlementManagerLocal entitlementManager = LookupUtil.getEntitlementManager();
//ADVISORYMANAGER: BEGIN ------------------------------------------
public Advisory createAdvisory(@WebParam(name = "subject") Subject user,
- @WebParam(name = "advisory") String advisory,
- @WebParam(name = "advisoryType") String advisoryType,
- @WebParam(name = "advisoryName") String advisoryName) throws AdvisoryException {
+ @WebParam(name = "advisory") String advisory, @WebParam(name = "advisoryType") String advisoryType,
+ @WebParam(name = "advisoryName") String advisoryName) throws AdvisoryException {
return advisoryManager.createAdvisory(user, advisory, advisoryType, advisoryName);
}
@@ -211,14 +212,13 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public AdvisoryCVE createAdvisoryCVE(@WebParam(name = "subject") Subject user,
- @WebParam(name = "advisory") Advisory advisory,
- @WebParam(name = "cve") CVE cve) throws AdvisoryException {
+ @WebParam(name = "advisory") Advisory advisory, @WebParam(name = "cve") CVE cve) throws AdvisoryException {
return advisoryManager.createAdvisoryCVE(user, advisory, cve);
}
public AdvisoryPackage createAdvisoryPackage(@WebParam(name = "subject") Subject user,
- @WebParam(name = "advisory") Advisory advisory,
- @WebParam(name = "pkg") PackageVersion pkg) throws AdvisoryException {
+ @WebParam(name = "advisory") Advisory advisory, @WebParam(name = "pkg") PackageVersion pkg)
+ throws AdvisoryException {
return advisoryManager.createAdvisoryPackage(user, advisory, pkg);
}
@@ -234,8 +234,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
advisoryManager.deleteAdvisoryCVE(user, advId);
}
- public void deleteAdvisoryByAdvId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "advId") int advId) {
+ public void deleteAdvisoryByAdvId(@WebParam(name = "subject") Subject subject, @WebParam(name = "advId") int advId) {
advisoryManager.deleteAdvisoryByAdvId(subject, advId);
}
@@ -244,25 +243,22 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public List<AdvisoryPackage> findPackageByAdvisory(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "advId") int advId,
- @WebParam(name = "pc") PageControl pc) {
+ @WebParam(name = "advId") int advId, @WebParam(name = "pc") PageControl pc) {
return advisoryManager.findPackageByAdvisory(subject, advId, pc);
}
public PackageVersion findPackageVersionByPkgId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "rpmName") String rpmName,
- @WebParam(name = "pc") PageControl pc) {
+ @WebParam(name = "rpmName") String rpmName, @WebParam(name = "pc") PageControl pc) {
return advisoryManager.findPackageVersionByPkgId(subject, rpmName, pc);
}
public PageList<AdvisoryCVE> getAdvisoryCVEByAdvId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "advId") int advId,
- @WebParam(name = "pc") PageControl pc) {
+ @WebParam(name = "advId") int advId, @WebParam(name = "pc") PageControl pc) {
return advisoryManager.getAdvisoryCVEByAdvId(subject, advId, pc);
}
public List<AdvisoryBuglist> getAdvisoryBuglistByAdvId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "advId") int advId) {
+ @WebParam(name = "advId") int advId) {
return advisoryManager.getAdvisoryBuglistByAdvId(subject, advId);
}
@@ -275,14 +271,12 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public AdvisoryPackage findAdvisoryPackage(@WebParam(name = "subject") Subject overlord,
- @WebParam(name = "advId") int advId,
- @WebParam(name = "pkgVerId") int pkgVerId) {
+ @WebParam(name = "advId") int advId, @WebParam(name = "pkgVerId") int pkgVerId) {
return advisoryManager.findAdvisoryPackage(overlord, advId, pkgVerId);
}
public AdvisoryBuglist getAdvisoryBuglist(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "advId") int advId,
- @WebParam(name = "buginfo") String buginfo) {
+ @WebParam(name = "advId") int advId, @WebParam(name = "buginfo") String buginfo) {
return advisoryManager.getAdvisoryBuglist(subject, advId, buginfo);
}
@@ -571,7 +565,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public void deleteDistributionFilesByDistId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "distid") int distid) {
+ @WebParam(name = "distid") int distid) {
distributionManager.deleteDistributionByDistId(subject, distid);
}
@@ -588,20 +582,18 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public void deleteDistributionByDistId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "distId") int distId) throws Exception {
+ @WebParam(name = "distId") int distId) throws Exception {
distributionManager.deleteDistributionByDistId(subject, distId);
}
public void deleteDistributionTypeByName(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "name") String name) {
+ @WebParam(name = "name") String name) {
distributionManager.deleteDistributionTypeByName(subject, name);
}
public Distribution createDistribution(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "kslabel") String kslabel,
- @WebParam(name = "basepath") String basepath,
- @WebParam(name = "disttype") DistributionType disttype)
- throws DistributionException {
+ @WebParam(name = "kslabel") String kslabel, @WebParam(name = "basepath") String basepath,
+ @WebParam(name = "disttype") DistributionType disttype) throws DistributionException {
return distributionManager.createDistribution(subject, kslabel, basepath, disttype);
}
@@ -1082,6 +1074,6 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
- return repoManager.getCertificates(subject, resourceId);
+ return entitlementManager.getCertificates(subject, resourceId);
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
index 13f89df..86d48cf 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
@@ -12,6 +12,7 @@ import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
import org.rhq.enterprise.server.content.AdvisoryManagerRemote;
import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.DistributionManagerRemote;
+import org.rhq.enterprise.server.content.EntitlementManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
@@ -42,6 +43,7 @@ public interface WebservicesRemote extends //
AvailabilityManagerRemote,//
CallTimeDataManagerRemote,//
RepoManagerRemote,//
+ EntitlementManagerRemote, //
ConfigurationManagerRemote,//
ContentManagerRemote,//
//Removed as it was problematic for WS clients. Not sure if this well be re-enabled.
commit 554db9caf1534b8fe23fb5d00cfd399e02891ff8
Author: Jeff Ortel <jortel(a)redhat.com>
Date: Thu Jan 21 16:30:27 2010 -0600
x509 entitlement prototype.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
new file mode 100644
index 0000000..e734083
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
@@ -0,0 +1,113 @@
+package org.rhq.core.domain.content.transfer;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+public class EntitlementCertificate {
+
+ private String certificate;
+ private String key;
+
+ /**
+ * Get certificate for even numbered resource ids.
+ * @return The cert.
+ * @note This is a prototype hack.
+ */
+ public static EntitlementCertificate getOdd() {
+ DummyLoader loader = new DummyLoader();
+ try {
+ return loader.getOdd();
+ } catch (Exception ex) {
+ }
+ return null;
+ }
+
+ /**
+ * Get certificate for odd numbered resource ids.
+ * @return The cert.
+ * @note This is a prototype hack.
+ */
+ public static EntitlementCertificate getEven() {
+ DummyLoader loader = new DummyLoader();
+ try {
+ return loader.getEven();
+ } catch (Exception ex) {
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ public EntitlementCertificate() {
+
+ }
+
+ /**
+ *
+ * @param certificate
+ * @param key
+ */
+ public EntitlementCertificate(String certificate, String key) {
+ this.certificate = certificate;
+ this.key = key;
+ }
+
+ /**
+ * @return the certificate
+ */
+ public String getCertificate() {
+ return certificate;
+ }
+
+ /**
+ * @param certificate the certificate to set
+ */
+ public void setCertificate(String certificate) {
+ this.certificate = certificate;
+ }
+
+ /**
+ * @return the private key
+ */
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * @param key the private key to set
+ */
+ public void setKey(String key) {
+ this.key = key;
+ }
+}
+
+class DummyLoader {
+
+ private static final String dir = "/etc/pki/yum/rhq";
+
+ EntitlementCertificate getOdd() throws IOException {
+ String key = read("odd.key");
+ String pem = read("odd.pem");
+ return new EntitlementCertificate(key, pem);
+ }
+
+ EntitlementCertificate getEven() throws IOException {
+ String key = read("even.key");
+ String pem = read("even.pem");
+ return new EntitlementCertificate(key, pem);
+ }
+
+ private String read(String fn) throws IOException {
+ String path = dir + File.separator + fn;
+ File f = new File(path);
+ byte[] buffer = new byte[(int) f.length()];
+ BufferedInputStream istr = new BufferedInputStream(new FileInputStream(f));
+ istr.read(buffer);
+ String result = new String(buffer);
+ istr.close();
+ return result;
+ }
+}
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java
new file mode 100644
index 0000000..46b5119
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java
@@ -0,0 +1,36 @@
+package org.rhq.gui.content;
+
+import java.security.cert.X509Extension;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class ContentFilter {
+
+ static final String CERTS = "javax.servlet.request.X509Certificate";
+
+ void filter(HttpServletRequest request, int repoId) throws EntitlementException {
+ X509Extension[] certificates = (X509Extension[]) request.getAttribute(CERTS);
+ if (certificates == null) {
+ throw new EntitlementException("client x.509 cert not passed");
+ }
+ String oid = objectIdentifier(repoId);
+ for (X509Extension x509 : certificates) {
+ byte[] bytes = x509.getExtensionValue(oid);
+ if (bytes != null) {
+ return;
+ }
+ }
+ throw new EntitlementException("oid (" + oid + ") not found");
+ }
+
+ private String objectIdentifier(int repoId) {
+ String idstr = String.valueOf(repoId);
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < idstr.length(); i++) {
+ if (i > 0)
+ sb.append('.');
+ sb.append(idstr.charAt(i));
+ }
+ return sb.toString();
+ }
+}
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
index d883f19..cfcf1ec 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -51,6 +51,11 @@ import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
public class ContentHTTPServlet extends DefaultServlet {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
private final Log log = LogFactory.getLog(ContentHTTPServlet.class);
protected static final String CONTENT_URI = "/content/";
@@ -124,6 +129,15 @@ public class ContentHTTPServlet extends DefaultServlet {
renderRepoList(request, response);
return;
}
+
+ // validate entitlement
+ try {
+ ContentFilter x509Filter = new ContentFilter();
+ x509Filter.filter(request, repo.getId());
+ } catch (EntitlementException e) {
+ throw new ServletException(e);
+ }
+
// Check if type of content has been specified
String typeOfContent = getTypeOfContent(request.getRequestURI());
if (StringUtils.isBlank(typeOfContent)) {
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/EntitlementException.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/EntitlementException.java
new file mode 100644
index 0000000..59b1e4c
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/EntitlementException.java
@@ -0,0 +1,62 @@
+/*
+ * 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.gui.content;
+
+/**
+ * @author jortel
+ *
+ */
+public class EntitlementException extends Exception {
+
+ public static final long serialVersionUID = 0L;
+
+ /**
+ *
+ */
+ public EntitlementException() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ */
+ public EntitlementException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param cause
+ */
+ public EntitlementException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public EntitlementException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
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 d6b8e12..4c5177c 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
@@ -60,6 +60,7 @@ import org.rhq.core.domain.content.RepoRepoRelationship;
import org.rhq.core.domain.content.RepoSyncResults;
import org.rhq.core.domain.content.ResourceRepo;
import org.rhq.core.domain.content.composite.RepoComposite;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
@@ -233,8 +234,9 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
}
@RequiredPermission(Permission.MANAGE_INVENTORY)
- public PageList<SubscribedRepo> findSubscriptions(Subject subject, int resourceId, PageControl pc) {
- PageList<SubscribedRepo> list = new PageList<SubscribedRepo>();
+ public List<SubscribedRepo> findSubscriptions(Subject subject, int resourceId) {
+ List<SubscribedRepo> list = new ArrayList<SubscribedRepo>();
+ PageControl pc = new PageControl();
for (RepoComposite repoComposite : findResourceSubscriptions(subject, resourceId, pc)) {
Repo repo = repoComposite.getRepo();
SubscribedRepo summary = new SubscribedRepo(repo.getId(), repo.getName());
@@ -243,6 +245,17 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
return list;
}
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
+ List<EntitlementCertificate> list = new ArrayList<EntitlementCertificate>();
+ if (resourceId % 2 == 0) {
+ list.add(EntitlementCertificate.getEven());
+ } else {
+ list.add(EntitlementCertificate.getOdd());
+ }
+ return list;
+ }
+
@SuppressWarnings("unchecked")
@RequiredPermission(Permission.MANAGE_INVENTORY)
public PageList<RepoComposite> findAvailableResourceSubscriptions(Subject subject, int resourceId, PageControl pc) {
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 b2cf635..187021d 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
@@ -32,6 +32,7 @@ import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
import org.rhq.core.domain.content.RepoSyncResults;
import org.rhq.core.domain.content.composite.RepoComposite;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
@@ -64,15 +65,6 @@ public interface RepoManagerLocal {
PageList<RepoComposite> findResourceSubscriptions(Subject subject, int resourceId, PageControl pc);
/**
- * Gets all repos that are subscribed to by the given resource.
- * @param subject
- * @param resourceId
- * @param pc
- * @return
- */
- PageList<SubscribedRepo> findSubscriptions(Subject subject, int resourceId, PageControl pc);
-
- /**
* Gets all repos that aren't subscribed to for the given resource.
*
* @param subject
@@ -390,4 +382,19 @@ public interface RepoManagerLocal {
*/
RepoSyncResults getMostRecentSyncResults(Subject subject, int repoId);
+ /**
+ * Gets all repos that are subscribed to by the given resource.
+ * @param subject
+ * @param resourceId
+ * @return
+ */
+ List<SubscribedRepo> findSubscriptions(Subject subject, int resourceId);
+
+ /**
+ * Get a list of entitlement certificates for the specified resources.
+ * @param subject The logged in user's subject.
+ * @param resourceId The resource id.
+ * @return
+ */
+ List<EntitlementCertificate> getCertificates(Subject subject, int resourceId);
}
\ 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 3ff4f3a..6aefbac 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
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.server.content;
+import java.util.List;
+
import javax.ejb.Remote;
import javax.jws.WebMethod;
import javax.jws.WebParam;
@@ -31,6 +33,7 @@ import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
@@ -284,9 +287,26 @@ public interface RepoManagerRemote {
int synchronizeRepos(@WebParam(name = "subject") Subject subject, @WebParam(name = "repoIds") Integer[] repoIds)
throws Exception;
+ /**
+ * Get a list of truncated Repo objects that represent the
+ * subscriptions for the specified resource.
+ * @param subject The logged in user's subject.
+ * @param resourceId The id of the resource.
+ * @return A list of repos.
+ */
@WebMethod
- PageList<SubscribedRepo> findSubscriptions( //
+ List<SubscribedRepo> findSubscriptions( //
@WebParam(name = "subject") Subject subject, //
- @WebParam(name = "resourceId") int resourceId, //
- @WebParam(name = "resource") PageControl pc);
+ @WebParam(name = "resourceId") int resourceId);
+
+ /**
+ * Get a list of entitlement certificates for the specified resources.
+ * @param subject The logged in user's subject.
+ * @param resourceId The resource id.
+ * @return
+ */
+ @WebMethod
+ List<EntitlementCertificate> getCertificates( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "resourceId") int resourceId);
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index e737c2d..479f8b3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -62,6 +62,7 @@ import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.AlertCriteria;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
@@ -1076,8 +1077,11 @@ public class WebservicesManagerBean implements WebservicesRemote {
return repoManager.findAssociatedAdvisory(subject, repoId, pc);
}
- public PageList<SubscribedRepo> findSubscriptions(Subject subject, int resourceId,
- PageControl pc) {
- return repoManager.findSubscriptions(subject, resourceId, pc);
+ public List<SubscribedRepo> findSubscriptions(Subject subject, int resourceId) {
+ return repoManager.findSubscriptions(subject, resourceId);
+ }
+
+ public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
+ return repoManager.getCertificates(subject, resourceId);
}
}
commit d26acbd2712dbc9c8aca733294bac653ba95142a
Author: Sayli Karmarkar <skarmark(a)redhat.com>
Date: Fri Jan 22 03:06:14 2010 -0500
Fixing issues with rendering of Content Update page for a resource
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/content-beans.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/content-beans.xml
index 8f7f449..5ab9219 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/content-beans.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/content-beans.xml
@@ -177,6 +177,11 @@
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
+ <managed-bean-name>ResourceUpdatePackageVersionsUIBean</managed-bean-name>
+ <managed-bean-class>org.rhq.enterprise.gui.content.ResourceUpdatePackageVersionsUIBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
<managed-bean-name>AvailableResourceReposUIBean</managed-bean-name>
<managed-bean-class>org.rhq.enterprise.gui.content.AvailableResourceReposUIBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/content-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/content-navigation.xml
index aa6c245..2c0f473 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/content-navigation.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/content-navigation.xml
@@ -71,6 +71,26 @@
</navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/rhq/resource/content/update.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-outcome>uploadNew</from-outcome>
+ <to-view-id>/rhq/resource/content/create.xhtml?id=#{param.id}</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-action>#{CreateNewPackageUIBean.deployExisting}</from-action>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/rhq/resource/content/confirm-create.xhtml</to-view-id>
+ </navigation-case>
+
+ </navigation-rule>
+
+
+
<navigation-rule>
<from-view-id>/rhq/resource/content/history.xhtml</from-view-id>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/update.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/update.xhtml
index 09c6e6b..aa05fee 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/update.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/update.xhtml
@@ -29,12 +29,12 @@
to enable more existing packages for deployment, use the subscriptions sub-tab to subscribe this resource
to more repositories.</p>
- <a4j:keepAlive beanName="ResourcePackageVersionsUIBean"/>
+ <a4j:keepAlive beanName="ResourceUpdatePackageVersionsUIBean"/>
- <ui:param name="resourcePackageVersionsDataModel" value="#{ResourcePackageVersionsUIBean.dataModel}"/>
- <rich:dataTable id="resourcePackageVersionsDataTable"
- rows="#{PageControl.ResourcePackageVersionsList.pageSize}"
- value="#{resourcePackageVersionsDataModel}"
+ <ui:param name="resourceUpdatePackageVersionsDataModel" value="#{ResourceUpdatePackageVersionsUIBean.dataModel}"/>
+ <rich:dataTable id="resourceUpdatePackageVersionsDataTable"
+ rows="#{PageControl.ResourceUpdatePackageVersionsList.pageSize}"
+ value="#{resourceUpdatePackageVersionsDataModel}"
var="item"
width="100%"
columnsWidth="1%, 15%, 10%, 10%, 10%, 54%"
@@ -44,7 +44,7 @@
onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
<f:facet name="PageControlView">
- <onc:paginationControl id="ResourcePackageVersionsList" />
+ <onc:paginationControl id="ResourceUpdatePackageVersionsList" />
</f:facet>
<rich:column>
@@ -115,9 +115,9 @@
rendered="${ResourceUIBean.permissions.content}"/>
<ui:include src="/rhq/resource/include/pagination.xhtml">
- <ui:param name="paginationDataTableName" value="resourcePackageVersionsDataTable"/>
- <ui:param name="paginationDataModel" value="#{resourcePackageVersionsDataModel}"/>
- <ui:param name="paginationPageControl" value="#{PageControl.ResourcePackageVersionsList}"/>
+ <ui:param name="paginationDataTableName" value="resourceUpdatePackageVersionsDataTable"/>
+ <ui:param name="paginationDataModel" value="#{resourceUpdatePackageVersionsDataModel}"/>
+ <ui:param name="paginationPageControl" value="#{PageControl.ResourceUpdatePackageVersionsList}"/>
</ui:include>
</rich:column>
</rich:columnGroup>
@@ -126,9 +126,26 @@
</rich:dataTable>
+ </rich:panel>
+
+ <rich:panel styleClass="BlockContent"
+ rendered="${ResourceUIBean.permissions.content}">
+ <f:facet name="header"><h:outputText value="Upload New Package"/></f:facet>
+
+ <p>The following option will begin the workflow to upload a new package into the system. Once
+ the package information has been specified and the file uploaded, the workflow to deploy the newly
+ created package to this resource will resume.</p>
+
+ <h:panelGrid columns="1" styleClass="buttons-table" columnClasses="button-cell">
+ <h:commandButton action="uploadNew"
+ value="UPLOAD NEW PACKAGE" styleClass="buttonmed"/>
+ </h:panelGrid>
+
+ <br/>
</rich:panel>
- </h:form>
+
+ </h:form>
</ui:define>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
index 3d72055..e003579 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
@@ -225,15 +225,15 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
public PageList<PackageVersionComposite> getPackageVersionCompositesByFilter(Subject user, int resourceId,
String filter, PageControl pc) {
pc.initDefaultOrderingField("pv.generalPackage.name", PageOrdering.ASC);
+ PageControl unlimitedpc = PageControl.getUnlimitedInstance();
Query queryInstalled = PersistenceUtility.createQueryWithOrderBy(entityManager,
- InstalledPackage.QUERY_FIND_PACKAGE_LIST_ITEM_COMPOSITE, pc);
+ InstalledPackage.QUERY_FIND_PACKAGE_LIST_ITEM_COMPOSITE, unlimitedpc);
queryInstalled.setParameter("resourceId", resourceId);
queryInstalled.setParameter("packageTypeFilterId", null);
queryInstalled.setParameter("packageVersionFilter", null);
queryInstalled.setParameter("search", null);
- queryInstalled.setParameter("search", null);
List<PackageListItemComposite> packagesInstalled = queryInstalled.getResultList();
@@ -243,7 +243,7 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
}
Query query = PersistenceUtility.createQueryWithOrderBy(entityManager,
- PackageVersion.QUERY_FIND_COMPOSITE_BY_FILTERS, pc);
+ PackageVersion.QUERY_FIND_COMPOSITE_BY_FILTERS, unlimitedpc);
Query queryCount = PersistenceUtility.createCountQuery(entityManager,
PackageVersion.QUERY_FIND_COMPOSITE_BY_FILTERS);
@@ -273,15 +273,15 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
public PageList<PackageVersionComposite> getUpdatePackageVersionCompositesByFilter(Subject user, int resourceId,
String filter, PageControl pc) {
pc.initDefaultOrderingField("pv.generalPackage.name", PageOrdering.ASC);
+ PageControl unlimitedpc = PageControl.getUnlimitedInstance();
Query queryInstalled = PersistenceUtility.createQueryWithOrderBy(entityManager,
- InstalledPackage.QUERY_FIND_PACKAGE_LIST_ITEM_COMPOSITE, pc);
+ InstalledPackage.QUERY_FIND_PACKAGE_LIST_ITEM_COMPOSITE, unlimitedpc);
queryInstalled.setParameter("resourceId", resourceId);
queryInstalled.setParameter("packageTypeFilterId", null);
queryInstalled.setParameter("packageVersionFilter", null);
queryInstalled.setParameter("search", null);
- queryInstalled.setParameter("search", null);
List<PackageListItemComposite> packagesInstalled = queryInstalled.getResultList();
@@ -291,7 +291,7 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
}
Query query = PersistenceUtility.createQueryWithOrderBy(entityManager,
- PackageVersion.QUERY_FIND_COMPOSITE_BY_FILTERS, pc);
+ PackageVersion.QUERY_FIND_COMPOSITE_BY_FILTERS, unlimitedpc);
query.setParameter("resourceId", resourceId);
query.setParameter("filter", filter);
@@ -303,7 +303,7 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
for (PackageVersionComposite result : results) {
if (installedPackageNameAndVersion.get(result.getPackageName()) != null) {
- packageName = installedPackageNameAndVersion.get(result.getPackageName());
+ packageName = result.getPackageName();
if (installedPackageNameAndVersion.get(packageName).compareTo(result.getPackageVersion().getVersion()) < 0) {
modifiedResults.add(result);
diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java
index d04210e..74cc8b7 100644
--- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java
+++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java
@@ -101,12 +101,14 @@ public class RpmPackageDiscoveryDelegate {
BufferedReader rpmNameReader = new BufferedReader(new StringReader(capturedOutput));
String rpmName;
+
while ((rpmName = rpmNameReader.readLine()) != null) {
String name = null;
String version = null;
String architectureName = null;
try {
+
// Execute RPM query for each RPM
ProcessExecution rpmQuery = new ProcessExecution(rpmExecutable);
rpmQuery
@@ -179,8 +181,10 @@ public class RpmPackageDiscoveryDelegate {
log.error("Error creating resource package. RPM Name: " + rpmName + " Version: " + version
+ " Architecture: " + architectureName);
}
+
}
return packages;
+
}
-}
\ No newline at end of file
+}
commit 9107582e81396907000a5b255ab5e8afed53ef08
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Thu Jan 21 17:21:01 2010 -0800
1374 - bugfixes, cleanup
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
index a710a22..cdf7b25 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
@@ -24,6 +24,7 @@ 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.ContentSyncStatus;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.content.RepoSyncResults;
import org.rhq.core.gui.util.FacesContextUtility;
@@ -47,6 +48,19 @@ public class RepoDetailsUIBean {
return "edit";
}
+ public boolean getShowProgressBar() {
+ String syncStatus = getSyncStatus();
+ if (!syncStatus.equals(ContentSyncStatus.SUCCESS.toString())
+ && !syncStatus.equals(ContentSyncStatus.FAILURE.toString())
+ && !syncStatus.equals(ContentSyncStatus.NONE.toString())
+ && !syncStatus.equals(ContentSyncStatus.CANCELLED.toString())
+ && !syncStatus.equals(ContentSyncStatus.CANCELLING.toString())) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
public String getSyncStatus() {
Subject subject = EnterpriseFacesContextUtility.getSubject();
Integer id = FacesContextUtility.getRequiredRequestParameter("id", Integer.class);
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
index 7e9070f..5f93c10 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
@@ -107,19 +107,39 @@
</c:otherwise>
</c:choose></td>
</tr>
+ <!--
<tr>
- <td align="right"><b>Synchronization Complete:</b></td>
- <td align="left"><rich:progressBar
- value="#{RepoDetailsUIBean.percentComplete}"
- label="#{RepoDetailsUIBean.percentComplete} %"
- interval="999" minValue="0" maxValue="99">
- <f:facet name="complete">
- <h:outputText value="Synchronizing Complete" />
- </f:facet>
- <f:facet name="initial">
- <h:outputText value="Synching Not Started" />
- </f:facet>
- </rich:progressBar></td>
+ <td align="right"><b>Raw Percentage :</b></td>
+ <td align="left">
+ <a4j:region>
+ <a4j:poll id="percentPoll" interval="1005"
+ reRender="syncPercent" />
+ <h:outputText id="syncPercent"
+ value="#{RepoDetailsUIBean.percentComplete}" />
+ </a4j:region>
+ </td>
+ </tr>
+ -->
+ <tr>
+ <td align="right"><b>Synchronization Progress:</b></td>
+ <td align="left">
+ <c:choose>
+ <c:when
+ test="#{RepoDetailsUIBean.showProgressBar}">
+ <rich:progressBar
+ value="#{RepoDetailsUIBean.percentComplete}"
+ label="#{RepoDetailsUIBean.percentComplete} %"
+ interval="999" minValue="-1" maxValue="99">
+ <f:facet name="complete">
+ <h:outputText value="Synchronizing Complete" />
+ </f:facet>
+ </rich:progressBar>
+ </c:when>
+ <c:otherwise>
+ Not Synching
+ </c:otherwise>
+ </c:choose>
+ </td>
</tr>
<tr>
<td align="right"><b>Synchronization Results:</b></td>
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 4a40b72..21fac03 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
@@ -288,6 +288,7 @@ public class ContentProviderManager {
tracker.setResults(progress.toString());
tracker.setRepoSyncResults(repoManager.persistRepoSyncResults(tracker.getRepoSyncResults()));
log.debug("synchronizeRepo :: inProgress");
+ tracker = updatePercentComplete(tracker, repoManager);
if (tracker.getRepoSyncResults() == null) {
log.info("Repository [" + repo.getName()
commit 6022accd62237d7cd48926fabf7b1b650cf4b608
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jan 21 18:03:56 2010 -0500
create distros using the proper distro tree ks metadata entry
diff --git a/modules/enterprise/server/plugins/cobbler/src/main/java/org/rhq/enterprise/server/plugins/cobbler/CobblerServerPluginComponent.java b/modules/enterprise/server/plugins/cobbler/src/main/java/org/rhq/enterprise/server/plugins/cobbler/CobblerServerPluginComponent.java
index 4705bbd..30537c5 100644
--- a/modules/enterprise/server/plugins/cobbler/src/main/java/org/rhq/enterprise/server/plugins/cobbler/CobblerServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/cobbler/src/main/java/org/rhq/enterprise/server/plugins/cobbler/CobblerServerPluginComponent.java
@@ -55,8 +55,19 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class CobblerServerPluginComponent implements ServerPluginComponent, ControlFacet {
private static Log log = LogFactory.getLog(CobblerServerPluginComponent.class);
+ /**
+ * This string is placed at the start of all distro comments created in Cobbler.
+ * When we see this marker at the start of a distro comment, we know its a distro we created.
+ */
+ private static final String COMMENT_MARKER = "[rhq]";
+
private ServerPluginContext context;
+ /**
+ * Used to avoid having an operation running at the same time as a sync.
+ */
+ private boolean syncInProgress;
+
public void initialize(ServerPluginContext context) throws Exception {
this.context = context;
log.info("initialized: " + this);
@@ -77,53 +88,76 @@ public class CobblerServerPluginComponent implements ServerPluginComponent, Cont
public ControlResults invoke(String name, Configuration parameters) {
ControlResults controlResults = new ControlResults();
- if (name.equals("getCobblerDistros")) {
- String searchRegex = parameters.getSimpleValue("searchRegex", null);
- Pattern pattern = null;
- if (searchRegex != null) {
- pattern = Pattern.compile(searchRegex);
- }
+ try {
+ if (name.equals("getCobblerDistros")) {
+ String searchRegex = parameters.getSimpleValue("searchRegex", null);
+ Pattern pattern = null;
+ if (searchRegex != null) {
+ pattern = Pattern.compile(searchRegex);
+ }
- Configuration results = controlResults.getComplexResults();
- PropertyList list = new PropertyList("distros");
- results.put(list);
-
- Collection<Distro> distros = getAllCobblerDistros().values();
- for (Distro d : distros) {
- if (pattern == null || pattern.matcher(d.getName()).matches()) {
- PropertyMap map = new PropertyMap("distro");
- map.put(new PropertySimple("name", d.getName()));
- map.put(new PropertySimple("breed", d.getBreed()));
- map.put(new PropertySimple("osversion", d.getOsVersion()));
- map.put(new PropertySimple("arch", d.getArch()));
- map.put(new PropertySimple("initrd", d.getInitrd()));
- map.put(new PropertySimple("kernel", d.getKernel()));
- list.add(map);
+ Configuration results = controlResults.getComplexResults();
+ PropertyList list = new PropertyList("distros");
+ results.put(list);
+
+ Collection<Distro> distros = getAllCobblerDistros().values();
+ for (Distro d : distros) {
+ if (pattern == null || pattern.matcher(d.getName()).matches()) {
+ PropertyMap map = new PropertyMap("distro");
+ map.put(new PropertySimple("name", d.getName()));
+ map.put(new PropertySimple("breed", d.getBreed()));
+ map.put(new PropertySimple("osversion", d.getOsVersion()));
+ map.put(new PropertySimple("arch", d.getArch()));
+ map.put(new PropertySimple("initrd", d.getInitrd()));
+ map.put(new PropertySimple("kernel", d.getKernel()));
+ list.add(map);
+ }
+ }
+ } else if (name.equals("getCobblerProfiles")) {
+ String searchRegex = parameters.getSimpleValue("searchRegex", null);
+ Pattern pattern = null;
+ if (searchRegex != null) {
+ pattern = Pattern.compile(searchRegex);
}
- }
- } else if (name.equals("getCobblerProfiles")) {
- String searchRegex = parameters.getSimpleValue("searchRegex", null);
- Pattern pattern = null;
- if (searchRegex != null) {
- pattern = Pattern.compile(searchRegex);
- }
- Configuration results = controlResults.getComplexResults();
- PropertyList list = new PropertyList("profiles");
- results.put(list);
-
- List<Profile> profiles = getAllCobblerProfiles();
- for (Profile p : profiles) {
- if (pattern == null || pattern.matcher(p.getName()).matches()) {
- PropertyMap map = new PropertyMap("profile");
- map.put(new PropertySimple("name", p.getName()));
- map.put(new PropertySimple("distro", p.getDistro()));
- map.put(new PropertySimple("kickstart", p.getKickstart()));
- list.add(map);
+ Configuration results = controlResults.getComplexResults();
+ PropertyList list = new PropertyList("profiles");
+ results.put(list);
+
+ List<Profile> profiles = getAllCobblerProfiles();
+ for (Profile p : profiles) {
+ if (pattern == null || pattern.matcher(p.getName()).matches()) {
+ PropertyMap map = new PropertyMap("profile");
+ map.put(new PropertySimple("name", p.getName()));
+ map.put(new PropertySimple("distro", p.getDistro()));
+ map.put(new PropertySimple("kickstart", p.getKickstart()));
+ list.add(map);
+ }
+ }
+ } else if (name.equals("removeCobblerDistros")) {
+ String searchRegex = parameters.getSimpleValue("searchRegex", null);
+ Pattern pattern = null;
+ if (searchRegex != null) {
+ pattern = Pattern.compile(searchRegex);
}
+
+ if (!this.syncInProgress) {
+ Collection<Distro> distros = getAllCobblerDistros().values();
+ for (Distro d : distros) {
+ if (pattern == null || pattern.matcher(d.getName()).matches()) {
+ if (d.getComment().startsWith(COMMENT_MARKER)) {
+ d.remove();
+ }
+ }
+ }
+ } else {
+ controlResults.setError("A synchronize is currently in progress - please wait for it to finish");
+ }
+ } else {
+ controlResults.setError("Unknown operation name: " + name);
}
- } else {
- controlResults.setError("Unknown operation name: " + name);
+ } catch (Exception e) {
+ controlResults.setError(e);
}
return controlResults;
@@ -133,6 +167,8 @@ public class CobblerServerPluginComponent implements ServerPluginComponent, Cont
log.info("Synchronizing content to the local Cobbler server: " + this);
try {
+ this.syncInProgress = true;
+
Server server = LookupUtil.getServerManager().getServer();
String rootUrl = "http://" + server.getAddress() + ":" + server.getPort() + "/content/";
@@ -149,15 +185,15 @@ public class CobblerServerPluginComponent implements ServerPluginComponent, Cont
Distro cobblerDistro = cobblerDistros.get(distribution.getLabel());
if (cobblerDistro == null) {
+ String distroRootUrl = rootUrl + repoName + "/distributions/" + distribution.getLabel();
+
cobblerDistro = new Distro(conn);
cobblerDistro.setName(distribution.getLabel());
- cobblerDistro.setComment("[rhq] " + distribution.getLabel());
- cobblerDistro.setKernel(rootUrl + repoName + "/distributions/" + distribution.getLabel()
- + "/images/pxeboot/vmlinuz");
- cobblerDistro.setInitrd(rootUrl + repoName + "/distributions/" + distribution.getLabel()
- + "/images/pxeboot/initrd.img");
+ cobblerDistro.setComment(COMMENT_MARKER + " " + distribution.getLabel());
+ cobblerDistro.setKernel(distroRootUrl + "/images/pxeboot/vmlinuz"); // TODO what about other arches
+ cobblerDistro.setInitrd(distroRootUrl + "/images/pxeboot/initrd.img"); // TODO what about other arches
Map<String, String> ksmeta = new HashMap<String, String>();
- ksmeta.put("tree", "http://foo/releases/12/Fedora/x86_64/os/");
+ ksmeta.put("tree", distroRootUrl);
cobblerDistro.setKsMeta(ksmeta);
cobblerDistro.commit();
log.info("Added distro to Cobbler: [" + distribution.getLabel() + "]");
@@ -170,7 +206,7 @@ public class CobblerServerPluginComponent implements ServerPluginComponent, Cont
// now remove those RHQ distros that we no longer have, only remove RHQ distros though
for (Distro doomed : cobblerDistros.values()) {
- if (doomed.getComment().startsWith("[rhq]")) {
+ if (doomed.getComment().startsWith(COMMENT_MARKER)) {
doomed.remove();
log.info("Removed distro from Cobbler: [" + doomed.getName() + "]");
}
@@ -178,6 +214,8 @@ public class CobblerServerPluginComponent implements ServerPluginComponent, Cont
} catch (Throwable t) {
// TODO what should we do?
t.printStackTrace();
+ } finally {
+ this.syncInProgress = false;
}
}
diff --git a/modules/enterprise/server/plugins/cobbler/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/cobbler/src/main/resources/META-INF/rhq-serverplugin.xml
index 6121146..1bcc161 100644
--- a/modules/enterprise/server/plugins/cobbler/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/cobbler/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -46,6 +46,11 @@
</c:list-property>
</serverplugin:results>
</serverplugin:control>
+ <serverplugin:control name="removeCobblerDistros" description="Removes RHQ distros known to Cobbler. Any non-RHQ distros will remain intact.">
+ <serverplugin:parameters>
+ <c:simple-property name="searchRegex" required="false" description="If specified, only those distros whose name matches this regex will be removed" />
+ </serverplugin:parameters>
+ </serverplugin:control>
</serverplugin:plugin-component>
<serverplugin:scheduled-jobs>
commit f023dd906b540758278df9209437afb57527605e
Author: John Matthews <jmatthew(a)redhat.com>
Date: Thu Jan 21 17:01:37 2010 -0500
Fixes kickstarts through http content
- add support for HEAD requests
- urldecode the request for filenames
- add byte-range fetching through HTTP <important fix for anaconda fetching of rpm headers>
- allow package fetches to work when accessed under distribution trees
- decrease most logging to DEBUG not INFO
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
index f08964f..d883f19 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -29,6 +29,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.servlets.DefaultServlet;
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.net.URLCodec;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.text.StrTokenizer;
import org.apache.commons.logging.Log;
@@ -62,17 +64,19 @@ public class ContentHTTPServlet extends DefaultServlet {
protected ContentSourceManagerLocal contentSourceMgr;
protected DistributionManagerLocal distroMgr;
+ protected URLCodec urlCodec;
+
public ContentHTTPServlet() {
super();
}
public void init() throws ServletException {
super.init();
+ urlCodec = new URLCodec();
repoMgr = LookupUtil.getRepoManagerLocal();
contentMgr = LookupUtil.getContentManager();
contentSourceMgr = LookupUtil.getContentSourceManager();
distroMgr = LookupUtil.getDistributionManagerLocal();
- log.info("ContentHTTPServlet resolved references in init.");
}
protected boolean isIconRequest(HttpServletRequest request) {
@@ -82,11 +86,31 @@ public class ContentHTTPServlet extends DefaultServlet {
protected void doHead(HttpServletRequest request, HttpServletResponse response) throws IOException,
ServletException {
+ log.info("HEAD received: " + request.getRequestURI());
doGet(request, response);
}
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
+ ServletException {
+ log.info("POST received: " + request.getRequestURI());
+ doGet(request, response);
+ }
+
+ protected void doPut(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+ log.info("PUT received: " + request.getRequestURI());
+ renderErrorPage(request, response);
+ }
+
+ protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException,
+ ServletException {
+ log.info("DELETE received: " + request.getRequestURI());
+ renderErrorPage(request, response);
+ }
+
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
log.info("doGet(): requestURI = " + request.getRequestURI());
+ response.setHeader("Accept-Ranges", "bytes");
+
if (isIconRequest(request)) {
// this request is for our icons which are static content in the webapp
// defer back to DefaultServlet.doGet and this will be served automatically
@@ -111,16 +135,16 @@ public class ContentHTTPServlet extends DefaultServlet {
// Determine what we should render, i.e.: packages or distributions
//
if (StringUtils.equalsIgnoreCase(typeOfContent, PACKAGES)) {
- log.info("render packages");
+ log.debug("render packages");
renderPackages(request, response, repo);
return;
} else if (StringUtils.equalsIgnoreCase(typeOfContent, DISTRIBUTIONS)) {
- log.info("render distributions");
+ log.debug("render distributions");
renderDistributions(request, response, repo);
return;
} else {
- log.info("Unable to determine what type of content was requested: " + typeOfContent);
+ log.debug("Unable to determine what type of content was requested: " + typeOfContent);
renderErrorPage(request, response);
return;
}
@@ -141,15 +165,15 @@ public class ContentHTTPServlet extends DefaultServlet {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
PageList<Repo> repos = repoMgr.findRepos(overlord, PageControl.getUnlimitedInstance());
- log.info("Returned list of repos: " + repos.getTotalSize() + " entries");
+ log.debug("Returned list of repos: " + repos.getTotalSize() + " entries");
for (Repo r : repos) {
- log.info("Potential repo: Name = " + r.getName() + ", ID = " + r.getId());
+ log.debug("Potential repo: Name = " + r.getName() + ", ID = " + r.getId());
}
- log.info("TODO: generate index.html");
+ log.debug("TODO: generate index.html");
StringBuffer sb = new StringBuffer();
HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
for (Repo r : repos) {
- log.info("Potential repo: Name = " + r.getName() + ", ID = " + r.getId());
+ log.debug("Potential repo: Name = " + r.getName() + ", ID = " + r.getId());
// Skip candidate repos
if (!r.isCandidate()) {
String lastMod = new Date(r.getLastModifiedDate()).toString();
@@ -162,7 +186,6 @@ public class ContentHTTPServlet extends DefaultServlet {
protected void renderChoiceOfContent(HttpServletRequest request, HttpServletResponse response, Repo repo)
throws IOException {
- log.info("Choice of content is: {" + PACKAGES + ", " + DISTRIBUTIONS + "}");
StringBuffer sb = new StringBuffer();
HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
@@ -175,14 +198,14 @@ public class ContentHTTPServlet extends DefaultServlet {
protected void renderPackages(HttpServletRequest request, HttpServletResponse response, Repo repo)
throws IOException {
- log.info("renderPackages(repo name = " + repo.getName() + ", id = " + repo.getId() + ", isCandidate = "
+ log.debug("renderPackages(repo name = " + repo.getName() + ", id = " + repo.getId() + ", isCandidate = "
+ repo.isCandidate() + ")");
String fileName = getFileName(request.getRequestURI());
- log.info("Parsed file name = " + fileName);
+ log.debug("Parsed file name = " + fileName);
if (StringUtils.isBlank(fileName)) {
// form a directory listing for each package in repository.
- log.info("create listing of all packages for this repo: " + repo.getName());
+ log.debug("create listing of all packages for this repo: " + repo.getName());
renderPackageIndex(request, response, repo);
return;
}
@@ -196,20 +219,19 @@ public class ContentHTTPServlet extends DefaultServlet {
return;
}
- log.info("fetch package bits and return them.");
+ log.debug("fetch package bits and return them.");
PackageVersion pv = getPackageVersionFromFileName(repo, fileName);
if (pv == null) {
log.info("Unable to find PackageVersion from filename: " + fileName);
renderErrorPage(request, response);
return;
}
- response.setContentType("application/octet-stream");
- writePackageVersionBits(response.getOutputStream(), pv);
+ writePackageVersionBits(request, response, pv);
}
protected void renderPackageIndex(HttpServletRequest request, HttpServletResponse response, Repo repo)
throws IOException {
- log.info("Forming packages index.html for repo: " + repo.getName() + ", ID = " + repo.getId());
+ log.debug("Forming packages index.html for repo: " + repo.getName() + ", ID = " + repo.getId());
List<PackageVersion> pvs = repoMgr.findPackageVersionsInRepo(LookupUtil.getSubjectManager().getOverlord(), repo
.getId(), PageControl.getUnlimitedInstance());
@@ -227,7 +249,7 @@ public class ContentHTTPServlet extends DefaultServlet {
protected void renderMetadata(HttpServletRequest request, HttpServletResponse response, Repo repo)
throws IOException {
- log.info("renderMetadata(repo name = " + repo.getName() + ", id = " + repo.getId());
+ log.debug("renderMetadata(repo name = " + repo.getName() + ", id = " + repo.getId());
String metadataFilename = getMetadataFileName(request.getRequestURI());
if (StringUtils.isBlank(metadataFilename)) {
@@ -235,10 +257,10 @@ public class ContentHTTPServlet extends DefaultServlet {
return;
}
// Generate Yum Metadata
- log.info("Generate Yum Metadata for : " + metadataFilename);
+ log.debug("Generate Yum Metadata for : " + metadataFilename);
List<PackageVersion> pvs = repoMgr.findPackageVersionsInRepo(LookupUtil.getSubjectManager().getOverlord(), repo
.getId(), PageControl.getUnlimitedInstance());
- log.info(pvs.size() + " packages were found for repo : " + repo.getName());
+ log.debug(pvs.size() + " packages were found for repo : " + repo.getName());
StringBuffer sb = new StringBuffer();
if (!YumMetadata.generate(sb, repo, pvs, metadataFilename)) {
log.info("Error generating: " + metadataFilename + " for repo: " + repo.getName() + " with " + pvs.size()
@@ -251,7 +273,7 @@ public class ContentHTTPServlet extends DefaultServlet {
protected void renderMetadataIndex(HttpServletRequest request, HttpServletResponse response, Repo repo)
throws IOException {
- log.info("renderMetadataIndex(repo name = " + repo.getName() + ", id = " + repo.getId());
+ log.debug("renderMetadataIndex(repo name = " + repo.getName() + ", id = " + repo.getId());
StringBuffer sb = new StringBuffer();
HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
@@ -267,11 +289,11 @@ public class ContentHTTPServlet extends DefaultServlet {
protected void renderDistributions(HttpServletRequest request, HttpServletResponse response, Repo repo)
throws IOException {
- log.info("renderDistributions(repo name = " + repo.getName() + ", id = " + repo.getId() + ", isCandidate = "
+ log.debug("renderDistributions(repo name = " + repo.getName() + ", id = " + repo.getId() + ", isCandidate = "
+ repo.isCandidate() + ")");
String distLabel = getDistLabel(request.getRequestURI());
- log.info("Parsed dist label is = " + distLabel);
+ log.debug("Parsed dist label is = " + distLabel);
if (StringUtils.isBlank(distLabel)) {
// form a directory listing for each distribution in repository.
log.info("TODO: create index.html listing all the distribution labels for this repo: " + repo.getName());
@@ -291,7 +313,7 @@ public class ContentHTTPServlet extends DefaultServlet {
renderDistributionFileList(request, response, dist);
return;
}
- log.info("Parsed DistributionFile request is for: " + fileRequest);
+ log.debug("Parsed DistributionFile request is for: " + fileRequest);
// Looks like a request for a distribution file
List<DistributionFile> distFiles = distroMgr.getDistributionFilesByDistId(dist.getId());
if (distFiles.isEmpty()) {
@@ -300,10 +322,11 @@ public class ContentHTTPServlet extends DefaultServlet {
return;
}
for (DistributionFile dFile : distFiles) {
- log.info("Compare: " + dFile.getRelativeFilename() + " to " + fileRequest);
+ //log.info("Compare: " + dFile.getRelativeFilename() + " to " + fileRequest);
if (StringUtils.equalsIgnoreCase(dFile.getRelativeFilename(), fileRequest)) {
- response.setContentType("application/octet-stream");
- writeDistributionFileBits(response.getOutputStream(), dFile);
+ log.info("Sending back package bytes for: " + dFile.getRelativeFilename());
+
+ writeDistributionFileBits(request, response, dFile);
return;
}
}
@@ -312,12 +335,13 @@ public class ContentHTTPServlet extends DefaultServlet {
// ..../distributions/{Server,Cluster,Packages,etc}/a2ps-XXXXX.rpm
String possiblePkgName = getLastPiece(request.getRequestURI());
- log.info("Looking up : " + possiblePkgName + ", it might be a package request");
+ log.debug("Looking up : " + possiblePkgName + ", it might be a package request");
PackageVersion pv = getPackageVersionFromFileName(repo, possiblePkgName);
if (pv != null) {
log.info(possiblePkgName + " resolved to a package, will send package bytes back as response");
- response.setContentType("application/octet-stream");
- writePackageVersionBits(response.getOutputStream(), pv);
+ //response.setContentType("application/octet-stream");
+ writePackageVersionBits(request, response, pv);
+ return;
}
log.info("Searched through DistributionFiles and Packages, unable to find: " + fileRequest
+ ", in Distribution: " + dist.getLabel());
@@ -330,7 +354,7 @@ public class ContentHTTPServlet extends DefaultServlet {
Distribution dist) throws IOException {
List<DistributionFile> distFiles = distroMgr.getDistributionFilesByDistId(dist.getId());
- log.info("For Distribution label '" + dist.getLabel() + "' " + distFiles.size()
+ log.debug("For Distribution label '" + dist.getLabel() + "' " + distFiles.size()
+ " distribution files were found");
StringBuffer sb = new StringBuffer();
@@ -353,7 +377,7 @@ public class ContentHTTPServlet extends DefaultServlet {
// Get list of Distributions per repo
List<Distribution> distros = repoMgr.findAssociatedDistributions(LookupUtil.getSubjectManager().getOverlord(),
repo.getId(), PageControl.getUnlimitedInstance());
- log.info("Found " + distros.size() + " for repo " + repo.getName());
+ log.debug("Found " + distros.size() + " for repo " + repo.getName());
for (Distribution d : distros) {
log.info("Creating link for distribution label: " + d.getLabel());
HtmlRenderer.formDirEntry(sb, request, d.getLabel(), new Date(d.getLastModifiedDate()).toString());
@@ -384,7 +408,7 @@ public class ContentHTTPServlet extends DefaultServlet {
protected Repo getRepo(HttpServletRequest request, HttpServletResponse response) {
String repoName = getRepoName(request.getRequestURI());
- log.info("Parsed repo name = " + repoName);
+ log.debug("Parsed repo name = " + repoName);
List<Repo> targetRepos = repoMgr.getRepoByName(repoName);
if (targetRepos.isEmpty()) {
// Check if maybe this is the repoID passed in as an int, instead of repo name
@@ -446,7 +470,7 @@ public class ContentHTTPServlet extends DefaultServlet {
}
protected String getLastPiece(String requestURI) {
- StrTokenizer st = new StrTokenizer(requestURI, "/");
+ StrTokenizer st = new StrTokenizer(decodeURL(requestURI), "/");
List<String> tokens = st.getTokenList();
if (tokens.size() < 1) {
return "";
@@ -463,7 +487,8 @@ public class ContentHTTPServlet extends DefaultServlet {
// Goal is we find where the distribution file path starts
// then we return the entire path, it may include an unknown
// level of sub-directories.
- StrTokenizer st = new StrTokenizer(requestURI, "/");
+
+ StrTokenizer st = new StrTokenizer(decodeURL(requestURI), "/");
List<String> tokens = st.getTokenList();
if (tokens.isEmpty()) {
return "";
@@ -472,7 +497,7 @@ public class ContentHTTPServlet extends DefaultServlet {
String distFilePath = "";
for (int index = startIndex; index < tokens.size(); index++) {
distFilePath = distFilePath + "/" + tokens.get(index);
- log.info("index = " + index + ", distFilePath = " + distFilePath);
+ log.debug("index = " + index + ", distFilePath = " + distFilePath);
}
// Remove the '/' we added to the front of this string
if (distFilePath.startsWith("/")) {
@@ -487,7 +512,7 @@ public class ContentHTTPServlet extends DefaultServlet {
*
*/
protected String getNthPiece(int n, String requestURI) {
- StrTokenizer st = new StrTokenizer(requestURI, "/");
+ StrTokenizer st = new StrTokenizer(decodeURL(requestURI), "/");
List<String> tokens = st.getTokenList();
if (tokens.size() < n) {
return "";
@@ -496,6 +521,7 @@ public class ContentHTTPServlet extends DefaultServlet {
}
protected String getParentURI(String uri) {
+ uri = decodeURL(uri);
if (uri.endsWith("/")) {
uri = uri.substring(0, uri.length() - 1);
}
@@ -506,18 +532,30 @@ public class ContentHTTPServlet extends DefaultServlet {
return uri.substring(0, index);
}
+ protected String decodeURL(String requestURI) {
+ String req = null;
+ try {
+ req = urlCodec.decode(requestURI);
+ } catch (DecoderException e) {
+ log.info(e);
+ return "";
+ }
+ return req;
+ }
+
protected PackageVersion getPackageVersionFromFileName(Repo repo, String fileName) {
PackageVersionCriteria criteria = new PackageVersionCriteria();
criteria.addFilterFileName(fileName);
criteria.addFilterRepoId(repo.getId());
- log.info("Created criteria for repoId = " + repo.getId() + ", fileName = " + fileName);
+ criteria.setStrict(true);
+ log.debug("Created criteria for repoId = " + repo.getId() + ", fileName = " + fileName);
List<PackageVersion> pkgVers = contentMgr.findPackageVersionsByCriteria(LookupUtil.getSubjectManager()
.getOverlord(), criteria);
for (PackageVersion pkgV : pkgVers) {
- log.info("PackageVersion found: " + pkgVers);
+ log.debug("PackageVersion found: " + pkgV);
}
- log.info("Found " + pkgVers.size() + " entries");
+ log.debug("Found " + pkgVers.size() + " entries");
PackageVersion pv = null;
if (pkgVers.size() > 0) {
pv = pkgVers.get(0);
@@ -527,10 +565,12 @@ public class ContentHTTPServlet extends DefaultServlet {
return pv;
}
- protected boolean writeDistributionFileBits(ServletOutputStream output, DistributionFile distFile)
- throws IOException {
+ protected boolean writeDistributionFileBits(HttpServletRequest request, HttpServletResponse response,
+ DistributionFile distFile) throws IOException {
try {
+ ServletOutputStream output = response.getOutputStream();
+ response.setContentType("application/octet-stream");
contentSourceMgr.outputDistributionFileBits(distFile, output);
output.flush();
output.close();
@@ -544,10 +584,31 @@ public class ContentHTTPServlet extends DefaultServlet {
return true;
}
- protected boolean writePackageVersionBits(ServletOutputStream output, PackageVersion pkgVer) {
-
+ protected boolean writePackageVersionBits(HttpServletRequest request, HttpServletResponse response,
+ PackageVersion pkgVer) {
+ //
+ // Anaconda does a fetch with specific ranges so it can locate the header in a rpm.
+ // Refer to anaconda source: yuminstall.py to see the details.
+ // We will default to range values of [0 -> -1] which will allow non-range based fetches to work as usual
+ //
+ long startRange = getStartRange(request);
+ long endRange = getEndRange(request);
+ if (endRange < 0) {
+ response.setContentType("application/x-rpm");
+ response.setContentLength(pkgVer.getFileSize().intValue());
+ } else {
+ response.setContentType("application/octet-stream");
+ log.debug("Range request: start = " + startRange + ", end = " + endRange);
+ int contentLength = new Long(endRange).intValue() - new Long(startRange).intValue() + 1;
+ log.debug("Setting contentLength = " + contentLength);
+ response.setContentLength(contentLength);
+ response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
+ String rangeHdr = "bytes=" + startRange + "-" + endRange + "/" + contentLength;
+ response.setHeader("Content-Range", rangeHdr);
+ }
try {
- contentSourceMgr.outputPackageVersionBits(pkgVer, output);
+ ServletOutputStream output = response.getOutputStream();
+ contentSourceMgr.outputPackageVersionBits(pkgVer, output, startRange, endRange);
output.flush();
output.close();
} catch (IllegalStateException e) {
@@ -559,4 +620,47 @@ public class ContentHTTPServlet extends DefaultServlet {
}
return true;
}
+
+ protected String[] getRanges(HttpServletRequest request) {
+ String rangeHeader = request.getHeader("Range");
+ if (rangeHeader == null) {
+ // Default value is 0, so it always starts at beginning
+ return null;
+ }
+ String[] ranges = rangeHeader.split("=");
+ if (ranges.length < 2) {
+ return null;
+ }
+ String[] indexes = ranges[1].split("-");
+ if (indexes.length < 2) {
+ return null;
+ }
+ return indexes;
+ }
+
+ /**
+ *
+ * @param request
+ * @return 0 if no value is present, or the number
+ */
+ protected long getStartRange(HttpServletRequest request) {
+ String[] indexes = getRanges(request);
+ if ((indexes == null) || (indexes.length < 2)) {
+ return 0;
+ }
+ return Long.valueOf(indexes[0]).longValue();
+ }
+
+ /**
+ *
+ * @param request
+ * @return -1 or the number
+ */
+ protected long getEndRange(HttpServletRequest request) {
+ String[] indexes = getRanges(request);
+ if ((indexes == null) || (indexes.length < 2)) {
+ return -1;
+ }
+ return Long.valueOf(indexes[1]).longValue();
+ }
}
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 09aad7e..1f9c62e 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
@@ -1753,6 +1753,23 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
.getId());
}
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ @TransactionTimeout(45 * 60)
+ public long outputPackageVersionBits(PackageVersion packageVersion, OutputStream outputStream, long startByte,
+ long endByte) {
+ // Used by export of content through http
+
+ PackageDetailsKey packageDetailsKey = new PackageDetailsKey(packageVersion.getDisplayName(), packageVersion
+ .getDisplayVersion(), packageVersion.getGeneralPackage().getPackageType().toString(), packageVersion
+ .getArchitecture().toString());
+
+ int resourceId = 0; //set to dummy value
+
+ log.info("Calling outputPackageVersionBitsRangeHelper() with package details: " + packageDetailsKey);
+ return outputPackageVersionBitsRangeHelper(resourceId, packageDetailsKey, outputStream, startByte, endByte,
+ packageVersion.getId());
+ }
+
@SuppressWarnings("unchecked")
private long outputPackageVersionBitsRangeHelper(int resourceId, PackageDetailsKey packageDetailsKey,
OutputStream outputStream, long startByte, long endByte, int packageVersionId) {
@@ -1877,12 +1894,10 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
// the magic happens here - outputStream is probably a remote stream down to the agent
long bytesRetrieved;
-
if (endByte < 0) {
if (startByte > 0) {
bitsStream.skip(startByte);
}
-
bytesRetrieved = StreamUtil.copy(bitsStream, outputStream, false);
} else {
BufferedInputStream bis = new BufferedInputStream(bitsStream);
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 cc742e7..4ff85fe 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
@@ -577,6 +577,25 @@ public interface ContentSourceManagerLocal {
long outputPackageVersionBits(PackageVersion packageVersion, OutputStream outputStream);
/**
+ * Requests a range of bits from a package. This range of bits will be streamed down to the caller over the given
+ * output stream. This method will <b>not</b> take care of closing the stream when it is finished;
+ * it is the caller's responsibility. This may be a time-consuming method call because
+ * if the bits have not yet been loaded (i.e. the content source where the package version lives
+ * {@link ContentSource#isLazyLoad() is lazy loading} then this may be the time when it is downloaded from the
+ * remote repository.
+ *
+ * @param packageVersion packageVersion to fetch
+ * @param outputStream an output stream where the server should write the package contents. It is up to the
+ * caller to prepare this output stream in order to write the package content to an
+ * appropriate location.
+ * @param startByte start index
+ * @param endByte end index
+ *
+ * @return the number of bytes written to the output stream
+ */
+ long outputPackageVersionBits(PackageVersion packageVersion, OutputStream outputStream, long startByte, long endByte);
+
+ /**
* Requests the bits of a distribution file be streamed down to the caller over the given output stream.
* This method will <b>not</b> take care of closing the stream when it is finished;
* it is the caller's responsibility.
commit a8e5dcf748c0157a4197010c1331b7fc1f058a9d
Author: John Matthews <jmatthew(a)redhat.com>
Date: Tue Jan 19 18:20:09 2010 -0500
1361 - add support for 'HEAD' request needed by virt-install & add pkg fetch through distribution url
-work in progress to support kickstarts through http
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
index e2f96f5..f08964f 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -80,6 +80,11 @@ public class ContentHTTPServlet extends DefaultServlet {
return StringUtils.equalsIgnoreCase(dir, "icons");
}
+ protected void doHead(HttpServletRequest request, HttpServletResponse response) throws IOException,
+ ServletException {
+ doGet(request, response);
+ }
+
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
log.info("doGet(): requestURI = " + request.getRequestURI());
if (isIconRequest(request)) {
@@ -302,8 +307,20 @@ public class ContentHTTPServlet extends DefaultServlet {
return;
}
}
- log.info("Searched through DistributionFiles and unable to find: " + fileRequest + ", in Distribution: "
- + dist.getLabel());
+ // This isn't a DistributionFile
+ // This could be a request for a package. Package requests will come in as:
+ // ..../distributions/{Server,Cluster,Packages,etc}/a2ps-XXXXX.rpm
+
+ String possiblePkgName = getLastPiece(request.getRequestURI());
+ log.info("Looking up : " + possiblePkgName + ", it might be a package request");
+ PackageVersion pv = getPackageVersionFromFileName(repo, possiblePkgName);
+ if (pv != null) {
+ log.info(possiblePkgName + " resolved to a package, will send package bytes back as response");
+ response.setContentType("application/octet-stream");
+ writePackageVersionBits(response.getOutputStream(), pv);
+ }
+ log.info("Searched through DistributionFiles and Packages, unable to find: " + fileRequest
+ + ", in Distribution: " + dist.getLabel());
renderErrorPage(request, response);
@@ -428,6 +445,15 @@ public class ContentHTTPServlet extends DefaultServlet {
return getNthPiece(4, requestURI);
}
+ protected String getLastPiece(String requestURI) {
+ StrTokenizer st = new StrTokenizer(requestURI, "/");
+ List<String> tokens = st.getTokenList();
+ if (tokens.size() < 1) {
+ return "";
+ }
+ return tokens.get(tokens.size() - 1);
+ }
+
/**
*
* @param requestURI
commit 11f0725a0d2007921c1257c539e6c060866609ca
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 16:20:40 2010 -0500
Added delete distribution type method so we can clean up properly after the web service tests.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java
index 50c3870..f251f7a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java
@@ -23,22 +23,16 @@
package org.rhq.core.domain.content;
import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
-import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
/**
* Defines a type of (@link Distribution)
@@ -48,9 +42,10 @@ import javax.persistence.ManyToOne;
*/
@Entity
-@NamedQueries(
- @NamedQuery(name = DistributionType.QUERY_FIND_BY_NAME, query = "SELECT dt FROM DistributionType dt WHERE dt.name = :name")
-)
+@NamedQueries({
+ @NamedQuery(name = DistributionType.QUERY_FIND_BY_NAME, query = "SELECT dt FROM DistributionType dt WHERE dt.name = :name"),
+ @NamedQuery(name = DistributionType.QUERY_DELETE_BY_NAME, query = "DELETE FROM DistributionType dt where dt.name = :name")
+})
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_DISTRIBUTION_TYPE_ID_SEQ")
@Table(name = "RHQ_DISTRIBUTION_TYPE")
public class DistributionType implements Serializable {
@@ -58,6 +53,7 @@ public class DistributionType implements Serializable {
private static final long serialVersionUID = 1L;
public static final String QUERY_FIND_BY_NAME = "DistributionType.findByName";
+ public static final String QUERY_DELETE_BY_NAME = "DistributionType.deleteByName";
// Attributes --------------------------------------------
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsDistributionManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsDistributionManagerTest.java
index a301454..dabcae0 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsDistributionManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsDistributionManagerTest.java
@@ -79,6 +79,12 @@ public class WsDistributionManagerTest extends WsUnitTestBase {
Distribution afterDelete = service.getDistributionByLabel(label);
assert afterDelete == null;
+
+ // Cleanup
+ service.deleteDistributionTypeByName(admin, type.getName());
+ DistributionType typeAfterDelete = service.getDistributionTypeByName(type.getName());
+
+ assert typeAfterDelete == null;
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
index 49bcba7..e931267 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
@@ -79,7 +79,7 @@ public class DistributionManagerBean implements DistributionManagerLocal, Distri
if (loaded != null) {
disttype = loaded;
}
-
+
Distribution kstree = new Distribution(kslabel, basepath, disttype);
validateDistTree(kstree);
@@ -217,6 +217,14 @@ public class DistributionManagerBean implements DistributionManagerLocal, Distri
}
}
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public void deleteDistributionTypeByName(Subject subject, String name) {
+ Query query = entityManager.createNamedQuery(DistributionType.QUERY_DELETE_BY_NAME);
+ query.setParameter("name", name);
+
+ query.executeUpdate();
+ }
+
/**
* validates a given kickstart tree object and throws a KickstartTreeException
* @param kstree kickstart tree object
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java
index 8528da8..b3eb4df 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java
@@ -89,6 +89,16 @@ public interface DistributionManagerLocal {
void deleteDistributionFilesByDistId(Subject subject, int distid);
/**
+ * Deletes all distribution types with the given name.
+ * <p/>
+ * This should only be needed for testing purposes.
+ *
+ * @param subject
+ * @param name
+ */
+ void deleteDistributionTypeByName(Subject subject, String name);
+
+ /**
* Returns a DistributionType for given name
* @param name name of distribution type
* @return distribution type from db
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java
index bebd3a1..35e5361 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java
@@ -99,6 +99,18 @@ public interface DistributionManagerRemote {
@WebParam(name = "distid") int distid);
/**
+ * Deletes all distribution types with the given name.
+ * <p/>
+ * This should only be needed for testing purposes.
+ *
+ * @param subject
+ * @param name
+ */
+ @WebMethod
+ void deleteDistributionTypeByName(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "name") String name);
+
+ /**
* Returns a DistributionType for given name
* @param name name of distribution type
* @return distribution type from db
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index a19fcbd..e737c2d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -591,6 +591,11 @@ public class WebservicesManagerBean implements WebservicesRemote {
distributionManager.deleteDistributionByDistId(subject, distId);
}
+ public void deleteDistributionTypeByName(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "name") String name) {
+ distributionManager.deleteDistributionTypeByName(subject, name);
+ }
+
public Distribution createDistribution(@WebParam(name = "subject") Subject subject,
@WebParam(name = "kslabel") String kslabel,
@WebParam(name = "basepath") String basepath,
commit a2b83b54b47d745f18dd8c749dfe3698c2f3fe7a
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 15:46:04 2010 -0500
Initial work on the distribution manager tests. Not all of the test cases are flushed out, but this at least proves it's configured correctly to allow remote calls to be made into it.
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsDistributionManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsDistributionManagerTest.java
new file mode 100644
index 0000000..a301454
--- /dev/null
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsDistributionManagerTest.java
@@ -0,0 +1,84 @@
+/*
+* 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.ws.test;
+
+import org.testng.annotations.Test;
+
+import org.rhq.enterprise.server.ws.Distribution;
+import org.rhq.enterprise.server.ws.DistributionType;
+import org.rhq.enterprise.server.ws.Subject;
+
+/**
+ * Web service tests for the distribution manager service.
+ *
+ * @author Jason Dobies
+ */
+@Test(groups = "ws")
+public class WsDistributionManagerTest extends WsUnitTestBase {
+
+ private static final boolean TESTS_ENABLED = true;
+
+ @Test(enabled = TESTS_ENABLED)
+ public void createGetDeleteDistribution() throws Exception {
+
+ // Setup
+ Subject admin = subjectUtil.admin();
+ String label = "WsDistributionManagerTest.createGetDeleteDistribution.label";
+ String path = "WsDistributionManagerTest.createGetDeleteDistribution.path";
+
+ DistributionType type = objectFactory.createDistributionType();
+ type.setName("WsDistributionManagerTest.createGetDeleteDistribution.type");
+ type.setDescription("WsDistributionManagerTest.createGetDeleteDistribution.desc");
+
+ // Test
+ Distribution created = service.createDistribution(admin, label, path, type);
+
+ assert created != null;
+
+ Distribution byLabel = service.getDistributionByLabel(label);
+ Distribution byPath = service.getDistributionByPath(path);
+
+ DistributionType typeByName = service.getDistributionTypeByName(type.getName());
+
+ service.deleteDistributionByDistId(admin, created.getId());
+
+ // Verify
+ assert byLabel != null;
+ assert label.equals(byLabel.getLabel());
+ assert path.equals(byLabel.getBasePath());
+ assert type.getName().equals(byLabel.getDistributionType().getName());
+
+ assert byPath != null;
+ assert label.equals(byPath.getLabel());
+ assert path.equals(byPath.getBasePath());
+ assert type.getName().equals(byPath.getDistributionType().getName());
+
+ assert typeByName != null;
+ assert type.getName().equals(typeByName.getName());
+ assert type.getDescription().equals(typeByName.getDescription());
+
+ Distribution afterDelete = service.getDistributionByLabel(label);
+ assert afterDelete == null;
+ }
+
+}
commit 3feaac41e98fad8e0066bdb8815c3641741aa027
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 15:43:37 2010 -0500
This should try to reuse the distribution type if it already exists. Prior to this, multiple distribution types with the same label/description were being created.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
index cdfcbe0..49bcba7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
@@ -75,6 +75,11 @@ public class DistributionManagerBean implements DistributionManagerLocal, Distri
public Distribution createDistribution(Subject user, String kslabel, String basepath, DistributionType disttype)
throws DistributionException {
+ DistributionType loaded = distributionManager.getDistributionTypeByName(disttype.getName());
+ if (loaded != null) {
+ disttype = loaded;
+ }
+
Distribution kstree = new Distribution(kslabel, basepath, disttype);
validateDistTree(kstree);
commit e7d1ae92c45189db62c40b55b7035ccb653e35b6
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 15:33:08 2010 -0500
Fixed broken call to query.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java
index c93a886..e3aa284 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java
@@ -53,7 +53,7 @@ import org.hibernate.annotations.NamedQuery;
@NamedQuery(name = Distribution.QUERY_FIND_PATH_BY_DIST_TYPE, query = "SELECT dt " + " FROM Distribution dt "
+ " WHERE dt.label = :label AND dt.distributionType.name = :typeName "),
@NamedQuery(name = Distribution.QUERY_FIND_BY_DIST_LABEL, query = "SELECT dt FROM Distribution dt WHERE dt.label = :label"),
- @NamedQuery(name = Distribution.QUERY_FIND_BY_DIST_PATH, query = "SELECT dt FROM Distribution dt WHERE dt.base_path = :path"),
+ @NamedQuery(name = Distribution.QUERY_FIND_BY_DIST_PATH, query = "SELECT dt FROM Distribution dt WHERE dt.basePath = :path"),
@NamedQuery(name = Distribution.QUERY_DELETE_BY_DIST_ID, query = "DELETE Distribution dt WHERE dt.id = :distid") })
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_DISTRIBUTION_ID_SEQ")
@Table(name = "RHQ_DISTRIBUTION")
@@ -87,7 +87,7 @@ public class Distribution implements Serializable {
* Base path where the kickstart tree is located
*/
@Column(name = "BASE_PATH", nullable = false)
- private String base_path;
+ private String basePath;
@Column(name = "LAST_MODIFIED", nullable = false)
private long lastModifiedDate;
@@ -119,7 +119,7 @@ public class Distribution implements Serializable {
}
public String getBasePath() {
- return this.base_path;
+ return this.basePath;
}
public void setLabel(String labelIn) {
@@ -127,7 +127,7 @@ public class Distribution implements Serializable {
}
public void setBasePath(String basepathIn) {
- this.base_path = basepathIn;
+ this.basePath = basepathIn;
}
public int getId() {
@@ -161,7 +161,7 @@ public class Distribution implements Serializable {
@Override
public String toString() {
- return String.format("Distribution [label=%s, Type=%s, basePath=%s]", label, distributionType, base_path);
+ return String.format("Distribution [label=%s, Type=%s, basePath=%s]", label, distributionType, basePath);
}
@Override
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
index 14dc8fb..cdfcbe0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
@@ -134,7 +134,7 @@ public class DistributionManagerBean implements DistributionManagerLocal, Distri
public Distribution getDistributionByPath(String basepath) {
Query query = entityManager.createNamedQuery(Distribution.QUERY_FIND_BY_DIST_PATH);
- query.setParameter("base_path", basepath);
+ query.setParameter("path", basepath);
List<Distribution> results = query.getResultList();
if (results.size() > 0) {
commit f173b246eea0a6a92572cd53bebbad04f1013620
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 15:07:18 2010 -0500
Changed to expose the distribution manager over webservices.
diff --git a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
index d261413..1162a69 100644
--- a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
+++ b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
@@ -37,6 +37,7 @@ import org.rhq.enterprise.server.authz.RoleManagerRemote;
import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
import org.rhq.enterprise.server.content.AdvisoryManagerRemote;
import org.rhq.enterprise.server.content.ContentManagerRemote;
+import org.rhq.enterprise.server.content.DistributionManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
@@ -78,6 +79,7 @@ public class RemoteClient {
ContentManager(ContentManagerRemote.class), //
DataAccessManager(DataAccessManagerRemote.class), //
DiscoveryBoss(DiscoveryBossRemote.class), //
+ DistributionManager(DistributionManagerRemote.class),//
EventManager(EventManagerRemote.class), //
MeasurementBaselineManager(MeasurementBaselineManagerRemote.class), //
MeasurementDataManager(MeasurementDataManagerRemote.class), //
@@ -350,6 +352,10 @@ public class RemoteClient {
return RemoteClientProxy.getProcessor(this, Manager.DiscoveryBoss);
}
+ public DistributionManagerRemote getDistributionManagerRemote() {
+ return RemoteClientProxy.getProcessor(this, Manager.DistributionManager);
+ }
+
public EventManagerRemote getEventManagerRemote() {
return RemoteClientProxy.getProcessor(this, Manager.EventManager);
}
diff --git a/modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml b/modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml
index 3044936..5bb03d4 100644
--- a/modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml
+++ b/modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml
@@ -21,6 +21,7 @@
<property name="ConfigurationManager" value="org.rhq.enterprise.server.configuration.ConfigurationManagerBean" />
<property name="ContentManager" value="org.rhq.enterprise.server.content.ContentManagerBean" />
<property name="DataAccessManager" value="org.rhq.enterprise.server.report.DataAccessManagerBean" />
+ <property name="DistributionManager" value="org.rhq.enterprise.server.content.DistributionManagerBean"/>
<property name="EventManager" value="org.rhq.enterprise.server.event.EventManagerBean" />
<property name="MeasurementDefinitionManager" value="org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerBean" />
<property name="MeasurementBaselineManager" value="org.rhq.enterprise.server.measurement.MeasurementBaselineManagerBean" />
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
index 53c1be0..52ca48e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
@@ -40,6 +40,7 @@ import org.rhq.enterprise.server.authz.RoleManagerBean;
import org.rhq.enterprise.server.configuration.ConfigurationManagerBean;
import org.rhq.enterprise.server.content.AdvisoryManagerBean;
import org.rhq.enterprise.server.content.ContentManagerBean;
+import org.rhq.enterprise.server.content.DistributionManagerBean;
import org.rhq.enterprise.server.content.RepoManagerBean;
import org.rhq.enterprise.server.event.EventManagerBean;
import org.rhq.enterprise.server.measurement.AvailabilityManagerBean;
@@ -75,6 +76,7 @@ public class RemoteAPIValidator {
ContentManagerBean.class, //
//ContentSourceManagerBean.class, //
DataAccessManagerBean.class, //
+ DistributionManagerBean.class,//
EventManagerBean.class, //
MeasurementBaselineManagerBean.class,//
MeasurementDataManagerBean.class,//
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index c19808f..a19fcbd 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -54,6 +54,8 @@ import org.rhq.core.domain.content.AdvisoryPackage;
import org.rhq.core.domain.content.Architecture;
import org.rhq.core.domain.content.CVE;
import org.rhq.core.domain.content.Distribution;
+import org.rhq.core.domain.content.DistributionFile;
+import org.rhq.core.domain.content.DistributionType;
import org.rhq.core.domain.content.InstalledPackage;
import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.content.PackageVersion;
@@ -112,6 +114,8 @@ import org.rhq.enterprise.server.configuration.ConfigurationUpdateStillInProgres
import org.rhq.enterprise.server.content.AdvisoryException;
import org.rhq.enterprise.server.content.AdvisoryManagerLocal;
import org.rhq.enterprise.server.content.ContentManagerLocal;
+import org.rhq.enterprise.server.content.DistributionException;
+import org.rhq.enterprise.server.content.DistributionManagerLocal;
import org.rhq.enterprise.server.content.RepoException;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
@@ -172,6 +176,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
//removed as it is problematic for WS clients having XMLAny for Object.
// private DataAccessManagerLocal dataAccessManager = LookupUtil.getDataAccessManager();
private DiscoveryBossLocal discoveryBoss = LookupUtil.getDiscoveryBoss();
+ private DistributionManagerLocal distributionManager = LookupUtil.getDistributionManagerLocal();
private EventManagerLocal eventManager = LookupUtil.getEventManager();
private MeasurementBaselineManagerLocal measurementBaselineManager = LookupUtil.getMeasurementBaselineManager();
private MeasurementDataManagerLocal measurementDataManager = LookupUtil.getMeasurementDataManager();
@@ -558,6 +563,44 @@ public class WebservicesManagerBean implements WebservicesRemote {
//DISCOVERYBOSS: END ------------------------------------
+ //DISTRIBUTION: START ------------------------------------
+
+ public DistributionType getDistributionTypeByName(@WebParam(name = "name") String name) {
+ return distributionManager.getDistributionTypeByName(name);
+ }
+
+ public void deleteDistributionFilesByDistId(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "distid") int distid) {
+ distributionManager.deleteDistributionByDistId(subject, distid);
+ }
+
+ public List<DistributionFile> getDistributionFilesByDistId(@WebParam(name = "distid") int distid) {
+ return distributionManager.getDistributionFilesByDistId(distid);
+ }
+
+ public Distribution getDistributionByPath(@WebParam(name = "basepath") String basepath) {
+ return distributionManager.getDistributionByPath(basepath);
+ }
+
+ public Distribution getDistributionByLabel(@WebParam(name = "kslabel") String kslabel) {
+ return distributionManager.getDistributionByLabel(kslabel);
+ }
+
+ public void deleteDistributionByDistId(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "distId") int distId) throws Exception {
+ distributionManager.deleteDistributionByDistId(subject, distId);
+ }
+
+ public Distribution createDistribution(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "kslabel") String kslabel,
+ @WebParam(name = "basepath") String basepath,
+ @WebParam(name = "disttype") DistributionType disttype)
+ throws DistributionException {
+ return distributionManager.createDistribution(subject, kslabel, basepath, disttype);
+ }
+
+ //DISTRIBUTION: END ------------------------------------
+
//EVENTMANAGER: BEGIN ----------------------------------
public PageList<Event> findEventsByCriteria(Subject subject, EventCriteria criteria) {
checkParametersPassedIn(subject, criteria);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
index eb5937b..13f89df 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
@@ -11,6 +11,7 @@ import org.rhq.enterprise.server.authz.RoleManagerRemote;
import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
import org.rhq.enterprise.server.content.AdvisoryManagerRemote;
import org.rhq.enterprise.server.content.ContentManagerRemote;
+import org.rhq.enterprise.server.content.DistributionManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
@@ -46,6 +47,7 @@ public interface WebservicesRemote extends //
//Removed as it was problematic for WS clients. Not sure if this well be re-enabled.
// DataAccessManagerRemote,//
DiscoveryBossRemote,//
+ DistributionManagerRemote,//
EventManagerRemote,//
MeasurementBaselineManagerRemote,//
MeasurementDataManagerRemote,//
commit f00604d38a40dabd0bca32e8fb708f48e1c70c28
Merge: 28e1caf... c749e1a...
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Thu Jan 21 14:11:51 2010 -0500
Merge branch 'content' of ssh://git.fedorahosted.org/git/rhq/rhq into content
commit 28e1cafc18845501f10f0aeacf46a3b7806da37d
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Thu Jan 21 14:11:32 2010 -0500
fixing the last modified on distribution trees to show right time stamp
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
index 77ab7f1..7e9070f 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
@@ -677,8 +677,10 @@
<h:outputText styleClass="headerText"
value="Last Modified" />
</f:facet>
- <h:outputText value="#{dist.lastModifiedDate}" />
-
+ <h:outputText value="#{dist.lastModifiedDate}">
+ <f:converter converterId="UserDateTimeConverter" />
+ </h:outputText>
+
</rich:column>
commit c749e1a6acc4c699247b41d88423852520a494d1
Merge: cab715c... ec13d2a...
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jan 21 14:07:38 2010 -0500
Merge branch 'master' into content
commit cab715c7171b14200a7adcccc725850427584c86
Merge: 947167f... 2afe643...
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Thu Jan 21 10:50:10 2010 -0800
Merge branch 'master' into content
Conflicts:
.classpath
modules/enterprise/gui/pom.xml
diff --cc .classpath
index a8668a4,8b3c7cf..5746d68
--- a/.classpath
+++ b/.classpath
@@@ -222,9 -220,10 +221,11 @@@
<classpathentry exported="true" kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.2.1/byteman-1.2.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.2/antlr-runtime-3.2.jar"/>
<classpathentry exported="true" kind="lib" path="modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-1.4.0-SNAPSHOT/wsconsume-output"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/jboss/web/jbossweb/2.0.1.GA/jbossweb-2.0.1.GA.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/libvirt/libvirt/0.4.1/libvirt-0.4.1.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.2.1/byteman-1.2.1.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/fedorahosted/cobbler/cobbler4j/0.1/cobbler4j-0.1.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
diff --cc modules/enterprise/gui/pom.xml
index 9ae5584,9b895cb..c9e59f1
--- a/modules/enterprise/gui/pom.xml
+++ b/modules/enterprise/gui/pom.xml
@@@ -35,7 -35,7 +35,8 @@@
<module>portal-war</module>
<module>installer-war</module>
<module>webdav-war</module>
+ <module>content_http-war</module>
+ <module>alert-migration</module>
</modules>
</profile>
diff --cc modules/enterprise/server/ear/pom.xml
index 4ab1ee1,5db9a4e..3faa62b
--- a/modules/enterprise/server/ear/pom.xml
+++ b/modules/enterprise/server/ear/pom.xml
@@@ -66,14 -66,14 +66,21 @@@
<version>${project.version}</version>
<type>war</type>
</dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-content_http</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ </dependency>
+ <dependency>
+ <groupId>org.rhq.helpers</groupId>
+ <artifactId>alert-migration</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ </dependency>
+
<!-- ** SARs -->
<!--
<dependency> <groupId>org.rhq</groupId> <artifactId>rhq-enterprise-server-agent-sar</artifactId>
@@@ -175,16 -175,14 +182,23 @@@
<bundleFileName>rhq-webdav.war</bundleFileName>
<contextRoot>/webdav</contextRoot>
</webModule>
+
+ <!-- used to expose content through http -->
+ <webModule>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-content_http</artifactId>
+ <excluded>${exclude-content_http}</excluded>
+ <bundleFileName>rhq-content_http.war</bundleFileName>
+ <contextRoot>/content</contextRoot>
+ </webModule>
+ <webModule>
+ <groupId>org.rhq.helpers</groupId>
+ <artifactId>alert-migration</artifactId>
+ <bundleFileName>alert-migration.war</bundleFileName>
+ <contextRoot>/alert-migration</contextRoot>
+ </webModule>
+
<!-- ** EJB-JARs -->
<ejbModule>
commit 947167f528d432923a96eefc188562d0c71dc2a5
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 12:53:55 2010 -0500
The import call isn't supposed to be used anymore, so remove from the tests.
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
index 3e3265a..7886e4b 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
@@ -55,7 +55,6 @@ public class WsRegistrationManagerTest extends WsUnitTestBase {
// Note: randomPlatform calls #registerPlatform, which is why there's no explicit test for that
Resource created = resourceUtil.randomPlatform();
- service.importPlatform(admin, created);
// Verify and Cleanup
try {
commit bb0734689ca35af4bbb893cb2d3f86e3b848dc73
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 12:35:15 2010 -0500
Missed a place to add the new method.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index af011a6..c19808f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -216,6 +216,10 @@ public class WebservicesManagerBean implements WebservicesRemote {
return advisoryManager.createAdvisoryPackage(user, advisory, pkg);
}
+ public CVE getCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "cveId") int cveId) {
+ return advisoryManager.getCVE(user, cveId);
+ }
+
public void deleteCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "cveId") int cveId) {
advisoryManager.deleteAdvisoryCVE(user, cveId);
}
commit 06287f603a67d598cd90b7a84833bbf9ab05d771
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 12:33:13 2010 -0500
Added method needed for testing.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
index 83c5416..e4c42a4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
@@ -108,6 +108,11 @@ public class AdvisoryManagerBean implements AdvisoryManagerLocal, AdvisoryManage
return advpkg;
}
+ public CVE getCVE(Subject user, int cveId) {
+ CVE cve = entityManager.find(CVE.class, cveId);
+ return cve;
+ }
+
public void deleteCVE(Subject user, int cveId) {
log.debug("User [" + user + "] is deleting CVE [" + cveId + "]");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerLocal.java
index 3450b10..d44fdbc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerLocal.java
@@ -60,7 +60,7 @@ public interface AdvisoryManagerLocal {
CVE createCVE(Subject user, String cvename) throws AdvisoryException;
/**
- * creates a AdvisoryCVE relationship object
+ * creates a AdvisoryCVE relationship object
* @param user
* @param advisory
* @param cve
@@ -80,6 +80,14 @@ public interface AdvisoryManagerLocal {
AdvisoryPackage createAdvisoryPackage(Subject user, Advisory advisory, PackageVersion pkg) throws AdvisoryException;
/**
+ * returns an existing CVE object
+ * @param user
+ * @param cveId
+ * @return
+ */
+ CVE getCVE(Subject user, int cveId);
+
+ /**
* deletes specified cve object
* @param user
* @param cveId
@@ -159,7 +167,7 @@ public interface AdvisoryManagerLocal {
/**
* find AdvisoryPackage object for given advId and packageVersion id
* @param overlord
- * @param advId
+ * @param advId
* @param pkgVerId
*/
AdvisoryPackage findAdvisoryPackage(Subject overlord, int advId, int pkgVerId);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java
index cb0514f..a74a81a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java
@@ -89,6 +89,15 @@ public interface AdvisoryManagerRemote {
@WebParam(name = "pkg") PackageVersion pkg) throws AdvisoryException;
/**
+ * returns an existing CVE object
+ * @param user
+ * @param cveId
+ * @return
+ */
+ CVE getCVE(@WebParam(name = "subject") Subject user,
+ @WebParam(name = "cveId")int cveId);
+
+ /**
* deletes specified cve object
* @param user
* @param cveId
commit 68a788527b1b465403538e4ef0b2c3bcb8f709ff
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 12:32:22 2010 -0500
Refactored into base class that takes care of the remote connection initialization.
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java
index 00a01f3..3f22fa0 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java
@@ -22,22 +22,10 @@
*/
package org.rhq.enterprise.server.ws.test;
-import java.net.URL;
-
-import javax.xml.namespace.QName;
-
-import org.testng.AssertJUnit;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.rhq.enterprise.server.ws.Advisory;
-import org.rhq.enterprise.server.ws.ObjectFactory;
import org.rhq.enterprise.server.ws.Subject;
-import org.rhq.enterprise.server.ws.TestPropertiesInterface;
-import org.rhq.enterprise.server.ws.WebservicesManagerBeanService;
-import org.rhq.enterprise.server.ws.WebservicesRemote;
-import org.rhq.enterprise.server.ws.test.util.WsSubjectUtility;
-import org.rhq.enterprise.server.ws.utility.WsUtility;
/**
* Web service tests for the advisory manager services.
@@ -45,31 +33,10 @@ import org.rhq.enterprise.server.ws.utility.WsUtility;
* @author Jason Dobies
*/
@Test(groups = "ws")
-public class WsAdvisoryManagerTest extends AssertJUnit implements TestPropertiesInterface {
+public class WsAdvisoryManagerTest extends WsUnitTestBase {
private static final boolean TESTS_ENABLED = true;
- private WebservicesRemote service;
- private ObjectFactory objectFactory;
-
- private WsSubjectUtility subjectUtil;
-
- @BeforeClass
- public void setup() throws Exception {
-
- // Variables needed
- URL gUrl = WsUtility.generateRemoteWebserviceURL(WebservicesManagerBeanService.class, host, port, useSSL);
- QName gQName = WsUtility.generateRemoteWebserviceQName(WebservicesManagerBeanService.class);
-
- // Establish outbound webservices connections
- WebservicesManagerBeanService jws = new WebservicesManagerBeanService(gUrl, gQName);
- service = jws.getWebservicesManagerBeanPort();
-
- objectFactory = new ObjectFactory();
-
- subjectUtil = new WsSubjectUtility(service);
- }
-
@Test(enabled = TESTS_ENABLED)
public void createGetDeleteAdvisory() throws Exception {
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
index b4367db..3e3265a 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
@@ -22,21 +22,16 @@
*/
package org.rhq.enterprise.server.ws.test;
-import java.lang.Exception;
-import java.net.URL;
import java.util.List;
-import javax.xml.namespace.QName;
-
-import org.testng.AssertJUnit;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.rhq.enterprise.server.ws.*;
+import org.rhq.enterprise.server.ws.InventoryStatus;
+import org.rhq.enterprise.server.ws.Resource;
+import org.rhq.enterprise.server.ws.ResourceCriteria;
+import org.rhq.enterprise.server.ws.Subject;
import org.rhq.enterprise.server.ws.test.util.WsResourceUtility;
import org.rhq.enterprise.server.ws.test.util.WsSubjectUtility;
-import org.rhq.enterprise.server.ws.utility.WsUtility;
/**
* Web service tests for the registration manager services.
@@ -44,27 +39,10 @@ import org.rhq.enterprise.server.ws.utility.WsUtility;
* @author Jason Dobies
*/
@Test(groups = "ws")
-public class WsRegistrationManagerTest extends AssertJUnit implements TestPropertiesInterface {
+public class WsRegistrationManagerTest extends WsUnitTestBase {
private static final boolean TESTS_ENABLED = true;
- private WebservicesRemote service;
- private ObjectFactory objectFactory;
-
- @BeforeClass
- public void setup() throws Exception {
-
- // Variables needed
- URL gUrl = WsUtility.generateRemoteWebserviceURL(WebservicesManagerBeanService.class, host, port, useSSL);
- QName gQName = WsUtility.generateRemoteWebserviceQName(WebservicesManagerBeanService.class);
-
- // Establish outbound webservices connections
- WebservicesManagerBeanService jws = new WebservicesManagerBeanService(gUrl, gQName);
- service = jws.getWebservicesManagerBeanPort();
-
- objectFactory = new ObjectFactory();
- }
-
@Test(enabled = TESTS_ENABLED)
public void importPlatform() throws Exception {
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsUnitTestBase.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsUnitTestBase.java
new file mode 100644
index 0000000..f6ef8d2
--- /dev/null
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsUnitTestBase.java
@@ -0,0 +1,72 @@
+/*
+* 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.ws.test;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.testng.AssertJUnit;
+import org.testng.annotations.BeforeClass;
+
+import org.rhq.enterprise.server.ws.ObjectFactory;
+import org.rhq.enterprise.server.ws.TestPropertiesInterface;
+import org.rhq.enterprise.server.ws.WebservicesManagerBeanService;
+import org.rhq.enterprise.server.ws.WebservicesRemote;
+import org.rhq.enterprise.server.ws.test.util.WsResourceUtility;
+import org.rhq.enterprise.server.ws.test.util.WsSubjectUtility;
+import org.rhq.enterprise.server.ws.utility.WsUtility;
+
+/**
+ * Base class for all webservice unit tests. This class runs the setup and teardown
+ * necessary to establish and release the connection to the remote server. Subclasses
+ * can use the variables initialized here for testing purposes.
+ *
+ * @author Jason Dobies
+ */
+public class WsUnitTestBase extends AssertJUnit implements TestPropertiesInterface {
+
+ protected WebservicesRemote service;
+ protected ObjectFactory objectFactory;
+
+ protected WsSubjectUtility subjectUtil;
+ protected WsResourceUtility resourceUtil;
+
+ @BeforeClass
+ public void setup() throws Exception {
+
+ // Variables needed
+ URL gUrl = WsUtility.generateRemoteWebserviceURL(WebservicesManagerBeanService.class, host, port, useSSL);
+ QName gQName = WsUtility.generateRemoteWebserviceQName(WebservicesManagerBeanService.class);
+
+ // Establish outbound webservices connections
+ WebservicesManagerBeanService jws = new WebservicesManagerBeanService(gUrl, gQName);
+ service = jws.getWebservicesManagerBeanPort();
+
+ objectFactory = new ObjectFactory();
+
+ subjectUtil = new WsSubjectUtility(service);
+ resourceUtil = new WsResourceUtility(service);
+ }
+
+}
commit 9b46a01f42e577202dd47e0fe775c5ad42f5d883
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Thu Jan 21 11:35:53 2010 -0500
some optimizations to not check hibernate twice
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
index 44a7846..83c5416 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
@@ -114,12 +114,10 @@ public class AdvisoryManagerBean implements AdvisoryManagerLocal, AdvisoryManage
entityManager.flush();
entityManager.clear();
- entityManager.createNamedQuery(CVE.DELETE_BY_CVE_ID).setParameter("cveId", cveId).executeUpdate();
+ int success = entityManager.createNamedQuery(CVE.DELETE_BY_CVE_ID).setParameter("cveId", cveId).executeUpdate();
- CVE cve = entityManager.find(CVE.class, cveId);
- if (cve != null) {
- entityManager.remove(cve);
- log.debug("User [" + user + "] deleted CVE [" + cve + "]");
+ if (success == 1) {
+ log.debug("User [" + user + "] deleted CVE [" + cveId + "]");
} else {
log.debug("CVE ID [" + cveId + "] doesn't exist - nothing to delete");
}
@@ -131,14 +129,13 @@ public class AdvisoryManagerBean implements AdvisoryManagerLocal, AdvisoryManage
entityManager.flush();
entityManager.clear();
- entityManager.createNamedQuery(AdvisoryCVE.DELETE_BY_ADV_ID).setParameter("advId", advId).executeUpdate();
+ int success = entityManager.createNamedQuery(AdvisoryCVE.DELETE_BY_ADV_ID).setParameter("advId", advId)
+ .executeUpdate();
- AdvisoryCVE advcve = entityManager.find(AdvisoryCVE.class, advId);
- if (advcve != null) {
- entityManager.remove(advcve);
- log.debug("User [" + user + "] deleted CVE [" + advcve + "]");
+ if (success == 1) {
+ log.debug("User [" + user + "] deleted CVEs for " + advId);
} else {
- log.debug("Advisory ID [" + advId + "] doesn't exist - nothing to delete");
+ log.debug("Advisory ID [" + advId + "] CVE deletion unsuccessful");
}
}
@@ -148,48 +145,44 @@ public class AdvisoryManagerBean implements AdvisoryManagerLocal, AdvisoryManage
entityManager.flush();
entityManager.clear();
- entityManager.createNamedQuery(Advisory.QUERY_DELETE_BY_ADV_ID).setParameter("advid", advId).executeUpdate();
+ int success = entityManager.createNamedQuery(Advisory.QUERY_DELETE_BY_ADV_ID).setParameter("advid", advId)
+ .executeUpdate();
- Advisory adv = entityManager.find(Advisory.class, advId);
- if (adv != null) {
- entityManager.remove(adv);
- log.debug("User [" + user + "] deleted advisory [" + adv + "]");
+ if (success == 1) {
+ log.debug("User [" + user + "] deleted Advisory for " + advId);
} else {
- log.debug("Advisory tree ID [" + adv + "] doesn't exist - nothing to delete");
+ log.debug("Advisory ID [" + advId + "] deletion unsuccessful");
}
}
public void deleteAdvisoryPackage(Subject user, int advId) {
- log.debug("User [" + user + "] is deleting CVE [" + advId + "]");
+ log.debug("User [" + user + "] is deleting packages for advisory [" + advId + "]");
entityManager.flush();
entityManager.clear();
- entityManager.createNamedQuery(AdvisoryPackage.DELETE_PACKAGES_BY_ADV_ID).setParameter("advId", advId)
- .executeUpdate();
+ int success = entityManager.createNamedQuery(AdvisoryPackage.DELETE_PACKAGES_BY_ADV_ID).setParameter("advId",
+ advId).executeUpdate();
- AdvisoryPackage advpkg = entityManager.find(AdvisoryPackage.class, advId);
- if (advpkg != null) {
- entityManager.remove(advpkg);
- log.debug("User [" + user + "] deleted CVE [" + advpkg + "]");
+ if (success == 1) {
+ log.debug("User [" + user + "] deleted AdvisoryPackage for [" + advId + "]");
} else {
log.debug("Advisory ID [" + advId + "] doesn't exist - nothing to delete");
}
}
public void deleteAdvisoryBugList(Subject user, int advId) {
- log.debug("User [" + user + "] is deleting CVE [" + advId + "]");
+ log.debug("User [" + user + "] is deleting Buglist for Advisory [" + advId + "]");
entityManager.flush();
entityManager.clear();
- entityManager.createNamedQuery(AdvisoryBuglist.DELETE_BY_ADV_ID).setParameter("advId", advId).executeUpdate();
+ int success = entityManager.createNamedQuery(AdvisoryBuglist.DELETE_BY_ADV_ID).setParameter("advId", advId)
+ .executeUpdate();
- AdvisoryBuglist advbugs = entityManager.find(AdvisoryBuglist.class, advId);
- if (advbugs != null) {
- entityManager.remove(advbugs);
- log.debug("User [" + user + "] deleted CVE [" + advbugs + "]");
+ if (success == 1) {
+ log.debug("User [" + user + "] deleted buglist for Advisory [" + advId + "]");
} else {
log.debug("Advisory ID [" + advId + "] doesn't exist - nothing to delete");
}
commit 5ee5e05f9f1c8035b571ea591babc5a17dac8a59
Author: Sayli Karmarkar <skarmark(a)redhat.com>
Date: Thu Jan 21 05:27:05 2010 -0500
1368,1369 - Adding webUI and manager layer changes for tracking resource deployment
diff --git a/.classpath b/.classpath
index 020776a..a8668a4 100644
--- a/.classpath
+++ b/.classpath
@@ -225,6 +225,6 @@
<classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.2.1/byteman-1.2.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.2/antlr-runtime-3.2.jar"/>
<classpathentry exported="true" kind="lib" path="modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-1.4.0-SNAPSHOT/wsconsume-output"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/jboss/web/jbossweb/2.0.1.GA/jbossweb-2.0.1.GA.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/jboss/web/jbossweb/2.0.1.GA/jbossweb-2.0.1.GA.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PageControlView.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PageControlView.java
index 4927a71..321a755 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PageControlView.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PageControlView.java
@@ -53,6 +53,7 @@ import org.rhq.enterprise.gui.content.RepoSubscriptionsUIBean;
import org.rhq.enterprise.gui.content.RepoUnsubscriptionsUIBean;
import org.rhq.enterprise.gui.content.ResourcePackageVersionsUIBean;
import org.rhq.enterprise.gui.content.ResourceReposUIBean;
+import org.rhq.enterprise.gui.content.ResourceUpdatePackageVersionsUIBean;
import org.rhq.enterprise.gui.content.ShowContentServiceRequestUIBean;
import org.rhq.enterprise.gui.definition.group.GroupDefinitionUIBean;
import org.rhq.enterprise.gui.definition.group.ListGroupDefinitionsUIBean;
@@ -160,6 +161,8 @@ public enum PageControlView {
/** */
ResourcePackageVersionsList(ResourcePackageVersionsUIBean.class),
/** */
+ ResourceUpdatePackageVersionsList(ResourceUpdatePackageVersionsUIBean.class),
+ /** */
PackagesToDeployList(DeployPackagesUIBean.class),
/** */
InstalledPackageHistoryList(ShowContentServiceRequestUIBean.class),
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/layout/main-no-leftnav.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/layout/main-no-leftnav.xhtml
index 0ec84df..6cf4efb 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/layout/main-no-leftnav.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/layout/main-no-leftnav.xhtml
@@ -115,6 +115,7 @@ REQUEST PARAMETERS:
rendered="#{ResourceUIBean.facets.content}">
<onc:subtab name="Deployed" url="/rhq/resource/content/view.xhtml" />
<onc:subtab name="New" url="/rhq/resource/content/deploy.xhtml" />
+ <onc:subtab name="Update" url="/rhq/resource/content/update.xhtml" />
<onc:subtab name="Subscriptions" url="/rhq/resource/content/subscription.xhtml" />
<onc:subtab name="History" url="/rhq/resource/content/history.xhtml" />
</onc:tab>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
index 5f8e828..3d72055 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
@@ -19,7 +19,9 @@
package org.rhq.enterprise.server.content;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
@@ -224,6 +226,22 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
String filter, PageControl pc) {
pc.initDefaultOrderingField("pv.generalPackage.name", PageOrdering.ASC);
+ Query queryInstalled = PersistenceUtility.createQueryWithOrderBy(entityManager,
+ InstalledPackage.QUERY_FIND_PACKAGE_LIST_ITEM_COMPOSITE, pc);
+
+ queryInstalled.setParameter("resourceId", resourceId);
+ queryInstalled.setParameter("packageTypeFilterId", null);
+ queryInstalled.setParameter("packageVersionFilter", null);
+ queryInstalled.setParameter("search", null);
+ queryInstalled.setParameter("search", null);
+
+ List<PackageListItemComposite> packagesInstalled = queryInstalled.getResultList();
+
+ List<String> installedPackageNames = new ArrayList<String>();
+ for (PackageListItemComposite packageInstalled : packagesInstalled) {
+ installedPackageNames.add(packageInstalled.getPackageName());
+ }
+
Query query = PersistenceUtility.createQueryWithOrderBy(entityManager,
PackageVersion.QUERY_FIND_COMPOSITE_BY_FILTERS, pc);
Query queryCount = PersistenceUtility.createCountQuery(entityManager,
@@ -237,8 +255,64 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
long count = (Long) queryCount.getSingleResult();
List<PackageVersionComposite> results = query.getResultList();
+ List<PackageVersionComposite> modifiedResults = new ArrayList<PackageVersionComposite>();
+
+ for (PackageVersionComposite result : results) {
+ if (installedPackageNames.contains(result.getPackageName())) {
+ if (count > 0)
+ count--;
+ } else {
+ modifiedResults.add(result);
+ }
+ }
+
+ return new PageList<PackageVersionComposite>(modifiedResults, (int) count, pc);
+ }
+
+ @SuppressWarnings("unchecked")
+ public PageList<PackageVersionComposite> getUpdatePackageVersionCompositesByFilter(Subject user, int resourceId,
+ String filter, PageControl pc) {
+ pc.initDefaultOrderingField("pv.generalPackage.name", PageOrdering.ASC);
+
+ Query queryInstalled = PersistenceUtility.createQueryWithOrderBy(entityManager,
+ InstalledPackage.QUERY_FIND_PACKAGE_LIST_ITEM_COMPOSITE, pc);
+
+ queryInstalled.setParameter("resourceId", resourceId);
+ queryInstalled.setParameter("packageTypeFilterId", null);
+ queryInstalled.setParameter("packageVersionFilter", null);
+ queryInstalled.setParameter("search", null);
+ queryInstalled.setParameter("search", null);
+
+ List<PackageListItemComposite> packagesInstalled = queryInstalled.getResultList();
+
+ Map<String, String> installedPackageNameAndVersion = new HashMap<String, String>();
+ for (PackageListItemComposite packageInstalled : packagesInstalled) {
+ installedPackageNameAndVersion.put(packageInstalled.getPackageName(), packageInstalled.getVersion());
+ }
+
+ Query query = PersistenceUtility.createQueryWithOrderBy(entityManager,
+ PackageVersion.QUERY_FIND_COMPOSITE_BY_FILTERS, pc);
+ query.setParameter("resourceId", resourceId);
+ query.setParameter("filter", filter);
+
+ long count = 0;
+ List<PackageVersionComposite> results = query.getResultList();
+ List<PackageVersionComposite> modifiedResults = new ArrayList<PackageVersionComposite>();
+ String packageName = new String();
+
+ for (PackageVersionComposite result : results) {
+ if (installedPackageNameAndVersion.get(result.getPackageName()) != null) {
- return new PageList<PackageVersionComposite>(results, (int) count, pc);
+ packageName = installedPackageNameAndVersion.get(result.getPackageName());
+
+ if (installedPackageNameAndVersion.get(packageName).compareTo(result.getPackageVersion().getVersion()) < 0) {
+ modifiedResults.add(result);
+ count++;
+ }
+
+ }
+ }
+ return new PageList<PackageVersionComposite>(modifiedResults, (int) count, pc);
}
public PackageVersionComposite loadPackageVersionComposite(Subject user, int packageVersionId) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerLocal.java
index 63dbc97..6b9d2f8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerLocal.java
@@ -134,6 +134,9 @@ public interface ContentUIManagerLocal {
PageList<PackageVersionComposite> getPackageVersionCompositesByFilter(Subject user, int resourceId, String filter,
PageControl pc);
+ PageList<PackageVersionComposite> getUpdatePackageVersionCompositesByFilter(Subject user, int resourceId,
+ String filter, PageControl pc);
+
/**
* Used to retrieve information about a package version to display to a user.
*
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 b428989..9d59c39 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
@@ -781,17 +781,24 @@
placement="firstChild" />
</tab>
- <tab name="Content.New" displayName="New" url="/rhq/resource/content/deploy.xhtml">
+ <tab name="Content.New" displayName="Install" url="/rhq/resource/content/deploy.xhtml">
<position
name="Content.Deployed"
placement="after" />
+ </tab>
+
+ <tab name="Content.Update" displayName="Update" url="/rhq/resource/content/update.xhtml">
+ <position
+
+ name="Content.New"
+ placement="after" />
</tab>
<tab name="Content.Subscriptions" displayName="Subscriptions" url="/rhq/resource/content/subscription.xhtml">
<position
- name="Content.New"
+ name="Content.Update"
placement="after" />
</tab>
diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java
index e6f6c09..d04210e 100644
--- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java
+++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java
@@ -1,25 +1,25 @@
- /*
- * 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.plugins.platform.content;
import java.io.BufferedReader;
@@ -27,8 +27,10 @@ import java.io.IOException;
import java.io.StringReader;
import java.util.HashSet;
import java.util.Set;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.rhq.core.domain.content.PackageDetailsKey;
import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
commit 57fa9d105ea7e5aa5aad147c6c8f93806dbe4352
Author: Sayli Karmarkar <skarmark(a)redhat.com>
Date: Thu Jan 21 05:26:11 2010 -0500
1368,1369 - Adding webUI and manager layer changes for tracking resource deployment
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/ResourceUpdatePackageVersionsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/ResourceUpdatePackageVersionsUIBean.java
new file mode 100644
index 0000000..dc801f3
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/ResourceUpdatePackageVersionsUIBean.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 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.gui.content;
+
+import javax.faces.model.DataModel;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.content.composite.PackageVersionComposite;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.gui.util.FacesContextUtility;
+import org.rhq.enterprise.gui.common.framework.PagedDataTableUIBean;
+import org.rhq.enterprise.gui.common.paging.PageControlView;
+import org.rhq.enterprise.gui.common.paging.PagedListDataModel;
+import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
+import org.rhq.enterprise.server.content.ContentUIManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+public class ResourceUpdatePackageVersionsUIBean extends PagedDataTableUIBean {
+
+ public static final String MANAGED_BEAN_NAME = "ResourceUpdatePackageVersionsUIBean";
+
+ public ResourceUpdatePackageVersionsUIBean() {
+ }
+
+ @Override
+ public DataModel getDataModel() {
+ if (dataModel == null) {
+ dataModel = new ResourceUpdatePackageVersionsDataModel(PageControlView.ResourceUpdatePackageVersionsList,
+ MANAGED_BEAN_NAME);
+ }
+
+ return dataModel;
+ }
+
+ private class ResourceUpdatePackageVersionsDataModel extends PagedListDataModel<PackageVersionComposite> {
+ public ResourceUpdatePackageVersionsDataModel(PageControlView view, String beanName) {
+ super(view, beanName);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public PageList<PackageVersionComposite> fetchPage(PageControl pc) {
+ Subject subject = EnterpriseFacesContextUtility.getSubject();
+ Integer resourceId = Integer.parseInt(FacesContextUtility.getRequiredRequestParameter("id"));
+ //String filter = FacesContextUtility.getRequiredRequestParameter("contentForm:filter");
+ ContentUIManagerLocal manager = LookupUtil.getContentUIManager();
+
+ PageList<PackageVersionComposite> results = manager.getUpdatePackageVersionCompositesByFilter(subject,
+ resourceId, null, pc);
+ return results;
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/update.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/update.xhtml
new file mode 100644
index 0000000..09c6e6b
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/update.xhtml
@@ -0,0 +1,137 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:c="http://java.sun.com/jstl/core"
+ xmlns:onc="http://jboss.org/on/component"
+ xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
+ xmlns:rich="http://richfaces.ajax4jsf.org/rich">
+
+<ui:composition template="/rhq/resource/layout/main.xhtml">
+
+ <ui:param name="pageTitle" value="Update Existing Package"/>
+ <ui:param name="selectedTabName" value="Content.Update"/>
+ <ui:define name="content">
+
+ <h:form id="currentPackageVersionsForm">
+ <input type="hidden" name="id" value="${param.id}"/>
+
+ <rich:panel styleClass="BlockContent">
+ <f:facet name="header"><h:outputText value="Packages Eligible for Update"/></f:facet>
+
+ <p>The following packages were found from the repositories currently subscribed to by this resource. In order
+ to enable more existing packages for deployment, use the subscriptions sub-tab to subscribe this resource
+ to more repositories.</p>
+
+ <a4j:keepAlive beanName="ResourcePackageVersionsUIBean"/>
+
+ <ui:param name="resourcePackageVersionsDataModel" value="#{ResourcePackageVersionsUIBean.dataModel}"/>
+ <rich:dataTable id="resourcePackageVersionsDataTable"
+ rows="#{PageControl.ResourcePackageVersionsList.pageSize}"
+ value="#{resourcePackageVersionsDataModel}"
+ var="item"
+ width="100%"
+ columnsWidth="1%, 15%, 10%, 10%, 10%, 54%"
+ headerClass="tableRowHeader"
+ footerClass="on-pager-footer"
+ onRowMouseOver="this.style.backgroundColor='#E7E7E7'"
+ onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
+
+ <f:facet name="PageControlView">
+ <onc:paginationControl id="ResourcePackageVersionsList" />
+ </f:facet>
+
+ <rich:column>
+ <f:facet name="header">
+ <onc:allSelect target="selectedPackages" />
+ </f:facet>
+
+ <onc:select name="selectedPackages" value="#{item.packageVersion.id}"/>
+ </rich:column>
+
+ <rich:column>
+ <f:facet name="header">
+ <onc:sortableColumnHeader sort="pv.generalPackage.name">
+ <h:outputText styleClass="headerText" value="Package Name" />
+ </onc:sortableColumnHeader>
+ </f:facet>
+
+ <h:outputLink value="../../content/packageVersion.xhtml">
+ <f:param name="id" value="#{item.packageVersion.id}"/>
+ <h:outputText value="#{item.packageName}"/>
+ </h:outputLink>
+
+ </rich:column>
+
+ <rich:column>
+ <f:facet name="header">
+ <onc:sortableColumnHeader sort="pv.displayVersion">
+ <h:outputText styleClass="headerText" value="Version" />
+ </onc:sortableColumnHeader>
+ </f:facet>
+
+ <h:outputText value="#{item.packageVersion.displayVersion}"/>
+ </rich:column>
+
+ <rich:column>
+ <f:facet name="header">
+ <onc:sortableColumnHeader sort="pv.generalPackage.packageType.displayName">
+ <h:outputText styleClass="headerText" value="Type" />
+ </onc:sortableColumnHeader>
+ </f:facet>
+
+ <h:outputText value="#{item.packageTypeName}"/>
+ </rich:column>
+
+ <rich:column>
+ <f:facet name="header">
+ <onc:sortableColumnHeader sort="pv.architecture">
+ <h:outputText styleClass="headerText" value="Architecture" />
+ </onc:sortableColumnHeader>
+ </f:facet>
+
+ <h:outputText value="#{item.architectureName}"/>
+ </rich:column>
+
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText styleClass="headerText" value="Description" />
+ </f:facet>
+
+ <h:outputText value="#{item.packageVersion.shortDescription}" escape="false"/>
+ </rich:column>
+
+ <f:facet name="footer">
+ <rich:columnGroup>
+ <rich:column colspan="6" width="100%">
+ <onc:selectCommandButton action="#{CreateNewPackageUIBean.deployExisting}"
+ value="DEPLOY SELECTED" target="selectedPackages" styleClass="on-pager-button buttonsmall"
+ rendered="${ResourceUIBean.permissions.content}"/>
+
+ <ui:include src="/rhq/resource/include/pagination.xhtml">
+ <ui:param name="paginationDataTableName" value="resourcePackageVersionsDataTable"/>
+ <ui:param name="paginationDataModel" value="#{resourcePackageVersionsDataModel}"/>
+ <ui:param name="paginationPageControl" value="#{PageControl.ResourcePackageVersionsList}"/>
+ </ui:include>
+ </rich:column>
+ </rich:columnGroup>
+ </f:facet>
+
+ </rich:dataTable>
+
+
+ </rich:panel>
+
+ </h:form>
+
+
+ </ui:define>
+</ui:composition>
+
+</html>
commit 77e83c9287b56bc6b993cbb4c7021bb50ce4d13d
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 10:47:30 2010 -0500
Initial version
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java
new file mode 100644
index 0000000..00a01f3
--- /dev/null
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java
@@ -0,0 +1,107 @@
+/*
+* 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.ws.test;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.testng.AssertJUnit;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.rhq.enterprise.server.ws.Advisory;
+import org.rhq.enterprise.server.ws.ObjectFactory;
+import org.rhq.enterprise.server.ws.Subject;
+import org.rhq.enterprise.server.ws.TestPropertiesInterface;
+import org.rhq.enterprise.server.ws.WebservicesManagerBeanService;
+import org.rhq.enterprise.server.ws.WebservicesRemote;
+import org.rhq.enterprise.server.ws.test.util.WsSubjectUtility;
+import org.rhq.enterprise.server.ws.utility.WsUtility;
+
+/**
+ * Web service tests for the advisory manager services.
+ *
+ * @author Jason Dobies
+ */
+@Test(groups = "ws")
+public class WsAdvisoryManagerTest extends AssertJUnit implements TestPropertiesInterface {
+
+ private static final boolean TESTS_ENABLED = true;
+
+ private WebservicesRemote service;
+ private ObjectFactory objectFactory;
+
+ private WsSubjectUtility subjectUtil;
+
+ @BeforeClass
+ public void setup() throws Exception {
+
+ // Variables needed
+ URL gUrl = WsUtility.generateRemoteWebserviceURL(WebservicesManagerBeanService.class, host, port, useSSL);
+ QName gQName = WsUtility.generateRemoteWebserviceQName(WebservicesManagerBeanService.class);
+
+ // Establish outbound webservices connections
+ WebservicesManagerBeanService jws = new WebservicesManagerBeanService(gUrl, gQName);
+ service = jws.getWebservicesManagerBeanPort();
+
+ objectFactory = new ObjectFactory();
+
+ subjectUtil = new WsSubjectUtility(service);
+ }
+
+ @Test(enabled = TESTS_ENABLED)
+ public void createGetDeleteAdvisory() throws Exception {
+
+ // Setup
+ String label = "WsAdvisoryManagerTest.createGetDeleteAdvisory.label";
+ String synopsis = "WsAdvisoryManagerTest.createGetDeleteAdvisory.name";
+ String type = "bugfix";
+
+ Subject admin = subjectUtil.admin();
+
+ // Test
+ Advisory created = service.createAdvisory(admin, label, type, synopsis);
+
+ assert created != null;
+
+ Advisory retrieved = service.getAdvisoryByName(label);
+
+ service.deleteAdvisoryByAdvId(admin, created.getId());
+
+ // Verify
+ assert label.equals(created.getAdvisory()) : "Found: " + created.getAdvisory();
+ assert synopsis.equals(created.getSynopsis()) : "Found: " + created.getAdvisoryName();
+ assert type.equals(created.getAdvisoryType()) : "Found: " + created.getAdvisoryType();
+
+ assert retrieved != null;
+ assert label.equals(retrieved.getAdvisory()) : "Found: " + retrieved.getAdvisory();
+ assert synopsis.equals(retrieved.getSynopsis()) : "Found: " + retrieved.getAdvisoryName();
+ assert type.equals(retrieved.getAdvisoryType()) : "Found: " + retrieved.getAdvisoryType();
+
+ retrieved = service.getAdvisoryByName(label);
+
+ assert retrieved == null;
+ }
+
+}
commit b02df6c83f1c6144af94145a3b5fad3c2296c071
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 10:46:47 2010 -0500
Accidentally removed the ws excluded group, didn't mean to commit that.
diff --git a/modules/enterprise/remoting/webservices/pom.xml b/modules/enterprise/remoting/webservices/pom.xml
index b0922a7..833d0d4 100644
--- a/modules/enterprise/remoting/webservices/pom.xml
+++ b/modules/enterprise/remoting/webservices/pom.xml
@@ -160,7 +160,7 @@
<excludes>
<exclude>com/**/*.java</exclude>
</excludes>
- <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
+ <excludedGroups>${rhq.testng.excludedGroups},ws</excludedGroups>
<systemProperties>
<property>
<name>deploymentDirectory</name>
commit 410605fc772991aefd9ff8945cbe43fa883b5d65
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 10:34:57 2010 -0500
Renamed incorrect parameter name (was "name" in remote but "synopsis" in bean)
diff --git a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
index c4c8aed..d261413 100644
--- a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
+++ b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
@@ -35,6 +35,7 @@ import org.rhq.enterprise.server.alert.AlertManagerRemote;
import org.rhq.enterprise.server.auth.SubjectManagerRemote;
import org.rhq.enterprise.server.authz.RoleManagerRemote;
import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
+import org.rhq.enterprise.server.content.AdvisoryManagerRemote;
import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
@@ -66,10 +67,11 @@ import org.rhq.enterprise.server.system.SystemManagerRemote;
public class RemoteClient {
public enum Manager {
+ AdvisoryManager(AdvisoryManagerRemote.class), //
AlertManager(AlertManagerRemote.class), //
AlertDefinitionManager(AlertDefinitionManagerRemote.class), //
AvailabilityManager(AvailabilityManagerRemote.class), //
- CallTimeDataManager(CallTimeDataManagerRemote.class), //
+ CallTimeDataManager(CallTimeDataManagerRemote.class), //
RepoManager(RepoManagerRemote.class), //
ConfigurationManager(ConfigurationManagerRemote.class), //
//ContentHelperManager(ContentHelperRemote.class), //
@@ -79,7 +81,7 @@ public class RemoteClient {
EventManager(EventManagerRemote.class), //
MeasurementBaselineManager(MeasurementBaselineManagerRemote.class), //
MeasurementDataManager(MeasurementDataManagerRemote.class), //
- MeasurementDefinitionManager(MeasurementDefinitionManagerRemote.class), //
+ MeasurementDefinitionManager(MeasurementDefinitionManagerRemote.class), //
MeasurementScheduleManager(MeasurementScheduleManagerRemote.class), //
OperationManager(OperationManagerRemote.class), //
ResourceManager(ResourceManagerRemote.class), //
@@ -133,7 +135,7 @@ public class RemoteClient {
* Creates a client that will communicate with the server running on the given host
* listening on the given port. This constructor will not attempt to connect or login
* to the remote server - use {@link #login(String, String)} for that.
- *
+ *
* @param host
* @param port
*/
@@ -146,7 +148,7 @@ public class RemoteClient {
* listening on the given port over the given transport.
* This constructor will not attempt to connect or login
* to the remote server - use {@link #login(String, String)} for that.
- *
+ *
* @param transport valid values are "servlet" and "sslservlet" - if <code>null</code>,
* sslservlet will be used for ports that end with "443", servlet otherwise
* @param host
@@ -167,7 +169,7 @@ public class RemoteClient {
* Connects to the remote server and logs in with the given credentials.
* After successfully executing this, {@link #isLoggedIn()} will be <code>true</code>
* and {@link #getSubject()} will return the subject that this method returns.
- *
+ *
* @param user
* @param password
*
@@ -211,10 +213,10 @@ public class RemoteClient {
/**
* Connects to the remote server but does not establish a user session. This can be used
* with the limited API that does not require a Subject.
- *
+ *
* After successfully executing this, {@link #isConnected()} will be <code>true</code>
* and {@link #getSubject()} will return the subject that this method returns.
- *
+ *
* @param user
* @param password
*
@@ -249,7 +251,7 @@ public class RemoteClient {
/**
* Returns <code>true</code> if and only if this client successfully connected
* to the remote server and the user successfully logged in.
- *
+ *
* @return if the user was able to connect and log into the server
*/
public boolean isLoggedIn() {
@@ -259,7 +261,7 @@ public class RemoteClient {
/**
* Returns <code>true</code> if and only if this client successfully connected
* to the remote server.
- *
+ *
* @return if the user was able to connect and log into the server
*/
public boolean isConnected() {
@@ -269,7 +271,7 @@ public class RemoteClient {
/**
* Returns the information on the user that is logged in.
* May be <code>null</code> if the user never logged in successfully.
- *
+ *
* @return user information or <code>null</code>
*/
public Subject getSubject() {
@@ -301,13 +303,17 @@ public class RemoteClient {
* be set appropriately for the {@link #getPort()} (e.g. a secure transport
* will be used for ports that end with 443, a non-secure transport will be
* used for all other ports).
- *
+ *
* @param transport
*/
public void setTransport(String transport) {
this.transport = transport;
}
+ public AdvisoryManagerRemote getAdvisoryManagerRemote() {
+ return RemoteClientProxy.getProcessor(this, Manager.AdvisoryManager);
+ }
+
public AlertManagerRemote getAlertManagerRemote() {
return RemoteClientProxy.getProcessor(this, Manager.AlertManager);
}
@@ -407,7 +413,7 @@ public class RemoteClient {
/**
* Returns the map of all remote managers running in the server that this
* client can talk to.
- *
+ *
* @return Map K=manager name V=remote proxy
*/
public Map<String, Object> getManagers() {
@@ -431,9 +437,9 @@ public class RemoteClient {
/**
* Returns the internal JBoss/Remoting client used to perform the low-level
* comm with the server.
- *
+ *
* This is package-scoped so the proxy can use it.
- *
+ *
* @return remoting client used to talk to the server
*/
Client getRemotingClient() {
@@ -509,7 +515,7 @@ public class RemoteClient {
* Looks up the prop name in system properties and puts the value in the map. If the property
* isn't set, the given default is used. If the given default is null and the property isn't
* set, then the map is not populated.
- *
+ *
* @param configMap
* @param propName
* @param defaultValue
diff --git a/modules/enterprise/remoting/webservices/pom.xml b/modules/enterprise/remoting/webservices/pom.xml
index 833d0d4..b0922a7 100644
--- a/modules/enterprise/remoting/webservices/pom.xml
+++ b/modules/enterprise/remoting/webservices/pom.xml
@@ -160,7 +160,7 @@
<excludes>
<exclude>com/**/*.java</exclude>
</excludes>
- <excludedGroups>${rhq.testng.excludedGroups},ws</excludedGroups>
+ <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
<systemProperties>
<property>
<name>deploymentDirectory</name>
diff --git a/modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml b/modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml
index e4ab64b..3044936 100644
--- a/modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml
+++ b/modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml
@@ -9,9 +9,10 @@
<property name="wsprovide.home" location="${project.build.outputDirectory}/wsprovide-output" />
<property name="include.client.jar" value="true" />
- <!-- load all the Stateless Session Bean for WS exposure as properties. Must add bean as separate
+ <!-- load all the Stateless Session Bean for WS exposure as properties. Must add bean as separate
property AND in the "ws-list" below for successful inclusion. ##TODO SP: collapse these to one list. -->
<property name="PropertyBagManager" value="org.rhq.enterprise.server.jaxb.PropertyBagManagerBean" />
+ <property name="AdvisoryManager" value="org.rhq.enterprise.server.content.AdvisoryManagerBean"/>
<property name="AlertManager" value="org.rhq.enterprise.server.alert.AlertManagerBean" />
<property name="AlertDefinitionManager" value="org.rhq.enterprise.server.alert.AlertDefinitionManagerBean" />
<property name="AvailabilityManager" value="org.rhq.enterprise.server.measurement.AvailabilityManagerBean" />
@@ -79,9 +80,9 @@
</patternset>
</unzip>
- <!-- Run JBossWS 3.1.1 upgrade script on the JBossAS:
- i) pull upgrade bundle
- ii) unzip
+ <!-- Run JBossWS 3.1.1 upgrade script on the JBossAS:
+ i) pull upgrade bundle
+ ii) unzip
iii) run it on JBossAS instance (4.2.3) to 3.1.1.
These upgrade steps should be revisited when moving JBossAS version beyond 4.2.3 -->
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
index cbcea16..b4367db 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
@@ -51,8 +51,6 @@ public class WsRegistrationManagerTest extends AssertJUnit implements TestProper
private WebservicesRemote service;
private ObjectFactory objectFactory;
- private Subject subject;
-
@BeforeClass
public void setup() throws Exception {
@@ -65,16 +63,6 @@ public class WsRegistrationManagerTest extends AssertJUnit implements TestProper
service = jws.getWebservicesManagerBeanPort();
objectFactory = new ObjectFactory();
-
- // Establish a new user in the system
- WsSubjectUtility subjectUtil = new WsSubjectUtility(service);
- subject = subjectUtil.createOrLoginUser("reg-manager-test", "reg-manager-test");
- }
-
- @AfterClass
- public void teardown() throws Exception {
- WsSubjectUtility subjectUtil = new WsSubjectUtility(service);
- subjectUtil.deleteUser(subject.getId());
}
@Test(enabled = TESTS_ENABLED)
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java
index 2caeeb7..cb0514f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java
@@ -44,7 +44,7 @@ public interface AdvisoryManagerRemote {
* Creates a new advisory in the system. If the advisory does not exist, it will be created.
* If a advisory exists with the specified version ID, a new one will not be created and the
* existing advisory will be returned.
- * @param subject
+ * @param user
* @param advisory advisory label
* @param advisoryType adv type
* @return newly created advisory object
@@ -52,7 +52,7 @@ public interface AdvisoryManagerRemote {
@WebMethod
Advisory createAdvisory(@WebParam(name = "subject") Subject user, @WebParam(name = "advisory") String advisory, //
@WebParam(name = "advisoryType") String advisoryType, //
- @WebParam(name = "advisoryName") String advisoryName) throws AdvisoryException;
+ @WebParam(name = "advisoryName") String synopsis) throws AdvisoryException;
/**
* creates a cve instance for a given cve name
@@ -65,14 +65,14 @@ public interface AdvisoryManagerRemote {
@WebParam(name = "cvename") String cvename) throws AdvisoryException;
/**
- * creates a AdvisoryCVE relationship object
+ * creates a AdvisoryCVE relationship object
* @param user
* @param advisory
* @param cve
* @return AdvisoryCVE object
* @throws AdvisoryException
*/
- AdvisoryCVE createAdvisoryCVE(@WebParam(name = "subject") Subject user, //
+ AdvisoryCVE createAdvisoryCVE(@WebParam(name = "subject") Subject user, //
@WebParam(name = "advisory") Advisory advisory, //
@WebParam(name = "cve") CVE cve) throws AdvisoryException;
@@ -183,7 +183,7 @@ public interface AdvisoryManagerRemote {
/**
* find AdvisoryPackage object for given advId and packageVersion id
* @param overlord
- * @param advId
+ * @param advId
* @param pkgVerId
*/
@WebMethod
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
index 8c43cb4..53c1be0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
@@ -38,6 +38,7 @@ import org.rhq.enterprise.server.alert.AlertManagerBean;
import org.rhq.enterprise.server.auth.SubjectManagerBean;
import org.rhq.enterprise.server.authz.RoleManagerBean;
import org.rhq.enterprise.server.configuration.ConfigurationManagerBean;
+import org.rhq.enterprise.server.content.AdvisoryManagerBean;
import org.rhq.enterprise.server.content.ContentManagerBean;
import org.rhq.enterprise.server.content.RepoManagerBean;
import org.rhq.enterprise.server.event.EventManagerBean;
@@ -64,7 +65,8 @@ import org.rhq.enterprise.server.system.SystemManagerBean;
public class RemoteAPIValidator {
private static Class<?>[] beans = new Class[] { //
- AlertDefinitionManagerBean.class, //
+ AdvisoryManagerBean.class, //
+ AlertDefinitionManagerBean.class, //
AlertManagerBean.class,//
AvailabilityManagerBean.class,//
CallTimeDataManagerBean.class, //
@@ -93,8 +95,8 @@ public class RemoteAPIValidator {
private static Set<String> finderMethodExceptions = new HashSet<String>();
static {
- /*
- * unless otherwise noted, all of the below methods return data considered to
+ /*
+ * unless otherwise noted, all of the below methods return data considered to
* be single, logical objects even though they are implemented as list structures
*/
finderMethodExceptions.add("translateInstallationSteps");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 19e07ac..af011a6 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -28,6 +28,7 @@ import java.util.Map;
import java.util.Set;
import javax.ejb.Stateless;
+import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -47,7 +48,11 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.group.GroupPluginConfigurationUpdate;
import org.rhq.core.domain.configuration.group.GroupResourceConfigurationUpdate;
import org.rhq.core.domain.content.Advisory;
+import org.rhq.core.domain.content.AdvisoryBuglist;
+import org.rhq.core.domain.content.AdvisoryCVE;
+import org.rhq.core.domain.content.AdvisoryPackage;
import org.rhq.core.domain.content.Architecture;
+import org.rhq.core.domain.content.CVE;
import org.rhq.core.domain.content.Distribution;
import org.rhq.core.domain.content.InstalledPackage;
import org.rhq.core.domain.content.PackageType;
@@ -104,6 +109,8 @@ import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.RoleManagerLocal;
import org.rhq.enterprise.server.configuration.ConfigurationManagerLocal;
import org.rhq.enterprise.server.configuration.ConfigurationUpdateStillInProgressException;
+import org.rhq.enterprise.server.content.AdvisoryException;
+import org.rhq.enterprise.server.content.AdvisoryManagerLocal;
import org.rhq.enterprise.server.content.ContentManagerLocal;
import org.rhq.enterprise.server.content.RepoException;
import org.rhq.enterprise.server.content.RepoManagerLocal;
@@ -142,8 +149,8 @@ import org.rhq.enterprise.server.util.LookupUtil;
/** The purpose of this class is to aggregate all the EJB remote implementation into one
* class that can be annotated by JBossWS. Each annotated SLSB causes a full WSDL compile and
- * publish by JBossWS which is very costly in terms of time. Deploy times went from 2 mins to 12 mins.
- *
+ * publish by JBossWS which is very costly in terms of time. Deploy times went from 2 mins to 12 mins.
+ *
* @author Simeon Pinder
*
*/
@@ -154,6 +161,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class WebservicesManagerBean implements WebservicesRemote {
//Lookup the required beans as local references
+ private AdvisoryManagerLocal advisoryManager = LookupUtil.getAdvisoryManagerLocal();
private AlertManagerLocal alertManager = LookupUtil.getAlertManager();
private AlertDefinitionManagerLocal alertDefinitionManager = LookupUtil.getAlertDefinitionManager();
private AvailabilityManagerLocal availabilityManager = LookupUtil.getAvailabilityManager();
@@ -182,6 +190,94 @@ public class WebservicesManagerBean implements WebservicesRemote {
private SupportManagerLocal supportManager = LookupUtil.getSupportManager();
private SystemManagerLocal systemManager = LookupUtil.getSystemManager();
+ //ADVISORYMANAGER: BEGIN ------------------------------------------
+
+ public Advisory createAdvisory(@WebParam(name = "subject") Subject user,
+ @WebParam(name = "advisory") String advisory,
+ @WebParam(name = "advisoryType") String advisoryType,
+ @WebParam(name = "advisoryName") String advisoryName) throws AdvisoryException {
+ return advisoryManager.createAdvisory(user, advisory, advisoryType, advisoryName);
+ }
+
+ public CVE createCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "cvename") String cvename)
+ throws AdvisoryException {
+ return advisoryManager.createCVE(user, cvename);
+ }
+
+ public AdvisoryCVE createAdvisoryCVE(@WebParam(name = "subject") Subject user,
+ @WebParam(name = "advisory") Advisory advisory,
+ @WebParam(name = "cve") CVE cve) throws AdvisoryException {
+ return advisoryManager.createAdvisoryCVE(user, advisory, cve);
+ }
+
+ public AdvisoryPackage createAdvisoryPackage(@WebParam(name = "subject") Subject user,
+ @WebParam(name = "advisory") Advisory advisory,
+ @WebParam(name = "pkg") PackageVersion pkg) throws AdvisoryException {
+ return advisoryManager.createAdvisoryPackage(user, advisory, pkg);
+ }
+
+ public void deleteCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "cveId") int cveId) {
+ advisoryManager.deleteAdvisoryCVE(user, cveId);
+ }
+
+ public void deleteAdvisoryCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "advId") int advId) {
+ advisoryManager.deleteAdvisoryCVE(user, advId);
+ }
+
+ public void deleteAdvisoryByAdvId(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "advId") int advId) {
+ advisoryManager.deleteAdvisoryByAdvId(subject, advId);
+ }
+
+ public Advisory getAdvisoryByName(@WebParam(name = "advlabel") String advlabel) {
+ return advisoryManager.getAdvisoryByName(advlabel);
+ }
+
+ public List<AdvisoryPackage> findPackageByAdvisory(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "advId") int advId,
+ @WebParam(name = "pc") PageControl pc) {
+ return advisoryManager.findPackageByAdvisory(subject, advId, pc);
+ }
+
+ public PackageVersion findPackageVersionByPkgId(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "rpmName") String rpmName,
+ @WebParam(name = "pc") PageControl pc) {
+ return advisoryManager.findPackageVersionByPkgId(subject, rpmName, pc);
+ }
+
+ public PageList<AdvisoryCVE> getAdvisoryCVEByAdvId(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "advId") int advId,
+ @WebParam(name = "pc") PageControl pc) {
+ return advisoryManager.getAdvisoryCVEByAdvId(subject, advId, pc);
+ }
+
+ public List<AdvisoryBuglist> getAdvisoryBuglistByAdvId(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "advId") int advId) {
+ return advisoryManager.getAdvisoryBuglistByAdvId(subject, advId);
+ }
+
+ public void deleteAdvisoryBugList(@WebParam(name = "subject") Subject overlord, @WebParam(name = "advId") int id) {
+ advisoryManager.deleteAdvisoryBugList(overlord, id);
+ }
+
+ public void deleteAdvisoryPackage(@WebParam(name = "subject") Subject user, @WebParam(name = "advId") int advId) {
+ advisoryManager.deleteAdvisoryPackage(user, advId);
+ }
+
+ public AdvisoryPackage findAdvisoryPackage(@WebParam(name = "subject") Subject overlord,
+ @WebParam(name = "advId") int advId,
+ @WebParam(name = "pkgVerId") int pkgVerId) {
+ return advisoryManager.findAdvisoryPackage(overlord, advId, pkgVerId);
+ }
+
+ public AdvisoryBuglist getAdvisoryBuglist(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "advId") int advId,
+ @WebParam(name = "buginfo") String buginfo) {
+ return advisoryManager.getAdvisoryBuglist(subject, advId, buginfo);
+ }
+
+ //ADVISORYMANAGER: END ------------------------------------------
+
//ALERTMANAGER: BEGIN ------------------------------------------
public PageList<Alert> findAlertsByCriteria(Subject subject, AlertCriteria criteria) {
return alertManager.findAlertsByCriteria(subject, criteria);
@@ -443,7 +539,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
//DATAACCESSMANAGER: END ----------------------------------
- //DISCOVERYBOSS: BEGIN ------------------------------------
+ //DISCOVERYBOSS: BEGIN ------------------------------------
public void ignoreResources(Subject subject, Integer[] resourceIds) {
discoveryBoss.ignoreResources(subject, resourceIds);
}
@@ -636,7 +732,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public ResourceOperationSchedule scheduleResourceOperation(Subject subject, int resourceId, String operationName,
- long delay, long repeatInterval, int repeatCount, int timeout,//
+ long delay, long repeatInterval, int repeatCount, int timeout,//
@XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
Configuration parameters, String description) throws ScheduleException {
return operationManager.scheduleResourceOperation(subject, resourceId, operationName, delay, repeatInterval,
@@ -774,7 +870,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
//RESOURCEGROUPMANAGER: END ----------------------------------
- //RESOURCETYPEMANAGER: BEGIN ------------------------------------
+ //RESOURCETYPEMANAGER: BEGIN ------------------------------------
public PageList<ResourceType> findResourceTypesByCriteria(Subject subject, ResourceTypeCriteria criteria) {
return resourceTypeManager.findResourceTypesByCriteria(subject, criteria);
}
@@ -904,12 +1000,12 @@ public class WebservicesManagerBean implements WebservicesRemote {
//SUPPORTMANAGER: END ------------------------------------
- //SYSTEMMANAGER: BEGIN ------------------------------------
+ //SYSTEMMANAGER: BEGIN ------------------------------------
public ServerVersion getServerVersion(Subject subject) throws Exception {
return systemManager.getServerVersion(subject);
}
- //SYSTEMMANAGER: END ------------------------------------
+ //SYSTEMMANAGER: END ------------------------------------
private void checkParametersPassedIn(Subject subject, Criteria criteria) {
if (subject == null) {
commit 7c41a5d483fbf4a3018ed45f042ae3db15d7cedf
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 09:29:37 2010 -0500
Removed invalid tag from interface implementation
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 0d70c64..d6b8e12 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
@@ -1050,7 +1050,6 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
return syncCount;
}
- @Override
public void cancelSync(Subject subject, int repoId) throws ContentException {
ContentServerPluginContainer pc;
try {
commit 16663f2213a07d3e8044e6e6043c6c979631b3fe
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 08:49:33 2010 -0500
Exposed the advisory manager as a web service
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
index 8f72716..eb5937b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
@@ -9,6 +9,7 @@ import org.rhq.enterprise.server.alert.AlertManagerRemote;
import org.rhq.enterprise.server.auth.SubjectManagerRemote;
import org.rhq.enterprise.server.authz.RoleManagerRemote;
import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
+import org.rhq.enterprise.server.content.AdvisoryManagerRemote;
import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
@@ -34,6 +35,7 @@ import org.rhq.enterprise.server.system.SystemManagerRemote;
@WebService(targetNamespace = ServerVersion.namespace)
@Remote
public interface WebservicesRemote extends //
+ AdvisoryManagerRemote, //
AlertManagerRemote, //
AlertDefinitionManagerRemote, //
AvailabilityManagerRemote,//
@@ -56,7 +58,7 @@ public interface WebservicesRemote extends //
ResourceManagerRemote,//
ResourceTypeManagerRemote,//
RoleManagerRemote,//
- SubjectManagerRemote,//
+ SubjectManagerRemote,//
SupportManagerRemote,//
SystemManagerRemote, //
RegistrationManagerRemote {
commit 1340ca2042e40df0788cc27e39d348ca28c44ba2
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 08:44:11 2010 -0500
Removed System.out.println call
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
index 6d7fc3a..44a7846 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
@@ -248,7 +248,6 @@ public class AdvisoryManagerBean implements AdvisoryManagerLocal, AdvisoryManage
/**
* find list of Packages Versions associated to an advisory
- * @param pkgId packageId
* @return list of PackageVersion objects
*/
@SuppressWarnings("unchecked")
@@ -350,7 +349,7 @@ public class AdvisoryManagerBean implements AdvisoryManagerLocal, AdvisoryManage
if (adv.getAdvisory() == null || adv.getAdvisory().trim().equals("")) {
throw new AdvisoryException("A valid Advisory tree is required");
}
- System.out.println("Advisory validating done " + adv);
+ log.debug("Advisory validating done " + adv);
}
}
commit 17674f20a8843b50a16e49d7981e72aca5aad02b
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 08:36:19 2010 -0500
Added test group
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
index 6b7d8dd..cbcea16 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
@@ -43,6 +43,7 @@ import org.rhq.enterprise.server.ws.utility.WsUtility;
*
* @author Jason Dobies
*/
+@Test(groups = "ws")
public class WsRegistrationManagerTest extends AssertJUnit implements TestPropertiesInterface {
private static final boolean TESTS_ENABLED = true;
commit bbd8b6b6974901b1d561ae14a8fe1437076eeaac
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 08:27:45 2010 -0500
Added comment
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
index 99087c9..6b7d8dd 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
@@ -85,6 +85,8 @@ public class WsRegistrationManagerTest extends AssertJUnit implements TestProper
Subject admin = subjectUtil.admin();
// Test
+
+ // Note: randomPlatform calls #registerPlatform, which is why there's no explicit test for that
Resource created = resourceUtil.randomPlatform();
service.importPlatform(admin, created);
commit 181cf1c2d647f209da61134c81b16b091631118b
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 08:20:43 2010 -0500
Steps towards automation of web service tests.
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
new file mode 100644
index 0000000..99087c9
--- /dev/null
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
@@ -0,0 +1,108 @@
+/*
+* 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.ws.test;
+
+import java.lang.Exception;
+import java.net.URL;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.testng.AssertJUnit;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.rhq.enterprise.server.ws.*;
+import org.rhq.enterprise.server.ws.test.util.WsResourceUtility;
+import org.rhq.enterprise.server.ws.test.util.WsSubjectUtility;
+import org.rhq.enterprise.server.ws.utility.WsUtility;
+
+/**
+ * Web service tests for the registration manager services.
+ *
+ * @author Jason Dobies
+ */
+public class WsRegistrationManagerTest extends AssertJUnit implements TestPropertiesInterface {
+
+ private static final boolean TESTS_ENABLED = true;
+
+ private WebservicesRemote service;
+ private ObjectFactory objectFactory;
+
+ private Subject subject;
+
+ @BeforeClass
+ public void setup() throws Exception {
+
+ // Variables needed
+ URL gUrl = WsUtility.generateRemoteWebserviceURL(WebservicesManagerBeanService.class, host, port, useSSL);
+ QName gQName = WsUtility.generateRemoteWebserviceQName(WebservicesManagerBeanService.class);
+
+ // Establish outbound webservices connections
+ WebservicesManagerBeanService jws = new WebservicesManagerBeanService(gUrl, gQName);
+ service = jws.getWebservicesManagerBeanPort();
+
+ objectFactory = new ObjectFactory();
+
+ // Establish a new user in the system
+ WsSubjectUtility subjectUtil = new WsSubjectUtility(service);
+ subject = subjectUtil.createOrLoginUser("reg-manager-test", "reg-manager-test");
+ }
+
+ @AfterClass
+ public void teardown() throws Exception {
+ WsSubjectUtility subjectUtil = new WsSubjectUtility(service);
+ subjectUtil.deleteUser(subject.getId());
+ }
+
+ @Test(enabled = TESTS_ENABLED)
+ public void importPlatform() throws Exception {
+
+ // Setup
+ WsResourceUtility resourceUtil = new WsResourceUtility(service);
+ WsSubjectUtility subjectUtil = new WsSubjectUtility(service);
+ Subject admin = subjectUtil.admin();
+
+ // Test
+ Resource created = resourceUtil.randomPlatform();
+ service.importPlatform(admin, created);
+
+ // Verify and Cleanup
+ try {
+ ResourceCriteria criteria = objectFactory.createResourceCriteria();
+ criteria.setFilterId(created.getId());
+ List<Resource> resources = service.findResourcesByCriteria(admin, criteria);
+
+ assert resources.size() == 1 : "Incorrect number of resources returned. Found: " + resources.size();
+
+ Resource retrieved = resources.get(0);
+
+ assert retrieved.getName().equals(created.getName());
+ assert retrieved.getInventoryStatus().equals(InventoryStatus.COMMITTED);
+ } finally {
+ resourceUtil.deleteResource(created.getId());
+ }
+
+ }
+}
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java
index 7534deb..10cc5ad 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java
@@ -22,8 +22,97 @@
*/
package org.rhq.enterprise.server.ws.test.util;
+import java.util.List;
+
+import org.rhq.enterprise.server.ws.ObjectFactory;
+import org.rhq.enterprise.server.ws.Resource;
+import org.rhq.enterprise.server.ws.ResourceCriteria;
+import org.rhq.enterprise.server.ws.ResourceType;
+import org.rhq.enterprise.server.ws.ResourceTypeCriteria;
+import org.rhq.enterprise.server.ws.Subject;
+import org.rhq.enterprise.server.ws.WebservicesRemote;
+
/**
+ * Utility functions for working with resources via web service calls.
+ *
* @author Jason Dobies
*/
public class WsResourceUtility {
+
+ private WebservicesRemote service;
+ private WsSubjectUtility subjectUtil;
+ private ObjectFactory objectFactory;
+
+ /**
+ * Initializes a new instance to use the given connection to a running server.
+ *
+ * @param service must be in a state where remote calls can be made (i.e. the server is running)
+ */
+ public WsResourceUtility(WebservicesRemote service) {
+ this.service = service;
+ this.subjectUtil = new WsSubjectUtility(service);
+ this.objectFactory = new ObjectFactory();
+ }
+
+ /**
+ * Creates and returns a new platform in the system with a randomly generated name. The platform will be
+ * of type 'Linux'.
+ * <p/>
+ * Resources created in this way should be removed via {@link #deleteResource(int)} at the end of the test run.
+ *
+ * @return WS representation of the created platform
+ * @throws Exception if the platform cannot be created successfully
+ * @see #deleteResource(int)
+ */
+ public Resource randomPlatform() throws Exception {
+
+ long randomSeed = System.currentTimeMillis();
+ Subject admin = subjectUtil.admin();
+
+ // Use the default Linux platform
+ ResourceTypeCriteria typeCriteria = objectFactory.createResourceTypeCriteria();
+ typeCriteria.setFilterName("Linux");
+ List<ResourceType> types = service.findResourceTypesByCriteria(admin, typeCriteria);
+
+ if (types.size() != 1) {
+ throw new RuntimeException("Unexpected number of resource types returned for " +
+ "type [Linux]. Expected [1], Found [" + types.size() + "]");
+ }
+
+ // Information about the resource being created
+ String name = "Test Platform " + randomSeed;
+
+ Resource resource = objectFactory.createResource();
+ resource.setName(name);
+ resource.setResourceKey(name);
+ resource.setDescription("WsResourceUtility Created");
+ resource.setVersion("1.0");
+ resource.setResourceType(types.get(0));
+
+ // Register the platform
+ service.registerPlatform(admin, resource, -1);
+
+ // Retrieve for return
+ ResourceCriteria criteria = objectFactory.createResourceCriteria();
+ criteria.setFilterName(name);
+ List<Resource> resources = service.findResourcesByCriteria(admin, criteria);
+
+ if (resources.size() != 1) {
+ throw new RuntimeException("Unexpected number of resources returned for name [" +
+ name + "]. Expected [1], Found [" + resources.size() + "]");
+ }
+
+ return resources.get(0);
+ }
+
+ /**
+ * Deletes the indicated resource from the server.
+ *
+ * @param resourceId must refer to an existing resource in the server
+ * @throws Exception if the resource cannot be deleted
+ */
+ public void deleteResource(int resourceId) throws Exception {
+ Subject admin = subjectUtil.admin();
+ service.deleteResource(admin, resourceId);
+ }
}
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsSubjectUtility.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsSubjectUtility.java
new file mode 100644
index 0000000..fca9dad
--- /dev/null
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsSubjectUtility.java
@@ -0,0 +1,153 @@
+/*
+* 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.ws.test.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.rhq.enterprise.server.ws.ObjectFactory;
+import org.rhq.enterprise.server.ws.Role;
+import org.rhq.enterprise.server.ws.RoleCriteria;
+import org.rhq.enterprise.server.ws.Subject;
+import org.rhq.enterprise.server.ws.WebservicesRemote;
+
+/**
+ * @author Jason Dobies
+ */
+public class WsSubjectUtility {
+
+ private static final String ADMIN_USERNAME = "rhqadmin";
+ private static final String ADMIN_PASSWORD = "rhqadmin";
+
+ private WebservicesRemote service;
+ private ObjectFactory objectFactory;
+
+ /**
+ * Initializes a new instance to use the given connection to a running server.
+ *
+ * @param service must be in a state where remote calls can be made (i.e. the server is running)
+ */
+ public WsSubjectUtility(WebservicesRemote service) {
+ this.service = service;
+ this.objectFactory = new ObjectFactory();
+ }
+
+ /**
+ * Logs in and returns a WS representation of the default admin user.
+ *
+ * @return WS subject representing the default admin
+ * @throws Exception if there is an error in the remote call
+ * @see #ADMIN_USERNAME
+ * @see #ADMIN_PASSWORD
+ */
+ public Subject admin() throws Exception {
+ Subject admin = service.login(ADMIN_USERNAME, ADMIN_PASSWORD);
+ return admin;
+ }
+
+ /**
+ * Retrieves a WS subject object for the given credentials. If the user does not exist,
+ * it will be created first, assigning it to all roles in the system. The subject will be logged
+ * in as part of this call.
+ * <p/>
+ * Calls to this should be accompanied by a call to {#deleteUser(String} to clean up.
+ *
+ * @param username may not be <code>null</code>
+ * @param password may not be <code>null</code>
+ * @return WS subject object that can be used for remote calls that require a subject
+ * @throws Exception if anything goes wrong, most likely in the remote calls
+ * @see #deleteUser(int)
+ */
+ public Subject createOrLoginUser(String username, String password) throws Exception {
+
+ // If the user already exists, return that
+ try {
+ Subject user = service.login(username, password);
+ if (user != null) {
+ return user;
+ }
+ }
+ catch (Throwable e) {
+ // Will occur if the user does not exist, so this should occur often
+ }
+
+ // Otherwise, create the user
+ Subject newUser = new Subject();
+ newUser.setName(username);
+ newUser.setFirstName("WsSubjectUtility Created");
+ newUser.setLastName("WsSubjectUtility Created");
+ newUser.setEmailAddress(username + "@wssubjectutility");
+ newUser.setDepartment("WsSubjectUtility Created");
+
+ Subject admin = admin();
+ Subject created = service.createSubject(admin, newUser);
+
+ service.createPrincipal(admin, username, password);
+
+ // Assign to all roles
+ RoleCriteria criteria = objectFactory.createRoleCriteria();
+ List<Role> allRoles = service.findRolesByCriteria(admin, criteria);
+ List<Integer> roleIds = rolesToIds(allRoles);
+
+ service.addRolesToSubject(admin, created.getId(), roleIds);
+
+ return created;
+ }
+
+ /**
+ * Deletes an existing user from the system.
+ *
+ * @param subjectId must represent a valid subject in the system
+ * @throws Exception if there is an error in the remoting
+ * @see #deleteUsers(List)
+ */
+ public void deleteUser(int subjectId) throws Exception {
+ List<Integer> deleteUs = new ArrayList<Integer>(1);
+ deleteUs.add(subjectId);
+ service.deleteSubjects(admin(), deleteUs);
+ }
+
+ /**
+ * Deletes a number of users from the system.
+ *
+ * @param deleteUs IDs of one or more users in the system to delete
+ * @throws Exception if there is an error in the remoting
+ */
+ public void deleteUsers(List<Integer> deleteUs) throws Exception {
+ service.deleteSubjects(admin(), deleteUs);
+ }
+
+ /**
+ * Simple transformer from list of {@link Role} objects to a list of their respective IDs.
+ *
+ * @param roles cannot be <code>null</code>
+ * @return new list of the same size as <code>roles</code>
+ */
+ private List<Integer> rolesToIds(List<Role> roles) {
+ List<Integer> roleIds = new ArrayList<Integer>(roles.size());
+ for (Role role : roles) {
+ roleIds.add(role.getId());
+ }
+ return roleIds;
+ }
+}
commit 86ee4dd97af34b90c48950bb9674c38ee1564d16
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Wed Jan 20 22:17:50 2010 -0800
1370 - cancel is now functional. feel free to test
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java
index 15e6533..d2de807 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java
@@ -23,5 +23,5 @@
package org.rhq.core.domain.content;
public enum ContentSyncStatus {
- INPROGRESS, PACKAGEMETADATA, PACKAGEBITS, DISTROMETADATA, DISTROBITS, ADVISORYMETADATA, SUCCESS, FAILURE, NONE, CANCELLED
+ INPROGRESS, PACKAGEMETADATA, PACKAGEBITS, DISTROMETADATA, DISTROBITS, ADVISORYMETADATA, SUCCESS, FAILURE, NONE, CANCELLED, CANCELLING
}
\ No newline at end of file
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java b/modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java
index 41217f3..1e11c2a 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java
@@ -109,7 +109,7 @@ public class ProgressWatcher {
* Reset the ProgressWatcher to zero.
*/
public void resetToZero() {
- start();
stop();
+ start();
}
}
diff --git a/modules/core/util/src/test/java/org/rhq/core/util/progresswatch/ProgressWatcherTest.java b/modules/core/util/src/test/java/org/rhq/core/util/progresswatch/ProgressWatcherTest.java
index ba1f6f8..8bf4336 100644
--- a/modules/core/util/src/test/java/org/rhq/core/util/progresswatch/ProgressWatcherTest.java
+++ b/modules/core/util/src/test/java/org/rhq/core/util/progresswatch/ProgressWatcherTest.java
@@ -51,4 +51,14 @@ public class ProgressWatcherTest extends TestCase {
assertTrue(pw.getPercentComplete() == 98);
}
+ public void testResetToZero() {
+ ProgressWatcher pw = new ProgressWatcher();
+ pw.start();
+ pw.setTotalWork(102);
+ pw.finishWork(100);
+ pw.resetToZero();
+ assertTrue(pw.getPercentComplete() == 0);
+
+ }
+
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
index 40d921b..77ab7f1 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
@@ -95,11 +95,11 @@
<c:when
test="#{RepoDetailsUIBean.percentComplete != '100'}">
<a4j:region>
- <a4j:poll id="poll" interval="1000"
+ <a4j:poll id="statusPoll" interval="1000"
reRender="syncStatus" />
<h:outputText id="syncStatus"
value="#{RepoDetailsUIBean.syncStatus}" />
- </a4j:region>
+ </a4j:region>
</c:when>
<c:otherwise>
<h:outputText id="syncStatus"
@@ -112,7 +112,7 @@
<td align="left"><rich:progressBar
value="#{RepoDetailsUIBean.percentComplete}"
label="#{RepoDetailsUIBean.percentComplete} %"
- interval="1000" minValue="0" maxValue="99">
+ interval="999" minValue="0" maxValue="99">
<f:facet name="complete">
<h:outputText value="Synchronizing Complete" />
</f:facet>
@@ -147,8 +147,14 @@
operation="hide" event="onclick" />
</h:panelGroup>
</f:facet>
- <PRE><h:outputText
+ <a4j:region>
+ <a4j:poll id="resultsPoll" interval="2000"
+ reRender="syncResults" />
+ <PRE><h:outputText id="syncResults"
value="#{RepoDetailsUIBean.syncResults.results}" /></PRE>
+ </a4j:region>
+
+
</rich:modalPanel></td>
</tr>
</table>
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 393e694..0d70c64 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
@@ -108,6 +108,9 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
@EJB
private SubjectManagerLocal subjectManager;
+ @EJB
+ private RepoManagerLocal repoManager;
+
@RequiredPermission(Permission.MANAGE_INVENTORY)
public void deleteRepo(Subject subject, int repoId) {
log.debug("User [" + subject + "] is deleting repo [" + repoId + "]");
@@ -992,6 +995,7 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
}
}
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public RepoSyncResults getMostRecentSyncResults(Subject subject, int repoId) {
Repo found = this.getRepo(subject, repoId);
Set<ContentSyncStatus> stati = new HashSet<ContentSyncStatus>();
@@ -1057,10 +1061,14 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
Repo repo = this.getRepo(subject, repoId);
try {
- pc.cancelRepoSync(repo);
+ pc.cancelRepoSync(subject, repo);
+
} catch (SchedulerException e) {
throw new ContentException(e);
}
+ RepoSyncResults results = this.getMostRecentSyncResults(subject, repo.getId());
+ results.setStatus(ContentSyncStatus.CANCELLING);
+ repoManager.mergeRepoSyncResults(results);
}
@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 d8bc4fc..4a40b72 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
@@ -34,7 +34,6 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.exception.GenericJDBCException;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.content.ContentSource;
@@ -263,7 +262,8 @@ public class ContentProviderManager {
* if the data required to perform the sync is missing or
* invalid
*/
- public boolean synchronizeRepo(int repoId) throws InterruptedException {
+ public boolean synchronizeRepo(int repoId) {
+ log.debug("synchronizeRepo() :: start");
RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
@@ -412,22 +412,19 @@ public class ContentProviderManager {
tracker.setResults(progress.toString());
tracker = updateSyncStatus(tracker, ContentSyncStatus.SUCCESS);
log.debug("synchronizeRepo :: Success");
- } catch (GenericJDBCException jdbc) {
- log.debug("Caught GenericJDBCException");
- progress.append("\n ** Cancelled syncing **");
- tracker.getProgressWatcher().resetToZero();
- tracker = updatePercentComplete(tracker, repoManager);
- tracker.setResults(progress.toString());
- tracker = updateSyncStatus(tracker, ContentSyncStatus.CANCELLED);
- ie = jdbc;
- } catch (InterruptedException ieinner) {
+ } catch (Exception e) {
+ RepoSyncResults recentResults = repoManager.getMostRecentSyncResults(overlord, repo.getId());
log.debug("Caught InterruptedException");
progress.append("\n ** Cancelled syncing **");
tracker.setResults(progress.toString());
tracker.getProgressWatcher().resetToZero();
tracker = updatePercentComplete(tracker, repoManager);
- tracker = updateSyncStatus(tracker, ContentSyncStatus.CANCELLED);
- ie = ieinner;
+ try {
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.CANCELLED, false);
+ } catch (InterruptedException e1) {
+ throw new RuntimeException("Unexpected InterruptedException", e1);
+ }
+ ie = e;
}
if (tracker.getRepoSyncResults() != null) {
@@ -439,8 +436,7 @@ public class ContentProviderManager {
log.debug("synchronizeRepo :: merging results.");
}
if (ie != null) {
- log.debug("rethrowing the InterruptedException");
- throw new InterruptedException(ie.toString());
+ return false;
} else {
return true;
}
@@ -482,8 +478,20 @@ public class ContentProviderManager {
}
- private SyncTracker updateSyncStatus(SyncTracker tracker, ContentSyncStatus status) {
+ private SyncTracker updateSyncStatus(SyncTracker tracker, ContentSyncStatus status) throws InterruptedException {
+ return updateSyncStatus(tracker, status, true);
+ }
+
+ private SyncTracker updateSyncStatus(SyncTracker tracker, ContentSyncStatus status, boolean checkCancelling)
+ throws InterruptedException {
RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
+ SubjectManagerLocal subjMgr = LookupUtil.getSubjectManager();
+ Subject overlord = subjMgr.getOverlord();
+ int repoId = tracker.getRepoId();
+ RepoSyncResults cancelCheck = repoManager.getMostRecentSyncResults(overlord, repoId);
+ if (cancelCheck.getStatus() == ContentSyncStatus.CANCELLING) {
+ throw new InterruptedException();
+ }
RepoSyncResults results = tracker.getRepoSyncResults();
results.setStatus(status);
results = repoManager.mergeRepoSyncResults(results);
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 3418ae7..9c1f89d 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
@@ -19,16 +19,19 @@
package org.rhq.enterprise.server.plugin.pc.content;
import java.util.Date;
-import java.util.Set;
import org.quartz.JobDetail;
-import org.quartz.JobExecutionContext;
import org.quartz.SchedulerException;
import org.quartz.SimpleTrigger;
+import org.quartz.Trigger;
+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.Repo;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.server.content.ContentSourceManagerLocal;
import org.rhq.enterprise.server.plugin.pc.AbstractTypeServerPluginContainer;
import org.rhq.enterprise.server.plugin.pc.MasterServerPluginContainer;
import org.rhq.enterprise.server.plugin.pc.ServerPluginManager;
@@ -48,6 +51,7 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
private static final String CONTENT_SRC_SYNC_JOB_GROUP_NAME = "syncContentSource";
private static final String REPO_SYNC_JOB_GROUP_NAME = "syncRepo";
+ private static final String REPO_SYNC_JOB_IMMEDIATE_GROUP_NAME = "syncRepoImmediate";
private ContentProviderManager adapterManager;
@@ -138,24 +142,28 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
* @throws SchedulerException if the job cannot be scheduled
*/
public void syncRepoNow(Repo repo) throws SchedulerException {
- JobDetail job = new JobDetail(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME, RepoSyncJob.class,
- false, false, false);
+ String jobName = RepoSyncJob.createJobName(repo);
+ JobDetail job = new JobDetail(jobName, REPO_SYNC_JOB_IMMEDIATE_GROUP_NAME, RepoSyncJob.class, false, false,
+ false);
RepoSyncJob.createJobDataMap(job, repo);
-
- SimpleTrigger trigger = new SimpleTrigger(job.getName(), job.getGroup());
- trigger.setVolatility(false);
-
+ Date nextExecution;
SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
- Date next = scheduler.scheduleJob(job, trigger);
-
+ Trigger trigger = scheduler.getTrigger(jobName, REPO_SYNC_JOB_IMMEDIATE_GROUP_NAME);
+ if (trigger == null) {
+ trigger = new SimpleTrigger(jobName, job.getGroup());
+ trigger.setVolatility(false);
+ nextExecution = scheduler.scheduleJob(job, trigger);
+ } else {
+ nextExecution = scheduler.rescheduleJob(jobName, REPO_SYNC_JOB_IMMEDIATE_GROUP_NAME, trigger);
+ }
getLog().info(
- "Scheduled repo sync job [" + job.getName() + ':' + job.getGroup() + "] to fire now at [" + next
+ "Scheduled repo sync job [" + job.getName() + ':' + job.getGroup() + "] to fire now at [" + nextExecution
+ "] for [" + repo + "]");
}
- public void cancelRepoSync(Repo repo) throws SchedulerException {
- JobDetail jobDetail = new JobDetail(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME,
+ public void cancelRepoSync(Subject subject, Repo repo) throws SchedulerException {
+ JobDetail jobDetail = new JobDetail(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_IMMEDIATE_GROUP_NAME,
RepoSyncJob.class, false, false, false);
RepoSyncJob.createJobDataMap(jobDetail, repo);
@@ -165,7 +173,7 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
- boolean cancelled = scheduler.interrupt(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME);
+ boolean cancelled = scheduler.interrupt(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_IMMEDIATE_GROUP_NAME);
getLog().info("cancelled repo sync job [" + jobDetail.getName() + ':' + jobDetail.getGroup() + "] ");
}
@@ -230,7 +238,9 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
try {
getLog().debug("scheduleSyncJobs :: Scheduling CP job: " + contentSource.getName());
scheduleProviderSyncJob(contentSource);
- Set<Repo> repos = contentSource.getRepos();
+ ContentSourceManagerLocal contentSourceManager = LookupUtil.getContentSourceManager();
+ PageList<Repo> repos = contentSourceManager.getAssociatedRepos(LookupUtil.getSubjectManager()
+ .getOverlord(), contentSource.getId(), PageControl.getUnlimitedInstance());
if (repos != null) {
for (Repo repo : repos) {
getLog().debug("scheduleSyncJobs :: Scheduling REPO job: " + repo.getName());
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncTracker.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncTracker.java
index 813f717..67a5440 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncTracker.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncTracker.java
@@ -30,6 +30,7 @@ import org.rhq.core.util.progresswatch.ProgressWatcher;
*/
public class SyncTracker {
+ private int repoId;
private RepoSyncResults repoSyncResults;
private ProgressWatcher progressWatcher;
private int packageSyncCount;
@@ -40,6 +41,7 @@ public class SyncTracker {
*/
public SyncTracker(RepoSyncResults repoSyncResultsIn, ProgressWatcher progressWatcherIn) {
super();
+ this.repoId = repoSyncResultsIn.getRepo().getId();
this.repoSyncResults = repoSyncResultsIn;
this.progressWatcher = progressWatcherIn;
this.progressWatcher.start();
@@ -125,4 +127,12 @@ public class SyncTracker {
this.packageSyncCount = packageSyncCount;
}
+ /**
+ * RepoId we are tracking
+ * @return int repoId
+ */
+ public int getRepoId() {
+
+ return this.repoId;
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ThreadUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ThreadUtil.java
index bd04b65..80bdc05 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ThreadUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ThreadUtil.java
@@ -8,14 +8,10 @@ package org.rhq.enterprise.server.plugin.pc.content;
*
*/
public class ThreadUtil {
-
- public static void checkInterrupted() throws InterruptedException {
- Thread cthread = Thread.currentThread();
- System.out.println("ThreadInterrupt : [" + cthread.getName() + "]");
- if (Thread.interrupted()) {
- throw new InterruptedException();
- }
-
- }
+ public static void checkInterrupted() throws InterruptedException {
+ if (Thread.interrupted()) {
+ throw new InterruptedException();
+ }
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java
index dbc0987..68df9c3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java
@@ -131,7 +131,8 @@ public class AdvisorySourceSynchronizer {
return tracker;
}
- private void translateDomainToDto(List<Advisory> advs, List<AdvisoryDetails> advDetails) {
+ private void translateDomainToDto(List<Advisory> advs, List<AdvisoryDetails> advDetails)
+ throws InterruptedException {
AdvisoryManagerLocal advManager = LookupUtil.getAdvisoryManagerLocal();
for (Advisory d : advs) {
@@ -167,6 +168,7 @@ public class AdvisorySourceSynchronizer {
}
}
advDetails.add(detail);
+ ThreadUtil.checkInterrupted();
}
}
}
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 9d1ba80..5e4e995 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
@@ -69,6 +69,8 @@ public class RepoSyncJob implements StatefulJob, InterruptableJob {
private Thread executionThread;
+ private static ThreadLocal<Boolean> interruptMonitor = new ThreadLocal();
+
/**
* {@inheritDoc}
*/
@@ -226,4 +228,5 @@ public class RepoSyncJob implements StatefulJob, InterruptableJob {
executionThread.interrupt();
}
}
+
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java
index fd5c521..97e9343 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java
@@ -167,7 +167,7 @@ public class RepoSyncingTest extends AbstractEJB3Test {
ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer();
pc.syncRepoNow(repo);
- for (int i = 0; i < 100; i++) {
+ for (int i = 0; i < 10; i++) {
RepoSyncResults res = getSyncResults(repo.getId());
if (res != null) {
System.out.println("status: [" + res.getStatus() + "] CTRL+C to exit");
@@ -179,7 +179,7 @@ public class RepoSyncingTest extends AbstractEJB3Test {
}
Thread.sleep(1000);
if (i == 5) {
- pc.cancelRepoSync(repo);
+ pc.cancelRepoSync(LookupUtil.getSubjectManager().getOverlord(), repo);
}
}
diff --git a/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java b/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
index ffac623..2c2f204 100644
--- a/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
+++ b/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
@@ -119,7 +119,7 @@ public class DiskSource implements ContentProvider, PackageSource, RepoSource {
}
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws SyncException {
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException, InterruptedException {
if (!isPackageSource) {
return;
diff --git a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
index c9d5880..90a0d30 100644
--- a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
+++ b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
@@ -115,7 +115,7 @@ public class JBossSoftwareContentSourceAdapter implements ContentProvider, Packa
}
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws SyncException {
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException, InterruptedException {
if (!active)
return;
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNHelper.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNHelper.java
index 930182d..ac02551 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNHelper.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNHelper.java
@@ -40,6 +40,7 @@ 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.DistributionDetails;
import org.rhq.enterprise.server.plugin.pc.content.DistributionFileDetails;
+import org.rhq.enterprise.server.plugin.pc.content.ThreadUtil;
import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnChannelFamilyType;
import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnChannelType;
import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnErratumBugType;
@@ -115,10 +116,11 @@ public class RHNHelper {
}
public List<AdvisoryDetails> getAdvisoryMetadata(List<String> advisoryList, String repoName)
- throws XmlRpcException, IOException {
+ throws XmlRpcException, IOException, InterruptedException {
List<AdvisoryDetails> erratadetails = new ArrayList<AdvisoryDetails>();
List<RhnErratumType> errata = rhndata.getErrataMetadata(this.systemid, advisoryList);
for (RhnErratumType erratum : errata) {
+ ThreadUtil.checkInterrupted();
log.debug("Forming AdvisoryDetails(" + erratum.getAdvisory());
AdvisoryDetails details = new AdvisoryDetails(erratum.getAdvisory(), erratum.getRhnErratumAdvisoryType(),
erratum.getRhnErratumSynopsis());
@@ -158,27 +160,27 @@ public class RHNHelper {
String pkgs = erratum.getPackages();
String[] pkgIds = pkgs.split(" ");
- try {
- List<AdvisoryPackageDetails> apkgdetails = new ArrayList<AdvisoryPackageDetails>();
- List<RhnPackageType> pkgdetails = rhndata.getPackageMetadata(this.systemid, Arrays.asList(pkgIds));
- for (RhnPackageType pkgd : pkgdetails) {
- if (log.isDebugEnabled()) {
- log.debug("RHNHelper::getAdvisoryMetaData<Advisory=" + erratum.getAdvisory() + "> Package<"
- + pkgd + ">");
- }
- String name = pkgd.getName();
- String version = pkgd.getVersion();
- String arch = pkgd.getPackageArch();
- String release = pkgd.getRelease();
- String rpmname = constructRpmDisplayName(name, version, release, arch);
- AdvisoryPackageDetails apkgd = new AdvisoryPackageDetails(name, version, arch, rpmname);
- apkgdetails.add(apkgd);
+ //try {
+ List<AdvisoryPackageDetails> apkgdetails = new ArrayList<AdvisoryPackageDetails>();
+ List<RhnPackageType> pkgdetails = rhndata.getPackageMetadata(this.systemid, Arrays.asList(pkgIds));
+ for (RhnPackageType pkgd : pkgdetails) {
+ if (log.isDebugEnabled()) {
+ log.debug("RHNHelper::getAdvisoryMetaData<Advisory=" + erratum.getAdvisory() + "> Package<" + pkgd
+ + ">");
}
- details.addPkgs(apkgdetails);
-
- } catch (Exception e) {
- e.printStackTrace();
+ String name = pkgd.getName();
+ String version = pkgd.getVersion();
+ String arch = pkgd.getPackageArch();
+ String release = pkgd.getRelease();
+ String rpmname = constructRpmDisplayName(name, version, release, arch);
+ AdvisoryPackageDetails apkgd = new AdvisoryPackageDetails(name, version, arch, rpmname);
+ apkgdetails.add(apkgd);
}
+ details.addPkgs(apkgdetails);
+
+ //} catch (Exception e) {
+ // e.printStackTrace();
+ // }
erratadetails.add(details);
}
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
index 04fdbba..bfad1a1 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
@@ -33,6 +33,7 @@ import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlrpc.XmlRpcException;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.enterprise.server.plugin.pc.content.AdvisoryDetails;
@@ -227,7 +228,7 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
* @inheritDoc
*/
public void synchronizeAdvisory(String repoName, AdvisorySyncReport report,
- Collection<AdvisoryDetails> existingAdvisory) throws SyncException {
+ Collection<AdvisoryDetails> existingAdvisory) throws SyncException, InterruptedException {
List<String> existingLabels = new ArrayList<String>();
for (AdvisoryDetails ad : existingAdvisory) {
@@ -249,9 +250,12 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
+ "with cves" + adv.getCVEs() + "wiuth packages" + adv.getPkgs());
report.addAdvisory(adv);
}
+ ThreadUtil.checkInterrupted();
}
- } catch (Exception e) {
- throw new SyncException("Error syncing advisory meta", e);
+ } catch (IOException ioe) {
+ throw new SyncException("IOException syncing advisory meta", ioe);
+ } catch (XmlRpcException x) {
+ throw new SyncException("XmlRpcException syncing advisory meta", x);
}
for (String adv : deletedAdvs) {
diff --git a/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java b/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
index 36d000c..40c6656 100644
--- a/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
+++ b/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
@@ -132,7 +132,7 @@ public class RepoProvider implements ContentProvider, PackageSource {
* @throws Exception On all errors.
*/
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws SyncException {
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException, InterruptedException {
Summary summary = new Summary(reader);
log.info("synchronizing with repo: " + reader + " started");
try {
commit 58dfac1b97a9e089bfc21168554522aee822e6a9
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 20 17:40:57 2010 -0500
Fixed javadoc
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java
new file mode 100644
index 0000000..7534deb
--- /dev/null
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java
@@ -0,0 +1,29 @@
+/*
+* 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.ws.test.util;
+
+/**
+ * @author Jason Dobies
+ */
+public class WsResourceUtility {
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
index 2ebc9f2..49b6334 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
@@ -64,8 +64,8 @@ public class RegistrationManagerBean implements RegistrationManagerLocal, Regist
* Registers the platform as a resource on RHQ server
* @param user secure id user
* @param platform to be registered
- * @param parenId if any.
- *
+ * @param parentId if any.
+ *
*/
public void registerPlatform(Subject user, Resource platform, int parentId) {
try {
@@ -92,8 +92,8 @@ public class RegistrationManagerBean implements RegistrationManagerLocal, Regist
/**
* Imports the registered resource into inventory and makes it a managed resource
* @param user secure id user
- * @param platform to be imported
- *
+ * @param resource to be imported
+ *
*/
public void importPlatform(Subject user, Resource resource) {
resource.setInventoryStatus(InventoryStatus.COMMITTED);
@@ -103,7 +103,7 @@ public class RegistrationManagerBean implements RegistrationManagerLocal, Regist
/**
* subscribe the requested platform to a compatible base repo based on release
* and arch information. This method does a lookup in ReleaseRepoMapping
- * to get the compatible base channel and tried to tie the platform to
+ * to get the compatible base channel and tried to tie the platform to
* the repo.
* @param user secure id user
* @param platform to be imported
commit e80ef0f1f183af1f549b865054465980bde74372
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 20 16:07:10 2010 -0500
Disabled test that requires a lot of setup (and even then I can't get it working). Will revisit once we get a better way to set the initial state of the server.
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/WsRepoManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/WsRepoManagerTest.java
index 3cff064..2267411 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/WsRepoManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/WsRepoManagerTest.java
@@ -23,23 +23,26 @@ import org.rhq.enterprise.server.ws.utility.WsUtility;
/**
* These tests can not be executed in our standard unit test fashion as they
* require a running RHQ Server with our web services deployed.
- *
- * This is still in development and has the current restrictions: - add
- * [dev_root
- * ]/modules/enterprise/remoting/webservices/target/rhq-remoting-webservices
- * -{version}.jar to TOP of eclipse classpath to run from your IDE(actually need
- * to use classpath setup from bin/jbossas/bin/wsrunclient.sh to take advantage
- * of type substitution correctly) - Server running on localhost. - ws-test user
- * defined in database with full permissions - Non RHQ Server JBossAS in
- * inventory. - The -Ptest-ws profile specified when running mvn test from
- * webservices dir - Perftest plugin installed and agent started as described in
- * modules/enterprise/remoting/scripts/README.txt
- *
+ *
+ * This is still in development and has the current restrictions:
+ * <ul>
+ * <li>add [dev_root]/modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-{version}.jar to TOP of
+ * eclipse classpath to run from your IDE(actually need to use classpath setup from bin/jbossas/bin/wsrunclient.sh to
+ * take advantage of type substitution correctly)</li>
+ * <li>Server running on localhost</li>
+ * <li>ws-test user defined in database with full permissions</li>
+ * <li>Non RHQ Server JBossAS in inventory</li>
+ * <li>The -Ptest-ws profile specified when running mvn test from webservices dir</li>
+ * <li>Perftest plugin installed and agent started as described in modules/enterprise/remoting/scripts/README.txt</li>
+ * </ul>
+ *
* @author Jay Shaughnessy, Simeon Pinder
*/
@Test(groups = "ws")
public class WsRepoManagerTest extends AssertJUnit implements TestPropertiesInterface {
+ private static final boolean TESTS_ENABLED = true;
+
// Test variables
private static ObjectFactory WS_OBJECT_FACTORY;
private static WebservicesRemote WEBSERVICE_REMOTE;
@@ -222,7 +225,7 @@ public class WsRepoManagerTest extends AssertJUnit implements TestPropertiesInte
}
}
- @Test(enabled = TESTS_ENABLED)
+ @Test(enabled = false)
void testDeploy() throws InterruptedException, IOException, ResourceTypeNotFoundException_Exception,
RepoException_Exception {
@@ -232,8 +235,8 @@ public class WsRepoManagerTest extends AssertJUnit implements TestPropertiesInte
ResourceCriteria criteria = new ResourceCriteria();
criteria.strict = true;
// criteria.setFilterName("Tomcat (");
- criteria.setFilterName("Tomcat VHost (localhost)");
- // criteria.setFilterName("Tomcat");
+// criteria.setFilterName("Tomcat VHost (localhost)");
+ criteria.setFilterName("Tomcat (8080)");
criteria.setFilterCurrentAvailability(AvailabilityType.UP);
// criteria.setFilterCurrentAvailability(AvailabilityType.DOWN);
List<Resource> tomcatServers = WEBSERVICE_REMOTE.findResourcesByCriteria(subject, criteria);
commit b548d9dd026e97c99085d724e1e9cd45708618d5
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 20 13:13:09 2010 -0500
Updated for web service serialization. Fixed bug in setting tag.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
index 1180f6e..9f810bc 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
@@ -150,21 +150,27 @@ public class Repo implements Serializable, Taggable {
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY)
private Set<ResourceRepo> resourceRepos;
+ @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Set<RepoContentSource> repoContentSources;
+ @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY)
private Set<RepoPackageVersion> repoPackageVersions;
+ @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Set<RepoRepoGroup> repoRepoGroups;
+ @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY)
private Set<RepoRepoRelationship> repoRepoRelationships;
+ @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY)
private Set<RepoTag> repoTags;
+ @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@OrderBy("startTime DESC")
// latest appears first, oldest last
@@ -756,7 +762,7 @@ public class Repo implements Serializable, Taggable {
}
public void setRepoTags(Set<RepoTag> tags) {
- this.repoTags = repoTags;
+ this.repoTags = tags;
}
public boolean hasTag(Tag tag) {
commit b295f8a645b6d2fe2a62b8aa9ff4b42095d0ee70
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 20 09:13:40 2010 -0500
Fixed bug in filtering.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
index 52f4985..a695476 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
@@ -100,6 +100,7 @@ public class ResourceCriteria extends Criteria {
filterOverrides.put("parentResourceId", "parentResource.id = ?");
filterOverrides.put("parentResourceName", "parentResource.name like ?");
filterOverrides.put("agentName", "agent.name like ?");
+ filterOverrides.put("currentAvailability", "currentAvailability.availabilityType = ?");
sortOverrides.put("resourceTypeName", "resourceType.name");
sortOverrides.put("resourceCategory", "resourceType.category");
commit 491db1bd2bdbe9a11d1840cc73609c5a8651d5db
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Tue Jan 19 21:53:53 2010 -0800
1376,1374,1377 - big amount of work to support cancelling syncs
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java
index aa92ee3..15e6533 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java
@@ -23,5 +23,5 @@
package org.rhq.core.domain.content;
public enum ContentSyncStatus {
- INPROGRESS, PACKAGEMETADATA, PACKAGEBITS, DISTROMETADATA, DISTROBITS, ADVISORYMETADATA, SUCCESS, FAILURE, NONE
+ INPROGRESS, PACKAGEMETADATA, PACKAGEBITS, DISTROMETADATA, DISTROBITS, ADVISORYMETADATA, SUCCESS, FAILURE, NONE, CANCELLED
}
\ No newline at end of file
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java b/modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java
index b019f0b..41217f3 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java
@@ -104,4 +104,12 @@ public class ProgressWatcher {
public void stop() {
this.started = false;
}
+
+ /**
+ * Reset the ProgressWatcher to zero.
+ */
+ public void resetToZero() {
+ start();
+ stop();
+ }
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
index c521323..a710a22 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
@@ -104,6 +104,21 @@ public class RepoDetailsUIBean {
return "success";
}
+ public String cancelSync() {
+ Subject subject = EnterpriseFacesContextUtility.getSubject();
+ RepoManagerLocal manager = LookupUtil.getRepoManagerLocal();
+ Integer repoId = FacesContextUtility.getRequiredRequestParameter("id", Integer.class);
+ try {
+ manager.cancelSync(subject, repoId);
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "The synchronization has been cancelled.");
+ } catch (Exception ce) {
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Error: " + ce.getMessage());
+ return "success"; // stay in edit mode on failure
+ }
+
+ return "success";
+ }
+
public String cancel() {
return "success";
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
index c80471e..40d921b 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
@@ -154,7 +154,7 @@
</table>
</rich:panel>
- <h:panelGrid columns="2" styleClass="buttons-table"
+ <h:panelGrid columns="3" styleClass="buttons-table"
columnClasses="button-cell">
<h:commandButton rendered="${mode ne 'edit'}" value="EDIT"
action="#{RepoDetailsUIBean.edit}" alt="Edit"
@@ -162,6 +162,9 @@
<h:commandButton rendered="${mode ne 'edit'}"
value="SYNCHRONIZE" action="#{RepoDetailsUIBean.sync}"
alt="Synchronize" styleClass="buttonmed" id="syncButton" />
+ <h:commandButton rendered="${mode ne 'edit'}"
+ value="CANCEL SYNCH" action="#{RepoDetailsUIBean.cancelSync}"
+ alt="Cancel Synch" styleClass="buttonmed" id="cancelSyncButton" />
<h:commandButton rendered="${mode eq 'edit'}" value="SAVE"
action="#{RepoDetailsUIBean.save}" alt="Save"
styleClass="buttonmed" id="saveButton" />
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 1f0f62b..393e694 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
@@ -1025,8 +1025,13 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
}
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
- public int internalSynchronizeRepos(Subject subject, Integer[] repoIds) throws Exception {
- ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer();
+ public int internalSynchronizeRepos(Subject subject, Integer[] repoIds) throws InterruptedException {
+ ContentServerPluginContainer pc;
+ try {
+ pc = ContentManagerHelper.getPluginContainer();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
ContentProviderManager providerManager = pc.getAdapterManager();
int syncCount = 0;
@@ -1041,6 +1046,23 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
return syncCount;
}
+ @Override
+ public void cancelSync(Subject subject, int repoId) throws ContentException {
+ ContentServerPluginContainer pc;
+ try {
+ pc = ContentManagerHelper.getPluginContainer();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ Repo repo = this.getRepo(subject, repoId);
+ try {
+ pc.cancelRepoSync(repo);
+ } catch (SchedulerException e) {
+ throw new ContentException(e);
+ }
+ }
+
@SuppressWarnings("unchecked")
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public RepoSyncResults persistRepoSyncResults(RepoSyncResults results) {
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 d6d061d..b2cf635 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
@@ -330,7 +330,15 @@ public interface RepoManagerLocal {
* @return number of repos successfully syncced
* @throws Exception if any errors occur
*/
- int internalSynchronizeRepos(Subject subject, Integer[] repoIds) throws Exception;
+ int internalSynchronizeRepos(Subject subject, Integer[] repoIds) throws InterruptedException;
+
+ /**
+ * Cancel any running sync job for the given repo
+ *
+ * @param repoId you want to cancel the sync for
+ * @return boolean if it was cancelled or not
+ */
+ void cancelSync(Subject subject, int repoId) throws ContentException;
/**
* Creates a new sync results object. Note that this will return <code>null</code> if the given results object has a
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/AdvisorySource.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/AdvisorySource.java
index e82085e..d3b05e3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/AdvisorySource.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/AdvisorySource.java
@@ -42,6 +42,6 @@ public interface AdvisorySource {
* source cannot be connected to.
*/
void synchronizeAdvisory(String repoName, AdvisorySyncReport report, Collection<AdvisoryDetails> existingAdvisory)
- throws Exception;
+ throws SyncException, InterruptedException;
}
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 0e678d7..d8bc4fc 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
@@ -34,6 +34,7 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hibernate.exception.GenericJDBCException;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.content.ContentSource;
@@ -57,9 +58,9 @@ import org.rhq.enterprise.server.plugin.pc.content.sync.RepoSourceSynchronizer;
import org.rhq.enterprise.server.util.LookupUtil;
/**
- * Responsible for managing {@link ContentProvider} implementations. These implementations
- * come from the content plugins themselves.
- *
+ * Responsible for managing {@link ContentProvider} implementations. These
+ * implementations come from the content plugins themselves.
+ *
* @author John Mazzitelli
* @author Jason Dobies
*/
@@ -70,17 +71,23 @@ public class ContentProviderManager {
private Map<ContentSource, ContentProvider> adapters;
// This is used as a monitor lock to the synchronizeContentProvider method;
- // it helps us avoid two content sources getting synchronized at the same time.
+ // it helps us avoid two content sources getting synchronized at the same
+ // time.
private final Object synchronizeContentSourceLock = new Object();
/**
- * Asks that the adapter responsible for the given content source return a stream to the package
- * bits for the package at the given location.
- *
- * @param contentSourceId the adapter for this content source will be used to stream the bits
- * @param location where the adapter can find the package bits on the content source
+ * Asks that the adapter responsible for the given content source return a
+ * stream to the package bits for the package at the given location.
+ *
+ * @param contentSourceId
+ * the adapter for this content source will be used to stream the
+ * bits
+ * @param location
+ * where the adapter can find the package bits on the content
+ * source
* @return the stream to the package bits
- * @throws Exception if the adapter failed to load the bits
+ * @throws Exception
+ * if the adapter failed to load the bits
*/
public InputStream loadPackageBits(int contentSourceId, String location) throws Exception {
ContentProvider adapter = getIsolatedContentProvider(contentSourceId);
@@ -97,13 +104,19 @@ public class ContentProviderManager {
}
/**
- * Asks that the adapter responsible for the given content source return a stream to the
- * DistributionFile bits for the DistributionFile at the given location.
- *
- * @param contentSourceId the adapter for this content source will be used to stream the bits
- * @param location where the adapter can find the DistributionFile bits on the source
+ * Asks that the adapter responsible for the given content source return a
+ * stream to the DistributionFile bits for the DistributionFile at the given
+ * location.
+ *
+ * @param contentSourceId
+ * the adapter for this content source will be used to stream the
+ * bits
+ * @param location
+ * where the adapter can find the DistributionFile bits on the
+ * source
* @return the stream to the DistributionFile bits
- * @throws Exception if the adapter failed to load the bits
+ * @throws Exception
+ * if the adapter failed to load the bits
*/
public InputStream loadDistributionFileBits(int contentSourceId, String location) throws Exception {
ContentProvider adapter = getIsolatedContentProvider(contentSourceId);
@@ -120,16 +133,20 @@ public class ContentProviderManager {
}
/**
- * Asks the provider responsible for the given content source to synchronize with its remote
- * repository. This will not attempt to load any package bits - it only synchronizes the repos
- * and package version information. Note that if a synchronization is already currently underway,
- * this method will not do anything and will return <code>false</code> (in effect, will let the
- * currently running synchronization continue; we try not to step on it). If this method does
- * actually do a sync, <code>true</code> will be returned.
- *
- * @param contentSourceId identifies the database entry of the provider
- * @return <code>true</code> if the synchronization completed; <code>false</code> if there was
- * already a synchronization happening and this method aborted
+ * Asks the provider responsible for the given content source to synchronize
+ * with its remote repository. This will not attempt to load any package
+ * bits - it only synchronizes the repos and package version information.
+ * Note that if a synchronization is already currently underway, this method
+ * will not do anything and will return <code>false</code> (in effect, will
+ * let the currently running synchronization continue; we try not to step on
+ * it). If this method does actually do a sync, <code>true</code> will be
+ * returned.
+ *
+ * @param contentSourceId
+ * identifies the database entry of the provider
+ * @return <code>true</code> if the synchronization completed;
+ * <code>false</code> if there was already a synchronization
+ * happening and this method aborted
* @throws Exception
*/
public boolean synchronizeContentProvider(int contentSourceId) throws Exception {
@@ -150,11 +167,16 @@ public class ContentProviderManager {
throw new Exception("Cannot sync a non-existing content source [" + contentSourceId + "]");
}
- // This should not take very long so it should be OK to block other callers.
- // We are avoiding the problem that would occur if we try to synchronize the same source
- // at the same time. We could do it more cleverly by synchronizing on a per content source
- // basis, but I don't see a need right now to make this more complicated.
- // We can come back and revisit if we need more fine-grained locking.
+ // This should not take very long so it should be OK to block other
+ // callers.
+ // We are avoiding the problem that would occur if we try to
+ // synchronize the same source
+ // at the same time. We could do it more cleverly by synchronizing
+ // on a per content source
+ // basis, but I don't see a need right now to make this more
+ // complicated.
+ // We can come back and revisit if we need more fine-grained
+ // locking.
synchronized (synchronizeContentSourceLock) {
progress.append(new Date()).append(": ");
progress.append("Start synchronization of content provider [").append(contentSource.getName()).append(
@@ -169,12 +191,17 @@ public class ContentProviderManager {
}
if (results == null) {
- // note that it technically is still possible to have concurrent syncs - if two
- // threads running in two different servers (i.e. different VMs) both try to sync the
- // same content source and both enter the persistContentSourceSyncResults method at
- // the same time, you'll get two inprogress rows - this is so rare as to not care.
+ // note that it technically is still possible to have concurrent
+ // syncs - if two
+ // threads running in two different servers (i.e. different VMs)
+ // both try to sync the
+ // same content source and both enter the
+ // persistContentSourceSyncResults method at
+ // the same time, you'll get two inprogress rows - this is so
+ // rare as to not care.
// Even if it does happen, it may still work, or
- // one sync will get an error and rollback its tx and no harm will be done.
+ // one sync will get an error and rollback its tx and no harm
+ // will be done.
log.info("Content provider [" + contentSource.getName()
+ "] is already currently being synchronized, this sync request will be ignored");
return false;
@@ -184,7 +211,8 @@ public class ContentProviderManager {
repoSourceSynchronizer.synchronizeCandidateRepos(progress);
} catch (Throwable t) {
if (results != null) {
- // try to reload the results in case it was updated by the SLSB before the
+ // try to reload the results in case it was updated by the SLSB
+ // before the
// exception happened
ContentSourceSyncResults reloadedResults = contentSourceManager.getContentSourceSyncResults(results
.getId());
@@ -217,21 +245,25 @@ public class ContentProviderManager {
}
/**
- * Asks each content provider associated with the given repo to synchronize the following
- * information for the given repo:
+ * 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
+ *
+ * @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 {
+ public boolean synchronizeRepo(int repoId) throws InterruptedException {
RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
@@ -241,10 +273,11 @@ public class ContentProviderManager {
// Load the repo to sync
Repo repo = repoManager.getRepo(overlord, repoId);
if (repo == null) {
- throw new Exception("Invalid repo ID specified for sync: " + repoId);
+ throw new IllegalArgumentException("Invalid repo ID specified for sync: " + repoId);
}
- // results = contentSourceManager.persistContentSourceSyncResults(results);
+ // results =
+ // contentSourceManager.persistContentSourceSyncResults(results);
StringBuilder progress = new StringBuilder();
progress.append(new Date()).append(": ");
progress.append("Start synchronization of Repository [").append(repo.getName()).append("]");
@@ -262,122 +295,156 @@ public class ContentProviderManager {
return false;
}
- // METADATA Loop
- for (ContentSource source : repo.getContentSources()) {
- try {
- ContentProvider provider = getIsolatedContentProvider(source.getId());
- SyncProgressWeight sw = provider.getSyncProgressWeight();
- PackageSourceSynchronizer packageSourceSynchronizer = new PackageSourceSynchronizer(repo, source,
- provider);
- log.debug("synchronizeRepo :: synchronizePackageMetadata");
-
- tracker = updateSyncStatus(tracker, ContentSyncStatus.PACKAGEMETADATA);
- tracker = packageSourceSynchronizer.synchronizePackageMetadata(tracker);
- } catch (Exception e) {
- processSyncException(e, tracker, repo, source, repoManager);
+ Exception ie = null;
+ try {
+ ThreadUtil.checkInterrupted();
+ // METADATA Loop
+ for (ContentSource source : repo.getContentSources()) {
+ try {
+ ContentProvider provider = getIsolatedContentProvider(source.getId());
+ SyncProgressWeight sw = provider.getSyncProgressWeight();
+ PackageSourceSynchronizer packageSourceSynchronizer = new PackageSourceSynchronizer(repo, source,
+ provider);
+ log.debug("synchronizeRepo :: synchronizePackageMetadata");
+
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.PACKAGEMETADATA);
+ tracker = packageSourceSynchronizer.synchronizePackageMetadata(tracker);
+ } catch (SyncException e) {
+ processSyncException(e, tracker, repo, source, repoManager);
+ }
}
- }
-
- // Setup ProgressWatcher
- for (ContentSource source : repo.getContentSources()) {
- ContentProvider provider = getIsolatedContentProvider(source.getId());
- SyncProgressWeight sw = provider.getSyncProgressWeight();
- tracker.getProgressWatcher().addWork(sw.getPackageMetadataWeight());
- tracker.addAdvisoryMetadataWork(provider);
- tracker.getProgressWatcher().addWork(sw.getDistribtutionBitsWeight());
- tracker.getProgressWatcher().addWork(sw.getDistribtutionMetadataWeight());
- tracker.addPackageBitsWork(provider);
- tracker.getProgressWatcher().finishWork(sw.getPackageMetadataWeight());
- }
- tracker = updatePercentComplete(tracker, repoManager);
+ ThreadUtil.checkInterrupted();
- // PACKAGEBITS Loop
- // Synchronize every content provider associated with the repo
- for (ContentSource source : repo.getContentSources()) {
- // Don't let the entire sync fail if a single content source fails
- try {
+ // Setup ProgressWatcher
+ for (ContentSource source : repo.getContentSources()) {
ContentProvider provider = getIsolatedContentProvider(source.getId());
-
- PackageSourceSynchronizer packageSourceSynchronizer = new PackageSourceSynchronizer(repo, source,
- provider);
- log.debug("synchronizeRepo :: synchronizePackageBits");
- tracker = updateSyncStatus(tracker, ContentSyncStatus.PACKAGEBITS);
- tracker = packageSourceSynchronizer.synchronizePackageBits(tracker, provider);
- tracker = updatePercentComplete(tracker, repoManager);
- } catch (Exception e) {
- processSyncException(e, tracker, repo, source, repoManager);
+ SyncProgressWeight sw = provider.getSyncProgressWeight();
+ tracker.getProgressWatcher().addWork(sw.getPackageMetadataWeight());
+ tracker.addAdvisoryMetadataWork(provider);
+ tracker.getProgressWatcher().addWork(sw.getDistribtutionBitsWeight());
+ tracker.getProgressWatcher().addWork(sw.getDistribtutionMetadataWeight());
+ tracker.addPackageBitsWork(provider);
+ tracker.getProgressWatcher().finishWork(sw.getPackageMetadataWeight());
}
- }
- // Distro meta
- for (ContentSource source : repo.getContentSources()) {
- try {
- ContentProvider provider = getIsolatedContentProvider(source.getId());
- DistributionSourceSynchronizer distributionSourceSynchronizer = new DistributionSourceSynchronizer(
- repo, source, provider);
-
- log.debug("synchronizeRepo :: synchronizeDistributionMetadata");
- tracker = updateSyncStatus(tracker, ContentSyncStatus.DISTROMETADATA);
- tracker = distributionSourceSynchronizer.synchronizeDistributionMetadata(tracker);
- tracker = updatePercentComplete(tracker, repoManager);
+ tracker = updatePercentComplete(tracker, repoManager);
- } catch (Exception e) {
- processSyncException(e, tracker, repo, source, repoManager);
+ // PACKAGEBITS Loop
+ // Synchronize every content provider associated with the repo
+ for (ContentSource source : repo.getContentSources()) {
+ // Don't let the entire sync fail if a single content source
+ // fails
+ try {
+ ContentProvider provider = getIsolatedContentProvider(source.getId());
+
+ PackageSourceSynchronizer packageSourceSynchronizer = new PackageSourceSynchronizer(repo, source,
+ provider);
+ log.debug("synchronizeRepo :: synchronizePackageBits");
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.PACKAGEBITS);
+ tracker = packageSourceSynchronizer.synchronizePackageBits(tracker, provider);
+ tracker = updatePercentComplete(tracker, repoManager);
+ // Check to cancel after each contentsource
+ ThreadUtil.checkInterrupted();
+
+ } catch (SyncException e) {
+ processSyncException(e, tracker, repo, source, repoManager);
+ }
+ }
+ // Distro meta
+ for (ContentSource source : repo.getContentSources()) {
+ try {
+ ContentProvider provider = getIsolatedContentProvider(source.getId());
+ DistributionSourceSynchronizer distributionSourceSynchronizer = new DistributionSourceSynchronizer(
+ repo, source, provider);
+
+ log.debug("synchronizeRepo :: synchronizeDistributionMetadata");
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.DISTROMETADATA);
+ tracker = distributionSourceSynchronizer.synchronizeDistributionMetadata(tracker);
+ tracker = updatePercentComplete(tracker, repoManager);
+ ThreadUtil.checkInterrupted();
+ } catch (SyncException e) {
+ processSyncException(e, tracker, repo, source, repoManager);
+ }
}
- }
- // Distro bits
- for (ContentSource source : repo.getContentSources()) {
- try {
- ContentProvider provider = getIsolatedContentProvider(source.getId());
- DistributionSourceSynchronizer distributionSourceSynchronizer = new DistributionSourceSynchronizer(
- repo, source, provider);
-
- log.debug("synchronizeRepo :: synchronizeDistributionBits");
- tracker = updateSyncStatus(tracker, ContentSyncStatus.DISTROBITS);
- tracker = distributionSourceSynchronizer.synchronizeDistributionBits(tracker);
- tracker = updatePercentComplete(tracker, repoManager);
- } catch (Exception e) {
- processSyncException(e, tracker, repo, source, repoManager);
+ // Distro bits
+ for (ContentSource source : repo.getContentSources()) {
+ try {
+ ContentProvider provider = getIsolatedContentProvider(source.getId());
+ DistributionSourceSynchronizer distributionSourceSynchronizer = new DistributionSourceSynchronizer(
+ repo, source, provider);
+
+ log.debug("synchronizeRepo :: synchronizeDistributionBits");
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.DISTROBITS);
+ tracker = distributionSourceSynchronizer.synchronizeDistributionBits(tracker);
+ tracker = updatePercentComplete(tracker, repoManager);
+ ThreadUtil.checkInterrupted();
+ } catch (SyncException e) {
+ processSyncException(e, tracker, repo, source, repoManager);
+ }
}
- }
- // advisory meta
- for (ContentSource source : repo.getContentSources()) {
- try {
- log.debug("synchronizeRepo :: synchronizeAdvisoryMetadata");
- ContentProvider provider = getIsolatedContentProvider(source.getId());
- tracker = updateSyncStatus(tracker, ContentSyncStatus.ADVISORYMETADATA);
- AdvisorySourceSynchronizer advisorySourcesync = new AdvisorySourceSynchronizer(repo, source, provider);
- tracker = advisorySourcesync.synchronizeAdvisoryMetadata(tracker);
- tracker = updatePercentComplete(tracker, repoManager);
- } catch (Exception e) {
- processSyncException(e, tracker, repo, source, repoManager);
+ // advisory meta
+ for (ContentSource source : repo.getContentSources()) {
+ try {
+ log.debug("synchronizeRepo :: synchronizeAdvisoryMetadata");
+ ContentProvider provider = getIsolatedContentProvider(source.getId());
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.ADVISORYMETADATA);
+ AdvisorySourceSynchronizer advisorySourcesync = new AdvisorySourceSynchronizer(repo, source,
+ provider);
+ tracker = advisorySourcesync.synchronizeAdvisoryMetadata(tracker);
+ tracker = updatePercentComplete(tracker, repoManager);
+ ThreadUtil.checkInterrupted();
+ } catch (SyncException e) {
+ processSyncException(e, tracker, repo, source, repoManager);
+ }
}
- }
- // Update status to finished.
- progress = new StringBuilder();
- progress.append("\n");
- progress.append(tracker.getRepoSyncResults().getResults());
- progress.append("\n");
- progress.append(new Date()).append(": ");
- progress.append(" Repository [").append(repo.getName()).append("]");
- progress.append('\n');
- progress.append(new Date()).append(": ");
- progress.append("completed syncing.");
- tracker.setResults(progress.toString());
- tracker = updateSyncStatus(tracker, ContentSyncStatus.SUCCESS);
- log.debug("synchronizeRepo :: Success");
+ // Update status to finished.
+ progress = new StringBuilder();
+ progress.append("\n");
+ progress.append(tracker.getRepoSyncResults().getResults());
+ progress.append("\n");
+ progress.append(new Date()).append(": ");
+ progress.append(" Repository [").append(repo.getName()).append("]");
+ progress.append('\n');
+ progress.append(new Date()).append(": ");
+ progress.append("completed syncing.");
+ tracker.setResults(progress.toString());
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.SUCCESS);
+ log.debug("synchronizeRepo :: Success");
+ } catch (GenericJDBCException jdbc) {
+ log.debug("Caught GenericJDBCException");
+ progress.append("\n ** Cancelled syncing **");
+ tracker.getProgressWatcher().resetToZero();
+ tracker = updatePercentComplete(tracker, repoManager);
+ tracker.setResults(progress.toString());
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.CANCELLED);
+ ie = jdbc;
+ } catch (InterruptedException ieinner) {
+ log.debug("Caught InterruptedException");
+ progress.append("\n ** Cancelled syncing **");
+ tracker.setResults(progress.toString());
+ tracker.getProgressWatcher().resetToZero();
+ tracker = updatePercentComplete(tracker, repoManager);
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.CANCELLED);
+ ie = ieinner;
+ }
if (tracker.getRepoSyncResults() != null) {
// pw.stop();
tracker.getRepoSyncResults().setEndTime(System.currentTimeMillis());
- // results.setPercentComplete(new Long(pw.getPercentComplete()));
+ // results.setPercentComplete(new
+ // Long(pw.getPercentComplete()));
repoManager.mergeRepoSyncResults(tracker.getRepoSyncResults());
log.debug("synchronizeRepo :: merging results.");
}
+ if (ie != null) {
+ log.debug("rethrowing the InterruptedException");
+ throw new InterruptedException(ie.toString());
+ } else {
+ return true;
+ }
- return true;
}
private SyncTracker updatePercentComplete(SyncTracker tracker, RepoManagerLocal repoManager) {
@@ -393,7 +460,8 @@ public class ContentProviderManager {
log.error("Error while synchronizing repo [" + repo + "] with content provider [" + source
+ "]. Synchronization for the repo will continue for other providers.", e);
- // try to reload the results in case it was updated by the SLSB before the
+ // try to reload the results in case it was updated by the SLSB before
+ // the
// exception happened
RepoSyncResults reloadedResults = repoManager.getRepoSyncResults(tracker.getRepoSyncResults().getId());
if (reloadedResults != null) {
@@ -425,11 +493,14 @@ public class ContentProviderManager {
/**
* Tests the connection to the content source that has the given ID.
- *
- * @param contentSourceId refers to a valid content source in the database
- * @return <code>true</code> if there is an adapter that can successfully connect to the given
- * content source <code>false</code> if there is an adapter but it cannot connect
- * @throws Exception if failed to get an adapter to attempt the connection
+ *
+ * @param contentSourceId
+ * refers to a valid content source in the database
+ * @return <code>true</code> if there is an adapter that can successfully
+ * connect to the given content source <code>false</code> if there
+ * is an adapter but it cannot connect
+ * @throws Exception
+ * if failed to get an adapter to attempt the connection
*/
public boolean testConnection(int contentSourceId) throws Exception {
ContentProvider adapter = getIsolatedContentProvider(contentSourceId);
@@ -444,8 +515,9 @@ public class ContentProviderManager {
}
/**
- * Returns a set of all content sources whose adapters are managed by this object.
- *
+ * Returns a set of all content sources whose adapters are managed by this
+ * object.
+ *
* @return all content sources
*/
public Set<ContentSource> getAllContentSources() {
@@ -455,20 +527,25 @@ public class ContentProviderManager {
}
/**
- * Call this method when a new content source is added to the system during runtime. This can
- * also be used to restart an adapter that was previously {@link #shutdownAdapter(ContentSource)
- * shutdown}.
- *
- * <p>If there is already an adapter currently started for the given content source, this
- * returns silently.</p>
- *
- * @param contentSource the new content source that was added
- * @throws InitializationException if the provider throws an error on its startup
+ * Call this method when a new content source is added to the system during
+ * runtime. This can also be used to restart an adapter that was previously
+ * {@link #shutdownAdapter(ContentSource) shutdown}.
+ *
+ * <p>
+ * If there is already an adapter currently started for the given content
+ * source, this returns silently.
+ * </p>
+ *
+ * @param contentSource
+ * the new content source that was added
+ * @throws InitializationException
+ * if the provider throws an error on its startup
*/
public void startAdapter(ContentSource contentSource) throws InitializationException {
synchronized (this.adapters) {
if (this.adapters.containsKey(contentSource)) {
- return; // already exists, which means it was already initialized
+ return; // already exists, which means it was already
+ // initialized
}
}
@@ -482,8 +559,10 @@ public class ContentProviderManager {
adapter.initialize(contentSource.getConfiguration());
} catch (Exception e) {
log.warn("Failed to initialize adapter for content source [" + contentSource.getName() + "]");
- // The adapter is put in the adapter cache when it is instantiated. If it failed to start, remove it
- // from the cache so we don't immediately return at the start of this method.
+ // The adapter is put in the adapter cache when it is instantiated.
+ // If it failed to start, remove it
+ // from the cache so we don't immediately return at the start of
+ // this method.
this.adapters.remove(contentSource);
throw new InitializationException(e);
@@ -491,14 +570,18 @@ public class ContentProviderManager {
}
/**
- * Call this method when a content source is removed from the system during runtime or if you
- * just want to shutdown the adapter for whatever reason. You can restart the adapter by calling
+ * Call this method when a content source is removed from the system during
+ * runtime or if you just want to shutdown the adapter for whatever reason.
+ * You can restart the adapter by calling
* {@link #startAdapter(ContentSource)}.
- *
- * <p>If there are no adapters currently started for the given content source, this returns
- * silently.</p>
- *
- * @param contentSource the content source being deleted
+ *
+ * <p>
+ * If there are no adapters currently started for the given content source,
+ * this returns silently.
+ * </p>
+ *
+ * @param contentSource
+ * the content source being deleted
*/
public void shutdownAdapter(ContentSource contentSource) {
synchronized (this.adapters) {
@@ -521,12 +604,15 @@ public class ContentProviderManager {
}
/**
- * Convienence method that simply {@link #shutdownAdapter(ContentSource) shuts down the adapter}
- * and then {@link #startAdapter(ContentSource) restarts it}. Call this when, for example, a
- * content source's {@link ContentSource#getConfiguration() configuration} has changed.
- *
- * @param contentSource the content source whose adapter is to be restarted
- * @throws Exception if there is an error asking the provider to shutdown or start
+ * Convienence method that simply {@link #shutdownAdapter(ContentSource)
+ * shuts down the adapter} and then {@link #startAdapter(ContentSource)
+ * restarts it}. Call this when, for example, a content source's
+ * {@link ContentSource#getConfiguration() configuration} has changed.
+ *
+ * @param contentSource
+ * the content source whose adapter is to be restarted
+ * @throws Exception
+ * if there is an error asking the provider to shutdown or start
*/
public void restartAdapter(ContentSource contentSource) throws Exception {
shutdownAdapter(contentSource);
@@ -534,13 +620,17 @@ 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
+ * 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) {
@@ -555,12 +645,16 @@ public class ContentProviderManager {
}
/**
- * 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>
- *
- * @param pluginManager the plugin manager this object can use to obtain information from (like
- * classloaders)
+ * 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>
+ *
+ * @param pluginManager
+ * the plugin manager this object can use to obtain information
+ * from (like classloaders)
*/
protected void initialize(ContentServerPluginManager pluginManager) {
this.pluginManager = pluginManager;
@@ -568,8 +662,10 @@ public class ContentProviderManager {
ContentSourceMetadataManagerLocal metadataManager = LookupUtil.getContentSourceMetadataManager();
ContentSourceManagerLocal contentSourceManager = LookupUtil.getContentSourceManager();
- // Our plugin manager should have parsed all descriptors and have our types for us.
- // Let's register the types to make sure they are merged with the old existing types.
+ // Our plugin manager should have parsed all descriptors and have our
+ // types for us.
+ // Let's register the types to make sure they are merged with the old
+ // existing types.
ContentSourcePluginMetadataManager pluginMetadataManager = this.pluginManager.getMetadataManager();
Set<ContentSourceType> allTypes = pluginMetadataManager.getAllContentSourceTypes();
metadataManager.registerTypes(allTypes);
@@ -594,14 +690,18 @@ public class ContentProviderManager {
}
/**
- * Tells this manager to shutdown. This will effectively shutdown all of its adapters.
- *
- * <p>This is protected so only the plugin container and subclasses can use it.</p>
+ * Tells this manager to shutdown. This will effectively shutdown all of its
+ * adapters.
+ *
+ * <p>
+ * This is protected so only the plugin container and subclasses can use it.
+ * </p>
*/
protected void shutdown() {
HashMap<ContentSource, ContentProvider> adaptersCopy;
- // shutdown all adapters to give them a chance to clean up after themselves
+ // shutdown all adapters to give them a chance to clean up after
+ // themselves
synchronized (this.adapters) {
adaptersCopy = new HashMap<ContentSource, ContentProvider>(this.adapters);
}
@@ -623,12 +723,16 @@ public class ContentProviderManager {
}
/**
- * 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.
- *
- * @param contentSource the returned adapter communicates with this content source
- * @return the adapter that is communicating with the content source, isolated to its classloader
- * @throws RuntimeException if there is no content source adapter available
+ * 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.
+ *
+ * @param contentSource
+ * the returned adapter communicates with this content source
+ * @return the adapter that is communicating with the content source,
+ * isolated to its classloader
+ * @throws RuntimeException
+ * if there is no content source adapter available
*/
protected ContentProvider getIsolatedContentSourceAdapter(ContentSource contentSource) throws RuntimeException {
ContentProvider adapter;
@@ -671,10 +775,13 @@ public class ContentProviderManager {
}
/**
- * Creates a provider instance that will service the give {@link ContentSource}.
- *
- * @param contentSource the source that the adapter will connect to
- * @return an adapter instance; will be <code>null</code> if failed to create adapter
+ * Creates a provider instance that will service the give
+ * {@link ContentSource}.
+ *
+ * @param contentSource
+ * the source that the adapter will connect to
+ * @return an adapter instance; will be <code>null</code> if failed to
+ * create adapter
*/
protected ContentProvider instantiateAdapter(ContentSource contentSource) {
ContentProvider adapter = null;
@@ -718,8 +825,8 @@ public class ContentProviderManager {
}
/**
- * This will handle invocations to an object ensuring that the call is isolated to within the
- * appropriate classloader.
+ * This will handle invocations to an object ensuring that the call is
+ * isolated to within the appropriate classloader.
*/
private class IsolatedInvocationHandler implements InvocationHandler {
private final Object instance;
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 da28caa..3418ae7 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
@@ -22,6 +22,7 @@ import java.util.Date;
import java.util.Set;
import org.quartz.JobDetail;
+import org.quartz.JobExecutionContext;
import org.quartz.SchedulerException;
import org.quartz.SimpleTrigger;
@@ -137,8 +138,8 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
* @throws SchedulerException if the job cannot be scheduled
*/
public void syncRepoNow(Repo repo) throws SchedulerException {
- JobDetail job = new JobDetail(RepoSyncJob.createUniqueJobName(repo), CONTENT_SRC_SYNC_JOB_GROUP_NAME,
- RepoSyncJob.class, false, false, false);
+ JobDetail job = new JobDetail(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME, RepoSyncJob.class,
+ false, false, false);
RepoSyncJob.createJobDataMap(job, repo);
@@ -153,6 +154,22 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
+ "] for [" + repo + "]");
}
+ public void cancelRepoSync(Repo repo) throws SchedulerException {
+ JobDetail jobDetail = new JobDetail(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME,
+ RepoSyncJob.class, false, false, false);
+
+ RepoSyncJob.createJobDataMap(jobDetail, repo);
+
+ SimpleTrigger trigger = new SimpleTrigger(jobDetail.getName(), jobDetail.getGroup());
+ trigger.setVolatility(false);
+
+ SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
+
+ boolean cancelled = scheduler.interrupt(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME);
+
+ getLog().info("cancelled repo sync job [" + jobDetail.getName() + ':' + jobDetail.getGroup() + "] ");
+ }
+
/**
* This will schedule the sync job for the given content source. Once the scheduling is complete, the content
* source's adapter will be asked to synchronize with the remote content source according to the time(s) specified
@@ -268,4 +285,5 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
ContentProviderManager am = new ContentProviderManager();
return am;
}
+
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/DistributionSource.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/DistributionSource.java
index 9efd9c7..e2cbc7c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/DistributionSource.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/DistributionSource.java
@@ -42,8 +42,7 @@ public interface DistributionSource {
* source cannot be connected to.
*/
void synchronizeDistribution(String repoName, DistributionSyncReport report,
- Collection<DistributionDetails> existingDistros)
- throws Exception;
+ Collection<DistributionDetails> existingDistros) throws SyncException, InterruptedException;
/**
* Get an input stream for the specified distribution.
@@ -64,4 +63,3 @@ public interface DistributionSource {
String getDistFileRemoteLocation(String repoName, String label, String relativeFilename);
}
-
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/PackageSource.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/PackageSource.java
index 459d78f..33c66aa 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/PackageSource.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/PackageSource.java
@@ -48,8 +48,7 @@ public interface PackageSource {
* source cannot be connected to.
*/
void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages)
- throws Exception;
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException, InterruptedException;
/**
* Get an input stream for the specified package.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncException.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncException.java
new file mode 100644
index 0000000..9b901f0
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.plugin.pc.content;
+
+/**
+ * @author mmccune
+ *
+ */
+public class SyncException extends Exception {
+
+ public SyncException(String errorMsg, Exception e) {
+ super(errorMsg, e);
+ }
+
+ public SyncException(String errorMsg) {
+ super(errorMsg);
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ThreadUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ThreadUtil.java
new file mode 100644
index 0000000..bd04b65
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ThreadUtil.java
@@ -0,0 +1,21 @@
+/**
+ *
+ */
+package org.rhq.enterprise.server.plugin.pc.content;
+
+/**
+ * @author mmccune
+ *
+ */
+public class ThreadUtil {
+
+ public static void checkInterrupted() throws InterruptedException {
+ Thread cthread = Thread.currentThread();
+ System.out.println("ThreadInterrupt : [" + cthread.getName() + "]");
+ if (Thread.interrupted()) {
+ throw new InterruptedException();
+ }
+
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java
index 2fc7ae9..dbc0987 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java
@@ -49,7 +49,9 @@ import org.rhq.enterprise.server.plugin.pc.content.AdvisoryPackageDetails;
import org.rhq.enterprise.server.plugin.pc.content.AdvisorySource;
import org.rhq.enterprise.server.plugin.pc.content.AdvisorySyncReport;
import org.rhq.enterprise.server.plugin.pc.content.ContentProvider;
+import org.rhq.enterprise.server.plugin.pc.content.SyncException;
import org.rhq.enterprise.server.plugin.pc.content.SyncTracker;
+import org.rhq.enterprise.server.plugin.pc.content.ThreadUtil;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -83,7 +85,7 @@ public class AdvisorySourceSynchronizer {
overlord = subjectManager.getOverlord();
}
- public SyncTracker synchronizeAdvisoryMetadata(SyncTracker tracker) throws Exception {
+ public SyncTracker synchronizeAdvisoryMetadata(SyncTracker tracker) throws SyncException, InterruptedException {
if (!(provider instanceof AdvisorySource)) {
log.error(" Advisory Instance:" + provider);
return tracker;
@@ -97,10 +99,12 @@ public class AdvisorySourceSynchronizer {
List<Advisory> advs = repoManager.findAssociatedAdvisory(overlord, repo.getId(), pc);
log.error("Found " + advs.size() + " Advisory for repo " + repo.getId());
+ ThreadUtil.checkInterrupted();
AdvisorySyncReport advReport = new AdvisorySyncReport(repo.getId());
List<AdvisoryDetails> advDetails = new ArrayList<AdvisoryDetails>(advs.size());
translateDomainToDto(advs, advDetails);
+ ThreadUtil.checkInterrupted();
log.error("Synchronize Advisory: [" + source.getName() + "]: loaded existing list of size=[" + advs.size()
+ "] (" + (System.currentTimeMillis() - start) + ")ms");
@@ -110,12 +114,18 @@ public class AdvisorySourceSynchronizer {
start = System.currentTimeMillis();
advisorySource.synchronizeAdvisory(repo.getName(), advReport, advDetails);
+ ThreadUtil.checkInterrupted();
log.error("Synchronize Advisory: [" + source.getName() + "]: got sync report from adapter=[" + advReport
+ "] (" + (System.currentTimeMillis() - start) + ")ms");
RepoSyncResults syncResults = contentSourceManager.mergeAdvisorySyncReport(source, advReport, tracker
.getRepoSyncResults());
+ ThreadUtil.checkInterrupted();
+
+ log.error("Synchronize Advisory: [" + source.getName() + "]: finished mergeAdvisorySyncReport ("
+ + (System.currentTimeMillis() - start) + ")ms");
+
tracker.setRepoSyncResults(syncResults);
tracker.finishAdvisoryMetadataWork(provider);
return tracker;
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 d145421..e5dfd67 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
@@ -44,6 +44,7 @@ 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.plugin.pc.content.SyncException;
import org.rhq.enterprise.server.plugin.pc.content.SyncTracker;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -75,7 +76,7 @@ public class DistributionSourceSynchronizer {
subjectManager = LookupUtil.getSubjectManager();
}
- public SyncTracker synchronizeDistributionMetadata(SyncTracker tracker) throws Exception {
+ public SyncTracker synchronizeDistributionMetadata(SyncTracker tracker) throws SyncException, InterruptedException {
if (!(provider instanceof DistributionSource)) {
return tracker;
}
@@ -118,7 +119,7 @@ public class DistributionSourceSynchronizer {
return tracker;
}
- public SyncTracker synchronizeDistributionBits(SyncTracker tracker) throws Exception {
+ public SyncTracker synchronizeDistributionBits(SyncTracker tracker) throws SyncException, InterruptedException {
if (!(provider instanceof DistributionSource)) {
return tracker;
}
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 e196b6d..4f7d05a 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,7 @@ 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.plugin.pc.content.SyncException;
import org.rhq.enterprise.server.plugin.pc.content.SyncProgressWeight;
import org.rhq.enterprise.server.plugin.pc.content.SyncTracker;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -82,7 +83,7 @@ public class PackageSourceSynchronizer {
repoManager = LookupUtil.getRepoManagerLocal();
}
- public SyncTracker synchronizePackageMetadata(SyncTracker tracker) throws Exception {
+ public SyncTracker synchronizePackageMetadata(SyncTracker tracker) throws SyncException, InterruptedException {
if (!(provider instanceof PackageSource)) {
return tracker;
}
@@ -133,7 +134,8 @@ public class PackageSourceSynchronizer {
return tracker;
}
- public SyncTracker synchronizePackageBits(SyncTracker tracker, ContentProvider provider) throws Exception {
+ public SyncTracker synchronizePackageBits(SyncTracker tracker, ContentProvider provider)
+ throws InterruptedException, SyncException {
SyncProgressWeight sw = provider.getSyncProgressWeight();
// Determine if the sync even needs to take place
@@ -207,8 +209,7 @@ public class PackageSourceSynchronizer {
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);
+ throw new SyncException(errorMsg, e);
}
}
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 664b592..9d1ba80 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
@@ -26,11 +26,13 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.quartz.InterruptableJob;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.StatefulJob;
+import org.quartz.UnableToInterruptJobException;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.content.Repo;
@@ -59,16 +61,21 @@ import org.rhq.enterprise.server.util.LookupUtil;
*
* @author Jason Dobies
*/
-public class RepoSyncJob implements StatefulJob {
+public class RepoSyncJob implements StatefulJob, InterruptableJob {
public static final String KEY_REPO_NAME = "repoName";
private final Log log = LogFactory.getLog(this.getClass());
+ private Thread executionThread;
+
/**
* {@inheritDoc}
*/
public void execute(JobExecutionContext context) throws JobExecutionException {
+
+ executionThread = Thread.currentThread();
+
try {
JobDetail jobDetail = context.getJobDetail();
if (jobDetail == null) {
@@ -87,13 +94,13 @@ public class RepoSyncJob implements StatefulJob {
}
sync(repoName);
- }
- catch (Exception e) {
+ } catch (InterruptedException ie) {
+ log.error("Cancelled job [" + context.getJobDetail() + "]");
+ } catch (Exception e) {
String errorMsg = "Failed to sync repo in job [" + context.getJobDetail() + "]";
log.error(errorMsg, e);
- JobExecutionException jobExecutionException = new JobExecutionException(errorMsg, e,
- false);
+ JobExecutionException jobExecutionException = new JobExecutionException(errorMsg, e, false);
// Do not retrigger if we threw IllegalStateException because it'll never work anyway
if (!(e instanceof IllegalStateException)) {
@@ -142,8 +149,8 @@ public class RepoSyncJob implements StatefulJob {
String jobName = Integer.toHexString(repo.getName().hashCode());
if (jobName.length() > 80) {
- throw new IllegalArgumentException("Job names max size is 80 chars due to DB column " +
- "size restrictions: " + jobName);
+ throw new IllegalArgumentException("Job names max size is 80 chars due to DB column "
+ + "size restrictions: " + jobName);
}
return jobName;
@@ -165,14 +172,13 @@ public class RepoSyncJob implements StatefulJob {
jobName = jobName + "-" + uniquifier;
if (jobName.length() > 80) {
- throw new IllegalArgumentException("Job names max size is 80 chars due to DB column " +
- "size restrictions: " + jobName);
+ throw new IllegalArgumentException("Job names max size is 80 chars due to DB column "
+ + "size restrictions: " + jobName);
}
return jobName;
}
-
/**
* Performs the repo synchronization.
* <p/>
@@ -182,9 +188,11 @@ public class RepoSyncJob implements StatefulJob {
* timeout a transaction.
*
* @param repoName may not be <code>null</code>
+ * @throws InterruptedException
+ * @throws
* @throws Exception if there is an error in the sync
*/
- private void sync(String repoName) throws Exception {
+ private void sync(String repoName) throws InterruptedException {
SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
@@ -198,12 +206,24 @@ public class RepoSyncJob implements StatefulJob {
List<Repo> repoList = repoManager.getRepoByName(repoName);
if (repoList.size() != 1) {
- throw new Exception("Unexpected number of repos found for name [" + repoName + "]. " +
- "Found [" + repoList.size() + "] repos");
+ throw new RuntimeException("Unexpected number of repos found for name [" + repoName + "]. " + "Found ["
+ + repoList.size() + "] repos");
}
Repo repoToSync = repoList.get(0);
// This call executes all of the logic associated with synchronizing the given repo
- repoManager.internalSynchronizeRepos(overlord, new Integer[]{repoToSync.getId()});
+ repoManager.internalSynchronizeRepos(overlord, new Integer[] { repoToSync.getId() });
+ }
+
+ @Override
+ public void interrupt() throws UnableToInterruptJobException {
+
+ if (executionThread == null) {
+ log.error("execution thread is null, cant interrupt", new IllegalStateException());
+
+ } else {
+ log.debug("exeThread : [" + executionThread.getName() + "]");
+ executionThread.interrupt();
+ }
}
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java
index df07fbf..fd5c521 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java
@@ -19,12 +19,16 @@ import org.rhq.core.domain.content.DistributionFile;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.content.RepoDistribution;
import org.rhq.core.domain.content.RepoSyncResults;
+import org.rhq.enterprise.server.content.ContentManagerHelper;
+import org.rhq.enterprise.server.plugin.pc.content.ContentServerPluginContainer;
import org.rhq.enterprise.server.plugin.pc.content.TestContentProvider;
import org.rhq.enterprise.server.plugin.pc.content.TestContentServerPluginService;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
public class RepoSyncingTest extends AbstractEJB3Test {
+ private static final boolean ENABLED = false;
+
private EntityManager em;
private Repo repo;
private ContentSource contentSource;
@@ -53,7 +57,7 @@ public class RepoSyncingTest extends AbstractEJB3Test {
em.flush();
}
- @Test(enabled = false)
+ @Test(enabled = ENABLED)
public void testSyncResults() throws Exception {
// We have to commit because bean has new transaction inside it
getTransactionManager().commit();
@@ -66,7 +70,7 @@ public class RepoSyncingTest extends AbstractEJB3Test {
assert (results.getPercentComplete().equals(new Long(100)));
}
- @Test(enabled = false)
+ @Test(enabled = ENABLED)
public void testMultipleSyncResults() throws Exception {
getTransactionManager().commit();
// Sync 2x so we get multiple results
@@ -88,9 +92,9 @@ public class RepoSyncingTest extends AbstractEJB3Test {
assert (r1.getId() > r2.getId());
}
- @Test(enabled = true)
+ @Test(enabled = ENABLED)
public void testSyncRepos() throws Exception {
- p1.setLongRunningSyncs(true);
+ p1.setLongRunningSynchSleep(5000);
assert repo.getContentSources().size() == 1;
// We have to commit because bean has new transaction inside it
@@ -140,7 +144,7 @@ public class RepoSyncingTest extends AbstractEJB3Test {
}
- @Test(enabled = false)
+ @Test(enabled = ENABLED)
public void testSyncCount() throws Exception {
Integer[] ids = { repo.getId() };
@@ -152,6 +156,39 @@ public class RepoSyncingTest extends AbstractEJB3Test {
}
+ @Test(enabled = true)
+ public void testCancelSync() throws Exception {
+ getTransactionManager().commit();
+ p1 = new TestContentProvider();
+ p1.setLongRunningSynchSleep(10000);
+ pluginService.associateContentProvider(contentSource, p1);
+
+ prepareScheduler();
+ ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer();
+ pc.syncRepoNow(repo);
+
+ for (int i = 0; i < 100; i++) {
+ RepoSyncResults res = getSyncResults(repo.getId());
+ if (res != null) {
+ System.out.println("status: [" + res.getStatus() + "] CTRL+C to exit");
+ if (res.getStatus() == ContentSyncStatus.CANCELLED) {
+ break;
+ }
+ } else {
+ System.out.println("CTRL+C to exit");
+ }
+ Thread.sleep(1000);
+ if (i == 5) {
+ pc.cancelRepoSync(repo);
+ }
+
+ }
+ RepoSyncResults res = getSyncResults(repo.getId());
+ assert res != null;
+ assert res.getStatus() == ContentSyncStatus.CANCELLED;
+ unprepareScheduler();
+ }
+
private RepoSyncResults getSyncResults(int repoId) {
Query q = em.createNamedQuery(RepoSyncResults.QUERY_GET_ALL_BY_REPO_ID);
q.setParameter("repoId", repoId);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
index ad0766d..c157729 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
@@ -14,21 +14,25 @@ import org.rhq.core.domain.configuration.Configuration;
public class TestContentProvider implements ContentProvider, PackageSource, RepoSource, DistributionSource {
/**
- * Packages returned in a call to {@link #synchronizePackages(String, PackageSyncReport, Collection)} will
- * indicate they are of this type. Any test attempting to call this synchronize method should be sure to
- * create a package type of this name in the database prior to calling it.
+ * Packages returned in a call to
+ * {@link #synchronizePackages(String, PackageSyncReport, Collection)} will
+ * indicate they are of this type. Any test attempting to call this
+ * synchronize method should be sure to create a package type of this name
+ * in the database prior to calling it.
*/
public static final String PACKAGE_TYPE_NAME = "testContentProviderFakePackage";
/**
- * In order to create a package type (as needed to create the type indicated in {@link #PACKAGE_TYPE_NAME}), the
- * package type must be created as part of this resource type.
+ * In order to create a package type (as needed to create the type indicated
+ * in {@link #PACKAGE_TYPE_NAME}), the package type must be created as part
+ * of this resource type.
*/
public static final String RESOURCE_TYPE_NAME = "testContentProviderFakeResourceType";
/**
- * In order to create a resource type (as needed to create the type indicated in {@link #RESOURCE_TYPE_NAME}), this
- * resource type plugin name should be used.
+ * In order to create a resource type (as needed to create the type
+ * indicated in {@link #RESOURCE_TYPE_NAME}), this resource type plugin name
+ * should be used.
*/
public static final String RESOURCE_TYPE_PLUGIN_NAME = "testContentProviderFakeResourceTypePlugin";
@@ -36,19 +40,21 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
public static final String EXISTING_CANDIDATE_REPO_NAME = "testRepoCandidateExisting";
/**
- * This content provider will return packages when asked to synchronize a repo with this name.
+ * This content provider will return packages when asked to synchronize a
+ * repo with this name.
*/
public static final String REPO_WITH_PACKAGES = EXISTING_IMPORTED_REPO_NAME;
/**
- * This content provider will return distributions when asked to synchronize a repo with this name.
+ * This content provider will return distributions when asked to synchronize
+ * a repo with this name.
*/
public static final String REPO_WITH_DISTRIBUTIONS = EXISTING_IMPORTED_REPO_NAME;
/**
* Collection of packages that will be returned from calling
- * {@link #synchronizePackages(String, PackageSyncReport, Collection)} passing in a repo with the name
- * {@link #REPO_WITH_PACKAGES}.
+ * {@link #synchronizePackages(String, PackageSyncReport, Collection)}
+ * passing in a repo with the name {@link #REPO_WITH_PACKAGES}.
*/
public static final Map<ContentProviderPackageDetailsKey, ContentProviderPackageDetails> PACKAGES = new HashMap<ContentProviderPackageDetailsKey, ContentProviderPackageDetails>(
2);
@@ -86,17 +92,18 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
public static final Map<String, DistributionDetails> DISTRIBUTIONS = new HashMap<String, DistributionDetails>(2);
static {
- // Note: The type "kickstart" should already be in the database from installation
+ // Note: The type "kickstart" should already be in the database from
+ // installation
- /* Note: The md5 sums below will be used to determine if the file needs to be loaded through
- a call to getPackageBits. I set these to an invalid MD5 so they will *always* be downloaded.
+ /*
+ * Note: The md5 sums below will be used to determine if the file needs
+ * to be loaded through a call to getPackageBits. I set these to an
+ * invalid MD5 so they will *always* be downloaded.
*/
DistributionDetails dis1 = new DistributionDetails(DISTRIBUTION_1_LABEL, "kickstart");
dis1.setDistributionPath("/kstrees");
- DistributionFileDetails file11 = new DistributionFileDetails("dist1file1", System.currentTimeMillis(),
- "zzz");
- DistributionFileDetails file12 = new DistributionFileDetails("dist1file2", System.currentTimeMillis(),
- "zzz");
+ DistributionFileDetails file11 = new DistributionFileDetails("dist1file1", System.currentTimeMillis(), "zzz");
+ DistributionFileDetails file12 = new DistributionFileDetails("dist1file2", System.currentTimeMillis(), "zzz");
dis1.addFile(file11);
dis1.addFile(file12);
@@ -104,37 +111,45 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
DistributionDetails dis2 = new DistributionDetails(DISTRIBUTION_2_LABEL, "kickstart");
dis2.setDistributionPath("/kstrees");
- DistributionFileDetails file21 = new DistributionFileDetails("dist2file1", System.currentTimeMillis(),
- "zzz");
+ DistributionFileDetails file21 = new DistributionFileDetails("dist2file1", System.currentTimeMillis(), "zzz");
dis2.addFile(file21);
DISTRIBUTIONS.put(dis2.getLabel(), dis2);
}
- public static final int PACKAGE_COUNT_FOR_BITS = PACKAGES.size() + 3; // packages + number of distro files
+ public static final int PACKAGE_COUNT_FOR_BITS = PACKAGES.size() + 3; // packages
+ // +
+ // number
+ // of
+ // distro
+ // files
/**
- * If <code>true</code>, the call to {@link #testConnection()} will throw an exception.
+ * If <code>true</code>, the call to {@link #testConnection()} will throw an
+ * exception.
*/
private boolean failTest = false;
- private boolean longRunningSyncs = false;
+ // Set this value if you want the packageSync step to take a while
+ private int longRunningSynchSleep = 0;
/**
* Holds a list of all repo names that were passed into calls to
- * {@link #synchronizePackages(String, PackageSyncReport, Collection)} to track when and with
- * what data these calls are made.
+ * {@link #synchronizePackages(String, PackageSyncReport, Collection)} to
+ * track when and with what data these calls are made.
*/
private List<String> logSynchronizePackagesRepos = new ArrayList<String>();
/**
- * Holds a list of all locations passed into calls to {@link #getInputStream(String)}.
+ * Holds a list of all locations passed into calls to
+ * {@link #getInputStream(String)}.
*/
private List<String> logGetInputStreamLocations = new ArrayList<String>();
/**
* Holds a list of all repo names that were passed into calls to
- * {@link #synchronizeDistribution(String, DistributionSyncReport, Collection)}.
+ * {@link #synchronizeDistribution(String, DistributionSyncReport, Collection)}
+ * .
*/
private List<String> logSynchronizeDistroRepos = new ArrayList<String>();
@@ -173,7 +188,8 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
report.addRepo(repo2);
// Repo with a parent repo created in this sync
- // Parent explicitly added to this list *after* this child to ensure that's not a problem
+ // Parent explicitly added to this list *after* this child to ensure
+ // that's not a problem
RepoDetails repo3 = new RepoDetails("testRepo3");
report.addRepo(repo3);
@@ -193,7 +209,7 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
}
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws Exception {
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException, InterruptedException {
logSynchronizePackagesRepos.add(repoName);
@@ -201,9 +217,12 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
return;
}
- // For each package this provider wants to introduce, make sure it doesn't exist already.
- // This basically means the report will only ever contain "added" packages and will only do so
- // on the first call to this method. This will likely be changed as new requirements emerge.
+ // For each package this provider wants to introduce, make sure it
+ // doesn't exist already.
+ // This basically means the report will only ever contain "added"
+ // packages and will only do so
+ // on the first call to this method. This will likely be changed as new
+ // requirements emerge.
for (ContentProviderPackageDetails pkg : PACKAGES.values()) {
ContentProviderPackageDetails existingPackage = findDetailsByKey(pkg.getContentProviderPackageDetailsKey(),
@@ -214,10 +233,9 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
}
}
- if (this.longRunningSyncs) {
- System.out.println(this.getClass().getSimpleName() + ".synchronizePackages sleeping for 5 seconds");
- Thread.sleep(5000);
- }
+ System.out.println(this.getClass().getSimpleName() + ".synchronizePackages sleeping for "
+ + this.longRunningSynchSleep + " seconds");
+ Thread.sleep(this.longRunningSynchSleep);
}
public InputStream getInputStream(String location) throws Exception {
@@ -232,7 +250,7 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
}
public void synchronizeDistribution(String repoName, DistributionSyncReport report,
- Collection<DistributionDetails> existingDistros) throws Exception {
+ Collection<DistributionDetails> existingDistros) throws SyncException, InterruptedException {
logSynchronizeDistroRepos.add(repoName);
@@ -254,6 +272,10 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
report.addDistro(distro);
}
}
+ System.out.println(this.getClass().getSimpleName() + ".synchronizeDistribution sleeping for "
+ + this.longRunningSynchSleep + " seconds");
+
+ Thread.sleep(this.longRunningSynchSleep);
}
public String getDistFileRemoteLocation(String repoName, String label, String relativeFilename) {
@@ -266,28 +288,42 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
/**
* Returns a list of repo names that were used to all calls to
- * {@link #synchronizePackages(String, PackageSyncReport, Collection)} either since the creation
- * of this instance or the last call to {@link #reset()}.
- *
- * @return handle to the actual list used to capture these names; be careful about iterating this
- * list while making other calls against this instance
+ * {@link #synchronizePackages(String, PackageSyncReport, Collection)}
+ * either since the creation of this instance or the last call to
+ * {@link #reset()}.
+ *
+ * @return handle to the actual list used to capture these names; be careful
+ * about iterating this list while making other calls against this
+ * instance
*/
public List<String> getLogSynchronizePackagesRepos() {
return logSynchronizePackagesRepos;
}
/**
- * Returns a list of locations passed into all calls to {@link #getInputStream(String)} since
- * the creation of this instance or the lsat call to {@link #reset()}.
- *
- * @return handle to the actual list used to capture these names; be careful about iterating this
- * list while making other calls against this instance
+ * Returns a list of locations passed into all calls to
+ * {@link #getInputStream(String)} since the creation of this instance or
+ * the lsat call to {@link #reset()}.
+ *
+ * @return handle to the actual list used to capture these names; be careful
+ * about iterating this list while making other calls against this
+ * instance
*/
public List<String> getLogGetInputStreamLocations() {
return logGetInputStreamLocations;
}
/**
+ * Indicate how long you want the provider to sleep during the PackageSync
+ * step
+ *
+ * @param longRunningSynchSleep
+ */
+ public void setLongRunningSynchSleep(int longRunningSynchSleep) {
+ this.longRunningSynchSleep = longRunningSynchSleep;
+ }
+
+ /**
* Rests the logging of calls made into this instance.
*/
public void reset() {
@@ -296,16 +332,6 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
logSynchronizeDistroRepos.clear();
}
- /**
- * Indicate you want this test to simulate a long running sync. Will pause for ~10 seconds during
- * the package sync phase.
- *
- * @param longRunningSyncs enables/disables long syncs
- */
- public void setLongRunningSyncs(boolean longRunningSyncs) {
- this.longRunningSyncs = longRunningSyncs;
- }
-
private ContentProviderPackageDetails findDetailsByKey(ContentProviderPackageDetailsKey key,
Collection<ContentProviderPackageDetails> packages) {
diff --git a/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java b/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
index 6f9bb8b..ffac623 100644
--- a/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
+++ b/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
@@ -20,6 +20,7 @@ package org.rhq.enterprise.server.plugins.disk;
import java.io.File;
import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
@@ -42,6 +43,7 @@ import org.rhq.enterprise.server.plugin.pc.content.PackageSyncReport;
import org.rhq.enterprise.server.plugin.pc.content.RepoDetails;
import org.rhq.enterprise.server.plugin.pc.content.RepoImportReport;
import org.rhq.enterprise.server.plugin.pc.content.RepoSource;
+import org.rhq.enterprise.server.plugin.pc.content.SyncException;
import org.rhq.enterprise.server.plugin.pc.content.SyncProgressWeight;
/**
@@ -117,11 +119,7 @@ public class DiskSource implements ContentProvider, PackageSource, RepoSource {
}
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws Exception {
-
- if (!isPackageSource) {
- return;
- }
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException {
if (!isPackageSource) {
return;
@@ -195,7 +193,7 @@ public class DiskSource implements ContentProvider, PackageSource, RepoSource {
* @throws Exception if the sync fails
*/
protected void syncPackages(PackageSyncReport report, String repoName,
- List<ContentProviderPackageDetails> packages, File directory) throws Exception {
+ List<ContentProviderPackageDetails> packages, File directory) throws SyncException {
for (File file : directory.listFiles()) {
if (file.isDirectory()) {
@@ -228,7 +226,7 @@ public class DiskSource implements ContentProvider, PackageSource, RepoSource {
}
}
- protected ContentProviderPackageDetails createPackage(File file) throws Exception {
+ protected ContentProviderPackageDetails createPackage(File file) throws SyncException {
SupportedPackageType supportedPackageType = determinePackageType(file);
if (supportedPackageType == null) {
@@ -236,7 +234,12 @@ public class DiskSource implements ContentProvider, PackageSource, RepoSource {
}
ContentFileInfo fileInfo = ContentFileInfoFactory.createContentFileInfo(file);
- String md5 = MessageDigestGenerator.getDigestString(file);
+ String md5;
+ try {
+ md5 = MessageDigestGenerator.getDigestString(file);
+ } catch (IOException e) {
+ throw new SyncException("Error digesting file", e);
+ }
String name = file.getName();
String version = fileInfo.getVersion(md5);
String packageTypeName = supportedPackageType.packageTypeName;
diff --git a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
index 47a473d..c9d5880 100644
--- a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
+++ b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
@@ -23,6 +23,8 @@ import java.net.URI;
import java.net.URL;
import java.util.Collection;
+import javax.xml.parsers.ParserConfigurationException;
+
import churchillobjects.rss4j.RssDocument;
import churchillobjects.rss4j.parser.RssParser;
@@ -42,6 +44,7 @@ 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.PackageSource;
import org.rhq.enterprise.server.plugin.pc.content.PackageSyncReport;
+import org.rhq.enterprise.server.plugin.pc.content.SyncException;
import org.rhq.enterprise.server.plugin.pc.content.SyncProgressWeight;
/**
@@ -112,17 +115,26 @@ public class JBossSoftwareContentSourceAdapter implements ContentProvider, Packa
}
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws Exception {
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException {
if (!active)
return;
- RssDocument rssDocument = retrieveRssDocument();
+ RssDocument rssDocument;
+ try {
+ rssDocument = retrieveRssDocument();
+ } catch (Exception e) {
+ throw new SyncException("Error retrieving rss doc", e);
+ }
if (rssDocument == null) {
- throw new Exception("Null RSS document received from adapter: " + this);
+ throw new SyncException("Null RSS document received from adapter: " + this);
}
- parser.parseResults(rssDocument, report, existingPackages);
+ try {
+ parser.parseResults(rssDocument, report, existingPackages);
+ } catch (ParserConfigurationException e) {
+ throw new SyncException("error parsing results.", e);
+ }
}
public InputStream getInputStream(String location) throws Exception {
@@ -195,17 +207,17 @@ public class JBossSoftwareContentSourceAdapter implements ContentProvider, Packa
int status = client.executeMethod(method);
if (status == 404) {
- throw new Exception("Could not find the feed at URL [" + url + "]. Make sure the URL field correctly "
- + "refers to the CSP feed location.");
+ throw new SyncException("Could not find the feed at URL [" + url
+ + "]. Make sure the URL field correctly " + "refers to the CSP feed location.");
}
if (status == 401 || status == 403) {
- throw new Exception("Invalid login credentials specified for user [" + username + "]. Make sure "
+ throw new SyncException("Invalid login credentials specified for user [" + username + "]. Make sure "
+ "this user has an active account at the CSP and that the password is correct.");
}
if (status != 200) {
- throw new Exception("The call to retrieve the RSS feed failed with status code: " + status);
+ throw new SyncException("The call to retrieve the RSS feed failed with status code: " + status);
}
rawFeed = method.getResponseBodyAsString();
diff --git a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/RssFeedParser.java b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/RssFeedParser.java
index 9f35bee..c65a7b9 100644
--- a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/RssFeedParser.java
+++ b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/RssFeedParser.java
@@ -26,9 +26,17 @@ import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
+import churchillobjects.rss4j.RssChannel;
+import churchillobjects.rss4j.RssChannelItem;
+import churchillobjects.rss4j.RssDocument;
+import churchillobjects.rss4j.RssDublinCore;
+import churchillobjects.rss4j.RssJbnDependency;
+import churchillobjects.rss4j.RssJbnPatch;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
@@ -40,13 +48,6 @@ 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.PackageSyncReport;
-import churchillobjects.rss4j.RssChannel;
-import churchillobjects.rss4j.RssChannelItem;
-import churchillobjects.rss4j.RssDocument;
-import churchillobjects.rss4j.RssDublinCore;
-import churchillobjects.rss4j.RssJbnDependency;
-import churchillobjects.rss4j.RssJbnPatch;
-
/**
* Parses the contents of the JBoss RSS feed into the server's domain model.
*
@@ -86,7 +87,7 @@ public class RssFeedParser {
// Public --------------------------------------------
public void parseResults(RssDocument feed, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws Exception {
+ Collection<ContentProviderPackageDetails> existingPackages) throws ParserConfigurationException {
// Used to determine if a package was already sent to the server or is new
Map<PackageDetailsKey, ContentProviderPackageDetails> existingPackageMap = unpack(existingPackages);
@@ -202,8 +203,7 @@ public class RssFeedParser {
// bytes will be retrieved using platform encoding on the agent side so use the same
// on the server side and assume they are identical
packageDetails.setMetadata(choppedInstructions.trim().getBytes());
- }
- catch (Exception e) {
+ } catch (Exception e) {
log.error("Could not parse or set automated installation instructions for package: "
+ packageName);
continue;
@@ -254,8 +254,7 @@ public class RssFeedParser {
*/
private Map<PackageDetailsKey, ContentProviderPackageDetails> unpack(
Collection<ContentProviderPackageDetails> existingPackages) {
- Map<PackageDetailsKey, ContentProviderPackageDetails> map =
- new HashMap<PackageDetailsKey, ContentProviderPackageDetails>();
+ Map<PackageDetailsKey, ContentProviderPackageDetails> map = new HashMap<PackageDetailsKey, ContentProviderPackageDetails>();
if (existingPackages == null) {
return map;
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
index 56c21d4..04fdbba 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
@@ -49,7 +49,9 @@ import org.rhq.enterprise.server.plugin.pc.content.PackageSyncReport;
import org.rhq.enterprise.server.plugin.pc.content.RepoDetails;
import org.rhq.enterprise.server.plugin.pc.content.RepoImportReport;
import org.rhq.enterprise.server.plugin.pc.content.RepoSource;
+import org.rhq.enterprise.server.plugin.pc.content.SyncException;
import org.rhq.enterprise.server.plugin.pc.content.SyncProgressWeight;
+import org.rhq.enterprise.server.plugin.pc.content.ThreadUtil;
import org.rhq.enterprise.server.plugins.rhnhosted.certificate.Certificate;
import org.rhq.enterprise.server.plugins.rhnhosted.certificate.CertificateFactory;
import org.rhq.enterprise.server.plugins.rhnhosted.certificate.PublicKeyRing;
@@ -152,7 +154,7 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
* @inheritDoc
*/
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws Exception {
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException, InterruptedException {
log.info("synchronizePackages(repoName = " + repoName + ", report = " + report + ", existingPackages.size() = "
+ existingPackages.size());
RHNSummary summary = new RHNSummary(helper);
@@ -187,6 +189,7 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
long endTimeSlice = System.currentTimeMillis();
log.debug("Slice processed in " + (endTimeSlice - startTimeSlice) + "ms current size of pkgDetails is "
+ pkgDetails.size());
+ ThreadUtil.checkInterrupted();
}
long endTime = System.currentTimeMillis();
log.info("It took " + (endTime - startTime) + "ms too get PackageDetails for " + pkgIds.size()
@@ -202,6 +205,7 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
report.addNewPackage(p);
summary.added++;
}
+ ThreadUtil.checkInterrupted();
}
for (ContentProviderPackageDetails p : deletedPackages) {
log.debug("Package at (" + p.getDisplayName() + ") marked as deleted");
@@ -210,7 +214,7 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
}
} catch (Exception e) {
summary.errors.add(e.toString());
- throw e;
+ throw new SyncException("error synching packages.", e);
} finally {
//helper.disconnect();
summary.markEnded();
@@ -223,7 +227,7 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
* @inheritDoc
*/
public void synchronizeAdvisory(String repoName, AdvisorySyncReport report,
- Collection<AdvisoryDetails> existingAdvisory) throws Exception {
+ Collection<AdvisoryDetails> existingAdvisory) throws SyncException {
List<String> existingLabels = new ArrayList<String>();
for (AdvisoryDetails ad : existingAdvisory) {
@@ -233,17 +237,21 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
List<String> deletedAdvs = new ArrayList<String>(); //Existing advisories we want to remove.
deletedAdvs.addAll(existingLabels);
- List<String> errataIds = helper.getChannelAdvisory(repoName);
- List<AdvisoryDetails> advList = helper.getAdvisoryMetadata(errataIds, repoName);
- log.debug("Found " + advList.size() + " available errata");
- for (AdvisoryDetails adv : advList) {
- log.debug("Processing Advisory ::" + adv.getAdvisory());
- deletedAdvs.remove(adv.getAdvisory());
- if (!existingLabels.contains(adv.getAdvisory())) {
- log.debug("New Advisory " + adv.getAdvisory() + ") detected" + " with bugs" + adv.getBugs()
- + "with cves" + adv.getCVEs() + "wiuth packages" + adv.getPkgs());
- report.addAdvisory(adv);
+ try {
+ List<String> errataIds = helper.getChannelAdvisory(repoName);
+ List<AdvisoryDetails> advList = helper.getAdvisoryMetadata(errataIds, repoName);
+ log.debug("Found " + advList.size() + " available errata");
+ for (AdvisoryDetails adv : advList) {
+ log.debug("Processing Advisory ::" + adv.getAdvisory());
+ deletedAdvs.remove(adv.getAdvisory());
+ if (!existingLabels.contains(adv.getAdvisory())) {
+ log.debug("New Advisory " + adv.getAdvisory() + ") detected" + " with bugs" + adv.getBugs()
+ + "with cves" + adv.getCVEs() + "wiuth packages" + adv.getPkgs());
+ report.addAdvisory(adv);
+ }
}
+ } catch (Exception e) {
+ throw new SyncException("Error syncing advisory meta", e);
}
for (String adv : deletedAdvs) {
@@ -259,7 +267,7 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
* @inheritDoc
*/
public void synchronizeDistribution(String repoName, DistributionSyncReport report,
- Collection<DistributionDetails> existingDistros) throws Exception {
+ Collection<DistributionDetails> existingDistros) throws SyncException {
// Goal:
// This method will create the metadata representing what kickstart tree files need to be downloaded.
@@ -274,7 +282,12 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
List<String> deletedDistros = new ArrayList<String>(); //Existing distros we want to remove.
deletedDistros.addAll(existingLabels);
- List<String> availableLabels = helper.getSyncableKickstartLabels(repoName);
+ List<String> availableLabels;
+ try {
+ availableLabels = helper.getSyncableKickstartLabels(repoName);
+ } catch (Exception e) {
+ throw new SyncException("Error synching kickstart labels", e);
+ }
log.debug("Found " + availableLabels.size() + " available kickstart trees");
for (String label : availableLabels) {
log.debug("Processing kickstart: " + label);
@@ -294,7 +307,12 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
}
}
- List<DistributionDetails> ddList = helper.getDistributionMetaData(toSyncDistros);
+ List<DistributionDetails> ddList;
+ try {
+ ddList = helper.getDistributionMetaData(toSyncDistros);
+ } catch (Exception e) {
+ throw new SyncException("Error synching distro metadata", e);
+ }
report.addDistros(ddList);
}
diff --git a/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java b/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java
index 0af228e..c229a2b 100644
--- a/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java
+++ b/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java
@@ -38,6 +38,7 @@ 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.plugin.pc.content.SyncException;
import org.rhq.enterprise.server.plugin.pc.content.SyncProgressWeight;
import org.rhq.enterprise.server.plugins.url.RemotePackageInfo.SupportedPackageType;
@@ -176,7 +177,7 @@ public class UrlProvider implements ContentProvider, PackageSource {
}
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws Exception {
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException {
// put all existing packages in a "to be deleted" list. As we sync, we will remove
// packages from this list that still exist on the remote system. Any leftover in the list
@@ -187,9 +188,13 @@ public class UrlProvider implements ContentProvider, PackageSource {
// sync now
long before = System.currentTimeMillis();
- Map<String, RemotePackageInfo> locationList = getRemotePackageInfosFromIndex();
- for (RemotePackageInfo rpi : locationList.values()) {
- syncPackage(report, deletedPackages, rpi);
+ try {
+ Map<String, RemotePackageInfo> locationList = getRemotePackageInfosFromIndex();
+ for (RemotePackageInfo rpi : locationList.values()) {
+ syncPackage(report, deletedPackages, rpi);
+ }
+ } catch (Exception e) {
+ throw new SyncException("error synching packages", e);
}
long elapsed = System.currentTimeMillis() - before;
diff --git a/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java b/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
index 00bdb0f..36d000c 100644
--- a/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
+++ b/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
@@ -31,6 +31,7 @@ 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.PackageSource;
import org.rhq.enterprise.server.plugin.pc.content.PackageSyncReport;
+import org.rhq.enterprise.server.plugin.pc.content.SyncException;
import org.rhq.enterprise.server.plugin.pc.content.SyncProgressWeight;
/**
@@ -131,7 +132,7 @@ public class RepoProvider implements ContentProvider, PackageSource {
* @throws Exception On all errors.
*/
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws Exception {
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException {
Summary summary = new Summary(reader);
log.info("synchronizing with repo: " + reader + " started");
try {
@@ -157,7 +158,7 @@ public class RepoProvider implements ContentProvider, PackageSource {
}
} catch (Exception e) {
summary.errors.add(e.toString());
- throw e;
+ throw new SyncException("error synching synchronizePackages", e);
} finally {
repo.disconnect();
summary.markEnded();
commit 8a0a2ac291b4fe17019c3622544d33be150477d1
Author: John Matthews <jmatthew(a)redhat.com>
Date: Tue Jan 19 10:01:44 2010 -0500
1358 - generate yum metadata from database entries, expose through http
tested yum install/list of packages through http content
diff --git a/modules/enterprise/gui/content_http-war/pom.xml b/modules/enterprise/gui/content_http-war/pom.xml
index 452c0ce..4bbad94 100644
--- a/modules/enterprise/gui/content_http-war/pom.xml
+++ b/modules/enterprise/gui/content_http-war/pom.xml
@@ -131,6 +131,12 @@
</dependency>
<dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.4</version>
+ </dependency>
+
+ <dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2</version>
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
index 9c4a712..e2f96f5 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -55,6 +55,7 @@ public class ContentHTTPServlet extends DefaultServlet {
protected static final String PACKAGES = "packages";
protected static final String DISTRIBUTIONS = "distributions";
+ protected static final String REPODATA = "repodata";
protected RepoManagerLocal repoMgr;
protected ContentManagerLocal contentMgr;
@@ -176,20 +177,29 @@ public class ContentHTTPServlet extends DefaultServlet {
log.info("Parsed file name = " + fileName);
if (StringUtils.isBlank(fileName)) {
// form a directory listing for each package in repository.
- log.info("TODO: create index.html listing all the packages for this repo: " + repo.getName());
+ log.info("create listing of all packages for this repo: " + repo.getName());
renderPackageIndex(request, response, repo);
return;
- } else {
- log.info("fetch package bits and return them.");
- PackageVersion pv = getPackageVersionFromFileName(repo, fileName);
- if (pv == null) {
- log.info("Unable to find PackageVersion from filename: " + fileName);
- renderErrorPage(request, response);
- return;
- }
- response.setContentType("application/octet-stream");
- writePackageVersionBits(response.getOutputStream(), pv);
}
+ /*
+ * This will likely change in a future sprint.
+ * For now we are assuming that metadata is only yum metadata
+ * and it's accessed as 'packages/repodata/primary.xml'
+ */
+ if (StringUtils.equals(fileName, REPODATA)) {
+ renderMetadata(request, response, repo);
+ return;
+ }
+
+ log.info("fetch package bits and return them.");
+ PackageVersion pv = getPackageVersionFromFileName(repo, fileName);
+ if (pv == null) {
+ log.info("Unable to find PackageVersion from filename: " + fileName);
+ renderErrorPage(request, response);
+ return;
+ }
+ response.setContentType("application/octet-stream");
+ writePackageVersionBits(response.getOutputStream(), pv);
}
protected void renderPackageIndex(HttpServletRequest request, HttpServletResponse response, Repo repo)
@@ -210,6 +220,46 @@ public class ContentHTTPServlet extends DefaultServlet {
writeResponse(sb.toString(), response);
}
+ protected void renderMetadata(HttpServletRequest request, HttpServletResponse response, Repo repo)
+ throws IOException {
+ log.info("renderMetadata(repo name = " + repo.getName() + ", id = " + repo.getId());
+
+ String metadataFilename = getMetadataFileName(request.getRequestURI());
+ if (StringUtils.isBlank(metadataFilename)) {
+ renderMetadataIndex(request, response, repo);
+ return;
+ }
+ // Generate Yum Metadata
+ log.info("Generate Yum Metadata for : " + metadataFilename);
+ List<PackageVersion> pvs = repoMgr.findPackageVersionsInRepo(LookupUtil.getSubjectManager().getOverlord(), repo
+ .getId(), PageControl.getUnlimitedInstance());
+ log.info(pvs.size() + " packages were found for repo : " + repo.getName());
+ StringBuffer sb = new StringBuffer();
+ if (!YumMetadata.generate(sb, repo, pvs, metadataFilename)) {
+ log.info("Error generating: " + metadataFilename + " for repo: " + repo.getName() + " with " + pvs.size()
+ + " packages");
+ renderErrorPage(request, response);
+ return;
+ }
+ writeResponse(sb.toString(), response, "text/xml; charset=utf-8");
+ }
+
+ protected void renderMetadataIndex(HttpServletRequest request, HttpServletResponse response, Repo repo)
+ throws IOException {
+ log.info("renderMetadataIndex(repo name = " + repo.getName() + ", id = " + repo.getId());
+
+ StringBuffer sb = new StringBuffer();
+ HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
+ HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
+
+ // We are only supporting 2 types of yum metadata
+ HtmlRenderer.formFileEntry(sb, request, "primary.xml", new Date().toString(), -1);
+ HtmlRenderer.formFileEntry(sb, request, "repomd.xml", new Date().toString(), -1);
+
+ HtmlRenderer.formEnd(sb);
+ writeResponse(sb.toString(), response);
+ }
+
protected void renderDistributions(HttpServletRequest request, HttpServletResponse response, Repo repo)
throws IOException {
log.info("renderDistributions(repo name = " + repo.getName() + ", id = " + repo.getId() + ", isCandidate = "
@@ -301,8 +351,12 @@ public class ContentHTTPServlet extends DefaultServlet {
}
protected boolean writeResponse(String data, HttpServletResponse response) throws IOException {
+ return writeResponse(data, response, "text/html");
+ }
- response.setContentType("text/html");
+ protected boolean writeResponse(String data, HttpServletResponse response, String contentType) throws IOException {
+
+ response.setContentType(contentType);
PrintWriter out = response.getWriter();
out.write(data);
out.flush();
@@ -360,6 +414,16 @@ public class ContentHTTPServlet extends DefaultServlet {
return getNthPiece(4, requestURI);
}
+ /**
+ *
+ * @param requestURI
+ * @return metadata file name or "" if no file name could be determined
+ */
+ protected String getMetadataFileName(String requestURI) {
+ // expecting something like '.../packages/repodata/primary.xml'
+ return getNthPiece(5, requestURI);
+ }
+
protected String getDistLabel(String requestURI) {
return getNthPiece(4, requestURI);
}
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/YumMetadata.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/YumMetadata.java
new file mode 100644
index 0000000..0210d53
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/YumMetadata.java
@@ -0,0 +1,167 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.gui.content;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.security.DigestInputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.List;
+import java.util.zip.GZIPInputStream;
+
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.content.PackageVersion;
+import org.rhq.core.domain.content.Repo;
+import org.rhq.core.util.stream.StreamUtil;
+
+public class YumMetadata {
+ final private static Log log = LogFactory.getLog(YumMetadata.class);
+
+ final public static String PRIMARY_XML = "primary.xml";
+ final public static String REPOMD_XML = "repomd.xml";
+
+ /*
+
+ This class is implementing a temporary way to grab yum metadata.
+ It's following the approach done by: org.rhq.plugins.platform.content.yum.Primary
+ In a future sprint this topic will be revisited and this approach should change.
+
+ Each package has the ability to store it's metadata in the database.
+ We are assuming the metadata was stored as a xml string which has been gzipped.
+ We'll grab this from the DB, uncompress, and adjust the "location" element.
+ Note: The location element is what yum will use to form the GET request to fetch the package.
+
+ All of these entries are added together to form the primary.xml
+ */
+
+ public static boolean generate(StringBuffer sb, Repo repo, List<PackageVersion> pvs, String filename) {
+ if (StringUtils.equalsIgnoreCase(filename, PRIMARY_XML)) {
+ generatePrimary(sb, repo, pvs);
+ return true;
+ }
+ if (StringUtils.equalsIgnoreCase(filename, REPOMD_XML)) {
+ return generateRepoMD(sb, repo, pvs);
+ }
+ return false;
+ }
+
+ protected static void generatePrimary(StringBuffer sb, Repo repo, List<PackageVersion> pvs) {
+ sb.append("<metadata xmlns=\"http://linux.duke.edu/metadata/common\" ");
+ sb.append("packages=\"" + pvs.size() + "\">\n");
+ sb.append("xmlns:rpm=\"http://linux.duke.edu/metadata/rpm\" ");
+ for (PackageVersion p : pvs) {
+ String metadata = unzip(p.getMetadata());
+ metadata = modifyLocation(metadata, repo.getName(), p.getFileName());
+ if (StringUtils.isBlank(metadata)) {
+ log.warn("No metadata for package : " + p.getDisplayName() + " not adding this to primary.xml");
+ continue;
+ }
+ sb.append(metadata + "\n");
+ }
+ sb.append("</metadata>");
+ }
+
+ protected static boolean generateRepoMD(StringBuffer sb, Repo repo, List<PackageVersion> pvs) {
+ StringBuffer primaryXML = new StringBuffer();
+ generatePrimary(primaryXML, repo, pvs);
+ sb.append("<repomd xmlns=\"http://linux.duke.edu/metadata/repo\">");
+ try {
+ writeRepoMDEntry(sb, "primary", getSHA(primaryXML), "0");
+ } catch (NoSuchAlgorithmException e) {
+ log.info(e);
+ return false;
+ } catch (IOException e) {
+ log.info(e);
+ return false;
+ }
+ sb.append("</repomd>");
+ return true;
+ }
+
+ protected static String getSHA(StringBuffer primaryXML) throws NoSuchAlgorithmException, IOException {
+ // Note: For RHEL6 this may need to change to "SHA-256",
+ // going for SHA for now, as it's a lowest common denominator so it can work with older clients.
+ MessageDigest md = MessageDigest.getInstance("SHA");
+ ByteArrayInputStream bis = new ByteArrayInputStream(primaryXML.toString().getBytes());
+ DigestInputStream mdistr = new DigestInputStream(bis, md);
+ while (mdistr.read() != -1) {
+ ;
+ }
+ mdistr.close();
+ return Hex.encodeHexString(md.digest());
+ }
+
+ protected static void writeRepoMDEntry(StringBuffer sb, String type, String sum, String ts) {
+ sb.append("\t<data type=\"" + type + "\">\n");
+ sb.append("\t<location href=\"repodata/" + type + ".xml\"/>\n");
+ sb.append("\t<checksum type=\"sha\">" + sum + "</checksum>\n");
+ sb.append("\t<timestamp>" + ts + "</timestamp>\n");
+ sb.append("\t</data>\n\n");
+ }
+
+ protected static String unzip(byte[] zippedMetadata) {
+ try {
+ ByteArrayInputStream bis = new ByteArrayInputStream(zippedMetadata);
+ ByteArrayOutputStream unzipped = new ByteArrayOutputStream();
+ GZIPInputStream gis = new GZIPInputStream(bis);
+ StreamUtil.copy(gis, unzipped);
+ return unzipped.toString();
+ } catch (IOException e) {
+ log.warn(e);
+ return "";
+ }
+ }
+
+ protected static String modifyLocation(String metadata, String repoName, String filename) {
+ /**
+ * We will wipe out the current <location href=""> and insert our own which has the package filename.
+ *
+ * Note: this might be a redundant step for content synced from RHN Hosted, yet to avoid cases where the
+ * location might not be what we want, we'll always drop it and put the filename in so we are guaranteed it's
+ * correct.
+ */
+ final String START_STR = "<location ";
+ final String END_STR = "/>";
+
+ int startIndex = metadata.indexOf(START_STR);
+ if (startIndex == -1) {
+ log.info("Unable to find " + START_STR + " in metadata.");
+ return metadata;
+ }
+ // adjust startIndex to point to after START_STR
+ startIndex = startIndex + START_STR.length();
+ int endIndex = metadata.indexOf(END_STR, startIndex);
+ if (endIndex == -1) {
+ log.info("Unable to find " + END_STR + " in metadata.");
+ return metadata;
+ }
+
+ String partA = metadata.substring(0, startIndex);
+ String partB = metadata.substring(endIndex);
+
+ String href = " href=\"" + filename + "\"";
+ return partA + href + partB;
+ }
+}
commit 95922e034c4bbce4a9e976f765c115af5f3d4f76
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Tue Jan 19 09:42:24 2010 -0500
1424 - Work towards content web service APIs -- remove cyclical dependencies
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryBuglist.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryBuglist.java
index cff35be..ab4f537 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryBuglist.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryBuglist.java
@@ -36,9 +36,10 @@ import javax.persistence.NamedQuery;
import javax.persistence.PrePersist;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlTransient;
/**
- * This is the entity mapping that correlates an advisory with associated bugid.
+ * This is the entity mapping that correlates an advisory with associated bugid.
*
* @author Pradeep Kilambi
*/
@@ -68,6 +69,7 @@ public class AdvisoryBuglist implements Serializable {
@Id
private int id;
+ @XmlTransient
@ManyToOne
@JoinColumn(name = "ADVISORY_ID", referencedColumnName = "ID", nullable = false)
private Advisory advisory;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java
index a87d997..bc9ad68 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java
@@ -36,9 +36,10 @@ import javax.persistence.NamedQuery;
import javax.persistence.PrePersist;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlTransient;
/**
- * This is the many-to-many entity that correlates an advisory with a package.
+ * This is the many-to-many entity that correlates an advisory with a package.
*
* @author Pradeep Kilambi
*/
@@ -65,6 +66,7 @@ public class AdvisoryCVE implements Serializable {
@Id
private int id;
+ @XmlTransient
@ManyToOne
@JoinColumn(name = "ADVISORY_ID", referencedColumnName = "ID", nullable = false)
private Advisory advisory;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryPackage.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryPackage.java
index c2b6d30..17bd2d8 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryPackage.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryPackage.java
@@ -36,9 +36,10 @@ import javax.persistence.NamedQuery;
import javax.persistence.PrePersist;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlTransient;
/**
- * This is the many-to-many entity that correlates an advisory with a package.
+ * This is the many-to-many entity that correlates an advisory with a package.
*
* @author Pradeep Kilambi
*/
@@ -69,6 +70,7 @@ public class AdvisoryPackage implements Serializable {
@Id
private int id;
+ @XmlTransient
@ManyToOne
@JoinColumn(name = "ADVISORY_ID", referencedColumnName = "ID", nullable = false)
private Advisory advisory;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java
index 6826442..0ba61b0 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java
@@ -37,6 +37,7 @@ import javax.persistence.NamedQuery;
import javax.persistence.PrePersist;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlTransient;
/**
* This is the many-to-many entity that correlates a distribution with its associated files.
@@ -67,6 +68,7 @@ public class DistributionFile {
@Id
private int id;
+ @XmlTransient
@JoinColumn(name = "DISTRIBUTION_ID", referencedColumnName = "ID", nullable = false)
@ManyToOne(cascade = { CascadeType.MERGE, CascadeType.PERSIST })
private Distribution distribution;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
index 5f4061c..1180f6e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
@@ -46,6 +46,7 @@ import javax.persistence.PreUpdate;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
+import javax.xml.bind.annotation.XmlTransient;
import org.rhq.core.domain.common.Tag;
import org.rhq.core.domain.common.Taggable;
@@ -169,9 +170,11 @@ public class Repo implements Serializable, Taggable {
// latest appears first, oldest last
private List<RepoSyncResults> syncResults;
+ @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Set<RepoDistribution> repoDistributions;
+ @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Set<RepoAdvisory> repoAdvisories;
@@ -382,13 +385,13 @@ public class Repo implements Serializable, Taggable {
/**
* Get the overall sync status of this Repository. This is a summation of all the syncs.
- *
+ *
* There is a weight to the status since this returns the most 'relevant' status:
- *
+ *
* 1) ContentSourceSyncStatus.FAILURE
* 2) ContentSourceSyncStatus.INPROGRESS
* 3) ContentSourceSyncStatus.SUCCESS
- *
+ *
* @return String summary of the status of this Repository
*/
@Transient
@@ -819,7 +822,7 @@ public class Repo implements Serializable, Taggable {
}
/**
- * Removes association with a tag, if it exists.
+ * Removes association with a tag, if it exists.
*/
public void removeTag(Tag tag) {
if ((this.repoTags == null) || (tag == null)) {
commit daf920f22a6f325d98534761f58074130520b207
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Mon Jan 18 15:03:51 2010 -0500
Removed unnecessary method; was replaced by retrieving the distribution files and getting their bits.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
index 56082a3..14dc8fb 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
@@ -110,11 +110,6 @@ public class DistributionManagerBean implements DistributionManagerLocal, Distri
}
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public void getDistributionBits(Subject user, String kslabel) {
- //TODO: Implement the ks tree bit downloads
- }
-
@SuppressWarnings("unchecked")
public Distribution getDistributionByLabel(String kslabel) {
Query query = entityManager.createNamedQuery(Distribution.QUERY_FIND_BY_DIST_LABEL);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java
index 89e40a2..8528da8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java
@@ -47,7 +47,7 @@ public interface DistributionManagerLocal {
/**
* Deletes a given instance of distribution object. If the object does not exist
- * @param subject
+ * @param subject
* @param repoId
*/
void deleteDistributionMappingsForRepo(Subject subject, int repoId);
@@ -60,14 +60,6 @@ public interface DistributionManagerLocal {
void deleteDistributionByDistId(Subject subject, int distId);
/**
- * get the kickstart tree bits either from database or filesystem based on kickstart label
- * @param subject
- * @param kslabel
- * @return
- */
- void getDistributionBits(Subject subject, String kslabel);
-
- /**
* get distribution based on a given label
* @param kslabel distribution tree label
* @return kickstart tree object
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java
index 00be58b..bebd3a1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java
@@ -67,16 +67,6 @@ public interface DistributionManagerRemote {
@WebParam(name = "distId") int distId) throws Exception;
/**
- * get the kickstart tree bits either from database or filesystem based on kickstart label
- * @param subject
- * @param kslabel
- * @return
- */
- @WebMethod
- void getDistributionBits(@WebParam(name = "subject") Subject subject, //
- @WebParam(name = "kslabel") String kslabel) throws Exception;
-
- /**
* get kickstart tree based on a given label
* @param kslabel kickstart tree label
* @return kickstart tree object
commit 8e734d142794008ba3def73f187741ec313d38e0
Author: John Matthews <jmatthew(a)redhat.com>
Date: Fri Jan 15 18:41:13 2010 -0500
1357 - adding support to browse/download distribution files
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
index b5b3604..9c4a712 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -35,6 +35,8 @@ 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.Distribution;
+import org.rhq.core.domain.content.DistributionFile;
import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
@@ -42,6 +44,7 @@ import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.content.ContentManagerLocal;
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.util.LookupUtil;
@@ -56,6 +59,7 @@ public class ContentHTTPServlet extends DefaultServlet {
protected RepoManagerLocal repoMgr;
protected ContentManagerLocal contentMgr;
protected ContentSourceManagerLocal contentSourceMgr;
+ protected DistributionManagerLocal distroMgr;
public ContentHTTPServlet() {
super();
@@ -66,6 +70,7 @@ public class ContentHTTPServlet extends DefaultServlet {
repoMgr = LookupUtil.getRepoManagerLocal();
contentMgr = LookupUtil.getContentManager();
contentSourceMgr = LookupUtil.getContentSourceManager();
+ distroMgr = LookupUtil.getDistributionManagerLocal();
log.info("ContentHTTPServlet resolved references in init.");
}
@@ -142,7 +147,7 @@ public class ContentHTTPServlet extends DefaultServlet {
// Skip candidate repos
if (!r.isCandidate()) {
String lastMod = new Date(r.getLastModifiedDate()).toString();
- HtmlRenderer.formDirEntry(request, sb, r.getName(), lastMod);
+ HtmlRenderer.formDirEntry(sb, request, r.getName(), lastMod);
}
}
HtmlRenderer.formEnd(sb);
@@ -155,8 +160,8 @@ public class ContentHTTPServlet extends DefaultServlet {
StringBuffer sb = new StringBuffer();
HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
- HtmlRenderer.formDirEntry(request, sb, PACKAGES, "-");
- HtmlRenderer.formDirEntry(request, sb, DISTRIBUTIONS, "-");
+ HtmlRenderer.formDirEntry(sb, request, PACKAGES, "-");
+ HtmlRenderer.formDirEntry(sb, request, DISTRIBUTIONS, "-");
HtmlRenderer.formEnd(sb);
writeResponse(sb.toString(), response);
}
@@ -183,7 +188,7 @@ public class ContentHTTPServlet extends DefaultServlet {
return;
}
response.setContentType("application/octet-stream");
- writePackageVersionBits(pv, response.getOutputStream());
+ writePackageVersionBits(response.getOutputStream(), pv);
}
}
@@ -198,7 +203,7 @@ public class ContentHTTPServlet extends DefaultServlet {
HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
for (PackageVersion pv : pvs) {
- HtmlRenderer.formFileEntry(request, sb, pv.getFileName(), new Date(pv.getFileCreatedDate()).toString(), pv
+ HtmlRenderer.formFileEntry(sb, request, pv.getFileName(), new Date(pv.getFileCreatedDate()).toString(), pv
.getFileSize());
}
HtmlRenderer.formEnd(sb);
@@ -207,10 +212,85 @@ public class ContentHTTPServlet extends DefaultServlet {
protected void renderDistributions(HttpServletRequest request, HttpServletResponse response, Repo repo)
throws IOException {
+ log.info("renderDistributions(repo name = " + repo.getName() + ", id = " + repo.getId() + ", isCandidate = "
+ + repo.isCandidate() + ")");
+
+ String distLabel = getDistLabel(request.getRequestURI());
+ log.info("Parsed dist label is = " + distLabel);
+ if (StringUtils.isBlank(distLabel)) {
+ // form a directory listing for each distribution in repository.
+ log.info("TODO: create index.html listing all the distribution labels for this repo: " + repo.getName());
+ renderDistributionLabels(request, response, repo);
+ return;
+ }
+ // Get Distribution
+ Distribution dist = distroMgr.getDistributionByLabel(distLabel);
+ if (dist == null) {
+ log.info("Unable to find Distribution by label '" + distLabel + "'");
+ renderErrorPage(request, response);
+ return;
+ }
+ String fileRequest = getDistFilePath(request.getRequestURI());
+ if (StringUtils.isEmpty(fileRequest)) {
+ log.info("no distribution file was found in request, so render list of all distribution files");
+ renderDistributionFileList(request, response, dist);
+ return;
+ }
+ log.info("Parsed DistributionFile request is for: " + fileRequest);
+ // Looks like a request for a distribution file
+ List<DistributionFile> distFiles = distroMgr.getDistributionFilesByDistId(dist.getId());
+ if (distFiles.isEmpty()) {
+ log.info("Unable to find any distribution files for dist: " + dist.getLabel());
+ renderErrorPage(request, response);
+ return;
+ }
+ for (DistributionFile dFile : distFiles) {
+ log.info("Compare: " + dFile.getRelativeFilename() + " to " + fileRequest);
+ if (StringUtils.equalsIgnoreCase(dFile.getRelativeFilename(), fileRequest)) {
+ response.setContentType("application/octet-stream");
+ writeDistributionFileBits(response.getOutputStream(), dFile);
+ return;
+ }
+ }
+ log.info("Searched through DistributionFiles and unable to find: " + fileRequest + ", in Distribution: "
+ + dist.getLabel());
+
+ renderErrorPage(request, response);
+
+ }
+
+ protected void renderDistributionFileList(HttpServletRequest request, HttpServletResponse response,
+ Distribution dist) throws IOException {
+
+ List<DistributionFile> distFiles = distroMgr.getDistributionFilesByDistId(dist.getId());
+ log.info("For Distribution label '" + dist.getLabel() + "' " + distFiles.size()
+ + " distribution files were found");
+
+ StringBuffer sb = new StringBuffer();
+ HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
+ HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
+ for (DistributionFile dFile : distFiles) {
+ HtmlRenderer.formFileEntry(sb, request, dFile.getRelativeFilename(), new Date(dFile.getLastModified())
+ .toString(), -1);
+ }
+ HtmlRenderer.formEnd(sb);
+ writeResponse(sb.toString(), response);
+ }
+
+ protected void renderDistributionLabels(HttpServletRequest request, HttpServletResponse response, Repo repo)
+ throws IOException {
StringBuffer sb = new StringBuffer();
HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
+ // Get list of Distributions per repo
+ List<Distribution> distros = repoMgr.findAssociatedDistributions(LookupUtil.getSubjectManager().getOverlord(),
+ repo.getId(), PageControl.getUnlimitedInstance());
+ log.info("Found " + distros.size() + " for repo " + repo.getName());
+ for (Distribution d : distros) {
+ log.info("Creating link for distribution label: " + d.getLabel());
+ HtmlRenderer.formDirEntry(sb, request, d.getLabel(), new Date(d.getLastModifiedDate()).toString());
+ }
HtmlRenderer.formEnd(sb);
writeResponse(sb.toString(), response);
}
@@ -280,6 +360,37 @@ public class ContentHTTPServlet extends DefaultServlet {
return getNthPiece(4, requestURI);
}
+ protected String getDistLabel(String requestURI) {
+ return getNthPiece(4, requestURI);
+ }
+
+ /**
+ *
+ * @param requestURI
+ * @return
+ */
+ protected String getDistFilePath(String requestURI) {
+ // Goal is we find where the distribution file path starts
+ // then we return the entire path, it may include an unknown
+ // level of sub-directories.
+ StrTokenizer st = new StrTokenizer(requestURI, "/");
+ List<String> tokens = st.getTokenList();
+ if (tokens.isEmpty()) {
+ return "";
+ }
+ int startIndex = 4;
+ String distFilePath = "";
+ for (int index = startIndex; index < tokens.size(); index++) {
+ distFilePath = distFilePath + "/" + tokens.get(index);
+ log.info("index = " + index + ", distFilePath = " + distFilePath);
+ }
+ // Remove the '/' we added to the front of this string
+ if (distFilePath.startsWith("/")) {
+ distFilePath = distFilePath.substring(1);
+ }
+ return distFilePath;
+ }
+
/**
* @param n nth element to return from requestURI, (first element corresponds to 1, not 0)
* @param requestURI
@@ -326,7 +437,24 @@ public class ContentHTTPServlet extends DefaultServlet {
return pv;
}
- protected boolean writePackageVersionBits(PackageVersion pkgVer, ServletOutputStream output) {
+ protected boolean writeDistributionFileBits(ServletOutputStream output, DistributionFile distFile)
+ throws IOException {
+
+ try {
+ contentSourceMgr.outputDistributionFileBits(distFile, output);
+ output.flush();
+ output.close();
+ } catch (IllegalStateException e) {
+ log.error(e);
+ return false;
+ } catch (IOException e) {
+ log.error(e);
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean writePackageVersionBits(ServletOutputStream output, PackageVersion pkgVer) {
try {
contentSourceMgr.outputPackageVersionBits(pkgVer, output);
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java
index 0b47d95..1d52ae7 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java
@@ -66,11 +66,11 @@ public class HtmlRenderer {
public static String formDirEntry(HttpServletRequest request, String dirName, String lastMod) {
StringBuffer sb = new StringBuffer();
- formDirEntry(request, sb, dirName, lastMod);
+ formDirEntry(sb, request, dirName, lastMod);
return sb.toString();
}
- public static void formDirEntry(HttpServletRequest request, StringBuffer sb, String dirName, String lastMod) {
+ public static void formDirEntry(StringBuffer sb, HttpServletRequest request, String dirName, String lastMod) {
if (!dirName.endsWith("/")) {
dirName = dirName + "/";
}
@@ -82,16 +82,22 @@ public class HtmlRenderer {
public static String formFileEntry(HttpServletRequest request, String fileName, String lastModDate, long fileSize) {
StringBuffer sb = new StringBuffer();
- formFileEntry(request, sb, fileName, lastModDate, fileSize);
+ formFileEntry(sb, request, fileName, lastModDate, fileSize);
return sb.toString();
}
- public static void formFileEntry(HttpServletRequest request, StringBuffer sb, String fileName, String lastMod,
+ public static void formFileEntry(StringBuffer sb, HttpServletRequest request, String fileName, String lastMod,
long fileSize) {
+
+ String fSize = new Long(fileSize).toString();
+ if (fileSize < 0) {
+ fSize = "-";
+ }
sb.append("<tr><td valign=\"top\"><img src=\"" + getIconPath("/icons/unknown.gif")
+ "\" alt=\"[DIR]\" width=\"20\" height=\"22\"></td>\n");
sb.append("<td><a href=\"" + getLink(request, fileName) + "\">" + fileName + "</a></td>\n");
- sb.append("<td align=\"right\">" + lastMod + "</td><td align=\"right\"> - </td><td> </td></tr>\n");
+ sb.append("<td align=\"right\">" + lastMod + "</td><td align=\"right\">" + fSize
+ + "</td><td> </td></tr>\n");
}
protected static String getIconPath(String path) {
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 fbfaedb..09aad7e 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
@@ -2068,4 +2068,33 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
return packageBitsFile;
}
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ @TransactionTimeout(45 * 60)
+ public long outputDistributionFileBits(DistributionFile distFile, OutputStream outputStream) {
+
+ long numBytes = 0;
+ InputStream bitStream = null;
+ try {
+ Distribution dist = distFile.getDistribution();
+ log.info("Distribution has a basePath of " + dist.getBasePath());
+ String distFilePath = dist.getBasePath() + "/" + distFile.getRelativeFilename();
+ File f = getDistributionFileBitsLocalFilesystemFile(dist.getLabel(), distFilePath);
+ log.info("Fetching: " + distFilePath + " on local file store from: " + f.getAbsolutePath());
+ bitStream = new FileInputStream(f);
+ numBytes = StreamUtil.copy(bitStream, outputStream);
+
+ } catch (Exception e) {
+ log.info(e);
+ } finally {
+ // close our stream but leave the output stream open
+ try {
+ bitStream.close();
+ } catch (Exception closeError) {
+ log.warn("Failed to close the bits stream", closeError);
+ }
+ }
+ log.debug("Retrieved and sent [" + numBytes + "] bytes for [" + distFile.getRelativeFilename() + "]");
+ return numBytes;
+ }
}
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 5fa9fa3..cc742e7 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
@@ -30,6 +30,7 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.content.ContentSource;
import org.rhq.core.domain.content.ContentSourceSyncResults;
import org.rhq.core.domain.content.ContentSourceType;
+import org.rhq.core.domain.content.DistributionFile;
import org.rhq.core.domain.content.DownloadMode;
import org.rhq.core.domain.content.PackageBits;
import org.rhq.core.domain.content.PackageDetailsKey;
@@ -576,6 +577,20 @@ public interface ContentSourceManagerLocal {
long outputPackageVersionBits(PackageVersion packageVersion, OutputStream outputStream);
/**
+ * Requests the bits of a distribution file be streamed down to the caller over the given output stream.
+ * This method will <b>not</b> take care of closing the stream when it is finished;
+ * it is the caller's responsibility.
+ *
+ * @param distFile distribution file to fetch
+ * @param outputStream an output stream where the server should write the package contents. It is up to the
+ * caller to prepare this output stream in order to write the package content to an
+ * appropriate location.
+ *
+ * @return the number of bytes written to the output stream
+ */
+ long outputDistributionFileBits(DistributionFile distFile, OutputStream outputStream);
+
+ /**
* Adds the specified content source to the database but does not attempt to create or start
* the server-side plugin provider implementation associated with it.
* <p/>
commit 74bb7ee71f05a2d58f28322fe247c5383339fea1
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Fri Jan 15 15:20:57 2010 -0500
Added the database keys to the schema to help the plugin writer.
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
index 5a6473e..9d09ba1 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
@@ -245,7 +245,8 @@ public class ConfigurationMetadataParser {
.deCamelCase(dynamicProperty.getName());
PropertyDefinitionDynamic property = new PropertyDefinitionDynamic(dynamicProperty.getName(), description,
- dynamicProperty.isRequired(), PropertyDynamicType.DATABASE, dynamicProperty.getDatabaseBacking().getKey());
+ dynamicProperty.isRequired(), PropertyDynamicType.DATABASE,
+ dynamicProperty.getDatabaseBacking().getKey().value());
property.setReadOnly(dynamicProperty.isReadOnly());
property.setSummary(dynamicProperty.isSummary());
diff --git a/modules/core/client-api/src/main/resources/rhq-configuration.xsd b/modules/core/client-api/src/main/resources/rhq-configuration.xsd
index e6c479d..869de57 100644
--- a/modules/core/client-api/src/main/resources/rhq-configuration.xsd
+++ b/modules/core/client-api/src/main/resources/rhq-configuration.xsd
@@ -232,14 +232,21 @@
<xs:documentation>Configures a property to look up values from the database.</xs:documentation>
</xs:annotation>
- <xs:attribute name="key" type="xs:string" use="required">
+ <xs:attribute name="key" type="config:databaseBackingKeys" use="required">
<xs:annotation>
<xs:documentation>Key RHQ will use to determine what values to retieve from the database.</xs:documentation>
</xs:annotation>
</xs:attribute>
-
</xs:complexType>
+ <xs:simpleType name="databaseBackingKeys">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="users"/>
+ <xs:enumeration value="roles"/>
+ <xs:enumeration value="package-types"/>
+ </xs:restriction>
+ </xs:simpleType>
+
<xs:element name="simple-property" type="config:simpleProperty" substitutionGroup="config:configuration-property"/>
<xs:complexType name="simpleProperty">
<xs:complexContent>
commit fe67a23b0b7df690999fe8fc0300b0c2e6a816f6
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Fri Jan 15 11:05:41 2010 -0500
Updated to more fully exercise the options available when defining properties.
diff --git a/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
index b7f98cb..2d3161e 100644
--- a/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -19,21 +19,24 @@
<c:simple-property name="rootDirectory" type="directory" required="true"
description="The root directory that contains all content that is to be served by this content provider. In an HA environment, this must be on a distributed file system that all servers can access."/>
- <c:dynamic-property name="users" description="TEST - List of all users in the system.">
+ <c:dynamic-property name="users" displayName="User Display Name" description="TEST - List of all users in the system."
+ required="true" activationPolicy="shutdown">
<c:database-backing key="users"/>
</c:dynamic-property>
-<!-- <c:dynamic-property name="roles" description="TEST - List of all roles in the system.">
+ <c:dynamic-property name="roles" description="TEST - List of all roles in the system."
+ readOnly="true" required="false">
<c:database-backing key="roles"/>
</c:dynamic-property>
- <c:dynamic-property name="packageTypes" description="TEST - List of all package types in the system.">
+ <c:dynamic-property name="packageTypes" description="TEST - List of all package types in the system."
+ required="false" summary="true">
<c:database-backing key="package-types"/>
- </c:dynamic-property>-->
+ </c:dynamic-property>
</c:group>
<c:group name="Package Source">
- <c:simple-property name="packageSourceEnabled" required="true" summary="true" default="true"
+ <c:simple-property name="packageSourceEnabled" required="true" summary="true" default="true" readOnly="true"
type="boolean" description="Indicates if this instance of the plugin should act as a package source"/>
<c:simple-property name="filenameFilter" required="true" summary="true" default=".*"
description="A regular expression that identifies a file of this package type (e.g. '.*\.jar', '.*/i686/.*\.rpm$')"/>
commit 03963af2d460248c9b6dee0ce235fb67a3f39ba8
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Fri Jan 15 11:05:22 2010 -0500
Fixed required indicator not appearing for dynamic configuration properties.
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
index 03d01c3..c73205a 100644
--- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
@@ -360,8 +360,10 @@ public class PropertyRenderingUtility {
Property property, boolean configReadOnly) {
String displayName = (propertyDefinition != null) ? propertyDefinition.getDisplayName() : property.getName();
FacesComponentUtility.addOutputText(parent, null, displayName, CssStyleClasses.PROPERTY_DISPLAY_NAME_TEXT);
- if (!configReadOnly && propertyDefinition != null && propertyDefinition.isRequired()
- && (propertyDefinition instanceof PropertyDefinitionSimple)) {
+ if (!configReadOnly && propertyDefinition != null &&
+ propertyDefinition.isRequired() &&
+ (propertyDefinition instanceof PropertyDefinitionSimple ||
+ propertyDefinition instanceof PropertyDefinitionDynamic) ) {
// Print a required marker next to required simples.
// Ignore the required field for maps and lists, as it is has no significance for them.
FacesComponentUtility.addOutputText(parent, null, " * ", CssStyleClasses.REQUIRED_MARKER_TEXT);
commit 2612b772597ed556e7655514218cdbe54a28f97b
Author: John Matthews <jmatthew(a)redhat.com>
Date: Thu Jan 14 18:09:18 2010 -0500
1357 - update to how we render links
fixes a problem I saw while testing, after I traversed back from a page using the parent link
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
index d301413..b5b3604 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -48,7 +48,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class ContentHTTPServlet extends DefaultServlet {
private final Log log = LogFactory.getLog(ContentHTTPServlet.class);
- protected static final String CONTENT_URI = "/content";
+ protected static final String CONTENT_URI = "/content/";
protected static final String PACKAGES = "packages";
protected static final String DISTRIBUTIONS = "distributions";
@@ -77,13 +77,15 @@ public class ContentHTTPServlet extends DefaultServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
log.info("doGet(): requestURI = " + request.getRequestURI());
if (isIconRequest(request)) {
+ // this request is for our icons which are static content in the webapp
+ // defer back to DefaultServlet.doGet and this will be served automatically
super.doGet(request, response);
return;
}
// Check if repo has been specified
Repo repo = getRepo(request, response);
if (repo == null) {
- log.info("No repo found so we'll render a list of all repos.");
+ log.info("No repo found, possibly bad repo name, or no name was entered.");
renderRepoList(request, response);
return;
}
@@ -196,7 +198,7 @@ public class ContentHTTPServlet extends DefaultServlet {
HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
for (PackageVersion pv : pvs) {
- HtmlRenderer.formFileEntry(sb, pv.getFileName(), new Date(pv.getFileCreatedDate()).toString(), pv
+ HtmlRenderer.formFileEntry(request, sb, pv.getFileName(), new Date(pv.getFileCreatedDate()).toString(), pv
.getFileSize());
}
HtmlRenderer.formEnd(sb);
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java
index f1f0826..0b47d95 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java
@@ -76,24 +76,41 @@ public class HtmlRenderer {
}
sb.append("<tr><td valign=\"top\"><img src=\"" + getIconPath("/icons/folder.gif")
+ "\" alt=\"[DIR]\" width=\"20\" height=\"22\"></td>\n");
- sb.append("<td><a href=\"" + request.getRequestURI() + "/" + dirName + "\">" + dirName + "</a></td>\n");
+ sb.append("<td><a href=\"" + getLink(request, dirName) + "\">" + dirName + "</a></td>\n");
sb.append("<td align=\"right\">" + lastMod + "</td><td align=\"right\"> - </td><td> </td></tr>\n");
}
- public static String formFileEntry(String fileName, String lastModDate, long fileSize) {
+ public static String formFileEntry(HttpServletRequest request, String fileName, String lastModDate, long fileSize) {
StringBuffer sb = new StringBuffer();
- formFileEntry(sb, fileName, lastModDate, fileSize);
+ formFileEntry(request, sb, fileName, lastModDate, fileSize);
return sb.toString();
}
- public static void formFileEntry(StringBuffer sb, String fileName, String lastMod, long fileSize) {
+ public static void formFileEntry(HttpServletRequest request, StringBuffer sb, String fileName, String lastMod,
+ long fileSize) {
sb.append("<tr><td valign=\"top\"><img src=\"" + getIconPath("/icons/unknown.gif")
+ "\" alt=\"[DIR]\" width=\"20\" height=\"22\"></td>\n");
- sb.append("<td><a href=\"" + fileName + "\">" + fileName + "</a></td>\n");
+ sb.append("<td><a href=\"" + getLink(request, fileName) + "\">" + fileName + "</a></td>\n");
sb.append("<td align=\"right\">" + lastMod + "</td><td align=\"right\"> - </td><td> </td></tr>\n");
}
protected static String getIconPath(String path) {
+ if (!ContentHTTPServlet.CONTENT_URI.endsWith("/")) {
+ if (!path.startsWith("/")) {
+ path = "/" + path;
+ }
+ }
return ContentHTTPServlet.CONTENT_URI + path;
}
+
+ protected static String getLink(HttpServletRequest request, String path) {
+ String reqUri = request.getRequestURI();
+ if (!reqUri.endsWith("/")) {
+ reqUri = reqUri + "/"; // we need to ensure this ends with a "/"
+ }
+ if (path.startsWith("/")) {
+ path = path.substring(1); // this is just to make the link look nice, it's not "needed"
+ }
+ return reqUri + path;
+ }
}
commit 5649627a5d942e7185d5f0ff7c31112cf9d8fa65
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Thu Jan 14 14:15:31 2010 -0800
Fixing unit test and adding hacked ejb exception class to help testing
Added src/test/java/javax/ejb/EJBTransactionRolledbackException.java to
assist finding source of exceptions in our SLSB classes.
diff --git a/.classpath b/.classpath
index 527d92e..020776a 100644
--- a/.classpath
+++ b/.classpath
@@ -20,7 +20,7 @@
<classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.SP1/jboss-profileservice-spi-5.1.0.SP1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.1.1.GA/jboss-managed-2.1.1.GA.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.1.1.GA/jboss-metatype-2.1.1.GA.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.jar" sourcepath="/M2_REPO/commons-io/commons-io/1.3.1/commons-io-1.3.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/com/sun/xml/bind/jaxb-impl/2.1.6/jaxb-impl-2.1.6.jar"/>
<classpathentry kind="src" path="modules/core/util/src/main/java"/>
<classpathentry kind="src" path="modules/core/util/src/test/java"/>
diff --git a/modules/enterprise/server/jar/src/test/java/javax/ejb/EJBTransactionRolledbackException.java b/modules/enterprise/server/jar/src/test/java/javax/ejb/EJBTransactionRolledbackException.java
new file mode 100644
index 0000000..a50c4d2
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/javax/ejb/EJBTransactionRolledbackException.java
@@ -0,0 +1,58 @@
+/*
+ * 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 javax.ejb;
+
+/**
+ * This was placed into our source tree to get around the fact jboss-ejb3-all-1.0.0.Alpha9.jar
+ * expects this constructor:
+ *
+ * public EJBTransactionRolledbackException(Exception ex) {
+ * super(ex);
+ * }
+ *
+ * but jboss-ejb3x-4.2.3.GA.jar which shows up in the classpath first
+ * does not provide this implementation.
+ *
+ * Without this unit tests will often blow up with:
+ *
+ * javax.ejb.EJBTransactionRolledbackException: method <init>(Ljava/lang/Exception;)V not found
+ *
+ * and you are left scratching your head as to why it failed. This is only used in our unit
+ * test runs.
+ *
+ * @author mmccune
+ *
+ */
+public class EJBTransactionRolledbackException extends EJBException {
+
+ public EJBTransactionRolledbackException() {
+ }
+
+ public EJBTransactionRolledbackException(String message) {
+ super(message);
+ }
+
+ public EJBTransactionRolledbackException(String message, Exception ex) {
+ super(message, ex);
+ }
+
+ public EJBTransactionRolledbackException(Exception ex) {
+ super(ex);
+ }
+}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
index bf7657a..be68961 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
@@ -25,7 +25,6 @@ import java.util.Random;
import java.util.Set;
import javax.persistence.EntityManager;
-import javax.transaction.TransactionManager;
import org.apache.commons.lang.RandomStringUtils;
import org.testng.annotations.AfterMethod;
@@ -64,25 +63,23 @@ public class RepoManagerBeanTest extends AbstractEJB3Test {
@BeforeMethod
public void setupBeforeMethod() throws Exception {
- TransactionManager tx = getTransactionManager();
- tx.begin();
+ overlord = LookupUtil.getSubjectManager().getOverlord();
+ prepareScheduler();
repoManager = LookupUtil.getRepoManagerLocal();
contentSourceManager = LookupUtil.getContentSourceManager();
contentSourceMetadataManager = LookupUtil.getContentSourceMetadataManager();
TestContentServerPluginService pluginService = new TestContentServerPluginService(this);
- overlord = LookupUtil.getSubjectManager().getOverlord();
+ getTransactionManager().begin();
+
}
@AfterMethod
public void tearDownAfterMethod() throws Exception {
unprepareServerPluginService();
-
- TransactionManager tx = getTransactionManager();
- if (tx != null) {
- tx.rollback();
- }
+ unprepareScheduler();
+ getTransactionManager().rollback();
}
@Test(enabled = ENABLED)
commit 4d7c2ae1b9788610f12311c07c19432949bbb475
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 14 16:07:32 2010 -0500
1348 - Changes to allow dynamic configuration property values to be retrieved and displayed. Enterprise additions to support database backed values. Additions to disk plugin as an example.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
index 7c2af68..3615a6a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
@@ -71,7 +71,7 @@ import org.rhq.core.domain.resource.ResourceType;
+ "JOIN pt.resourceType rt "
+ "LEFT JOIN FETCH pt.deploymentConfigurationDefinition cd "
+ "LEFT JOIN FETCH cd.templates cts " + "WHERE rt.id = :typeId AND pt.isCreationData = true"),
- @NamedQuery(name = PackageType.QUERY_DYNAMIC_CONFIG_VALUES, query = "SELECT pt.name FROM PackageType AS pt")
+ @NamedQuery(name = PackageType.QUERY_DYNAMIC_CONFIG_VALUES, query = "SELECT pt.displayName FROM PackageType AS pt")
})
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_PACKAGE_TYPE_ID_SEQ")
@Table(name = "RHQ_PACKAGE_TYPE")
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractPropertyBagUIComponentTreeFactory.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractPropertyBagUIComponentTreeFactory.java
index a70907a..e17f23c 100644
--- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractPropertyBagUIComponentTreeFactory.java
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractPropertyBagUIComponentTreeFactory.java
@@ -44,6 +44,7 @@ import org.richfaces.component.html.HtmlModalPanel;
import org.rhq.core.domain.configuration.AbstractPropertyMap;
import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -284,11 +285,69 @@ public abstract class AbstractPropertyBagUIComponentTreeFactory {
addListProperty(parent, (PropertyDefinitionList) propertyDefinition, rowStyleClass);
} else if (propertyDefinition instanceof PropertyDefinitionMap) {
addMapProperty(parent, (PropertyDefinitionMap) propertyDefinition, rowStyleClass);
- } else {
+ } else if (propertyDefinition instanceof PropertyDefinitionDynamic) {
+ addDynamicProperty(parent, (PropertyDefinitionDynamic) propertyDefinition, rowStyleClass);
+ }
+ else {
throw new IllegalStateException("Unsupported subclass of " + PropertyDefinition.class.getName() + ".");
}
}
+ /**
+ * Adds a new property to the UI based on a dynamic property definition.
+ *
+ * @param parent owner in which the UI rendering of the property will live
+ * @param propertyDefinitionDynamic describes the property being rendered
+ * @param rowStyleClass indicates the CSS style (i.e. background color) of this row in the property list
+ */
+ private void addDynamicProperty(UIComponent parent, PropertyDefinitionDynamic propertyDefinitionDynamic,
+ String rowStyleClass) {
+ addDebug(parent, true, ".addDynamicProperty()");
+
+ FacesComponentUtility.addVerbatimText(parent, "\n\n<tr class='" + rowStyleClass + "'>");
+
+ PropertySimple propertySimple = this.propertyMap.getSimple(propertyDefinitionDynamic.getName());
+ ValueExpression propertyValueExpression = createPropertyValueExpression(propertySimple.getName(),
+ this.valueExpressionFormat);
+
+ UIInput input = null;
+ if (!this.isGroup || (propertySimple.getOverride() != null && propertySimple.getOverride())) {
+ // We need to create the input component ahead of when we need to add it to the component tree, since we
+ // need to know the input component's id in order to render the unset control.
+ input = PropertyRenderingUtility.createInputForDynamicProperty(propertyDefinitionDynamic, propertySimple,
+ propertyValueExpression, getListIndex(), this.isGroup, this.config.isReadOnly(), this.config
+ .isFullyEditable(), this.config.isPrevalidate());
+ }
+
+ FacesComponentUtility
+ .addVerbatimText(parent, "<td class='" + CssStyleClasses.PROPERTY_DISPLAY_NAME_CELL + "'>");
+ PropertyRenderingUtility.addPropertyDisplayName(parent, propertyDefinitionDynamic, propertySimple, this.config
+ .isReadOnly());
+ FacesComponentUtility.addVerbatimText(parent, "</td>");
+
+ FacesComponentUtility.addVerbatimText(parent, "<td class='" + CssStyleClasses.PROPERTY_ENABLED_CELL + "'>");
+ if (!propertyDefinitionDynamic.isRequired())
+ PropertyRenderingUtility.addUnsetControl(parent, propertyDefinitionDynamic.isRequired(),
+ propertyDefinitionDynamic.isReadOnly(), propertySimple, this.config.getListIndex(), input, this.isGroup,
+ this.config.isReadOnly(), this.config.isFullyEditable());
+ FacesComponentUtility.addVerbatimText(parent, "</td>");
+
+ FacesComponentUtility.addVerbatimText(parent, "<td class='" + CssStyleClasses.PROPERTY_VALUE_CELL + "'>");
+ addPropertySimpleValue(parent, input, propertyValueExpression);
+ FacesComponentUtility.addVerbatimText(parent, "<br/>");
+ if (input != null)
+ PropertyRenderingUtility.addMessageComponentForInput(parent, input);
+ FacesComponentUtility.addVerbatimText(parent, "</td>");
+
+ FacesComponentUtility.addVerbatimText(parent, "<td class='" + CssStyleClasses.PROPERTY_DESCRIPTION_CELL + "'>");
+ PropertyRenderingUtility.addPropertyDescription(parent, propertyDefinitionDynamic);
+ FacesComponentUtility.addVerbatimText(parent, "</td>");
+
+ FacesComponentUtility.addVerbatimText(parent, "</tr>");
+
+ addDebug(parent, false, ".addSimpleProperty()");
+ }
+
private void addSimpleProperty(UIComponent parent, PropertyDefinitionSimple propertyDefinitionSimple,
String rowStyleClass) {
addDebug(parent, true, ".addSimpleProperty()");
@@ -323,8 +382,9 @@ public abstract class AbstractPropertyBagUIComponentTreeFactory {
FacesComponentUtility.addVerbatimText(parent, "<td class='" + CssStyleClasses.PROPERTY_ENABLED_CELL + "'>");
if (!propertyDefinitionSimple.isRequired())
- PropertyRenderingUtility.addUnsetControl(parent, propertyDefinitionSimple, propertySimple, this.config
- .getListIndex(), input, this.isGroup, this.config.isReadOnly(), this.config.isFullyEditable());
+ PropertyRenderingUtility.addUnsetControl(parent, propertyDefinitionSimple.isRequired(),
+ propertyDefinitionSimple.isReadOnly(), propertySimple, this.config.getListIndex(), input, this.isGroup,
+ this.config.isReadOnly(), this.config.isFullyEditable());
FacesComponentUtility.addVerbatimText(parent, "</td>");
FacesComponentUtility.addVerbatimText(parent, "<td class='" + CssStyleClasses.PROPERTY_VALUE_CELL + "'>");
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java
new file mode 100644
index 0000000..1010cc7
--- /dev/null
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java
@@ -0,0 +1,52 @@
+/*
+* 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.core.gui.configuration.helper;
+
+import java.util.List;
+
+import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
+
+/**
+ * Plugins to the dynamic property rendering sections of {@link PropertyRenderingUtility} that perform
+ * the actual retrieval of the values.
+ * <p/>
+ * <strong>In order to associate implementations of this interface with the rendering code, calls must be made to
+ * {@link PropertyRenderingUtility#putDynamicPropertyRetriever(org.rhq.core.domain.configuration.PropertyDynamicType,
+ * DynamicPropertyRetriever)} to map the property type to the instance.</strong>
+ * <p/>
+ * This functionality is abstracted out to prevent the core-gui module from having to make non-core
+ * dependencies. Modules using core-gui can implement this interface using whatever means available,
+ * such as accessing a database or making a network hop, without having to modify the core-gui dependencies.
+ *
+ * @author Jason Dobies
+ */
+public interface DynamicPropertyRetriever {
+
+ /**
+ * Returns a list of values to display to the user when prompting for the property given.
+ *
+ * @param propertyDefinition cannot be <code>null</code>
+ * @return list of values to use as both the name and value of the UI inputs; empty list if none are found
+ */
+ List<String> loadValues(PropertyDefinitionDynamic propertyDefinition);
+}
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
index ac91723..03d01c3 100644
--- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
@@ -19,7 +19,9 @@
package org.rhq.core.gui.configuration.helper;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.UUID;
import javax.el.ValueExpression;
@@ -43,6 +45,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
+import org.rhq.core.domain.configuration.PropertyDynamicType;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionEnumeration;
@@ -56,7 +60,7 @@ import org.rhq.core.gui.util.PropertyIdGeneratorUtility;
import org.rhq.core.gui.validator.PropertySimpleValueValidator;
/**
- * A class that provides methods for rendering RHQ {@link Property}s.
+ * A class that provides methods for rendering RHQ {@link Property}s.
*
* @author Ian Springer
*/
@@ -72,6 +76,14 @@ public class PropertyRenderingUtility {
private static final String UNIQUE_ID_PREFIX = "rhq_id";
+ /**
+ * Holds a mapping from dynamic property backing type (i.e. database, server-side-plugin) to the
+ * {@link DynamicPropertyRetriever} instance that should be called to retrieve the values. Code using
+ * this class as a core UI dependency
+ */
+ private static final Map<PropertyDynamicType, DynamicPropertyRetriever> DYNAMIC_PROPERTY_RETRIEVERS =
+ new HashMap<PropertyDynamicType, DynamicPropertyRetriever>();
+
@NotNull
public static UIInput createInputForSimpleProperty(PropertyDefinitionSimple propertyDefinitionSimple,
PropertySimple propertySimple, ValueExpression propertyValueExpression, Integer listIndex,
@@ -81,8 +93,9 @@ public class PropertyRenderingUtility {
if (propertySimple != null)
addTitleAttribute(input, propertySimple.getStringValue());
- boolean isUnset = isUnset(propertyDefinitionSimple, propertySimple, isGroupConfig);
- boolean isReadOnly = isReadOnly(propertyDefinitionSimple, propertySimple, configReadOnly, configFullyEditable);
+ boolean isUnset = isUnset(propertyDefinitionSimple.isRequired(), propertySimple, isGroupConfig);
+ boolean isReadOnly = isReadOnly(propertyDefinitionSimple.isReadOnly(), propertyDefinitionSimple.isRequired(),
+ propertySimple, configReadOnly, configFullyEditable);
String propertyId = PropertyIdGeneratorUtility.getIdentifier(propertySimple, listIndex);
input.setId(propertyId);
@@ -98,6 +111,61 @@ public class PropertyRenderingUtility {
return input;
}
+ public static UIInput createInputForDynamicProperty(PropertyDefinitionDynamic propertyDefinitionDynamic,
+ PropertySimple property, ValueExpression valueExpression, Integer listIndex, boolean isGroupConfig,
+ boolean configReadOnly, boolean configFullyEditable, boolean prevalidate) {
+
+ // Simply use a drop down in all cases
+ UISelectOne input = FacesComponentUtility.createComponent(HtmlSelectOneMenu.class, null);
+
+ // Determine where to retrieve the values from
+ PropertyDynamicType propertyType = propertyDefinitionDynamic.getDynamicType();
+ DynamicPropertyRetriever retriever = DYNAMIC_PROPERTY_RETRIEVERS.get(propertyType);
+
+ if (retriever == null) {
+ throw new IllegalStateException("Attempt to render a dynamic property but no retrievers are " +
+ "configured for the type. Dynamic property type: " + propertyType + ", Definition: " +
+ propertyDefinitionDynamic);
+ }
+
+ // Retrieve the values and load them into UI options
+ List<String> values = retriever.loadValues(propertyDefinitionDynamic);
+ for (String option : values) {
+ UISelectItem selectItem = FacesComponentUtility.createComponent(UISelectItem.class, null);
+ selectItem.setItemLabel(option);
+ selectItem.setItemValue(option);
+ input.getChildren().add(selectItem);
+ }
+
+ boolean isUnset = isUnset(propertyDefinitionDynamic.isRequired(), property, isGroupConfig);
+ boolean isReadOnly = isReadOnly(propertyDefinitionDynamic.isReadOnly(), propertyDefinitionDynamic.isRequired(),
+ property, configReadOnly, configFullyEditable);
+
+ String propertyId = PropertyIdGeneratorUtility.getIdentifier(property, listIndex);
+ input.setId(propertyId);
+
+ // Revert to the previously selected value
+ input.setValueExpression("value", valueExpression);
+
+ FacesComponentUtility.setUnset(input, isUnset);
+ FacesComponentUtility.setReadonly(input, isReadOnly);
+
+ // If there is a PC-detected error associated with the property, associate it with the input.
+ addPluginContainerDetectedErrorMessage(input, property);
+
+ return input;
+ }
+
+ /**
+ * Sets the object used to retrieve property values for dynamic properties of the given type.
+ *
+ * @param type each type in the enum will only have one retriever associated with it at any given time
+ * @param retriever may not be <code>null</code>
+ */
+ public static void putDynamicPropertyRetriever(PropertyDynamicType type, DynamicPropertyRetriever retriever) {
+ DYNAMIC_PROPERTY_RETRIEVERS.put(type, retriever);
+ }
+
public static UIInput createInput(PropertyDefinitionSimple propertyDefinitionSimple) {
UIInput input;
PropertySimpleType type = (propertyDefinitionSimple != null) ? propertyDefinitionSimple.getType()
@@ -156,7 +224,7 @@ public class PropertyRenderingUtility {
}
public static HtmlSelectBooleanCheckbox addUnsetControl(UIComponent parent,
- PropertyDefinitionSimple propertyDefinitionSimple, PropertySimple propertySimple, Integer listIndex,
+ boolean isRequired, boolean isReadOnly, PropertySimple propertySimple, Integer listIndex,
UIInput valueInput, boolean isGroupConfig, boolean configReadOnly, boolean configFullyEditable) {
HtmlSelectBooleanCheckbox unsetCheckbox = FacesComponentUtility.createComponent(
@@ -166,8 +234,8 @@ public class PropertyRenderingUtility {
unsetCheckbox.setId(unsetCheckboxId);
}
parent.getChildren().add(unsetCheckbox);
- unsetCheckbox.setValue(isUnset(propertyDefinitionSimple, propertySimple, isGroupConfig));
- if (isReadOnly(propertyDefinitionSimple, propertySimple, configReadOnly, configFullyEditable)
+ unsetCheckbox.setValue(isUnset(isRequired, propertySimple, isGroupConfig));
+ if (isReadOnly(isReadOnly, isRequired, propertySimple, configReadOnly, configFullyEditable)
|| isGroupConfigWithDifferingValues(propertySimple, isGroupConfig)) {
FacesComponentUtility.setDisabled(unsetCheckbox, true);
} else {
@@ -456,33 +524,34 @@ public class PropertyRenderingUtility {
}
}
- private static boolean isUnset(PropertyDefinitionSimple propertyDefinitionSimple, PropertySimple propertySimple,
+ private static boolean isUnset(boolean isRequired, PropertySimple propertySimple,
boolean isGroupConfig) {
if (isGroupConfigWithDifferingValues(propertySimple, isGroupConfig))
// Properties from group configs that have differing values should not be marked unset.
return false;
if (propertySimple == null)
return false;
- return ((propertyDefinitionSimple == null || !propertyDefinitionSimple.isRequired()) && propertySimple
- .getStringValue() == null);
+
+ return (!isRequired && propertySimple.getStringValue() == null);
}
- public static boolean isReadOnly(PropertyDefinitionSimple propertyDefinitionSimple, PropertySimple propertySimple,
+ public static boolean isReadOnly(boolean isReadOnly, boolean isRequired, PropertySimple propertySimple,
boolean configReadOnly, boolean configFullyEditable) {
// A fully editable config overrides any other means of setting read-only.
- return (!configFullyEditable && (configReadOnly || ((propertyDefinitionSimple != null && propertyDefinitionSimple
- .isReadOnly()) && (propertySimple == null || !isInvalidRequiredProperty(propertyDefinitionSimple,
- propertySimple)))));
+ return (!configFullyEditable && //
+ (configReadOnly || //
+ isReadOnly && //
+ (propertySimple == null || //
+ !isInvalidRequiredProperty(isRequired, propertySimple))));
}
public static boolean isGroupConfigWithDifferingValues(PropertySimple propertySimple, boolean isGroupConfig) {
return isGroupConfig && (propertySimple.getOverride() == null || !propertySimple.getOverride());
}
- private static boolean isInvalidRequiredProperty(PropertyDefinitionSimple propertyDefinitionSimple,
- PropertySimple propertySimple) {
+ private static boolean isInvalidRequiredProperty(boolean isRequired, PropertySimple propertySimple) {
boolean isInvalidRequiredProperty = false;
- if (propertyDefinitionSimple.isRequired()) {
+ if (isRequired) {
String errorMessage = propertySimple.getErrorMessage();
if ((null == propertySimple.getStringValue()) || "".equals(propertySimple.getStringValue())
|| ((null != errorMessage) && (!"".equals(errorMessage.trim())))) {
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/PropertySetRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/PropertySetRenderer.java
index 04891a3..de1620e 100644
--- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/PropertySetRenderer.java
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/PropertySetRenderer.java
@@ -94,7 +94,7 @@ public class PropertySetRenderer extends Renderer {
// If it's an AJAX request for this component, apply the group config to the member configs
// and clear our child components. NOTE: This can *not* be done in decode(), because the model
- // will not have been updated yet with any changes made to child UIInput values.
+ // will not have been updated yet with any changes made to child UIInput values.
String refresh = FacesContextUtility.getOptionalRequestParameter("refresh");
if (refresh != null && refresh.equals(ConfigRenderer.PROPERTY_SET_COMPONENT_ID)) {
propertySetComponent.getConfigurationSet().applyGroupConfiguration();
@@ -122,8 +122,8 @@ public class PropertySetRenderer extends Renderer {
addPropertyDisplayNameAndDescription(propertySetComponent, propertyDefinitionSimple, propertySimple);
boolean configReadOnly = propertySetComponent.getReadOnly() != null && propertySetComponent.getReadOnly();
- boolean propIsReadOnly = PropertyRenderingUtility.isReadOnly(propertyDefinitionSimple, null, configReadOnly,
- false);
+ boolean propIsReadOnly = PropertyRenderingUtility.isReadOnly(propertyDefinitionSimple.isReadOnly(),
+ propertyDefinitionSimple.isRequired(), null, configReadOnly,false);
HtmlPanelGroup setAllToSameValueControlPanel = null;
if (!propIsReadOnly) {
// NOTE: We'll add children to the below panel a bit later when we know the id's of the inputs.
@@ -184,8 +184,9 @@ public class PropertySetRenderer extends Renderer {
HtmlSelectBooleanCheckbox unsetCheckbox = null;
if (isOptional(propertyDefinitionSimple)) {
FacesComponentUtility.addOutputText(panelGrid, null, "Unset All: ", null);
- unsetCheckbox = PropertyRenderingUtility.addUnsetControl(panelGrid, propertyDefinitionSimple, null,
- propertySetComponent.getListIndex(), input, false, propertySetComponent.getReadOnly(), false);
+ unsetCheckbox = PropertyRenderingUtility.addUnsetControl(panelGrid, propertyDefinitionSimple.isRequired(),
+ propertyDefinitionSimple.isReadOnly(), null, propertySetComponent.getListIndex(), input, false,
+ propertySetComponent.getReadOnly(), false);
}
// the 'APPLY' button
@@ -382,8 +383,8 @@ public class PropertySetRenderer extends Renderer {
FacesComponentUtility.addVerbatimText(propertySetComponent, "<td class='"
+ CssStyleClasses.MEMBER_PROPERTY_UNSET_CELL + "'>");
HtmlSelectBooleanCheckbox unsetCheckbox = PropertyRenderingUtility.addUnsetControl(propertySetComponent,
- propertyDefinitionSimple, propertyInfo.getProperty(), propertySetComponent.getListIndex(), input,
- false, propertySetComponent.getReadOnly(), false);
+ propertyDefinitionSimple.isRequired(), propertyDefinitionSimple.isReadOnly(), propertyInfo.getProperty(),
+ propertySetComponent.getListIndex(), input, false, propertySetComponent.getReadOnly(), false);
propertyInfo.setUnsetCheckbox(unsetCheckbox);
FacesComponentUtility.addVerbatimText(propertySetComponent, "</td>");
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java
new file mode 100644
index 0000000..3dc4e3e
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java
@@ -0,0 +1,46 @@
+/*
+* 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.gui.configuration;
+
+import java.util.List;
+
+import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
+import org.rhq.core.gui.configuration.helper.DynamicPropertyRetriever;
+import org.rhq.enterprise.server.configuration.DynamicConfigurationPropertyLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * Handles retrieving the values of a database backed dynamic configuration property.
+ *
+ * @author Jason Dobies
+ */
+public class DatabaseDynamicPropertyRetriever implements DynamicPropertyRetriever {
+
+ public List<String> loadValues(PropertyDefinitionDynamic propertyDefinition) {
+ String key = propertyDefinition.getKey();
+ DynamicConfigurationPropertyLocal bean = LookupUtil.getDynamicConfigurationProperty();
+ List<String> values = bean.lookupValues(key);
+
+ return values;
+ }
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
index 2697759..9d84205 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
@@ -39,11 +39,14 @@ import org.jboss.mx.util.MBeanServerLocator;
import org.rhq.core.db.DatabaseTypeFactory;
import org.rhq.core.domain.cloud.Server;
import org.rhq.core.domain.cloud.Server.OperationMode;
+import org.rhq.core.domain.configuration.PropertyDynamicType;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.util.serial.ExternalizableStrategy;
+import org.rhq.core.gui.configuration.helper.PropertyRenderingUtility;
import org.rhq.core.util.ObjectNameFactory;
import org.rhq.enterprise.communications.ServiceContainerConfigurationConstants;
import org.rhq.enterprise.communications.util.SecurityUtil;
+import org.rhq.enterprise.gui.configuration.DatabaseDynamicPropertyRetriever;
import org.rhq.enterprise.server.alert.engine.internal.AlertConditionCacheCoordinator;
import org.rhq.enterprise.server.auth.SessionManager;
import org.rhq.enterprise.server.auth.prefs.SubjectPreferencesCache;
@@ -87,7 +90,7 @@ public class StartupServlet extends HttpServlet {
// As a security measure, make sure the installer has been undeployed
LookupUtil.getSystemManager().undeployInstaller();
- // get singletons right now so we load the classes immediately into our classloader
+ // get singletons right now so we load the classes immediately into our classloader
AlertConditionCacheCoordinator.getInstance();
SessionManager.getInstance();
SubjectPreferencesCache.getInstance();
@@ -126,11 +129,15 @@ public class StartupServlet extends HttpServlet {
startEmbeddedAgent();
registerShutdownListener();
+ // Configures the configuration rendering to be able to support database backed dynamic configuration properties
+ PropertyRenderingUtility.putDynamicPropertyRetriever(PropertyDynamicType.DATABASE,
+ new DatabaseDynamicPropertyRetriever());
+
return;
}
private void initializeServer() {
- // Ensure the class is loaded and the dbType is set for our current db
+ // Ensure the class is loaded and the dbType is set for our current db
try {
DataSource ds = LookupUtil.getDataSource();
Connection conn = ds.getConnection();
@@ -161,7 +168,7 @@ public class StartupServlet extends HttpServlet {
* For developer builds that don't use the HA installer to write a localhost entry into the {@link Server}
* table, we will create a default one here. Then, if the "rhq.high-availability.name" property is missing, the
* {@link ServerManagerLocal} will return this localhost entry.
- *
+ *
* If the installer was already run, then this method should be a no-op because a row would already exist
* in the {@link Server} table
*/
@@ -204,7 +211,7 @@ public class StartupServlet extends HttpServlet {
/**
* Starts the plugin deployer which will effectively ask the plugin deployer to persist information about all
- * detected agent and server plugins.
+ * detected agent and server plugins.
*
* Because this will scan and register the initial plugins right now, make sure this is called prior
* to starting the master plugin container; otherwise, the master PC will not have any plugins to start.
diff --git a/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
index 560bc9e..b7f98cb 100644
--- a/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -18,6 +18,18 @@
<c:group name="General">
<c:simple-property name="rootDirectory" type="directory" required="true"
description="The root directory that contains all content that is to be served by this content provider. In an HA environment, this must be on a distributed file system that all servers can access."/>
+
+ <c:dynamic-property name="users" description="TEST - List of all users in the system.">
+ <c:database-backing key="users"/>
+ </c:dynamic-property>
+
+<!-- <c:dynamic-property name="roles" description="TEST - List of all roles in the system.">
+ <c:database-backing key="roles"/>
+ </c:dynamic-property>
+
+ <c:dynamic-property name="packageTypes" description="TEST - List of all package types in the system.">
+ <c:database-backing key="package-types"/>
+ </c:dynamic-property>-->
</c:group>
<c:group name="Package Source">
commit a86cb92866d71049f5440181267489d14c37f678
Author: John Matthews <jmatthew(a)redhat.com>
Date: Thu Jan 14 13:34:01 2010 -0500
1357 - added browsing for packages through http
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
index 549850f..d301413 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -19,6 +19,8 @@
package org.rhq.gui.content;
import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Date;
import java.util.List;
import javax.servlet.ServletException;
@@ -46,6 +48,8 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class ContentHTTPServlet extends DefaultServlet {
private final Log log = LogFactory.getLog(ContentHTTPServlet.class);
+ protected static final String CONTENT_URI = "/content";
+
protected static final String PACKAGES = "packages";
protected static final String DISTRIBUTIONS = "distributions";
@@ -65,9 +69,17 @@ public class ContentHTTPServlet extends DefaultServlet {
log.info("ContentHTTPServlet resolved references in init.");
}
+ protected boolean isIconRequest(HttpServletRequest request) {
+ String dir = getNthPiece(2, request.getRequestURI());
+ return StringUtils.equalsIgnoreCase(dir, "icons");
+ }
+
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
log.info("doGet(): requestURI = " + request.getRequestURI());
-
+ if (isIconRequest(request)) {
+ super.doGet(request, response);
+ return;
+ }
// Check if repo has been specified
Repo repo = getRepo(request, response);
if (repo == null) {
@@ -121,12 +133,30 @@ public class ContentHTTPServlet extends DefaultServlet {
log.info("Potential repo: Name = " + r.getName() + ", ID = " + r.getId());
}
log.info("TODO: generate index.html");
-
- // dont include candidate repos
+ StringBuffer sb = new StringBuffer();
+ HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
+ for (Repo r : repos) {
+ log.info("Potential repo: Name = " + r.getName() + ", ID = " + r.getId());
+ // Skip candidate repos
+ if (!r.isCandidate()) {
+ String lastMod = new Date(r.getLastModifiedDate()).toString();
+ HtmlRenderer.formDirEntry(request, sb, r.getName(), lastMod);
+ }
+ }
+ HtmlRenderer.formEnd(sb);
+ writeResponse(sb.toString(), response);
}
- protected void renderChoiceOfContent(HttpServletRequest request, HttpServletResponse response, Repo repo) {
+ protected void renderChoiceOfContent(HttpServletRequest request, HttpServletResponse response, Repo repo)
+ throws IOException {
log.info("Choice of content is: {" + PACKAGES + ", " + DISTRIBUTIONS + "}");
+ StringBuffer sb = new StringBuffer();
+ HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
+ HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
+ HtmlRenderer.formDirEntry(request, sb, PACKAGES, "-");
+ HtmlRenderer.formDirEntry(request, sb, DISTRIBUTIONS, "-");
+ HtmlRenderer.formEnd(sb);
+ writeResponse(sb.toString(), response);
}
protected void renderPackages(HttpServletRequest request, HttpServletResponse response, Repo repo)
@@ -143,33 +173,44 @@ public class ContentHTTPServlet extends DefaultServlet {
renderPackageIndex(request, response, repo);
return;
} else {
- log.info("TODO: fetch package bits and return them.");
+ log.info("fetch package bits and return them.");
PackageVersion pv = getPackageVersionFromFileName(repo, fileName);
if (pv == null) {
log.info("Unable to find PackageVersion from filename: " + fileName);
renderErrorPage(request, response);
return;
}
- response.setContentType("application/x-rpm");
+ response.setContentType("application/octet-stream");
writePackageVersionBits(pv, response.getOutputStream());
}
}
- protected void renderPackageIndex(HttpServletRequest request, HttpServletResponse response, Repo repo) {
- // placeholder for packages index.html
+ protected void renderPackageIndex(HttpServletRequest request, HttpServletResponse response, Repo repo)
+ throws IOException {
log.info("Forming packages index.html for repo: " + repo.getName() + ", ID = " + repo.getId());
List<PackageVersion> pvs = repoMgr.findPackageVersionsInRepo(LookupUtil.getSubjectManager().getOverlord(), repo
.getId(), PageControl.getUnlimitedInstance());
+ StringBuffer sb = new StringBuffer();
+ HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
+ HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
for (PackageVersion pv : pvs) {
- log.info("Add PackageVersion: " + pv);
+ HtmlRenderer.formFileEntry(sb, pv.getFileName(), new Date(pv.getFileCreatedDate()).toString(), pv
+ .getFileSize());
}
-
+ HtmlRenderer.formEnd(sb);
+ writeResponse(sb.toString(), response);
}
- protected void renderDistributions(HttpServletRequest request, HttpServletResponse response, Repo repo) {
+ protected void renderDistributions(HttpServletRequest request, HttpServletResponse response, Repo repo)
+ throws IOException {
+ StringBuffer sb = new StringBuffer();
+ HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
+ HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
+ HtmlRenderer.formEnd(sb);
+ writeResponse(sb.toString(), response);
}
protected void renderErrorPage(HttpServletRequest request, HttpServletResponse response) throws IOException {
@@ -177,6 +218,16 @@ public class ContentHTTPServlet extends DefaultServlet {
response.sendError(response.SC_NOT_FOUND);
}
+ protected boolean writeResponse(String data, HttpServletResponse response) throws IOException {
+
+ response.setContentType("text/html");
+ PrintWriter out = response.getWriter();
+ out.write(data);
+ out.flush();
+ out.close();
+ return true;
+ }
+
protected Repo getRepo(HttpServletRequest request, HttpServletResponse response) {
String repoName = getRepoName(request.getRequestURI());
@@ -233,13 +284,23 @@ public class ContentHTTPServlet extends DefaultServlet {
*
*/
protected String getNthPiece(int n, String requestURI) {
- int index = n - 1;
StrTokenizer st = new StrTokenizer(requestURI, "/");
List<String> tokens = st.getTokenList();
- if (tokens.size() < index) {
+ if (tokens.size() < n) {
return "";
}
- return tokens.get(index);
+ return tokens.get(n - 1); // caller is starting at 1 not 0
+ }
+
+ protected String getParentURI(String uri) {
+ if (uri.endsWith("/")) {
+ uri = uri.substring(0, uri.length() - 1);
+ }
+ int index = uri.lastIndexOf("/");
+ if (index == -1) {
+ return uri;
+ }
+ return uri.substring(0, index);
}
protected PackageVersion getPackageVersionFromFileName(Repo repo, String fileName) {
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java
new file mode 100644
index 0000000..f1f0826
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java
@@ -0,0 +1,99 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.gui.content;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class HtmlRenderer {
+
+ public static String formStart(String title, String currentURI) {
+ StringBuffer sb = new StringBuffer();
+ formStart(sb, title, currentURI);
+ return sb.toString();
+ }
+
+ public static void formStart(StringBuffer sb, String title, String currentURI) {
+ sb.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n");
+ sb.append("<html>\n");
+ sb.append("<head>\n");
+ sb.append("<title>Index of " + currentURI + "</title>\n");
+ sb.append("</head>\n");
+ sb.append("<body>\n");
+ sb.append("<h1>Index of " + currentURI + "</h1>\n");
+ sb.append("<table><tr><th><img src=\"" + getIconPath("/icons/blank.gif")
+ + "\" alt=\"[ICO]\" width=\"20\" height=\"22\"></th>");
+ sb.append("<th>Name</th><th>Last modified</th><th>Size</th></tr>\n");
+ sb.append("<tr><th colspan=\"4\"><hr></th></tr>\n");
+ }
+
+ public static String formParentLink(String parentURI) {
+ StringBuffer sb = new StringBuffer();
+ formParentLink(sb, parentURI);
+ return sb.toString();
+ }
+
+ public static void formParentLink(StringBuffer sb, String parentURI) {
+ sb.append("<tr><td valign=\"top\"><img src=\"" + getIconPath("/icons/back.gif")
+ + "\" alt=\"[DIR]\" width=\"20\" height=\"22\"></td><td><a href=\"" + parentURI
+ + "\">Parent Directory</a></td><td> </td><td align=\"right\"> - </td><td> </td></tr>");
+ }
+
+ public static String formEnd() {
+ StringBuffer sb = new StringBuffer();
+ formEnd(sb);
+ return sb.toString();
+ }
+
+ public static void formEnd(StringBuffer sb) {
+ sb.append("<tr><th colspan=\"4\"><hr></th></tr>\n" + "</table>\n" + "</body></html>\n");
+ }
+
+ public static String formDirEntry(HttpServletRequest request, String dirName, String lastMod) {
+ StringBuffer sb = new StringBuffer();
+ formDirEntry(request, sb, dirName, lastMod);
+ return sb.toString();
+ }
+
+ public static void formDirEntry(HttpServletRequest request, StringBuffer sb, String dirName, String lastMod) {
+ if (!dirName.endsWith("/")) {
+ dirName = dirName + "/";
+ }
+ sb.append("<tr><td valign=\"top\"><img src=\"" + getIconPath("/icons/folder.gif")
+ + "\" alt=\"[DIR]\" width=\"20\" height=\"22\"></td>\n");
+ sb.append("<td><a href=\"" + request.getRequestURI() + "/" + dirName + "\">" + dirName + "</a></td>\n");
+ sb.append("<td align=\"right\">" + lastMod + "</td><td align=\"right\"> - </td><td> </td></tr>\n");
+ }
+
+ public static String formFileEntry(String fileName, String lastModDate, long fileSize) {
+ StringBuffer sb = new StringBuffer();
+ formFileEntry(sb, fileName, lastModDate, fileSize);
+ return sb.toString();
+ }
+
+ public static void formFileEntry(StringBuffer sb, String fileName, String lastMod, long fileSize) {
+ sb.append("<tr><td valign=\"top\"><img src=\"" + getIconPath("/icons/unknown.gif")
+ + "\" alt=\"[DIR]\" width=\"20\" height=\"22\"></td>\n");
+ sb.append("<td><a href=\"" + fileName + "\">" + fileName + "</a></td>\n");
+ sb.append("<td align=\"right\">" + lastMod + "</td><td align=\"right\"> - </td><td> </td></tr>\n");
+ }
+
+ protected static String getIconPath(String path) {
+ return ContentHTTPServlet.CONTENT_URI + path;
+ }
+}
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/icons/back.gif b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/back.gif
new file mode 100644
index 0000000..a694ae1
Binary files /dev/null and b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/back.gif differ
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/icons/blank.gif b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/blank.gif
new file mode 100644
index 0000000..0ccf01e
Binary files /dev/null and b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/blank.gif differ
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/icons/bomb.gif b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/bomb.gif
new file mode 100644
index 0000000..270fdb1
Binary files /dev/null and b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/bomb.gif differ
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/icons/folder.gif b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/folder.gif
new file mode 100644
index 0000000..4826460
Binary files /dev/null and b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/folder.gif differ
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/icons/text.gif b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/text.gif
new file mode 100644
index 0000000..4c62390
Binary files /dev/null and b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/text.gif differ
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/icons/unknown.gif b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/unknown.gif
new file mode 100644
index 0000000..32b1ea2
Binary files /dev/null and b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/unknown.gif differ
commit 76bfba92397380f968b8bdc40dc2d51d5f369f0e
Author: Jeff Ortel <jortel(a)redhat.com>
Date: Thu Jan 14 09:18:18 2010 -0600
Add API for retrieving subscribed repos by id. Returns truncated Repo.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/SubscribedRepo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/SubscribedRepo.java
new file mode 100644
index 0000000..0f0e191
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/SubscribedRepo.java
@@ -0,0 +1,47 @@
+package org.rhq.core.domain.content.transfer;
+
+import java.io.Serializable;
+
+public class SubscribedRepo implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private int id;
+ private String name;
+
+ public SubscribedRepo() {
+ }
+
+ public SubscribedRepo(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ /**
+ * @return the repo id
+ */
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id the repo id to set
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the repo name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param repoName the repo name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+}
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 c79d561..1f0f62b 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
@@ -60,6 +60,7 @@ import org.rhq.core.domain.content.RepoRepoRelationship;
import org.rhq.core.domain.content.RepoSyncResults;
import org.rhq.core.domain.content.ResourceRepo;
import org.rhq.core.domain.content.composite.RepoComposite;
+import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.resource.Resource;
@@ -228,6 +229,17 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
return new PageList<RepoComposite>(results, (int) count, pc);
}
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public PageList<SubscribedRepo> findSubscriptions(Subject subject, int resourceId, PageControl pc) {
+ PageList<SubscribedRepo> list = new PageList<SubscribedRepo>();
+ for (RepoComposite repoComposite : findResourceSubscriptions(subject, resourceId, pc)) {
+ Repo repo = repoComposite.getRepo();
+ SubscribedRepo summary = new SubscribedRepo(repo.getId(), repo.getName());
+ list.add(summary);
+ }
+ return list;
+ }
+
@SuppressWarnings("unchecked")
@RequiredPermission(Permission.MANAGE_INVENTORY)
public PageList<RepoComposite> findAvailableResourceSubscriptions(Subject subject, int resourceId, PageControl pc) {
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 b77abb5..d6d061d 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
@@ -32,6 +32,7 @@ import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
import org.rhq.core.domain.content.RepoSyncResults;
import org.rhq.core.domain.content.composite.RepoComposite;
+import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.resource.Resource;
@@ -63,6 +64,15 @@ public interface RepoManagerLocal {
PageList<RepoComposite> findResourceSubscriptions(Subject subject, int resourceId, PageControl pc);
/**
+ * Gets all repos that are subscribed to by the given resource.
+ * @param subject
+ * @param resourceId
+ * @param pc
+ * @return
+ */
+ PageList<SubscribedRepo> findSubscriptions(Subject subject, int resourceId, PageControl pc);
+
+ /**
* Gets all repos that aren't subscribed to for the given resource.
*
* @param subject
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 04789b7..3ff4f3a 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
@@ -31,6 +31,7 @@ import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
+import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.resource.Resource;
@@ -283,4 +284,9 @@ public interface RepoManagerRemote {
int synchronizeRepos(@WebParam(name = "subject") Subject subject, @WebParam(name = "repoIds") Integer[] repoIds)
throws Exception;
+ @WebMethod
+ PageList<SubscribedRepo> findSubscriptions( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "resourceId") int resourceId, //
+ @WebParam(name = "resource") PageControl pc);
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index c531297..19e07ac 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -55,6 +55,7 @@ import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
+import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.AlertCriteria;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
import org.rhq.core.domain.criteria.Criteria;
@@ -927,4 +928,8 @@ public class WebservicesManagerBean implements WebservicesRemote {
return repoManager.findAssociatedAdvisory(subject, repoId, pc);
}
+ public PageList<SubscribedRepo> findSubscriptions(Subject subject, int resourceId,
+ PageControl pc) {
+ return repoManager.findSubscriptions(subject, resourceId, pc);
+ }
}
commit 25aeb6d063e910ddeabc62d47cc35c59202f99b3
Author: Todd B Sanders <tsanders(a)dhcp231-67.rdu.redhat.com>
Date: Thu Jan 14 08:45:05 2010 -0500
Removed incorrect @Override annotations. These annotations will cause compiler errors with the OpenJDK (v1.6.0 in F12).
diff --git a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
index c65a1b0..47a473d 100644
--- a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
+++ b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
@@ -244,9 +244,8 @@ public class JBossSoftwareContentSourceAdapter implements ContentProvider, Packa
}
}
- @Override
public SyncProgressWeight getSyncProgressWeight() {
return SyncProgressWeight.DEFAULT_WEIGHTS;
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
index 9a6e9c0..56c21d4 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
@@ -357,7 +357,6 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
return helper.constructKickstartFileUrl(repoName, label, relativeFilename);
}
- @Override
public SyncProgressWeight getSyncProgressWeight() {
return new SyncProgressWeight(10, 1, 0, 0, 1);
}
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java
index f3c75e2..004608a 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java
@@ -32,12 +32,10 @@ public class ApacheXmlRpcExecutor implements XmlRpcExecutor {
this.client = clientIn;
}
- @Override
public Object execute(String methodName, Object[] params) throws XmlRpcException {
return client.execute(methodName, params);
}
- @Override
public Object execute(String pMethodName, List pParams) throws XmlRpcException {
return client.execute(pMethodName, pParams);
}
diff --git a/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java b/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java
index 061f860..0af228e 100644
--- a/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java
+++ b/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java
@@ -393,8 +393,7 @@ public class UrlProvider implements ContentProvider, PackageSource {
return null; // the file doesn't match any known types for this content source
}
- @Override
public SyncProgressWeight getSyncProgressWeight() {
return SyncProgressWeight.DEFAULT_WEIGHTS;
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java b/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
index f45c0a4..00bdb0f 100644
--- a/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
+++ b/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
@@ -191,8 +191,7 @@ public class RepoProvider implements ContentProvider, PackageSource {
return path;
}
- @Override
public SyncProgressWeight getSyncProgressWeight() {
return SyncProgressWeight.DEFAULT_WEIGHTS;
}
-}
\ No newline at end of file
+}
commit b138416f64a8a0d80eba1bb720779430e9a1ba9e
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 13 16:31:50 2010 -0500
Deleted invalid use of @Override (not allowed when implementing an interface method). I wasn't seeing issues with this in place but it was causing the build to break for at least one other developer.
diff --git a/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java b/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
index 8c3f163..6f9bb8b 100644
--- a/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
+++ b/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
@@ -353,7 +353,6 @@ public class DiskSource implements ContentProvider, PackageSource, RepoSource {
public String resourceTypePluginName;
}
- @Override
public SyncProgressWeight getSyncProgressWeight() {
return new SyncProgressWeight(10, 1, 0, 0, 0);
}
commit 4c49062b9cc93140f5f39197fe4e72c2cbe9c320
Author: John Matthews <jmatthew(a)redhat.com>
Date: Wed Jan 13 13:42:10 2010 -0500
1357 - added support for 'wget' of a package through http
Example URL (supports repo name or repo id in URL)
http://127.0.0.1:7080/content/rhel-i386-server-vt-5/packages/gnome-applet...
http://127.0.0.1:7080/content/10055/packages/gnome-applet-vm-0.1.2-1.el5....
diff --git a/modules/enterprise/gui/content_http-war/pom.xml b/modules/enterprise/gui/content_http-war/pom.xml
index 5966c8e..452c0ce 100644
--- a/modules/enterprise/gui/content_http-war/pom.xml
+++ b/modules/enterprise/gui/content_http-war/pom.xml
@@ -162,6 +162,12 @@
<version>1.1.4</version>
</dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ </dependency>
+
</dependencies>
<build>
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
index 2ac2061..549850f 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -1,34 +1,281 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.gui.content;
import java.io.IOException;
+import java.util.List;
import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.servlets.DefaultServlet;
-
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.text.StrTokenizer;
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.PackageVersion;
+import org.rhq.core.domain.content.Repo;
+import org.rhq.core.domain.criteria.PackageVersionCriteria;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.server.content.ContentManagerLocal;
+import org.rhq.enterprise.server.content.ContentSourceManagerLocal;
+import org.rhq.enterprise.server.content.RepoManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
public class ContentHTTPServlet extends DefaultServlet {
private final Log log = LogFactory.getLog(ContentHTTPServlet.class);
+ protected static final String PACKAGES = "packages";
+ protected static final String DISTRIBUTIONS = "distributions";
+
+ protected RepoManagerLocal repoMgr;
+ protected ContentManagerLocal contentMgr;
+ protected ContentSourceManagerLocal contentSourceMgr;
+
public ContentHTTPServlet() {
super();
}
public void init() throws ServletException {
- log.info("** *** ** ** ** *** Inside of ContentHTTPServlet::init()");
super.init();
+ repoMgr = LookupUtil.getRepoManagerLocal();
+ contentMgr = LookupUtil.getContentManager();
+ contentSourceMgr = LookupUtil.getContentSourceManager();
+ log.info("ContentHTTPServlet resolved references in init.");
}
- protected void doGet(HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException {
- log.info("** ** ** Inside of ContentHTTPServlet::doGet()");
- super.doGet(request, response);
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+ log.info("doGet(): requestURI = " + request.getRequestURI());
+
+ // Check if repo has been specified
+ Repo repo = getRepo(request, response);
+ if (repo == null) {
+ log.info("No repo found so we'll render a list of all repos.");
+ renderRepoList(request, response);
+ return;
+ }
+ // Check if type of content has been specified
+ String typeOfContent = getTypeOfContent(request.getRequestURI());
+ if (StringUtils.isBlank(typeOfContent)) {
+ log.info("no info was specified for type of content.");
+ renderChoiceOfContent(request, response, repo);
+ return;
+ }
+ //
+ // Determine what we should render, i.e.: packages or distributions
+ //
+ if (StringUtils.equalsIgnoreCase(typeOfContent, PACKAGES)) {
+ log.info("render packages");
+ renderPackages(request, response, repo);
+ return;
+
+ } else if (StringUtils.equalsIgnoreCase(typeOfContent, DISTRIBUTIONS)) {
+ log.info("render distributions");
+ renderDistributions(request, response, repo);
+ return;
+ } else {
+ log.info("Unable to determine what type of content was requested: " + typeOfContent);
+ renderErrorPage(request, response);
+ return;
+ }
}
-}
+ protected void renderRepoList(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ // Two known situations
+ // #1 User entered a bad URL
+ // #2 User entered no repo name
+
+ String repoName = getRepoName(request.getRequestURI());
+ if (!StringUtils.isEmpty(repoName)) {
+ log.info("Assuming bad repo name for: " + repoName + ", will render error page");
+ renderErrorPage(request, response);
+ return;
+ }
+ // Entered repo name is blank, so we'll render a list of repos
+
+ Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+ PageList<Repo> repos = repoMgr.findRepos(overlord, PageControl.getUnlimitedInstance());
+ log.info("Returned list of repos: " + repos.getTotalSize() + " entries");
+ for (Repo r : repos) {
+ log.info("Potential repo: Name = " + r.getName() + ", ID = " + r.getId());
+ }
+ log.info("TODO: generate index.html");
+
+ // dont include candidate repos
+ }
+
+ protected void renderChoiceOfContent(HttpServletRequest request, HttpServletResponse response, Repo repo) {
+ log.info("Choice of content is: {" + PACKAGES + ", " + DISTRIBUTIONS + "}");
+ }
+
+ protected void renderPackages(HttpServletRequest request, HttpServletResponse response, Repo repo)
+ throws IOException {
+
+ log.info("renderPackages(repo name = " + repo.getName() + ", id = " + repo.getId() + ", isCandidate = "
+ + repo.isCandidate() + ")");
+
+ String fileName = getFileName(request.getRequestURI());
+ log.info("Parsed file name = " + fileName);
+ if (StringUtils.isBlank(fileName)) {
+ // form a directory listing for each package in repository.
+ log.info("TODO: create index.html listing all the packages for this repo: " + repo.getName());
+ renderPackageIndex(request, response, repo);
+ return;
+ } else {
+ log.info("TODO: fetch package bits and return them.");
+ PackageVersion pv = getPackageVersionFromFileName(repo, fileName);
+ if (pv == null) {
+ log.info("Unable to find PackageVersion from filename: " + fileName);
+ renderErrorPage(request, response);
+ return;
+ }
+ response.setContentType("application/x-rpm");
+ writePackageVersionBits(pv, response.getOutputStream());
+ }
+ }
+
+ protected void renderPackageIndex(HttpServletRequest request, HttpServletResponse response, Repo repo) {
+ // placeholder for packages index.html
+ log.info("Forming packages index.html for repo: " + repo.getName() + ", ID = " + repo.getId());
+
+ List<PackageVersion> pvs = repoMgr.findPackageVersionsInRepo(LookupUtil.getSubjectManager().getOverlord(), repo
+ .getId(), PageControl.getUnlimitedInstance());
+
+ for (PackageVersion pv : pvs) {
+ log.info("Add PackageVersion: " + pv);
+ }
+
+ }
+
+ protected void renderDistributions(HttpServletRequest request, HttpServletResponse response, Repo repo) {
+
+ }
+
+ protected void renderErrorPage(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ log.info("render error page for request: " + request.getRequestURI());
+ response.sendError(response.SC_NOT_FOUND);
+ }
+
+ protected Repo getRepo(HttpServletRequest request, HttpServletResponse response) {
+
+ String repoName = getRepoName(request.getRequestURI());
+ log.info("Parsed repo name = " + repoName);
+ List<Repo> targetRepos = repoMgr.getRepoByName(repoName);
+ if (targetRepos.isEmpty()) {
+ // Check if maybe this is the repoID passed in as an int, instead of repo name
+ try {
+ Integer repoId = Integer.parseInt(repoName);
+ return repoMgr.getRepo(LookupUtil.getSubjectManager().getOverlord(), repoId);
+ } catch (NumberFormatException e) {
+ //ignore
+ }
+ return null;
+ }
+ return targetRepos.get(0);
+ }
+
+ /**
+ * Expecting URI format of:
+ * 127.0.0.1:7080/content/$REPONAME/$TYPE_OF_CONTENT/$FILENAME
+ */
+
+ /**
+ *
+ * @param requestURI
+ * @return repo name or "" if no repo name could be determined
+ */
+ protected String getRepoName(String requestURI) {
+ return getNthPiece(2, requestURI);
+ }
+
+ /**
+ *
+ * @param requestURI
+ * @return string that denotes if this is a package/distribution/etc kind of request
+ */
+ protected String getTypeOfContent(String requestURI) {
+ return getNthPiece(3, requestURI);
+ }
+
+ /**
+ *
+ * @param requestURI
+ * @return file name or "" if no file name could be determined
+ */
+ protected String getFileName(String requestURI) {
+ return getNthPiece(4, requestURI);
+ }
+
+ /**
+ * @param n nth element to return from requestURI, (first element corresponds to 1, not 0)
+ * @param requestURI
+ *
+ */
+ protected String getNthPiece(int n, String requestURI) {
+ int index = n - 1;
+ StrTokenizer st = new StrTokenizer(requestURI, "/");
+ List<String> tokens = st.getTokenList();
+ if (tokens.size() < index) {
+ return "";
+ }
+ return tokens.get(index);
+ }
+
+ protected PackageVersion getPackageVersionFromFileName(Repo repo, String fileName) {
+
+ PackageVersionCriteria criteria = new PackageVersionCriteria();
+ criteria.addFilterFileName(fileName);
+ criteria.addFilterRepoId(repo.getId());
+ log.info("Created criteria for repoId = " + repo.getId() + ", fileName = " + fileName);
+ List<PackageVersion> pkgVers = contentMgr.findPackageVersionsByCriteria(LookupUtil.getSubjectManager()
+ .getOverlord(), criteria);
+ for (PackageVersion pkgV : pkgVers) {
+ log.info("PackageVersion found: " + pkgVers);
+ }
+ log.info("Found " + pkgVers.size() + " entries");
+ PackageVersion pv = null;
+ if (pkgVers.size() > 0) {
+ pv = pkgVers.get(0);
+ } else {
+ log.info("Couldn't find " + fileName + " in " + repo.getName());
+ }
+ return pv;
+ }
+
+ protected boolean writePackageVersionBits(PackageVersion pkgVer, ServletOutputStream output) {
+
+ try {
+ contentSourceMgr.outputPackageVersionBits(pkgVer, output);
+ output.flush();
+ output.close();
+ } catch (IllegalStateException e) {
+ log.error(e);
+ return false;
+ } catch (IOException e) {
+ log.error(e);
+ return false;
+ }
+ return true;
+ }
+}
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 7421961..fbfaedb 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
@@ -1737,6 +1737,22 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
packageVersionId);
}
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ @TransactionTimeout(45 * 60)
+ public long outputPackageVersionBits(PackageVersion packageVersion, OutputStream outputStream) {
+ // Used by export of content through http
+
+ PackageDetailsKey packageDetailsKey = new PackageDetailsKey(packageVersion.getDisplayName(), packageVersion
+ .getDisplayVersion(), packageVersion.getGeneralPackage().getPackageType().toString(), packageVersion
+ .getArchitecture().toString());
+
+ int resourceId = 0; //set to dummy value
+
+ log.info("Calling outputPackageVersionBitsRangeHelper() with package details: " + packageDetailsKey);
+ return outputPackageVersionBitsRangeHelper(resourceId, packageDetailsKey, outputStream, 0, -1, packageVersion
+ .getId());
+ }
+
@SuppressWarnings("unchecked")
private long outputPackageVersionBitsRangeHelper(int resourceId, PackageDetailsKey packageDetailsKey,
OutputStream outputStream, long startByte, long endByte, int packageVersionId) {
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 25fefdc..5fa9fa3 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
@@ -559,6 +559,23 @@ public interface ContentSourceManagerLocal {
PackageDetailsKey packageDetailsKey, OutputStream outputStream);
/**
+ * Requests the bits of a package be streamed down to the caller over the given output stream.
+ * This method will <b>not</b> take care of closing the stream when it is finished;
+ * it is the caller's responsibility. This may be a time-consuming method call because
+ * if the bits have not yet been loaded (i.e. the content source where the package version lives
+ * {@link ContentSource#isLazyLoad() is lazy loading} then this may be the time when it is downloaded from the
+ * remote repository.
+ *
+ * @param packageVersion packageVersion to fetch
+ * @param outputStream an output stream where the server should write the package contents. It is up to the
+ * caller to prepare this output stream in order to write the package content to an
+ * appropriate location.
+ *
+ * @return the number of bytes written to the output stream
+ */
+ long outputPackageVersionBits(PackageVersion packageVersion, OutputStream outputStream);
+
+ /**
* Adds the specified content source to the database but does not attempt to create or start
* the server-side plugin provider implementation associated with it.
* <p/>
commit c078896bcb5067ae66e67358c5c3257104914b2a
Author: John Matthews <jmatthew(a)redhat.com>
Date: Wed Jan 13 13:41:05 2010 -0500
Adding eclipse changes for exposing content through http
diff --git a/.classpath b/.classpath
index 4598f49..527d92e 100644
--- a/.classpath
+++ b/.classpath
@@ -67,6 +67,7 @@
<classpathentry kind="src" path="modules/enterprise/gui/portal-war/src/test/java"/>
<classpathentry kind="src" path="modules/enterprise/gui/installer-war/src/main/java"/>
<classpathentry kind="src" path="modules/enterprise/gui/webdav-war/src/main/java"/>
+ <classpathentry kind="src" path="modules/enterprise/gui/content_http-war/src/main/java"/>
<classpathentry kind="src" path="modules/enterprise/remoting/cli/src/main/java"/>
<classpathentry kind="src" path="modules/enterprise/remoting/cli/src/test/java"/>
<classpathentry kind="src" path="modules/enterprise/remoting/webservices/src/main/java"/>
@@ -224,5 +225,6 @@
<classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.2.1/byteman-1.2.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.2/antlr-runtime-3.2.jar"/>
<classpathentry exported="true" kind="lib" path="modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-1.4.0-SNAPSHOT/wsconsume-output"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/jboss/web/jbossweb/2.0.1.GA/jbossweb-2.0.1.GA.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
commit 5cce671275d5820067e49afda67ae19ff62633a3
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 13 09:52:40 2010 -0500
Backend changes (configuration XML schema, parser, and data model) for supporting dynamic configuration property values.
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
index 79cd764..74a864e 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
@@ -31,6 +31,7 @@ import org.jetbrains.annotations.Nullable;
import org.rhq.core.domain.configuration.AbstractPropertyMap;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -135,6 +136,9 @@ public abstract class ConfigurationUtility {
property = new PropertyMap(propertyDefinition.getName());
} else if (propertyDefinition instanceof PropertyDefinitionList) {
property = new PropertyList(propertyDefinition.getName());
+ } else if (propertyDefinition instanceof PropertyDefinitionDynamic) {
+ // Dynamic property values should simply be stored as simple
+ property = new PropertySimple(propertyDefinition.getName(), null);
} else {
throw new IllegalStateException("Unsupported PropertyDefinition subclass: "
+ propertyDefinition.getClass().getName());
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
index de68ca6..5a6473e 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
@@ -34,6 +34,7 @@ import org.rhq.core.clientapi.descriptor.configuration.ConfigurationDescriptor;
import org.rhq.core.clientapi.descriptor.configuration.ConfigurationProperty;
import org.rhq.core.clientapi.descriptor.configuration.ConfigurationTemplateDescriptor;
import org.rhq.core.clientapi.descriptor.configuration.ConstraintType;
+import org.rhq.core.clientapi.descriptor.configuration.DynamicProperty;
import org.rhq.core.clientapi.descriptor.configuration.FloatConstraintType;
import org.rhq.core.clientapi.descriptor.configuration.IntegerConstraintType;
import org.rhq.core.clientapi.descriptor.configuration.ListProperty;
@@ -44,8 +45,9 @@ import org.rhq.core.clientapi.descriptor.configuration.PropertyOptions;
import org.rhq.core.clientapi.descriptor.configuration.PropertyType;
import org.rhq.core.clientapi.descriptor.configuration.RegexConstraintType;
import org.rhq.core.clientapi.descriptor.configuration.SimpleProperty;
-import org.rhq.core.clientapi.descriptor.configuration.ConfigurationFormat;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
+import org.rhq.core.domain.configuration.PropertyDynamicType;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.AbstractPropertyMap;
import org.rhq.core.domain.configuration.PropertyMap;
@@ -81,7 +83,7 @@ public class ConfigurationMetadataParser {
configurationDefinition.setConfigurationFormat(getConfigurationFormat(descriptor));
if (configurationDefinition.getConfigurationFormat() == RAW) {
- return configurationDefinition;
+ return configurationDefinition;
}
for (ConfigurationTemplateDescriptor templateDescriptor : descriptor.getTemplate()) {
@@ -195,6 +197,8 @@ public class ConfigurationMetadataParser {
property = parseListProperty((ListProperty) uncastedProperty);
} else if (uncastedProperty instanceof MapProperty) {
property = parseMapProperty((MapProperty) uncastedProperty, defaultConfigurationParentMap);
+ } else if (uncastedProperty instanceof DynamicProperty) {
+ property = parseDynamicProperty((DynamicProperty) uncastedProperty);
}
if (property != null) {
@@ -234,6 +238,23 @@ public class ConfigurationMetadataParser {
return property;
}
+ private static PropertyDefinitionDynamic parseDynamicProperty(DynamicProperty dynamicProperty)
+ throws InvalidPluginDescriptorException {
+ String description = parseMultiValue(dynamicProperty.getDescription(), dynamicProperty.getLongDescription());
+ String displayName = (dynamicProperty.getDisplayName() != null) ? dynamicProperty.getDisplayName() : StringUtils
+ .deCamelCase(dynamicProperty.getName());
+
+ PropertyDefinitionDynamic property = new PropertyDefinitionDynamic(dynamicProperty.getName(), description,
+ dynamicProperty.isRequired(), PropertyDynamicType.DATABASE, dynamicProperty.getDatabaseBacking().getKey());
+
+ property.setReadOnly(dynamicProperty.isReadOnly());
+ property.setSummary(dynamicProperty.isSummary());
+ property.setDisplayName(displayName);
+ property.setActivationPolicy(translateActivationPolicy(dynamicProperty.getActivationPolicy()));
+
+ return property;
+ }
+
private static List<PropertyDefinitionEnumeration> parsePropertyOptions(PropertyDefinitionSimple parentProperty,
PropertyOptions options) {
List<PropertyDefinitionEnumeration> results = new ArrayList<PropertyDefinitionEnumeration>();
diff --git a/modules/core/client-api/src/main/resources/rhq-configuration.xsd b/modules/core/client-api/src/main/resources/rhq-configuration.xsd
index 65ff6b7..e6c479d 100644
--- a/modules/core/client-api/src/main/resources/rhq-configuration.xsd
+++ b/modules/core/client-api/src/main/resources/rhq-configuration.xsd
@@ -23,7 +23,7 @@
<jaxb:class name="ConfigurationDescriptor"/>
</xs:appinfo>
<xs:documentation>Describes all configurable elements of a resource.</xs:documentation>
- </xs:annotation>
+ </xs:annotation>
<xs:sequence>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1">
<xs:annotation>
@@ -201,6 +201,45 @@
</xs:complexType>
+ <xs:element name="dynamic-property" type="config:dynamicProperty" substitutionGroup="config:configuration-property"/>
+ <xs:complexType name="dynamicProperty">
+ <xs:complexContent>
+ <xs:extension base="config:configurationProperty">
+ <xs:sequence>
+ <xs:choice minOccurs="1" maxOccurs="1">
+ <xs:element name="database-backing" type="config:databaseBackingType">
+ <xs:annotation>
+ <xs:documentation>Indicates where to retrieve the values for this property.</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <!-- This will ultimately have other options in the choice, such as from a plugin call. -->
+ </xs:choice>
+ </xs:sequence>
+
+ <xs:attribute name="activationPolicy" default="immediate" type="config:activationPolicy" use="optional">
+ <xs:annotation>
+ <xs:documentation>conditions under which a change to this property will become effective
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <xs:complexType name="databaseBackingType">
+ <xs:annotation>
+ <xs:documentation>Configures a property to look up values from the database.</xs:documentation>
+ </xs:annotation>
+
+ <xs:attribute name="key" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation>Key RHQ will use to determine what values to retieve from the database.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ </xs:complexType>
+
<xs:element name="simple-property" type="config:simpleProperty" substitutionGroup="config:configuration-property"/>
<xs:complexType name="simpleProperty">
<xs:complexContent>
@@ -261,7 +300,7 @@
property that is not defined in a configuration</xs:documentation>
<xs:appinfo>
<jaxb:property name="initialValue"/>
- </xs:appinfo>
+ </xs:appinfo>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index a9f912b..256f287 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.75</db.schema.version>
+ <db.schema.version>2.76</db.schema.version>
</properties>
<dependencies>
@@ -92,13 +92,13 @@
if (!project.properties.dbreset) {
return
}
-
+
database = project.properties['rhq.test.ds.db-name']
project.properties.dbsetup = 'true'
sql = Sql.newInstance(
- "jdbc:postgresql://127.0.0.1:5432/postgres",
- "postgres",
+ "jdbc:postgresql://127.0.0.1:5432/postgres",
+ "postgres",
"postgres",
"org.postgresql.Driver")
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
index 04d5fb3..95dd243 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
@@ -44,6 +44,10 @@
<!-- only simple properties (not lists and maps) have this -->
<column name="UNITS" type="SMALLINT" required="false"/>
+
+ <!-- only dynamic properties (not simple) have this -->
+ <column name="DYNAMIC_TYPE" type="VARCHAR2" size="20" required="false"/>
+ <column name="DYNAMIC_KEY" type="VARCHAR2" size="128" required="false"/>
</table>
<table name="RHQ_CONF_PROP_DEF_ENUM">
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index cd9ebc3..144c793 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2756,10 +2756,16 @@
</statement>
</schema-directSQL>
</schemaSpec>
-
+
<schemaSpec version="2.75">
<schema-addColumn table="RHQ_REPO" column="SYNC_SCHEDULE" columnType="VARCHAR2" precision="64" />
</schemaSpec>
+
+ <schemaSpec version="2.76">
+ <schema-addColumn table="RHQ_CONFIG_PROP_DEF" column="DYNAMIC_TYPE" columnType="VARCHAR2" precision="20" />
+ <schema-addColumn table="RHQ_CONFIG_PROP_DEF" column="DYNAMIC_KEY" columnType="VARCHAR2" precision="128" />
+ </schemaSpec>
+
</dbupgrade>
</target>
</project>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyDefinitionDynamic.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyDefinitionDynamic.java
new file mode 100644
index 0000000..e2395c6
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyDefinitionDynamic.java
@@ -0,0 +1,82 @@
+/*
+* 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.core.domain.configuration;
+
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+
+/**
+ * Describes a property whose values are retrieved from a dynamic source. Currently, the only source supported
+ * is database. Changes will likely need to be made when plugin based value sources are introduced.
+ *
+ * @author Jason Dobies
+ */
+@DiscriminatorValue("dynamic")
+@Entity(name = "PropertyDefinitionDynamic")
+@XmlRootElement(name = "PropertyDefinitionDynamic")
+(a)XmlAccessorType(XmlAccessType.FIELD)
+public class PropertyDefinitionDynamic extends PropertyDefinition {
+
+ private static final long serialVersionUID = 1L;
+
+ @Column(name = "DYNAMIC_TYPE")
+ @Enumerated(EnumType.STRING)
+ private PropertyDynamicType dynamicType;
+
+ @Column(name = "DYNAMIC_KEY")
+ private String key;
+
+ public PropertyDefinitionDynamic() {
+ }
+
+ public PropertyDefinitionDynamic(String name, String description, boolean required,
+ PropertyDynamicType dynamicType, String key) {
+ super(name, description, required);
+ this.dynamicType = dynamicType;
+ this.key = key;
+ }
+
+ public PropertyDynamicType getDynamicType() {
+ return dynamicType;
+ }
+
+ public void setDynamicType(PropertyDynamicType dynamicType) {
+ this.dynamicType = dynamicType;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyDynamicType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyDynamicType.java
new file mode 100644
index 0000000..e413039
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyDynamicType.java
@@ -0,0 +1,33 @@
+/*
+* 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.core.domain.configuration;
+
+/**
+ * @author Jason Dobies
+ */
+public enum PropertyDynamicType {
+
+ DATABASE
+ // SERVER-SIDE-PLUGIN - Not supported yet, but ultimately this is an example of why this enum exists
+
+}
commit 0f194a7fb5ea6889a6e978e4be2f1c045dc7f151
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Tue Jan 12 17:00:52 2010 -0800
1384 - validate format of cron input
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/content/test/RepoTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/content/test/RepoTest.java
new file mode 100644
index 0000000..7b5a402
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/content/test/RepoTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.domain.content.test;
+
+import javax.persistence.EntityManager;
+
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.content.Repo;
+import org.rhq.core.domain.test.AbstractEJB3Test;
+
+@Test
+public class RepoTest extends AbstractEJB3Test {
+ public void testInsert() throws Exception {
+ getTransactionManager().begin();
+ try {
+ EntityManager em = getEntityManager();
+ Repo repo = new Repo("testRepoTest");
+ repo.setSyncSchedule("0 0 5 * * ?");
+ em.persist(repo);
+ em.flush();
+ em.close();
+ em = getEntityManager();
+
+ Repo lookedUp = em.find(Repo.class, repo.getId());
+ assert lookedUp != null;
+ assert lookedUp.getSyncSchedule().equals("0 0 5 * * ?");
+
+ } finally {
+ getTransactionManager().rollback();
+ }
+ }
+
+}
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 2d969cf..c79d561 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
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.server.content;
+import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -33,6 +34,7 @@ import javax.persistence.Query;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.quartz.CronExpression;
import org.quartz.SchedulerException;
import org.jboss.annotation.IgnoreDependency;
@@ -300,10 +302,7 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
@RequiredPermission(Permission.MANAGE_INVENTORY)
public Repo updateRepo(Subject subject, Repo repo) throws RepoException {
- if (repo.getName() == null || repo.getName().trim().equals("")) {
- throw new RepoException("Repo name is required");
- }
-
+ validateFields(repo);
// HHH-2864 - Leave this in until we move to hibernate > 3.2.r14201-2
getRepo(subject, repo.getId());
@@ -790,10 +789,21 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
repo.addRepoRelationship(repoRelationship);
}
- private void validateRepo(Repo c) throws RepoException {
- if (c.getName() == null || c.getName().trim().equals("")) {
+ private void validateFields(Repo repo) throws RepoException {
+ if (repo.getName() == null || repo.getName().trim().equals("")) {
throw new RepoException("Repo name is required");
}
+ if (repo.getSyncSchedule() != null) {
+ try {
+ CronExpression ce = new CronExpression(repo.getSyncSchedule());
+ } catch (ParseException e) {
+ throw new RepoException("Repo sync schedule is not a vaild format.");
+ }
+ }
+ }
+
+ private void validateRepo(Repo c) throws RepoException {
+ this.validateFields(c);
List<Repo> repos = getRepoByName(c.getName());
if (repos.size() != 0) {
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/QuartzScheduleFormatTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/QuartzScheduleFormatTest.java
new file mode 100644
index 0000000..01c1f88
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/QuartzScheduleFormatTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.content.test;
+
+import java.text.ParseException;
+
+import junit.framework.TestCase;
+
+import org.quartz.CronExpression;
+
+/**
+ * @author mmccune
+ *
+ */
+public class QuartzScheduleFormatTest extends TestCase {
+
+ public void testValidFormat() {
+ String test = "23asdf";
+ boolean failed = false;
+ try {
+ CronExpression ce = new CronExpression(test);
+ } catch (ParseException e) {
+ failed = true;
+ }
+ assert failed;
+
+ test = "0 0 3 * * ?";
+ failed = false;
+ try {
+ CronExpression ce = new CronExpression(test);
+ } catch (ParseException e) {
+ failed = true;
+ }
+
+ assert !failed;
+
+ }
+}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
index 2d9f78b..bf7657a 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
@@ -466,4 +466,27 @@ public class RepoManagerBeanTest extends AbstractEJB3Test {
assert reposWithOldName.size() == 0;
}
+
+ @Test(enabled = ENABLED)
+ public void updateSyncSchedule() {
+ Repo repo = new Repo("updateSyncSchedule");
+ repo.setSyncSchedule("NOT A VALID CRON");
+ boolean failed = false;
+ try {
+ repo = repoManager.createRepo(overlord, repo);
+ } catch (RepoException e) {
+ failed = true;
+ }
+ assert failed;
+
+ failed = false;
+ repo.setSyncSchedule("0 0 3 * * ?");
+ try {
+ repo = repoManager.createRepo(overlord, repo);
+ } catch (RepoException e) {
+ failed = true;
+ }
+ assert !failed;
+ }
+
}
\ No newline at end of file
commit f13bee90803cd5713c80f58310e7d561691b0461
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Tue Jan 12 16:16:02 2010 -0800
1383, 1385, 1387 - can now edit/save the sync schedule.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
index 2fdbb50..5f4061c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
@@ -143,6 +143,9 @@ public class Repo implements Serializable, Taggable {
@Column(name = "IS_CANDIDATE", nullable = false)
private boolean candidate;
+ @Column(name = "SYNC_SCHEDULE", nullable = true)
+ private String syncSchedule = "0 0 3 * * ?";
+
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY)
private Set<ResourceRepo> resourceRepos;
@@ -254,6 +257,25 @@ public class Repo implements Serializable, Taggable {
}
/**
+ * Periodically, the Repo will be asked to synchronize with the remote ContentProviders associated with it
+ * This attribute defines the schedule, as a cron string. The default will be set for everyday at
+ * 3:00am local time. If this content source should never automatically sync, this should be null, but
+ * an empty string would also indicate this, too.
+ *
+ * @return sync schedule as a cron string or null if the sync should not automatically occur
+ */
+ public String getSyncSchedule() {
+ return syncSchedule;
+ }
+
+ public void setSyncSchedule(String syncSchedule) {
+ if (syncSchedule != null && syncSchedule.trim().length() == 0) {
+ syncSchedule = null;
+ }
+ this.syncSchedule = syncSchedule;
+ }
+
+ /**
* Returns the explicit mapping entities.
*
* @return the mapping entities
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
index 39b2056..c80471e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
@@ -66,6 +66,14 @@
value="#{RepoDetailsUIBean.repo.description}" /></td>
</tr>
<tr>
+ <td align="right"><b>Sync Schedule:</b></td>
+ <td align="left"><h:inputText
+ rendered="${mode eq 'edit'}"
+ value="#{RepoDetailsUIBean.repo.syncSchedule}" /> <h:outputText
+ rendered="${mode ne 'edit'}"
+ value="#{RepoDetailsUIBean.repo.syncSchedule}" /></td>
+ </tr>
+ <tr>
<td align="right"><b>Creation Date:</b></td>
<td align="left"><h:outputText
value="#{RepoDetailsUIBean.repo.creationDate}">
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 6c6d77e..2d969cf 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
@@ -312,6 +312,14 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
repo = entityManager.merge(repo);
log.debug("User [" + subject + "] updated repo [" + repo + "]");
+ try {
+ ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer();
+ pc.unscheduleRepoSyncJob(repo);
+ pc.scheduleRepoSyncJob(repo);
+ } catch (Exception e) {
+ log.warn("Failed to reschedule for [" + repo + "]", e);
+ }
+
return repo;
}
@@ -324,6 +332,16 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
entityManager.persist(repo);
log.debug("User [" + subject + "] created repo [" + repo + "]");
+ // Schedule the repo sync job.
+ try {
+ ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer();
+ // Schedule a job for the future
+ pc.scheduleRepoSyncJob(repo);
+ } catch (Exception e) {
+ log.error("error trying to schedule RepoSync", e);
+ throw new RuntimeException(e);
+ }
+
return repo; // now has the ID set
}
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 6fa249a..da28caa 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
@@ -19,6 +19,7 @@
package org.rhq.enterprise.server.plugin.pc.content;
import java.util.Date;
+import java.util.Set;
import org.quartz.JobDetail;
import org.quartz.SchedulerException;
@@ -44,7 +45,8 @@ import org.rhq.enterprise.server.xmlschema.generated.serverplugin.content.Conten
*/
public class ContentServerPluginContainer extends AbstractTypeServerPluginContainer {
- private static final String SYNC_JOB_GROUP_NAME = "syncContentSource";
+ private static final String CONTENT_SRC_SYNC_JOB_GROUP_NAME = "syncContentSource";
+ private static final String REPO_SYNC_JOB_GROUP_NAME = "syncRepo";
private ContentProviderManager adapterManager;
@@ -111,8 +113,8 @@ 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(ContentProviderSyncJob.createUniqueJobName(contentSource), SYNC_JOB_GROUP_NAME,
- ContentProviderSyncJob.class, false, false, false);
+ JobDetail job = new JobDetail(ContentProviderSyncJob.createUniqueJobName(contentSource),
+ CONTENT_SRC_SYNC_JOB_GROUP_NAME, ContentProviderSyncJob.class, false, false, false);
ContentProviderSyncJob.createJobDataMap(contentSource, job);
@@ -122,8 +124,9 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
Date next = scheduler.scheduleJob(job, trigger);
- getLog().info("Scheduled content provider sync job [" + job.getName() + ':' + job.getGroup() +
- "] to fire now at [" + next + "] for [" + contentSource + "]");
+ getLog().info(
+ "Scheduled content provider sync job [" + job.getName() + ':' + job.getGroup() + "] to fire now at ["
+ + next + "] for [" + contentSource + "]");
}
/**
@@ -134,7 +137,7 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
* @throws SchedulerException if the job cannot be scheduled
*/
public void syncRepoNow(Repo repo) throws SchedulerException {
- JobDetail job = new JobDetail(RepoSyncJob.createUniqueJobName(repo), SYNC_JOB_GROUP_NAME,
+ JobDetail job = new JobDetail(RepoSyncJob.createUniqueJobName(repo), CONTENT_SRC_SYNC_JOB_GROUP_NAME,
RepoSyncJob.class, false, false, false);
RepoSyncJob.createJobDataMap(job, repo);
@@ -145,8 +148,9 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
Date next = scheduler.scheduleJob(job, trigger);
- getLog().info("Scheduled repo sync job [" + job.getName() + ':' + job.getGroup() +
- "] to fire now at [" + next + "] for [" + repo + "]");
+ getLog().info(
+ "Scheduled repo sync job [" + job.getName() + ':' + job.getGroup() + "] to fire now at [" + next
+ + "] for [" + repo + "]");
}
/**
@@ -169,12 +173,37 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
}
SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
- scheduler.scheduleCronJob(ContentProviderSyncJob.createJobName(contentSource), SYNC_JOB_GROUP_NAME,
+ scheduler.scheduleCronJob(ContentProviderSyncJob.createJobName(contentSource), CONTENT_SRC_SYNC_JOB_GROUP_NAME,
ContentProviderSyncJob.createJobDataMap(contentSource, null), ContentProviderSyncJob.class, true, false,
syncSchedule);
}
/**
+ * This will schedule the sync job for the given content source. Once the scheduling is complete, the content
+ * source's adapter will be asked to synchronize with the remote content source according to the time(s) specified
+ * in the {@link ContentSource#getSyncSchedule() schedule}.
+ *
+ * <p>If the content source's sync schedule is empty, this method assumes it should not be automatically sync'ed so
+ * no schedule will be created and this method simply returns.</p>
+ *
+ * @param contentSource provider to sync
+ *
+ * @throws SchedulerException if failed to schedule the job
+ */
+ public void scheduleRepoSyncJob(Repo repo) throws SchedulerException {
+ String syncSchedule = repo.getSyncSchedule();
+ if ((syncSchedule == null) || (syncSchedule.trim().length() == 0)) {
+ getLog().warn(repo.toString() + " does not define a sync schedule - not scheduling");
+ return;
+ }
+
+ SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
+
+ scheduler.scheduleCronJob(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME, RepoSyncJob
+ .createJobDataMap(null, repo), RepoSyncJob.class, true, false, syncSchedule);
+ }
+
+ /**
* It will schedule one job per adapter such that each adapter is scheduled to be synchronized as per its defined
* sync schedule. This must only be called when all content source adapters have been initialized.
*/
@@ -182,7 +211,15 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
if (this.adapterManager != null) {
for (ContentSource contentSource : this.adapterManager.getAllContentSources()) {
try {
+ getLog().debug("scheduleSyncJobs :: Scheduling CP job: " + contentSource.getName());
scheduleProviderSyncJob(contentSource);
+ Set<Repo> repos = contentSource.getRepos();
+ if (repos != null) {
+ for (Repo repo : repos) {
+ getLog().debug("scheduleSyncJobs :: Scheduling REPO job: " + repo.getName());
+ scheduleRepoSyncJob(repo);
+ }
+ }
} catch (Exception e) {
getLog().warn("Could not schedule sync job for content source [" + contentSource + "]", e);
}
@@ -200,7 +237,19 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
*/
public void unscheduleProviderSyncJob(ContentSource contentSource) throws SchedulerException {
SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
- scheduler.deleteJob(ContentProviderSyncJob.createJobName(contentSource), SYNC_JOB_GROUP_NAME);
+ scheduler.deleteJob(ContentProviderSyncJob.createJobName(contentSource), CONTENT_SRC_SYNC_JOB_GROUP_NAME);
+ }
+
+ /**
+ * This will unschedule the sync job for the given Repo.
+ *
+ * @param repo cannot be <code>null</code>
+ *
+ * @throws SchedulerException if failed to unschedule the job
+ */
+ public void unscheduleRepoSyncJob(Repo repo) throws SchedulerException {
+ SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
+ scheduler.deleteJob(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME);
}
protected ServerPluginManager createPluginManager() {
commit 8150ad6b7fe304d4b27e4a393737cf0508003bf0
Merge: abb58c7... 8c6f3cf...
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Tue Jan 12 10:07:54 2010 -0800
Merge branch 'master' into content
commit abb58c79dbca0284913fdd9dbb6f524ed508ef3c
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Tue Jan 12 13:05:30 2010 -0500
fix unittest failure
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
index c0295b2..3293933 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
@@ -67,14 +67,16 @@ public class RegistrationBeanTest extends AbstractEJB3Test {
public void testReleaseRepoMap() throws Exception {
String release = "5Server";
+ String version = "5.4.0";
String arch = "x86_64";
- ReleaseRepoMapping repomap = new ReleaseRepoMapping(release, arch);
+ ReleaseRepoMapping repomap = new ReleaseRepoMapping(release, version, arch);
String repo = repomap.getCompatibleRepo();
assert (repo == "rhel-x86_64-server-5");
String release2 = "5Client";
String arch2 = "x86_64";
- ReleaseRepoMapping repomap2 = new ReleaseRepoMapping(release2, arch2);
+ String version2 = "5.4.0";
+ ReleaseRepoMapping repomap2 = new ReleaseRepoMapping(release2, version2, arch2);
String repo2 = repomap2.getCompatibleRepo();
assert (repo2 == "rhel-x86_64-client-5");
commit db2f300fbf1bf9c17e66d13c4f4ebc44380bd539
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Mon Jan 11 16:36:01 2010 -0800
1382 - sync schedule
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 356e6ac..a9f912b 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.74</db.schema.version>
+ <db.schema.version>2.75</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
index 5ba8ebb..261ac25 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -79,6 +79,7 @@
<column name="CREATION_TIME" type="LONG" required="true"/>
<column name="LAST_MODIFIED_TIME" type="LONG" required="true"/>
<column name="IS_CANDIDATE" type="BOOLEAN" required="true"/>
+ <column name="SYNC_SCHEDULE" size="64" type="VARCHAR2" required="false"/>
<index name="RHQ_REPO_IDX" unique="true">
<field ref="NAME"/>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 5e8a703..cd9ebc3 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2756,6 +2756,11 @@
</statement>
</schema-directSQL>
</schemaSpec>
+
+ <schemaSpec version="2.75">
+ <schema-addColumn table="RHQ_REPO" column="SYNC_SCHEDULE" columnType="VARCHAR2" precision="64" />
+ </schemaSpec>
</dbupgrade>
</target>
</project>
+
commit d40066dbc341965193e07109395a5d9badec5a46
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Mon Jan 11 19:36:19 2010 -0500
Supporting bean layer calls for bootstrap process to leverage to register a rhel client, import it as a managed resource, subscribe the resource to compatible base channel if available based on release,version and arch information sent from the clients. The resource created is associated to a dummy agent which will have the same host and port as the resource but does nothing. More work left to sync the agents once they are installed on the clients. These basic calls should siffice the goal of bootstrapping.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
index 7cd0da7..6253c8d 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
@@ -20,10 +20,10 @@ package org.rhq.enterprise.gui.navigation.resource;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.HashSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -88,7 +88,6 @@ public class ResourceTreeModelUIBean {
HibernatePerformanceMonitor.get().stop(monitorId, "ResourceTree agent resource");
log.debug("Loaded " + resources.size() + " raw resources in " + (end - start));
-
start = System.currentTimeMillis();
monitorId = HibernatePerformanceMonitor.get().start();
rootNode = load(rootResource.getId(), resources, false);
@@ -110,7 +109,6 @@ public class ResourceTreeModelUIBean {
return root;
}
-
public static void load(ResourceTreeNode parentNode, boolean alwaysGroup) {
if (parentNode.getData() instanceof Resource) {
@@ -169,9 +167,9 @@ public class ResourceTreeModelUIBean {
if (rsc instanceof ResourceSubCategory) {
agc = new AutoGroupComposite(avail, parentResource, (ResourceSubCategory) rsc, entries.size());
} else if (rsc instanceof ResourceType) {
- boolean isDupResourceTypeName = dupResourceTypeNames.contains(((ResourceType)rsc).getName());
+ boolean isDupResourceTypeName = dupResourceTypeNames.contains(((ResourceType) rsc).getName());
agc = new AutoGroupComposite(avail, parentResource, (ResourceType) rsc, entries.size(),
- isDupResourceTypeName);
+ isDupResourceTypeName);
}
ResourceTreeNode node = new ResourceTreeNode(agc);
load(node, alwaysGroup);
@@ -198,42 +196,45 @@ public class ResourceTreeModelUIBean {
AutoGroupComposite compositeParent = (AutoGroupComposite) parentNode.getData();
Map<Object, List<Resource>> children = new HashMap<Object, List<Resource>>();
- for (Resource res : compositeParent.getParentResource().getChildResources()) {
- if (compositeParent.getSubcategory() != null) {
- // parent is a sub category
- if (res.getResourceType().getSubCategory() != null
- && compositeParent.getSubcategory().equals(
- res.getResourceType().getSubCategory().getParentSubCategory())
- && compositeParent.getParentResource().equals(res.getParentResource())) {
-
- // A subSubCategory in a subcategory
- if (children.containsKey(res.getResourceType().getSubCategory())) {
- children.get(res.getResourceType().getSubCategory()).add(res);
- } else {
- ArrayList<Resource> list = new ArrayList<Resource>();
- list.add(res);
- children.put(res.getResourceType().getSubCategory(), list);
+ log.error("composite parent" + compositeParent);
+ if (compositeParent != null) {
+ for (Resource res : compositeParent.getParentResource().getChildResources()) {
+ if (compositeParent.getSubcategory() != null) {
+ // parent is a sub category
+ if (res.getResourceType().getSubCategory() != null
+ && compositeParent.getSubcategory().equals(
+ res.getResourceType().getSubCategory().getParentSubCategory())
+ && compositeParent.getParentResource().equals(res.getParentResource())) {
+
+ // A subSubCategory in a subcategory
+ if (children.containsKey(res.getResourceType().getSubCategory())) {
+ children.get(res.getResourceType().getSubCategory()).add(res);
+ } else {
+ ArrayList<Resource> list = new ArrayList<Resource>();
+ list.add(res);
+ children.put(res.getResourceType().getSubCategory(), list);
+ }
+ } else if (compositeParent.getSubcategory().equals(res.getResourceType().getSubCategory())
+ && compositeParent.getParentResource().equals(res.getParentResource())) {
+ // Direct entries in a subcategory... now group them by autogroup (type)
+ if (children.containsKey(res.getResourceType())) {
+ children.get(res.getResourceType()).add(res);
+ } else {
+ ArrayList<Resource> list = new ArrayList<Resource>();
+ list.add(res);
+ children.put(res.getResourceType(), list);
+ }
}
- } else if (compositeParent.getSubcategory().equals(res.getResourceType().getSubCategory())
- && compositeParent.getParentResource().equals(res.getParentResource())) {
- // Direct entries in a subcategory... now group them by autogroup (type)
- if (children.containsKey(res.getResourceType())) {
- children.get(res.getResourceType()).add(res);
- } else {
- ArrayList<Resource> list = new ArrayList<Resource>();
- list.add(res);
- children.put(res.getResourceType(), list);
- }
- }
- } else if (compositeParent.getResourceType() != null) {
- if (compositeParent.getResourceType().equals(res.getResourceType())
- && compositeParent.getParentResource().getId() == res.getParentResource().getId()) {
- if (children.containsKey(res.getResourceType())) {
- children.get(res.getResourceType()).add(res);
- } else {
- ArrayList<Resource> list = new ArrayList<Resource>();
- list.add(res);
- children.put(res.getResourceType(), list);
+ } else if (compositeParent.getResourceType() != null) {
+ if (compositeParent.getResourceType().equals(res.getResourceType())
+ && compositeParent.getParentResource().getId() == res.getParentResource().getId()) {
+ if (children.containsKey(res.getResourceType())) {
+ children.get(res.getResourceType()).add(res);
+ } else {
+ ArrayList<Resource> list = new ArrayList<Resource>();
+ list.add(res);
+ children.put(res.getResourceType(), list);
+ }
}
}
}
@@ -324,9 +325,9 @@ public class ResourceTreeModelUIBean {
Set<String> dupResourceTypeNames = new HashSet();
for (Object rsc : children.keySet()) {
if (rsc != null
- && (rsc instanceof ResourceType && (children.get(rsc).size() > 1 || (alwaysGroup && children
- .get(rsc).size() == 1)))) {
- String resourceTypeName = ((ResourceType)rsc).getName();
+ && (rsc instanceof ResourceType && (children.get(rsc).size() > 1 || (alwaysGroup && children.get(rsc)
+ .size() == 1)))) {
+ String resourceTypeName = ((ResourceType) rsc).getName();
if (resourceTypeNames.contains(resourceTypeName)) {
dupResourceTypeNames.add(resourceTypeName);
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java
index 28adc98..a848358 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java
@@ -18,15 +18,15 @@
*/
package org.rhq.enterprise.gui.navigation.resource;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.composite.ResourceWithAvailability;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
import org.rhq.core.util.sort.HumaneStringComparator;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
/**
* Just a basic node to hold resources, resource auto groups and subcategories
* in a tree.
@@ -58,8 +58,11 @@ public class ResourceTreeNode implements Comparable<ResourceTreeNode> {
}
public String toString() {
+ if (level == null) {
+ return "";
+ }
if (level instanceof AutoGroupComposite) {
- AutoGroupComposite composite = ((AutoGroupComposite) level) ;
+ AutoGroupComposite composite = ((AutoGroupComposite) level);
return composite.getName();
} else if (level instanceof ResourceWithAvailability) {
return ((ResourceWithAvailability) level).getResource().getName();
@@ -79,12 +82,15 @@ public class ResourceTreeNode implements Comparable<ResourceTreeNode> {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
ResourceTreeNode that = (ResourceTreeNode) o;
- if (!level.equals(that.level)) return false;
+ if (!level.equals(that.level))
+ return false;
return true;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationException.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationException.java
new file mode 100644
index 0000000..f7a3b40
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationException.java
@@ -0,0 +1,38 @@
+/*
+ * 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.registration;
+
+public class RegistrationException extends Exception {
+ private static final long serialVersionUID = -2258189843514401027L;
+
+ public RegistrationException() {
+ }
+
+ public RegistrationException(String message) {
+ super(message);
+ }
+
+ public RegistrationException(Throwable cause) {
+ super(cause);
+ }
+
+ public RegistrationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
new file mode 100644
index 0000000..2ebc9f2
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
@@ -0,0 +1,222 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.registration;
+
+import java.util.List;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.jboss.annotation.IgnoreDependency;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.content.Repo;
+import org.rhq.core.domain.resource.Agent;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.server.RHQConstants;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
+import org.rhq.enterprise.server.content.RepoManagerLocal;
+import org.rhq.enterprise.server.core.AgentManagerLocal;
+import org.rhq.enterprise.server.resource.ResourceAlreadyExistsException;
+import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+@Stateless
+public class RegistrationManagerBean implements RegistrationManagerLocal, RegistrationManagerRemote {
+
+ private final Log log = LogFactory.getLog(RegistrationManagerBean.class.getName());
+
+ @PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
+ private EntityManager entityManager;
+ @EJB
+ @IgnoreDependency
+ private ResourceManagerLocal resourceManager;
+ @EJB
+ private SubjectManagerLocal subjectManager;
+ @EJB
+ private AgentManagerLocal agentManager;
+
+ /**
+ * Registers the platform as a resource on RHQ server
+ * @param user secure id user
+ * @param platform to be registered
+ * @param parenId if any.
+ *
+ */
+ public void registerPlatform(Subject user, Resource platform, int parentId) {
+ try {
+ validatePlatform(platform);
+ } catch (RegistrationException e) {
+ throw new IllegalStateException(e);
+ }
+
+ platform.setInventoryStatus(InventoryStatus.COMMITTED);
+
+ Agent agent = createFakeAgent(platform);
+ platform.setAgent(agent);
+
+ try {
+ resourceManager.createResource(user, platform, parentId);
+ } catch (ResourceAlreadyExistsException e) {
+ throw new IllegalStateException(e);
+ }
+
+ log.error("Resource " + platform + "persisted");
+
+ }
+
+ /**
+ * Imports the registered resource into inventory and makes it a managed resource
+ * @param user secure id user
+ * @param platform to be imported
+ *
+ */
+ public void importPlatform(Subject user, Resource resource) {
+ resource.setInventoryStatus(InventoryStatus.COMMITTED);
+ entityManager.persist(resource);
+ }
+
+ /**
+ * subscribe the requested platform to a compatible base repo based on release
+ * and arch information. This method does a lookup in ReleaseRepoMapping
+ * to get the compatible base channel and tried to tie the platform to
+ * the repo.
+ * @param user secure id user
+ * @param platform to be imported
+ * @param release the release string of the client
+ * @param arch arch of the platform
+ */
+ public void subscribePlatformToBaseRepo(Subject user, Resource platform, String release, String version, String arch)
+ throws RegistrationException {
+ log.debug("Trying to subscribe " + platform + " to a compatible baserepo");
+ ReleaseRepoMapping rm = new ReleaseRepoMapping(release, version, arch);
+ String repoName = rm.getCompatibleRepo();
+ try {
+ RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
+ List<Repo> repos = repoManager.getRepoByName(repoName);
+ int[] repoIds = getIntRepoIdArray(repos);
+ repoManager.subscribeResourceToRepos(user, platform.getId(), repoIds);
+ } catch (Exception e) {
+ throw new RegistrationException("No Compatible Base repo Found." + e);
+ }
+ }
+
+ /**
+ * Validates the sanity of the resource to be created. Also checks to see if the platform
+ * alreday exists.
+ * @param platform
+ * @throws RegistrationException
+ */
+ private void validatePlatform(Resource platform) throws RegistrationException {
+ if (platform.getResourceType() == null) {
+ throw new RegistrationException("Reported resource [" + platform + "] has a null type.");
+ }
+
+ if (platform.getResourceKey() == null) {
+ throw new RegistrationException("Reported resource [" + platform + "] has a null key.");
+ }
+
+ if (platform.getInventoryStatus() == InventoryStatus.DELETED) {
+ throw new RegistrationException(
+ "Reported resource ["
+ + platform
+ + "] has an illegal inventory status of 'DELETED' - agents are not allowed to delete platforms from inventory.");
+ }
+
+ //check if the resource already exists
+ Resource existingPlatform = checkResourceExists(platform);
+
+ if (existingPlatform != null) {
+ throw new RegistrationException("Reported resource [" + platform + "] Already Exists.");
+ }
+
+ }
+
+ /**
+ * Checks to see if the resource already exists in rhq
+ * @param platform
+ * @return
+ */
+ private Resource checkResourceExists(Resource platform) {
+ Resource existingResource = null;
+
+ if (platform.getId() != 0) {
+ existingResource = entityManager.find(Resource.class, platform.getId());
+ }
+
+ if (existingResource == null) {
+ ResourceType resourceType = platform.getResourceType();
+ existingResource = resourceManager.getResourceByParentAndKey(subjectManager.getOverlord(), platform
+ .getParentResource(), platform.getResourceKey(), resourceType.getPlugin(), resourceType.getName());
+ if (existingResource != null) {
+ platform.setId(existingResource.getId());
+ } else {
+
+ if (platform.getId() != 0) {
+ platform.setId(0);
+ }
+ }
+ }
+
+ return existingResource;
+ }
+
+ /**
+ * Creates an agent for a given resource and persist in the db. The agents role is noop
+ * until its installed on the client and tied to this row in the db.
+ * @param resource
+ * @return
+ */
+ private Agent createFakeAgent(Resource resource) {
+ String address = resource.getName();
+ int port = 16163;
+ String endPoint = "socket://" + address + ":" + port + "/?rhq.communications.connector.rhqtype=agent";
+ Agent agent = agentManager.getAgentByAddressAndPort(resource.getName(), 16163);
+ if (agent == null) {
+ agent = new Agent(resource.getName(), address, port, endPoint, resource.getResourceKey());
+
+ entityManager.persist(agent);
+ entityManager.flush();
+ }
+ return agent;
+
+ }
+
+ private int[] getIntRepoIdArray(List<Repo> input) {
+ if (input == null) {
+ return new int[0];
+ }
+
+ int[] output = new int[input.size()];
+ for (int i = 0; i < input.size(); i++) {
+ output[i] = Integer.valueOf(input.get(i).getId()).intValue();
+ }
+
+ return output;
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerLocal.java
new file mode 100644
index 0000000..a1ef1c9
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerLocal.java
@@ -0,0 +1,52 @@
+/*
+ * 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.registration;
+
+import javax.ejb.Local;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.resource.Resource;
+
+@Local
+public interface RegistrationManagerLocal {
+ /**
+ * Register the platform in the inventory
+ * @param user
+ * @param resource
+ */
+ void registerPlatform(Subject user, Resource resource, int parentId);
+
+ /**
+ * Import the inventoried resource as a managed resource object
+ * @param user
+ * @param resourceId
+ */
+ void importPlatform(Subject user, Resource resource);
+
+ /**
+ * subscribe a platform to a compatible baserepo
+ * @param user
+ * @param platform
+ * @param release
+ * @param arch
+ */
+ void subscribePlatformToBaseRepo(Subject user, Resource platform, String release, String version, String arch)
+ throws RegistrationException;
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerRemote.java
new file mode 100644
index 0000000..7ee0ac6
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerRemote.java
@@ -0,0 +1,52 @@
+/*
+ * 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.registration;
+
+import javax.ejb.Remote;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.resource.Resource;
+
+@Remote
+public interface RegistrationManagerRemote {
+ /**
+ * Register the platform in the inventory
+ * @param user
+ * @param resource
+ */
+ void registerPlatform(Subject user, Resource resource, int parentId);
+
+ /**
+ * Import the inventoried resource as a managed resource object
+ * @param user
+ * @param resourceId
+ */
+ void importPlatform(Subject user, Resource resource);
+
+ /**
+ * subscribe a platform to a compatible baserepo
+ * @param user
+ * @param platform
+ * @param release
+ * @param arch
+ */
+ void subscribePlatformToBaseRepo(Subject user, Resource platform, String release, String version, String arch)
+ throws RegistrationException;
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/ReleaseRepoMapping.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/ReleaseRepoMapping.java
new file mode 100644
index 0000000..5f98da4
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/ReleaseRepoMapping.java
@@ -0,0 +1,76 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.registration;
+
+import java.util.HashMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Class representing the repo to release relationship.
+ * Ideally This should be persisted in the database at the sync time
+ * from hosted and should do a lookup in the db to extract compatible repos.
+ *
+ * Since we're still unsure if we want go the agentless route,
+ * Just using static mappings for now. This will be eventually replaced
+ * by persisting these mapping in the db.
+ *
+ * @author pkilambi
+ *
+ */
+public class ReleaseRepoMapping {
+ private final Log log = LogFactory.getLog(ReleaseRepoMapping.class.getName());
+ private String release;
+ private String arch;
+ private String version;
+
+ public ReleaseRepoMapping(String release, String version, String arch) {
+ this.release = release;
+ this.arch = arch;
+ this.version = version; //ignored for now, used for z-stream repos in future
+ }
+
+ public String getCompatibleRepo() {
+ HashMap<String, String> repomap = generateRepoMap();
+ log.debug("mapping generated " + repomap);
+ return repomap.get(this.release + "." + this.arch);
+ }
+
+ /**
+ * Static mappings for base repos
+ * @return
+ */
+ private HashMap<String, String> generateRepoMap() {
+ HashMap<String, String> hm = new HashMap<String, String>();
+
+ hm.put("5Server.arch", "rhel-arch-server-5");
+ hm.put("5Client.arch", "rhel-arch-client-5");
+
+ String[] arches = { "i386", "x86_64", "ia64", "s390x", "ppc" };
+ HashMap<String, String> newhm = new HashMap();
+ for (String k : hm.keySet()) {
+ for (String arch : arches) {
+ newhm.put(k.replace("arch", arch), hm.get(k).replace("arch", arch));
+ }
+ }
+ return newhm;
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 5b2716c..01c9b7d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -159,18 +159,17 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
if (parent == null) {
throw new ResourceNotFoundException("Intended parent for new resource does not exist.");
}
- }
- if (!authorizationManager.hasResourcePermission(user, Permission.CREATE_CHILD_RESOURCES, parent.getId())) {
- throw new PermissionException("You do not have permission to add this resource as a child.");
- }
+ if (!authorizationManager.hasResourcePermission(user, Permission.CREATE_CHILD_RESOURCES, parent.getId())) {
+ throw new PermissionException("You do not have permission to add this resource as a child.");
+ }
- if (getResourceByParentAndKey(user, parent, resource.getResourceKey(), resource.getResourceType().getPlugin(),
- resource.getResourceType().getName()) != null) {
- throw new ResourceAlreadyExistsException("Resource with key '" + resource.getResourceKey()
- + "' already exists.");
+ if (getResourceByParentAndKey(user, parent, resource.getResourceKey(), resource.getResourceType()
+ .getPlugin(), resource.getResourceType().getName()) != null) {
+ throw new ResourceAlreadyExistsException("Resource with key '" + resource.getResourceKey()
+ + "' already exists.");
+ }
}
-
if (parent != Resource.ROOT) {
// Only set the relationships if this is not a root resource.
// The cardinal rule is to add the relationship in both directions,
@@ -180,7 +179,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
}
entityManager.persist(resource);
-
+ log.error("********* resource persisted ************");
// Execute sub-methods as overlord to bypass additional security checks.
Subject overlord = this.subjectManager.getOverlord();
updateImplicitMembership(overlord, resource);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index fe9a2ef..9d2a8aa 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -130,6 +130,8 @@ import org.rhq.enterprise.server.perspective.PerspectiveManagerLocal;
import org.rhq.enterprise.server.plugin.ServerPluginsBean;
import org.rhq.enterprise.server.plugin.ServerPluginsLocal;
import org.rhq.enterprise.server.plugin.pc.ServerPluginServiceManagement;
+import org.rhq.enterprise.server.registration.RegistrationManagerBean;
+import org.rhq.enterprise.server.registration.RegistrationManagerLocal;
import org.rhq.enterprise.server.report.DataAccessManagerBean;
import org.rhq.enterprise.server.report.DataAccessManagerLocal;
import org.rhq.enterprise.server.resource.ProductVersionManagerBean;
@@ -484,6 +486,10 @@ public final class LookupUtil {
return lookupRemote(ResourceTypeManagerBean.class);
}
+ public static RegistrationManagerLocal getRegistrationManager() {
+ return lookupLocal(RegistrationManagerBean.class);
+ }
+
public static RoleManagerLocal getRoleManager() {
return lookupLocal(RoleManagerBean.class);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
index 3d768ab..8c43cb4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
@@ -38,8 +38,8 @@ import org.rhq.enterprise.server.alert.AlertManagerBean;
import org.rhq.enterprise.server.auth.SubjectManagerBean;
import org.rhq.enterprise.server.authz.RoleManagerBean;
import org.rhq.enterprise.server.configuration.ConfigurationManagerBean;
-import org.rhq.enterprise.server.content.RepoManagerBean;
import org.rhq.enterprise.server.content.ContentManagerBean;
+import org.rhq.enterprise.server.content.RepoManagerBean;
import org.rhq.enterprise.server.event.EventManagerBean;
import org.rhq.enterprise.server.measurement.AvailabilityManagerBean;
import org.rhq.enterprise.server.measurement.CallTimeDataManagerBean;
@@ -49,6 +49,7 @@ import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerBean;
import org.rhq.enterprise.server.measurement.MeasurementProblemManagerBean;
import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerBean;
import org.rhq.enterprise.server.operation.OperationManagerBean;
+import org.rhq.enterprise.server.registration.RegistrationManagerBean;
import org.rhq.enterprise.server.report.DataAccessManagerBean;
import org.rhq.enterprise.server.resource.ResourceFactoryManagerBean;
import org.rhq.enterprise.server.resource.ResourceManagerBean;
@@ -84,6 +85,7 @@ public class RemoteAPIValidator {
ResourceGroupManagerBean.class, //
ResourceManagerBean.class, //
ResourceTypeManagerBean.class, //
+ RegistrationManagerBean.class, //
RoleManagerBean.class, //
SubjectManagerBean.class, //
SupportManagerBean.class, //
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 409d7b3..c531297 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -124,6 +124,8 @@ import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal;
import org.rhq.enterprise.server.operation.GroupOperationSchedule;
import org.rhq.enterprise.server.operation.OperationManagerLocal;
import org.rhq.enterprise.server.operation.ResourceOperationSchedule;
+import org.rhq.enterprise.server.registration.RegistrationException;
+import org.rhq.enterprise.server.registration.RegistrationManagerLocal;
import org.rhq.enterprise.server.resource.ResourceFactoryManagerLocal;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.resource.ResourceNotFoundException;
@@ -173,6 +175,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
private ResourceGroupManagerLocal resourceGroupManager = LookupUtil.getResourceGroupManager();
private ResourceTypeManagerLocal resourceTypeManager = LookupUtil.getResourceTypeManager();
+ private RegistrationManagerLocal registrationManager = LookupUtil.getRegistrationManager();
private RoleManagerLocal roleManager = LookupUtil.getRoleManager();
private SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
private SupportManagerLocal supportManager = LookupUtil.getSupportManager();
@@ -372,8 +375,8 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public ResourceConfigurationUpdate updateStructuredOrRawConfiguration(Subject subject, int resourceId,
- Configuration newConfiguration, boolean fromStructured)
- throws ResourceNotFoundException, ConfigurationUpdateStillInProgressException {
+ Configuration newConfiguration, boolean fromStructured) throws ResourceNotFoundException,
+ ConfigurationUpdateStillInProgressException {
return configurationManager.updateStructuredOrRawConfiguration(subject, resourceId, newConfiguration,
fromStructured);
}
@@ -656,6 +659,19 @@ public class WebservicesManagerBean implements WebservicesRemote {
pluginConfiguration, resourceConfiguration);
}
+ public void registerPlatform(Subject subject, Resource resource, int parentId) {
+ registrationManager.registerPlatform(subject, resource, parentId);
+ }
+
+ public void importPlatform(Subject subject, Resource resource) {
+ registrationManager.importPlatform(subject, resource);
+ }
+
+ public void subscribePlatformToBaseRepo(Subject user, Resource platform, String release, String version, String arch)
+ throws RegistrationException {
+ registrationManager.subscribePlatformToBaseRepo(user, platform, release, version, arch);
+ }
+
public void createPackageBackedResource(Subject subject, int parentResourceId, int newResourceTypeId,
String newResourceName,//
@XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
index 596d737..8f72716 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
@@ -9,8 +9,8 @@ import org.rhq.enterprise.server.alert.AlertManagerRemote;
import org.rhq.enterprise.server.auth.SubjectManagerRemote;
import org.rhq.enterprise.server.authz.RoleManagerRemote;
import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
-import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.content.ContentManagerRemote;
+import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
import org.rhq.enterprise.server.measurement.AvailabilityManagerRemote;
@@ -21,6 +21,7 @@ import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerRemote;
import org.rhq.enterprise.server.measurement.MeasurementProblemManagerRemote;
import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerRemote;
import org.rhq.enterprise.server.operation.OperationManagerRemote;
+import org.rhq.enterprise.server.registration.RegistrationManagerRemote;
import org.rhq.enterprise.server.resource.ResourceFactoryManagerRemote;
import org.rhq.enterprise.server.resource.ResourceManagerRemote;
import org.rhq.enterprise.server.resource.ResourceTypeManagerRemote;
@@ -57,5 +58,6 @@ public interface WebservicesRemote extends //
RoleManagerRemote,//
SubjectManagerRemote,//
SupportManagerRemote,//
- SystemManagerRemote {
+ SystemManagerRemote, //
+ RegistrationManagerRemote {
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
new file mode 100644
index 0000000..c0295b2
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
@@ -0,0 +1,94 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.registration.test;
+
+import javax.persistence.EntityManager;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.resource.Agent;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.server.registration.RegistrationManagerLocal;
+import org.rhq.enterprise.server.registration.ReleaseRepoMapping;
+import org.rhq.enterprise.server.test.AbstractEJB3Test;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+public class RegistrationBeanTest extends AbstractEJB3Test {
+ private RegistrationManagerLocal registrationManager;
+ private ResourceType platformType;
+ private Agent agent;
+ private int parentId = -1;
+ private Subject overlord;
+
+ @BeforeClass
+ public void beforeClass() throws Exception {
+ this.registrationManager = LookupUtil.getRegistrationManager();
+ this.overlord = LookupUtil.getSubjectManager().getOverlord();
+ }
+
+ @Test(groups = "integration.ejb3")
+ public void testRegisterPlatform() throws Exception {
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ try {
+ createResourceTypes(em);
+ createAgent(em);
+ em.flush();
+
+ Resource platform = new Resource("alpha", "platform", platformType);
+
+ registrationManager.registerPlatform(overlord, platform, parentId);
+
+ } finally {
+ getTransactionManager().rollback();
+ }
+ }
+
+ public void testReleaseRepoMap() throws Exception {
+ String release = "5Server";
+ String arch = "x86_64";
+ ReleaseRepoMapping repomap = new ReleaseRepoMapping(release, arch);
+ String repo = repomap.getCompatibleRepo();
+ assert (repo == "rhel-x86_64-server-5");
+
+ String release2 = "5Client";
+ String arch2 = "x86_64";
+ ReleaseRepoMapping repomap2 = new ReleaseRepoMapping(release2, arch2);
+ String repo2 = repomap2.getCompatibleRepo();
+ assert (repo2 == "rhel-x86_64-client-5");
+
+ }
+
+ private void createAgent(EntityManager em) {
+ agent = new Agent("TestAgent-dbbt", "0.0.0.0", 1, "http://here", "tok");
+ em.persist(agent);
+ }
+
+ private void createResourceTypes(EntityManager entityManager) {
+ platformType = new ResourceType("test platform", "test", ResourceCategory.PLATFORM, null);
+
+ entityManager.persist(platformType);
+ }
+
+}
commit 60cd5aa9ecd61b2548c6be87c38bb38857574908
Author: John Matthews <jmatthew(a)redhat.com>
Date: Mon Jan 11 12:18:24 2010 -0500
build fix
diff --git a/modules/enterprise/gui/content_http-war/pom.xml b/modules/enterprise/gui/content_http-war/pom.xml
index 50e0ad6..5966c8e 100644
--- a/modules/enterprise/gui/content_http-war/pom.xml
+++ b/modules/enterprise/gui/content_http-war/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.rhq</groupId>
- <artifactId>rhq-parent</artifactId>
+ <artifactId>rhq-enterprise-gui-parent</artifactId>
<version>1.4.0-SNAPSHOT</version>
</parent>
diff --git a/modules/enterprise/gui/pom.xml b/modules/enterprise/gui/pom.xml
index ea3588d..9ae5584 100644
--- a/modules/enterprise/gui/pom.xml
+++ b/modules/enterprise/gui/pom.xml
@@ -34,10 +34,11 @@
<modules>
<module>portal-war</module>
<module>installer-war</module>
- <module>webdav-war</module>
+ <module>webdav-war</module>
+ <module>content_http-war</module>
</modules>
</profile>
</profiles>
-</project>
\ No newline at end of file
+</project>
commit 8ac53e72f020d5dd778d373838d6824ac7b4d2e4
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Mon Jan 11 10:01:48 2010 -0500
1347 - Added mechanism to translate and lookup database configuration property values
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java
index ef70fed..f10dc64 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java
@@ -182,7 +182,10 @@ import org.rhq.core.domain.util.serial.ExternalizableStrategy;
+ " FROM Role rr JOIN rr.subjects AS ss " //
+ " WHERE rr.id = :roleId" + " ) " //
+ " AND s.fsystem = FALSE " //
- + " AND s.factive = TRUE") })
+ + " AND s.factive = TRUE"), //
+ @NamedQuery(name = Subject.QUERY_DYNAMIC_CONFIG_VALUES, query = "" //
+ + "SELECT s.name FROM Subject AS s WHERE s.fsystem = false")
+})
@SequenceGenerator(name = "RHQ_SUBJECT_ID_SEQ", sequenceName = "RHQ_SUBJECT_ID_SEQ")
@Table(name = "RHQ_SUBJECT")
/*@Cache(usage= CacheConcurrencyStrategy.TRANSACTIONAL)*/
@@ -211,6 +214,8 @@ public class Subject implements Externalizable {
public static final String QUERY_FIND_AVAILABLE_SUBJECTS_FOR_ALERT_DEFINITION_WITH_EXCLUDES = "Subject.findAvailableSubjectsForAlertDefinitionWithExcludes";
public static final String QUERY_FIND_AVAILABLE_SUBJECTS_FOR_ALERT_DEFINITION = "Subject.findAvailableSubjectForAlertDefinition";
+ public static final String QUERY_DYNAMIC_CONFIG_VALUES = "Subject.dynamicConfigValues";
+
private static final long serialVersionUID = 1L;
@Column(name = "ID", nullable = false)
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java
index 87a1287..089ca55 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java
@@ -90,7 +90,10 @@ import org.rhq.core.domain.auth.Subject;
+ " FROM Role r" //
+ " WHERE r.id NOT IN ( SELECT rn.role.id " //
+ " FROM RoleNotification rn" //
- + " WHERE rn.alertDefinition.id = :alertDefinitionId ) ") })
+ + " WHERE rn.alertDefinition.id = :alertDefinitionId ) "), //
+ @NamedQuery(name = Role.QUERY_DYNAMIC_CONFIG_VALUES, query = "" //
+ + "SELECT r.name FROM Role AS r")
+})
@SequenceGenerator(name = "RHQ_ROLE_ID_SEQ", sequenceName = "RHQ_ROLE_ID_SEQ")
@Table(name = "RHQ_ROLE")
public class Role implements Serializable {
@@ -101,6 +104,8 @@ public class Role implements Serializable {
public static final String QUERY_FIND_AVAILABLE_ROLES_FOR_ALERT_DEFINITION_WITH_EXCLUDES = "Role.findAvailableRolesForAlertDefinitionWithExcludes";
public static final String QUERY_FIND_AVAILABLE_ROLES_FOR_ALERT_DEFINITION = "Role.findAvailableRolesForAlertDefinition";
+ public static final String QUERY_DYNAMIC_CONFIG_VALUES = "Role.dynamicConfigValues";
+
private static final long serialVersionUID = 1L;
@Column(name = "ID", nullable = false)
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
index a4e8530..7c2af68 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
@@ -64,12 +64,15 @@ import org.rhq.core.domain.resource.ResourceType;
*/
@Entity
@NamedQueries( {
+ @NamedQuery(name = PackageType.QUERY_FIND_ALL, query = "SELECT pt FROM PackageType pt"),
@NamedQuery(name = PackageType.QUERY_FIND_BY_RESOURCE_TYPE_ID, query = "SELECT pt FROM PackageType pt WHERE pt.resourceType.id = :typeId"),
@NamedQuery(name = PackageType.QUERY_FIND_BY_RESOURCE_TYPE_ID_AND_NAME, query = "SELECT pt FROM PackageType pt WHERE pt.resourceType.id = :typeId AND pt.name = :name"),
@NamedQuery(name = PackageType.QUERY_FIND_BY_RESOURCE_TYPE_ID_AND_CREATION_FLAG, query = "SELECT pt FROM PackageType pt "
+ "JOIN pt.resourceType rt "
+ "LEFT JOIN FETCH pt.deploymentConfigurationDefinition cd "
- + "LEFT JOIN FETCH cd.templates cts " + "WHERE rt.id = :typeId AND pt.isCreationData = true") })
+ + "LEFT JOIN FETCH cd.templates cts " + "WHERE rt.id = :typeId AND pt.isCreationData = true"),
+ @NamedQuery(name = PackageType.QUERY_DYNAMIC_CONFIG_VALUES, query = "SELECT pt.name FROM PackageType AS pt")
+})
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_PACKAGE_TYPE_ID_SEQ")
@Table(name = "RHQ_PACKAGE_TYPE")
@XmlAccessorType(XmlAccessType.FIELD)
@@ -78,10 +81,14 @@ public class PackageType implements Serializable {
private static final long serialVersionUID = 1L;
+ public static final String QUERY_FIND_ALL = "PackageType.findAll";
+
public static final String QUERY_FIND_BY_RESOURCE_TYPE_ID = "PackageType.findByResourceTypeId";
public static final String QUERY_FIND_BY_RESOURCE_TYPE_ID_AND_NAME = "PackageType.findByResourceTypeIdAndName";
public static final String QUERY_FIND_BY_RESOURCE_TYPE_ID_AND_CREATION_FLAG = "PackageType.findByResourceTypeIdAndCreationFlag";
+ public static final String QUERY_DYNAMIC_CONFIG_VALUES = "PackageType.dynamicConfigValues";
+
// Attributes --------------------------------------------
@Column(name = "ID", nullable = false)
@@ -221,7 +228,7 @@ public class PackageType implements Serializable {
/**
* Indicates if this package type will be of any specific architecture. If this is <code>true</code>, each package
* may be of a different architecture. If this is <code>false</code>, all packages will be of architecture
- * "noarch".
+ * "noarch".
*/
public boolean isSupportsArchitecture() {
return supportsArchitecture;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.java
new file mode 100644
index 0000000..dd9f844
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.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.configuration;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.enterprise.server.RHQConstants;
+
+/**
+ * @see DynamicConfigurationPropertyLocal
+ *
+ * @author Jason Dobies
+ */
+@Stateless
+public class DynamicConfigurationPropertyBean implements DynamicConfigurationPropertyLocal {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ @PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
+ private EntityManager entityManager;
+
+ @SuppressWarnings("unchecked")
+ public List<String> lookupValues(String key) {
+
+ String queryName = PropertyExpressionEvaluator.getQueryNameForKey(key);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Lookup value for key [" + key + "] found query name [" + queryName + "]");
+ }
+
+ if (queryName == null) {
+ return Collections.emptyList();
+ }
+
+ Query query = entityManager.createNamedQuery(queryName);
+ List<String> results = query.getResultList();
+
+ return results;
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java
new file mode 100644
index 0000000..613e28c
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java
@@ -0,0 +1,44 @@
+/*
+* 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.configuration;
+
+import java.util.List;
+
+/**
+ * Responsible for retrieving configuration property values from the database.
+ *
+ * @author Jason Dobies
+ */
+public interface DynamicConfigurationPropertyLocal {
+
+ /**
+ * Translates the provided property value key into its corresponding domain query and returns the
+ * results.
+ *
+ * @param key indicates the data being retrieved from the database; should be one of the constants
+ * in {@link PropertyExpressionEvaluator}
+ * @return list of values matching the requested key; empty list if the key is not supported
+ */
+ List<String> lookupValues(String key);
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/PropertyExpressionEvaluator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/PropertyExpressionEvaluator.java
new file mode 100644
index 0000000..4a4993d
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/PropertyExpressionEvaluator.java
@@ -0,0 +1,75 @@
+/*
+* 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.configuration;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.content.PackageType;
+
+/**
+ * Translates the configuration property value lookup key into a named query in the system.
+ *
+ * @see DynamicConfigurationPropertyBean
+ *
+ * @author Jason Dobies
+ */
+public class PropertyExpressionEvaluator {
+
+ public static final String KEY_USERS = "users";
+ public static final String KEY_ROLES = "roles";
+ public static final String KEY_PACKAGE_TYPES = "package-types";
+
+ /**
+ * @see #getQueryNameForKey(String)
+ */
+ private static final Map<String, String> KEY_TO_QUERY_NAME;
+ static {
+ Map<String, String> temp = new HashMap<String, String>();
+
+ temp.put(KEY_USERS, Subject.QUERY_DYNAMIC_CONFIG_VALUES);
+ temp.put(KEY_ROLES, Role.QUERY_DYNAMIC_CONFIG_VALUES);
+ temp.put(KEY_PACKAGE_TYPES, PackageType.QUERY_DYNAMIC_CONFIG_VALUES);
+
+ KEY_TO_QUERY_NAME = Collections.unmodifiableMap(temp);
+ }
+
+ /**
+ * Returns the name of the query to use to retrieve the configuration values for properties
+ * defined with the given key. Each query referenced by the return result should only return
+ * a list of <code>String</code> objects, not any form of complex object (such as <code>Resource</code>
+ * or <code>Subject</code>).
+ *
+ * @param key plugin writer specified key to indicate what values to look up; this should be one
+ * of the KEY_* values defined in this class.
+ * @return name of a named query, where the query is defined elsewhere; <code>null</code> if the
+ * key is not supported by the system
+ */
+ public static String getQueryNameForKey(String key) {
+ return KEY_TO_QUERY_NAME.get(key);
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index e46e8d9..fe9a2ef 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -73,6 +73,8 @@ import org.rhq.enterprise.server.common.EntityManagerFacade;
import org.rhq.enterprise.server.common.EntityManagerFacadeLocal;
import org.rhq.enterprise.server.configuration.ConfigurationManagerBean;
import org.rhq.enterprise.server.configuration.ConfigurationManagerLocal;
+import org.rhq.enterprise.server.configuration.DynamicConfigurationPropertyBean;
+import org.rhq.enterprise.server.configuration.DynamicConfigurationPropertyLocal;
import org.rhq.enterprise.server.configuration.metadata.ConfigurationMetadataManagerBean;
import org.rhq.enterprise.server.configuration.metadata.ConfigurationMetadataManagerLocal;
import org.rhq.enterprise.server.content.AdvisoryManagerBean;
@@ -204,7 +206,7 @@ public final class LookupUtil {
/**
* Returns the main data source that can be used to directly access the database.
- *
+ *
* @return a transactional data source to connect to the database
*/
public static DataSource getDataSource() {
@@ -220,7 +222,7 @@ public final class LookupUtil {
/**
* Returns the transaction manager that you can use for your own managed transactions.
* Use this sparingly and only inside code that is outside of any CMT-scoped objects.
- *
+ *
* @return the transaction manager
*/
public static TransactionManager getTransactionManager() {
@@ -314,6 +316,10 @@ public final class LookupUtil {
return lookupLocal(ConfigurationManagerBean.class);
}
+ public static DynamicConfigurationPropertyLocal getDynamicConfigurationProperty() {
+ return lookupLocal(DynamicConfigurationPropertyBean.class);
+ }
+
public static ConfigurationSubsystemManagerLocal getConfigurationSubsystemManager() {
return lookupLocal(ConfigurationSubsystemManagerBean.class);
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java
new file mode 100644
index 0000000..6367f92
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java
@@ -0,0 +1,164 @@
+/*
+* 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.configuration;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import javax.transaction.NotSupportedException;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.server.test.AbstractEJB3Test;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * @author Jason Dobies
+ */
+public class DynamicConfigurationPropertyBeanTest extends AbstractEJB3Test {
+
+ private static final boolean ENABLED = true;
+
+ private DynamicConfigurationPropertyLocal bean;
+
+ @BeforeMethod
+ public void setUp() {
+ bean = LookupUtil.getDynamicConfigurationProperty();
+ }
+
+ @Test(enabled = ENABLED)
+ public void invalidKey() throws Exception {
+ // Test
+ List<String> stringList = bean.lookupValues("foo");
+
+ // Verify
+ assert stringList != null;
+ assert stringList.size() == 0;
+ }
+
+ @Test(enabled = ENABLED)
+ public void user() throws Exception {
+ // Setup
+ int existingUserCount = countForQuery(Subject.QUERY_FIND_ALL);
+
+ // Test
+ List<String> users = bean.lookupValues(PropertyExpressionEvaluator.KEY_USERS);
+
+ // Verify
+ outputList(users);
+ assert users.size() == existingUserCount : "Expected: " + existingUserCount + ", Found: " + users.size();
+ }
+
+ @Test(enabled = ENABLED)
+ public void roles() throws Exception {
+ // Setup
+ int existingRoleCount = countForQuery(Role.QUERY_FIND_ALL);
+
+ // Test
+ List<String> roles = bean.lookupValues(PropertyExpressionEvaluator.KEY_ROLES);
+
+ // Verify
+ outputList(roles);
+ assert roles.size() == existingRoleCount : "Expected: " + existingRoleCount + ", Found: " + roles.size();
+ }
+
+ @Test(enabled = ENABLED)
+ public void packageType() throws Exception {
+ // Setup
+ ResourceType resourceType = null;
+ PackageType packageType = null;
+
+ TransactionManager tx = getTransactionManager();
+ try {
+ tx.begin();
+ EntityManager entityManager = getEntityManager();
+
+ resourceType = new ResourceType("dynamicConfigPropBeanTestType", "foo", ResourceCategory.PLATFORM, null);
+ entityManager.persist(resourceType);
+
+ packageType = new PackageType("dynamicConfigPropBeanTestType", resourceType);
+ entityManager.persist(packageType);
+ tx.commit();
+ }
+ catch (Exception e) {
+ tx.rollback();
+ }
+
+ int existingPackageTypes = countForQuery(PackageType.QUERY_FIND_ALL);
+ assert existingPackageTypes > 0 : "Package type created in setup was not written correctly";
+
+ // Test
+ List<String> types = bean.lookupValues(PropertyExpressionEvaluator.KEY_PACKAGE_TYPES);
+
+ // Verify
+ assert types.size() == existingPackageTypes : "Expected: " + existingPackageTypes + ", Found: " + types.size();
+
+ // Clean up
+ tx = getTransactionManager();
+ try {
+ tx.begin();
+ EntityManager entityManager = getEntityManager();
+
+ resourceType = entityManager.find(ResourceType.class, resourceType.getId());
+ entityManager.remove(resourceType);
+
+ packageType = entityManager.find(PackageType.class, packageType.getId());
+ entityManager.remove(packageType);
+
+ tx.commit();
+ }
+ catch (Exception e) {
+ tx.rollback();
+ }
+ }
+
+ private int countForQuery(String queryName) throws NotSupportedException, SystemException {
+ getTransactionManager().begin();
+ EntityManager entityManager = getEntityManager();
+
+ Query query = entityManager.createNamedQuery(queryName);
+ List existing = query.getResultList();
+
+ int count = existing.size();
+
+ getTransactionManager().rollback();
+
+ return count;
+ }
+
+ private void outputList(List<String> items) {
+ System.out.println("Items returned from lookupValues:");
+ for (String item : items) {
+ System.out.println(item);
+ }
+ }
+}
commit 299fb0615d893c0f061d45c65c1f7dcd2aa3d10b
Author: John Matthews <jmatthew(a)redhat.com>
Date: Fri Jan 8 16:25:00 2010 -0500
1357 - adding war to expose content through http
diff --git a/modules/enterprise/server/ear/pom.xml b/modules/enterprise/server/ear/pom.xml
index 0666bbe..4ab1ee1 100644
--- a/modules/enterprise/server/ear/pom.xml
+++ b/modules/enterprise/server/ear/pom.xml
@@ -66,6 +66,13 @@
<version>${project.version}</version>
<type>war</type>
</dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-content_http</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ </dependency>
<!-- ** SARs -->
<!--
@@ -168,6 +175,15 @@
<bundleFileName>rhq-webdav.war</bundleFileName>
<contextRoot>/webdav</contextRoot>
</webModule>
+
+ <!-- used to expose content through http -->
+ <webModule>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-content_http</artifactId>
+ <excluded>${exclude-content_http}</excluded>
+ <bundleFileName>rhq-content_http.war</bundleFileName>
+ <contextRoot>/content</contextRoot>
+ </webModule>
<!-- ** EJB-JARs -->
commit 6c15cabd5c29e3a5d4cf543a3d122c0747febd28
Author: John Matthews <jmatthew(a)redhat.com>
Date: Fri Jan 8 16:18:02 2010 -0500
1357 - first step at creating a placeholder for fetching content through http
Intent is to get the guts of http content working from this module
We can refactor this later so it's integrated into RHQ in a cleaner manner.
diff --git a/modules/enterprise/gui/content_http-war/pom.xml b/modules/enterprise/gui/content_http-war/pom.xml
new file mode 100644
index 0000000..50e0ad6
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/pom.xml
@@ -0,0 +1,280 @@
+<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-content_http</artifactId>
+ <packaging>war</packaging>
+
+ <name>RHQ Enterprise Content HTTP Support</name>
+ <description>Provides http export for content in RHQ.</description>
+
+ <scm>
+ <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/gui/con...</connection>
+ <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/gui/con...</developerConnection>
+ </scm>
+
+ <properties>
+ <scm.module.path>modules/enterprise/gui/content_http-war/</scm.module.path>
+ </properties>
+
+ <dependencies>
+
+ <!-- Internal Deps -->
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope> <!-- by rhq.ear (as ejb-jar) -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-gui</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-server</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope> <!-- by rhq.ear (as ejb-jar) -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-util</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope> <!-- by rhq.ear -->
+ </dependency>
+
+ <!-- 3rd Party Deps -->
+
+ <dependency>
+ <groupId>hibernate</groupId>
+ <artifactId>hibernate3</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <!-- used by a test JSP -->
+ <dependency>
+ <groupId>hibernate-entitymanager</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <!-- needed for referenced domain entities that use Hibernate annotations (due to JDK5 bug) -->
+ <dependency>
+ <groupId>hibernate-annotations</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+
+ <!-- needed for referenced domain entities that use JPA annotations (due to JDK5 bug) -->
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <!--
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+ -->
+
+ <!-- adding to pick up javax.servlet.http.HttpServlet -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <!-- adding so we can extend DefaultServlet
+ Chose version 2.0.1 so it's compatible with info here for JBoss 4.2.3
+ http://community.jboss.org/wiki/VersionOfTomcatInJBossAS-->
+ <dependency>
+ <groupId>jboss.web</groupId>
+ <artifactId>jbossweb</artifactId>
+ <version>2.0.1.GA</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <!-- needed for EJB3 annotations (e.g. ApplicationException) -->
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-ejb3x</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.0.1</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.3.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <dependency>
+ <groupId>commons-validator</groupId>
+ <artifactId>commons-validator</artifactId>
+ <version>1.1.4</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>rhq-content_http</finalName>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.1-alpha-1</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ </manifest>
+ <manifestEntries>
+ <Build-Number>${buildNumber}</Build-Number>
+ </manifestEntries>
+ </archive>
+ <webResources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>${basedir}/src/main/webapp</directory>
+ </resource>
+ </webResources>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+
+ <profiles>
+
+ <profile>
+ <id>dev</id>
+
+ <properties>
+ <rhq.rootDir>../../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentName>${project.build.finalName}.war</rhq.deploymentName>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/${rhq.deploymentName}</rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+
+ <execution>
+ <id>deploy-classes</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <property name="classes.dir" location="${rhq.deploymentDir}/WEB-INF/classes" />
+ <echo>*** Copying updated files from target/classes to ${classes.dir}...</echo>
+ <copy todir="${classes.dir}" verbose="${rhq.verbose}">
+ <fileset dir="target/classes" />
+ </copy>
+ <property name="deployment.dir" location="${rhq.deploymentDir}" />
+ <echo>*** Copying updated files from src${file.separator}main${file.separator}webapp${file.separator} to ${deployment.dir}${file.separator}...</echo>
+ <copy todir="${deployment.dir}" verbose="${rhq.verbose}">
+ <fileset dir="${basedir}/src/main/webapp" />
+ </copy>
+ <!-- TODO: Also copy the files from src/main/webapp-filtered/, and then filter them ourselves. -->
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>deploy</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.dir" location="${rhq.deploymentDir}" />
+ <echo>*** Copying updated files from target${file.separator}${project.build.finalName}${file.separator} to ${deployment.dir}${file.separator}...</echo>
+ <copy todir="${deployment.dir}" verbose="${rhq.verbose}">
+ <fileset dir="${basedir}/target/${project.build.finalName}" />
+ </copy>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.dir" location="${rhq.deploymentDir}" />
+ <echo>*** Deleting ${deployment.dir}${file.separator}...</echo>
+ <delete dir="${deployment.dir}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
+</project>
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
new file mode 100644
index 0000000..2ac2061
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -0,0 +1,34 @@
+package org.rhq.gui.content;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.catalina.servlets.DefaultServlet;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+public class ContentHTTPServlet extends DefaultServlet {
+ private final Log log = LogFactory.getLog(ContentHTTPServlet.class);
+
+ public ContentHTTPServlet() {
+ super();
+ }
+
+ public void init() throws ServletException {
+ log.info("** *** ** ** ** *** Inside of ContentHTTPServlet::init()");
+ super.init();
+ }
+
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response)
+ throws IOException, ServletException {
+ log.info("** ** ** Inside of ContentHTTPServlet::doGet()");
+ super.doGet(request, response);
+ }
+}
+
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/WEB-INF/jboss-web.xml b/modules/enterprise/gui/content_http-war/src/main/webapp/WEB-INF/jboss-web.xml
new file mode 100644
index 0000000..e1505f7
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/webapp/WEB-INF/jboss-web.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+
+<jboss-web>
+ <context-root>content</context-root>
+</jboss-web>
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/content_http-war/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..afa7bcd
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+ <display-name>RHQ Content HTTP Support</display-name>
+
+
+ <!-- Export content through http support -->
+ <servlet>
+ <servlet-name>ContentHTTP</servlet-name>
+ <servlet-class>org.rhq.gui.content.ContentHTTPServlet</servlet-class>
+ <!-- <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class> -->
+ <init-param>
+ <param-name>listings</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ <init-param>
+ <param-name>readonly</param-name>
+ <param-value>true</param-value>
+ </init-param>
+
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>ContentHTTP</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+
+</web-app>
+
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/testfile b/modules/enterprise/gui/content_http-war/src/main/webapp/testfile
new file mode 100644
index 0000000..9767b7a
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/webapp/testfile
@@ -0,0 +1,2 @@
+This is a test file
+
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/testfile2 b/modules/enterprise/gui/content_http-war/src/main/webapp/testfile2
new file mode 100644
index 0000000..e5c132d
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/webapp/testfile2
@@ -0,0 +1,2 @@
+This is the second test file
+
commit 5bbf830ec4f443df72f0a5f273c0e7df14b480d8
Merge: 505bfa4... b9e3538...
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Wed Jan 6 13:16:49 2010 -0800
Merge branch 'master' into content
Conflicts:
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
commit 505bfa4fe0453bf3157e166f054aef287334d240
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Wed Jan 6 13:28:55 2010 -0500
fixing db error
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 161ebed..b7d3a0e 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2755,6 +2755,7 @@
ALTER TABLE RHQ_ADVISORY_PACKAGE ALTER COLUMN ID SET DEFAULT NEXTVAL('RHQ_ADVISORY_PKG_SEQ')
</statement>
</schema-directSQL>
+ </schemaSpec>
</dbupgrade>
</target>
</project>
14 years, 4 months
[rhq] Branch 'content' - modules/enterprise
by mazz
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java | 65 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java | 41 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java | 8
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java | 142 ++++++++++
4 files changed, 255 insertions(+), 1 deletion(-)
New commits:
commit 3a72c583b7ce93a12f0779b4cc90a567b6a28917
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 27 15:17:24 2010 -0500
the start of the bundle SLSB and its unit test
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
new file mode 100644
index 0000000..7c52758
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -0,0 +1,65 @@
+/*
+ * 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.bundle;
+
+import java.util.List;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.bundle.Bundle;
+import org.rhq.core.domain.bundle.BundleType;
+import org.rhq.enterprise.server.RHQConstants;
+
+/**
+ * Manages the creation and usage of bundles.
+ *
+ * @author John Mazzitelli
+ */
+@Stateless
+public class BundleManagerBean implements BundleManagerLocal {
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ @PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
+ private EntityManager entityManager;
+
+ public BundleType createBundleType(BundleType bundleType) {
+ entityManager.persist(bundleType);
+ return bundleType;
+ }
+
+ public Bundle createBundle(Bundle bundle) {
+ entityManager.persist(bundle);
+ return bundle;
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<BundleType> getAllBundleTypes() {
+ // the list of types will be small, no need to support paging
+ Query q = entityManager.createNamedQuery(BundleType.QUERY_FIND_ALL);
+ List<BundleType> types = q.getResultList();
+ return types;
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java
new file mode 100644
index 0000000..6adff52
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java
@@ -0,0 +1,41 @@
+/*
+ * 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.bundle;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.rhq.core.domain.bundle.Bundle;
+import org.rhq.core.domain.bundle.BundleType;
+
+/**
+ * Local interface to the manager responsible for creating and managing bundles.
+ *
+ * @author John Mazzitelli
+ */
+@Local
+public interface BundleManagerLocal {
+ BundleType createBundleType(BundleType bundleType);
+
+ Bundle createBundle(Bundle b);
+
+ List<BundleType> getAllBundleTypes();
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index fdddc60..dc9ae11 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -55,6 +55,8 @@ import org.rhq.enterprise.server.authz.AuthorizationManagerBean;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.RoleManagerBean;
import org.rhq.enterprise.server.authz.RoleManagerLocal;
+import org.rhq.enterprise.server.bundle.BundleManagerBean;
+import org.rhq.enterprise.server.bundle.BundleManagerLocal;
import org.rhq.enterprise.server.cloud.AffinityGroupManagerBean;
import org.rhq.enterprise.server.cloud.AffinityGroupManagerLocal;
import org.rhq.enterprise.server.cloud.CloudManagerBean;
@@ -101,8 +103,8 @@ import org.rhq.enterprise.server.core.EmailManagerLocal;
import org.rhq.enterprise.server.core.plugin.PluginDeploymentScannerMBean;
import org.rhq.enterprise.server.discovery.DiscoveryBossBean;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
-import org.rhq.enterprise.server.entitlement.EntitlementManagerLocal;
import org.rhq.enterprise.server.entitlement.EntitlementManagerBean;
+import org.rhq.enterprise.server.entitlement.EntitlementManagerLocal;
import org.rhq.enterprise.server.event.EventManagerBean;
import org.rhq.enterprise.server.event.EventManagerLocal;
import org.rhq.enterprise.server.measurement.AvailabilityManagerBean;
@@ -314,6 +316,10 @@ public final class LookupUtil {
return lookupLocal(AvailabilityManagerBean.class);
}
+ public static BundleManagerLocal getBundleManager() {
+ return lookupLocal(BundleManagerBean.class);
+ }
+
public static CallTimeDataManagerLocal getCallTimeDataManager() {
return lookupLocal(CallTimeDataManagerBean.class);
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
new file mode 100644
index 0000000..90888f1
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
@@ -0,0 +1,142 @@
+/*
+ * 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.bundle;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.bundle.Bundle;
+import org.rhq.core.domain.bundle.BundleType;
+import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.enterprise.server.test.AbstractEJB3Test;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * @author John Mazzitelli
+ */
+@Test
+public class BundleManagerBeanTest extends AbstractEJB3Test {
+
+ private static final String TEST_PREFIX = "bundletest";
+
+ private BundleManagerLocal bundleManagerBean;
+
+ @BeforeMethod
+ public void beforeMethod() {
+ bundleManagerBean = LookupUtil.getBundleManager();
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void afterMethod() {
+
+ EntityManager em = null;
+
+ try {
+ getTransactionManager().begin();
+ em = getEntityManager();
+
+ Query q;
+ List doomed;
+
+ // clean up any tests that don't already clean up after themselves
+ q = em.createQuery("SELECT bv FROM BundleVersion bv WHERE bv.bundle.name LIKE '" + TEST_PREFIX + "%'");
+ doomed = q.getResultList();
+ for (Object removeMe : doomed) {
+ em.remove(em.getReference(BundleVersion.class, ((BundleVersion) removeMe).getId()));
+ }
+
+ q = em.createQuery("SELECT b FROM Bundle b WHERE b.name LIKE '" + TEST_PREFIX + "%'");
+ doomed = q.getResultList();
+ for (Object removeMe : doomed) {
+ em.remove(em.getReference(Bundle.class, ((Bundle) removeMe).getId()));
+ }
+
+ q = em.createQuery("SELECT bt FROM BundleType bt WHERE bt.name LIKE '" + TEST_PREFIX + "%'");
+ doomed = q.getResultList();
+ for (Object removeMe : doomed) {
+ em.remove(em.getReference(BundleType.class, ((BundleType) removeMe).getId()));
+ }
+
+ getTransactionManager().commit();
+ em.close();
+ em = null;
+ } catch (Exception e) {
+ try {
+ System.out.println("CANNOT CLEAN UP TEST: Cause: " + e);
+ getTransactionManager().rollback();
+ } catch (Exception ignore) {
+ }
+ } finally {
+ if (null != em) {
+ em.close();
+ }
+ }
+ }
+
+ public void testGetBundleTypes() throws Exception {
+ BundleType bt1 = createBundleType("one");
+ BundleType bt2 = createBundleType("two");
+ List<BundleType> bts = bundleManagerBean.getAllBundleTypes();
+ assert bts.size() >= 2 : "should have at least 2 bundle types";
+
+ List<String> btNames = new ArrayList<String>();
+ for (BundleType bundleType : bts) {
+ btNames.add(bundleType.getName());
+ }
+
+ assert btNames.contains(bt1.getName());
+ assert btNames.contains(bt2.getName());
+ }
+
+ private Bundle createBundle(String name) throws Exception {
+ BundleType bt = createBundleType(name);
+ return createBundle(name, bt);
+ }
+
+ private Bundle createBundle(String name, BundleType bt) throws Exception {
+ final String fullName = TEST_PREFIX + "-bundle-" + name;
+ Bundle b = new Bundle(fullName, bt);
+ b = bundleManagerBean.createBundle(b);
+ assert b.getId() > 0;
+ assert b.getName().endsWith(fullName);
+ return b;
+ }
+
+ private BundleType createBundleType(String name) throws Exception {
+ final String fullName = TEST_PREFIX + "-type-" + name;
+ BundleType bt = new BundleType(fullName);
+ bt = bundleManagerBean.createBundleType(bt);
+ assert bt.getId() > 0;
+ assert bt.getName().endsWith(fullName);
+ return bt;
+ }
+
+ private Subject getOverlord() {
+ return LookupUtil.getSubjectManager().getOverlord();
+ }
+}
14 years, 4 months
[rhq] Branch 'alertPlugin' - 99 commits - .classpath modules/core modules/enterprise modules/plugins
by jharris
.classpath | 6
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java | 4
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java | 26
modules/core/client-api/src/main/resources/rhq-configuration.xsd | 50
modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml | 4
modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml | 67
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 238 +++
modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java | 7
modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java | 7
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java | 150 ++
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleConfig.java | 156 ++
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java | 134 +
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentPK.java | 122 +
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleFile.java | 169 ++
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleType.java | 125 +
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java | 195 ++
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersionRepo.java | 132 +
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersionRepoPK.java | 122 +
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyDefinitionDynamic.java | 82 +
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyDynamicType.java | 33
modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java | 11
modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryBuglist.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryPackage.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java | 10
modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java | 14
modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java | 11
modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java | 41
modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java | 17
modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java | 68 +
modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/SubscribedRepo.java | 47
modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java | 345 +++++
modules/core/domain/src/test/java/org/rhq/core/domain/content/test/RepoTest.java | 54
modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java | 15
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractPropertyBagUIComponentTreeFactory.java | 66
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java | 52
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java | 107 +
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/PropertySetRenderer.java | 15
modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java | 8
modules/core/util/src/test/java/org/rhq/core/util/progresswatch/ProgressWatcherTest.java | 10
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java | 7
modules/enterprise/gui/content_http-war/pom.xml | 292 ++++
modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java | 42
modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java | 680 ++++++++++
modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/EntitlementException.java | 62
modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java | 122 +
modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/YumMetadata.java | 167 ++
modules/enterprise/gui/content_http-war/src/main/webapp/WEB-INF/jboss-web.xml | 5
modules/enterprise/gui/content_http-war/src/main/webapp/WEB-INF/web.xml | 33
modules/enterprise/gui/content_http-war/src/main/webapp/icons/back.gif |binary
modules/enterprise/gui/content_http-war/src/main/webapp/icons/blank.gif |binary
modules/enterprise/gui/content_http-war/src/main/webapp/icons/bomb.gif |binary
modules/enterprise/gui/content_http-war/src/main/webapp/icons/folder.gif |binary
modules/enterprise/gui/content_http-war/src/main/webapp/icons/text.gif |binary
modules/enterprise/gui/content_http-war/src/main/webapp/icons/unknown.gif |binary
modules/enterprise/gui/content_http-war/src/main/webapp/testfile | 2
modules/enterprise/gui/content_http-war/src/main/webapp/testfile2 | 2
modules/enterprise/gui/pom.xml | 3
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PageControlView.java | 3
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java | 46
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java | 38
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/ResourceUpdatePackageVersionsUIBean.java | 71 +
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java | 87 -
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java | 22
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java | 15
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/content-beans.xml | 5
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/content-navigation.xml | 20
modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml | 89 +
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/update.xhtml | 154 ++
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/layout/main-no-leftnav.xhtml | 1
modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java | 42
modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml | 10
modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/WsRepoManagerTest.java | 33
modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java | 118 +
modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsDistributionManagerTest.java | 90 +
modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java | 76 +
modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsUnitTestBase.java | 72 +
modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java | 118 +
modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsSubjectUtility.java | 153 ++
modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml | 2
modules/enterprise/server/ear/pom.xml | 16
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.java | 69 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java | 44
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/PropertyExpressionEvaluator.java | 75 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java | 61
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerLocal.java | 12
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java | 19
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerBean.java | 77 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentSourceManagerLocal.java | 51
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java | 129 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerLocal.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java | 20
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java | 20
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java | 22
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DummyLoader.java | 63
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java | 38
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerLocal.java | 25
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerRemote.java | 29
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java | 89 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerLocal.java | 18
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerRemote.java | 14
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/AdvisorySource.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java | 530 ++++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentServerPluginContainer.java | 103 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/DistributionSource.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/PackageSource.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncException.java | 35
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncTracker.java | 10
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ThreadUtil.java | 17
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java | 16
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/DistributionSourceSynchronizer.java | 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/PackageSourceSynchronizer.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationException.java | 38
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java | 243 +++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerLocal.java | 52
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerRemote.java | 52
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/ReleaseRepoMapping.java | 76 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 19
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/RepoSyncJob.java | 51
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java | 25
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java | 14
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java | 183 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java | 14
modules/enterprise/server/jar/src/test/java/javax/ejb/EJBTransactionRolledbackException.java | 58
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java | 164 ++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/QuartzScheduleFormatTest.java | 55
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java | 38
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java | 47
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java | 140 +-
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java | 113 +
modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java | 20
modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml | 17
modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java | 31
modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/RssFeedParser.java | 23
modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml | 12
modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNHelper.java | 42
modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java | 55
modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java | 2
modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java | 16
modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java | 8
modules/plugins/kickstart/pom.xml | 2
modules/plugins/kickstart/src/main/java/org/rhq/plugins/kickstart/KickstartServerComponent.java | 25
modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java | 52
145 files changed, 7981 insertions(+), 751 deletions(-)
New commits:
commit d2913885ba5aeee5d6efcdca1350b0a70bbcff61
Merge: 2dde4f5... c5470ae...
Author: Justin Harris <jharris(a)redhat.com>
Date: Wed Jan 27 13:58:28 2010 -0500
Merge remote branch 'origin/master' into alertPlugin
commit c5470ae79abb7ba7d7814d0f4feb08776f9dc798
Author: Bryan Kearney <bkearney(a)redhat.com>
Date: Wed Jan 27 13:09:25 2010 -0500
Catch koan failures and record them
diff --git a/modules/plugins/kickstart/src/main/java/org/rhq/plugins/kickstart/KickstartServerComponent.java b/modules/plugins/kickstart/src/main/java/org/rhq/plugins/kickstart/KickstartServerComponent.java
index de56c4a..ed7f03d 100644
--- a/modules/plugins/kickstart/src/main/java/org/rhq/plugins/kickstart/KickstartServerComponent.java
+++ b/modules/plugins/kickstart/src/main/java/org/rhq/plugins/kickstart/KickstartServerComponent.java
@@ -61,9 +61,15 @@ public class KickstartServerComponent implements ResourceComponent, OperationFac
String virtName = configuration.getSimpleValue("name", "Guest " + System.currentTimeMillis());
String profile = configuration.getSimpleValue("profile", "profile");
String server = configuration.getSimpleValue("server", "localhost");
- ProcessExecutionResults pr = this.execute(command, "--virt", "--server", server, "--profile", profile,
- "--virt-name", virtName);
- res.setSimpleResult(pr.getExitCode().toString());
+ String[] argsString = { "--virt", "--server", server, "--profile", profile, "--virt-name", virtName };
+ ProcessExecutionResults pr = this.execute(command, argsString);
+ if (pr.getExitCode() > 0) {
+ log.error("Error executing command: " + this.buildCommandString(command, argsString));
+ res.setErrorMessage(pr.getCapturedOutput());
+ } else {
+ res.setSimpleResult(pr.getCapturedOutput());
+ }
+
}
return res;
@@ -72,10 +78,7 @@ public class KickstartServerComponent implements ResourceComponent, OperationFac
public ProcessExecutionResults execute(String process, String... args) {
List<String> argsList = Arrays.asList(args);
if (log.isDebugEnabled()) {
- String argsString = "";
- for (String arg : argsList)
- argsString = argsString + " " + arg;
- log.debug("Executing command " + process + argsString);
+ log.debug("Executing command " + this.buildCommandString(process, args));
}
ProcessExecution pe = new ProcessExecution(process);
pe.setCaptureOutput(true);
@@ -85,4 +88,12 @@ public class KickstartServerComponent implements ResourceComponent, OperationFac
log.debug("Result " + pr.getExitCode());
return pr;
}
+
+ private String buildCommandString(String process, String... argsList) {
+ String argsString = process;
+ for (String arg : argsList)
+ argsString = argsString + " " + arg;
+ return process;
+
+ }
}
commit 03ec3f8d46c55615ce0f256eee607302d4feed36
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 27 12:08:09 2010 -0500
trivial fix to a javadoc comment
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
index e77df6f..32a7398 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
@@ -289,10 +289,7 @@ public class AgentMain {
private boolean m_advancedSetup = false;
/**
- * If the agent was told to setup (via a command line option), this will be trueneeds to be setup when it is first
- * initialized, by default the basic setup will run which asks the user for some basic, minimal information
- * necessary to get the agent started. However, if this flag is <code>true</code>, the advanced setup will run as
- * opposed to the basic setup.
+ * If the agent was told to setup (via a command line option), this will be true.
*/
private boolean m_forcedSetup = false;
@@ -3312,4 +3309,4 @@ public class AgentMain {
return this.serverEndpoint + "@" + new Date(this.timestamp);
}
}
-}
\ No newline at end of file
+}
commit ebaf42d67c501e1383e8e08eaa95ae58fdc5f77e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 27 12:03:26 2010 -0500
change the blob column to clob since this really is text of the action script/receipt and not raw binary data
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
index d558c09..d1ae3ad 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -505,7 +505,7 @@
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="NAME" size="200" type="VARCHAR2" required="true"/>
<column name="VERSION" size="500" type="VARCHAR2" required="true"/>
- <column name="ACTION" type="BLOB" required="true"/>
+ <column name="ACTION" type="CLOB" required="true"/>
<column name="BUNDLE_ID" type="INTEGER" required="true" references="RHQ_BUNDLE"/>
<column name="DISTRIBUTION_ID" type="INTEGER" required="false" references="RHQ_DISTRIBUTION"/>
</table>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 3eca05e..dd16274 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2826,7 +2826,7 @@
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="NAME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="VERSION" columnType="VARCHAR2" precision="500" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="VERSION" nullable="FALSE" />
- <schema-addColumn table="RHQ_BUNDLE_VERSION" column="ACTION" columnType="BLOB" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="ACTION" columnType="CLOB" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="ACTION" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" nullable="FALSE" />
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
index a4c4d31..f2ea97c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
@@ -72,7 +72,7 @@ public class BundleVersion implements Serializable {
private String version;
@Column(name = "ACTION", nullable = false)
- private byte[] action;
+ private String action;
@JoinColumn(name = "BUNDLE_ID", referencedColumnName = "ID", nullable = false)
@ManyToOne(fetch = FetchType.LAZY)
@@ -116,11 +116,11 @@ public class BundleVersion implements Serializable {
this.version = version;
}
- public byte[] getAction() {
+ public String getAction() {
return action;
}
- public void setAction(byte[] action) {
+ public void setAction(String action) {
this.action = action;
}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
index f4ee5d4..0ac6459 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
@@ -22,7 +22,6 @@
*/
package org.rhq.core.domain.bundle.test;
-import java.util.Arrays;
import java.util.List;
import javax.persistence.EntityManager;
@@ -49,7 +48,7 @@ public class BundleTest extends AbstractEJB3Test {
int id;
String name = "BundleTest-testBundleVersionRepo";
- byte[] action = "action/script/recipe is here".getBytes();
+ String action = "action/script/recipe is here";
Repo repo1 = new Repo(name + "-Repo1");
Repo repo2 = new Repo(name + "-Repo2");
@@ -126,7 +125,7 @@ public class BundleTest extends AbstractEJB3Test {
int id;
String name = "BundleTest-testBundleVersion";
- byte[] action = "action/script/recipe is here".getBytes();
+ String action = "action/script/recipe is here";
BundleType bundleType = new BundleType(name + "-Type");
Bundle bundle = new Bundle(name + "-Bundle", bundleType);
@@ -155,7 +154,7 @@ public class BundleTest extends AbstractEJB3Test {
assert bvFind.getId() == bv.getId();
assert bvFind.getName().equals(bv.getName());
assert bvFind.getVersion().equals(bv.getVersion());
- assert Arrays.equals(bvFind.getAction(), bv.getAction());
+ assert bvFind.getAction().equals(bv.getAction());
assert bvFind.getBundle().equals(bv.getBundle());
assert bvFind.equals(bv);
assert bvFind.hashCode() == bv.hashCode();
commit 83590bcca95e79ea331bcb2a9c20737bee8d4321
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 11:33:40 2010 -0500
Fixed botched merge.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index 1fe5bab..fdddc60 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -101,6 +101,7 @@ import org.rhq.enterprise.server.core.EmailManagerLocal;
import org.rhq.enterprise.server.core.plugin.PluginDeploymentScannerMBean;
import org.rhq.enterprise.server.discovery.DiscoveryBossBean;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
+import org.rhq.enterprise.server.entitlement.EntitlementManagerLocal;
import org.rhq.enterprise.server.entitlement.EntitlementManagerBean;
import org.rhq.enterprise.server.event.EventManagerBean;
import org.rhq.enterprise.server.event.EventManagerLocal;
@@ -345,7 +346,7 @@ public final class LookupUtil {
return lookupLocal(EmailManagerBean.class);
}
- public static EntitlementStuffManagerLocal getEntitlementManagerBean() {
+ public static EntitlementManagerLocal getEntitlementManagerBean() {
return lookupLocal(EntitlementManagerBean.class);
}
commit af588cb39b0696357217014771036e5a164c5137
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 10:19:12 2010 -0500
Turns out, when merging master into content there were two EJBs named EntitlementManagerBean. This really, really makes JBoss unhappy. Temporarily moved the prototype one out of the way.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
deleted file mode 100644
index 999a655..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.rhq.enterprise.server.content;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ejb.Stateless;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.core.domain.content.transfer.EntitlementCertificate;
-import org.rhq.enterprise.server.authz.RequiredPermission;
-
-@Stateless
-public class EntitlementManagerBean implements EntitlementManagerLocal, EntitlementManagerRemote {
-
- private final Log log = LogFactory.getLog(EntitlementManagerBean.class);
-
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
- List<EntitlementCertificate> list = new ArrayList<EntitlementCertificate>();
- DummyLoader loader = new DummyLoader();
- try {
- list.add(loader.load(resourceId));
-
- } catch (Exception ex) {
- log.warn("x.509 cert for: " //
- + resourceId //
- + " not-found in: " //
- + DummyLoader.dir);
- }
- return list;
- }
-
-}
-
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerLocal.java
deleted file mode 100644
index 8fe2554..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerLocal.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.rhq.enterprise.server.content;
-
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.content.transfer.EntitlementCertificate;
-
-/**
- *
- * @author jortel
- *
- */
-@Local
-public interface EntitlementManagerLocal {
-
- /**
- * Get a list of entitlement certificates for the specified resources.
- * @param subject The logged in user's subject.
- * @param resourceId The resource id.
- * @return A list of certificates.
- */
- List<EntitlementCertificate> getCertificates(Subject subject, int resourceId);
-}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerRemote.java
deleted file mode 100644
index 16f1a0a..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerRemote.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.rhq.enterprise.server.content;
-
-import java.util.List;
-
-import javax.ejb.Remote;
-import javax.jws.WebMethod;
-import javax.jws.WebParam;
-import javax.jws.WebService;
-import javax.jws.soap.SOAPBinding;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.content.transfer.EntitlementCertificate;
-import org.rhq.enterprise.server.system.ServerVersion;
-
-@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
-@WebService(targetNamespace = ServerVersion.namespace)
-@Remote
-public interface EntitlementManagerRemote {
- /**
- * Get a list of entitlement certificates for the specified resources.
- * @param subject The logged in user's subject.
- * @param resourceId The resource id.
- * @return A list of certificates.
- */
- @WebMethod
- List<EntitlementCertificate> getCertificates( //
- @WebParam(name = "subject") Subject subject, //
- @WebParam(name = "resourceId") int resourceId);
-}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java
new file mode 100644
index 0000000..9e3e69e
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java
@@ -0,0 +1,38 @@
+package org.rhq.enterprise.server.content;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Stateless;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
+import org.rhq.enterprise.server.authz.RequiredPermission;
+
+@Stateless
+public class EntitlementStuffManagerBean implements EntitlementStuffManagerLocal, EntitlementStuffManagerRemote {
+
+ private final Log log = LogFactory.getLog(EntitlementStuffManagerBean.class);
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
+ List<EntitlementCertificate> list = new ArrayList<EntitlementCertificate>();
+ DummyLoader loader = new DummyLoader();
+ try {
+ list.add(loader.load(resourceId));
+
+ } catch (Exception ex) {
+ log.warn("x.509 cert for: " //
+ + resourceId //
+ + " not-found in: " //
+ + DummyLoader.dir);
+ }
+ return list;
+ }
+
+}
+
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerLocal.java
new file mode 100644
index 0000000..7eb4f8c
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerLocal.java
@@ -0,0 +1,25 @@
+package org.rhq.enterprise.server.content;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
+
+/**
+ *
+ * @author jortel
+ *
+ */
+@Local
+public interface EntitlementStuffManagerLocal {
+
+ /**
+ * Get a list of entitlement certificates for the specified resources.
+ * @param subject The logged in user's subject.
+ * @param resourceId The resource id.
+ * @return A list of certificates.
+ */
+ List<EntitlementCertificate> getCertificates(Subject subject, int resourceId);
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerRemote.java
new file mode 100644
index 0000000..6050a70
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerRemote.java
@@ -0,0 +1,29 @@
+package org.rhq.enterprise.server.content;
+
+import java.util.List;
+
+import javax.ejb.Remote;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
+import org.rhq.enterprise.server.system.ServerVersion;
+
+@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
+@WebService(targetNamespace = ServerVersion.namespace)
+@Remote
+public interface EntitlementStuffManagerRemote {
+ /**
+ * Get a list of entitlement certificates for the specified resources.
+ * @param subject The logged in user's subject.
+ * @param resourceId The resource id.
+ * @return A list of certificates.
+ */
+ @WebMethod
+ List<EntitlementCertificate> getCertificates( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "resourceId") int resourceId);
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index e11d8b7..1fe5bab 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -87,8 +87,8 @@ import org.rhq.enterprise.server.content.ContentUIManagerBean;
import org.rhq.enterprise.server.content.ContentUIManagerLocal;
import org.rhq.enterprise.server.content.DistributionManagerBean;
import org.rhq.enterprise.server.content.DistributionManagerLocal;
-import org.rhq.enterprise.server.content.EntitlementManagerBean;
-import org.rhq.enterprise.server.content.EntitlementManagerLocal;
+import org.rhq.enterprise.server.content.EntitlementStuffManagerBean;
+import org.rhq.enterprise.server.content.EntitlementStuffManagerLocal;
import org.rhq.enterprise.server.content.RepoManagerBean;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.content.metadata.ContentSourceMetadataManagerBean;
@@ -101,6 +101,7 @@ import org.rhq.enterprise.server.core.EmailManagerLocal;
import org.rhq.enterprise.server.core.plugin.PluginDeploymentScannerMBean;
import org.rhq.enterprise.server.discovery.DiscoveryBossBean;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
+import org.rhq.enterprise.server.entitlement.EntitlementManagerBean;
import org.rhq.enterprise.server.event.EventManagerBean;
import org.rhq.enterprise.server.event.EventManagerLocal;
import org.rhq.enterprise.server.measurement.AvailabilityManagerBean;
@@ -344,7 +345,7 @@ public final class LookupUtil {
return lookupLocal(EmailManagerBean.class);
}
- public static EntitlementManagerLocal getEntitlementManagerBean() {
+ public static EntitlementStuffManagerLocal getEntitlementManagerBean() {
return lookupLocal(EntitlementManagerBean.class);
}
@@ -432,8 +433,8 @@ public final class LookupUtil {
return lookupLocal(RepoManagerBean.class);
}
- public static EntitlementManagerLocal getEntitlementManager() {
- return lookupLocal(EntitlementManagerBean.class);
+ public static EntitlementStuffManagerLocal getEntitlementManager() {
+ return lookupLocal(EntitlementStuffManagerBean.class);
}
public static DistributionManagerLocal getDistributionManagerLocal() {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index b427713..a111f46 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -117,7 +117,7 @@ import org.rhq.enterprise.server.content.AdvisoryManagerLocal;
import org.rhq.enterprise.server.content.ContentManagerLocal;
import org.rhq.enterprise.server.content.DistributionException;
import org.rhq.enterprise.server.content.DistributionManagerLocal;
-import org.rhq.enterprise.server.content.EntitlementManagerLocal;
+import org.rhq.enterprise.server.content.EntitlementStuffManagerLocal;
import org.rhq.enterprise.server.content.RepoException;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
@@ -196,7 +196,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
private SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
private SupportManagerLocal supportManager = LookupUtil.getSupportManager();
private SystemManagerLocal systemManager = LookupUtil.getSystemManager();
- private EntitlementManagerLocal entitlementManager = LookupUtil.getEntitlementManager();
+ private EntitlementStuffManagerLocal entitlementManager = LookupUtil.getEntitlementManager();
//ADVISORYMANAGER: BEGIN ------------------------------------------
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
index 86d48cf..8ddfc49 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
@@ -12,7 +12,7 @@ import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
import org.rhq.enterprise.server.content.AdvisoryManagerRemote;
import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.DistributionManagerRemote;
-import org.rhq.enterprise.server.content.EntitlementManagerRemote;
+import org.rhq.enterprise.server.content.EntitlementStuffManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
@@ -43,7 +43,7 @@ public interface WebservicesRemote extends //
AvailabilityManagerRemote,//
CallTimeDataManagerRemote,//
RepoManagerRemote,//
- EntitlementManagerRemote, //
+ EntitlementStuffManagerRemote, //
ConfigurationManagerRemote,//
ContentManagerRemote,//
//Removed as it was problematic for WS clients. Not sure if this well be re-enabled.
commit a80b205dafc0a1f196f9a9a1b60fd8bac05ca250
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 09:43:27 2010 -0500
Oops, my IDE accidentally added some testing changes to the index, undoing part of that last commit.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DummyLoader.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DummyLoader.java
new file mode 100644
index 0000000..63dbb7b
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DummyLoader.java
@@ -0,0 +1,63 @@
+/*
+* 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.content;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
+
+/**
+ * @author Jason Dobies
+ */
+public class DummyLoader {
+
+ static final String dir = "/etc/pki/rhq";
+
+ EntitlementCertificate load(int resourceId) throws IOException {
+ String name = String.valueOf(resourceId);
+ EntitlementCertificate x509 = load("client");
+ x509.setName(name);
+ return x509;
+ }
+
+ EntitlementCertificate load(String name) throws IOException {
+ String key = read(name + ".key");
+ String pem = read(name + ".pem");
+ return new EntitlementCertificate(name, key, pem);
+ }
+
+ private String read(String fn) throws IOException {
+ String path = dir + File.separator + fn;
+ File f = new File(path);
+ byte[] buffer = new byte[(int) f.length()];
+ BufferedInputStream istr = new BufferedInputStream(new FileInputStream(f));
+ istr.read(buffer);
+ String result = new String(buffer);
+ istr.close();
+ return result;
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java
deleted file mode 100644
index 6620486..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.rhq.enterprise.server.content;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ejb.Stateless;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.core.domain.content.transfer.EntitlementCertificate;
-import org.rhq.enterprise.server.authz.RequiredPermission;
-
-@Stateless
-public class EntitlementStuffManagerBean implements EntitlementManagerLocal, EntitlementManagerRemote {
-
- private final Log log = LogFactory.getLog(EntitlementStuffManagerBean.class);
-
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
- List<EntitlementCertificate> list = new ArrayList<EntitlementCertificate>();
- DummyLoader loader = new DummyLoader();
- try {
- list.add(loader.load(resourceId));
-
- } catch (Exception ex) {
- log.warn("x.509 cert for: " //
- + resourceId //
- + " not-found in: " //
- + DummyLoader.dir);
- }
- return list;
- }
-
-}
-
commit 3fef1f546e7d1df40bd5007dfca79c0b34070768
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 09:41:12 2010 -0500
This needs to return the bean, not the local interface.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
index 7220970..999a655 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
@@ -1,9 +1,5 @@
package org.rhq.enterprise.server.content;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -37,33 +33,6 @@ public class EntitlementManagerBean implements EntitlementManagerLocal, Entitlem
}
return list;
}
-}
-
-class DummyLoader {
-
- static final String dir = "/etc/pki/rhq";
-
- EntitlementCertificate load(int resourceId) throws IOException {
- String name = String.valueOf(resourceId);
- EntitlementCertificate x509 = load("client");
- x509.setName(name);
- return x509;
- }
- EntitlementCertificate load(String name) throws IOException {
- String key = read(name + ".key");
- String pem = read(name + ".pem");
- return new EntitlementCertificate(name, key, pem);
- }
-
- private String read(String fn) throws IOException {
- String path = dir + File.separator + fn;
- File f = new File(path);
- byte[] buffer = new byte[(int) f.length()];
- BufferedInputStream istr = new BufferedInputStream(new FileInputStream(f));
- istr.read(buffer);
- String result = new String(buffer);
- istr.close();
- return result;
- }
}
+
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java
new file mode 100644
index 0000000..6620486
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementStuffManagerBean.java
@@ -0,0 +1,38 @@
+package org.rhq.enterprise.server.content;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Stateless;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
+import org.rhq.enterprise.server.authz.RequiredPermission;
+
+@Stateless
+public class EntitlementStuffManagerBean implements EntitlementManagerLocal, EntitlementManagerRemote {
+
+ private final Log log = LogFactory.getLog(EntitlementStuffManagerBean.class);
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
+ List<EntitlementCertificate> list = new ArrayList<EntitlementCertificate>();
+ DummyLoader loader = new DummyLoader();
+ try {
+ list.add(loader.load(resourceId));
+
+ } catch (Exception ex) {
+ log.warn("x.509 cert for: " //
+ + resourceId //
+ + " not-found in: " //
+ + DummyLoader.dir);
+ }
+ return list;
+ }
+
+}
+
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index fb185c8..e11d8b7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -345,7 +345,7 @@ public final class LookupUtil {
}
public static EntitlementManagerLocal getEntitlementManagerBean() {
- return lookupLocal(EntitlementManagerLocal.class);
+ return lookupLocal(EntitlementManagerBean.class);
}
public static EntityManagerFacadeLocal getEntityManagerFacade() {
commit 99c5d3d471d195eac0cdfec4ba92952e451979d0
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 09:03:06 2010 -0500
Fixed incorrect logger declaration.
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java
index 0904ee5..f61ca7b 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java
@@ -7,11 +7,9 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.enterprise.server.content.EntitlementManagerBean;
-
public class ContentFilter {
- private final Log log = LogFactory.getLog(EntitlementManagerBean.class);
+ private final Log log = LogFactory.getLog(ContentFilter.class);
static final String CERTS = "javax.servlet.request.X509Certificate";
commit e8345020f585e0780a91a628fede0c90ad5919c2
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 08:36:12 2010 -0500
Removed invalid import.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index cd14ebc..fb185c8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -101,7 +101,6 @@ import org.rhq.enterprise.server.core.EmailManagerLocal;
import org.rhq.enterprise.server.core.plugin.PluginDeploymentScannerMBean;
import org.rhq.enterprise.server.discovery.DiscoveryBossBean;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
-import org.rhq.enterprise.server.entitlement.EntitlementManagerLocal;
import org.rhq.enterprise.server.event.EventManagerBean;
import org.rhq.enterprise.server.event.EventManagerLocal;
import org.rhq.enterprise.server.measurement.AvailabilityManagerBean;
commit d8fd6998dee8eeaa2d337412f839943221624825
Merge: d50e6c3... 9ba9416...
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 08:25:52 2010 -0500
Merge branch 'master' into content
Conflicts:
.classpath
modules/core/dbutils/pom.xml
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml
diff --cc modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 6da02b6,21cd3c7..3eca05e
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@@ -2757,242 -2757,25 +2757,262 @@@
</schema-directSQL>
</schemaSpec>
+ <schemaSpec version="2.75">
+ <schema-addColumn table="RHQ_REPO" column="SYNC_SCHEDULE" columnType="VARCHAR2" precision="64" />
+ </schemaSpec>
+
+ <schemaSpec version="2.76">
+ <schema-addColumn table="RHQ_CONFIG_PROP_DEF" column="DYNAMIC_TYPE" columnType="VARCHAR2" precision="20" />
+ <schema-addColumn table="RHQ_CONFIG_PROP_DEF" column="DYNAMIC_KEY" columnType="VARCHAR2" precision="128" />
+ </schemaSpec>
+
+ <schemaSpec version="2.76.1">
+ <!-- RHQ_BUNDLE_TYPE -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_TYPE">
+ CREATE TABLE RHQ_BUNDLE_TYPE ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_TYPE" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_TYPE_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_TYPE">
+ ALTER TABLE RHQ_BUNDLE_TYPE ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_TYPE" column="NAME" columnType="VARCHAR2" precision="200" />
+ <schema-alterColumn table="RHQ_BUNDLE_TYPE" column="NAME" nullable="FALSE" />
+
+ <!-- RHQ_BUNDLE -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE">
+ CREATE TABLE RHQ_BUNDLE ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE">
+ ALTER TABLE RHQ_BUNDLE ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE" column="NAME" columnType="VARCHAR2" precision="200" />
+ <schema-alterColumn table="RHQ_BUNDLE" column="NAME" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE" column="BUNDLE_TYPE_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE" column="BUNDLE_TYPE_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE foreign key relation to RHQ_BUNDLE_TYPE">
+ ALTER TABLE RHQ_BUNDLE
+ ADD CONSTRAINT RHQ_BUNDLE_TYPE_ID_FK
+ FOREIGN KEY (BUNDLE_TYPE_ID)
+ REFERENCES RHQ_BUNDLE_TYPE (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_VERSION -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_VERSION">
+ CREATE TABLE RHQ_BUNDLE_VERSION ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_VERSION_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_VERSION ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="NAME" columnType="VARCHAR2" precision="200" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="NAME" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="VERSION" columnType="VARCHAR2" precision="500" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="VERSION" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="ACTION" columnType="BLOB" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="ACTION" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION foreign key relation to RHQ_BUNDLE">
+ ALTER TABLE RHQ_BUNDLE_VERSION
+ ADD CONSTRAINT RHQ_BUNDLE_ID_FK
+ FOREIGN KEY (BUNDLE_ID)
+ REFERENCES RHQ_BUNDLE (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="DISTRIBUTION_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION foreign key relation to RHQ_DISTRIBUTION">
+ ALTER TABLE RHQ_BUNDLE_VERSION
+ ADD CONSTRAINT RHQ_DISTRIBUTION_ID_FK
+ FOREIGN KEY (DISTRIBUTION_ID)
+ REFERENCES RHQ_DISTRIBUTION (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_VERSION_REPO -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_VERSION_REPO">
+ CREATE TABLE RHQ_BUNDLE_VERSION_REPO ( BUNDLE_VERSION_ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION_REPO" column="BUNDLE_VERSION_ID" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION_REPO" column="REPO_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION_REPO" column="REPO_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_VERSION_REPO">
+ ALTER TABLE RHQ_BUNDLE_VERSION_REPO ADD PRIMARY KEY ( BUNDLE_VERSION_ID, REPO_ID )
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION_REPO foreign key relation to RHQ_BUNDLE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_VERSION_REPO
+ ADD CONSTRAINT RHQ_BUNDLE_VERSION_ID_FK
+ FOREIGN KEY (BUNDLE_VERSION_ID)
+ REFERENCES RHQ_BUNDLE_VERSION (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION_REPO foreign key relation to RHQ_REPO">
+ ALTER TABLE RHQ_BUNDLE_VERSION_REPO
+ ADD CONSTRAINT RHQ_REPO_ID_FK
+ FOREIGN KEY (REPO_ID)
+ REFERENCES RHQ_REPO (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_FILE -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_FILE">
+ CREATE TABLE RHQ_BUNDLE_FILE ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_FILE" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_FILE_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_FILE">
+ ALTER TABLE RHQ_BUNDLE_FILE ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_FILE" column="BUNDLE_VERSION_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_FILE" column="BUNDLE_VERSION_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_BUNDLE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_FILE
+ ADD CONSTRAINT RHQ_BUNDLE_VERSION_ID_FK
+ FOREIGN KEY (BUNDLE_VERSION_ID)
+ REFERENCES RHQ_BUNDLE_VERSION (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_FILE" column="PACKAGE_VERSION_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_PACKAGE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_FILE
+ ADD CONSTRAINT RHQ_PACKAGE_VERSION_ID_FK
+ FOREIGN KEY (PACKAGE_VERSION_ID)
+ REFERENCES RHQ_PACKAGE_VERSION (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_FILE" column="PACKAGE_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_PACKAGE">
+ ALTER TABLE RHQ_BUNDLE_FILE
+ ADD CONSTRAINT RHQ_PACKAGE_ID_FK
+ FOREIGN KEY (PACKAGE_ID)
+ REFERENCES RHQ_PACKAGE (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_CONFIG -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_CONFIG">
+ CREATE TABLE RHQ_BUNDLE_CONFIG ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_CONFIG" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_CONFIG_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_CONFIG">
+ ALTER TABLE RHQ_BUNDLE_CONFIG ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_CONFIG" column="CONFIG_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_CONFIG foreign key relation to RHQ_CONFIG">
+ ALTER TABLE RHQ_BUNDLE_CONFIG
+ ADD CONSTRAINT RHQ_CONFIG_ID_FK
+ FOREIGN KEY (CONFIG_ID)
+ REFERENCES RHQ_CONFIG (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_CONFIG" column="BUNDLE_VERSION_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_CONFIG foreign key relation to RHQ_BUNDLE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_CONFIG
+ ADD CONSTRAINT RHQ_BUNDLE_VERSION_ID_FK
+ FOREIGN KEY (BUNDLE_VERSION_ID)
+ REFERENCES RHQ_BUNDLE_VERSION (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_CONFIG" column="BUNDLE_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_CONFIG foreign key relation to RHQ_BUNDLE">
+ ALTER TABLE RHQ_BUNDLE_CONFIG
+ ADD CONSTRAINT RHQ_BUNDLE_ID_FK
+ FOREIGN KEY (BUNDLE_ID)
+ REFERENCES RHQ_BUNDLE (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_DEPLOYMENT -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_DEPLOYMENT">
+ CREATE TABLE RHQ_BUNDLE_DEPLOYMENT ( BUNDLE_CONFIG_ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_DEPLOYMENT" column="BUNDLE_CONFIG_ID" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_DEPLOYMENT" column="RESOURCE_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_DEPLOYMENT" column="RESOURCE_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_DEPLOYMENT">
+ ALTER TABLE RHQ_BUNDLE_DEPLOYMENT ADD PRIMARY KEY ( BUNDLE_CONFIG_ID, RESOURCE_ID )
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_DEPLOYMENT foreign key relation to RHQ_BUNDLE_CONFIG">
+ ALTER TABLE RHQ_BUNDLE_DEPLOYMENT
+ ADD CONSTRAINT RHQ_BUNDLE_CONFIG_ID_FK
+ FOREIGN KEY (BUNDLE_CONFIG_ID)
+ REFERENCES RHQ_BUNDLE_CONFIG (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_DEPLOYMENT foreign key relation to RHQ_RESOURCE">
+ ALTER TABLE RHQ_BUNDLE_DEPLOYMENT
+ ADD CONSTRAINT RHQ_RESOURCE_ID_FK
+ FOREIGN KEY (RESOURCE_ID)
+ REFERENCES RHQ_RESOURCE (ID)
+ </statement>
+ </schema-directSQL>
++ </schemaSpec>
+
+ <schemaSpec version="2.77">
+ <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIF_TEMPLATE_ID" columnType="INTEGER"/>
+ <schema-directSQL>
+ <statement>
+ ALTER TABLE RHQ_ALERT_NOTIFICATION
+ ADD CONSTRAINT RHQ_NOTIF_TEMPL_ID_FKEY
+ FOREIGN KEY (NOTIF_TEMPLATE_ID)
+ REFERENCES RHQ_ALERT_NOTIF_TEMPL(ID)
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
+ <schemaSpec version="2.77.1">
+ <schema-createSequence name="RHQ_ALERT_NOTIF_TEMPL_ID_SEQ" initial="10001"/>
+ </schemaSpec>
+ <schemaSpec version="2.77.2">
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_host"/>
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_port"/>
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_oid"/>
+ <schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="email_address"/>
</schemaSpec>
</dbupgrade>
</target>
diff --cc modules/enterprise/server/plugins/perspectives/core/perspective/src/main/resources/META-INF/rhq-serverplugin.xml
index 873b26a,2844bcb..71dda8a
--- 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
@@@ -779,32 -790,25 +790,31 @@@
placement="firstChild" />
</tab>
- <tab name="Content.New" displayName="New" url="/rhq/resource/content/deploy.xhtml">
+ <tab name="Content.New" displayName="Install" url="/rhq/resource/content/deploy.xhtml">
<position
-
+
name="Content.Deployed"
placement="after" />
</tab>
--
- <tab name="Content.Subscriptions" displayName="Subscriptions" url="/rhq/resource/content/subscription.xhtml">
+ <tab name="Content.Update" displayName="Update" url="/rhq/resource/content/update.xhtml">
<position
name="Content.New"
placement="after" />
- </tab>
+ </tab>
+ <tab name="Content.Subscriptions" displayName="Subscriptions" url="/rhq/resource/content/subscription.xhtml">
+ <position
+
+ name="Content.Update"
+ placement="after" />
- </tab>
++ </tab>
+
<tab name="Content.History" displayName="History" url="/rhq/resource/content/history.xhtml">
<position
-
+
name="Content.Subscriptions"
placement="after" />
- </tab>
-
+ </tab>
+
</perspectivePlugin>
commit d50e6c3146963b2304d541ad92e51110738645ad
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 27 08:15:13 2010 -0500
Fixed test to be self-sufficient. Prior to this change, the test relied on the server being started at least once to populate the database with the default plugins' metadata.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
index fe4b61e..4e6dd5d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
@@ -34,6 +34,7 @@ import org.jboss.annotation.IgnoreDependency;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.InventoryStatus;
@@ -84,7 +85,14 @@ public class RegistrationManagerBean implements RegistrationManagerLocal, Regist
ConfigurationDefinition configDefinition = configManager.getPluginConfigurationDefinitionForResourceType(user,
resourceType.getId());
- Configuration platformConfig = configDefinition.getDefaultTemplate().getConfiguration();
+ Configuration platformConfig = null;
+ if (configDefinition != null) {
+ ConfigurationTemplate template = configDefinition.getDefaultTemplate();
+
+ if (template != null) {
+ platformConfig = template.getConfiguration();
+ }
+ }
platform.setPluginConfiguration(platformConfig);
platform.setInventoryStatus(InventoryStatus.COMMITTED);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
index 8571aa9..3dc9696 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
@@ -21,12 +21,14 @@ package org.rhq.enterprise.server.registration.test;
import javax.persistence.EntityManager;
+import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.server.registration.RegistrationManagerLocal;
import org.rhq.enterprise.server.registration.ReleaseRepoMapping;
@@ -47,9 +49,29 @@ public class RegistrationBeanTest extends AbstractEJB3Test {
this.registrationManager = LookupUtil.getRegistrationManager();
this.resourceTypeManager = LookupUtil.getResourceTypeManager();
this.overlord = LookupUtil.getSubjectManager().getOverlord();
+
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+
+ platformType = new ResourceType("RegistrationBeanTest.testRegisterPlatform",
+ "RegistrationBeanTest.testRegisterPlatform", ResourceCategory.PLATFORM, null);
+ em.persist(platformType);
+
+ getTransactionManager().commit();
+ }
+
+ @AfterClass
+ public void afterClass() throws Exception {
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+
+ platformType = em.find(ResourceType.class, platformType.getId());
+ em.remove(platformType);
+
+ getTransactionManager().commit();
}
- @Test(groups = "integration.ejb3")
+ @Test
public void testRegisterPlatform() throws Exception {
getTransactionManager().begin();
EntityManager em = getEntityManager();
@@ -57,7 +79,6 @@ public class RegistrationBeanTest extends AbstractEJB3Test {
createAgent(em);
em.flush();
- platformType = getPlatformResourceType();
Resource platform = new Resource("alpha", "platform", platformType);
registrationManager.registerPlatform(overlord, platform, parentId);
@@ -73,14 +94,14 @@ public class RegistrationBeanTest extends AbstractEJB3Test {
String arch = "x86_64";
ReleaseRepoMapping repomap = new ReleaseRepoMapping(release, version, arch);
String repo = repomap.getCompatibleRepo();
- assert (repo == "rhel-x86_64-server-5");
+ assert repo.equals("rhel-x86_64-server-5");
String release2 = "5Client";
String arch2 = "x86_64";
String version2 = "5.4.0";
ReleaseRepoMapping repomap2 = new ReleaseRepoMapping(release2, version2, arch2);
String repo2 = repomap2.getCompatibleRepo();
- assert (repo2 == "rhel-x86_64-client-5");
+ assert repo2.equals("rhel-x86_64-client-5");
}
@@ -89,9 +110,4 @@ public class RegistrationBeanTest extends AbstractEJB3Test {
em.persist(agent);
}
- private ResourceType getPlatformResourceType() {
-
- return resourceTypeManager.getResourceTypeByNameAndPlugin(overlord, "Linux", "Platforms");
- }
-
}
commit 54b75fe1df36921d1162b7fd985eaf8817e624fc
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 27 03:13:18 2010 -0500
new bundle config/file/deployment entities
these might not be finished - unsure if we want to use discriminators
to support multiple enties depending on relationship with package or package version
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleConfig.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleConfig.java
new file mode 100644
index 0000000..443a276
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleConfig.java
@@ -0,0 +1,156 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+import org.rhq.core.domain.configuration.Configuration;
+
+/**
+ * Defines a set of configuration values that can be used to deploy a bundle version somewhere.
+ *
+ * @author John Mazzitelli
+ */
+@Entity
+@NamedQueries( { @NamedQuery(name = BundleConfig.QUERY_FIND_ALL, query = "SELECT bc FROM BundleConfig bc") //
+})
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_BUNDLE_CONFIG_ID_SEQ")
+@Table(name = "RHQ_BUNDLE_CONFIG")
+(a)XmlAccessorType(XmlAccessType.FIELD)
+public class BundleConfig implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_FIND_ALL = "BundleConfig.findAll";
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
+ @Id
+ private int id;
+
+ @JoinColumn(name = "CONFIG_ID", referencedColumnName = "ID", nullable = true)
+ @ManyToOne(fetch = FetchType.LAZY)
+ private Configuration configuration;
+
+ @JoinColumn(name = "BUNDLE_VERSION_ID", referencedColumnName = "ID", nullable = true)
+ @ManyToOne(fetch = FetchType.LAZY)
+ private BundleVersion bundleVersion;
+
+ @JoinColumn(name = "BUNDLE_ID", referencedColumnName = "ID", nullable = true)
+ @ManyToOne(fetch = FetchType.LAZY)
+ private Bundle bundle;
+
+ public BundleConfig() {
+ // for JPA use
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public Configuration getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(Configuration config) {
+ this.configuration = config;
+ }
+
+ public BundleVersion getBundleVersion() {
+ return bundleVersion;
+ }
+
+ public void setBundleVersion(BundleVersion bundleVersion) {
+ this.bundleVersion = bundleVersion;
+ }
+
+ public Bundle getBundle() {
+ return bundle;
+ }
+
+ public void setBundle(Bundle bundle) {
+ this.bundle = bundle;
+ }
+
+ @Override
+ public String toString() {
+ return "BundleConfig[id=" + id + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((bundleVersion == null) ? 0 : bundleVersion.hashCode());
+ result = prime * result + ((bundle == null) ? 0 : bundle.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof BundleConfig)) {
+ return false;
+ }
+
+ BundleConfig other = (BundleConfig) obj;
+
+ if (bundleVersion == null) {
+ if (other.bundleVersion != null) {
+ return false;
+ }
+ } else if (!bundleVersion.equals(other.bundleVersion)) {
+ return false;
+ }
+
+ if (bundle == null) {
+ if (other.bundle != null) {
+ return false;
+ }
+ } else if (!bundle.equals(other.bundle)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
new file mode 100644
index 0000000..702c6eb
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
@@ -0,0 +1,134 @@
+/*
+ * 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+import org.rhq.core.domain.resource.Resource;
+
+/**
+ * This is the many-to-many entity that correlates a bundle configuration with a resource where
+ * that bundle config is installed. A bundle configuration is essentially a bundle version with
+ * the custom configuration settings that were used to determine how/where that bundle version
+ * was deployed to the resource.
+ *
+ * @author John Mazzitelli
+ */
+@Entity
+(a)IdClass(BundleDeploymentPK.class)
+@NamedQueries( {
+ @NamedQuery(name = BundleDeployment.QUERY_FIND_BY_BUNDLE_CONFIG_ID_NO_FETCH, query = "SELECT bd FROM BundleDeployment bd WHERE bd.bundleConfig.id = :id "),
+ @NamedQuery(name = BundleDeployment.QUERY_FIND_BY_RESOURCE_ID_NO_FETCH, query = "SELECT bd FROM BundleDeployment bd WHERE bd.resource.id = :id ") })
+@Table(name = "RHQ_BUNDLE_DEPLOYMENT")
+public class BundleDeployment implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_FIND_BY_BUNDLE_CONFIG_ID_NO_FETCH = "BundleDeployment.findByBundleConfigIdNoFetch";
+ public static final String QUERY_FIND_BY_RESOURCE_ID_NO_FETCH = "BundleDeployment.findByResourceIdNoFetch";
+
+ /*
+ * http://opensource.atlassian.com/projects/hibernate/browse/EJB-286 Hibernate seems to want these mappings in the
+ * @IdClass and ignore these here, even though the mappings should be here and no mappings should be needed in the
+ * @IdClass.
+ */
+ @Id
+ // @ManyToOne
+ // @JoinColumn(name = "BUNDLE_VERSION_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
+ private BundleConfig bundleConfig;
+
+ @Id
+ // @ManyToOne
+ // @JoinColumn(name = "REPO_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
+ private Resource resource;
+
+ protected BundleDeployment() {
+ }
+
+ public BundleDeployment(BundleConfig bundleConfig, Resource repo) {
+ this.bundleConfig = bundleConfig;
+ this.resource = repo;
+ }
+
+ public BundleDeploymentPK getBundleVersionRepoPK() {
+ return new BundleDeploymentPK(bundleConfig, resource);
+ }
+
+ public void setBundleVersionRepoPK(BundleDeploymentPK pk) {
+ this.bundleConfig = pk.getBundleConfig();
+ this.resource = pk.getResource();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder str = new StringBuilder("BundleDeployment: ");
+ str.append(", bc=[").append(this.bundleConfig).append("]");
+ str.append(", resource=[").append(this.resource).append("]");
+ return str.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 1;
+ result = (31 * result) + ((bundleConfig == null) ? 0 : bundleConfig.hashCode());
+ result = (31 * result) + ((resource == null) ? 0 : resource.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if ((obj == null) || (!(obj instanceof BundleDeployment))) {
+ return false;
+ }
+
+ final BundleDeployment other = (BundleDeployment) obj;
+
+ if (bundleConfig == null) {
+ if (bundleConfig != null) {
+ return false;
+ }
+ } else if (!bundleConfig.equals(other.bundleConfig)) {
+ return false;
+ }
+
+ if (resource == null) {
+ if (resource != null) {
+ return false;
+ }
+ } else if (!resource.equals(other.resource)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentPK.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentPK.java
new file mode 100644
index 0000000..3549360
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeploymentPK.java
@@ -0,0 +1,122 @@
+/*
+ * 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+
+import org.rhq.core.domain.resource.Resource;
+
+/**
+ * This is the composite primary key for the {@link BundleDeployment} entity. That entity is an explicit
+ * many-to-many mapping table, so this composite key is simply the foreign keys to both ends of that relationship.
+ *
+ * @author John Mazzitelli
+ */
+public class BundleDeploymentPK implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /*
+ * http://opensource.atlassian.com/projects/hibernate/browse/EJB-286 Hibernate seems to want these mappings here,
+ * even though this class is an @IdClass and it should not need the mappings here. The mappings belong in the
+ * entity itself.
+ */
+ @JoinColumn(name = "BUNDLE_CONFIG_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne
+ // persist so we can add the version as soon as we map it
+ private BundleConfig bundleConfig;
+
+ @JoinColumn(name = "RESOURCE_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne
+ private Resource resource;
+
+ public BundleDeploymentPK() {
+ }
+
+ public BundleDeploymentPK(BundleConfig bc, Resource r) {
+ bundleConfig = bc;
+ resource = r;
+ }
+
+ public BundleConfig getBundleConfig() {
+ return bundleConfig;
+ }
+
+ public void setBundleConfig(BundleConfig bc) {
+ this.bundleConfig = bc;
+ }
+
+ public Resource getResource() {
+ return resource;
+ }
+
+ public void setResource(Resource resource) {
+ this.resource = resource;
+ }
+
+ @Override
+ public String toString() {
+ return "BundleDeploymentPK: bundleConfig=[" + bundleConfig + "]; resource=[" + resource + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 1;
+ result = (31 * result) + ((bundleConfig == null) ? 0 : bundleConfig.hashCode());
+ result = (31 * result) + ((resource == null) ? 0 : resource.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (!(obj instanceof BundleDeploymentPK)) {
+ return false;
+ }
+
+ final BundleDeploymentPK other = (BundleDeploymentPK) obj;
+
+ if (bundleConfig == null) {
+ if (other.bundleConfig != null) {
+ return false;
+ }
+ } else if (!bundleConfig.equals(other.bundleConfig)) {
+ return false;
+ }
+
+ if (resource == null) {
+ if (other.resource != null) {
+ return false;
+ }
+ } else if (!resource.equals(other.resource)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleFile.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleFile.java
new file mode 100644
index 0000000..2eacd4e
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleFile.java
@@ -0,0 +1,169 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+import org.rhq.core.domain.content.Package;
+import org.rhq.core.domain.content.PackageVersion;
+
+/**
+ * Defines a bundle file that is part of a bundle version.
+ *
+ * @author John Mazzitelli
+ */
+@Entity
+@NamedQueries( {
+ @NamedQuery(name = BundleFile.QUERY_FIND_ALL, query = "SELECT bf FROM BundleFile bf"), //
+ @NamedQuery(name = BundleFile.QUERY_FIND_BY_BUNDLE_VERSION_ID, query = "SELECT bf FROM BundleFile bf WHERE bf.bundleVersion.id = :id") //
+})
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_BUNDLE_CONFIG_ID_SEQ")
+@Table(name = "RHQ_BUNDLE_FILE")
+(a)XmlAccessorType(XmlAccessType.FIELD)
+public class BundleFile implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_FIND_ALL = "BundleFile.findAll";
+ public static final String QUERY_FIND_BY_BUNDLE_VERSION_ID = "BundleFile.findByBundleVersionId";
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
+ @Id
+ private int id;
+
+ @JoinColumn(name = "BUNDLE_VERSION_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne(fetch = FetchType.LAZY)
+ private BundleVersion bundleVersion;
+
+ @JoinColumn(name = "PACKAGE_ID", referencedColumnName = "ID", nullable = true)
+ @ManyToOne(fetch = FetchType.LAZY)
+ private Package pkg;
+
+ @JoinColumn(name = "PACKAGE_VERSION_ID", referencedColumnName = "ID", nullable = true)
+ @ManyToOne(fetch = FetchType.LAZY)
+ private PackageVersion packageVersion;
+
+ public BundleFile() {
+ // for JPA use
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public BundleVersion getBundleVersion() {
+ return bundleVersion;
+ }
+
+ public void setBundleVersion(BundleVersion bundleVersion) {
+ this.bundleVersion = bundleVersion;
+ }
+
+ public Package getPackage() {
+ return pkg;
+ }
+
+ public void setPackage(Package pkg) {
+ this.pkg = pkg;
+ }
+
+ public PackageVersion getPackageVersion() {
+ return packageVersion;
+ }
+
+ public void setPackageVersion(PackageVersion packageVersion) {
+ this.packageVersion = packageVersion;
+ }
+
+ @Override
+ public String toString() {
+ return "BundleFile[id=" + id + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((bundleVersion == null) ? 0 : bundleVersion.hashCode());
+ result = prime * result + ((pkg == null) ? 0 : pkg.hashCode());
+ result = prime * result + ((packageVersion == null) ? 0 : packageVersion.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof BundleFile)) {
+ return false;
+ }
+
+ BundleFile other = (BundleFile) obj;
+
+ if (bundleVersion == null) {
+ if (other.bundleVersion != null) {
+ return false;
+ }
+ } else if (!bundleVersion.equals(other.bundleVersion)) {
+ return false;
+ }
+
+ if (pkg == null) {
+ if (other.pkg != null) {
+ return false;
+ }
+ } else if (!pkg.equals(other.pkg)) {
+ return false;
+ }
+
+ if (packageVersion == null) {
+ if (other.packageVersion != null) {
+ return false;
+ }
+ } else if (!packageVersion.equals(other.packageVersion)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
index 28d1994..1a40205 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
@@ -53,6 +53,9 @@ import org.rhq.core.domain.auth.Principal;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.bundle.Bundle;
+import org.rhq.core.domain.bundle.BundleConfig;
+import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.bundle.BundleFile;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.bundle.BundleVersionRepo;
@@ -148,12 +151,14 @@ public class QueryAllTest extends AbstractEJB3Test {
ContentSource.class.getSimpleName(), ContentSourceType.class.getSimpleName(),
InstalledPackage.class.getSimpleName(), Package.class.getSimpleName(), PackageBits.class.getSimpleName(),
PackageInstallationStep.class.getSimpleName(), PackageType.class.getSimpleName(),
- PackageVersion.class.getSimpleName(), PackageVersionContentSource.class.getSimpleName(),
+ PackageVersion.class.getSimpleName(),
+ PackageVersionContentSource.class.getSimpleName(),
ContentSourceSyncResults.class.getSimpleName(),
// bundle stuff
BundleType.class.getSimpleName(), Bundle.class.getSimpleName(), BundleVersion.class.getSimpleName(),
- BundleVersionRepo.class.getSimpleName(),
+ BundleVersionRepo.class.getSimpleName(), BundleConfig.class.getSimpleName(), BundleFile.class.getSimpleName(),
+ BundleDeployment.class.getSimpleName(),
// group stuff
GroupDefinition.class.getSimpleName(), ResourceGroup.class.getSimpleName(),
commit 26828e1f1e0e60e34e05106b851657edede3e0df
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 27 02:36:28 2010 -0500
BundleVersionRepo entity and unit tests
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersionRepo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersionRepo.java
new file mode 100644
index 0000000..45beeb8
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersionRepo.java
@@ -0,0 +1,132 @@
+/*
+ * 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+import org.rhq.core.domain.content.Repo;
+
+/**
+ * This is the many-to-many entity that correlates a bundle version with a repo that has content
+ * needed by the bundle.
+ *
+ * @author John Mazzitelli
+ */
+@Entity
+(a)IdClass(BundleVersionRepoPK.class)
+@NamedQueries( {
+ @NamedQuery(name = BundleVersionRepo.QUERY_FIND_BY_REPO_ID_NO_FETCH, query = "SELECT bvr FROM BundleVersionRepo bvr WHERE bvr.repo.id = :id "),
+ @NamedQuery(name = BundleVersionRepo.QUERY_FIND_BY_BUNDLE_VERSION_ID_NO_FETCH, query = "SELECT bvr FROM BundleVersionRepo bvr WHERE bvr.bundleVersion.id = :id ") })
+@Table(name = "RHQ_BUNDLE_VERSION_REPO")
+public class BundleVersionRepo implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_FIND_BY_REPO_ID_NO_FETCH = "BundleVersionRepo.findByRepoIdNoFetch";
+ public static final String QUERY_FIND_BY_BUNDLE_VERSION_ID_NO_FETCH = "BundleVersionRepo.findByBundleVersionIdNoFetch";
+
+ /*
+ * http://opensource.atlassian.com/projects/hibernate/browse/EJB-286 Hibernate seems to want these mappings in the
+ * @IdClass and ignore these here, even though the mappings should be here and no mappings should be needed in the
+ * @IdClass.
+ */
+ @Id
+ // @ManyToOne
+ // @JoinColumn(name = "BUNDLE_VERSION_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
+ private BundleVersion bundleVersion;
+
+ @Id
+ // @ManyToOne
+ // @JoinColumn(name = "REPO_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
+ private Repo repo;
+
+ protected BundleVersionRepo() {
+ }
+
+ public BundleVersionRepo(BundleVersion bundleVersion, Repo repo) {
+ this.bundleVersion = bundleVersion;
+ this.repo = repo;
+ }
+
+ public BundleVersionRepoPK getBundleVersionRepoPK() {
+ return new BundleVersionRepoPK(bundleVersion, repo);
+ }
+
+ public void setBundleVersionRepoPK(BundleVersionRepoPK pk) {
+ this.bundleVersion = pk.getBundleVersion();
+ this.repo = pk.getRepo();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder str = new StringBuilder("BVR: ");
+ str.append(", bv=[").append(this.bundleVersion).append("]");
+ str.append(", repo=[").append(this.repo).append("]");
+ return str.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 1;
+ result = (31 * result) + ((bundleVersion == null) ? 0 : bundleVersion.hashCode());
+ result = (31 * result) + ((repo == null) ? 0 : repo.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if ((obj == null) || (!(obj instanceof BundleVersionRepo))) {
+ return false;
+ }
+
+ final BundleVersionRepo other = (BundleVersionRepo) obj;
+
+ if (bundleVersion == null) {
+ if (bundleVersion != null) {
+ return false;
+ }
+ } else if (!bundleVersion.equals(other.bundleVersion)) {
+ return false;
+ }
+
+ if (repo == null) {
+ if (repo != null) {
+ return false;
+ }
+ } else if (!repo.equals(other.repo)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersionRepoPK.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersionRepoPK.java
new file mode 100644
index 0000000..ca11031
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersionRepoPK.java
@@ -0,0 +1,122 @@
+/*
+ * 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+
+import org.rhq.core.domain.content.Repo;
+
+/**
+ * This is the composite primary key for the {@link BundleVersionRepo} entity. That entity is an explicit
+ * many-to-many mapping table, so this composite key is simply the foreign keys to both ends of that relationship.
+ *
+ * @author John Mazzitelli
+ */
+public class BundleVersionRepoPK implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /*
+ * http://opensource.atlassian.com/projects/hibernate/browse/EJB-286 Hibernate seems to want these mappings here,
+ * even though this class is an @IdClass and it should not need the mappings here. The mappings belong in the
+ * entity itself.
+ */
+ @JoinColumn(name = "BUNDLE_VERSION_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne
+ // persist so we can add the version as soon as we map it
+ private BundleVersion bundleVersion;
+
+ @JoinColumn(name = "REPO_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne
+ private Repo repo;
+
+ public BundleVersionRepoPK() {
+ }
+
+ public BundleVersionRepoPK(BundleVersion bv, Repo r) {
+ bundleVersion = bv;
+ repo = r;
+ }
+
+ public BundleVersion getBundleVersion() {
+ return bundleVersion;
+ }
+
+ public void setBundleVersion(BundleVersion bv) {
+ this.bundleVersion = bv;
+ }
+
+ public Repo getRepo() {
+ return repo;
+ }
+
+ public void setRepo(Repo repo) {
+ this.repo = repo;
+ }
+
+ @Override
+ public String toString() {
+ return "BundleVersionRepoPK: bundleVersion=[" + bundleVersion + "]; repo=[" + repo + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 1;
+ result = (31 * result) + ((repo == null) ? 0 : repo.hashCode());
+ result = (31 * result) + ((bundleVersion == null) ? 0 : bundleVersion.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if ((obj == null) || (!(obj instanceof BundleVersionRepoPK))) {
+ return false;
+ }
+
+ final BundleVersionRepoPK other = (BundleVersionRepoPK) obj;
+
+ if (repo == null) {
+ if (other.repo != null) {
+ return false;
+ }
+ } else if (!repo.equals(other.repo)) {
+ return false;
+ }
+
+ if (bundleVersion == null) {
+ if (other.bundleVersion != null) {
+ return false;
+ }
+ } else if (!bundleVersion.equals(other.bundleVersion)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
index cff2a27..f4ee5d4 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
@@ -23,6 +23,7 @@
package org.rhq.core.domain.bundle.test;
import java.util.Arrays;
+import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
@@ -32,12 +33,91 @@ import org.testng.annotations.Test;
import org.rhq.core.domain.bundle.Bundle;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.core.domain.bundle.BundleVersionRepo;
+import org.rhq.core.domain.bundle.BundleVersionRepoPK;
import org.rhq.core.domain.content.Distribution;
import org.rhq.core.domain.content.DistributionType;
+import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.test.AbstractEJB3Test;
@Test
public class BundleTest extends AbstractEJB3Test {
+ public void testBundleVersionRepo() throws Throwable {
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ try {
+ int id;
+
+ String name = "BundleTest-testBundleVersionRepo";
+ byte[] action = "action/script/recipe is here".getBytes();
+
+ Repo repo1 = new Repo(name + "-Repo1");
+ Repo repo2 = new Repo(name + "-Repo2");
+ em.persist(repo1);
+ em.persist(repo2);
+ assert repo1.getId() > 0;
+ assert repo2.getId() > 0;
+
+ Query q = em.createNamedQuery(BundleVersionRepo.QUERY_FIND_BY_REPO_ID_NO_FETCH);
+ q.setParameter("id", repo1.getId());
+ assert q.getResultList().size() == 0 : "should not have repo1 mapping in the db yet";
+ q.setParameter("id", repo2.getId());
+ assert q.getResultList().size() == 0 : "should not have repo2 mapping in the db yet";
+
+ BundleType bundleType = new BundleType(name + "-Type");
+ Bundle bundle = new Bundle(name + "-Bundle", bundleType);
+ em.persist(bundle);
+ BundleVersion bundleVersion = new BundleVersion(name, "1.0.0.BETA", bundle);
+ bundleVersion.setAction(action);
+ em.persist(bundleVersion);
+ id = bundleVersion.getId();
+ assert id > 0;
+ assert bundleVersion.getBundle().getId() != 0 : "bundle should have been cascade persisted too";
+ assert bundleVersion.getBundle().getBundleType().getId() != 0 : "bundleType should have been cascade persisted too";
+
+ BundleVersionRepo bvr1 = new BundleVersionRepo(bundleVersion, repo1);
+ BundleVersionRepo bvr2 = new BundleVersionRepo(bundleVersion, repo2);
+ em.persist(bvr1);
+ em.persist(bvr2);
+
+ q = em.createNamedQuery(BundleVersionRepo.QUERY_FIND_BY_REPO_ID_NO_FETCH);
+ q.setParameter("id", repo1.getId());
+ assert q.getResultList().size() == 1;
+ assert ((BundleVersionRepo) q.getSingleResult()).getBundleVersionRepoPK().getBundleVersion().equals(
+ bundleVersion);
+ assert ((BundleVersionRepo) q.getSingleResult()).getBundleVersionRepoPK().getRepo().equals(repo1);
+
+ q.setParameter("id", repo2.getId());
+ assert q.getResultList().size() == 1;
+ assert ((BundleVersionRepo) q.getSingleResult()).getBundleVersionRepoPK().getBundleVersion().equals(
+ bundleVersion);
+ assert ((BundleVersionRepo) q.getSingleResult()).getBundleVersionRepoPK().getRepo().equals(repo2);
+
+ q = em.createNamedQuery(BundleVersionRepo.QUERY_FIND_BY_BUNDLE_VERSION_ID_NO_FETCH);
+ q.setParameter("id", bundleVersion.getId());
+ List<BundleVersionRepo> resultList = q.getResultList();
+ assert resultList.size() == 2;
+ BundleVersionRepoPK pk1 = new BundleVersionRepoPK(bundleVersion, repo1);
+ BundleVersionRepoPK pk2 = new BundleVersionRepoPK(bundleVersion, repo2);
+ if (resultList.get(0).getBundleVersionRepoPK().getRepo().equals(repo1)) {
+ assert bvr1.equals(resultList.get(0));
+ assert bvr2.equals(resultList.get(1));
+ assert pk1.equals(resultList.get(0).getBundleVersionRepoPK());
+ assert pk2.equals(resultList.get(1).getBundleVersionRepoPK());
+ } else {
+ assert bvr1.equals(resultList.get(1));
+ assert bvr2.equals(resultList.get(0));
+ assert pk1.equals(resultList.get(1).getBundleVersionRepoPK());
+ assert pk2.equals(resultList.get(0).getBundleVersionRepoPK());
+ }
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw t;
+ } finally {
+ getTransactionManager().rollback();
+ }
+ }
+
public void testBundleVersion() throws Throwable {
boolean done = false;
getTransactionManager().begin();
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
index 07dd5a6..28d1994 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
@@ -55,6 +55,7 @@ import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.bundle.Bundle;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.core.domain.bundle.BundleVersionRepo;
import org.rhq.core.domain.cloud.Server;
import org.rhq.core.domain.common.SystemConfiguration;
import org.rhq.core.domain.content.Architecture;
@@ -152,6 +153,7 @@ public class QueryAllTest extends AbstractEJB3Test {
// bundle stuff
BundleType.class.getSimpleName(), Bundle.class.getSimpleName(), BundleVersion.class.getSimpleName(),
+ BundleVersionRepo.class.getSimpleName(),
// group stuff
GroupDefinition.class.getSimpleName(), ResourceGroup.class.getSimpleName(),
commit eab83513506c54961a77d8d208d4381a6b89c581
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 27 01:57:00 2010 -0500
start of the bundle domain objects along with unit tests
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
index 46d3822..d558c09 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -505,6 +505,7 @@
<column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
<column name="NAME" size="200" type="VARCHAR2" required="true"/>
<column name="VERSION" size="500" type="VARCHAR2" required="true"/>
+ <column name="ACTION" type="BLOB" required="true"/>
<column name="BUNDLE_ID" type="INTEGER" required="true" references="RHQ_BUNDLE"/>
<column name="DISTRIBUTION_ID" type="INTEGER" required="false" references="RHQ_DISTRIBUTION"/>
</table>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 75abe81..6da02b6 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2826,6 +2826,8 @@
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="NAME" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="VERSION" columnType="VARCHAR2" precision="500" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="VERSION" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="ACTION" columnType="BLOB" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="ACTION" nullable="FALSE" />
<schema-addColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" columnType="INTEGER" />
<schema-alterColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" nullable="FALSE" />
<schema-directSQL>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
new file mode 100644
index 0000000..8faec6c
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
@@ -0,0 +1,150 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+/**
+ * Defines a bundle of content that can be versioned.
+ *
+ * @author John Mazzitelli
+ */
+@Entity
+@NamedQueries( { @NamedQuery(name = Bundle.QUERY_FIND_ALL, query = "SELECT b FROM Bundle b"), //
+ @NamedQuery(name = Bundle.QUERY_FIND_BY_NAME, query = "SELECT b FROM Bundle b WHERE b.name = :name") //
+})
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_BUNDLE_ID_SEQ")
+@Table(name = "RHQ_BUNDLE")
+(a)XmlAccessorType(XmlAccessType.FIELD)
+public class Bundle implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_FIND_ALL = "Bundle.findAll";
+ public static final String QUERY_FIND_BY_NAME = "Bundle.findByName";
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
+ @Id
+ private int id;
+
+ @Column(name = "NAME", nullable = false)
+ private String name;
+
+ @JoinColumn(name = "BUNDLE_TYPE_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST)
+ private BundleType bundleType;
+
+ public Bundle() {
+ // for JPA use
+ }
+
+ public Bundle(String name, BundleType type) {
+ setName(name);
+ setBundleType(type);
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public BundleType getBundleType() {
+ return bundleType;
+ }
+
+ public void setBundleType(BundleType bundleType) {
+ this.bundleType = bundleType;
+ }
+
+ @Override
+ public String toString() {
+ return "Bundle[id=" + id + ",name=" + name + ",bundleType=" + bundleType + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = (prime * result) + ((name == null) ? 0 : name.hashCode());
+ result = (prime * result) + ((bundleType == null) ? 0 : bundleType.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (!(obj instanceof Bundle)) {
+ return false;
+ }
+
+ final Bundle other = (Bundle) obj;
+
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+
+ if (bundleType == null) {
+ if (other.bundleType != null) {
+ return false;
+ }
+ } else if (!bundleType.equals(other.bundleType)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleType.java
new file mode 100644
index 0000000..6433df4
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleType.java
@@ -0,0 +1,125 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+/**
+ * Defines a type of bundle that can exist in the system. Bundle types are used to determine
+ * how a bundle is to be processed.
+ *
+ * @author John Mazzitelli
+ */
+@Entity
+@NamedQueries( { @NamedQuery(name = BundleType.QUERY_FIND_ALL, query = "SELECT bt FROM BundleType bt"), //
+ @NamedQuery(name = BundleType.QUERY_FIND_BY_NAME, query = "SELECT bt FROM BundleType bt WHERE bt.name = :name") //
+})
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_BUNDLE_TYPE_ID_SEQ")
+@Table(name = "RHQ_BUNDLE_TYPE")
+(a)XmlAccessorType(XmlAccessType.FIELD)
+public class BundleType implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_FIND_ALL = "BundleType.findAll";
+ public static final String QUERY_FIND_BY_NAME = "BundleType.findByName";
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
+ @Id
+ private int id;
+
+ @Column(name = "NAME", nullable = false)
+ private String name;
+
+ public BundleType() {
+ // for JPA use
+ }
+
+ public BundleType(String name) {
+ setName(name);
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return "BundleType[id=" + id + ",name=" + name + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = (prime * result) + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (!(obj instanceof BundleType)) {
+ return false;
+ }
+
+ final BundleType other = (BundleType) obj;
+
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
new file mode 100644
index 0000000..a4c4d31
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
@@ -0,0 +1,195 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.domain.bundle;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+
+import org.rhq.core.domain.content.Distribution;
+
+/**
+ * Defines a versioned bundle of content that can be provisioned somewhere.
+ *
+ * @author John Mazzitelli
+ */
+@Entity
+@NamedQueries( {
+ @NamedQuery(name = BundleVersion.QUERY_FIND_ALL, query = "SELECT bv FROM BundleVersion bv"), //
+ @NamedQuery(name = BundleVersion.QUERY_FIND_BY_NAME, query = "SELECT bv FROM BundleVersion bv WHERE bv.name = :name") //
+})
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_BUNDLE_VERSION_ID_SEQ")
+@Table(name = "RHQ_BUNDLE_VERSION")
+(a)XmlAccessorType(XmlAccessType.FIELD)
+public class BundleVersion implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String QUERY_FIND_ALL = "BundleVersion.findAll";
+ public static final String QUERY_FIND_BY_NAME = "BundleVersion.findByName";
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
+ @Id
+ private int id;
+
+ @Column(name = "NAME", nullable = false)
+ private String name;
+
+ @Column(name = "VERSION", nullable = false)
+ private String version;
+
+ @Column(name = "ACTION", nullable = false)
+ private byte[] action;
+
+ @JoinColumn(name = "BUNDLE_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne(fetch = FetchType.LAZY)
+ private Bundle bundle;
+
+ @JoinColumn(name = "DISTRIBUTION_ID", referencedColumnName = "ID", nullable = true)
+ @ManyToOne(fetch = FetchType.LAZY)
+ private Distribution distribution;
+
+ public BundleVersion() {
+ // for JPA use
+ }
+
+ public BundleVersion(String name, String version, Bundle bundle) {
+ setName(name);
+ setVersion(version);
+ setBundle(bundle);
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public byte[] getAction() {
+ return action;
+ }
+
+ public void setAction(byte[] action) {
+ this.action = action;
+ }
+
+ public Bundle getBundle() {
+ return bundle;
+ }
+
+ public void setBundle(Bundle bundle) {
+ this.bundle = bundle;
+ }
+
+ public Distribution getDistribution() {
+ return distribution;
+ }
+
+ public void setDistribution(Distribution distribution) {
+ this.distribution = distribution;
+ }
+
+ @Override
+ public String toString() {
+ return "BundleVersion[id=" + id + ",name=" + name + ",version=" + version + ",bundle=" + bundle + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((version == null) ? 0 : version.hashCode());
+ result = prime * result + ((bundle == null) ? 0 : bundle.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof BundleVersion)) {
+ return false;
+ }
+
+ BundleVersion other = (BundleVersion) obj;
+
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+
+ if (version == null) {
+ if (other.version != null) {
+ return false;
+ }
+ } else if (!version.equals(other.version)) {
+ return false;
+ }
+
+ if (bundle == null) {
+ if (other.bundle != null) {
+ return false;
+ }
+ } else if (!bundle.equals(other.bundle)) {
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
new file mode 100644
index 0000000..cff2a27
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/bundle/test/BundleTest.java
@@ -0,0 +1,266 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.domain.bundle.test;
+
+import java.util.Arrays;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.bundle.Bundle;
+import org.rhq.core.domain.bundle.BundleType;
+import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.core.domain.content.Distribution;
+import org.rhq.core.domain.content.DistributionType;
+import org.rhq.core.domain.test.AbstractEJB3Test;
+
+@Test
+public class BundleTest extends AbstractEJB3Test {
+ public void testBundleVersion() throws Throwable {
+ boolean done = false;
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ try {
+ int id;
+
+ String name = "BundleTest-testBundleVersion";
+ byte[] action = "action/script/recipe is here".getBytes();
+
+ BundleType bundleType = new BundleType(name + "-Type");
+ Bundle bundle = new Bundle(name + "-Bundle", bundleType);
+ em.persist(bundle);
+ id = bundle.getId();
+ assert id > 0;
+ assert bundle.getBundleType().getId() != 0 : "bundleType should have been cascade persisted too";
+
+ BundleVersion bv = new BundleVersion(name, "1.0.0.BETA", bundle);
+ bv.setAction(action);
+ Query q = em.createNamedQuery(BundleVersion.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bv.getName());
+ assert q.getResultList().size() == 0; // not in the db yet
+
+ em.persist(bv);
+ id = bv.getId();
+ assert id > 0;
+
+ q = em.createNamedQuery(BundleVersion.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bv.getName());
+ assert q.getResultList().size() == 1;
+ assert ((BundleVersion) q.getSingleResult()).getName().equals(bv.getName());
+
+ BundleVersion bvFind = em.find(BundleVersion.class, id);
+ assert bvFind != null;
+ assert bvFind.getId() == bv.getId();
+ assert bvFind.getName().equals(bv.getName());
+ assert bvFind.getVersion().equals(bv.getVersion());
+ assert Arrays.equals(bvFind.getAction(), bv.getAction());
+ assert bvFind.getBundle().equals(bv.getBundle());
+ assert bvFind.equals(bv);
+ assert bvFind.hashCode() == bv.hashCode();
+ assert bvFind.getDistribution() == null;
+
+ // update it with a distro, then null out the distro, checking along the way
+ DistributionType distroType = new DistributionType(name + "-DistroType");
+ Distribution distro = new Distribution(name + "-Distro", "basepathIn", distroType);
+ em.persist(distro);
+ assert distro.getId() > 0;
+ assert distro.getDistributionType().getId() > 0;
+ bvFind.setDistribution(distro);
+ em.flush();
+ bvFind = em.find(BundleVersion.class, id);
+ assert bvFind.getDistribution().equals(distro);
+ bvFind.setDistribution(null);
+ em.flush();
+ bvFind = em.find(BundleVersion.class, id);
+ assert bvFind.getDistribution() == null;
+ em.remove(distro);
+ em.remove(distroType);
+
+ // clean up - delete our test entity
+ em.close();
+ getTransactionManager().commit();
+ getTransactionManager().begin();
+ em = getEntityManager();
+ q = em.createNamedQuery(BundleVersion.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bv.getName());
+ BundleVersion doomed = (BundleVersion) q.getSingleResult();
+ doomed = em.getReference(BundleVersion.class, doomed.getId());
+ em.remove(doomed);
+ assert q.getResultList().size() == 0 : "didn't remove the entity";
+ em.close();
+ getTransactionManager().commit();
+
+ // make sure we didn't delete the bundle - it should not be cascade deleted
+ getTransactionManager().begin();
+ em = getEntityManager();
+ q = em.createNamedQuery(Bundle.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bundle.getName());
+ assert q.getResultList().size() == 1;
+ bundle = (Bundle) q.getSingleResult();
+ bundleType = bundle.getBundleType();
+ em.remove(bundle);
+ em.remove(bundleType);
+ assert q.getResultList().size() == 0 : "didn't clean up test bundle";
+ assert em.find(BundleType.class, bundleType.getId()) == null : "didn't clean up bundle type";
+ em.close();
+ getTransactionManager().commit();
+
+ done = true;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw t;
+ } finally {
+ if (!done) {
+ getTransactionManager().rollback();
+ }
+ }
+ }
+
+ public void testBundle() throws Throwable {
+ boolean done = false;
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ try {
+ int id;
+
+ String name = "BundleTest-testBundle";
+
+ BundleType bundleType = new BundleType(name + "-Type");
+ Bundle b = new Bundle(name, bundleType);
+
+ Query q = em.createNamedQuery(Bundle.QUERY_FIND_BY_NAME);
+ q.setParameter("name", b.getName());
+ assert q.getResultList().size() == 0; // not in the db yet
+
+ em.persist(b);
+ id = b.getId();
+ assert id > 0;
+ assert b.getBundleType().getId() != 0 : "bundleType should have been cascade persisted too";
+
+ q = em.createNamedQuery(Bundle.QUERY_FIND_BY_NAME);
+ q.setParameter("name", b.getName());
+ assert q.getResultList().size() == 1;
+ assert ((Bundle) q.getSingleResult()).getName().equals(b.getName());
+
+ Bundle bFind = em.find(Bundle.class, id);
+ assert bFind != null;
+ assert bFind.getId() == b.getId();
+ assert bFind.getName().equals(b.getName());
+ assert bFind.getBundleType().equals(b.getBundleType());
+ assert bFind.equals(b);
+ assert bFind.hashCode() == b.hashCode();
+
+ // clean up - delete our test entity
+ em.close();
+ getTransactionManager().commit();
+ getTransactionManager().begin();
+ em = getEntityManager();
+ q = em.createNamedQuery(Bundle.QUERY_FIND_BY_NAME);
+ q.setParameter("name", b.getName());
+ Bundle doomed = (Bundle) q.getSingleResult();
+ doomed = em.getReference(Bundle.class, doomed.getId());
+ em.remove(doomed);
+ assert q.getResultList().size() == 0 : "didn't remove the entity";
+ em.close();
+ getTransactionManager().commit();
+
+ // make sure we didn't delete the bundle type - it should not be cascade deleted
+ getTransactionManager().begin();
+ em = getEntityManager();
+ q = em.createNamedQuery(BundleType.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bFind.getBundleType().getName());
+ assert q.getResultList().size() == 1;
+ BundleType bt = (BundleType) q.getSingleResult();
+ em.remove(bt);
+ assert q.getResultList().size() == 0 : "didn't clean up test bundle type";
+ em.close();
+ getTransactionManager().commit();
+
+ done = true;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw t;
+ } finally {
+ if (!done) {
+ getTransactionManager().rollback();
+ }
+ }
+ }
+
+ public void testBundleType() throws Throwable {
+ boolean done = false;
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ try {
+ int id;
+
+ String name = "BundleTest-testBundleType";
+
+ BundleType bt = new BundleType(name);
+
+ Query q = em.createNamedQuery(BundleType.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bt.getName());
+ assert q.getResultList().size() == 0; // not in the db yet
+
+ em.persist(bt);
+ id = bt.getId();
+ assert id > 0;
+
+ q = em.createNamedQuery(BundleType.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bt.getName());
+ assert q.getResultList().size() == 1;
+ assert ((BundleType) q.getSingleResult()).getName().equals(bt.getName());
+
+ BundleType btFind = em.find(BundleType.class, id);
+ assert btFind != null;
+ assert btFind.getId() == bt.getId();
+ assert btFind.getName().equals(bt.getName());
+ assert btFind.equals(bt);
+ assert btFind.hashCode() == bt.hashCode();
+
+ // clean up - delete our test entity
+ em.close();
+ getTransactionManager().commit();
+ getTransactionManager().begin();
+ em = getEntityManager();
+ q = em.createNamedQuery(BundleType.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bt.getName());
+ BundleType doomed = (BundleType) q.getSingleResult();
+ doomed = em.getReference(BundleType.class, doomed.getId());
+ em.remove(doomed);
+ assert q.getResultList().size() == 0 : "didn't remove the entity";
+ em.close();
+ getTransactionManager().commit();
+ done = true;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw t;
+ } finally {
+ if (!done) {
+ getTransactionManager().rollback();
+ }
+ }
+ }
+}
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
index e559830..07dd5a6 100644
--- a/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/test/QueryAllTest.java
@@ -52,6 +52,9 @@ import org.rhq.core.domain.alert.notification.SubjectNotification;
import org.rhq.core.domain.auth.Principal;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.bundle.Bundle;
+import org.rhq.core.domain.bundle.BundleType;
+import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.cloud.Server;
import org.rhq.core.domain.common.SystemConfiguration;
import org.rhq.core.domain.content.Architecture;
@@ -147,6 +150,9 @@ public class QueryAllTest extends AbstractEJB3Test {
PackageVersion.class.getSimpleName(), PackageVersionContentSource.class.getSimpleName(),
ContentSourceSyncResults.class.getSimpleName(),
+ // bundle stuff
+ BundleType.class.getSimpleName(), Bundle.class.getSimpleName(), BundleVersion.class.getSimpleName(),
+
// group stuff
GroupDefinition.class.getSimpleName(), ResourceGroup.class.getSimpleName(),
commit 87fec52f40bb2c586cb1a17722292c15266f5350
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Jan 26 23:49:40 2010 -0500
add bundle schema to db setup/upgrade scripts
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 256f287..fd906cf 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.76</db.schema.version>
+ <db.schema.version>2.76.1</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
index 261ac25..46d3822 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -487,6 +487,71 @@
</constraint>
</table>
+ <!-- BUNDLE_TYPE is things like "Cobbler profile" or "file-based bundle" or "puppet recipe" -->
+ <table name="RHQ_BUNDLE_TYPE">
+ <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
+ <column name="NAME" size="200" type="VARCHAR2" required="true"/>
+ </table>
+
+ <!-- BUNDLE is a named piece of content that can be versioned and installed somewhere -->
+ <table name="RHQ_BUNDLE">
+ <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
+ <column name="NAME" size="200" type="VARCHAR2" required="true"/>
+ <column name="BUNDLE_TYPE_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_TYPE"/>
+ </table>
+
+ <!-- BUNDLE_VERSION represents an actual piece of content that needs to be installed somewhere -->
+ <table name="RHQ_BUNDLE_VERSION">
+ <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
+ <column name="NAME" size="200" type="VARCHAR2" required="true"/>
+ <column name="VERSION" size="500" type="VARCHAR2" required="true"/>
+ <column name="BUNDLE_ID" type="INTEGER" required="true" references="RHQ_BUNDLE"/>
+ <column name="DISTRIBUTION_ID" type="INTEGER" required="false" references="RHQ_DISTRIBUTION"/>
+ </table>
+
+ <!-- Many-to-many table that links many repos to a particular bundle version -->
+ <table name="RHQ_BUNDLE_VERSION_REPO">
+ <column name="BUNDLE_VERSION_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_VERSION"/>
+ <column name="REPO_ID" type="INTEGER" required="true" references="RHQ_REPO"/>
+
+ <constraint name="RHQ_BUNDLE_VERSION_REPO_KEY">
+ <primaryKey>
+ <field ref="BUNDLE_VERSION_ID"/>
+ <field ref="REPO_ID"/>
+ </primaryKey>
+ </constraint>
+ </table>
+
+ <!-- BUNDLE_FILE represents a file that is associated with (possibly bundled inside) a bundle version -->
+ <table name="RHQ_BUNDLE_FILE">
+ <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
+ <column name="BUNDLE_VERSION_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_VERSION"/>
+ <!-- this probably needs a DTYPE discriminator so we know if its a package or a specific package version -->
+ <column name="PACKAGE_VERSION_ID" type="INTEGER" required="false" references="RHQ_PACKAGE_VERSION"/>
+ <column name="PACKAGE_ID" type="INTEGER" required="false" references="RHQ_PACKAGE"/>
+ </table>
+
+ <!-- A set of configuration values that are used to customize how/where a bundle version is installed -->
+ <table name="RHQ_BUNDLE_CONFIG">
+ <column name="ID" default="sequence-only" initial="10001" primarykey="true" required="true" type="INTEGER"/>
+ <column name="CONFIG_ID" type="INTEGER" required="false" references="RHQ_CONFIG" />
+ <!-- this probably needs a DTYPE discriminator so we know if its a bundle or a specific bundle version -->
+ <column name="BUNDLE_VERSION_ID" type="INTEGER" required="false" references="RHQ_BUNDLE_VERSION"/>
+ <column name="BUNDLE_ID" type="INTEGER" required="false" references="RHQ_BUNDLE"/>
+ </table>
+
+ <!-- Represents a bundle version that is deployed on a resource -->
+ <table name="RHQ_BUNDLE_DEPLOYMENT">
+ <column name="BUNDLE_CONFIG_ID" type="INTEGER" required="true" references="RHQ_BUNDLE_CONFIG"/>
+ <column name="RESOURCE_ID" type="INTEGER" required="true" references="RHQ_RESOURCE" />
+
+ <constraint name="RHQ_BUNDLE_DEPLOYMENT_KEY">
+ <primaryKey>
+ <field ref="BUNDLE_CONFIG_ID"/>
+ <field ref="RESOURCE_ID"/>
+ </primaryKey>
+ </constraint>
+ </table>
</dbsetup>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 144c793..75abe81 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2766,6 +2766,232 @@
<schema-addColumn table="RHQ_CONFIG_PROP_DEF" column="DYNAMIC_KEY" columnType="VARCHAR2" precision="128" />
</schemaSpec>
+ <schemaSpec version="2.76.1">
+ <!-- RHQ_BUNDLE_TYPE -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_TYPE">
+ CREATE TABLE RHQ_BUNDLE_TYPE ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_TYPE" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_TYPE_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_TYPE">
+ ALTER TABLE RHQ_BUNDLE_TYPE ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_TYPE" column="NAME" columnType="VARCHAR2" precision="200" />
+ <schema-alterColumn table="RHQ_BUNDLE_TYPE" column="NAME" nullable="FALSE" />
+
+ <!-- RHQ_BUNDLE -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE">
+ CREATE TABLE RHQ_BUNDLE ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE">
+ ALTER TABLE RHQ_BUNDLE ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE" column="NAME" columnType="VARCHAR2" precision="200" />
+ <schema-alterColumn table="RHQ_BUNDLE" column="NAME" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE" column="BUNDLE_TYPE_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE" column="BUNDLE_TYPE_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE foreign key relation to RHQ_BUNDLE_TYPE">
+ ALTER TABLE RHQ_BUNDLE
+ ADD CONSTRAINT RHQ_BUNDLE_TYPE_ID_FK
+ FOREIGN KEY (BUNDLE_TYPE_ID)
+ REFERENCES RHQ_BUNDLE_TYPE (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_VERSION -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_VERSION">
+ CREATE TABLE RHQ_BUNDLE_VERSION ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_VERSION_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_VERSION ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="NAME" columnType="VARCHAR2" precision="200" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="NAME" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="VERSION" columnType="VARCHAR2" precision="500" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="VERSION" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION" column="BUNDLE_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION foreign key relation to RHQ_BUNDLE">
+ ALTER TABLE RHQ_BUNDLE_VERSION
+ ADD CONSTRAINT RHQ_BUNDLE_ID_FK
+ FOREIGN KEY (BUNDLE_ID)
+ REFERENCES RHQ_BUNDLE (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_VERSION" column="DISTRIBUTION_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION foreign key relation to RHQ_DISTRIBUTION">
+ ALTER TABLE RHQ_BUNDLE_VERSION
+ ADD CONSTRAINT RHQ_DISTRIBUTION_ID_FK
+ FOREIGN KEY (DISTRIBUTION_ID)
+ REFERENCES RHQ_DISTRIBUTION (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_VERSION_REPO -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_VERSION_REPO">
+ CREATE TABLE RHQ_BUNDLE_VERSION_REPO ( BUNDLE_VERSION_ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION_REPO" column="BUNDLE_VERSION_ID" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_VERSION_REPO" column="REPO_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_VERSION_REPO" column="REPO_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_VERSION_REPO">
+ ALTER TABLE RHQ_BUNDLE_VERSION_REPO ADD PRIMARY KEY ( BUNDLE_VERSION_ID, REPO_ID )
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION_REPO foreign key relation to RHQ_BUNDLE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_VERSION_REPO
+ ADD CONSTRAINT RHQ_BUNDLE_VERSION_ID_FK
+ FOREIGN KEY (BUNDLE_VERSION_ID)
+ REFERENCES RHQ_BUNDLE_VERSION (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_VERSION_REPO foreign key relation to RHQ_REPO">
+ ALTER TABLE RHQ_BUNDLE_VERSION_REPO
+ ADD CONSTRAINT RHQ_REPO_ID_FK
+ FOREIGN KEY (REPO_ID)
+ REFERENCES RHQ_REPO (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_FILE -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_FILE">
+ CREATE TABLE RHQ_BUNDLE_FILE ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_FILE" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_FILE_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_FILE">
+ ALTER TABLE RHQ_BUNDLE_FILE ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_FILE" column="BUNDLE_VERSION_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_FILE" column="BUNDLE_VERSION_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_BUNDLE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_FILE
+ ADD CONSTRAINT RHQ_BUNDLE_VERSION_ID_FK
+ FOREIGN KEY (BUNDLE_VERSION_ID)
+ REFERENCES RHQ_BUNDLE_VERSION (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_FILE" column="PACKAGE_VERSION_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_PACKAGE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_FILE
+ ADD CONSTRAINT RHQ_PACKAGE_VERSION_ID_FK
+ FOREIGN KEY (PACKAGE_VERSION_ID)
+ REFERENCES RHQ_PACKAGE_VERSION (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_FILE" column="PACKAGE_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_FILE foreign key relation to RHQ_PACKAGE">
+ ALTER TABLE RHQ_BUNDLE_FILE
+ ADD CONSTRAINT RHQ_PACKAGE_ID_FK
+ FOREIGN KEY (PACKAGE_ID)
+ REFERENCES RHQ_PACKAGE (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_CONFIG -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_CONFIG">
+ CREATE TABLE RHQ_BUNDLE_CONFIG ( ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_CONFIG" column="ID" nullable="FALSE" />
+ <schema-createSequence name="RHQ_BUNDLE_CONFIG_ID_SEQ" initial="10001" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_CONFIG">
+ ALTER TABLE RHQ_BUNDLE_CONFIG ADD PRIMARY KEY ( ID )
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_CONFIG" column="CONFIG_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_CONFIG foreign key relation to RHQ_CONFIG">
+ ALTER TABLE RHQ_BUNDLE_CONFIG
+ ADD CONSTRAINT RHQ_CONFIG_ID_FK
+ FOREIGN KEY (CONFIG_ID)
+ REFERENCES RHQ_CONFIG (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_CONFIG" column="BUNDLE_VERSION_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_CONFIG foreign key relation to RHQ_BUNDLE_VERSION">
+ ALTER TABLE RHQ_BUNDLE_CONFIG
+ ADD CONSTRAINT RHQ_BUNDLE_VERSION_ID_FK
+ FOREIGN KEY (BUNDLE_VERSION_ID)
+ REFERENCES RHQ_BUNDLE_VERSION (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-addColumn table="RHQ_BUNDLE_CONFIG" column="BUNDLE_ID" columnType="INTEGER" />
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_CONFIG foreign key relation to RHQ_BUNDLE">
+ ALTER TABLE RHQ_BUNDLE_CONFIG
+ ADD CONSTRAINT RHQ_BUNDLE_ID_FK
+ FOREIGN KEY (BUNDLE_ID)
+ REFERENCES RHQ_BUNDLE (ID)
+ </statement>
+ </schema-directSQL>
+
+ <!-- RHQ_BUNDLE_DEPLOYMENT -->
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_BUNDLE_DEPLOYMENT">
+ CREATE TABLE RHQ_BUNDLE_DEPLOYMENT ( BUNDLE_CONFIG_ID INTEGER )
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_BUNDLE_DEPLOYMENT" column="BUNDLE_CONFIG_ID" nullable="FALSE" />
+ <schema-addColumn table="RHQ_BUNDLE_DEPLOYMENT" column="RESOURCE_ID" columnType="INTEGER" />
+ <schema-alterColumn table="RHQ_BUNDLE_DEPLOYMENT" column="RESOURCE_ID" nullable="FALSE" />
+ <schema-directSQL>
+ <statement desc="Creating primary key for RHQ_BUNDLE_DEPLOYMENT">
+ ALTER TABLE RHQ_BUNDLE_DEPLOYMENT ADD PRIMARY KEY ( BUNDLE_CONFIG_ID, RESOURCE_ID )
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_DEPLOYMENT foreign key relation to RHQ_BUNDLE_CONFIG">
+ ALTER TABLE RHQ_BUNDLE_DEPLOYMENT
+ ADD CONSTRAINT RHQ_BUNDLE_CONFIG_ID_FK
+ FOREIGN KEY (BUNDLE_CONFIG_ID)
+ REFERENCES RHQ_BUNDLE_CONFIG (ID)
+ </statement>
+ </schema-directSQL>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_BUNDLE_DEPLOYMENT foreign key relation to RHQ_RESOURCE">
+ ALTER TABLE RHQ_BUNDLE_DEPLOYMENT
+ ADD CONSTRAINT RHQ_RESOURCE_ID_FK
+ FOREIGN KEY (RESOURCE_ID)
+ REFERENCES RHQ_RESOURCE (ID)
+ </statement>
+ </schema-directSQL>
+
+ </schemaSpec>
</dbupgrade>
</target>
</project>
commit 9ba9416be7e945accb9716a654c544ff3fe95026
Author: Bryan Kearney <bkearney(a)redhat.com>
Date: Tue Jan 26 10:41:19 2010 -0500
Make the name of the kickstart plugin better
diff --git a/modules/plugins/kickstart/pom.xml b/modules/plugins/kickstart/pom.xml
index 460bc92..793526f 100644
--- a/modules/plugins/kickstart/pom.xml
+++ b/modules/plugins/kickstart/pom.xml
@@ -16,7 +16,7 @@
<artifactId>rhq-kickstart-plugin</artifactId>
<packaging>jar</packaging>
- <name>Kickstart Plugin</name>
+ <name>RHQ Kickstart Plugin</name>
<description>Exposes kickstart functionality for machine reinstalls and virt guests</description>
commit 75418428d87c9b6d6f33b8194b9720ae00c42619
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Tue Jan 26 10:38:12 2010 -0500
fixing unittests for registration bean
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
index 3293933..8571aa9 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
@@ -27,15 +27,16 @@ import org.testng.annotations.Test;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.server.registration.RegistrationManagerLocal;
import org.rhq.enterprise.server.registration.ReleaseRepoMapping;
+import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
public class RegistrationBeanTest extends AbstractEJB3Test {
private RegistrationManagerLocal registrationManager;
+ private ResourceTypeManagerLocal resourceTypeManager;
private ResourceType platformType;
private Agent agent;
private int parentId = -1;
@@ -44,6 +45,7 @@ public class RegistrationBeanTest extends AbstractEJB3Test {
@BeforeClass
public void beforeClass() throws Exception {
this.registrationManager = LookupUtil.getRegistrationManager();
+ this.resourceTypeManager = LookupUtil.getResourceTypeManager();
this.overlord = LookupUtil.getSubjectManager().getOverlord();
}
@@ -52,10 +54,10 @@ public class RegistrationBeanTest extends AbstractEJB3Test {
getTransactionManager().begin();
EntityManager em = getEntityManager();
try {
- createResourceTypes(em);
createAgent(em);
em.flush();
+ platformType = getPlatformResourceType();
Resource platform = new Resource("alpha", "platform", platformType);
registrationManager.registerPlatform(overlord, platform, parentId);
@@ -87,10 +89,9 @@ public class RegistrationBeanTest extends AbstractEJB3Test {
em.persist(agent);
}
- private void createResourceTypes(EntityManager entityManager) {
- platformType = new ResourceType("test platform", "test", ResourceCategory.PLATFORM, null);
+ private ResourceType getPlatformResourceType() {
- entityManager.persist(platformType);
+ return resourceTypeManager.getResourceTypeByNameAndPlugin(overlord, "Linux", "Platforms");
}
}
commit 41c75f85e39431f5997ac3a2d1ec95120a656a2f
Author: Sayli Karmarkar <skarmark(a)redhat.com>
Date: Mon Jan 25 13:28:52 2010 -0500
Adding sorting for install and update lists
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
index d229f93..d7b3e0a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
@@ -19,6 +19,8 @@
package org.rhq.enterprise.server.content;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -266,6 +268,15 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
}
}
+ Collections.sort(modifiedResults, new Comparator() {
+
+ public int compare(Object o1, Object o2) {
+ PackageVersionComposite p1 = (PackageVersionComposite) o1;
+ PackageVersionComposite p2 = (PackageVersionComposite) o2;
+ return p1.getPackageName().compareToIgnoreCase(p2.getPackageName());
+ }
+ });
+
return new PageList<PackageVersionComposite>(modifiedResults, (int) count, pc);
}
@@ -343,6 +354,15 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
}
}
+ Collections.sort(finalResults, new Comparator() {
+
+ public int compare(Object o1, Object o2) {
+ PackageVersionComposite p1 = (PackageVersionComposite) o1;
+ PackageVersionComposite p2 = (PackageVersionComposite) o2;
+ return p1.getPackageName().compareToIgnoreCase(p2.getPackageName());
+ }
+ });
+
return new PageList<PackageVersionComposite>(finalResults, (int) count, pc);
}
commit d5b19c721b6883da0c3813260327166a22ddfbc9
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Mon Jan 25 08:40:40 2010 -0800
0000 - switching to previous method for refreshing status bar
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
index b4855ce..dea6e98 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
@@ -48,7 +48,7 @@ public class RepoDetailsUIBean {
return "edit";
}
- public boolean getShowProgressBar() {
+ public boolean getCurrentlySyncing() {
String syncStatus = getSyncStatus();
if (!syncStatus.equals(ContentSyncStatus.SUCCESS.toString())
&& !syncStatus.equals(ContentSyncStatus.FAILURE.toString())
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
index 5b5a5ae..8837813 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
@@ -115,13 +115,12 @@
value="#{RepoDetailsUIBean.percentComplete}" />
</td>
</tr>
- <!--
<tr>
- <td align="right"><b>Synchronization Progress 1:</b></td>
+ <td align="right"><b>Synchronization Progress :</b></td>
<td align="left">
<c:choose>
<c:when
- test="#{RepoDetailsUIBean.showProgressBar}">
+ test="#{RepoDetailsUIBean.currentlySyncing}">
<rich:progressBar id="syncProgress"
value="#{RepoDetailsUIBean.percentComplete}"
label="#{RepoDetailsUIBean.percentComplete} %"
@@ -137,7 +136,7 @@
</c:choose>
</td>
</tr>
- -->
+ <!--
<tr>
<td align="right"><b>Synchronization Progress:</b></td>
<td align="left">
@@ -154,6 +153,7 @@
</rich:progressBar>
</td>
</tr>
+ -->
<tr>
<td align="right"><b>Synchronization Results:</b></td>
<td align="left"><h:outputLink
@@ -196,7 +196,7 @@
<h:commandButton rendered="${mode ne 'edit'}"
value="SYNCHRONIZE" action="#{RepoDetailsUIBean.sync}"
alt="Synchronize" styleClass="buttonmed" id="syncButton" />
- <h:commandButton rendered="${mode ne 'edit'}"
+ <h:commandButton rendered="#{RepoDetailsUIBean.currentlySyncing}"
value="CANCEL SYNCH" action="#{RepoDetailsUIBean.cancelSync}"
alt="Cancel Synch" styleClass="buttonmed" id="cancelSyncButton" />
<h:commandButton rendered="${mode eq 'edit'}" value="SAVE"
commit 67945293742b8ade2f9c3faf7bc134696be53ccd
Author: Jeff Ortel <jortel(a)redhat.com>
Date: Mon Jan 25 10:08:26 2010 -0600
Look for cert named client for demo instead of by resource id.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
index 3ec181f..7220970 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
@@ -28,6 +28,7 @@ public class EntitlementManagerBean implements EntitlementManagerLocal, Entitlem
DummyLoader loader = new DummyLoader();
try {
list.add(loader.load(resourceId));
+
} catch (Exception ex) {
log.warn("x.509 cert for: " //
+ resourceId //
@@ -44,6 +45,12 @@ class DummyLoader {
EntitlementCertificate load(int resourceId) throws IOException {
String name = String.valueOf(resourceId);
+ EntitlementCertificate x509 = load("client");
+ x509.setName(name);
+ return x509;
+ }
+
+ EntitlementCertificate load(String name) throws IOException {
String key = read(name + ".key");
String pem = read(name + ".pem");
return new EntitlementCertificate(name, key, pem);
commit 4ed31cc2dad1547e51102d143135b3cd41828a86
Author: Sayli Karmarkar <skarmark(a)redhat.com>
Date: Mon Jan 25 02:11:43 2010 -0500
1364 - Update list should show only the most recent packageversion and not all versions > installed package
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
index e003579..d229f93 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
@@ -295,7 +295,6 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
query.setParameter("resourceId", resourceId);
query.setParameter("filter", filter);
- long count = 0;
List<PackageVersionComposite> results = query.getResultList();
List<PackageVersionComposite> modifiedResults = new ArrayList<PackageVersionComposite>();
String packageName = new String();
@@ -307,12 +306,44 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
if (installedPackageNameAndVersion.get(packageName).compareTo(result.getPackageVersion().getVersion()) < 0) {
modifiedResults.add(result);
- count++;
}
+ }
+ }
+
+ List<PackageVersionComposite> testResults = new ArrayList<PackageVersionComposite>();
+ for (PackageVersionComposite result : modifiedResults) {
+ testResults.add(result);
+ }
+ List<PackageVersionComposite> latestResults = new ArrayList<PackageVersionComposite>();
+
+ PackageVersionComposite latestPackage = null;
+
+ for (PackageVersionComposite newPackage : modifiedResults) {
+ latestPackage = newPackage;
+
+ for (PackageVersionComposite pack : testResults) {
+ if (pack.getPackageName().equals(latestPackage.getPackageName())
+ && latestPackage.getPackageVersion().getVersion().compareTo(pack.getPackageVersion().getVersion()) < 0) {
+ latestPackage = pack;
+ }
}
+ latestResults.add(latestPackage);
}
- return new PageList<PackageVersionComposite>(modifiedResults, (int) count, pc);
+
+ List<PackageVersionComposite> finalResults = new ArrayList<PackageVersionComposite>();
+
+ long count = 0;
+ for (PackageVersionComposite pack : latestResults) {
+ if (finalResults.contains(pack)) {
+ continue;
+ } else {
+ finalResults.add(pack);
+ count++;
+ }
+ }
+
+ return new PageList<PackageVersionComposite>(finalResults, (int) count, pc);
}
public PackageVersionComposite loadPackageVersionComposite(Subject user, int packageVersionId) {
commit a99b8f2f463779bb4fe3d92857ed9ae541009737
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Fri Jan 22 16:23:23 2010 -0800
0000 - temp fix to alleviate timeouts during long syncs
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 f819aa0..b222f2e 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
@@ -38,6 +38,7 @@ import org.quartz.CronExpression;
import org.quartz.SchedulerException;
import org.jboss.annotation.IgnoreDependency;
+import org.jboss.annotation.ejb.TransactionTimeout;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
@@ -1030,6 +1031,8 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
}
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ // TEMPORARY TIMEOUT DEFINED WHILE WE PROPERLY FIGURE OUT TIMEOUTS
+ @TransactionTimeout(86400)
public int internalSynchronizeRepos(Subject subject, Integer[] repoIds) throws InterruptedException {
ContentServerPluginContainer pc;
try {
commit a892dcc85e71a7280bc958b428dfab3c92df0976
Author: Jeff Ortel <jortel(a)redhat.com>
Date: Fri Jan 22 16:28:39 2010 -0600
Allow access to content via http w/o cert. For now, only validate cert when presented.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
index 602c5a9..b5fa4f1 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
@@ -25,17 +25,6 @@ public class EntitlementCertificate {
}
/**
- *
- * @param certificate
- * @param key
- */
- public EntitlementCertificate(String certificate, String key) {
- this.name = "client";
- this.certificate = certificate;
- this.key = key;
- }
-
- /**
* @return the certificate
*/
public String getCertificate() {
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java
index 46b5119..0904ee5 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java
@@ -4,14 +4,22 @@ import java.security.cert.X509Extension;
import javax.servlet.http.HttpServletRequest;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.enterprise.server.content.EntitlementManagerBean;
+
public class ContentFilter {
+ private final Log log = LogFactory.getLog(EntitlementManagerBean.class);
+
static final String CERTS = "javax.servlet.request.X509Certificate";
void filter(HttpServletRequest request, int repoId) throws EntitlementException {
X509Extension[] certificates = (X509Extension[]) request.getAttribute(CERTS);
if (certificates == null) {
- throw new EntitlementException("client x.509 cert not passed");
+ log.warn("x509 client certificate not passed, not-checked.");
+ return;
}
String oid = objectIdentifier(repoId);
for (X509Extension x509 : certificates) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
index cb2d21d..3ec181f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
@@ -25,59 +25,28 @@ public class EntitlementManagerBean implements EntitlementManagerLocal, Entitlem
@RequiredPermission(Permission.MANAGE_INVENTORY)
public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
List<EntitlementCertificate> list = new ArrayList<EntitlementCertificate>();
- if (resourceId % 2 == 0) {
- list.add(getEven());
- } else {
- list.add(getOdd());
- }
- return list;
- }
-
- /**
- * Get certificate for even numbered resource ids.
- * @return The cert.
- * @note This is a prototype hack.
- */
- private EntitlementCertificate getOdd() {
DummyLoader loader = new DummyLoader();
try {
- return loader.getOdd();
+ list.add(loader.load(resourceId));
} catch (Exception ex) {
- log.error("Certificate (ODD), not-found", ex);
+ log.warn("x.509 cert for: " //
+ + resourceId //
+ + " not-found in: " //
+ + DummyLoader.dir);
}
- return null;
- }
-
- /**
- * Get certificate for odd numbered resource ids.
- * @return The cert.
- * @note This is a prototype hack.
- */
- private EntitlementCertificate getEven() {
- DummyLoader loader = new DummyLoader();
- try {
- return loader.getEven();
- } catch (Exception ex) {
- log.error("Certificate (EVEN), not-found", ex);
- }
- return null;
+ return list;
}
}
class DummyLoader {
- private static final String dir = "/etc/pki/yum/rhq";
-
- EntitlementCertificate getOdd() throws IOException {
- String key = read("odd.key");
- String pem = read("odd.pem");
- return new EntitlementCertificate(key, pem);
- }
+ static final String dir = "/etc/pki/rhq";
- EntitlementCertificate getEven() throws IOException {
- String key = read("even.key");
- String pem = read("even.pem");
- return new EntitlementCertificate(key, pem);
+ EntitlementCertificate load(int resourceId) throws IOException {
+ String name = String.valueOf(resourceId);
+ String key = read(name + ".key");
+ String pem = read(name + ".pem");
+ return new EntitlementCertificate(name, key, pem);
}
private String read(String fn) throws IOException {
commit 17aafa6f54b45a200adba6293fda78ec8b290316
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Fri Jan 22 13:57:54 2010 -0800
removing system.out
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
index 09b049d..b4855ce 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
@@ -65,7 +65,6 @@ public class RepoDetailsUIBean {
Subject subject = EnterpriseFacesContextUtility.getSubject();
Integer id = FacesContextUtility.getRequiredRequestParameter("id", Integer.class);
String retval = LookupUtil.getRepoManagerLocal().calculateSyncStatus(subject, id);
- System.out.println("getSyncStatus: " + retval);
return retval;
}
@@ -85,7 +84,6 @@ public class RepoDetailsUIBean {
} else {
retval = "0";
}
- System.out.println("getPercentComplete: " + retval);
return retval;
}
commit a168b7fa13aa1e888f8aee85a4e2321e91b53766
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Fri Jan 22 13:50:20 2010 -0800
0000 - various bugfixes
- Fixing some refresh issues with repo details page but still isn't
perfect
- Chaqnging ContentSourceManagerBean to redownload any package that has
a missmatched md5 sum. before we would error out
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
index cdf7b25..09b049d 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
@@ -64,7 +64,9 @@ public class RepoDetailsUIBean {
public String getSyncStatus() {
Subject subject = EnterpriseFacesContextUtility.getSubject();
Integer id = FacesContextUtility.getRequiredRequestParameter("id", Integer.class);
- return LookupUtil.getRepoManagerLocal().calculateSyncStatus(subject, id);
+ String retval = LookupUtil.getRepoManagerLocal().calculateSyncStatus(subject, id);
+ System.out.println("getSyncStatus: " + retval);
+ return retval;
}
public RepoSyncResults getSyncResults() {
@@ -77,11 +79,14 @@ public class RepoDetailsUIBean {
Subject subject = EnterpriseFacesContextUtility.getSubject();
Integer id = FacesContextUtility.getRequiredRequestParameter("id", Integer.class);
RepoSyncResults r = LookupUtil.getRepoManagerLocal().getMostRecentSyncResults(subject, id);
+ String retval;
if (r != null && r.getPercentComplete() != null) {
- return r.getPercentComplete().toString();
+ retval = r.getPercentComplete().toString();
} else {
- return "0";
+ retval = "0";
}
+ System.out.println("getPercentComplete: " + retval);
+ return retval;
}
public String sync() {
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
index 5f93c10..5b5a5ae 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
@@ -89,17 +89,18 @@
timeZone="#{ServerInfoUIBean.timeZone}" />
</h:outputText></td>
</tr>
+
+ <!-- ******* START AJAX REFRESH/POLLING BLOCK ****** -->
+ <a4j:region>
+ <a4j:poll id="statusPoll" interval="1005"
+ reRender="syncPercent,syncStatus" />
<tr>
<td align="right"><b>Synchronization Status:</b></td>
<td align="left"><c:choose>
<c:when
test="#{RepoDetailsUIBean.percentComplete != '100'}">
- <a4j:region>
- <a4j:poll id="statusPoll" interval="1000"
- reRender="syncStatus" />
<h:outputText id="syncStatus"
value="#{RepoDetailsUIBean.syncStatus}" />
- </a4j:region>
</c:when>
<c:otherwise>
<h:outputText id="syncStatus"
@@ -107,26 +108,21 @@
</c:otherwise>
</c:choose></td>
</tr>
- <!--
<tr>
<td align="right"><b>Raw Percentage :</b></td>
<td align="left">
- <a4j:region>
- <a4j:poll id="percentPoll" interval="1005"
- reRender="syncPercent" />
<h:outputText id="syncPercent"
value="#{RepoDetailsUIBean.percentComplete}" />
- </a4j:region>
</td>
</tr>
- -->
+ <!--
<tr>
- <td align="right"><b>Synchronization Progress:</b></td>
+ <td align="right"><b>Synchronization Progress 1:</b></td>
<td align="left">
<c:choose>
<c:when
test="#{RepoDetailsUIBean.showProgressBar}">
- <rich:progressBar
+ <rich:progressBar id="syncProgress"
value="#{RepoDetailsUIBean.percentComplete}"
label="#{RepoDetailsUIBean.percentComplete} %"
interval="999" minValue="-1" maxValue="99">
@@ -141,6 +137,23 @@
</c:choose>
</td>
</tr>
+ -->
+ <tr>
+ <td align="right"><b>Synchronization Progress:</b></td>
+ <td align="left">
+ <rich:progressBar id="syncProgress"
+ value="#{RepoDetailsUIBean.percentComplete}"
+ label="#{RepoDetailsUIBean.percentComplete} %"
+ interval="999" minValue="-1" maxValue="99">
+ <f:facet name="complete">
+ <h:outputText value="Synchronizing Complete" />
+ </f:facet>
+ <f:facet name="initial">
+ <h:outputText value="Not Synching" />
+ </f:facet>
+ </rich:progressBar>
+ </td>
+ </tr>
<tr>
<td align="right"><b>Synchronization Results:</b></td>
<td align="left"><h:outputLink
@@ -167,16 +180,11 @@
operation="hide" event="onclick" />
</h:panelGroup>
</f:facet>
- <a4j:region>
- <a4j:poll id="resultsPoll" interval="2000"
- reRender="syncResults" />
- <PRE><h:outputText id="syncResults"
- value="#{RepoDetailsUIBean.syncResults.results}" /></PRE>
- </a4j:region>
-
-
+ <PRE><h:outputText value="#{RepoDetailsUIBean.syncResults.results}" /></PRE>
</rich:modalPanel></td>
</tr>
+ </a4j:region>
+ <!-- ******* END AJAX REFRESH/POLLING BLOCK ****** -->
</table>
</rich:panel>
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 1f9c62e..cc1b11b 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
@@ -847,23 +847,32 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
// store content to local file system
File outputFile = getPackageBitsLocalFileAndCreateParentDir(pv.getId(), pv.getFileName());
log.info("OutPutFile is located at: " + outputFile);
+ boolean download = false;
+
if (outputFile.exists()) {
// hmmm... it already exists, maybe we already have it?
// if the MD5's match, just ignore this download request and continue on
+ // If they are different we re-download
String expectedMD5 = (pv.getMD5() != null) ? pv.getMD5() : "<unspecified MD5>";
String actualMD5 = MessageDigestGenerator.getDigestString(outputFile);
if (!expectedMD5.trim().toLowerCase().equals(actualMD5.toLowerCase())) {
- throw new Exception("Already have package bits for [" + pv + "] located at [" + outputFile
+ log.error("Already have package bits for [" + pv + "] located at [" + outputFile
+ "] but the MD5 hashcodes do not match. Expected MD5=[" + expectedMD5
- + "], Actual MD5=[" + actualMD5 + "]");
+ + "], Actual MD5=[" + actualMD5 + "] - redownloading package");
+ download = true;
} else {
log.info("Asked to download package bits but we already have it at [" + outputFile
+ "] with matching MD5 of [" + actualMD5 + "]");
+ download = false;
}
} else {
+ download = true;
+ }
+ if (download) {
StreamUtil.copy(bitsStream, new FileOutputStream(outputFile), true);
bitsStream = null;
}
+
}
} finally {
if (ps != null) {
commit b069b2977163477e1d95cd91b36168471b5e8569
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Fri Jan 22 15:55:05 2010 -0500
Adding logic to populate the default plugin configuration at the registration time. If not, the inventory -> connection tab will show up as empty as it sets to null
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
index 49b6334..fe4b61e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
@@ -32,6 +32,8 @@ import org.apache.commons.logging.LogFactory;
import org.jboss.annotation.IgnoreDependency;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.InventoryStatus;
@@ -39,6 +41,7 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
+import org.rhq.enterprise.server.configuration.ConfigurationManagerLocal;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.core.AgentManagerLocal;
import org.rhq.enterprise.server.resource.ResourceAlreadyExistsException;
@@ -56,6 +59,9 @@ public class RegistrationManagerBean implements RegistrationManagerLocal, Regist
@IgnoreDependency
private ResourceManagerLocal resourceManager;
@EJB
+ @IgnoreDependency
+ private ConfigurationManagerLocal configManager;
+ @EJB
private SubjectManagerLocal subjectManager;
@EJB
private AgentManagerLocal agentManager;
@@ -74,6 +80,13 @@ public class RegistrationManagerBean implements RegistrationManagerLocal, Regist
throw new IllegalStateException(e);
}
+ ResourceType resourceType = platform.getResourceType();
+ ConfigurationDefinition configDefinition = configManager.getPluginConfigurationDefinitionForResourceType(user,
+ resourceType.getId());
+
+ Configuration platformConfig = configDefinition.getDefaultTemplate().getConfiguration();
+
+ platform.setPluginConfiguration(platformConfig);
platform.setInventoryStatus(InventoryStatus.COMMITTED);
Agent agent = createFakeAgent(platform);
commit a41355483ee63f14bc7d8fe3ddd655c3f141005e
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Fri Jan 22 15:25:29 2010 -0500
Incorrect mapping of webservice bean to logic bean.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 698621d..b427713 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -227,7 +227,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public void deleteCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "cveId") int cveId) {
- advisoryManager.deleteAdvisoryCVE(user, cveId);
+ advisoryManager.deleteCVE(user, cveId);
}
public void deleteAdvisoryCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "advId") int advId) {
commit de17114d9d1e65efeba2059e1415e4f5a85709c5
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Fri Jan 22 15:15:12 2010 -0500
Changes to allow advisory operations over web services
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java
index 86155b0..32d2518 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Advisory.java
@@ -96,9 +96,6 @@ public class Advisory implements Serializable {
private long lastModifiedDate;
@OneToMany(mappedBy = "advisory", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
- private Set<AdvisoryCVE> advisorycves;
-
- @OneToMany(mappedBy = "advisory", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private Set<AdvisoryPackage> advisorypkgs;
@OneToMany(mappedBy = "advisory", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@@ -220,14 +217,6 @@ public class Advisory implements Serializable {
return lastModifiedDate;
}
- public Set<AdvisoryCVE> getAdvisorycves() {
- return advisorycves;
- }
-
- public void setAdvisorycves(Set<AdvisoryCVE> advisorycves) {
- this.advisorycves = advisorycves;
- }
-
public Set<AdvisoryPackage> getAdvisorypkgs() {
return advisorypkgs;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java
index bc9ad68..346880c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java
@@ -66,7 +66,6 @@ public class AdvisoryCVE implements Serializable {
@Id
private int id;
- @XmlTransient
@ManyToOne
@JoinColumn(name = "ADVISORY_ID", referencedColumnName = "ID", nullable = false)
private Advisory advisory;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java
index 72313da..db349f3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/composite/AdvisoryDetailsComposite.java
@@ -36,7 +36,7 @@ import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.util.StringUtils;
/**
- *
+ *
* @author Pradeep Kilambi
*
*/
@@ -54,7 +54,6 @@ public class AdvisoryDetailsComposite implements Serializable {
private final String severity;
private final Date updateDate;
private final Date issueDate;
- private final String cve;
private final List<PackageVersion> pkgs;
private String bugid;
@@ -70,7 +69,6 @@ public class AdvisoryDetailsComposite implements Serializable {
this.severity = severity;
this.updateDate = new Date(updateDate.longValue() * 1000L);
this.issueDate = new Date(issueDate.longValue() * 1000L);
- this.cve = getAdvisoryCVE();
this.pkgs = getAdvisoryPackages();
this.bugid = getBugid();
@@ -85,15 +83,6 @@ public class AdvisoryDetailsComposite implements Serializable {
return pkges;
}
- private String getAdvisoryCVE() {
- List<String> cves = new ArrayList<String>();
- Set<AdvisoryCVE> acves = advisory.getAdvisorycves();
- for (AdvisoryCVE acve : acves) {
- cves.add(acve.getCVE().getName());
- }
- return StringUtils.getListAsString(cves, " ");
- }
-
public static long getSerialversionuid() {
return serialVersionUID;
}
@@ -130,10 +119,6 @@ public class AdvisoryDetailsComposite implements Serializable {
return severity;
}
- public String getCve() {
- return cve;
- }
-
public List<PackageVersion> getPkgs() {
return pkgs;
}
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java
index 3f22fa0..48cf125 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java
@@ -22,9 +22,14 @@
*/
package org.rhq.enterprise.server.ws.test;
+import java.util.List;
+
import org.testng.annotations.Test;
import org.rhq.enterprise.server.ws.Advisory;
+import org.rhq.enterprise.server.ws.AdvisoryCVE;
+import org.rhq.enterprise.server.ws.Cve;
+import org.rhq.enterprise.server.ws.PageControl;
import org.rhq.enterprise.server.ws.Subject;
/**
@@ -42,7 +47,7 @@ public class WsAdvisoryManagerTest extends WsUnitTestBase {
// Setup
String label = "WsAdvisoryManagerTest.createGetDeleteAdvisory.label";
- String synopsis = "WsAdvisoryManagerTest.createGetDeleteAdvisory.name";
+ String synopsis = "WsAdvisoryManagerTest.createGetDeleteAdvisory.synopsis";
String type = "bugfix";
Subject admin = subjectUtil.admin();
@@ -71,4 +76,43 @@ public class WsAdvisoryManagerTest extends WsUnitTestBase {
assert retrieved == null;
}
+ @Test(enabled = TESTS_ENABLED)
+ public void createMapDeleteCve() throws Exception {
+
+ // Setup
+ String advLabel = "WsAdvisoryManagerTest.createMapDeleteCve.label";
+ String advSynopsis = "WsAdvisoryManagerTest.createMapDeleteCve.synopsis";
+ String advType = "bugfix";
+
+ String cveName = "WsAdvisoryManagerTest.createMapDeleteCve.name";
+
+ Subject admin = subjectUtil.admin();
+
+ PageControl pc = objectFactory.createPageControl();
+
+ // Test & Verify
+ Advisory createdAdvisory = service.createAdvisory(admin, advLabel, advType, advSynopsis);
+ assert createdAdvisory != null;
+
+ Cve createdCve = service.createCVE(admin, cveName);
+ assert createdCve != null;
+
+ AdvisoryCVE createdMapping = service.createAdvisoryCVE(admin, createdAdvisory, createdCve);
+ assert createdMapping != null;
+
+ assert advLabel.equals(createdMapping.getAdvisory().getAdvisory());
+
+ List<AdvisoryCVE> cveList = service.getAdvisoryCVEByAdvId(admin, createdAdvisory.getId(), pc);
+ assert cveList.size() == 1 : "Found: " + cveList.size();
+
+ service.deleteAdvisoryCVE(admin, createdAdvisory.getId());
+
+ List<AdvisoryCVE> deletedMappings = service.getAdvisoryCVEByAdvId(admin, createdAdvisory.getId(), pc);
+ assert deletedMappings != null;
+ assert deletedMappings.size() == 0;
+
+ // Cleanup
+ service.deleteCVE(admin, createdCve.getId());
+ service.deleteAdvisoryByAdvId(admin, createdAdvisory.getId());
+ }
}
commit 1764ede1f24ab601dead72a57737c1d216333de4
Author: Jeff Ortel <jortel(a)redhat.com>
Date: Fri Jan 22 13:58:10 2010 -0600
add (name) to cert.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
index 9315cda..602c5a9 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
@@ -1,8 +1,8 @@
package org.rhq.core.domain.content.transfer;
-
public class EntitlementCertificate {
+ private String name;
private String certificate;
private String key;
@@ -14,11 +14,23 @@ public class EntitlementCertificate {
}
/**
+ *
+ * @param certificate
+ * @param key
+ */
+ public EntitlementCertificate(String name, String certificate, String key) {
+ this.name = name;
+ this.certificate = certificate;
+ this.key = key;
+ }
+
+ /**
*
* @param certificate
* @param key
*/
public EntitlementCertificate(String certificate, String key) {
+ this.name = "client";
this.certificate = certificate;
this.key = key;
}
@@ -38,6 +50,20 @@ public class EntitlementCertificate {
}
/**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
* @return the private key
*/
public String getKey() {
commit 577c56cd2570a8f6034cbf5ef5e7e5a0e6cfd206
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jan 22 14:12:11 2010 -0500
merge changes if a cobbler distro needs to be changed
diff --git a/modules/enterprise/server/plugins/cobbler/src/main/java/org/rhq/enterprise/server/plugins/cobbler/CobblerServerPluginComponent.java b/modules/enterprise/server/plugins/cobbler/src/main/java/org/rhq/enterprise/server/plugins/cobbler/CobblerServerPluginComponent.java
index 30537c5..12cd116 100644
--- a/modules/enterprise/server/plugins/cobbler/src/main/java/org/rhq/enterprise/server/plugins/cobbler/CobblerServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/cobbler/src/main/java/org/rhq/enterprise/server/plugins/cobbler/CobblerServerPluginComponent.java
@@ -183,23 +183,26 @@ public class CobblerServerPluginComponent implements ServerPluginComponent, Cont
for (Distribution distribution : repoEntry.getValue().values()) {
- Distro cobblerDistro = cobblerDistros.get(distribution.getLabel());
- if (cobblerDistro == null) {
- String distroRootUrl = rootUrl + repoName + "/distributions/" + distribution.getLabel();
-
- cobblerDistro = new Distro(conn);
- cobblerDistro.setName(distribution.getLabel());
- cobblerDistro.setComment(COMMENT_MARKER + " " + distribution.getLabel());
- cobblerDistro.setKernel(distroRootUrl + "/images/pxeboot/vmlinuz"); // TODO what about other arches
- cobblerDistro.setInitrd(distroRootUrl + "/images/pxeboot/initrd.img"); // TODO what about other arches
- Map<String, String> ksmeta = new HashMap<String, String>();
- ksmeta.put("tree", distroRootUrl);
- cobblerDistro.setKsMeta(ksmeta);
- cobblerDistro.commit();
- log.info("Added distro to Cobbler: [" + distribution.getLabel() + "]");
+ Distro existingCobblerDistro = cobblerDistros.get(distribution.getLabel());
+ Distro desiredCobblerDistro = instantiateCobblerDistro(conn, distribution, repoName, rootUrl);
+
+ if (existingCobblerDistro != null) {
+ // cobbler already has a distro with the name we are looking for.
+ // let's make sure its data is the same, otherwise, we need to upgrade it.
+ // but first, we need to take it out of our map, because whatever is left in this map will be removed from Cobbler later.
+ cobblerDistros.remove(existingCobblerDistro.getName());
+
+ if (!compareCobblerDistros(existingCobblerDistro, desiredCobblerDistro)) {
+ // the one Cobbler has is old and needs to be updated with the latest data.
+ updateCobblerDistro(existingCobblerDistro, desiredCobblerDistro);
+ existingCobblerDistro.commit();
+ log.info("Updated existing Cobbler distro [" + distribution.getLabel() + "]");
+ } else {
+ log.debug("Cobbler already has distro [" + distribution.getLabel() + "]; keeping it");
+ }
} else {
- cobblerDistros.remove(cobblerDistro.getName());
- log.debug("Cobbler already has distro [" + distribution.getLabel() + "]");
+ desiredCobblerDistro.commit();
+ log.info("Added new distro to Cobbler: [" + distribution.getLabel() + "]");
}
}
}
@@ -208,17 +211,102 @@ public class CobblerServerPluginComponent implements ServerPluginComponent, Cont
for (Distro doomed : cobblerDistros.values()) {
if (doomed.getComment().startsWith(COMMENT_MARKER)) {
doomed.remove();
- log.info("Removed distro from Cobbler: [" + doomed.getName() + "]");
+ log.info("Removed obsolete distro from Cobbler: [" + doomed.getName() + "]");
}
}
} catch (Throwable t) {
- // TODO what should we do?
- t.printStackTrace();
+ log.error("Failed to synchronize distributions to Cobbler server", t);
} finally {
this.syncInProgress = false;
}
}
+ @SuppressWarnings("unchecked")
+ private void updateCobblerDistro(Distro existingCobblerDistro, Distro desiredCobblerDistro) {
+ existingCobblerDistro.setName(desiredCobblerDistro.getName());
+ existingCobblerDistro.setComment(desiredCobblerDistro.getComment());
+ existingCobblerDistro.setKernel(desiredCobblerDistro.getKernel());
+ existingCobblerDistro.setInitrd(desiredCobblerDistro.getInitrd());
+
+ Map<String, String> ksMetaDesired = desiredCobblerDistro.getKsMeta();
+ if (ksMetaDesired != null) {
+ Map<String, String> ksMetaExisting = existingCobblerDistro.getKsMeta();
+ if (ksMetaExisting == null) {
+ ksMetaExisting = new HashMap<String, String>(ksMetaDesired.size());
+ existingCobblerDistro.setKsMeta(ksMetaExisting);
+ }
+ ksMetaExisting.clear();
+ ksMetaExisting.putAll(ksMetaDesired);
+ } else {
+ existingCobblerDistro.setKsMeta(null);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private boolean compareCobblerDistros(Distro cobblerDistro1, Distro cobblerDistro2) {
+ if (!compareObjects(cobblerDistro1.getName(), cobblerDistro2.getName())) {
+ return false;
+ }
+ if (!compareObjects(cobblerDistro1.getComment(), cobblerDistro2.getComment())) {
+ return false;
+ }
+ if (!compareObjects(cobblerDistro1.getKernel(), cobblerDistro2.getKernel())) {
+ return false;
+ }
+ if (!compareObjects(cobblerDistro1.getInitrd(), cobblerDistro2.getInitrd())) {
+ return false;
+ }
+
+ Map<String, String> ksMeta1 = cobblerDistro1.getKsMeta();
+ Map<String, String> ksMeta2 = cobblerDistro2.getKsMeta();
+ String tree1 = null;
+ String tree2 = null;
+ if (ksMeta1 != null) {
+ tree1 = ksMeta1.get("tree");
+ }
+ if (ksMeta2 != null) {
+ tree2 = ksMeta2.get("tree");
+ }
+ if (!compareObjects(tree1, tree2)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Given a RHQ distribution domaon object, this instantiates a Cobbler Distro object
+ * that can allow Cobbler to access the distribution content.
+ * NOTE: this does NOT create the Distro on the Cobbler server, this only instantiates
+ * a Distro class object and returns it.
+ *
+ * @param conn a connection to the Cobbler server
+ * @param distribution the RHQ distribution data
+ * @param repoName the name of the repository that the distribution is associated with
+ * @param rootUrl the root URL where the distribution content can be found
+ * @return an instance of a Cobbler Distro object
+ */
+ private Distro instantiateCobblerDistro(CobblerConnection conn, Distribution distribution, String repoName,
+ String rootUrl) {
+
+ Distro cobblerDistro;
+ String distroRootUrl = rootUrl + repoName + "/distributions/" + distribution.getLabel();
+ String kernel = distroRootUrl + "/images/pxeboot/vmlinuz"; // TODO what about other arches
+ String initrd = distroRootUrl + "/images/pxeboot/initrd.img"; // TODO what about other arches
+ String ksTree = distroRootUrl;
+
+ cobblerDistro = new Distro(conn);
+ cobblerDistro.setName(distribution.getLabel());
+ cobblerDistro.setComment(COMMENT_MARKER + " " + distribution.getLabel());
+ cobblerDistro.setKernel(kernel);
+ cobblerDistro.setInitrd(initrd);
+ Map<String, String> ksmeta = new HashMap<String, String>();
+ ksmeta.put("tree", ksTree);
+ cobblerDistro.setKsMeta(ksmeta);
+
+ return cobblerDistro;
+ }
+
@Override
public String toString() {
if (this.context == null) {
@@ -345,4 +433,13 @@ public class CobblerServerPluginComponent implements ServerPluginComponent, Cont
}
return results;
}
+
+ private boolean compareObjects(Object o1, Object o2) {
+ // this ensures we don't throw an NPE if either is null
+ if (o1 != null) {
+ return o1.equals(o2);
+ } else {
+ return o2 == null;
+ }
+ }
}
commit d56f4706b452c08dd2f3d103c10d9783499ad690
Author: Jeff Ortel <jortel(a)redhat.com>
Date: Fri Jan 22 12:51:48 2010 -0600
change rhq.server.tomcat.security.client-auth to (want) to support x.509 authorization for content via https.
diff --git a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
index cf7e575..cd6f94a 100644
--- a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml
@@ -501,7 +501,7 @@ rhq.communications.multicast-detector.port=16162
# Server-side SSL Security Configuration for HTTPS thru Tomcat
# These are used for browser https: access and for incoming messages from agents over sslservlet transport
# [you cannot use ${x} variables - see https://jira.jboss.org/jira/browse/JBWEB-74]
-rhq.server.tomcat.security.client-auth-mode=false
+rhq.server.tomcat.security.client-auth-mode=want
rhq.server.tomcat.security.secure-socket-protocol=TLS
rhq.server.tomcat.security.algorithm=SunX509
rhq.server.tomcat.security.keystore.alias=RHQ
commit a61266b71bff54650bf0db559b8fe82929379610
Author: Jeff Ortel <jortel(a)redhat.com>
Date: Thu Jan 21 17:32:38 2010 -0600
Refactor x509 entitlement certificates stuff to new EntitlementManager SLSB.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
index e734083..9315cda 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
@@ -1,9 +1,5 @@
package org.rhq.core.domain.content.transfer;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
public class EntitlementCertificate {
@@ -11,34 +7,6 @@ public class EntitlementCertificate {
private String key;
/**
- * Get certificate for even numbered resource ids.
- * @return The cert.
- * @note This is a prototype hack.
- */
- public static EntitlementCertificate getOdd() {
- DummyLoader loader = new DummyLoader();
- try {
- return loader.getOdd();
- } catch (Exception ex) {
- }
- return null;
- }
-
- /**
- * Get certificate for odd numbered resource ids.
- * @return The cert.
- * @note This is a prototype hack.
- */
- public static EntitlementCertificate getEven() {
- DummyLoader loader = new DummyLoader();
- try {
- return loader.getEven();
- } catch (Exception ex) {
- }
- return null;
- }
-
- /**
*
*/
public EntitlementCertificate() {
@@ -82,32 +50,4 @@ public class EntitlementCertificate {
public void setKey(String key) {
this.key = key;
}
-}
-
-class DummyLoader {
-
- private static final String dir = "/etc/pki/yum/rhq";
-
- EntitlementCertificate getOdd() throws IOException {
- String key = read("odd.key");
- String pem = read("odd.pem");
- return new EntitlementCertificate(key, pem);
- }
-
- EntitlementCertificate getEven() throws IOException {
- String key = read("even.key");
- String pem = read("even.pem");
- return new EntitlementCertificate(key, pem);
- }
-
- private String read(String fn) throws IOException {
- String path = dir + File.separator + fn;
- File f = new File(path);
- byte[] buffer = new byte[(int) f.length()];
- BufferedInputStream istr = new BufferedInputStream(new FileInputStream(f));
- istr.read(buffer);
- String result = new String(buffer);
- istr.close();
- return result;
- }
-}
+}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
new file mode 100644
index 0000000..cb2d21d
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerBean.java
@@ -0,0 +1,93 @@
+package org.rhq.enterprise.server.content;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Stateless;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
+import org.rhq.enterprise.server.authz.RequiredPermission;
+
+@Stateless
+public class EntitlementManagerBean implements EntitlementManagerLocal, EntitlementManagerRemote {
+
+ private final Log log = LogFactory.getLog(EntitlementManagerBean.class);
+
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
+ List<EntitlementCertificate> list = new ArrayList<EntitlementCertificate>();
+ if (resourceId % 2 == 0) {
+ list.add(getEven());
+ } else {
+ list.add(getOdd());
+ }
+ return list;
+ }
+
+ /**
+ * Get certificate for even numbered resource ids.
+ * @return The cert.
+ * @note This is a prototype hack.
+ */
+ private EntitlementCertificate getOdd() {
+ DummyLoader loader = new DummyLoader();
+ try {
+ return loader.getOdd();
+ } catch (Exception ex) {
+ log.error("Certificate (ODD), not-found", ex);
+ }
+ return null;
+ }
+
+ /**
+ * Get certificate for odd numbered resource ids.
+ * @return The cert.
+ * @note This is a prototype hack.
+ */
+ private EntitlementCertificate getEven() {
+ DummyLoader loader = new DummyLoader();
+ try {
+ return loader.getEven();
+ } catch (Exception ex) {
+ log.error("Certificate (EVEN), not-found", ex);
+ }
+ return null;
+ }
+}
+
+class DummyLoader {
+
+ private static final String dir = "/etc/pki/yum/rhq";
+
+ EntitlementCertificate getOdd() throws IOException {
+ String key = read("odd.key");
+ String pem = read("odd.pem");
+ return new EntitlementCertificate(key, pem);
+ }
+
+ EntitlementCertificate getEven() throws IOException {
+ String key = read("even.key");
+ String pem = read("even.pem");
+ return new EntitlementCertificate(key, pem);
+ }
+
+ private String read(String fn) throws IOException {
+ String path = dir + File.separator + fn;
+ File f = new File(path);
+ byte[] buffer = new byte[(int) f.length()];
+ BufferedInputStream istr = new BufferedInputStream(new FileInputStream(f));
+ istr.read(buffer);
+ String result = new String(buffer);
+ istr.close();
+ return result;
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerLocal.java
new file mode 100644
index 0000000..8fe2554
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerLocal.java
@@ -0,0 +1,25 @@
+package org.rhq.enterprise.server.content;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
+
+/**
+ *
+ * @author jortel
+ *
+ */
+@Local
+public interface EntitlementManagerLocal {
+
+ /**
+ * Get a list of entitlement certificates for the specified resources.
+ * @param subject The logged in user's subject.
+ * @param resourceId The resource id.
+ * @return A list of certificates.
+ */
+ List<EntitlementCertificate> getCertificates(Subject subject, int resourceId);
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerRemote.java
new file mode 100644
index 0000000..16f1a0a
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/EntitlementManagerRemote.java
@@ -0,0 +1,29 @@
+package org.rhq.enterprise.server.content;
+
+import java.util.List;
+
+import javax.ejb.Remote;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
+import org.rhq.enterprise.server.system.ServerVersion;
+
+@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
+@WebService(targetNamespace = ServerVersion.namespace)
+@Remote
+public interface EntitlementManagerRemote {
+ /**
+ * Get a list of entitlement certificates for the specified resources.
+ * @param subject The logged in user's subject.
+ * @param resourceId The resource id.
+ * @return A list of certificates.
+ */
+ @WebMethod
+ List<EntitlementCertificate> getCertificates( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "resourceId") int resourceId);
+}
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 4c5177c..f819aa0 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
@@ -60,7 +60,6 @@ import org.rhq.core.domain.content.RepoRepoRelationship;
import org.rhq.core.domain.content.RepoSyncResults;
import org.rhq.core.domain.content.ResourceRepo;
import org.rhq.core.domain.content.composite.RepoComposite;
-import org.rhq.core.domain.content.transfer.EntitlementCertificate;
import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
@@ -245,17 +244,6 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
return list;
}
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
- List<EntitlementCertificate> list = new ArrayList<EntitlementCertificate>();
- if (resourceId % 2 == 0) {
- list.add(EntitlementCertificate.getEven());
- } else {
- list.add(EntitlementCertificate.getOdd());
- }
- return list;
- }
-
@SuppressWarnings("unchecked")
@RequiredPermission(Permission.MANAGE_INVENTORY)
public PageList<RepoComposite> findAvailableResourceSubscriptions(Subject subject, int resourceId, PageControl pc) {
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 187021d..aea0ef2 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
@@ -32,7 +32,6 @@ import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
import org.rhq.core.domain.content.RepoSyncResults;
import org.rhq.core.domain.content.composite.RepoComposite;
-import org.rhq.core.domain.content.transfer.EntitlementCertificate;
import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
@@ -389,12 +388,4 @@ public interface RepoManagerLocal {
* @return
*/
List<SubscribedRepo> findSubscriptions(Subject subject, int resourceId);
-
- /**
- * Get a list of entitlement certificates for the specified resources.
- * @param subject The logged in user's subject.
- * @param resourceId The resource id.
- * @return
- */
- List<EntitlementCertificate> getCertificates(Subject subject, int resourceId);
}
\ 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 6aefbac..0acbced 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
@@ -33,7 +33,6 @@ import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
-import org.rhq.core.domain.content.transfer.EntitlementCertificate;
import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
@@ -298,15 +297,4 @@ public interface RepoManagerRemote {
List<SubscribedRepo> findSubscriptions( //
@WebParam(name = "subject") Subject subject, //
@WebParam(name = "resourceId") int resourceId);
-
- /**
- * Get a list of entitlement certificates for the specified resources.
- * @param subject The logged in user's subject.
- * @param resourceId The resource id.
- * @return
- */
- @WebMethod
- List<EntitlementCertificate> getCertificates( //
- @WebParam(name = "subject") Subject subject, //
- @WebParam(name = "resourceId") int resourceId);
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index 9d2a8aa..3188ea2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -87,6 +87,8 @@ import org.rhq.enterprise.server.content.ContentUIManagerBean;
import org.rhq.enterprise.server.content.ContentUIManagerLocal;
import org.rhq.enterprise.server.content.DistributionManagerBean;
import org.rhq.enterprise.server.content.DistributionManagerLocal;
+import org.rhq.enterprise.server.content.EntitlementManagerBean;
+import org.rhq.enterprise.server.content.EntitlementManagerLocal;
import org.rhq.enterprise.server.content.RepoManagerBean;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.content.metadata.ContentSourceMetadataManagerBean;
@@ -426,6 +428,10 @@ public final class LookupUtil {
return lookupLocal(RepoManagerBean.class);
}
+ public static EntitlementManagerLocal getEntitlementManager() {
+ return lookupLocal(EntitlementManagerBean.class);
+ }
+
public static DistributionManagerLocal getDistributionManagerLocal() {
return lookupLocal(DistributionManagerBean.class);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 479f8b3..698621d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -117,6 +117,7 @@ import org.rhq.enterprise.server.content.AdvisoryManagerLocal;
import org.rhq.enterprise.server.content.ContentManagerLocal;
import org.rhq.enterprise.server.content.DistributionException;
import org.rhq.enterprise.server.content.DistributionManagerLocal;
+import org.rhq.enterprise.server.content.EntitlementManagerLocal;
import org.rhq.enterprise.server.content.RepoException;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
@@ -195,13 +196,13 @@ public class WebservicesManagerBean implements WebservicesRemote {
private SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
private SupportManagerLocal supportManager = LookupUtil.getSupportManager();
private SystemManagerLocal systemManager = LookupUtil.getSystemManager();
+ private EntitlementManagerLocal entitlementManager = LookupUtil.getEntitlementManager();
//ADVISORYMANAGER: BEGIN ------------------------------------------
public Advisory createAdvisory(@WebParam(name = "subject") Subject user,
- @WebParam(name = "advisory") String advisory,
- @WebParam(name = "advisoryType") String advisoryType,
- @WebParam(name = "advisoryName") String advisoryName) throws AdvisoryException {
+ @WebParam(name = "advisory") String advisory, @WebParam(name = "advisoryType") String advisoryType,
+ @WebParam(name = "advisoryName") String advisoryName) throws AdvisoryException {
return advisoryManager.createAdvisory(user, advisory, advisoryType, advisoryName);
}
@@ -211,14 +212,13 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public AdvisoryCVE createAdvisoryCVE(@WebParam(name = "subject") Subject user,
- @WebParam(name = "advisory") Advisory advisory,
- @WebParam(name = "cve") CVE cve) throws AdvisoryException {
+ @WebParam(name = "advisory") Advisory advisory, @WebParam(name = "cve") CVE cve) throws AdvisoryException {
return advisoryManager.createAdvisoryCVE(user, advisory, cve);
}
public AdvisoryPackage createAdvisoryPackage(@WebParam(name = "subject") Subject user,
- @WebParam(name = "advisory") Advisory advisory,
- @WebParam(name = "pkg") PackageVersion pkg) throws AdvisoryException {
+ @WebParam(name = "advisory") Advisory advisory, @WebParam(name = "pkg") PackageVersion pkg)
+ throws AdvisoryException {
return advisoryManager.createAdvisoryPackage(user, advisory, pkg);
}
@@ -234,8 +234,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
advisoryManager.deleteAdvisoryCVE(user, advId);
}
- public void deleteAdvisoryByAdvId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "advId") int advId) {
+ public void deleteAdvisoryByAdvId(@WebParam(name = "subject") Subject subject, @WebParam(name = "advId") int advId) {
advisoryManager.deleteAdvisoryByAdvId(subject, advId);
}
@@ -244,25 +243,22 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public List<AdvisoryPackage> findPackageByAdvisory(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "advId") int advId,
- @WebParam(name = "pc") PageControl pc) {
+ @WebParam(name = "advId") int advId, @WebParam(name = "pc") PageControl pc) {
return advisoryManager.findPackageByAdvisory(subject, advId, pc);
}
public PackageVersion findPackageVersionByPkgId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "rpmName") String rpmName,
- @WebParam(name = "pc") PageControl pc) {
+ @WebParam(name = "rpmName") String rpmName, @WebParam(name = "pc") PageControl pc) {
return advisoryManager.findPackageVersionByPkgId(subject, rpmName, pc);
}
public PageList<AdvisoryCVE> getAdvisoryCVEByAdvId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "advId") int advId,
- @WebParam(name = "pc") PageControl pc) {
+ @WebParam(name = "advId") int advId, @WebParam(name = "pc") PageControl pc) {
return advisoryManager.getAdvisoryCVEByAdvId(subject, advId, pc);
}
public List<AdvisoryBuglist> getAdvisoryBuglistByAdvId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "advId") int advId) {
+ @WebParam(name = "advId") int advId) {
return advisoryManager.getAdvisoryBuglistByAdvId(subject, advId);
}
@@ -275,14 +271,12 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public AdvisoryPackage findAdvisoryPackage(@WebParam(name = "subject") Subject overlord,
- @WebParam(name = "advId") int advId,
- @WebParam(name = "pkgVerId") int pkgVerId) {
+ @WebParam(name = "advId") int advId, @WebParam(name = "pkgVerId") int pkgVerId) {
return advisoryManager.findAdvisoryPackage(overlord, advId, pkgVerId);
}
public AdvisoryBuglist getAdvisoryBuglist(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "advId") int advId,
- @WebParam(name = "buginfo") String buginfo) {
+ @WebParam(name = "advId") int advId, @WebParam(name = "buginfo") String buginfo) {
return advisoryManager.getAdvisoryBuglist(subject, advId, buginfo);
}
@@ -571,7 +565,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public void deleteDistributionFilesByDistId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "distid") int distid) {
+ @WebParam(name = "distid") int distid) {
distributionManager.deleteDistributionByDistId(subject, distid);
}
@@ -588,20 +582,18 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public void deleteDistributionByDistId(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "distId") int distId) throws Exception {
+ @WebParam(name = "distId") int distId) throws Exception {
distributionManager.deleteDistributionByDistId(subject, distId);
}
public void deleteDistributionTypeByName(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "name") String name) {
+ @WebParam(name = "name") String name) {
distributionManager.deleteDistributionTypeByName(subject, name);
}
public Distribution createDistribution(@WebParam(name = "subject") Subject subject,
- @WebParam(name = "kslabel") String kslabel,
- @WebParam(name = "basepath") String basepath,
- @WebParam(name = "disttype") DistributionType disttype)
- throws DistributionException {
+ @WebParam(name = "kslabel") String kslabel, @WebParam(name = "basepath") String basepath,
+ @WebParam(name = "disttype") DistributionType disttype) throws DistributionException {
return distributionManager.createDistribution(subject, kslabel, basepath, disttype);
}
@@ -1082,6 +1074,6 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
- return repoManager.getCertificates(subject, resourceId);
+ return entitlementManager.getCertificates(subject, resourceId);
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
index 13f89df..86d48cf 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
@@ -12,6 +12,7 @@ import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
import org.rhq.enterprise.server.content.AdvisoryManagerRemote;
import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.DistributionManagerRemote;
+import org.rhq.enterprise.server.content.EntitlementManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
@@ -42,6 +43,7 @@ public interface WebservicesRemote extends //
AvailabilityManagerRemote,//
CallTimeDataManagerRemote,//
RepoManagerRemote,//
+ EntitlementManagerRemote, //
ConfigurationManagerRemote,//
ContentManagerRemote,//
//Removed as it was problematic for WS clients. Not sure if this well be re-enabled.
commit 554db9caf1534b8fe23fb5d00cfd399e02891ff8
Author: Jeff Ortel <jortel(a)redhat.com>
Date: Thu Jan 21 16:30:27 2010 -0600
x509 entitlement prototype.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
new file mode 100644
index 0000000..e734083
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/EntitlementCertificate.java
@@ -0,0 +1,113 @@
+package org.rhq.core.domain.content.transfer;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+public class EntitlementCertificate {
+
+ private String certificate;
+ private String key;
+
+ /**
+ * Get certificate for even numbered resource ids.
+ * @return The cert.
+ * @note This is a prototype hack.
+ */
+ public static EntitlementCertificate getOdd() {
+ DummyLoader loader = new DummyLoader();
+ try {
+ return loader.getOdd();
+ } catch (Exception ex) {
+ }
+ return null;
+ }
+
+ /**
+ * Get certificate for odd numbered resource ids.
+ * @return The cert.
+ * @note This is a prototype hack.
+ */
+ public static EntitlementCertificate getEven() {
+ DummyLoader loader = new DummyLoader();
+ try {
+ return loader.getEven();
+ } catch (Exception ex) {
+ }
+ return null;
+ }
+
+ /**
+ *
+ */
+ public EntitlementCertificate() {
+
+ }
+
+ /**
+ *
+ * @param certificate
+ * @param key
+ */
+ public EntitlementCertificate(String certificate, String key) {
+ this.certificate = certificate;
+ this.key = key;
+ }
+
+ /**
+ * @return the certificate
+ */
+ public String getCertificate() {
+ return certificate;
+ }
+
+ /**
+ * @param certificate the certificate to set
+ */
+ public void setCertificate(String certificate) {
+ this.certificate = certificate;
+ }
+
+ /**
+ * @return the private key
+ */
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * @param key the private key to set
+ */
+ public void setKey(String key) {
+ this.key = key;
+ }
+}
+
+class DummyLoader {
+
+ private static final String dir = "/etc/pki/yum/rhq";
+
+ EntitlementCertificate getOdd() throws IOException {
+ String key = read("odd.key");
+ String pem = read("odd.pem");
+ return new EntitlementCertificate(key, pem);
+ }
+
+ EntitlementCertificate getEven() throws IOException {
+ String key = read("even.key");
+ String pem = read("even.pem");
+ return new EntitlementCertificate(key, pem);
+ }
+
+ private String read(String fn) throws IOException {
+ String path = dir + File.separator + fn;
+ File f = new File(path);
+ byte[] buffer = new byte[(int) f.length()];
+ BufferedInputStream istr = new BufferedInputStream(new FileInputStream(f));
+ istr.read(buffer);
+ String result = new String(buffer);
+ istr.close();
+ return result;
+ }
+}
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java
new file mode 100644
index 0000000..46b5119
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentFilter.java
@@ -0,0 +1,36 @@
+package org.rhq.gui.content;
+
+import java.security.cert.X509Extension;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class ContentFilter {
+
+ static final String CERTS = "javax.servlet.request.X509Certificate";
+
+ void filter(HttpServletRequest request, int repoId) throws EntitlementException {
+ X509Extension[] certificates = (X509Extension[]) request.getAttribute(CERTS);
+ if (certificates == null) {
+ throw new EntitlementException("client x.509 cert not passed");
+ }
+ String oid = objectIdentifier(repoId);
+ for (X509Extension x509 : certificates) {
+ byte[] bytes = x509.getExtensionValue(oid);
+ if (bytes != null) {
+ return;
+ }
+ }
+ throw new EntitlementException("oid (" + oid + ") not found");
+ }
+
+ private String objectIdentifier(int repoId) {
+ String idstr = String.valueOf(repoId);
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < idstr.length(); i++) {
+ if (i > 0)
+ sb.append('.');
+ sb.append(idstr.charAt(i));
+ }
+ return sb.toString();
+ }
+}
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
index d883f19..cfcf1ec 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -51,6 +51,11 @@ import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
public class ContentHTTPServlet extends DefaultServlet {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
private final Log log = LogFactory.getLog(ContentHTTPServlet.class);
protected static final String CONTENT_URI = "/content/";
@@ -124,6 +129,15 @@ public class ContentHTTPServlet extends DefaultServlet {
renderRepoList(request, response);
return;
}
+
+ // validate entitlement
+ try {
+ ContentFilter x509Filter = new ContentFilter();
+ x509Filter.filter(request, repo.getId());
+ } catch (EntitlementException e) {
+ throw new ServletException(e);
+ }
+
// Check if type of content has been specified
String typeOfContent = getTypeOfContent(request.getRequestURI());
if (StringUtils.isBlank(typeOfContent)) {
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/EntitlementException.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/EntitlementException.java
new file mode 100644
index 0000000..59b1e4c
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/EntitlementException.java
@@ -0,0 +1,62 @@
+/*
+ * 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.gui.content;
+
+/**
+ * @author jortel
+ *
+ */
+public class EntitlementException extends Exception {
+
+ public static final long serialVersionUID = 0L;
+
+ /**
+ *
+ */
+ public EntitlementException() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ */
+ public EntitlementException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param cause
+ */
+ public EntitlementException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public EntitlementException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
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 d6b8e12..4c5177c 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
@@ -60,6 +60,7 @@ import org.rhq.core.domain.content.RepoRepoRelationship;
import org.rhq.core.domain.content.RepoSyncResults;
import org.rhq.core.domain.content.ResourceRepo;
import org.rhq.core.domain.content.composite.RepoComposite;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
@@ -233,8 +234,9 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
}
@RequiredPermission(Permission.MANAGE_INVENTORY)
- public PageList<SubscribedRepo> findSubscriptions(Subject subject, int resourceId, PageControl pc) {
- PageList<SubscribedRepo> list = new PageList<SubscribedRepo>();
+ public List<SubscribedRepo> findSubscriptions(Subject subject, int resourceId) {
+ List<SubscribedRepo> list = new ArrayList<SubscribedRepo>();
+ PageControl pc = new PageControl();
for (RepoComposite repoComposite : findResourceSubscriptions(subject, resourceId, pc)) {
Repo repo = repoComposite.getRepo();
SubscribedRepo summary = new SubscribedRepo(repo.getId(), repo.getName());
@@ -243,6 +245,17 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
return list;
}
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
+ List<EntitlementCertificate> list = new ArrayList<EntitlementCertificate>();
+ if (resourceId % 2 == 0) {
+ list.add(EntitlementCertificate.getEven());
+ } else {
+ list.add(EntitlementCertificate.getOdd());
+ }
+ return list;
+ }
+
@SuppressWarnings("unchecked")
@RequiredPermission(Permission.MANAGE_INVENTORY)
public PageList<RepoComposite> findAvailableResourceSubscriptions(Subject subject, int resourceId, PageControl pc) {
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 b2cf635..187021d 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
@@ -32,6 +32,7 @@ import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
import org.rhq.core.domain.content.RepoSyncResults;
import org.rhq.core.domain.content.composite.RepoComposite;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
@@ -64,15 +65,6 @@ public interface RepoManagerLocal {
PageList<RepoComposite> findResourceSubscriptions(Subject subject, int resourceId, PageControl pc);
/**
- * Gets all repos that are subscribed to by the given resource.
- * @param subject
- * @param resourceId
- * @param pc
- * @return
- */
- PageList<SubscribedRepo> findSubscriptions(Subject subject, int resourceId, PageControl pc);
-
- /**
* Gets all repos that aren't subscribed to for the given resource.
*
* @param subject
@@ -390,4 +382,19 @@ public interface RepoManagerLocal {
*/
RepoSyncResults getMostRecentSyncResults(Subject subject, int repoId);
+ /**
+ * Gets all repos that are subscribed to by the given resource.
+ * @param subject
+ * @param resourceId
+ * @return
+ */
+ List<SubscribedRepo> findSubscriptions(Subject subject, int resourceId);
+
+ /**
+ * Get a list of entitlement certificates for the specified resources.
+ * @param subject The logged in user's subject.
+ * @param resourceId The resource id.
+ * @return
+ */
+ List<EntitlementCertificate> getCertificates(Subject subject, int resourceId);
}
\ 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 3ff4f3a..6aefbac 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
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.server.content;
+import java.util.List;
+
import javax.ejb.Remote;
import javax.jws.WebMethod;
import javax.jws.WebParam;
@@ -31,6 +33,7 @@ import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
@@ -284,9 +287,26 @@ public interface RepoManagerRemote {
int synchronizeRepos(@WebParam(name = "subject") Subject subject, @WebParam(name = "repoIds") Integer[] repoIds)
throws Exception;
+ /**
+ * Get a list of truncated Repo objects that represent the
+ * subscriptions for the specified resource.
+ * @param subject The logged in user's subject.
+ * @param resourceId The id of the resource.
+ * @return A list of repos.
+ */
@WebMethod
- PageList<SubscribedRepo> findSubscriptions( //
+ List<SubscribedRepo> findSubscriptions( //
@WebParam(name = "subject") Subject subject, //
- @WebParam(name = "resourceId") int resourceId, //
- @WebParam(name = "resource") PageControl pc);
+ @WebParam(name = "resourceId") int resourceId);
+
+ /**
+ * Get a list of entitlement certificates for the specified resources.
+ * @param subject The logged in user's subject.
+ * @param resourceId The resource id.
+ * @return
+ */
+ @WebMethod
+ List<EntitlementCertificate> getCertificates( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "resourceId") int resourceId);
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index e737c2d..479f8b3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -62,6 +62,7 @@ import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
+import org.rhq.core.domain.content.transfer.EntitlementCertificate;
import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.AlertCriteria;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
@@ -1076,8 +1077,11 @@ public class WebservicesManagerBean implements WebservicesRemote {
return repoManager.findAssociatedAdvisory(subject, repoId, pc);
}
- public PageList<SubscribedRepo> findSubscriptions(Subject subject, int resourceId,
- PageControl pc) {
- return repoManager.findSubscriptions(subject, resourceId, pc);
+ public List<SubscribedRepo> findSubscriptions(Subject subject, int resourceId) {
+ return repoManager.findSubscriptions(subject, resourceId);
+ }
+
+ public List<EntitlementCertificate> getCertificates(Subject subject, int resourceId) {
+ return repoManager.getCertificates(subject, resourceId);
}
}
commit d26acbd2712dbc9c8aca733294bac653ba95142a
Author: Sayli Karmarkar <skarmark(a)redhat.com>
Date: Fri Jan 22 03:06:14 2010 -0500
Fixing issues with rendering of Content Update page for a resource
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/content-beans.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/content-beans.xml
index 8f7f449..5ab9219 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/content-beans.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/content-beans.xml
@@ -177,6 +177,11 @@
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
+ <managed-bean-name>ResourceUpdatePackageVersionsUIBean</managed-bean-name>
+ <managed-bean-class>org.rhq.enterprise.gui.content.ResourceUpdatePackageVersionsUIBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
<managed-bean-name>AvailableResourceReposUIBean</managed-bean-name>
<managed-bean-class>org.rhq.enterprise.gui.content.AvailableResourceReposUIBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/content-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/content-navigation.xml
index aa6c245..2c0f473 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/content-navigation.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/content-navigation.xml
@@ -71,6 +71,26 @@
</navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/rhq/resource/content/update.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-outcome>uploadNew</from-outcome>
+ <to-view-id>/rhq/resource/content/create.xhtml?id=#{param.id}</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-action>#{CreateNewPackageUIBean.deployExisting}</from-action>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/rhq/resource/content/confirm-create.xhtml</to-view-id>
+ </navigation-case>
+
+ </navigation-rule>
+
+
+
<navigation-rule>
<from-view-id>/rhq/resource/content/history.xhtml</from-view-id>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/update.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/update.xhtml
index 09c6e6b..aa05fee 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/update.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/update.xhtml
@@ -29,12 +29,12 @@
to enable more existing packages for deployment, use the subscriptions sub-tab to subscribe this resource
to more repositories.</p>
- <a4j:keepAlive beanName="ResourcePackageVersionsUIBean"/>
+ <a4j:keepAlive beanName="ResourceUpdatePackageVersionsUIBean"/>
- <ui:param name="resourcePackageVersionsDataModel" value="#{ResourcePackageVersionsUIBean.dataModel}"/>
- <rich:dataTable id="resourcePackageVersionsDataTable"
- rows="#{PageControl.ResourcePackageVersionsList.pageSize}"
- value="#{resourcePackageVersionsDataModel}"
+ <ui:param name="resourceUpdatePackageVersionsDataModel" value="#{ResourceUpdatePackageVersionsUIBean.dataModel}"/>
+ <rich:dataTable id="resourceUpdatePackageVersionsDataTable"
+ rows="#{PageControl.ResourceUpdatePackageVersionsList.pageSize}"
+ value="#{resourceUpdatePackageVersionsDataModel}"
var="item"
width="100%"
columnsWidth="1%, 15%, 10%, 10%, 10%, 54%"
@@ -44,7 +44,7 @@
onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
<f:facet name="PageControlView">
- <onc:paginationControl id="ResourcePackageVersionsList" />
+ <onc:paginationControl id="ResourceUpdatePackageVersionsList" />
</f:facet>
<rich:column>
@@ -115,9 +115,9 @@
rendered="${ResourceUIBean.permissions.content}"/>
<ui:include src="/rhq/resource/include/pagination.xhtml">
- <ui:param name="paginationDataTableName" value="resourcePackageVersionsDataTable"/>
- <ui:param name="paginationDataModel" value="#{resourcePackageVersionsDataModel}"/>
- <ui:param name="paginationPageControl" value="#{PageControl.ResourcePackageVersionsList}"/>
+ <ui:param name="paginationDataTableName" value="resourceUpdatePackageVersionsDataTable"/>
+ <ui:param name="paginationDataModel" value="#{resourceUpdatePackageVersionsDataModel}"/>
+ <ui:param name="paginationPageControl" value="#{PageControl.ResourceUpdatePackageVersionsList}"/>
</ui:include>
</rich:column>
</rich:columnGroup>
@@ -126,9 +126,26 @@
</rich:dataTable>
+ </rich:panel>
+
+ <rich:panel styleClass="BlockContent"
+ rendered="${ResourceUIBean.permissions.content}">
+ <f:facet name="header"><h:outputText value="Upload New Package"/></f:facet>
+
+ <p>The following option will begin the workflow to upload a new package into the system. Once
+ the package information has been specified and the file uploaded, the workflow to deploy the newly
+ created package to this resource will resume.</p>
+
+ <h:panelGrid columns="1" styleClass="buttons-table" columnClasses="button-cell">
+ <h:commandButton action="uploadNew"
+ value="UPLOAD NEW PACKAGE" styleClass="buttonmed"/>
+ </h:panelGrid>
+
+ <br/>
</rich:panel>
- </h:form>
+
+ </h:form>
</ui:define>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
index 3d72055..e003579 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
@@ -225,15 +225,15 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
public PageList<PackageVersionComposite> getPackageVersionCompositesByFilter(Subject user, int resourceId,
String filter, PageControl pc) {
pc.initDefaultOrderingField("pv.generalPackage.name", PageOrdering.ASC);
+ PageControl unlimitedpc = PageControl.getUnlimitedInstance();
Query queryInstalled = PersistenceUtility.createQueryWithOrderBy(entityManager,
- InstalledPackage.QUERY_FIND_PACKAGE_LIST_ITEM_COMPOSITE, pc);
+ InstalledPackage.QUERY_FIND_PACKAGE_LIST_ITEM_COMPOSITE, unlimitedpc);
queryInstalled.setParameter("resourceId", resourceId);
queryInstalled.setParameter("packageTypeFilterId", null);
queryInstalled.setParameter("packageVersionFilter", null);
queryInstalled.setParameter("search", null);
- queryInstalled.setParameter("search", null);
List<PackageListItemComposite> packagesInstalled = queryInstalled.getResultList();
@@ -243,7 +243,7 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
}
Query query = PersistenceUtility.createQueryWithOrderBy(entityManager,
- PackageVersion.QUERY_FIND_COMPOSITE_BY_FILTERS, pc);
+ PackageVersion.QUERY_FIND_COMPOSITE_BY_FILTERS, unlimitedpc);
Query queryCount = PersistenceUtility.createCountQuery(entityManager,
PackageVersion.QUERY_FIND_COMPOSITE_BY_FILTERS);
@@ -273,15 +273,15 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
public PageList<PackageVersionComposite> getUpdatePackageVersionCompositesByFilter(Subject user, int resourceId,
String filter, PageControl pc) {
pc.initDefaultOrderingField("pv.generalPackage.name", PageOrdering.ASC);
+ PageControl unlimitedpc = PageControl.getUnlimitedInstance();
Query queryInstalled = PersistenceUtility.createQueryWithOrderBy(entityManager,
- InstalledPackage.QUERY_FIND_PACKAGE_LIST_ITEM_COMPOSITE, pc);
+ InstalledPackage.QUERY_FIND_PACKAGE_LIST_ITEM_COMPOSITE, unlimitedpc);
queryInstalled.setParameter("resourceId", resourceId);
queryInstalled.setParameter("packageTypeFilterId", null);
queryInstalled.setParameter("packageVersionFilter", null);
queryInstalled.setParameter("search", null);
- queryInstalled.setParameter("search", null);
List<PackageListItemComposite> packagesInstalled = queryInstalled.getResultList();
@@ -291,7 +291,7 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
}
Query query = PersistenceUtility.createQueryWithOrderBy(entityManager,
- PackageVersion.QUERY_FIND_COMPOSITE_BY_FILTERS, pc);
+ PackageVersion.QUERY_FIND_COMPOSITE_BY_FILTERS, unlimitedpc);
query.setParameter("resourceId", resourceId);
query.setParameter("filter", filter);
@@ -303,7 +303,7 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
for (PackageVersionComposite result : results) {
if (installedPackageNameAndVersion.get(result.getPackageName()) != null) {
- packageName = installedPackageNameAndVersion.get(result.getPackageName());
+ packageName = result.getPackageName();
if (installedPackageNameAndVersion.get(packageName).compareTo(result.getPackageVersion().getVersion()) < 0) {
modifiedResults.add(result);
diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java
index d04210e..74cc8b7 100644
--- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java
+++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java
@@ -101,12 +101,14 @@ public class RpmPackageDiscoveryDelegate {
BufferedReader rpmNameReader = new BufferedReader(new StringReader(capturedOutput));
String rpmName;
+
while ((rpmName = rpmNameReader.readLine()) != null) {
String name = null;
String version = null;
String architectureName = null;
try {
+
// Execute RPM query for each RPM
ProcessExecution rpmQuery = new ProcessExecution(rpmExecutable);
rpmQuery
@@ -179,8 +181,10 @@ public class RpmPackageDiscoveryDelegate {
log.error("Error creating resource package. RPM Name: " + rpmName + " Version: " + version
+ " Architecture: " + architectureName);
}
+
}
return packages;
+
}
-}
\ No newline at end of file
+}
commit 9107582e81396907000a5b255ab5e8afed53ef08
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Thu Jan 21 17:21:01 2010 -0800
1374 - bugfixes, cleanup
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
index a710a22..cdf7b25 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
@@ -24,6 +24,7 @@ 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.ContentSyncStatus;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.content.RepoSyncResults;
import org.rhq.core.gui.util.FacesContextUtility;
@@ -47,6 +48,19 @@ public class RepoDetailsUIBean {
return "edit";
}
+ public boolean getShowProgressBar() {
+ String syncStatus = getSyncStatus();
+ if (!syncStatus.equals(ContentSyncStatus.SUCCESS.toString())
+ && !syncStatus.equals(ContentSyncStatus.FAILURE.toString())
+ && !syncStatus.equals(ContentSyncStatus.NONE.toString())
+ && !syncStatus.equals(ContentSyncStatus.CANCELLED.toString())
+ && !syncStatus.equals(ContentSyncStatus.CANCELLING.toString())) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
public String getSyncStatus() {
Subject subject = EnterpriseFacesContextUtility.getSubject();
Integer id = FacesContextUtility.getRequiredRequestParameter("id", Integer.class);
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
index 7e9070f..5f93c10 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
@@ -107,19 +107,39 @@
</c:otherwise>
</c:choose></td>
</tr>
+ <!--
<tr>
- <td align="right"><b>Synchronization Complete:</b></td>
- <td align="left"><rich:progressBar
- value="#{RepoDetailsUIBean.percentComplete}"
- label="#{RepoDetailsUIBean.percentComplete} %"
- interval="999" minValue="0" maxValue="99">
- <f:facet name="complete">
- <h:outputText value="Synchronizing Complete" />
- </f:facet>
- <f:facet name="initial">
- <h:outputText value="Synching Not Started" />
- </f:facet>
- </rich:progressBar></td>
+ <td align="right"><b>Raw Percentage :</b></td>
+ <td align="left">
+ <a4j:region>
+ <a4j:poll id="percentPoll" interval="1005"
+ reRender="syncPercent" />
+ <h:outputText id="syncPercent"
+ value="#{RepoDetailsUIBean.percentComplete}" />
+ </a4j:region>
+ </td>
+ </tr>
+ -->
+ <tr>
+ <td align="right"><b>Synchronization Progress:</b></td>
+ <td align="left">
+ <c:choose>
+ <c:when
+ test="#{RepoDetailsUIBean.showProgressBar}">
+ <rich:progressBar
+ value="#{RepoDetailsUIBean.percentComplete}"
+ label="#{RepoDetailsUIBean.percentComplete} %"
+ interval="999" minValue="-1" maxValue="99">
+ <f:facet name="complete">
+ <h:outputText value="Synchronizing Complete" />
+ </f:facet>
+ </rich:progressBar>
+ </c:when>
+ <c:otherwise>
+ Not Synching
+ </c:otherwise>
+ </c:choose>
+ </td>
</tr>
<tr>
<td align="right"><b>Synchronization Results:</b></td>
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 4a40b72..21fac03 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
@@ -288,6 +288,7 @@ public class ContentProviderManager {
tracker.setResults(progress.toString());
tracker.setRepoSyncResults(repoManager.persistRepoSyncResults(tracker.getRepoSyncResults()));
log.debug("synchronizeRepo :: inProgress");
+ tracker = updatePercentComplete(tracker, repoManager);
if (tracker.getRepoSyncResults() == null) {
log.info("Repository [" + repo.getName()
commit 6022accd62237d7cd48926fabf7b1b650cf4b608
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jan 21 18:03:56 2010 -0500
create distros using the proper distro tree ks metadata entry
diff --git a/modules/enterprise/server/plugins/cobbler/src/main/java/org/rhq/enterprise/server/plugins/cobbler/CobblerServerPluginComponent.java b/modules/enterprise/server/plugins/cobbler/src/main/java/org/rhq/enterprise/server/plugins/cobbler/CobblerServerPluginComponent.java
index 4705bbd..30537c5 100644
--- a/modules/enterprise/server/plugins/cobbler/src/main/java/org/rhq/enterprise/server/plugins/cobbler/CobblerServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/cobbler/src/main/java/org/rhq/enterprise/server/plugins/cobbler/CobblerServerPluginComponent.java
@@ -55,8 +55,19 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class CobblerServerPluginComponent implements ServerPluginComponent, ControlFacet {
private static Log log = LogFactory.getLog(CobblerServerPluginComponent.class);
+ /**
+ * This string is placed at the start of all distro comments created in Cobbler.
+ * When we see this marker at the start of a distro comment, we know its a distro we created.
+ */
+ private static final String COMMENT_MARKER = "[rhq]";
+
private ServerPluginContext context;
+ /**
+ * Used to avoid having an operation running at the same time as a sync.
+ */
+ private boolean syncInProgress;
+
public void initialize(ServerPluginContext context) throws Exception {
this.context = context;
log.info("initialized: " + this);
@@ -77,53 +88,76 @@ public class CobblerServerPluginComponent implements ServerPluginComponent, Cont
public ControlResults invoke(String name, Configuration parameters) {
ControlResults controlResults = new ControlResults();
- if (name.equals("getCobblerDistros")) {
- String searchRegex = parameters.getSimpleValue("searchRegex", null);
- Pattern pattern = null;
- if (searchRegex != null) {
- pattern = Pattern.compile(searchRegex);
- }
+ try {
+ if (name.equals("getCobblerDistros")) {
+ String searchRegex = parameters.getSimpleValue("searchRegex", null);
+ Pattern pattern = null;
+ if (searchRegex != null) {
+ pattern = Pattern.compile(searchRegex);
+ }
- Configuration results = controlResults.getComplexResults();
- PropertyList list = new PropertyList("distros");
- results.put(list);
-
- Collection<Distro> distros = getAllCobblerDistros().values();
- for (Distro d : distros) {
- if (pattern == null || pattern.matcher(d.getName()).matches()) {
- PropertyMap map = new PropertyMap("distro");
- map.put(new PropertySimple("name", d.getName()));
- map.put(new PropertySimple("breed", d.getBreed()));
- map.put(new PropertySimple("osversion", d.getOsVersion()));
- map.put(new PropertySimple("arch", d.getArch()));
- map.put(new PropertySimple("initrd", d.getInitrd()));
- map.put(new PropertySimple("kernel", d.getKernel()));
- list.add(map);
+ Configuration results = controlResults.getComplexResults();
+ PropertyList list = new PropertyList("distros");
+ results.put(list);
+
+ Collection<Distro> distros = getAllCobblerDistros().values();
+ for (Distro d : distros) {
+ if (pattern == null || pattern.matcher(d.getName()).matches()) {
+ PropertyMap map = new PropertyMap("distro");
+ map.put(new PropertySimple("name", d.getName()));
+ map.put(new PropertySimple("breed", d.getBreed()));
+ map.put(new PropertySimple("osversion", d.getOsVersion()));
+ map.put(new PropertySimple("arch", d.getArch()));
+ map.put(new PropertySimple("initrd", d.getInitrd()));
+ map.put(new PropertySimple("kernel", d.getKernel()));
+ list.add(map);
+ }
+ }
+ } else if (name.equals("getCobblerProfiles")) {
+ String searchRegex = parameters.getSimpleValue("searchRegex", null);
+ Pattern pattern = null;
+ if (searchRegex != null) {
+ pattern = Pattern.compile(searchRegex);
}
- }
- } else if (name.equals("getCobblerProfiles")) {
- String searchRegex = parameters.getSimpleValue("searchRegex", null);
- Pattern pattern = null;
- if (searchRegex != null) {
- pattern = Pattern.compile(searchRegex);
- }
- Configuration results = controlResults.getComplexResults();
- PropertyList list = new PropertyList("profiles");
- results.put(list);
-
- List<Profile> profiles = getAllCobblerProfiles();
- for (Profile p : profiles) {
- if (pattern == null || pattern.matcher(p.getName()).matches()) {
- PropertyMap map = new PropertyMap("profile");
- map.put(new PropertySimple("name", p.getName()));
- map.put(new PropertySimple("distro", p.getDistro()));
- map.put(new PropertySimple("kickstart", p.getKickstart()));
- list.add(map);
+ Configuration results = controlResults.getComplexResults();
+ PropertyList list = new PropertyList("profiles");
+ results.put(list);
+
+ List<Profile> profiles = getAllCobblerProfiles();
+ for (Profile p : profiles) {
+ if (pattern == null || pattern.matcher(p.getName()).matches()) {
+ PropertyMap map = new PropertyMap("profile");
+ map.put(new PropertySimple("name", p.getName()));
+ map.put(new PropertySimple("distro", p.getDistro()));
+ map.put(new PropertySimple("kickstart", p.getKickstart()));
+ list.add(map);
+ }
+ }
+ } else if (name.equals("removeCobblerDistros")) {
+ String searchRegex = parameters.getSimpleValue("searchRegex", null);
+ Pattern pattern = null;
+ if (searchRegex != null) {
+ pattern = Pattern.compile(searchRegex);
}
+
+ if (!this.syncInProgress) {
+ Collection<Distro> distros = getAllCobblerDistros().values();
+ for (Distro d : distros) {
+ if (pattern == null || pattern.matcher(d.getName()).matches()) {
+ if (d.getComment().startsWith(COMMENT_MARKER)) {
+ d.remove();
+ }
+ }
+ }
+ } else {
+ controlResults.setError("A synchronize is currently in progress - please wait for it to finish");
+ }
+ } else {
+ controlResults.setError("Unknown operation name: " + name);
}
- } else {
- controlResults.setError("Unknown operation name: " + name);
+ } catch (Exception e) {
+ controlResults.setError(e);
}
return controlResults;
@@ -133,6 +167,8 @@ public class CobblerServerPluginComponent implements ServerPluginComponent, Cont
log.info("Synchronizing content to the local Cobbler server: " + this);
try {
+ this.syncInProgress = true;
+
Server server = LookupUtil.getServerManager().getServer();
String rootUrl = "http://" + server.getAddress() + ":" + server.getPort() + "/content/";
@@ -149,15 +185,15 @@ public class CobblerServerPluginComponent implements ServerPluginComponent, Cont
Distro cobblerDistro = cobblerDistros.get(distribution.getLabel());
if (cobblerDistro == null) {
+ String distroRootUrl = rootUrl + repoName + "/distributions/" + distribution.getLabel();
+
cobblerDistro = new Distro(conn);
cobblerDistro.setName(distribution.getLabel());
- cobblerDistro.setComment("[rhq] " + distribution.getLabel());
- cobblerDistro.setKernel(rootUrl + repoName + "/distributions/" + distribution.getLabel()
- + "/images/pxeboot/vmlinuz");
- cobblerDistro.setInitrd(rootUrl + repoName + "/distributions/" + distribution.getLabel()
- + "/images/pxeboot/initrd.img");
+ cobblerDistro.setComment(COMMENT_MARKER + " " + distribution.getLabel());
+ cobblerDistro.setKernel(distroRootUrl + "/images/pxeboot/vmlinuz"); // TODO what about other arches
+ cobblerDistro.setInitrd(distroRootUrl + "/images/pxeboot/initrd.img"); // TODO what about other arches
Map<String, String> ksmeta = new HashMap<String, String>();
- ksmeta.put("tree", "http://foo/releases/12/Fedora/x86_64/os/");
+ ksmeta.put("tree", distroRootUrl);
cobblerDistro.setKsMeta(ksmeta);
cobblerDistro.commit();
log.info("Added distro to Cobbler: [" + distribution.getLabel() + "]");
@@ -170,7 +206,7 @@ public class CobblerServerPluginComponent implements ServerPluginComponent, Cont
// now remove those RHQ distros that we no longer have, only remove RHQ distros though
for (Distro doomed : cobblerDistros.values()) {
- if (doomed.getComment().startsWith("[rhq]")) {
+ if (doomed.getComment().startsWith(COMMENT_MARKER)) {
doomed.remove();
log.info("Removed distro from Cobbler: [" + doomed.getName() + "]");
}
@@ -178,6 +214,8 @@ public class CobblerServerPluginComponent implements ServerPluginComponent, Cont
} catch (Throwable t) {
// TODO what should we do?
t.printStackTrace();
+ } finally {
+ this.syncInProgress = false;
}
}
diff --git a/modules/enterprise/server/plugins/cobbler/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/cobbler/src/main/resources/META-INF/rhq-serverplugin.xml
index 6121146..1bcc161 100644
--- a/modules/enterprise/server/plugins/cobbler/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/cobbler/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -46,6 +46,11 @@
</c:list-property>
</serverplugin:results>
</serverplugin:control>
+ <serverplugin:control name="removeCobblerDistros" description="Removes RHQ distros known to Cobbler. Any non-RHQ distros will remain intact.">
+ <serverplugin:parameters>
+ <c:simple-property name="searchRegex" required="false" description="If specified, only those distros whose name matches this regex will be removed" />
+ </serverplugin:parameters>
+ </serverplugin:control>
</serverplugin:plugin-component>
<serverplugin:scheduled-jobs>
commit f023dd906b540758278df9209437afb57527605e
Author: John Matthews <jmatthew(a)redhat.com>
Date: Thu Jan 21 17:01:37 2010 -0500
Fixes kickstarts through http content
- add support for HEAD requests
- urldecode the request for filenames
- add byte-range fetching through HTTP <important fix for anaconda fetching of rpm headers>
- allow package fetches to work when accessed under distribution trees
- decrease most logging to DEBUG not INFO
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
index f08964f..d883f19 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -29,6 +29,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.servlets.DefaultServlet;
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.net.URLCodec;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.text.StrTokenizer;
import org.apache.commons.logging.Log;
@@ -62,17 +64,19 @@ public class ContentHTTPServlet extends DefaultServlet {
protected ContentSourceManagerLocal contentSourceMgr;
protected DistributionManagerLocal distroMgr;
+ protected URLCodec urlCodec;
+
public ContentHTTPServlet() {
super();
}
public void init() throws ServletException {
super.init();
+ urlCodec = new URLCodec();
repoMgr = LookupUtil.getRepoManagerLocal();
contentMgr = LookupUtil.getContentManager();
contentSourceMgr = LookupUtil.getContentSourceManager();
distroMgr = LookupUtil.getDistributionManagerLocal();
- log.info("ContentHTTPServlet resolved references in init.");
}
protected boolean isIconRequest(HttpServletRequest request) {
@@ -82,11 +86,31 @@ public class ContentHTTPServlet extends DefaultServlet {
protected void doHead(HttpServletRequest request, HttpServletResponse response) throws IOException,
ServletException {
+ log.info("HEAD received: " + request.getRequestURI());
doGet(request, response);
}
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,
+ ServletException {
+ log.info("POST received: " + request.getRequestURI());
+ doGet(request, response);
+ }
+
+ protected void doPut(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+ log.info("PUT received: " + request.getRequestURI());
+ renderErrorPage(request, response);
+ }
+
+ protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException,
+ ServletException {
+ log.info("DELETE received: " + request.getRequestURI());
+ renderErrorPage(request, response);
+ }
+
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
log.info("doGet(): requestURI = " + request.getRequestURI());
+ response.setHeader("Accept-Ranges", "bytes");
+
if (isIconRequest(request)) {
// this request is for our icons which are static content in the webapp
// defer back to DefaultServlet.doGet and this will be served automatically
@@ -111,16 +135,16 @@ public class ContentHTTPServlet extends DefaultServlet {
// Determine what we should render, i.e.: packages or distributions
//
if (StringUtils.equalsIgnoreCase(typeOfContent, PACKAGES)) {
- log.info("render packages");
+ log.debug("render packages");
renderPackages(request, response, repo);
return;
} else if (StringUtils.equalsIgnoreCase(typeOfContent, DISTRIBUTIONS)) {
- log.info("render distributions");
+ log.debug("render distributions");
renderDistributions(request, response, repo);
return;
} else {
- log.info("Unable to determine what type of content was requested: " + typeOfContent);
+ log.debug("Unable to determine what type of content was requested: " + typeOfContent);
renderErrorPage(request, response);
return;
}
@@ -141,15 +165,15 @@ public class ContentHTTPServlet extends DefaultServlet {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
PageList<Repo> repos = repoMgr.findRepos(overlord, PageControl.getUnlimitedInstance());
- log.info("Returned list of repos: " + repos.getTotalSize() + " entries");
+ log.debug("Returned list of repos: " + repos.getTotalSize() + " entries");
for (Repo r : repos) {
- log.info("Potential repo: Name = " + r.getName() + ", ID = " + r.getId());
+ log.debug("Potential repo: Name = " + r.getName() + ", ID = " + r.getId());
}
- log.info("TODO: generate index.html");
+ log.debug("TODO: generate index.html");
StringBuffer sb = new StringBuffer();
HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
for (Repo r : repos) {
- log.info("Potential repo: Name = " + r.getName() + ", ID = " + r.getId());
+ log.debug("Potential repo: Name = " + r.getName() + ", ID = " + r.getId());
// Skip candidate repos
if (!r.isCandidate()) {
String lastMod = new Date(r.getLastModifiedDate()).toString();
@@ -162,7 +186,6 @@ public class ContentHTTPServlet extends DefaultServlet {
protected void renderChoiceOfContent(HttpServletRequest request, HttpServletResponse response, Repo repo)
throws IOException {
- log.info("Choice of content is: {" + PACKAGES + ", " + DISTRIBUTIONS + "}");
StringBuffer sb = new StringBuffer();
HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
@@ -175,14 +198,14 @@ public class ContentHTTPServlet extends DefaultServlet {
protected void renderPackages(HttpServletRequest request, HttpServletResponse response, Repo repo)
throws IOException {
- log.info("renderPackages(repo name = " + repo.getName() + ", id = " + repo.getId() + ", isCandidate = "
+ log.debug("renderPackages(repo name = " + repo.getName() + ", id = " + repo.getId() + ", isCandidate = "
+ repo.isCandidate() + ")");
String fileName = getFileName(request.getRequestURI());
- log.info("Parsed file name = " + fileName);
+ log.debug("Parsed file name = " + fileName);
if (StringUtils.isBlank(fileName)) {
// form a directory listing for each package in repository.
- log.info("create listing of all packages for this repo: " + repo.getName());
+ log.debug("create listing of all packages for this repo: " + repo.getName());
renderPackageIndex(request, response, repo);
return;
}
@@ -196,20 +219,19 @@ public class ContentHTTPServlet extends DefaultServlet {
return;
}
- log.info("fetch package bits and return them.");
+ log.debug("fetch package bits and return them.");
PackageVersion pv = getPackageVersionFromFileName(repo, fileName);
if (pv == null) {
log.info("Unable to find PackageVersion from filename: " + fileName);
renderErrorPage(request, response);
return;
}
- response.setContentType("application/octet-stream");
- writePackageVersionBits(response.getOutputStream(), pv);
+ writePackageVersionBits(request, response, pv);
}
protected void renderPackageIndex(HttpServletRequest request, HttpServletResponse response, Repo repo)
throws IOException {
- log.info("Forming packages index.html for repo: " + repo.getName() + ", ID = " + repo.getId());
+ log.debug("Forming packages index.html for repo: " + repo.getName() + ", ID = " + repo.getId());
List<PackageVersion> pvs = repoMgr.findPackageVersionsInRepo(LookupUtil.getSubjectManager().getOverlord(), repo
.getId(), PageControl.getUnlimitedInstance());
@@ -227,7 +249,7 @@ public class ContentHTTPServlet extends DefaultServlet {
protected void renderMetadata(HttpServletRequest request, HttpServletResponse response, Repo repo)
throws IOException {
- log.info("renderMetadata(repo name = " + repo.getName() + ", id = " + repo.getId());
+ log.debug("renderMetadata(repo name = " + repo.getName() + ", id = " + repo.getId());
String metadataFilename = getMetadataFileName(request.getRequestURI());
if (StringUtils.isBlank(metadataFilename)) {
@@ -235,10 +257,10 @@ public class ContentHTTPServlet extends DefaultServlet {
return;
}
// Generate Yum Metadata
- log.info("Generate Yum Metadata for : " + metadataFilename);
+ log.debug("Generate Yum Metadata for : " + metadataFilename);
List<PackageVersion> pvs = repoMgr.findPackageVersionsInRepo(LookupUtil.getSubjectManager().getOverlord(), repo
.getId(), PageControl.getUnlimitedInstance());
- log.info(pvs.size() + " packages were found for repo : " + repo.getName());
+ log.debug(pvs.size() + " packages were found for repo : " + repo.getName());
StringBuffer sb = new StringBuffer();
if (!YumMetadata.generate(sb, repo, pvs, metadataFilename)) {
log.info("Error generating: " + metadataFilename + " for repo: " + repo.getName() + " with " + pvs.size()
@@ -251,7 +273,7 @@ public class ContentHTTPServlet extends DefaultServlet {
protected void renderMetadataIndex(HttpServletRequest request, HttpServletResponse response, Repo repo)
throws IOException {
- log.info("renderMetadataIndex(repo name = " + repo.getName() + ", id = " + repo.getId());
+ log.debug("renderMetadataIndex(repo name = " + repo.getName() + ", id = " + repo.getId());
StringBuffer sb = new StringBuffer();
HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
@@ -267,11 +289,11 @@ public class ContentHTTPServlet extends DefaultServlet {
protected void renderDistributions(HttpServletRequest request, HttpServletResponse response, Repo repo)
throws IOException {
- log.info("renderDistributions(repo name = " + repo.getName() + ", id = " + repo.getId() + ", isCandidate = "
+ log.debug("renderDistributions(repo name = " + repo.getName() + ", id = " + repo.getId() + ", isCandidate = "
+ repo.isCandidate() + ")");
String distLabel = getDistLabel(request.getRequestURI());
- log.info("Parsed dist label is = " + distLabel);
+ log.debug("Parsed dist label is = " + distLabel);
if (StringUtils.isBlank(distLabel)) {
// form a directory listing for each distribution in repository.
log.info("TODO: create index.html listing all the distribution labels for this repo: " + repo.getName());
@@ -291,7 +313,7 @@ public class ContentHTTPServlet extends DefaultServlet {
renderDistributionFileList(request, response, dist);
return;
}
- log.info("Parsed DistributionFile request is for: " + fileRequest);
+ log.debug("Parsed DistributionFile request is for: " + fileRequest);
// Looks like a request for a distribution file
List<DistributionFile> distFiles = distroMgr.getDistributionFilesByDistId(dist.getId());
if (distFiles.isEmpty()) {
@@ -300,10 +322,11 @@ public class ContentHTTPServlet extends DefaultServlet {
return;
}
for (DistributionFile dFile : distFiles) {
- log.info("Compare: " + dFile.getRelativeFilename() + " to " + fileRequest);
+ //log.info("Compare: " + dFile.getRelativeFilename() + " to " + fileRequest);
if (StringUtils.equalsIgnoreCase(dFile.getRelativeFilename(), fileRequest)) {
- response.setContentType("application/octet-stream");
- writeDistributionFileBits(response.getOutputStream(), dFile);
+ log.info("Sending back package bytes for: " + dFile.getRelativeFilename());
+
+ writeDistributionFileBits(request, response, dFile);
return;
}
}
@@ -312,12 +335,13 @@ public class ContentHTTPServlet extends DefaultServlet {
// ..../distributions/{Server,Cluster,Packages,etc}/a2ps-XXXXX.rpm
String possiblePkgName = getLastPiece(request.getRequestURI());
- log.info("Looking up : " + possiblePkgName + ", it might be a package request");
+ log.debug("Looking up : " + possiblePkgName + ", it might be a package request");
PackageVersion pv = getPackageVersionFromFileName(repo, possiblePkgName);
if (pv != null) {
log.info(possiblePkgName + " resolved to a package, will send package bytes back as response");
- response.setContentType("application/octet-stream");
- writePackageVersionBits(response.getOutputStream(), pv);
+ //response.setContentType("application/octet-stream");
+ writePackageVersionBits(request, response, pv);
+ return;
}
log.info("Searched through DistributionFiles and Packages, unable to find: " + fileRequest
+ ", in Distribution: " + dist.getLabel());
@@ -330,7 +354,7 @@ public class ContentHTTPServlet extends DefaultServlet {
Distribution dist) throws IOException {
List<DistributionFile> distFiles = distroMgr.getDistributionFilesByDistId(dist.getId());
- log.info("For Distribution label '" + dist.getLabel() + "' " + distFiles.size()
+ log.debug("For Distribution label '" + dist.getLabel() + "' " + distFiles.size()
+ " distribution files were found");
StringBuffer sb = new StringBuffer();
@@ -353,7 +377,7 @@ public class ContentHTTPServlet extends DefaultServlet {
// Get list of Distributions per repo
List<Distribution> distros = repoMgr.findAssociatedDistributions(LookupUtil.getSubjectManager().getOverlord(),
repo.getId(), PageControl.getUnlimitedInstance());
- log.info("Found " + distros.size() + " for repo " + repo.getName());
+ log.debug("Found " + distros.size() + " for repo " + repo.getName());
for (Distribution d : distros) {
log.info("Creating link for distribution label: " + d.getLabel());
HtmlRenderer.formDirEntry(sb, request, d.getLabel(), new Date(d.getLastModifiedDate()).toString());
@@ -384,7 +408,7 @@ public class ContentHTTPServlet extends DefaultServlet {
protected Repo getRepo(HttpServletRequest request, HttpServletResponse response) {
String repoName = getRepoName(request.getRequestURI());
- log.info("Parsed repo name = " + repoName);
+ log.debug("Parsed repo name = " + repoName);
List<Repo> targetRepos = repoMgr.getRepoByName(repoName);
if (targetRepos.isEmpty()) {
// Check if maybe this is the repoID passed in as an int, instead of repo name
@@ -446,7 +470,7 @@ public class ContentHTTPServlet extends DefaultServlet {
}
protected String getLastPiece(String requestURI) {
- StrTokenizer st = new StrTokenizer(requestURI, "/");
+ StrTokenizer st = new StrTokenizer(decodeURL(requestURI), "/");
List<String> tokens = st.getTokenList();
if (tokens.size() < 1) {
return "";
@@ -463,7 +487,8 @@ public class ContentHTTPServlet extends DefaultServlet {
// Goal is we find where the distribution file path starts
// then we return the entire path, it may include an unknown
// level of sub-directories.
- StrTokenizer st = new StrTokenizer(requestURI, "/");
+
+ StrTokenizer st = new StrTokenizer(decodeURL(requestURI), "/");
List<String> tokens = st.getTokenList();
if (tokens.isEmpty()) {
return "";
@@ -472,7 +497,7 @@ public class ContentHTTPServlet extends DefaultServlet {
String distFilePath = "";
for (int index = startIndex; index < tokens.size(); index++) {
distFilePath = distFilePath + "/" + tokens.get(index);
- log.info("index = " + index + ", distFilePath = " + distFilePath);
+ log.debug("index = " + index + ", distFilePath = " + distFilePath);
}
// Remove the '/' we added to the front of this string
if (distFilePath.startsWith("/")) {
@@ -487,7 +512,7 @@ public class ContentHTTPServlet extends DefaultServlet {
*
*/
protected String getNthPiece(int n, String requestURI) {
- StrTokenizer st = new StrTokenizer(requestURI, "/");
+ StrTokenizer st = new StrTokenizer(decodeURL(requestURI), "/");
List<String> tokens = st.getTokenList();
if (tokens.size() < n) {
return "";
@@ -496,6 +521,7 @@ public class ContentHTTPServlet extends DefaultServlet {
}
protected String getParentURI(String uri) {
+ uri = decodeURL(uri);
if (uri.endsWith("/")) {
uri = uri.substring(0, uri.length() - 1);
}
@@ -506,18 +532,30 @@ public class ContentHTTPServlet extends DefaultServlet {
return uri.substring(0, index);
}
+ protected String decodeURL(String requestURI) {
+ String req = null;
+ try {
+ req = urlCodec.decode(requestURI);
+ } catch (DecoderException e) {
+ log.info(e);
+ return "";
+ }
+ return req;
+ }
+
protected PackageVersion getPackageVersionFromFileName(Repo repo, String fileName) {
PackageVersionCriteria criteria = new PackageVersionCriteria();
criteria.addFilterFileName(fileName);
criteria.addFilterRepoId(repo.getId());
- log.info("Created criteria for repoId = " + repo.getId() + ", fileName = " + fileName);
+ criteria.setStrict(true);
+ log.debug("Created criteria for repoId = " + repo.getId() + ", fileName = " + fileName);
List<PackageVersion> pkgVers = contentMgr.findPackageVersionsByCriteria(LookupUtil.getSubjectManager()
.getOverlord(), criteria);
for (PackageVersion pkgV : pkgVers) {
- log.info("PackageVersion found: " + pkgVers);
+ log.debug("PackageVersion found: " + pkgV);
}
- log.info("Found " + pkgVers.size() + " entries");
+ log.debug("Found " + pkgVers.size() + " entries");
PackageVersion pv = null;
if (pkgVers.size() > 0) {
pv = pkgVers.get(0);
@@ -527,10 +565,12 @@ public class ContentHTTPServlet extends DefaultServlet {
return pv;
}
- protected boolean writeDistributionFileBits(ServletOutputStream output, DistributionFile distFile)
- throws IOException {
+ protected boolean writeDistributionFileBits(HttpServletRequest request, HttpServletResponse response,
+ DistributionFile distFile) throws IOException {
try {
+ ServletOutputStream output = response.getOutputStream();
+ response.setContentType("application/octet-stream");
contentSourceMgr.outputDistributionFileBits(distFile, output);
output.flush();
output.close();
@@ -544,10 +584,31 @@ public class ContentHTTPServlet extends DefaultServlet {
return true;
}
- protected boolean writePackageVersionBits(ServletOutputStream output, PackageVersion pkgVer) {
-
+ protected boolean writePackageVersionBits(HttpServletRequest request, HttpServletResponse response,
+ PackageVersion pkgVer) {
+ //
+ // Anaconda does a fetch with specific ranges so it can locate the header in a rpm.
+ // Refer to anaconda source: yuminstall.py to see the details.
+ // We will default to range values of [0 -> -1] which will allow non-range based fetches to work as usual
+ //
+ long startRange = getStartRange(request);
+ long endRange = getEndRange(request);
+ if (endRange < 0) {
+ response.setContentType("application/x-rpm");
+ response.setContentLength(pkgVer.getFileSize().intValue());
+ } else {
+ response.setContentType("application/octet-stream");
+ log.debug("Range request: start = " + startRange + ", end = " + endRange);
+ int contentLength = new Long(endRange).intValue() - new Long(startRange).intValue() + 1;
+ log.debug("Setting contentLength = " + contentLength);
+ response.setContentLength(contentLength);
+ response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
+ String rangeHdr = "bytes=" + startRange + "-" + endRange + "/" + contentLength;
+ response.setHeader("Content-Range", rangeHdr);
+ }
try {
- contentSourceMgr.outputPackageVersionBits(pkgVer, output);
+ ServletOutputStream output = response.getOutputStream();
+ contentSourceMgr.outputPackageVersionBits(pkgVer, output, startRange, endRange);
output.flush();
output.close();
} catch (IllegalStateException e) {
@@ -559,4 +620,47 @@ public class ContentHTTPServlet extends DefaultServlet {
}
return true;
}
+
+ protected String[] getRanges(HttpServletRequest request) {
+ String rangeHeader = request.getHeader("Range");
+ if (rangeHeader == null) {
+ // Default value is 0, so it always starts at beginning
+ return null;
+ }
+ String[] ranges = rangeHeader.split("=");
+ if (ranges.length < 2) {
+ return null;
+ }
+ String[] indexes = ranges[1].split("-");
+ if (indexes.length < 2) {
+ return null;
+ }
+ return indexes;
+ }
+
+ /**
+ *
+ * @param request
+ * @return 0 if no value is present, or the number
+ */
+ protected long getStartRange(HttpServletRequest request) {
+ String[] indexes = getRanges(request);
+ if ((indexes == null) || (indexes.length < 2)) {
+ return 0;
+ }
+ return Long.valueOf(indexes[0]).longValue();
+ }
+
+ /**
+ *
+ * @param request
+ * @return -1 or the number
+ */
+ protected long getEndRange(HttpServletRequest request) {
+ String[] indexes = getRanges(request);
+ if ((indexes == null) || (indexes.length < 2)) {
+ return -1;
+ }
+ return Long.valueOf(indexes[1]).longValue();
+ }
}
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 09aad7e..1f9c62e 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
@@ -1753,6 +1753,23 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
.getId());
}
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ @TransactionTimeout(45 * 60)
+ public long outputPackageVersionBits(PackageVersion packageVersion, OutputStream outputStream, long startByte,
+ long endByte) {
+ // Used by export of content through http
+
+ PackageDetailsKey packageDetailsKey = new PackageDetailsKey(packageVersion.getDisplayName(), packageVersion
+ .getDisplayVersion(), packageVersion.getGeneralPackage().getPackageType().toString(), packageVersion
+ .getArchitecture().toString());
+
+ int resourceId = 0; //set to dummy value
+
+ log.info("Calling outputPackageVersionBitsRangeHelper() with package details: " + packageDetailsKey);
+ return outputPackageVersionBitsRangeHelper(resourceId, packageDetailsKey, outputStream, startByte, endByte,
+ packageVersion.getId());
+ }
+
@SuppressWarnings("unchecked")
private long outputPackageVersionBitsRangeHelper(int resourceId, PackageDetailsKey packageDetailsKey,
OutputStream outputStream, long startByte, long endByte, int packageVersionId) {
@@ -1877,12 +1894,10 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
// the magic happens here - outputStream is probably a remote stream down to the agent
long bytesRetrieved;
-
if (endByte < 0) {
if (startByte > 0) {
bitsStream.skip(startByte);
}
-
bytesRetrieved = StreamUtil.copy(bitsStream, outputStream, false);
} else {
BufferedInputStream bis = new BufferedInputStream(bitsStream);
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 cc742e7..4ff85fe 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
@@ -577,6 +577,25 @@ public interface ContentSourceManagerLocal {
long outputPackageVersionBits(PackageVersion packageVersion, OutputStream outputStream);
/**
+ * Requests a range of bits from a package. This range of bits will be streamed down to the caller over the given
+ * output stream. This method will <b>not</b> take care of closing the stream when it is finished;
+ * it is the caller's responsibility. This may be a time-consuming method call because
+ * if the bits have not yet been loaded (i.e. the content source where the package version lives
+ * {@link ContentSource#isLazyLoad() is lazy loading} then this may be the time when it is downloaded from the
+ * remote repository.
+ *
+ * @param packageVersion packageVersion to fetch
+ * @param outputStream an output stream where the server should write the package contents. It is up to the
+ * caller to prepare this output stream in order to write the package content to an
+ * appropriate location.
+ * @param startByte start index
+ * @param endByte end index
+ *
+ * @return the number of bytes written to the output stream
+ */
+ long outputPackageVersionBits(PackageVersion packageVersion, OutputStream outputStream, long startByte, long endByte);
+
+ /**
* Requests the bits of a distribution file be streamed down to the caller over the given output stream.
* This method will <b>not</b> take care of closing the stream when it is finished;
* it is the caller's responsibility.
commit a8e5dcf748c0157a4197010c1331b7fc1f058a9d
Author: John Matthews <jmatthew(a)redhat.com>
Date: Tue Jan 19 18:20:09 2010 -0500
1361 - add support for 'HEAD' request needed by virt-install & add pkg fetch through distribution url
-work in progress to support kickstarts through http
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
index e2f96f5..f08964f 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -80,6 +80,11 @@ public class ContentHTTPServlet extends DefaultServlet {
return StringUtils.equalsIgnoreCase(dir, "icons");
}
+ protected void doHead(HttpServletRequest request, HttpServletResponse response) throws IOException,
+ ServletException {
+ doGet(request, response);
+ }
+
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
log.info("doGet(): requestURI = " + request.getRequestURI());
if (isIconRequest(request)) {
@@ -302,8 +307,20 @@ public class ContentHTTPServlet extends DefaultServlet {
return;
}
}
- log.info("Searched through DistributionFiles and unable to find: " + fileRequest + ", in Distribution: "
- + dist.getLabel());
+ // This isn't a DistributionFile
+ // This could be a request for a package. Package requests will come in as:
+ // ..../distributions/{Server,Cluster,Packages,etc}/a2ps-XXXXX.rpm
+
+ String possiblePkgName = getLastPiece(request.getRequestURI());
+ log.info("Looking up : " + possiblePkgName + ", it might be a package request");
+ PackageVersion pv = getPackageVersionFromFileName(repo, possiblePkgName);
+ if (pv != null) {
+ log.info(possiblePkgName + " resolved to a package, will send package bytes back as response");
+ response.setContentType("application/octet-stream");
+ writePackageVersionBits(response.getOutputStream(), pv);
+ }
+ log.info("Searched through DistributionFiles and Packages, unable to find: " + fileRequest
+ + ", in Distribution: " + dist.getLabel());
renderErrorPage(request, response);
@@ -428,6 +445,15 @@ public class ContentHTTPServlet extends DefaultServlet {
return getNthPiece(4, requestURI);
}
+ protected String getLastPiece(String requestURI) {
+ StrTokenizer st = new StrTokenizer(requestURI, "/");
+ List<String> tokens = st.getTokenList();
+ if (tokens.size() < 1) {
+ return "";
+ }
+ return tokens.get(tokens.size() - 1);
+ }
+
/**
*
* @param requestURI
commit 11f0725a0d2007921c1257c539e6c060866609ca
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 16:20:40 2010 -0500
Added delete distribution type method so we can clean up properly after the web service tests.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java
index 50c3870..f251f7a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionType.java
@@ -23,22 +23,16 @@
package org.rhq.core.domain.content;
import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
-import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
/**
* Defines a type of (@link Distribution)
@@ -48,9 +42,10 @@ import javax.persistence.ManyToOne;
*/
@Entity
-@NamedQueries(
- @NamedQuery(name = DistributionType.QUERY_FIND_BY_NAME, query = "SELECT dt FROM DistributionType dt WHERE dt.name = :name")
-)
+@NamedQueries({
+ @NamedQuery(name = DistributionType.QUERY_FIND_BY_NAME, query = "SELECT dt FROM DistributionType dt WHERE dt.name = :name"),
+ @NamedQuery(name = DistributionType.QUERY_DELETE_BY_NAME, query = "DELETE FROM DistributionType dt where dt.name = :name")
+})
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_DISTRIBUTION_TYPE_ID_SEQ")
@Table(name = "RHQ_DISTRIBUTION_TYPE")
public class DistributionType implements Serializable {
@@ -58,6 +53,7 @@ public class DistributionType implements Serializable {
private static final long serialVersionUID = 1L;
public static final String QUERY_FIND_BY_NAME = "DistributionType.findByName";
+ public static final String QUERY_DELETE_BY_NAME = "DistributionType.deleteByName";
// Attributes --------------------------------------------
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsDistributionManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsDistributionManagerTest.java
index a301454..dabcae0 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsDistributionManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsDistributionManagerTest.java
@@ -79,6 +79,12 @@ public class WsDistributionManagerTest extends WsUnitTestBase {
Distribution afterDelete = service.getDistributionByLabel(label);
assert afterDelete == null;
+
+ // Cleanup
+ service.deleteDistributionTypeByName(admin, type.getName());
+ DistributionType typeAfterDelete = service.getDistributionTypeByName(type.getName());
+
+ assert typeAfterDelete == null;
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
index 49bcba7..e931267 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
@@ -79,7 +79,7 @@ public class DistributionManagerBean implements DistributionManagerLocal, Distri
if (loaded != null) {
disttype = loaded;
}
-
+
Distribution kstree = new Distribution(kslabel, basepath, disttype);
validateDistTree(kstree);
@@ -217,6 +217,14 @@ public class DistributionManagerBean implements DistributionManagerLocal, Distri
}
}
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public void deleteDistributionTypeByName(Subject subject, String name) {
+ Query query = entityManager.createNamedQuery(DistributionType.QUERY_DELETE_BY_NAME);
+ query.setParameter("name", name);
+
+ query.executeUpdate();
+ }
+
/**
* validates a given kickstart tree object and throws a KickstartTreeException
* @param kstree kickstart tree object
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java
index 8528da8..b3eb4df 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java
@@ -89,6 +89,16 @@ public interface DistributionManagerLocal {
void deleteDistributionFilesByDistId(Subject subject, int distid);
/**
+ * Deletes all distribution types with the given name.
+ * <p/>
+ * This should only be needed for testing purposes.
+ *
+ * @param subject
+ * @param name
+ */
+ void deleteDistributionTypeByName(Subject subject, String name);
+
+ /**
* Returns a DistributionType for given name
* @param name name of distribution type
* @return distribution type from db
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java
index bebd3a1..35e5361 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java
@@ -99,6 +99,18 @@ public interface DistributionManagerRemote {
@WebParam(name = "distid") int distid);
/**
+ * Deletes all distribution types with the given name.
+ * <p/>
+ * This should only be needed for testing purposes.
+ *
+ * @param subject
+ * @param name
+ */
+ @WebMethod
+ void deleteDistributionTypeByName(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "name") String name);
+
+ /**
* Returns a DistributionType for given name
* @param name name of distribution type
* @return distribution type from db
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index a19fcbd..e737c2d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -591,6 +591,11 @@ public class WebservicesManagerBean implements WebservicesRemote {
distributionManager.deleteDistributionByDistId(subject, distId);
}
+ public void deleteDistributionTypeByName(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "name") String name) {
+ distributionManager.deleteDistributionTypeByName(subject, name);
+ }
+
public Distribution createDistribution(@WebParam(name = "subject") Subject subject,
@WebParam(name = "kslabel") String kslabel,
@WebParam(name = "basepath") String basepath,
commit a2b83b54b47d745f18dd8c749dfe3698c2f3fe7a
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 15:46:04 2010 -0500
Initial work on the distribution manager tests. Not all of the test cases are flushed out, but this at least proves it's configured correctly to allow remote calls to be made into it.
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsDistributionManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsDistributionManagerTest.java
new file mode 100644
index 0000000..a301454
--- /dev/null
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsDistributionManagerTest.java
@@ -0,0 +1,84 @@
+/*
+* 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.ws.test;
+
+import org.testng.annotations.Test;
+
+import org.rhq.enterprise.server.ws.Distribution;
+import org.rhq.enterprise.server.ws.DistributionType;
+import org.rhq.enterprise.server.ws.Subject;
+
+/**
+ * Web service tests for the distribution manager service.
+ *
+ * @author Jason Dobies
+ */
+@Test(groups = "ws")
+public class WsDistributionManagerTest extends WsUnitTestBase {
+
+ private static final boolean TESTS_ENABLED = true;
+
+ @Test(enabled = TESTS_ENABLED)
+ public void createGetDeleteDistribution() throws Exception {
+
+ // Setup
+ Subject admin = subjectUtil.admin();
+ String label = "WsDistributionManagerTest.createGetDeleteDistribution.label";
+ String path = "WsDistributionManagerTest.createGetDeleteDistribution.path";
+
+ DistributionType type = objectFactory.createDistributionType();
+ type.setName("WsDistributionManagerTest.createGetDeleteDistribution.type");
+ type.setDescription("WsDistributionManagerTest.createGetDeleteDistribution.desc");
+
+ // Test
+ Distribution created = service.createDistribution(admin, label, path, type);
+
+ assert created != null;
+
+ Distribution byLabel = service.getDistributionByLabel(label);
+ Distribution byPath = service.getDistributionByPath(path);
+
+ DistributionType typeByName = service.getDistributionTypeByName(type.getName());
+
+ service.deleteDistributionByDistId(admin, created.getId());
+
+ // Verify
+ assert byLabel != null;
+ assert label.equals(byLabel.getLabel());
+ assert path.equals(byLabel.getBasePath());
+ assert type.getName().equals(byLabel.getDistributionType().getName());
+
+ assert byPath != null;
+ assert label.equals(byPath.getLabel());
+ assert path.equals(byPath.getBasePath());
+ assert type.getName().equals(byPath.getDistributionType().getName());
+
+ assert typeByName != null;
+ assert type.getName().equals(typeByName.getName());
+ assert type.getDescription().equals(typeByName.getDescription());
+
+ Distribution afterDelete = service.getDistributionByLabel(label);
+ assert afterDelete == null;
+ }
+
+}
commit 3feaac41e98fad8e0066bdb8815c3641741aa027
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 15:43:37 2010 -0500
This should try to reuse the distribution type if it already exists. Prior to this, multiple distribution types with the same label/description were being created.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
index cdfcbe0..49bcba7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
@@ -75,6 +75,11 @@ public class DistributionManagerBean implements DistributionManagerLocal, Distri
public Distribution createDistribution(Subject user, String kslabel, String basepath, DistributionType disttype)
throws DistributionException {
+ DistributionType loaded = distributionManager.getDistributionTypeByName(disttype.getName());
+ if (loaded != null) {
+ disttype = loaded;
+ }
+
Distribution kstree = new Distribution(kslabel, basepath, disttype);
validateDistTree(kstree);
commit e7d1ae92c45189db62c40b55b7035ccb653e35b6
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 15:33:08 2010 -0500
Fixed broken call to query.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java
index c93a886..e3aa284 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Distribution.java
@@ -53,7 +53,7 @@ import org.hibernate.annotations.NamedQuery;
@NamedQuery(name = Distribution.QUERY_FIND_PATH_BY_DIST_TYPE, query = "SELECT dt " + " FROM Distribution dt "
+ " WHERE dt.label = :label AND dt.distributionType.name = :typeName "),
@NamedQuery(name = Distribution.QUERY_FIND_BY_DIST_LABEL, query = "SELECT dt FROM Distribution dt WHERE dt.label = :label"),
- @NamedQuery(name = Distribution.QUERY_FIND_BY_DIST_PATH, query = "SELECT dt FROM Distribution dt WHERE dt.base_path = :path"),
+ @NamedQuery(name = Distribution.QUERY_FIND_BY_DIST_PATH, query = "SELECT dt FROM Distribution dt WHERE dt.basePath = :path"),
@NamedQuery(name = Distribution.QUERY_DELETE_BY_DIST_ID, query = "DELETE Distribution dt WHERE dt.id = :distid") })
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_DISTRIBUTION_ID_SEQ")
@Table(name = "RHQ_DISTRIBUTION")
@@ -87,7 +87,7 @@ public class Distribution implements Serializable {
* Base path where the kickstart tree is located
*/
@Column(name = "BASE_PATH", nullable = false)
- private String base_path;
+ private String basePath;
@Column(name = "LAST_MODIFIED", nullable = false)
private long lastModifiedDate;
@@ -119,7 +119,7 @@ public class Distribution implements Serializable {
}
public String getBasePath() {
- return this.base_path;
+ return this.basePath;
}
public void setLabel(String labelIn) {
@@ -127,7 +127,7 @@ public class Distribution implements Serializable {
}
public void setBasePath(String basepathIn) {
- this.base_path = basepathIn;
+ this.basePath = basepathIn;
}
public int getId() {
@@ -161,7 +161,7 @@ public class Distribution implements Serializable {
@Override
public String toString() {
- return String.format("Distribution [label=%s, Type=%s, basePath=%s]", label, distributionType, base_path);
+ return String.format("Distribution [label=%s, Type=%s, basePath=%s]", label, distributionType, basePath);
}
@Override
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
index 14dc8fb..cdfcbe0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
@@ -134,7 +134,7 @@ public class DistributionManagerBean implements DistributionManagerLocal, Distri
public Distribution getDistributionByPath(String basepath) {
Query query = entityManager.createNamedQuery(Distribution.QUERY_FIND_BY_DIST_PATH);
- query.setParameter("base_path", basepath);
+ query.setParameter("path", basepath);
List<Distribution> results = query.getResultList();
if (results.size() > 0) {
commit f173b246eea0a6a92572cd53bebbad04f1013620
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 15:07:18 2010 -0500
Changed to expose the distribution manager over webservices.
diff --git a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
index d261413..1162a69 100644
--- a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
+++ b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
@@ -37,6 +37,7 @@ import org.rhq.enterprise.server.authz.RoleManagerRemote;
import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
import org.rhq.enterprise.server.content.AdvisoryManagerRemote;
import org.rhq.enterprise.server.content.ContentManagerRemote;
+import org.rhq.enterprise.server.content.DistributionManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
@@ -78,6 +79,7 @@ public class RemoteClient {
ContentManager(ContentManagerRemote.class), //
DataAccessManager(DataAccessManagerRemote.class), //
DiscoveryBoss(DiscoveryBossRemote.class), //
+ DistributionManager(DistributionManagerRemote.class),//
EventManager(EventManagerRemote.class), //
MeasurementBaselineManager(MeasurementBaselineManagerRemote.class), //
MeasurementDataManager(MeasurementDataManagerRemote.class), //
@@ -350,6 +352,10 @@ public class RemoteClient {
return RemoteClientProxy.getProcessor(this, Manager.DiscoveryBoss);
}
+ public DistributionManagerRemote getDistributionManagerRemote() {
+ return RemoteClientProxy.getProcessor(this, Manager.DistributionManager);
+ }
+
public EventManagerRemote getEventManagerRemote() {
return RemoteClientProxy.getProcessor(this, Manager.EventManager);
}
diff --git a/modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml b/modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml
index 3044936..5bb03d4 100644
--- a/modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml
+++ b/modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml
@@ -21,6 +21,7 @@
<property name="ConfigurationManager" value="org.rhq.enterprise.server.configuration.ConfigurationManagerBean" />
<property name="ContentManager" value="org.rhq.enterprise.server.content.ContentManagerBean" />
<property name="DataAccessManager" value="org.rhq.enterprise.server.report.DataAccessManagerBean" />
+ <property name="DistributionManager" value="org.rhq.enterprise.server.content.DistributionManagerBean"/>
<property name="EventManager" value="org.rhq.enterprise.server.event.EventManagerBean" />
<property name="MeasurementDefinitionManager" value="org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerBean" />
<property name="MeasurementBaselineManager" value="org.rhq.enterprise.server.measurement.MeasurementBaselineManagerBean" />
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
index 53c1be0..52ca48e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
@@ -40,6 +40,7 @@ import org.rhq.enterprise.server.authz.RoleManagerBean;
import org.rhq.enterprise.server.configuration.ConfigurationManagerBean;
import org.rhq.enterprise.server.content.AdvisoryManagerBean;
import org.rhq.enterprise.server.content.ContentManagerBean;
+import org.rhq.enterprise.server.content.DistributionManagerBean;
import org.rhq.enterprise.server.content.RepoManagerBean;
import org.rhq.enterprise.server.event.EventManagerBean;
import org.rhq.enterprise.server.measurement.AvailabilityManagerBean;
@@ -75,6 +76,7 @@ public class RemoteAPIValidator {
ContentManagerBean.class, //
//ContentSourceManagerBean.class, //
DataAccessManagerBean.class, //
+ DistributionManagerBean.class,//
EventManagerBean.class, //
MeasurementBaselineManagerBean.class,//
MeasurementDataManagerBean.class,//
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index c19808f..a19fcbd 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -54,6 +54,8 @@ import org.rhq.core.domain.content.AdvisoryPackage;
import org.rhq.core.domain.content.Architecture;
import org.rhq.core.domain.content.CVE;
import org.rhq.core.domain.content.Distribution;
+import org.rhq.core.domain.content.DistributionFile;
+import org.rhq.core.domain.content.DistributionType;
import org.rhq.core.domain.content.InstalledPackage;
import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.content.PackageVersion;
@@ -112,6 +114,8 @@ import org.rhq.enterprise.server.configuration.ConfigurationUpdateStillInProgres
import org.rhq.enterprise.server.content.AdvisoryException;
import org.rhq.enterprise.server.content.AdvisoryManagerLocal;
import org.rhq.enterprise.server.content.ContentManagerLocal;
+import org.rhq.enterprise.server.content.DistributionException;
+import org.rhq.enterprise.server.content.DistributionManagerLocal;
import org.rhq.enterprise.server.content.RepoException;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.discovery.DiscoveryBossLocal;
@@ -172,6 +176,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
//removed as it is problematic for WS clients having XMLAny for Object.
// private DataAccessManagerLocal dataAccessManager = LookupUtil.getDataAccessManager();
private DiscoveryBossLocal discoveryBoss = LookupUtil.getDiscoveryBoss();
+ private DistributionManagerLocal distributionManager = LookupUtil.getDistributionManagerLocal();
private EventManagerLocal eventManager = LookupUtil.getEventManager();
private MeasurementBaselineManagerLocal measurementBaselineManager = LookupUtil.getMeasurementBaselineManager();
private MeasurementDataManagerLocal measurementDataManager = LookupUtil.getMeasurementDataManager();
@@ -558,6 +563,44 @@ public class WebservicesManagerBean implements WebservicesRemote {
//DISCOVERYBOSS: END ------------------------------------
+ //DISTRIBUTION: START ------------------------------------
+
+ public DistributionType getDistributionTypeByName(@WebParam(name = "name") String name) {
+ return distributionManager.getDistributionTypeByName(name);
+ }
+
+ public void deleteDistributionFilesByDistId(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "distid") int distid) {
+ distributionManager.deleteDistributionByDistId(subject, distid);
+ }
+
+ public List<DistributionFile> getDistributionFilesByDistId(@WebParam(name = "distid") int distid) {
+ return distributionManager.getDistributionFilesByDistId(distid);
+ }
+
+ public Distribution getDistributionByPath(@WebParam(name = "basepath") String basepath) {
+ return distributionManager.getDistributionByPath(basepath);
+ }
+
+ public Distribution getDistributionByLabel(@WebParam(name = "kslabel") String kslabel) {
+ return distributionManager.getDistributionByLabel(kslabel);
+ }
+
+ public void deleteDistributionByDistId(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "distId") int distId) throws Exception {
+ distributionManager.deleteDistributionByDistId(subject, distId);
+ }
+
+ public Distribution createDistribution(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "kslabel") String kslabel,
+ @WebParam(name = "basepath") String basepath,
+ @WebParam(name = "disttype") DistributionType disttype)
+ throws DistributionException {
+ return distributionManager.createDistribution(subject, kslabel, basepath, disttype);
+ }
+
+ //DISTRIBUTION: END ------------------------------------
+
//EVENTMANAGER: BEGIN ----------------------------------
public PageList<Event> findEventsByCriteria(Subject subject, EventCriteria criteria) {
checkParametersPassedIn(subject, criteria);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
index eb5937b..13f89df 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
@@ -11,6 +11,7 @@ import org.rhq.enterprise.server.authz.RoleManagerRemote;
import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
import org.rhq.enterprise.server.content.AdvisoryManagerRemote;
import org.rhq.enterprise.server.content.ContentManagerRemote;
+import org.rhq.enterprise.server.content.DistributionManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
@@ -46,6 +47,7 @@ public interface WebservicesRemote extends //
//Removed as it was problematic for WS clients. Not sure if this well be re-enabled.
// DataAccessManagerRemote,//
DiscoveryBossRemote,//
+ DistributionManagerRemote,//
EventManagerRemote,//
MeasurementBaselineManagerRemote,//
MeasurementDataManagerRemote,//
commit f00604d38a40dabd0bca32e8fb708f48e1c70c28
Merge: 28e1caf... c749e1a...
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Thu Jan 21 14:11:51 2010 -0500
Merge branch 'content' of ssh://git.fedorahosted.org/git/rhq/rhq into content
commit 28e1cafc18845501f10f0aeacf46a3b7806da37d
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Thu Jan 21 14:11:32 2010 -0500
fixing the last modified on distribution trees to show right time stamp
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
index 77ab7f1..7e9070f 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
@@ -677,8 +677,10 @@
<h:outputText styleClass="headerText"
value="Last Modified" />
</f:facet>
- <h:outputText value="#{dist.lastModifiedDate}" />
-
+ <h:outputText value="#{dist.lastModifiedDate}">
+ <f:converter converterId="UserDateTimeConverter" />
+ </h:outputText>
+
</rich:column>
commit c749e1a6acc4c699247b41d88423852520a494d1
Merge: cab715c... ec13d2a...
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jan 21 14:07:38 2010 -0500
Merge branch 'master' into content
commit cab715c7171b14200a7adcccc725850427584c86
Merge: 947167f... 2afe643...
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Thu Jan 21 10:50:10 2010 -0800
Merge branch 'master' into content
Conflicts:
.classpath
modules/enterprise/gui/pom.xml
diff --cc .classpath
index a8668a4,8b3c7cf..5746d68
--- a/.classpath
+++ b/.classpath
@@@ -222,9 -220,10 +221,11 @@@
<classpathentry exported="true" kind="var" path="M2_REPO/org/jmock/jmock/2.5.1/jmock-2.5.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.2.1/byteman-1.2.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.2/antlr-runtime-3.2.jar"/>
<classpathentry exported="true" kind="lib" path="modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-1.4.0-SNAPSHOT/wsconsume-output"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/jboss/web/jbossweb/2.0.1.GA/jbossweb-2.0.1.GA.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/libvirt/libvirt/0.4.1/libvirt-0.4.1.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.2.1/byteman-1.2.1.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/fedorahosted/cobbler/cobbler4j/0.1/cobbler4j-0.1.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
diff --cc modules/enterprise/gui/pom.xml
index 9ae5584,9b895cb..c9e59f1
--- a/modules/enterprise/gui/pom.xml
+++ b/modules/enterprise/gui/pom.xml
@@@ -35,7 -35,7 +35,8 @@@
<module>portal-war</module>
<module>installer-war</module>
<module>webdav-war</module>
+ <module>content_http-war</module>
+ <module>alert-migration</module>
</modules>
</profile>
diff --cc modules/enterprise/server/ear/pom.xml
index 4ab1ee1,5db9a4e..3faa62b
--- a/modules/enterprise/server/ear/pom.xml
+++ b/modules/enterprise/server/ear/pom.xml
@@@ -66,14 -66,14 +66,21 @@@
<version>${project.version}</version>
<type>war</type>
</dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-content_http</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ </dependency>
+ <dependency>
+ <groupId>org.rhq.helpers</groupId>
+ <artifactId>alert-migration</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ </dependency>
+
<!-- ** SARs -->
<!--
<dependency> <groupId>org.rhq</groupId> <artifactId>rhq-enterprise-server-agent-sar</artifactId>
@@@ -175,16 -175,14 +182,23 @@@
<bundleFileName>rhq-webdav.war</bundleFileName>
<contextRoot>/webdav</contextRoot>
</webModule>
+
+ <!-- used to expose content through http -->
+ <webModule>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-content_http</artifactId>
+ <excluded>${exclude-content_http}</excluded>
+ <bundleFileName>rhq-content_http.war</bundleFileName>
+ <contextRoot>/content</contextRoot>
+ </webModule>
+ <webModule>
+ <groupId>org.rhq.helpers</groupId>
+ <artifactId>alert-migration</artifactId>
+ <bundleFileName>alert-migration.war</bundleFileName>
+ <contextRoot>/alert-migration</contextRoot>
+ </webModule>
+
<!-- ** EJB-JARs -->
<ejbModule>
commit 947167f528d432923a96eefc188562d0c71dc2a5
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 12:53:55 2010 -0500
The import call isn't supposed to be used anymore, so remove from the tests.
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
index 3e3265a..7886e4b 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
@@ -55,7 +55,6 @@ public class WsRegistrationManagerTest extends WsUnitTestBase {
// Note: randomPlatform calls #registerPlatform, which is why there's no explicit test for that
Resource created = resourceUtil.randomPlatform();
- service.importPlatform(admin, created);
// Verify and Cleanup
try {
commit bb0734689ca35af4bbb893cb2d3f86e3b848dc73
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 12:35:15 2010 -0500
Missed a place to add the new method.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index af011a6..c19808f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -216,6 +216,10 @@ public class WebservicesManagerBean implements WebservicesRemote {
return advisoryManager.createAdvisoryPackage(user, advisory, pkg);
}
+ public CVE getCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "cveId") int cveId) {
+ return advisoryManager.getCVE(user, cveId);
+ }
+
public void deleteCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "cveId") int cveId) {
advisoryManager.deleteAdvisoryCVE(user, cveId);
}
commit 06287f603a67d598cd90b7a84833bbf9ab05d771
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 12:33:13 2010 -0500
Added method needed for testing.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
index 83c5416..e4c42a4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
@@ -108,6 +108,11 @@ public class AdvisoryManagerBean implements AdvisoryManagerLocal, AdvisoryManage
return advpkg;
}
+ public CVE getCVE(Subject user, int cveId) {
+ CVE cve = entityManager.find(CVE.class, cveId);
+ return cve;
+ }
+
public void deleteCVE(Subject user, int cveId) {
log.debug("User [" + user + "] is deleting CVE [" + cveId + "]");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerLocal.java
index 3450b10..d44fdbc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerLocal.java
@@ -60,7 +60,7 @@ public interface AdvisoryManagerLocal {
CVE createCVE(Subject user, String cvename) throws AdvisoryException;
/**
- * creates a AdvisoryCVE relationship object
+ * creates a AdvisoryCVE relationship object
* @param user
* @param advisory
* @param cve
@@ -80,6 +80,14 @@ public interface AdvisoryManagerLocal {
AdvisoryPackage createAdvisoryPackage(Subject user, Advisory advisory, PackageVersion pkg) throws AdvisoryException;
/**
+ * returns an existing CVE object
+ * @param user
+ * @param cveId
+ * @return
+ */
+ CVE getCVE(Subject user, int cveId);
+
+ /**
* deletes specified cve object
* @param user
* @param cveId
@@ -159,7 +167,7 @@ public interface AdvisoryManagerLocal {
/**
* find AdvisoryPackage object for given advId and packageVersion id
* @param overlord
- * @param advId
+ * @param advId
* @param pkgVerId
*/
AdvisoryPackage findAdvisoryPackage(Subject overlord, int advId, int pkgVerId);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java
index cb0514f..a74a81a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java
@@ -89,6 +89,15 @@ public interface AdvisoryManagerRemote {
@WebParam(name = "pkg") PackageVersion pkg) throws AdvisoryException;
/**
+ * returns an existing CVE object
+ * @param user
+ * @param cveId
+ * @return
+ */
+ CVE getCVE(@WebParam(name = "subject") Subject user,
+ @WebParam(name = "cveId")int cveId);
+
+ /**
* deletes specified cve object
* @param user
* @param cveId
commit 68a788527b1b465403538e4ef0b2c3bcb8f709ff
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 12:32:22 2010 -0500
Refactored into base class that takes care of the remote connection initialization.
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java
index 00a01f3..3f22fa0 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java
@@ -22,22 +22,10 @@
*/
package org.rhq.enterprise.server.ws.test;
-import java.net.URL;
-
-import javax.xml.namespace.QName;
-
-import org.testng.AssertJUnit;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.rhq.enterprise.server.ws.Advisory;
-import org.rhq.enterprise.server.ws.ObjectFactory;
import org.rhq.enterprise.server.ws.Subject;
-import org.rhq.enterprise.server.ws.TestPropertiesInterface;
-import org.rhq.enterprise.server.ws.WebservicesManagerBeanService;
-import org.rhq.enterprise.server.ws.WebservicesRemote;
-import org.rhq.enterprise.server.ws.test.util.WsSubjectUtility;
-import org.rhq.enterprise.server.ws.utility.WsUtility;
/**
* Web service tests for the advisory manager services.
@@ -45,31 +33,10 @@ import org.rhq.enterprise.server.ws.utility.WsUtility;
* @author Jason Dobies
*/
@Test(groups = "ws")
-public class WsAdvisoryManagerTest extends AssertJUnit implements TestPropertiesInterface {
+public class WsAdvisoryManagerTest extends WsUnitTestBase {
private static final boolean TESTS_ENABLED = true;
- private WebservicesRemote service;
- private ObjectFactory objectFactory;
-
- private WsSubjectUtility subjectUtil;
-
- @BeforeClass
- public void setup() throws Exception {
-
- // Variables needed
- URL gUrl = WsUtility.generateRemoteWebserviceURL(WebservicesManagerBeanService.class, host, port, useSSL);
- QName gQName = WsUtility.generateRemoteWebserviceQName(WebservicesManagerBeanService.class);
-
- // Establish outbound webservices connections
- WebservicesManagerBeanService jws = new WebservicesManagerBeanService(gUrl, gQName);
- service = jws.getWebservicesManagerBeanPort();
-
- objectFactory = new ObjectFactory();
-
- subjectUtil = new WsSubjectUtility(service);
- }
-
@Test(enabled = TESTS_ENABLED)
public void createGetDeleteAdvisory() throws Exception {
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
index b4367db..3e3265a 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
@@ -22,21 +22,16 @@
*/
package org.rhq.enterprise.server.ws.test;
-import java.lang.Exception;
-import java.net.URL;
import java.util.List;
-import javax.xml.namespace.QName;
-
-import org.testng.AssertJUnit;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.rhq.enterprise.server.ws.*;
+import org.rhq.enterprise.server.ws.InventoryStatus;
+import org.rhq.enterprise.server.ws.Resource;
+import org.rhq.enterprise.server.ws.ResourceCriteria;
+import org.rhq.enterprise.server.ws.Subject;
import org.rhq.enterprise.server.ws.test.util.WsResourceUtility;
import org.rhq.enterprise.server.ws.test.util.WsSubjectUtility;
-import org.rhq.enterprise.server.ws.utility.WsUtility;
/**
* Web service tests for the registration manager services.
@@ -44,27 +39,10 @@ import org.rhq.enterprise.server.ws.utility.WsUtility;
* @author Jason Dobies
*/
@Test(groups = "ws")
-public class WsRegistrationManagerTest extends AssertJUnit implements TestPropertiesInterface {
+public class WsRegistrationManagerTest extends WsUnitTestBase {
private static final boolean TESTS_ENABLED = true;
- private WebservicesRemote service;
- private ObjectFactory objectFactory;
-
- @BeforeClass
- public void setup() throws Exception {
-
- // Variables needed
- URL gUrl = WsUtility.generateRemoteWebserviceURL(WebservicesManagerBeanService.class, host, port, useSSL);
- QName gQName = WsUtility.generateRemoteWebserviceQName(WebservicesManagerBeanService.class);
-
- // Establish outbound webservices connections
- WebservicesManagerBeanService jws = new WebservicesManagerBeanService(gUrl, gQName);
- service = jws.getWebservicesManagerBeanPort();
-
- objectFactory = new ObjectFactory();
- }
-
@Test(enabled = TESTS_ENABLED)
public void importPlatform() throws Exception {
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsUnitTestBase.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsUnitTestBase.java
new file mode 100644
index 0000000..f6ef8d2
--- /dev/null
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsUnitTestBase.java
@@ -0,0 +1,72 @@
+/*
+* 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.ws.test;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.testng.AssertJUnit;
+import org.testng.annotations.BeforeClass;
+
+import org.rhq.enterprise.server.ws.ObjectFactory;
+import org.rhq.enterprise.server.ws.TestPropertiesInterface;
+import org.rhq.enterprise.server.ws.WebservicesManagerBeanService;
+import org.rhq.enterprise.server.ws.WebservicesRemote;
+import org.rhq.enterprise.server.ws.test.util.WsResourceUtility;
+import org.rhq.enterprise.server.ws.test.util.WsSubjectUtility;
+import org.rhq.enterprise.server.ws.utility.WsUtility;
+
+/**
+ * Base class for all webservice unit tests. This class runs the setup and teardown
+ * necessary to establish and release the connection to the remote server. Subclasses
+ * can use the variables initialized here for testing purposes.
+ *
+ * @author Jason Dobies
+ */
+public class WsUnitTestBase extends AssertJUnit implements TestPropertiesInterface {
+
+ protected WebservicesRemote service;
+ protected ObjectFactory objectFactory;
+
+ protected WsSubjectUtility subjectUtil;
+ protected WsResourceUtility resourceUtil;
+
+ @BeforeClass
+ public void setup() throws Exception {
+
+ // Variables needed
+ URL gUrl = WsUtility.generateRemoteWebserviceURL(WebservicesManagerBeanService.class, host, port, useSSL);
+ QName gQName = WsUtility.generateRemoteWebserviceQName(WebservicesManagerBeanService.class);
+
+ // Establish outbound webservices connections
+ WebservicesManagerBeanService jws = new WebservicesManagerBeanService(gUrl, gQName);
+ service = jws.getWebservicesManagerBeanPort();
+
+ objectFactory = new ObjectFactory();
+
+ subjectUtil = new WsSubjectUtility(service);
+ resourceUtil = new WsResourceUtility(service);
+ }
+
+}
commit 9b46a01f42e577202dd47e0fe775c5ad42f5d883
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Thu Jan 21 11:35:53 2010 -0500
some optimizations to not check hibernate twice
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
index 44a7846..83c5416 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
@@ -114,12 +114,10 @@ public class AdvisoryManagerBean implements AdvisoryManagerLocal, AdvisoryManage
entityManager.flush();
entityManager.clear();
- entityManager.createNamedQuery(CVE.DELETE_BY_CVE_ID).setParameter("cveId", cveId).executeUpdate();
+ int success = entityManager.createNamedQuery(CVE.DELETE_BY_CVE_ID).setParameter("cveId", cveId).executeUpdate();
- CVE cve = entityManager.find(CVE.class, cveId);
- if (cve != null) {
- entityManager.remove(cve);
- log.debug("User [" + user + "] deleted CVE [" + cve + "]");
+ if (success == 1) {
+ log.debug("User [" + user + "] deleted CVE [" + cveId + "]");
} else {
log.debug("CVE ID [" + cveId + "] doesn't exist - nothing to delete");
}
@@ -131,14 +129,13 @@ public class AdvisoryManagerBean implements AdvisoryManagerLocal, AdvisoryManage
entityManager.flush();
entityManager.clear();
- entityManager.createNamedQuery(AdvisoryCVE.DELETE_BY_ADV_ID).setParameter("advId", advId).executeUpdate();
+ int success = entityManager.createNamedQuery(AdvisoryCVE.DELETE_BY_ADV_ID).setParameter("advId", advId)
+ .executeUpdate();
- AdvisoryCVE advcve = entityManager.find(AdvisoryCVE.class, advId);
- if (advcve != null) {
- entityManager.remove(advcve);
- log.debug("User [" + user + "] deleted CVE [" + advcve + "]");
+ if (success == 1) {
+ log.debug("User [" + user + "] deleted CVEs for " + advId);
} else {
- log.debug("Advisory ID [" + advId + "] doesn't exist - nothing to delete");
+ log.debug("Advisory ID [" + advId + "] CVE deletion unsuccessful");
}
}
@@ -148,48 +145,44 @@ public class AdvisoryManagerBean implements AdvisoryManagerLocal, AdvisoryManage
entityManager.flush();
entityManager.clear();
- entityManager.createNamedQuery(Advisory.QUERY_DELETE_BY_ADV_ID).setParameter("advid", advId).executeUpdate();
+ int success = entityManager.createNamedQuery(Advisory.QUERY_DELETE_BY_ADV_ID).setParameter("advid", advId)
+ .executeUpdate();
- Advisory adv = entityManager.find(Advisory.class, advId);
- if (adv != null) {
- entityManager.remove(adv);
- log.debug("User [" + user + "] deleted advisory [" + adv + "]");
+ if (success == 1) {
+ log.debug("User [" + user + "] deleted Advisory for " + advId);
} else {
- log.debug("Advisory tree ID [" + adv + "] doesn't exist - nothing to delete");
+ log.debug("Advisory ID [" + advId + "] deletion unsuccessful");
}
}
public void deleteAdvisoryPackage(Subject user, int advId) {
- log.debug("User [" + user + "] is deleting CVE [" + advId + "]");
+ log.debug("User [" + user + "] is deleting packages for advisory [" + advId + "]");
entityManager.flush();
entityManager.clear();
- entityManager.createNamedQuery(AdvisoryPackage.DELETE_PACKAGES_BY_ADV_ID).setParameter("advId", advId)
- .executeUpdate();
+ int success = entityManager.createNamedQuery(AdvisoryPackage.DELETE_PACKAGES_BY_ADV_ID).setParameter("advId",
+ advId).executeUpdate();
- AdvisoryPackage advpkg = entityManager.find(AdvisoryPackage.class, advId);
- if (advpkg != null) {
- entityManager.remove(advpkg);
- log.debug("User [" + user + "] deleted CVE [" + advpkg + "]");
+ if (success == 1) {
+ log.debug("User [" + user + "] deleted AdvisoryPackage for [" + advId + "]");
} else {
log.debug("Advisory ID [" + advId + "] doesn't exist - nothing to delete");
}
}
public void deleteAdvisoryBugList(Subject user, int advId) {
- log.debug("User [" + user + "] is deleting CVE [" + advId + "]");
+ log.debug("User [" + user + "] is deleting Buglist for Advisory [" + advId + "]");
entityManager.flush();
entityManager.clear();
- entityManager.createNamedQuery(AdvisoryBuglist.DELETE_BY_ADV_ID).setParameter("advId", advId).executeUpdate();
+ int success = entityManager.createNamedQuery(AdvisoryBuglist.DELETE_BY_ADV_ID).setParameter("advId", advId)
+ .executeUpdate();
- AdvisoryBuglist advbugs = entityManager.find(AdvisoryBuglist.class, advId);
- if (advbugs != null) {
- entityManager.remove(advbugs);
- log.debug("User [" + user + "] deleted CVE [" + advbugs + "]");
+ if (success == 1) {
+ log.debug("User [" + user + "] deleted buglist for Advisory [" + advId + "]");
} else {
log.debug("Advisory ID [" + advId + "] doesn't exist - nothing to delete");
}
commit 5ee5e05f9f1c8035b571ea591babc5a17dac8a59
Author: Sayli Karmarkar <skarmark(a)redhat.com>
Date: Thu Jan 21 05:27:05 2010 -0500
1368,1369 - Adding webUI and manager layer changes for tracking resource deployment
diff --git a/.classpath b/.classpath
index 020776a..a8668a4 100644
--- a/.classpath
+++ b/.classpath
@@ -225,6 +225,6 @@
<classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.2.1/byteman-1.2.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.2/antlr-runtime-3.2.jar"/>
<classpathentry exported="true" kind="lib" path="modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-1.4.0-SNAPSHOT/wsconsume-output"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/jboss/web/jbossweb/2.0.1.GA/jbossweb-2.0.1.GA.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/jboss/web/jbossweb/2.0.1.GA/jbossweb-2.0.1.GA.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PageControlView.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PageControlView.java
index 4927a71..321a755 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PageControlView.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/paging/PageControlView.java
@@ -53,6 +53,7 @@ import org.rhq.enterprise.gui.content.RepoSubscriptionsUIBean;
import org.rhq.enterprise.gui.content.RepoUnsubscriptionsUIBean;
import org.rhq.enterprise.gui.content.ResourcePackageVersionsUIBean;
import org.rhq.enterprise.gui.content.ResourceReposUIBean;
+import org.rhq.enterprise.gui.content.ResourceUpdatePackageVersionsUIBean;
import org.rhq.enterprise.gui.content.ShowContentServiceRequestUIBean;
import org.rhq.enterprise.gui.definition.group.GroupDefinitionUIBean;
import org.rhq.enterprise.gui.definition.group.ListGroupDefinitionsUIBean;
@@ -160,6 +161,8 @@ public enum PageControlView {
/** */
ResourcePackageVersionsList(ResourcePackageVersionsUIBean.class),
/** */
+ ResourceUpdatePackageVersionsList(ResourceUpdatePackageVersionsUIBean.class),
+ /** */
PackagesToDeployList(DeployPackagesUIBean.class),
/** */
InstalledPackageHistoryList(ShowContentServiceRequestUIBean.class),
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/layout/main-no-leftnav.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/layout/main-no-leftnav.xhtml
index 0ec84df..6cf4efb 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/layout/main-no-leftnav.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/layout/main-no-leftnav.xhtml
@@ -115,6 +115,7 @@ REQUEST PARAMETERS:
rendered="#{ResourceUIBean.facets.content}">
<onc:subtab name="Deployed" url="/rhq/resource/content/view.xhtml" />
<onc:subtab name="New" url="/rhq/resource/content/deploy.xhtml" />
+ <onc:subtab name="Update" url="/rhq/resource/content/update.xhtml" />
<onc:subtab name="Subscriptions" url="/rhq/resource/content/subscription.xhtml" />
<onc:subtab name="History" url="/rhq/resource/content/history.xhtml" />
</onc:tab>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
index 5f8e828..3d72055 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerBean.java
@@ -19,7 +19,9 @@
package org.rhq.enterprise.server.content;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
@@ -224,6 +226,22 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
String filter, PageControl pc) {
pc.initDefaultOrderingField("pv.generalPackage.name", PageOrdering.ASC);
+ Query queryInstalled = PersistenceUtility.createQueryWithOrderBy(entityManager,
+ InstalledPackage.QUERY_FIND_PACKAGE_LIST_ITEM_COMPOSITE, pc);
+
+ queryInstalled.setParameter("resourceId", resourceId);
+ queryInstalled.setParameter("packageTypeFilterId", null);
+ queryInstalled.setParameter("packageVersionFilter", null);
+ queryInstalled.setParameter("search", null);
+ queryInstalled.setParameter("search", null);
+
+ List<PackageListItemComposite> packagesInstalled = queryInstalled.getResultList();
+
+ List<String> installedPackageNames = new ArrayList<String>();
+ for (PackageListItemComposite packageInstalled : packagesInstalled) {
+ installedPackageNames.add(packageInstalled.getPackageName());
+ }
+
Query query = PersistenceUtility.createQueryWithOrderBy(entityManager,
PackageVersion.QUERY_FIND_COMPOSITE_BY_FILTERS, pc);
Query queryCount = PersistenceUtility.createCountQuery(entityManager,
@@ -237,8 +255,64 @@ public class ContentUIManagerBean implements ContentUIManagerLocal {
long count = (Long) queryCount.getSingleResult();
List<PackageVersionComposite> results = query.getResultList();
+ List<PackageVersionComposite> modifiedResults = new ArrayList<PackageVersionComposite>();
+
+ for (PackageVersionComposite result : results) {
+ if (installedPackageNames.contains(result.getPackageName())) {
+ if (count > 0)
+ count--;
+ } else {
+ modifiedResults.add(result);
+ }
+ }
+
+ return new PageList<PackageVersionComposite>(modifiedResults, (int) count, pc);
+ }
+
+ @SuppressWarnings("unchecked")
+ public PageList<PackageVersionComposite> getUpdatePackageVersionCompositesByFilter(Subject user, int resourceId,
+ String filter, PageControl pc) {
+ pc.initDefaultOrderingField("pv.generalPackage.name", PageOrdering.ASC);
+
+ Query queryInstalled = PersistenceUtility.createQueryWithOrderBy(entityManager,
+ InstalledPackage.QUERY_FIND_PACKAGE_LIST_ITEM_COMPOSITE, pc);
+
+ queryInstalled.setParameter("resourceId", resourceId);
+ queryInstalled.setParameter("packageTypeFilterId", null);
+ queryInstalled.setParameter("packageVersionFilter", null);
+ queryInstalled.setParameter("search", null);
+ queryInstalled.setParameter("search", null);
+
+ List<PackageListItemComposite> packagesInstalled = queryInstalled.getResultList();
+
+ Map<String, String> installedPackageNameAndVersion = new HashMap<String, String>();
+ for (PackageListItemComposite packageInstalled : packagesInstalled) {
+ installedPackageNameAndVersion.put(packageInstalled.getPackageName(), packageInstalled.getVersion());
+ }
+
+ Query query = PersistenceUtility.createQueryWithOrderBy(entityManager,
+ PackageVersion.QUERY_FIND_COMPOSITE_BY_FILTERS, pc);
+ query.setParameter("resourceId", resourceId);
+ query.setParameter("filter", filter);
+
+ long count = 0;
+ List<PackageVersionComposite> results = query.getResultList();
+ List<PackageVersionComposite> modifiedResults = new ArrayList<PackageVersionComposite>();
+ String packageName = new String();
+
+ for (PackageVersionComposite result : results) {
+ if (installedPackageNameAndVersion.get(result.getPackageName()) != null) {
- return new PageList<PackageVersionComposite>(results, (int) count, pc);
+ packageName = installedPackageNameAndVersion.get(result.getPackageName());
+
+ if (installedPackageNameAndVersion.get(packageName).compareTo(result.getPackageVersion().getVersion()) < 0) {
+ modifiedResults.add(result);
+ count++;
+ }
+
+ }
+ }
+ return new PageList<PackageVersionComposite>(modifiedResults, (int) count, pc);
}
public PackageVersionComposite loadPackageVersionComposite(Subject user, int packageVersionId) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerLocal.java
index 63dbc97..6b9d2f8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/ContentUIManagerLocal.java
@@ -134,6 +134,9 @@ public interface ContentUIManagerLocal {
PageList<PackageVersionComposite> getPackageVersionCompositesByFilter(Subject user, int resourceId, String filter,
PageControl pc);
+ PageList<PackageVersionComposite> getUpdatePackageVersionCompositesByFilter(Subject user, int resourceId,
+ String filter, PageControl pc);
+
/**
* Used to retrieve information about a package version to display to a user.
*
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 b428989..9d59c39 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
@@ -781,17 +781,24 @@
placement="firstChild" />
</tab>
- <tab name="Content.New" displayName="New" url="/rhq/resource/content/deploy.xhtml">
+ <tab name="Content.New" displayName="Install" url="/rhq/resource/content/deploy.xhtml">
<position
name="Content.Deployed"
placement="after" />
+ </tab>
+
+ <tab name="Content.Update" displayName="Update" url="/rhq/resource/content/update.xhtml">
+ <position
+
+ name="Content.New"
+ placement="after" />
</tab>
<tab name="Content.Subscriptions" displayName="Subscriptions" url="/rhq/resource/content/subscription.xhtml">
<position
- name="Content.New"
+ name="Content.Update"
placement="after" />
</tab>
diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java
index e6f6c09..d04210e 100644
--- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java
+++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/content/RpmPackageDiscoveryDelegate.java
@@ -1,25 +1,25 @@
- /*
- * 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.plugins.platform.content;
import java.io.BufferedReader;
@@ -27,8 +27,10 @@ import java.io.IOException;
import java.io.StringReader;
import java.util.HashSet;
import java.util.Set;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.rhq.core.domain.content.PackageDetailsKey;
import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
commit 57fa9d105ea7e5aa5aad147c6c8f93806dbe4352
Author: Sayli Karmarkar <skarmark(a)redhat.com>
Date: Thu Jan 21 05:26:11 2010 -0500
1368,1369 - Adding webUI and manager layer changes for tracking resource deployment
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/ResourceUpdatePackageVersionsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/ResourceUpdatePackageVersionsUIBean.java
new file mode 100644
index 0000000..dc801f3
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/ResourceUpdatePackageVersionsUIBean.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 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.gui.content;
+
+import javax.faces.model.DataModel;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.content.composite.PackageVersionComposite;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.gui.util.FacesContextUtility;
+import org.rhq.enterprise.gui.common.framework.PagedDataTableUIBean;
+import org.rhq.enterprise.gui.common.paging.PageControlView;
+import org.rhq.enterprise.gui.common.paging.PagedListDataModel;
+import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
+import org.rhq.enterprise.server.content.ContentUIManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+public class ResourceUpdatePackageVersionsUIBean extends PagedDataTableUIBean {
+
+ public static final String MANAGED_BEAN_NAME = "ResourceUpdatePackageVersionsUIBean";
+
+ public ResourceUpdatePackageVersionsUIBean() {
+ }
+
+ @Override
+ public DataModel getDataModel() {
+ if (dataModel == null) {
+ dataModel = new ResourceUpdatePackageVersionsDataModel(PageControlView.ResourceUpdatePackageVersionsList,
+ MANAGED_BEAN_NAME);
+ }
+
+ return dataModel;
+ }
+
+ private class ResourceUpdatePackageVersionsDataModel extends PagedListDataModel<PackageVersionComposite> {
+ public ResourceUpdatePackageVersionsDataModel(PageControlView view, String beanName) {
+ super(view, beanName);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public PageList<PackageVersionComposite> fetchPage(PageControl pc) {
+ Subject subject = EnterpriseFacesContextUtility.getSubject();
+ Integer resourceId = Integer.parseInt(FacesContextUtility.getRequiredRequestParameter("id"));
+ //String filter = FacesContextUtility.getRequiredRequestParameter("contentForm:filter");
+ ContentUIManagerLocal manager = LookupUtil.getContentUIManager();
+
+ PageList<PackageVersionComposite> results = manager.getUpdatePackageVersionCompositesByFilter(subject,
+ resourceId, null, pc);
+ return results;
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/update.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/update.xhtml
new file mode 100644
index 0000000..09c6e6b
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/update.xhtml
@@ -0,0 +1,137 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:c="http://java.sun.com/jstl/core"
+ xmlns:onc="http://jboss.org/on/component"
+ xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
+ xmlns:rich="http://richfaces.ajax4jsf.org/rich">
+
+<ui:composition template="/rhq/resource/layout/main.xhtml">
+
+ <ui:param name="pageTitle" value="Update Existing Package"/>
+ <ui:param name="selectedTabName" value="Content.Update"/>
+ <ui:define name="content">
+
+ <h:form id="currentPackageVersionsForm">
+ <input type="hidden" name="id" value="${param.id}"/>
+
+ <rich:panel styleClass="BlockContent">
+ <f:facet name="header"><h:outputText value="Packages Eligible for Update"/></f:facet>
+
+ <p>The following packages were found from the repositories currently subscribed to by this resource. In order
+ to enable more existing packages for deployment, use the subscriptions sub-tab to subscribe this resource
+ to more repositories.</p>
+
+ <a4j:keepAlive beanName="ResourcePackageVersionsUIBean"/>
+
+ <ui:param name="resourcePackageVersionsDataModel" value="#{ResourcePackageVersionsUIBean.dataModel}"/>
+ <rich:dataTable id="resourcePackageVersionsDataTable"
+ rows="#{PageControl.ResourcePackageVersionsList.pageSize}"
+ value="#{resourcePackageVersionsDataModel}"
+ var="item"
+ width="100%"
+ columnsWidth="1%, 15%, 10%, 10%, 10%, 54%"
+ headerClass="tableRowHeader"
+ footerClass="on-pager-footer"
+ onRowMouseOver="this.style.backgroundColor='#E7E7E7'"
+ onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
+
+ <f:facet name="PageControlView">
+ <onc:paginationControl id="ResourcePackageVersionsList" />
+ </f:facet>
+
+ <rich:column>
+ <f:facet name="header">
+ <onc:allSelect target="selectedPackages" />
+ </f:facet>
+
+ <onc:select name="selectedPackages" value="#{item.packageVersion.id}"/>
+ </rich:column>
+
+ <rich:column>
+ <f:facet name="header">
+ <onc:sortableColumnHeader sort="pv.generalPackage.name">
+ <h:outputText styleClass="headerText" value="Package Name" />
+ </onc:sortableColumnHeader>
+ </f:facet>
+
+ <h:outputLink value="../../content/packageVersion.xhtml">
+ <f:param name="id" value="#{item.packageVersion.id}"/>
+ <h:outputText value="#{item.packageName}"/>
+ </h:outputLink>
+
+ </rich:column>
+
+ <rich:column>
+ <f:facet name="header">
+ <onc:sortableColumnHeader sort="pv.displayVersion">
+ <h:outputText styleClass="headerText" value="Version" />
+ </onc:sortableColumnHeader>
+ </f:facet>
+
+ <h:outputText value="#{item.packageVersion.displayVersion}"/>
+ </rich:column>
+
+ <rich:column>
+ <f:facet name="header">
+ <onc:sortableColumnHeader sort="pv.generalPackage.packageType.displayName">
+ <h:outputText styleClass="headerText" value="Type" />
+ </onc:sortableColumnHeader>
+ </f:facet>
+
+ <h:outputText value="#{item.packageTypeName}"/>
+ </rich:column>
+
+ <rich:column>
+ <f:facet name="header">
+ <onc:sortableColumnHeader sort="pv.architecture">
+ <h:outputText styleClass="headerText" value="Architecture" />
+ </onc:sortableColumnHeader>
+ </f:facet>
+
+ <h:outputText value="#{item.architectureName}"/>
+ </rich:column>
+
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText styleClass="headerText" value="Description" />
+ </f:facet>
+
+ <h:outputText value="#{item.packageVersion.shortDescription}" escape="false"/>
+ </rich:column>
+
+ <f:facet name="footer">
+ <rich:columnGroup>
+ <rich:column colspan="6" width="100%">
+ <onc:selectCommandButton action="#{CreateNewPackageUIBean.deployExisting}"
+ value="DEPLOY SELECTED" target="selectedPackages" styleClass="on-pager-button buttonsmall"
+ rendered="${ResourceUIBean.permissions.content}"/>
+
+ <ui:include src="/rhq/resource/include/pagination.xhtml">
+ <ui:param name="paginationDataTableName" value="resourcePackageVersionsDataTable"/>
+ <ui:param name="paginationDataModel" value="#{resourcePackageVersionsDataModel}"/>
+ <ui:param name="paginationPageControl" value="#{PageControl.ResourcePackageVersionsList}"/>
+ </ui:include>
+ </rich:column>
+ </rich:columnGroup>
+ </f:facet>
+
+ </rich:dataTable>
+
+
+ </rich:panel>
+
+ </h:form>
+
+
+ </ui:define>
+</ui:composition>
+
+</html>
commit 77e83c9287b56bc6b993cbb4c7021bb50ce4d13d
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 10:47:30 2010 -0500
Initial version
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java
new file mode 100644
index 0000000..00a01f3
--- /dev/null
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsAdvisoryManagerTest.java
@@ -0,0 +1,107 @@
+/*
+* 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.ws.test;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.testng.AssertJUnit;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.rhq.enterprise.server.ws.Advisory;
+import org.rhq.enterprise.server.ws.ObjectFactory;
+import org.rhq.enterprise.server.ws.Subject;
+import org.rhq.enterprise.server.ws.TestPropertiesInterface;
+import org.rhq.enterprise.server.ws.WebservicesManagerBeanService;
+import org.rhq.enterprise.server.ws.WebservicesRemote;
+import org.rhq.enterprise.server.ws.test.util.WsSubjectUtility;
+import org.rhq.enterprise.server.ws.utility.WsUtility;
+
+/**
+ * Web service tests for the advisory manager services.
+ *
+ * @author Jason Dobies
+ */
+@Test(groups = "ws")
+public class WsAdvisoryManagerTest extends AssertJUnit implements TestPropertiesInterface {
+
+ private static final boolean TESTS_ENABLED = true;
+
+ private WebservicesRemote service;
+ private ObjectFactory objectFactory;
+
+ private WsSubjectUtility subjectUtil;
+
+ @BeforeClass
+ public void setup() throws Exception {
+
+ // Variables needed
+ URL gUrl = WsUtility.generateRemoteWebserviceURL(WebservicesManagerBeanService.class, host, port, useSSL);
+ QName gQName = WsUtility.generateRemoteWebserviceQName(WebservicesManagerBeanService.class);
+
+ // Establish outbound webservices connections
+ WebservicesManagerBeanService jws = new WebservicesManagerBeanService(gUrl, gQName);
+ service = jws.getWebservicesManagerBeanPort();
+
+ objectFactory = new ObjectFactory();
+
+ subjectUtil = new WsSubjectUtility(service);
+ }
+
+ @Test(enabled = TESTS_ENABLED)
+ public void createGetDeleteAdvisory() throws Exception {
+
+ // Setup
+ String label = "WsAdvisoryManagerTest.createGetDeleteAdvisory.label";
+ String synopsis = "WsAdvisoryManagerTest.createGetDeleteAdvisory.name";
+ String type = "bugfix";
+
+ Subject admin = subjectUtil.admin();
+
+ // Test
+ Advisory created = service.createAdvisory(admin, label, type, synopsis);
+
+ assert created != null;
+
+ Advisory retrieved = service.getAdvisoryByName(label);
+
+ service.deleteAdvisoryByAdvId(admin, created.getId());
+
+ // Verify
+ assert label.equals(created.getAdvisory()) : "Found: " + created.getAdvisory();
+ assert synopsis.equals(created.getSynopsis()) : "Found: " + created.getAdvisoryName();
+ assert type.equals(created.getAdvisoryType()) : "Found: " + created.getAdvisoryType();
+
+ assert retrieved != null;
+ assert label.equals(retrieved.getAdvisory()) : "Found: " + retrieved.getAdvisory();
+ assert synopsis.equals(retrieved.getSynopsis()) : "Found: " + retrieved.getAdvisoryName();
+ assert type.equals(retrieved.getAdvisoryType()) : "Found: " + retrieved.getAdvisoryType();
+
+ retrieved = service.getAdvisoryByName(label);
+
+ assert retrieved == null;
+ }
+
+}
commit b02df6c83f1c6144af94145a3b5fad3c2296c071
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 10:46:47 2010 -0500
Accidentally removed the ws excluded group, didn't mean to commit that.
diff --git a/modules/enterprise/remoting/webservices/pom.xml b/modules/enterprise/remoting/webservices/pom.xml
index b0922a7..833d0d4 100644
--- a/modules/enterprise/remoting/webservices/pom.xml
+++ b/modules/enterprise/remoting/webservices/pom.xml
@@ -160,7 +160,7 @@
<excludes>
<exclude>com/**/*.java</exclude>
</excludes>
- <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
+ <excludedGroups>${rhq.testng.excludedGroups},ws</excludedGroups>
<systemProperties>
<property>
<name>deploymentDirectory</name>
commit 410605fc772991aefd9ff8945cbe43fa883b5d65
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 10:34:57 2010 -0500
Renamed incorrect parameter name (was "name" in remote but "synopsis" in bean)
diff --git a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
index c4c8aed..d261413 100644
--- a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
+++ b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClient.java
@@ -35,6 +35,7 @@ import org.rhq.enterprise.server.alert.AlertManagerRemote;
import org.rhq.enterprise.server.auth.SubjectManagerRemote;
import org.rhq.enterprise.server.authz.RoleManagerRemote;
import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
+import org.rhq.enterprise.server.content.AdvisoryManagerRemote;
import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
@@ -66,10 +67,11 @@ import org.rhq.enterprise.server.system.SystemManagerRemote;
public class RemoteClient {
public enum Manager {
+ AdvisoryManager(AdvisoryManagerRemote.class), //
AlertManager(AlertManagerRemote.class), //
AlertDefinitionManager(AlertDefinitionManagerRemote.class), //
AvailabilityManager(AvailabilityManagerRemote.class), //
- CallTimeDataManager(CallTimeDataManagerRemote.class), //
+ CallTimeDataManager(CallTimeDataManagerRemote.class), //
RepoManager(RepoManagerRemote.class), //
ConfigurationManager(ConfigurationManagerRemote.class), //
//ContentHelperManager(ContentHelperRemote.class), //
@@ -79,7 +81,7 @@ public class RemoteClient {
EventManager(EventManagerRemote.class), //
MeasurementBaselineManager(MeasurementBaselineManagerRemote.class), //
MeasurementDataManager(MeasurementDataManagerRemote.class), //
- MeasurementDefinitionManager(MeasurementDefinitionManagerRemote.class), //
+ MeasurementDefinitionManager(MeasurementDefinitionManagerRemote.class), //
MeasurementScheduleManager(MeasurementScheduleManagerRemote.class), //
OperationManager(OperationManagerRemote.class), //
ResourceManager(ResourceManagerRemote.class), //
@@ -133,7 +135,7 @@ public class RemoteClient {
* Creates a client that will communicate with the server running on the given host
* listening on the given port. This constructor will not attempt to connect or login
* to the remote server - use {@link #login(String, String)} for that.
- *
+ *
* @param host
* @param port
*/
@@ -146,7 +148,7 @@ public class RemoteClient {
* listening on the given port over the given transport.
* This constructor will not attempt to connect or login
* to the remote server - use {@link #login(String, String)} for that.
- *
+ *
* @param transport valid values are "servlet" and "sslservlet" - if <code>null</code>,
* sslservlet will be used for ports that end with "443", servlet otherwise
* @param host
@@ -167,7 +169,7 @@ public class RemoteClient {
* Connects to the remote server and logs in with the given credentials.
* After successfully executing this, {@link #isLoggedIn()} will be <code>true</code>
* and {@link #getSubject()} will return the subject that this method returns.
- *
+ *
* @param user
* @param password
*
@@ -211,10 +213,10 @@ public class RemoteClient {
/**
* Connects to the remote server but does not establish a user session. This can be used
* with the limited API that does not require a Subject.
- *
+ *
* After successfully executing this, {@link #isConnected()} will be <code>true</code>
* and {@link #getSubject()} will return the subject that this method returns.
- *
+ *
* @param user
* @param password
*
@@ -249,7 +251,7 @@ public class RemoteClient {
/**
* Returns <code>true</code> if and only if this client successfully connected
* to the remote server and the user successfully logged in.
- *
+ *
* @return if the user was able to connect and log into the server
*/
public boolean isLoggedIn() {
@@ -259,7 +261,7 @@ public class RemoteClient {
/**
* Returns <code>true</code> if and only if this client successfully connected
* to the remote server.
- *
+ *
* @return if the user was able to connect and log into the server
*/
public boolean isConnected() {
@@ -269,7 +271,7 @@ public class RemoteClient {
/**
* Returns the information on the user that is logged in.
* May be <code>null</code> if the user never logged in successfully.
- *
+ *
* @return user information or <code>null</code>
*/
public Subject getSubject() {
@@ -301,13 +303,17 @@ public class RemoteClient {
* be set appropriately for the {@link #getPort()} (e.g. a secure transport
* will be used for ports that end with 443, a non-secure transport will be
* used for all other ports).
- *
+ *
* @param transport
*/
public void setTransport(String transport) {
this.transport = transport;
}
+ public AdvisoryManagerRemote getAdvisoryManagerRemote() {
+ return RemoteClientProxy.getProcessor(this, Manager.AdvisoryManager);
+ }
+
public AlertManagerRemote getAlertManagerRemote() {
return RemoteClientProxy.getProcessor(this, Manager.AlertManager);
}
@@ -407,7 +413,7 @@ public class RemoteClient {
/**
* Returns the map of all remote managers running in the server that this
* client can talk to.
- *
+ *
* @return Map K=manager name V=remote proxy
*/
public Map<String, Object> getManagers() {
@@ -431,9 +437,9 @@ public class RemoteClient {
/**
* Returns the internal JBoss/Remoting client used to perform the low-level
* comm with the server.
- *
+ *
* This is package-scoped so the proxy can use it.
- *
+ *
* @return remoting client used to talk to the server
*/
Client getRemotingClient() {
@@ -509,7 +515,7 @@ public class RemoteClient {
* Looks up the prop name in system properties and puts the value in the map. If the property
* isn't set, the given default is used. If the given default is null and the property isn't
* set, then the map is not populated.
- *
+ *
* @param configMap
* @param propName
* @param defaultValue
diff --git a/modules/enterprise/remoting/webservices/pom.xml b/modules/enterprise/remoting/webservices/pom.xml
index 833d0d4..b0922a7 100644
--- a/modules/enterprise/remoting/webservices/pom.xml
+++ b/modules/enterprise/remoting/webservices/pom.xml
@@ -160,7 +160,7 @@
<excludes>
<exclude>com/**/*.java</exclude>
</excludes>
- <excludedGroups>${rhq.testng.excludedGroups},ws</excludedGroups>
+ <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
<systemProperties>
<property>
<name>deploymentDirectory</name>
diff --git a/modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml b/modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml
index e4ab64b..3044936 100644
--- a/modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml
+++ b/modules/enterprise/remoting/webservices/src/main/scripts/rhq-client.build.xml
@@ -9,9 +9,10 @@
<property name="wsprovide.home" location="${project.build.outputDirectory}/wsprovide-output" />
<property name="include.client.jar" value="true" />
- <!-- load all the Stateless Session Bean for WS exposure as properties. Must add bean as separate
+ <!-- load all the Stateless Session Bean for WS exposure as properties. Must add bean as separate
property AND in the "ws-list" below for successful inclusion. ##TODO SP: collapse these to one list. -->
<property name="PropertyBagManager" value="org.rhq.enterprise.server.jaxb.PropertyBagManagerBean" />
+ <property name="AdvisoryManager" value="org.rhq.enterprise.server.content.AdvisoryManagerBean"/>
<property name="AlertManager" value="org.rhq.enterprise.server.alert.AlertManagerBean" />
<property name="AlertDefinitionManager" value="org.rhq.enterprise.server.alert.AlertDefinitionManagerBean" />
<property name="AvailabilityManager" value="org.rhq.enterprise.server.measurement.AvailabilityManagerBean" />
@@ -79,9 +80,9 @@
</patternset>
</unzip>
- <!-- Run JBossWS 3.1.1 upgrade script on the JBossAS:
- i) pull upgrade bundle
- ii) unzip
+ <!-- Run JBossWS 3.1.1 upgrade script on the JBossAS:
+ i) pull upgrade bundle
+ ii) unzip
iii) run it on JBossAS instance (4.2.3) to 3.1.1.
These upgrade steps should be revisited when moving JBossAS version beyond 4.2.3 -->
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
index cbcea16..b4367db 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
@@ -51,8 +51,6 @@ public class WsRegistrationManagerTest extends AssertJUnit implements TestProper
private WebservicesRemote service;
private ObjectFactory objectFactory;
- private Subject subject;
-
@BeforeClass
public void setup() throws Exception {
@@ -65,16 +63,6 @@ public class WsRegistrationManagerTest extends AssertJUnit implements TestProper
service = jws.getWebservicesManagerBeanPort();
objectFactory = new ObjectFactory();
-
- // Establish a new user in the system
- WsSubjectUtility subjectUtil = new WsSubjectUtility(service);
- subject = subjectUtil.createOrLoginUser("reg-manager-test", "reg-manager-test");
- }
-
- @AfterClass
- public void teardown() throws Exception {
- WsSubjectUtility subjectUtil = new WsSubjectUtility(service);
- subjectUtil.deleteUser(subject.getId());
}
@Test(enabled = TESTS_ENABLED)
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java
index 2caeeb7..cb0514f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerRemote.java
@@ -44,7 +44,7 @@ public interface AdvisoryManagerRemote {
* Creates a new advisory in the system. If the advisory does not exist, it will be created.
* If a advisory exists with the specified version ID, a new one will not be created and the
* existing advisory will be returned.
- * @param subject
+ * @param user
* @param advisory advisory label
* @param advisoryType adv type
* @return newly created advisory object
@@ -52,7 +52,7 @@ public interface AdvisoryManagerRemote {
@WebMethod
Advisory createAdvisory(@WebParam(name = "subject") Subject user, @WebParam(name = "advisory") String advisory, //
@WebParam(name = "advisoryType") String advisoryType, //
- @WebParam(name = "advisoryName") String advisoryName) throws AdvisoryException;
+ @WebParam(name = "advisoryName") String synopsis) throws AdvisoryException;
/**
* creates a cve instance for a given cve name
@@ -65,14 +65,14 @@ public interface AdvisoryManagerRemote {
@WebParam(name = "cvename") String cvename) throws AdvisoryException;
/**
- * creates a AdvisoryCVE relationship object
+ * creates a AdvisoryCVE relationship object
* @param user
* @param advisory
* @param cve
* @return AdvisoryCVE object
* @throws AdvisoryException
*/
- AdvisoryCVE createAdvisoryCVE(@WebParam(name = "subject") Subject user, //
+ AdvisoryCVE createAdvisoryCVE(@WebParam(name = "subject") Subject user, //
@WebParam(name = "advisory") Advisory advisory, //
@WebParam(name = "cve") CVE cve) throws AdvisoryException;
@@ -183,7 +183,7 @@ public interface AdvisoryManagerRemote {
/**
* find AdvisoryPackage object for given advId and packageVersion id
* @param overlord
- * @param advId
+ * @param advId
* @param pkgVerId
*/
@WebMethod
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
index 8c43cb4..53c1be0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
@@ -38,6 +38,7 @@ import org.rhq.enterprise.server.alert.AlertManagerBean;
import org.rhq.enterprise.server.auth.SubjectManagerBean;
import org.rhq.enterprise.server.authz.RoleManagerBean;
import org.rhq.enterprise.server.configuration.ConfigurationManagerBean;
+import org.rhq.enterprise.server.content.AdvisoryManagerBean;
import org.rhq.enterprise.server.content.ContentManagerBean;
import org.rhq.enterprise.server.content.RepoManagerBean;
import org.rhq.enterprise.server.event.EventManagerBean;
@@ -64,7 +65,8 @@ import org.rhq.enterprise.server.system.SystemManagerBean;
public class RemoteAPIValidator {
private static Class<?>[] beans = new Class[] { //
- AlertDefinitionManagerBean.class, //
+ AdvisoryManagerBean.class, //
+ AlertDefinitionManagerBean.class, //
AlertManagerBean.class,//
AvailabilityManagerBean.class,//
CallTimeDataManagerBean.class, //
@@ -93,8 +95,8 @@ public class RemoteAPIValidator {
private static Set<String> finderMethodExceptions = new HashSet<String>();
static {
- /*
- * unless otherwise noted, all of the below methods return data considered to
+ /*
+ * unless otherwise noted, all of the below methods return data considered to
* be single, logical objects even though they are implemented as list structures
*/
finderMethodExceptions.add("translateInstallationSteps");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 19e07ac..af011a6 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -28,6 +28,7 @@ import java.util.Map;
import java.util.Set;
import javax.ejb.Stateless;
+import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -47,7 +48,11 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.group.GroupPluginConfigurationUpdate;
import org.rhq.core.domain.configuration.group.GroupResourceConfigurationUpdate;
import org.rhq.core.domain.content.Advisory;
+import org.rhq.core.domain.content.AdvisoryBuglist;
+import org.rhq.core.domain.content.AdvisoryCVE;
+import org.rhq.core.domain.content.AdvisoryPackage;
import org.rhq.core.domain.content.Architecture;
+import org.rhq.core.domain.content.CVE;
import org.rhq.core.domain.content.Distribution;
import org.rhq.core.domain.content.InstalledPackage;
import org.rhq.core.domain.content.PackageType;
@@ -104,6 +109,8 @@ import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.RoleManagerLocal;
import org.rhq.enterprise.server.configuration.ConfigurationManagerLocal;
import org.rhq.enterprise.server.configuration.ConfigurationUpdateStillInProgressException;
+import org.rhq.enterprise.server.content.AdvisoryException;
+import org.rhq.enterprise.server.content.AdvisoryManagerLocal;
import org.rhq.enterprise.server.content.ContentManagerLocal;
import org.rhq.enterprise.server.content.RepoException;
import org.rhq.enterprise.server.content.RepoManagerLocal;
@@ -142,8 +149,8 @@ import org.rhq.enterprise.server.util.LookupUtil;
/** The purpose of this class is to aggregate all the EJB remote implementation into one
* class that can be annotated by JBossWS. Each annotated SLSB causes a full WSDL compile and
- * publish by JBossWS which is very costly in terms of time. Deploy times went from 2 mins to 12 mins.
- *
+ * publish by JBossWS which is very costly in terms of time. Deploy times went from 2 mins to 12 mins.
+ *
* @author Simeon Pinder
*
*/
@@ -154,6 +161,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class WebservicesManagerBean implements WebservicesRemote {
//Lookup the required beans as local references
+ private AdvisoryManagerLocal advisoryManager = LookupUtil.getAdvisoryManagerLocal();
private AlertManagerLocal alertManager = LookupUtil.getAlertManager();
private AlertDefinitionManagerLocal alertDefinitionManager = LookupUtil.getAlertDefinitionManager();
private AvailabilityManagerLocal availabilityManager = LookupUtil.getAvailabilityManager();
@@ -182,6 +190,94 @@ public class WebservicesManagerBean implements WebservicesRemote {
private SupportManagerLocal supportManager = LookupUtil.getSupportManager();
private SystemManagerLocal systemManager = LookupUtil.getSystemManager();
+ //ADVISORYMANAGER: BEGIN ------------------------------------------
+
+ public Advisory createAdvisory(@WebParam(name = "subject") Subject user,
+ @WebParam(name = "advisory") String advisory,
+ @WebParam(name = "advisoryType") String advisoryType,
+ @WebParam(name = "advisoryName") String advisoryName) throws AdvisoryException {
+ return advisoryManager.createAdvisory(user, advisory, advisoryType, advisoryName);
+ }
+
+ public CVE createCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "cvename") String cvename)
+ throws AdvisoryException {
+ return advisoryManager.createCVE(user, cvename);
+ }
+
+ public AdvisoryCVE createAdvisoryCVE(@WebParam(name = "subject") Subject user,
+ @WebParam(name = "advisory") Advisory advisory,
+ @WebParam(name = "cve") CVE cve) throws AdvisoryException {
+ return advisoryManager.createAdvisoryCVE(user, advisory, cve);
+ }
+
+ public AdvisoryPackage createAdvisoryPackage(@WebParam(name = "subject") Subject user,
+ @WebParam(name = "advisory") Advisory advisory,
+ @WebParam(name = "pkg") PackageVersion pkg) throws AdvisoryException {
+ return advisoryManager.createAdvisoryPackage(user, advisory, pkg);
+ }
+
+ public void deleteCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "cveId") int cveId) {
+ advisoryManager.deleteAdvisoryCVE(user, cveId);
+ }
+
+ public void deleteAdvisoryCVE(@WebParam(name = "subject") Subject user, @WebParam(name = "advId") int advId) {
+ advisoryManager.deleteAdvisoryCVE(user, advId);
+ }
+
+ public void deleteAdvisoryByAdvId(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "advId") int advId) {
+ advisoryManager.deleteAdvisoryByAdvId(subject, advId);
+ }
+
+ public Advisory getAdvisoryByName(@WebParam(name = "advlabel") String advlabel) {
+ return advisoryManager.getAdvisoryByName(advlabel);
+ }
+
+ public List<AdvisoryPackage> findPackageByAdvisory(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "advId") int advId,
+ @WebParam(name = "pc") PageControl pc) {
+ return advisoryManager.findPackageByAdvisory(subject, advId, pc);
+ }
+
+ public PackageVersion findPackageVersionByPkgId(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "rpmName") String rpmName,
+ @WebParam(name = "pc") PageControl pc) {
+ return advisoryManager.findPackageVersionByPkgId(subject, rpmName, pc);
+ }
+
+ public PageList<AdvisoryCVE> getAdvisoryCVEByAdvId(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "advId") int advId,
+ @WebParam(name = "pc") PageControl pc) {
+ return advisoryManager.getAdvisoryCVEByAdvId(subject, advId, pc);
+ }
+
+ public List<AdvisoryBuglist> getAdvisoryBuglistByAdvId(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "advId") int advId) {
+ return advisoryManager.getAdvisoryBuglistByAdvId(subject, advId);
+ }
+
+ public void deleteAdvisoryBugList(@WebParam(name = "subject") Subject overlord, @WebParam(name = "advId") int id) {
+ advisoryManager.deleteAdvisoryBugList(overlord, id);
+ }
+
+ public void deleteAdvisoryPackage(@WebParam(name = "subject") Subject user, @WebParam(name = "advId") int advId) {
+ advisoryManager.deleteAdvisoryPackage(user, advId);
+ }
+
+ public AdvisoryPackage findAdvisoryPackage(@WebParam(name = "subject") Subject overlord,
+ @WebParam(name = "advId") int advId,
+ @WebParam(name = "pkgVerId") int pkgVerId) {
+ return advisoryManager.findAdvisoryPackage(overlord, advId, pkgVerId);
+ }
+
+ public AdvisoryBuglist getAdvisoryBuglist(@WebParam(name = "subject") Subject subject,
+ @WebParam(name = "advId") int advId,
+ @WebParam(name = "buginfo") String buginfo) {
+ return advisoryManager.getAdvisoryBuglist(subject, advId, buginfo);
+ }
+
+ //ADVISORYMANAGER: END ------------------------------------------
+
//ALERTMANAGER: BEGIN ------------------------------------------
public PageList<Alert> findAlertsByCriteria(Subject subject, AlertCriteria criteria) {
return alertManager.findAlertsByCriteria(subject, criteria);
@@ -443,7 +539,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
//DATAACCESSMANAGER: END ----------------------------------
- //DISCOVERYBOSS: BEGIN ------------------------------------
+ //DISCOVERYBOSS: BEGIN ------------------------------------
public void ignoreResources(Subject subject, Integer[] resourceIds) {
discoveryBoss.ignoreResources(subject, resourceIds);
}
@@ -636,7 +732,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public ResourceOperationSchedule scheduleResourceOperation(Subject subject, int resourceId, String operationName,
- long delay, long repeatInterval, int repeatCount, int timeout,//
+ long delay, long repeatInterval, int repeatCount, int timeout,//
@XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
Configuration parameters, String description) throws ScheduleException {
return operationManager.scheduleResourceOperation(subject, resourceId, operationName, delay, repeatInterval,
@@ -774,7 +870,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
//RESOURCEGROUPMANAGER: END ----------------------------------
- //RESOURCETYPEMANAGER: BEGIN ------------------------------------
+ //RESOURCETYPEMANAGER: BEGIN ------------------------------------
public PageList<ResourceType> findResourceTypesByCriteria(Subject subject, ResourceTypeCriteria criteria) {
return resourceTypeManager.findResourceTypesByCriteria(subject, criteria);
}
@@ -904,12 +1000,12 @@ public class WebservicesManagerBean implements WebservicesRemote {
//SUPPORTMANAGER: END ------------------------------------
- //SYSTEMMANAGER: BEGIN ------------------------------------
+ //SYSTEMMANAGER: BEGIN ------------------------------------
public ServerVersion getServerVersion(Subject subject) throws Exception {
return systemManager.getServerVersion(subject);
}
- //SYSTEMMANAGER: END ------------------------------------
+ //SYSTEMMANAGER: END ------------------------------------
private void checkParametersPassedIn(Subject subject, Criteria criteria) {
if (subject == null) {
commit 7c41a5d483fbf4a3018ed45f042ae3db15d7cedf
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 09:29:37 2010 -0500
Removed invalid tag from interface implementation
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 0d70c64..d6b8e12 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
@@ -1050,7 +1050,6 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
return syncCount;
}
- @Override
public void cancelSync(Subject subject, int repoId) throws ContentException {
ContentServerPluginContainer pc;
try {
commit 16663f2213a07d3e8044e6e6043c6c979631b3fe
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 08:49:33 2010 -0500
Exposed the advisory manager as a web service
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
index 8f72716..eb5937b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
@@ -9,6 +9,7 @@ import org.rhq.enterprise.server.alert.AlertManagerRemote;
import org.rhq.enterprise.server.auth.SubjectManagerRemote;
import org.rhq.enterprise.server.authz.RoleManagerRemote;
import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
+import org.rhq.enterprise.server.content.AdvisoryManagerRemote;
import org.rhq.enterprise.server.content.ContentManagerRemote;
import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
@@ -34,6 +35,7 @@ import org.rhq.enterprise.server.system.SystemManagerRemote;
@WebService(targetNamespace = ServerVersion.namespace)
@Remote
public interface WebservicesRemote extends //
+ AdvisoryManagerRemote, //
AlertManagerRemote, //
AlertDefinitionManagerRemote, //
AvailabilityManagerRemote,//
@@ -56,7 +58,7 @@ public interface WebservicesRemote extends //
ResourceManagerRemote,//
ResourceTypeManagerRemote,//
RoleManagerRemote,//
- SubjectManagerRemote,//
+ SubjectManagerRemote,//
SupportManagerRemote,//
SystemManagerRemote, //
RegistrationManagerRemote {
commit 1340ca2042e40df0788cc27e39d348ca28c44ba2
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 08:44:11 2010 -0500
Removed System.out.println call
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
index 6d7fc3a..44a7846 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/AdvisoryManagerBean.java
@@ -248,7 +248,6 @@ public class AdvisoryManagerBean implements AdvisoryManagerLocal, AdvisoryManage
/**
* find list of Packages Versions associated to an advisory
- * @param pkgId packageId
* @return list of PackageVersion objects
*/
@SuppressWarnings("unchecked")
@@ -350,7 +349,7 @@ public class AdvisoryManagerBean implements AdvisoryManagerLocal, AdvisoryManage
if (adv.getAdvisory() == null || adv.getAdvisory().trim().equals("")) {
throw new AdvisoryException("A valid Advisory tree is required");
}
- System.out.println("Advisory validating done " + adv);
+ log.debug("Advisory validating done " + adv);
}
}
commit 17674f20a8843b50a16e49d7981e72aca5aad02b
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 08:36:19 2010 -0500
Added test group
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
index 6b7d8dd..cbcea16 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
@@ -43,6 +43,7 @@ import org.rhq.enterprise.server.ws.utility.WsUtility;
*
* @author Jason Dobies
*/
+@Test(groups = "ws")
public class WsRegistrationManagerTest extends AssertJUnit implements TestPropertiesInterface {
private static final boolean TESTS_ENABLED = true;
commit bbd8b6b6974901b1d561ae14a8fe1437076eeaac
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 08:27:45 2010 -0500
Added comment
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
index 99087c9..6b7d8dd 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
@@ -85,6 +85,8 @@ public class WsRegistrationManagerTest extends AssertJUnit implements TestProper
Subject admin = subjectUtil.admin();
// Test
+
+ // Note: randomPlatform calls #registerPlatform, which is why there's no explicit test for that
Resource created = resourceUtil.randomPlatform();
service.importPlatform(admin, created);
commit 181cf1c2d647f209da61134c81b16b091631118b
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 21 08:20:43 2010 -0500
Steps towards automation of web service tests.
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
new file mode 100644
index 0000000..99087c9
--- /dev/null
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/WsRegistrationManagerTest.java
@@ -0,0 +1,108 @@
+/*
+* 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.ws.test;
+
+import java.lang.Exception;
+import java.net.URL;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.testng.AssertJUnit;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.rhq.enterprise.server.ws.*;
+import org.rhq.enterprise.server.ws.test.util.WsResourceUtility;
+import org.rhq.enterprise.server.ws.test.util.WsSubjectUtility;
+import org.rhq.enterprise.server.ws.utility.WsUtility;
+
+/**
+ * Web service tests for the registration manager services.
+ *
+ * @author Jason Dobies
+ */
+public class WsRegistrationManagerTest extends AssertJUnit implements TestPropertiesInterface {
+
+ private static final boolean TESTS_ENABLED = true;
+
+ private WebservicesRemote service;
+ private ObjectFactory objectFactory;
+
+ private Subject subject;
+
+ @BeforeClass
+ public void setup() throws Exception {
+
+ // Variables needed
+ URL gUrl = WsUtility.generateRemoteWebserviceURL(WebservicesManagerBeanService.class, host, port, useSSL);
+ QName gQName = WsUtility.generateRemoteWebserviceQName(WebservicesManagerBeanService.class);
+
+ // Establish outbound webservices connections
+ WebservicesManagerBeanService jws = new WebservicesManagerBeanService(gUrl, gQName);
+ service = jws.getWebservicesManagerBeanPort();
+
+ objectFactory = new ObjectFactory();
+
+ // Establish a new user in the system
+ WsSubjectUtility subjectUtil = new WsSubjectUtility(service);
+ subject = subjectUtil.createOrLoginUser("reg-manager-test", "reg-manager-test");
+ }
+
+ @AfterClass
+ public void teardown() throws Exception {
+ WsSubjectUtility subjectUtil = new WsSubjectUtility(service);
+ subjectUtil.deleteUser(subject.getId());
+ }
+
+ @Test(enabled = TESTS_ENABLED)
+ public void importPlatform() throws Exception {
+
+ // Setup
+ WsResourceUtility resourceUtil = new WsResourceUtility(service);
+ WsSubjectUtility subjectUtil = new WsSubjectUtility(service);
+ Subject admin = subjectUtil.admin();
+
+ // Test
+ Resource created = resourceUtil.randomPlatform();
+ service.importPlatform(admin, created);
+
+ // Verify and Cleanup
+ try {
+ ResourceCriteria criteria = objectFactory.createResourceCriteria();
+ criteria.setFilterId(created.getId());
+ List<Resource> resources = service.findResourcesByCriteria(admin, criteria);
+
+ assert resources.size() == 1 : "Incorrect number of resources returned. Found: " + resources.size();
+
+ Resource retrieved = resources.get(0);
+
+ assert retrieved.getName().equals(created.getName());
+ assert retrieved.getInventoryStatus().equals(InventoryStatus.COMMITTED);
+ } finally {
+ resourceUtil.deleteResource(created.getId());
+ }
+
+ }
+}
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java
index 7534deb..10cc5ad 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java
@@ -22,8 +22,97 @@
*/
package org.rhq.enterprise.server.ws.test.util;
+import java.util.List;
+
+import org.rhq.enterprise.server.ws.ObjectFactory;
+import org.rhq.enterprise.server.ws.Resource;
+import org.rhq.enterprise.server.ws.ResourceCriteria;
+import org.rhq.enterprise.server.ws.ResourceType;
+import org.rhq.enterprise.server.ws.ResourceTypeCriteria;
+import org.rhq.enterprise.server.ws.Subject;
+import org.rhq.enterprise.server.ws.WebservicesRemote;
+
/**
+ * Utility functions for working with resources via web service calls.
+ *
* @author Jason Dobies
*/
public class WsResourceUtility {
+
+ private WebservicesRemote service;
+ private WsSubjectUtility subjectUtil;
+ private ObjectFactory objectFactory;
+
+ /**
+ * Initializes a new instance to use the given connection to a running server.
+ *
+ * @param service must be in a state where remote calls can be made (i.e. the server is running)
+ */
+ public WsResourceUtility(WebservicesRemote service) {
+ this.service = service;
+ this.subjectUtil = new WsSubjectUtility(service);
+ this.objectFactory = new ObjectFactory();
+ }
+
+ /**
+ * Creates and returns a new platform in the system with a randomly generated name. The platform will be
+ * of type 'Linux'.
+ * <p/>
+ * Resources created in this way should be removed via {@link #deleteResource(int)} at the end of the test run.
+ *
+ * @return WS representation of the created platform
+ * @throws Exception if the platform cannot be created successfully
+ * @see #deleteResource(int)
+ */
+ public Resource randomPlatform() throws Exception {
+
+ long randomSeed = System.currentTimeMillis();
+ Subject admin = subjectUtil.admin();
+
+ // Use the default Linux platform
+ ResourceTypeCriteria typeCriteria = objectFactory.createResourceTypeCriteria();
+ typeCriteria.setFilterName("Linux");
+ List<ResourceType> types = service.findResourceTypesByCriteria(admin, typeCriteria);
+
+ if (types.size() != 1) {
+ throw new RuntimeException("Unexpected number of resource types returned for " +
+ "type [Linux]. Expected [1], Found [" + types.size() + "]");
+ }
+
+ // Information about the resource being created
+ String name = "Test Platform " + randomSeed;
+
+ Resource resource = objectFactory.createResource();
+ resource.setName(name);
+ resource.setResourceKey(name);
+ resource.setDescription("WsResourceUtility Created");
+ resource.setVersion("1.0");
+ resource.setResourceType(types.get(0));
+
+ // Register the platform
+ service.registerPlatform(admin, resource, -1);
+
+ // Retrieve for return
+ ResourceCriteria criteria = objectFactory.createResourceCriteria();
+ criteria.setFilterName(name);
+ List<Resource> resources = service.findResourcesByCriteria(admin, criteria);
+
+ if (resources.size() != 1) {
+ throw new RuntimeException("Unexpected number of resources returned for name [" +
+ name + "]. Expected [1], Found [" + resources.size() + "]");
+ }
+
+ return resources.get(0);
+ }
+
+ /**
+ * Deletes the indicated resource from the server.
+ *
+ * @param resourceId must refer to an existing resource in the server
+ * @throws Exception if the resource cannot be deleted
+ */
+ public void deleteResource(int resourceId) throws Exception {
+ Subject admin = subjectUtil.admin();
+ service.deleteResource(admin, resourceId);
+ }
}
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsSubjectUtility.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsSubjectUtility.java
new file mode 100644
index 0000000..fca9dad
--- /dev/null
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsSubjectUtility.java
@@ -0,0 +1,153 @@
+/*
+* 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.ws.test.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.rhq.enterprise.server.ws.ObjectFactory;
+import org.rhq.enterprise.server.ws.Role;
+import org.rhq.enterprise.server.ws.RoleCriteria;
+import org.rhq.enterprise.server.ws.Subject;
+import org.rhq.enterprise.server.ws.WebservicesRemote;
+
+/**
+ * @author Jason Dobies
+ */
+public class WsSubjectUtility {
+
+ private static final String ADMIN_USERNAME = "rhqadmin";
+ private static final String ADMIN_PASSWORD = "rhqadmin";
+
+ private WebservicesRemote service;
+ private ObjectFactory objectFactory;
+
+ /**
+ * Initializes a new instance to use the given connection to a running server.
+ *
+ * @param service must be in a state where remote calls can be made (i.e. the server is running)
+ */
+ public WsSubjectUtility(WebservicesRemote service) {
+ this.service = service;
+ this.objectFactory = new ObjectFactory();
+ }
+
+ /**
+ * Logs in and returns a WS representation of the default admin user.
+ *
+ * @return WS subject representing the default admin
+ * @throws Exception if there is an error in the remote call
+ * @see #ADMIN_USERNAME
+ * @see #ADMIN_PASSWORD
+ */
+ public Subject admin() throws Exception {
+ Subject admin = service.login(ADMIN_USERNAME, ADMIN_PASSWORD);
+ return admin;
+ }
+
+ /**
+ * Retrieves a WS subject object for the given credentials. If the user does not exist,
+ * it will be created first, assigning it to all roles in the system. The subject will be logged
+ * in as part of this call.
+ * <p/>
+ * Calls to this should be accompanied by a call to {#deleteUser(String} to clean up.
+ *
+ * @param username may not be <code>null</code>
+ * @param password may not be <code>null</code>
+ * @return WS subject object that can be used for remote calls that require a subject
+ * @throws Exception if anything goes wrong, most likely in the remote calls
+ * @see #deleteUser(int)
+ */
+ public Subject createOrLoginUser(String username, String password) throws Exception {
+
+ // If the user already exists, return that
+ try {
+ Subject user = service.login(username, password);
+ if (user != null) {
+ return user;
+ }
+ }
+ catch (Throwable e) {
+ // Will occur if the user does not exist, so this should occur often
+ }
+
+ // Otherwise, create the user
+ Subject newUser = new Subject();
+ newUser.setName(username);
+ newUser.setFirstName("WsSubjectUtility Created");
+ newUser.setLastName("WsSubjectUtility Created");
+ newUser.setEmailAddress(username + "@wssubjectutility");
+ newUser.setDepartment("WsSubjectUtility Created");
+
+ Subject admin = admin();
+ Subject created = service.createSubject(admin, newUser);
+
+ service.createPrincipal(admin, username, password);
+
+ // Assign to all roles
+ RoleCriteria criteria = objectFactory.createRoleCriteria();
+ List<Role> allRoles = service.findRolesByCriteria(admin, criteria);
+ List<Integer> roleIds = rolesToIds(allRoles);
+
+ service.addRolesToSubject(admin, created.getId(), roleIds);
+
+ return created;
+ }
+
+ /**
+ * Deletes an existing user from the system.
+ *
+ * @param subjectId must represent a valid subject in the system
+ * @throws Exception if there is an error in the remoting
+ * @see #deleteUsers(List)
+ */
+ public void deleteUser(int subjectId) throws Exception {
+ List<Integer> deleteUs = new ArrayList<Integer>(1);
+ deleteUs.add(subjectId);
+ service.deleteSubjects(admin(), deleteUs);
+ }
+
+ /**
+ * Deletes a number of users from the system.
+ *
+ * @param deleteUs IDs of one or more users in the system to delete
+ * @throws Exception if there is an error in the remoting
+ */
+ public void deleteUsers(List<Integer> deleteUs) throws Exception {
+ service.deleteSubjects(admin(), deleteUs);
+ }
+
+ /**
+ * Simple transformer from list of {@link Role} objects to a list of their respective IDs.
+ *
+ * @param roles cannot be <code>null</code>
+ * @return new list of the same size as <code>roles</code>
+ */
+ private List<Integer> rolesToIds(List<Role> roles) {
+ List<Integer> roleIds = new ArrayList<Integer>(roles.size());
+ for (Role role : roles) {
+ roleIds.add(role.getId());
+ }
+ return roleIds;
+ }
+}
commit 86ee4dd97af34b90c48950bb9674c38ee1564d16
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Wed Jan 20 22:17:50 2010 -0800
1370 - cancel is now functional. feel free to test
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java
index 15e6533..d2de807 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java
@@ -23,5 +23,5 @@
package org.rhq.core.domain.content;
public enum ContentSyncStatus {
- INPROGRESS, PACKAGEMETADATA, PACKAGEBITS, DISTROMETADATA, DISTROBITS, ADVISORYMETADATA, SUCCESS, FAILURE, NONE, CANCELLED
+ INPROGRESS, PACKAGEMETADATA, PACKAGEBITS, DISTROMETADATA, DISTROBITS, ADVISORYMETADATA, SUCCESS, FAILURE, NONE, CANCELLED, CANCELLING
}
\ No newline at end of file
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java b/modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java
index 41217f3..1e11c2a 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java
@@ -109,7 +109,7 @@ public class ProgressWatcher {
* Reset the ProgressWatcher to zero.
*/
public void resetToZero() {
- start();
stop();
+ start();
}
}
diff --git a/modules/core/util/src/test/java/org/rhq/core/util/progresswatch/ProgressWatcherTest.java b/modules/core/util/src/test/java/org/rhq/core/util/progresswatch/ProgressWatcherTest.java
index ba1f6f8..8bf4336 100644
--- a/modules/core/util/src/test/java/org/rhq/core/util/progresswatch/ProgressWatcherTest.java
+++ b/modules/core/util/src/test/java/org/rhq/core/util/progresswatch/ProgressWatcherTest.java
@@ -51,4 +51,14 @@ public class ProgressWatcherTest extends TestCase {
assertTrue(pw.getPercentComplete() == 98);
}
+ public void testResetToZero() {
+ ProgressWatcher pw = new ProgressWatcher();
+ pw.start();
+ pw.setTotalWork(102);
+ pw.finishWork(100);
+ pw.resetToZero();
+ assertTrue(pw.getPercentComplete() == 0);
+
+ }
+
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
index 40d921b..77ab7f1 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
@@ -95,11 +95,11 @@
<c:when
test="#{RepoDetailsUIBean.percentComplete != '100'}">
<a4j:region>
- <a4j:poll id="poll" interval="1000"
+ <a4j:poll id="statusPoll" interval="1000"
reRender="syncStatus" />
<h:outputText id="syncStatus"
value="#{RepoDetailsUIBean.syncStatus}" />
- </a4j:region>
+ </a4j:region>
</c:when>
<c:otherwise>
<h:outputText id="syncStatus"
@@ -112,7 +112,7 @@
<td align="left"><rich:progressBar
value="#{RepoDetailsUIBean.percentComplete}"
label="#{RepoDetailsUIBean.percentComplete} %"
- interval="1000" minValue="0" maxValue="99">
+ interval="999" minValue="0" maxValue="99">
<f:facet name="complete">
<h:outputText value="Synchronizing Complete" />
</f:facet>
@@ -147,8 +147,14 @@
operation="hide" event="onclick" />
</h:panelGroup>
</f:facet>
- <PRE><h:outputText
+ <a4j:region>
+ <a4j:poll id="resultsPoll" interval="2000"
+ reRender="syncResults" />
+ <PRE><h:outputText id="syncResults"
value="#{RepoDetailsUIBean.syncResults.results}" /></PRE>
+ </a4j:region>
+
+
</rich:modalPanel></td>
</tr>
</table>
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 393e694..0d70c64 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
@@ -108,6 +108,9 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
@EJB
private SubjectManagerLocal subjectManager;
+ @EJB
+ private RepoManagerLocal repoManager;
+
@RequiredPermission(Permission.MANAGE_INVENTORY)
public void deleteRepo(Subject subject, int repoId) {
log.debug("User [" + subject + "] is deleting repo [" + repoId + "]");
@@ -992,6 +995,7 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
}
}
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public RepoSyncResults getMostRecentSyncResults(Subject subject, int repoId) {
Repo found = this.getRepo(subject, repoId);
Set<ContentSyncStatus> stati = new HashSet<ContentSyncStatus>();
@@ -1057,10 +1061,14 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
Repo repo = this.getRepo(subject, repoId);
try {
- pc.cancelRepoSync(repo);
+ pc.cancelRepoSync(subject, repo);
+
} catch (SchedulerException e) {
throw new ContentException(e);
}
+ RepoSyncResults results = this.getMostRecentSyncResults(subject, repo.getId());
+ results.setStatus(ContentSyncStatus.CANCELLING);
+ repoManager.mergeRepoSyncResults(results);
}
@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 d8bc4fc..4a40b72 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
@@ -34,7 +34,6 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.exception.GenericJDBCException;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.content.ContentSource;
@@ -263,7 +262,8 @@ public class ContentProviderManager {
* if the data required to perform the sync is missing or
* invalid
*/
- public boolean synchronizeRepo(int repoId) throws InterruptedException {
+ public boolean synchronizeRepo(int repoId) {
+ log.debug("synchronizeRepo() :: start");
RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
@@ -412,22 +412,19 @@ public class ContentProviderManager {
tracker.setResults(progress.toString());
tracker = updateSyncStatus(tracker, ContentSyncStatus.SUCCESS);
log.debug("synchronizeRepo :: Success");
- } catch (GenericJDBCException jdbc) {
- log.debug("Caught GenericJDBCException");
- progress.append("\n ** Cancelled syncing **");
- tracker.getProgressWatcher().resetToZero();
- tracker = updatePercentComplete(tracker, repoManager);
- tracker.setResults(progress.toString());
- tracker = updateSyncStatus(tracker, ContentSyncStatus.CANCELLED);
- ie = jdbc;
- } catch (InterruptedException ieinner) {
+ } catch (Exception e) {
+ RepoSyncResults recentResults = repoManager.getMostRecentSyncResults(overlord, repo.getId());
log.debug("Caught InterruptedException");
progress.append("\n ** Cancelled syncing **");
tracker.setResults(progress.toString());
tracker.getProgressWatcher().resetToZero();
tracker = updatePercentComplete(tracker, repoManager);
- tracker = updateSyncStatus(tracker, ContentSyncStatus.CANCELLED);
- ie = ieinner;
+ try {
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.CANCELLED, false);
+ } catch (InterruptedException e1) {
+ throw new RuntimeException("Unexpected InterruptedException", e1);
+ }
+ ie = e;
}
if (tracker.getRepoSyncResults() != null) {
@@ -439,8 +436,7 @@ public class ContentProviderManager {
log.debug("synchronizeRepo :: merging results.");
}
if (ie != null) {
- log.debug("rethrowing the InterruptedException");
- throw new InterruptedException(ie.toString());
+ return false;
} else {
return true;
}
@@ -482,8 +478,20 @@ public class ContentProviderManager {
}
- private SyncTracker updateSyncStatus(SyncTracker tracker, ContentSyncStatus status) {
+ private SyncTracker updateSyncStatus(SyncTracker tracker, ContentSyncStatus status) throws InterruptedException {
+ return updateSyncStatus(tracker, status, true);
+ }
+
+ private SyncTracker updateSyncStatus(SyncTracker tracker, ContentSyncStatus status, boolean checkCancelling)
+ throws InterruptedException {
RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
+ SubjectManagerLocal subjMgr = LookupUtil.getSubjectManager();
+ Subject overlord = subjMgr.getOverlord();
+ int repoId = tracker.getRepoId();
+ RepoSyncResults cancelCheck = repoManager.getMostRecentSyncResults(overlord, repoId);
+ if (cancelCheck.getStatus() == ContentSyncStatus.CANCELLING) {
+ throw new InterruptedException();
+ }
RepoSyncResults results = tracker.getRepoSyncResults();
results.setStatus(status);
results = repoManager.mergeRepoSyncResults(results);
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 3418ae7..9c1f89d 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
@@ -19,16 +19,19 @@
package org.rhq.enterprise.server.plugin.pc.content;
import java.util.Date;
-import java.util.Set;
import org.quartz.JobDetail;
-import org.quartz.JobExecutionContext;
import org.quartz.SchedulerException;
import org.quartz.SimpleTrigger;
+import org.quartz.Trigger;
+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.Repo;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.server.content.ContentSourceManagerLocal;
import org.rhq.enterprise.server.plugin.pc.AbstractTypeServerPluginContainer;
import org.rhq.enterprise.server.plugin.pc.MasterServerPluginContainer;
import org.rhq.enterprise.server.plugin.pc.ServerPluginManager;
@@ -48,6 +51,7 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
private static final String CONTENT_SRC_SYNC_JOB_GROUP_NAME = "syncContentSource";
private static final String REPO_SYNC_JOB_GROUP_NAME = "syncRepo";
+ private static final String REPO_SYNC_JOB_IMMEDIATE_GROUP_NAME = "syncRepoImmediate";
private ContentProviderManager adapterManager;
@@ -138,24 +142,28 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
* @throws SchedulerException if the job cannot be scheduled
*/
public void syncRepoNow(Repo repo) throws SchedulerException {
- JobDetail job = new JobDetail(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME, RepoSyncJob.class,
- false, false, false);
+ String jobName = RepoSyncJob.createJobName(repo);
+ JobDetail job = new JobDetail(jobName, REPO_SYNC_JOB_IMMEDIATE_GROUP_NAME, RepoSyncJob.class, false, false,
+ false);
RepoSyncJob.createJobDataMap(job, repo);
-
- SimpleTrigger trigger = new SimpleTrigger(job.getName(), job.getGroup());
- trigger.setVolatility(false);
-
+ Date nextExecution;
SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
- Date next = scheduler.scheduleJob(job, trigger);
-
+ Trigger trigger = scheduler.getTrigger(jobName, REPO_SYNC_JOB_IMMEDIATE_GROUP_NAME);
+ if (trigger == null) {
+ trigger = new SimpleTrigger(jobName, job.getGroup());
+ trigger.setVolatility(false);
+ nextExecution = scheduler.scheduleJob(job, trigger);
+ } else {
+ nextExecution = scheduler.rescheduleJob(jobName, REPO_SYNC_JOB_IMMEDIATE_GROUP_NAME, trigger);
+ }
getLog().info(
- "Scheduled repo sync job [" + job.getName() + ':' + job.getGroup() + "] to fire now at [" + next
+ "Scheduled repo sync job [" + job.getName() + ':' + job.getGroup() + "] to fire now at [" + nextExecution
+ "] for [" + repo + "]");
}
- public void cancelRepoSync(Repo repo) throws SchedulerException {
- JobDetail jobDetail = new JobDetail(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME,
+ public void cancelRepoSync(Subject subject, Repo repo) throws SchedulerException {
+ JobDetail jobDetail = new JobDetail(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_IMMEDIATE_GROUP_NAME,
RepoSyncJob.class, false, false, false);
RepoSyncJob.createJobDataMap(jobDetail, repo);
@@ -165,7 +173,7 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
- boolean cancelled = scheduler.interrupt(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME);
+ boolean cancelled = scheduler.interrupt(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_IMMEDIATE_GROUP_NAME);
getLog().info("cancelled repo sync job [" + jobDetail.getName() + ':' + jobDetail.getGroup() + "] ");
}
@@ -230,7 +238,9 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
try {
getLog().debug("scheduleSyncJobs :: Scheduling CP job: " + contentSource.getName());
scheduleProviderSyncJob(contentSource);
- Set<Repo> repos = contentSource.getRepos();
+ ContentSourceManagerLocal contentSourceManager = LookupUtil.getContentSourceManager();
+ PageList<Repo> repos = contentSourceManager.getAssociatedRepos(LookupUtil.getSubjectManager()
+ .getOverlord(), contentSource.getId(), PageControl.getUnlimitedInstance());
if (repos != null) {
for (Repo repo : repos) {
getLog().debug("scheduleSyncJobs :: Scheduling REPO job: " + repo.getName());
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncTracker.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncTracker.java
index 813f717..67a5440 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncTracker.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncTracker.java
@@ -30,6 +30,7 @@ import org.rhq.core.util.progresswatch.ProgressWatcher;
*/
public class SyncTracker {
+ private int repoId;
private RepoSyncResults repoSyncResults;
private ProgressWatcher progressWatcher;
private int packageSyncCount;
@@ -40,6 +41,7 @@ public class SyncTracker {
*/
public SyncTracker(RepoSyncResults repoSyncResultsIn, ProgressWatcher progressWatcherIn) {
super();
+ this.repoId = repoSyncResultsIn.getRepo().getId();
this.repoSyncResults = repoSyncResultsIn;
this.progressWatcher = progressWatcherIn;
this.progressWatcher.start();
@@ -125,4 +127,12 @@ public class SyncTracker {
this.packageSyncCount = packageSyncCount;
}
+ /**
+ * RepoId we are tracking
+ * @return int repoId
+ */
+ public int getRepoId() {
+
+ return this.repoId;
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ThreadUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ThreadUtil.java
index bd04b65..80bdc05 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ThreadUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ThreadUtil.java
@@ -8,14 +8,10 @@ package org.rhq.enterprise.server.plugin.pc.content;
*
*/
public class ThreadUtil {
-
- public static void checkInterrupted() throws InterruptedException {
- Thread cthread = Thread.currentThread();
- System.out.println("ThreadInterrupt : [" + cthread.getName() + "]");
- if (Thread.interrupted()) {
- throw new InterruptedException();
- }
-
- }
+ public static void checkInterrupted() throws InterruptedException {
+ if (Thread.interrupted()) {
+ throw new InterruptedException();
+ }
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java
index dbc0987..68df9c3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java
@@ -131,7 +131,8 @@ public class AdvisorySourceSynchronizer {
return tracker;
}
- private void translateDomainToDto(List<Advisory> advs, List<AdvisoryDetails> advDetails) {
+ private void translateDomainToDto(List<Advisory> advs, List<AdvisoryDetails> advDetails)
+ throws InterruptedException {
AdvisoryManagerLocal advManager = LookupUtil.getAdvisoryManagerLocal();
for (Advisory d : advs) {
@@ -167,6 +168,7 @@ public class AdvisorySourceSynchronizer {
}
}
advDetails.add(detail);
+ ThreadUtil.checkInterrupted();
}
}
}
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 9d1ba80..5e4e995 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
@@ -69,6 +69,8 @@ public class RepoSyncJob implements StatefulJob, InterruptableJob {
private Thread executionThread;
+ private static ThreadLocal<Boolean> interruptMonitor = new ThreadLocal();
+
/**
* {@inheritDoc}
*/
@@ -226,4 +228,5 @@ public class RepoSyncJob implements StatefulJob, InterruptableJob {
executionThread.interrupt();
}
}
+
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java
index fd5c521..97e9343 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java
@@ -167,7 +167,7 @@ public class RepoSyncingTest extends AbstractEJB3Test {
ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer();
pc.syncRepoNow(repo);
- for (int i = 0; i < 100; i++) {
+ for (int i = 0; i < 10; i++) {
RepoSyncResults res = getSyncResults(repo.getId());
if (res != null) {
System.out.println("status: [" + res.getStatus() + "] CTRL+C to exit");
@@ -179,7 +179,7 @@ public class RepoSyncingTest extends AbstractEJB3Test {
}
Thread.sleep(1000);
if (i == 5) {
- pc.cancelRepoSync(repo);
+ pc.cancelRepoSync(LookupUtil.getSubjectManager().getOverlord(), repo);
}
}
diff --git a/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java b/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
index ffac623..2c2f204 100644
--- a/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
+++ b/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
@@ -119,7 +119,7 @@ public class DiskSource implements ContentProvider, PackageSource, RepoSource {
}
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws SyncException {
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException, InterruptedException {
if (!isPackageSource) {
return;
diff --git a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
index c9d5880..90a0d30 100644
--- a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
+++ b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
@@ -115,7 +115,7 @@ public class JBossSoftwareContentSourceAdapter implements ContentProvider, Packa
}
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws SyncException {
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException, InterruptedException {
if (!active)
return;
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNHelper.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNHelper.java
index 930182d..ac02551 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNHelper.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNHelper.java
@@ -40,6 +40,7 @@ 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.DistributionDetails;
import org.rhq.enterprise.server.plugin.pc.content.DistributionFileDetails;
+import org.rhq.enterprise.server.plugin.pc.content.ThreadUtil;
import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnChannelFamilyType;
import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnChannelType;
import org.rhq.enterprise.server.plugins.rhnhosted.xml.RhnErratumBugType;
@@ -115,10 +116,11 @@ public class RHNHelper {
}
public List<AdvisoryDetails> getAdvisoryMetadata(List<String> advisoryList, String repoName)
- throws XmlRpcException, IOException {
+ throws XmlRpcException, IOException, InterruptedException {
List<AdvisoryDetails> erratadetails = new ArrayList<AdvisoryDetails>();
List<RhnErratumType> errata = rhndata.getErrataMetadata(this.systemid, advisoryList);
for (RhnErratumType erratum : errata) {
+ ThreadUtil.checkInterrupted();
log.debug("Forming AdvisoryDetails(" + erratum.getAdvisory());
AdvisoryDetails details = new AdvisoryDetails(erratum.getAdvisory(), erratum.getRhnErratumAdvisoryType(),
erratum.getRhnErratumSynopsis());
@@ -158,27 +160,27 @@ public class RHNHelper {
String pkgs = erratum.getPackages();
String[] pkgIds = pkgs.split(" ");
- try {
- List<AdvisoryPackageDetails> apkgdetails = new ArrayList<AdvisoryPackageDetails>();
- List<RhnPackageType> pkgdetails = rhndata.getPackageMetadata(this.systemid, Arrays.asList(pkgIds));
- for (RhnPackageType pkgd : pkgdetails) {
- if (log.isDebugEnabled()) {
- log.debug("RHNHelper::getAdvisoryMetaData<Advisory=" + erratum.getAdvisory() + "> Package<"
- + pkgd + ">");
- }
- String name = pkgd.getName();
- String version = pkgd.getVersion();
- String arch = pkgd.getPackageArch();
- String release = pkgd.getRelease();
- String rpmname = constructRpmDisplayName(name, version, release, arch);
- AdvisoryPackageDetails apkgd = new AdvisoryPackageDetails(name, version, arch, rpmname);
- apkgdetails.add(apkgd);
+ //try {
+ List<AdvisoryPackageDetails> apkgdetails = new ArrayList<AdvisoryPackageDetails>();
+ List<RhnPackageType> pkgdetails = rhndata.getPackageMetadata(this.systemid, Arrays.asList(pkgIds));
+ for (RhnPackageType pkgd : pkgdetails) {
+ if (log.isDebugEnabled()) {
+ log.debug("RHNHelper::getAdvisoryMetaData<Advisory=" + erratum.getAdvisory() + "> Package<" + pkgd
+ + ">");
}
- details.addPkgs(apkgdetails);
-
- } catch (Exception e) {
- e.printStackTrace();
+ String name = pkgd.getName();
+ String version = pkgd.getVersion();
+ String arch = pkgd.getPackageArch();
+ String release = pkgd.getRelease();
+ String rpmname = constructRpmDisplayName(name, version, release, arch);
+ AdvisoryPackageDetails apkgd = new AdvisoryPackageDetails(name, version, arch, rpmname);
+ apkgdetails.add(apkgd);
}
+ details.addPkgs(apkgdetails);
+
+ //} catch (Exception e) {
+ // e.printStackTrace();
+ // }
erratadetails.add(details);
}
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
index 04fdbba..bfad1a1 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
@@ -33,6 +33,7 @@ import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xmlrpc.XmlRpcException;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.enterprise.server.plugin.pc.content.AdvisoryDetails;
@@ -227,7 +228,7 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
* @inheritDoc
*/
public void synchronizeAdvisory(String repoName, AdvisorySyncReport report,
- Collection<AdvisoryDetails> existingAdvisory) throws SyncException {
+ Collection<AdvisoryDetails> existingAdvisory) throws SyncException, InterruptedException {
List<String> existingLabels = new ArrayList<String>();
for (AdvisoryDetails ad : existingAdvisory) {
@@ -249,9 +250,12 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
+ "with cves" + adv.getCVEs() + "wiuth packages" + adv.getPkgs());
report.addAdvisory(adv);
}
+ ThreadUtil.checkInterrupted();
}
- } catch (Exception e) {
- throw new SyncException("Error syncing advisory meta", e);
+ } catch (IOException ioe) {
+ throw new SyncException("IOException syncing advisory meta", ioe);
+ } catch (XmlRpcException x) {
+ throw new SyncException("XmlRpcException syncing advisory meta", x);
}
for (String adv : deletedAdvs) {
diff --git a/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java b/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
index 36d000c..40c6656 100644
--- a/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
+++ b/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
@@ -132,7 +132,7 @@ public class RepoProvider implements ContentProvider, PackageSource {
* @throws Exception On all errors.
*/
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws SyncException {
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException, InterruptedException {
Summary summary = new Summary(reader);
log.info("synchronizing with repo: " + reader + " started");
try {
commit 58dfac1b97a9e089bfc21168554522aee822e6a9
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 20 17:40:57 2010 -0500
Fixed javadoc
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java
new file mode 100644
index 0000000..7534deb
--- /dev/null
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/test/util/WsResourceUtility.java
@@ -0,0 +1,29 @@
+/*
+* 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.ws.test.util;
+
+/**
+ * @author Jason Dobies
+ */
+public class WsResourceUtility {
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
index 2ebc9f2..49b6334 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
@@ -64,8 +64,8 @@ public class RegistrationManagerBean implements RegistrationManagerLocal, Regist
* Registers the platform as a resource on RHQ server
* @param user secure id user
* @param platform to be registered
- * @param parenId if any.
- *
+ * @param parentId if any.
+ *
*/
public void registerPlatform(Subject user, Resource platform, int parentId) {
try {
@@ -92,8 +92,8 @@ public class RegistrationManagerBean implements RegistrationManagerLocal, Regist
/**
* Imports the registered resource into inventory and makes it a managed resource
* @param user secure id user
- * @param platform to be imported
- *
+ * @param resource to be imported
+ *
*/
public void importPlatform(Subject user, Resource resource) {
resource.setInventoryStatus(InventoryStatus.COMMITTED);
@@ -103,7 +103,7 @@ public class RegistrationManagerBean implements RegistrationManagerLocal, Regist
/**
* subscribe the requested platform to a compatible base repo based on release
* and arch information. This method does a lookup in ReleaseRepoMapping
- * to get the compatible base channel and tried to tie the platform to
+ * to get the compatible base channel and tried to tie the platform to
* the repo.
* @param user secure id user
* @param platform to be imported
commit e80ef0f1f183af1f549b865054465980bde74372
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 20 16:07:10 2010 -0500
Disabled test that requires a lot of setup (and even then I can't get it working). Will revisit once we get a better way to set the initial state of the server.
diff --git a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/WsRepoManagerTest.java b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/WsRepoManagerTest.java
index 3cff064..2267411 100644
--- a/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/WsRepoManagerTest.java
+++ b/modules/enterprise/remoting/webservices/src/test/java/org/rhq/enterprise/server/ws/WsRepoManagerTest.java
@@ -23,23 +23,26 @@ import org.rhq.enterprise.server.ws.utility.WsUtility;
/**
* These tests can not be executed in our standard unit test fashion as they
* require a running RHQ Server with our web services deployed.
- *
- * This is still in development and has the current restrictions: - add
- * [dev_root
- * ]/modules/enterprise/remoting/webservices/target/rhq-remoting-webservices
- * -{version}.jar to TOP of eclipse classpath to run from your IDE(actually need
- * to use classpath setup from bin/jbossas/bin/wsrunclient.sh to take advantage
- * of type substitution correctly) - Server running on localhost. - ws-test user
- * defined in database with full permissions - Non RHQ Server JBossAS in
- * inventory. - The -Ptest-ws profile specified when running mvn test from
- * webservices dir - Perftest plugin installed and agent started as described in
- * modules/enterprise/remoting/scripts/README.txt
- *
+ *
+ * This is still in development and has the current restrictions:
+ * <ul>
+ * <li>add [dev_root]/modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-{version}.jar to TOP of
+ * eclipse classpath to run from your IDE(actually need to use classpath setup from bin/jbossas/bin/wsrunclient.sh to
+ * take advantage of type substitution correctly)</li>
+ * <li>Server running on localhost</li>
+ * <li>ws-test user defined in database with full permissions</li>
+ * <li>Non RHQ Server JBossAS in inventory</li>
+ * <li>The -Ptest-ws profile specified when running mvn test from webservices dir</li>
+ * <li>Perftest plugin installed and agent started as described in modules/enterprise/remoting/scripts/README.txt</li>
+ * </ul>
+ *
* @author Jay Shaughnessy, Simeon Pinder
*/
@Test(groups = "ws")
public class WsRepoManagerTest extends AssertJUnit implements TestPropertiesInterface {
+ private static final boolean TESTS_ENABLED = true;
+
// Test variables
private static ObjectFactory WS_OBJECT_FACTORY;
private static WebservicesRemote WEBSERVICE_REMOTE;
@@ -222,7 +225,7 @@ public class WsRepoManagerTest extends AssertJUnit implements TestPropertiesInte
}
}
- @Test(enabled = TESTS_ENABLED)
+ @Test(enabled = false)
void testDeploy() throws InterruptedException, IOException, ResourceTypeNotFoundException_Exception,
RepoException_Exception {
@@ -232,8 +235,8 @@ public class WsRepoManagerTest extends AssertJUnit implements TestPropertiesInte
ResourceCriteria criteria = new ResourceCriteria();
criteria.strict = true;
// criteria.setFilterName("Tomcat (");
- criteria.setFilterName("Tomcat VHost (localhost)");
- // criteria.setFilterName("Tomcat");
+// criteria.setFilterName("Tomcat VHost (localhost)");
+ criteria.setFilterName("Tomcat (8080)");
criteria.setFilterCurrentAvailability(AvailabilityType.UP);
// criteria.setFilterCurrentAvailability(AvailabilityType.DOWN);
List<Resource> tomcatServers = WEBSERVICE_REMOTE.findResourcesByCriteria(subject, criteria);
commit b548d9dd026e97c99085d724e1e9cd45708618d5
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 20 13:13:09 2010 -0500
Updated for web service serialization. Fixed bug in setting tag.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
index 1180f6e..9f810bc 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
@@ -150,21 +150,27 @@ public class Repo implements Serializable, Taggable {
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY)
private Set<ResourceRepo> resourceRepos;
+ @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Set<RepoContentSource> repoContentSources;
+ @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY)
private Set<RepoPackageVersion> repoPackageVersions;
+ @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Set<RepoRepoGroup> repoRepoGroups;
+ @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY)
private Set<RepoRepoRelationship> repoRepoRelationships;
+ @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY)
private Set<RepoTag> repoTags;
+ @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@OrderBy("startTime DESC")
// latest appears first, oldest last
@@ -756,7 +762,7 @@ public class Repo implements Serializable, Taggable {
}
public void setRepoTags(Set<RepoTag> tags) {
- this.repoTags = repoTags;
+ this.repoTags = tags;
}
public boolean hasTag(Tag tag) {
commit b295f8a645b6d2fe2a62b8aa9ff4b42095d0ee70
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 20 09:13:40 2010 -0500
Fixed bug in filtering.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
index 52f4985..a695476 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
@@ -100,6 +100,7 @@ public class ResourceCriteria extends Criteria {
filterOverrides.put("parentResourceId", "parentResource.id = ?");
filterOverrides.put("parentResourceName", "parentResource.name like ?");
filterOverrides.put("agentName", "agent.name like ?");
+ filterOverrides.put("currentAvailability", "currentAvailability.availabilityType = ?");
sortOverrides.put("resourceTypeName", "resourceType.name");
sortOverrides.put("resourceCategory", "resourceType.category");
commit 491db1bd2bdbe9a11d1840cc73609c5a8651d5db
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Tue Jan 19 21:53:53 2010 -0800
1376,1374,1377 - big amount of work to support cancelling syncs
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java
index aa92ee3..15e6533 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSyncStatus.java
@@ -23,5 +23,5 @@
package org.rhq.core.domain.content;
public enum ContentSyncStatus {
- INPROGRESS, PACKAGEMETADATA, PACKAGEBITS, DISTROMETADATA, DISTROBITS, ADVISORYMETADATA, SUCCESS, FAILURE, NONE
+ INPROGRESS, PACKAGEMETADATA, PACKAGEBITS, DISTROMETADATA, DISTROBITS, ADVISORYMETADATA, SUCCESS, FAILURE, NONE, CANCELLED
}
\ No newline at end of file
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java b/modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java
index b019f0b..41217f3 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/progresswatch/ProgressWatcher.java
@@ -104,4 +104,12 @@ public class ProgressWatcher {
public void stop() {
this.started = false;
}
+
+ /**
+ * Reset the ProgressWatcher to zero.
+ */
+ public void resetToZero() {
+ start();
+ stop();
+ }
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
index c521323..a710a22 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/content/RepoDetailsUIBean.java
@@ -104,6 +104,21 @@ public class RepoDetailsUIBean {
return "success";
}
+ public String cancelSync() {
+ Subject subject = EnterpriseFacesContextUtility.getSubject();
+ RepoManagerLocal manager = LookupUtil.getRepoManagerLocal();
+ Integer repoId = FacesContextUtility.getRequiredRequestParameter("id", Integer.class);
+ try {
+ manager.cancelSync(subject, repoId);
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "The synchronization has been cancelled.");
+ } catch (Exception ce) {
+ FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Error: " + ce.getMessage());
+ return "success"; // stay in edit mode on failure
+ }
+
+ return "success";
+ }
+
public String cancel() {
return "success";
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
index c80471e..40d921b 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
@@ -154,7 +154,7 @@
</table>
</rich:panel>
- <h:panelGrid columns="2" styleClass="buttons-table"
+ <h:panelGrid columns="3" styleClass="buttons-table"
columnClasses="button-cell">
<h:commandButton rendered="${mode ne 'edit'}" value="EDIT"
action="#{RepoDetailsUIBean.edit}" alt="Edit"
@@ -162,6 +162,9 @@
<h:commandButton rendered="${mode ne 'edit'}"
value="SYNCHRONIZE" action="#{RepoDetailsUIBean.sync}"
alt="Synchronize" styleClass="buttonmed" id="syncButton" />
+ <h:commandButton rendered="${mode ne 'edit'}"
+ value="CANCEL SYNCH" action="#{RepoDetailsUIBean.cancelSync}"
+ alt="Cancel Synch" styleClass="buttonmed" id="cancelSyncButton" />
<h:commandButton rendered="${mode eq 'edit'}" value="SAVE"
action="#{RepoDetailsUIBean.save}" alt="Save"
styleClass="buttonmed" id="saveButton" />
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 1f0f62b..393e694 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
@@ -1025,8 +1025,13 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
}
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
- public int internalSynchronizeRepos(Subject subject, Integer[] repoIds) throws Exception {
- ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer();
+ public int internalSynchronizeRepos(Subject subject, Integer[] repoIds) throws InterruptedException {
+ ContentServerPluginContainer pc;
+ try {
+ pc = ContentManagerHelper.getPluginContainer();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
ContentProviderManager providerManager = pc.getAdapterManager();
int syncCount = 0;
@@ -1041,6 +1046,23 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
return syncCount;
}
+ @Override
+ public void cancelSync(Subject subject, int repoId) throws ContentException {
+ ContentServerPluginContainer pc;
+ try {
+ pc = ContentManagerHelper.getPluginContainer();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ Repo repo = this.getRepo(subject, repoId);
+ try {
+ pc.cancelRepoSync(repo);
+ } catch (SchedulerException e) {
+ throw new ContentException(e);
+ }
+ }
+
@SuppressWarnings("unchecked")
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public RepoSyncResults persistRepoSyncResults(RepoSyncResults results) {
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 d6d061d..b2cf635 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
@@ -330,7 +330,15 @@ public interface RepoManagerLocal {
* @return number of repos successfully syncced
* @throws Exception if any errors occur
*/
- int internalSynchronizeRepos(Subject subject, Integer[] repoIds) throws Exception;
+ int internalSynchronizeRepos(Subject subject, Integer[] repoIds) throws InterruptedException;
+
+ /**
+ * Cancel any running sync job for the given repo
+ *
+ * @param repoId you want to cancel the sync for
+ * @return boolean if it was cancelled or not
+ */
+ void cancelSync(Subject subject, int repoId) throws ContentException;
/**
* Creates a new sync results object. Note that this will return <code>null</code> if the given results object has a
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/AdvisorySource.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/AdvisorySource.java
index e82085e..d3b05e3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/AdvisorySource.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/AdvisorySource.java
@@ -42,6 +42,6 @@ public interface AdvisorySource {
* source cannot be connected to.
*/
void synchronizeAdvisory(String repoName, AdvisorySyncReport report, Collection<AdvisoryDetails> existingAdvisory)
- throws Exception;
+ throws SyncException, InterruptedException;
}
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 0e678d7..d8bc4fc 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
@@ -34,6 +34,7 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hibernate.exception.GenericJDBCException;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.content.ContentSource;
@@ -57,9 +58,9 @@ import org.rhq.enterprise.server.plugin.pc.content.sync.RepoSourceSynchronizer;
import org.rhq.enterprise.server.util.LookupUtil;
/**
- * Responsible for managing {@link ContentProvider} implementations. These implementations
- * come from the content plugins themselves.
- *
+ * Responsible for managing {@link ContentProvider} implementations. These
+ * implementations come from the content plugins themselves.
+ *
* @author John Mazzitelli
* @author Jason Dobies
*/
@@ -70,17 +71,23 @@ public class ContentProviderManager {
private Map<ContentSource, ContentProvider> adapters;
// This is used as a monitor lock to the synchronizeContentProvider method;
- // it helps us avoid two content sources getting synchronized at the same time.
+ // it helps us avoid two content sources getting synchronized at the same
+ // time.
private final Object synchronizeContentSourceLock = new Object();
/**
- * Asks that the adapter responsible for the given content source return a stream to the package
- * bits for the package at the given location.
- *
- * @param contentSourceId the adapter for this content source will be used to stream the bits
- * @param location where the adapter can find the package bits on the content source
+ * Asks that the adapter responsible for the given content source return a
+ * stream to the package bits for the package at the given location.
+ *
+ * @param contentSourceId
+ * the adapter for this content source will be used to stream the
+ * bits
+ * @param location
+ * where the adapter can find the package bits on the content
+ * source
* @return the stream to the package bits
- * @throws Exception if the adapter failed to load the bits
+ * @throws Exception
+ * if the adapter failed to load the bits
*/
public InputStream loadPackageBits(int contentSourceId, String location) throws Exception {
ContentProvider adapter = getIsolatedContentProvider(contentSourceId);
@@ -97,13 +104,19 @@ public class ContentProviderManager {
}
/**
- * Asks that the adapter responsible for the given content source return a stream to the
- * DistributionFile bits for the DistributionFile at the given location.
- *
- * @param contentSourceId the adapter for this content source will be used to stream the bits
- * @param location where the adapter can find the DistributionFile bits on the source
+ * Asks that the adapter responsible for the given content source return a
+ * stream to the DistributionFile bits for the DistributionFile at the given
+ * location.
+ *
+ * @param contentSourceId
+ * the adapter for this content source will be used to stream the
+ * bits
+ * @param location
+ * where the adapter can find the DistributionFile bits on the
+ * source
* @return the stream to the DistributionFile bits
- * @throws Exception if the adapter failed to load the bits
+ * @throws Exception
+ * if the adapter failed to load the bits
*/
public InputStream loadDistributionFileBits(int contentSourceId, String location) throws Exception {
ContentProvider adapter = getIsolatedContentProvider(contentSourceId);
@@ -120,16 +133,20 @@ public class ContentProviderManager {
}
/**
- * Asks the provider responsible for the given content source to synchronize with its remote
- * repository. This will not attempt to load any package bits - it only synchronizes the repos
- * and package version information. Note that if a synchronization is already currently underway,
- * this method will not do anything and will return <code>false</code> (in effect, will let the
- * currently running synchronization continue; we try not to step on it). If this method does
- * actually do a sync, <code>true</code> will be returned.
- *
- * @param contentSourceId identifies the database entry of the provider
- * @return <code>true</code> if the synchronization completed; <code>false</code> if there was
- * already a synchronization happening and this method aborted
+ * Asks the provider responsible for the given content source to synchronize
+ * with its remote repository. This will not attempt to load any package
+ * bits - it only synchronizes the repos and package version information.
+ * Note that if a synchronization is already currently underway, this method
+ * will not do anything and will return <code>false</code> (in effect, will
+ * let the currently running synchronization continue; we try not to step on
+ * it). If this method does actually do a sync, <code>true</code> will be
+ * returned.
+ *
+ * @param contentSourceId
+ * identifies the database entry of the provider
+ * @return <code>true</code> if the synchronization completed;
+ * <code>false</code> if there was already a synchronization
+ * happening and this method aborted
* @throws Exception
*/
public boolean synchronizeContentProvider(int contentSourceId) throws Exception {
@@ -150,11 +167,16 @@ public class ContentProviderManager {
throw new Exception("Cannot sync a non-existing content source [" + contentSourceId + "]");
}
- // This should not take very long so it should be OK to block other callers.
- // We are avoiding the problem that would occur if we try to synchronize the same source
- // at the same time. We could do it more cleverly by synchronizing on a per content source
- // basis, but I don't see a need right now to make this more complicated.
- // We can come back and revisit if we need more fine-grained locking.
+ // This should not take very long so it should be OK to block other
+ // callers.
+ // We are avoiding the problem that would occur if we try to
+ // synchronize the same source
+ // at the same time. We could do it more cleverly by synchronizing
+ // on a per content source
+ // basis, but I don't see a need right now to make this more
+ // complicated.
+ // We can come back and revisit if we need more fine-grained
+ // locking.
synchronized (synchronizeContentSourceLock) {
progress.append(new Date()).append(": ");
progress.append("Start synchronization of content provider [").append(contentSource.getName()).append(
@@ -169,12 +191,17 @@ public class ContentProviderManager {
}
if (results == null) {
- // note that it technically is still possible to have concurrent syncs - if two
- // threads running in two different servers (i.e. different VMs) both try to sync the
- // same content source and both enter the persistContentSourceSyncResults method at
- // the same time, you'll get two inprogress rows - this is so rare as to not care.
+ // note that it technically is still possible to have concurrent
+ // syncs - if two
+ // threads running in two different servers (i.e. different VMs)
+ // both try to sync the
+ // same content source and both enter the
+ // persistContentSourceSyncResults method at
+ // the same time, you'll get two inprogress rows - this is so
+ // rare as to not care.
// Even if it does happen, it may still work, or
- // one sync will get an error and rollback its tx and no harm will be done.
+ // one sync will get an error and rollback its tx and no harm
+ // will be done.
log.info("Content provider [" + contentSource.getName()
+ "] is already currently being synchronized, this sync request will be ignored");
return false;
@@ -184,7 +211,8 @@ public class ContentProviderManager {
repoSourceSynchronizer.synchronizeCandidateRepos(progress);
} catch (Throwable t) {
if (results != null) {
- // try to reload the results in case it was updated by the SLSB before the
+ // try to reload the results in case it was updated by the SLSB
+ // before the
// exception happened
ContentSourceSyncResults reloadedResults = contentSourceManager.getContentSourceSyncResults(results
.getId());
@@ -217,21 +245,25 @@ public class ContentProviderManager {
}
/**
- * Asks each content provider associated with the given repo to synchronize the following
- * information for the given repo:
+ * 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
+ *
+ * @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 {
+ public boolean synchronizeRepo(int repoId) throws InterruptedException {
RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
@@ -241,10 +273,11 @@ public class ContentProviderManager {
// Load the repo to sync
Repo repo = repoManager.getRepo(overlord, repoId);
if (repo == null) {
- throw new Exception("Invalid repo ID specified for sync: " + repoId);
+ throw new IllegalArgumentException("Invalid repo ID specified for sync: " + repoId);
}
- // results = contentSourceManager.persistContentSourceSyncResults(results);
+ // results =
+ // contentSourceManager.persistContentSourceSyncResults(results);
StringBuilder progress = new StringBuilder();
progress.append(new Date()).append(": ");
progress.append("Start synchronization of Repository [").append(repo.getName()).append("]");
@@ -262,122 +295,156 @@ public class ContentProviderManager {
return false;
}
- // METADATA Loop
- for (ContentSource source : repo.getContentSources()) {
- try {
- ContentProvider provider = getIsolatedContentProvider(source.getId());
- SyncProgressWeight sw = provider.getSyncProgressWeight();
- PackageSourceSynchronizer packageSourceSynchronizer = new PackageSourceSynchronizer(repo, source,
- provider);
- log.debug("synchronizeRepo :: synchronizePackageMetadata");
-
- tracker = updateSyncStatus(tracker, ContentSyncStatus.PACKAGEMETADATA);
- tracker = packageSourceSynchronizer.synchronizePackageMetadata(tracker);
- } catch (Exception e) {
- processSyncException(e, tracker, repo, source, repoManager);
+ Exception ie = null;
+ try {
+ ThreadUtil.checkInterrupted();
+ // METADATA Loop
+ for (ContentSource source : repo.getContentSources()) {
+ try {
+ ContentProvider provider = getIsolatedContentProvider(source.getId());
+ SyncProgressWeight sw = provider.getSyncProgressWeight();
+ PackageSourceSynchronizer packageSourceSynchronizer = new PackageSourceSynchronizer(repo, source,
+ provider);
+ log.debug("synchronizeRepo :: synchronizePackageMetadata");
+
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.PACKAGEMETADATA);
+ tracker = packageSourceSynchronizer.synchronizePackageMetadata(tracker);
+ } catch (SyncException e) {
+ processSyncException(e, tracker, repo, source, repoManager);
+ }
}
- }
-
- // Setup ProgressWatcher
- for (ContentSource source : repo.getContentSources()) {
- ContentProvider provider = getIsolatedContentProvider(source.getId());
- SyncProgressWeight sw = provider.getSyncProgressWeight();
- tracker.getProgressWatcher().addWork(sw.getPackageMetadataWeight());
- tracker.addAdvisoryMetadataWork(provider);
- tracker.getProgressWatcher().addWork(sw.getDistribtutionBitsWeight());
- tracker.getProgressWatcher().addWork(sw.getDistribtutionMetadataWeight());
- tracker.addPackageBitsWork(provider);
- tracker.getProgressWatcher().finishWork(sw.getPackageMetadataWeight());
- }
- tracker = updatePercentComplete(tracker, repoManager);
+ ThreadUtil.checkInterrupted();
- // PACKAGEBITS Loop
- // Synchronize every content provider associated with the repo
- for (ContentSource source : repo.getContentSources()) {
- // Don't let the entire sync fail if a single content source fails
- try {
+ // Setup ProgressWatcher
+ for (ContentSource source : repo.getContentSources()) {
ContentProvider provider = getIsolatedContentProvider(source.getId());
-
- PackageSourceSynchronizer packageSourceSynchronizer = new PackageSourceSynchronizer(repo, source,
- provider);
- log.debug("synchronizeRepo :: synchronizePackageBits");
- tracker = updateSyncStatus(tracker, ContentSyncStatus.PACKAGEBITS);
- tracker = packageSourceSynchronizer.synchronizePackageBits(tracker, provider);
- tracker = updatePercentComplete(tracker, repoManager);
- } catch (Exception e) {
- processSyncException(e, tracker, repo, source, repoManager);
+ SyncProgressWeight sw = provider.getSyncProgressWeight();
+ tracker.getProgressWatcher().addWork(sw.getPackageMetadataWeight());
+ tracker.addAdvisoryMetadataWork(provider);
+ tracker.getProgressWatcher().addWork(sw.getDistribtutionBitsWeight());
+ tracker.getProgressWatcher().addWork(sw.getDistribtutionMetadataWeight());
+ tracker.addPackageBitsWork(provider);
+ tracker.getProgressWatcher().finishWork(sw.getPackageMetadataWeight());
}
- }
- // Distro meta
- for (ContentSource source : repo.getContentSources()) {
- try {
- ContentProvider provider = getIsolatedContentProvider(source.getId());
- DistributionSourceSynchronizer distributionSourceSynchronizer = new DistributionSourceSynchronizer(
- repo, source, provider);
-
- log.debug("synchronizeRepo :: synchronizeDistributionMetadata");
- tracker = updateSyncStatus(tracker, ContentSyncStatus.DISTROMETADATA);
- tracker = distributionSourceSynchronizer.synchronizeDistributionMetadata(tracker);
- tracker = updatePercentComplete(tracker, repoManager);
+ tracker = updatePercentComplete(tracker, repoManager);
- } catch (Exception e) {
- processSyncException(e, tracker, repo, source, repoManager);
+ // PACKAGEBITS Loop
+ // Synchronize every content provider associated with the repo
+ for (ContentSource source : repo.getContentSources()) {
+ // Don't let the entire sync fail if a single content source
+ // fails
+ try {
+ ContentProvider provider = getIsolatedContentProvider(source.getId());
+
+ PackageSourceSynchronizer packageSourceSynchronizer = new PackageSourceSynchronizer(repo, source,
+ provider);
+ log.debug("synchronizeRepo :: synchronizePackageBits");
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.PACKAGEBITS);
+ tracker = packageSourceSynchronizer.synchronizePackageBits(tracker, provider);
+ tracker = updatePercentComplete(tracker, repoManager);
+ // Check to cancel after each contentsource
+ ThreadUtil.checkInterrupted();
+
+ } catch (SyncException e) {
+ processSyncException(e, tracker, repo, source, repoManager);
+ }
+ }
+ // Distro meta
+ for (ContentSource source : repo.getContentSources()) {
+ try {
+ ContentProvider provider = getIsolatedContentProvider(source.getId());
+ DistributionSourceSynchronizer distributionSourceSynchronizer = new DistributionSourceSynchronizer(
+ repo, source, provider);
+
+ log.debug("synchronizeRepo :: synchronizeDistributionMetadata");
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.DISTROMETADATA);
+ tracker = distributionSourceSynchronizer.synchronizeDistributionMetadata(tracker);
+ tracker = updatePercentComplete(tracker, repoManager);
+ ThreadUtil.checkInterrupted();
+ } catch (SyncException e) {
+ processSyncException(e, tracker, repo, source, repoManager);
+ }
}
- }
- // Distro bits
- for (ContentSource source : repo.getContentSources()) {
- try {
- ContentProvider provider = getIsolatedContentProvider(source.getId());
- DistributionSourceSynchronizer distributionSourceSynchronizer = new DistributionSourceSynchronizer(
- repo, source, provider);
-
- log.debug("synchronizeRepo :: synchronizeDistributionBits");
- tracker = updateSyncStatus(tracker, ContentSyncStatus.DISTROBITS);
- tracker = distributionSourceSynchronizer.synchronizeDistributionBits(tracker);
- tracker = updatePercentComplete(tracker, repoManager);
- } catch (Exception e) {
- processSyncException(e, tracker, repo, source, repoManager);
+ // Distro bits
+ for (ContentSource source : repo.getContentSources()) {
+ try {
+ ContentProvider provider = getIsolatedContentProvider(source.getId());
+ DistributionSourceSynchronizer distributionSourceSynchronizer = new DistributionSourceSynchronizer(
+ repo, source, provider);
+
+ log.debug("synchronizeRepo :: synchronizeDistributionBits");
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.DISTROBITS);
+ tracker = distributionSourceSynchronizer.synchronizeDistributionBits(tracker);
+ tracker = updatePercentComplete(tracker, repoManager);
+ ThreadUtil.checkInterrupted();
+ } catch (SyncException e) {
+ processSyncException(e, tracker, repo, source, repoManager);
+ }
}
- }
- // advisory meta
- for (ContentSource source : repo.getContentSources()) {
- try {
- log.debug("synchronizeRepo :: synchronizeAdvisoryMetadata");
- ContentProvider provider = getIsolatedContentProvider(source.getId());
- tracker = updateSyncStatus(tracker, ContentSyncStatus.ADVISORYMETADATA);
- AdvisorySourceSynchronizer advisorySourcesync = new AdvisorySourceSynchronizer(repo, source, provider);
- tracker = advisorySourcesync.synchronizeAdvisoryMetadata(tracker);
- tracker = updatePercentComplete(tracker, repoManager);
- } catch (Exception e) {
- processSyncException(e, tracker, repo, source, repoManager);
+ // advisory meta
+ for (ContentSource source : repo.getContentSources()) {
+ try {
+ log.debug("synchronizeRepo :: synchronizeAdvisoryMetadata");
+ ContentProvider provider = getIsolatedContentProvider(source.getId());
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.ADVISORYMETADATA);
+ AdvisorySourceSynchronizer advisorySourcesync = new AdvisorySourceSynchronizer(repo, source,
+ provider);
+ tracker = advisorySourcesync.synchronizeAdvisoryMetadata(tracker);
+ tracker = updatePercentComplete(tracker, repoManager);
+ ThreadUtil.checkInterrupted();
+ } catch (SyncException e) {
+ processSyncException(e, tracker, repo, source, repoManager);
+ }
}
- }
- // Update status to finished.
- progress = new StringBuilder();
- progress.append("\n");
- progress.append(tracker.getRepoSyncResults().getResults());
- progress.append("\n");
- progress.append(new Date()).append(": ");
- progress.append(" Repository [").append(repo.getName()).append("]");
- progress.append('\n');
- progress.append(new Date()).append(": ");
- progress.append("completed syncing.");
- tracker.setResults(progress.toString());
- tracker = updateSyncStatus(tracker, ContentSyncStatus.SUCCESS);
- log.debug("synchronizeRepo :: Success");
+ // Update status to finished.
+ progress = new StringBuilder();
+ progress.append("\n");
+ progress.append(tracker.getRepoSyncResults().getResults());
+ progress.append("\n");
+ progress.append(new Date()).append(": ");
+ progress.append(" Repository [").append(repo.getName()).append("]");
+ progress.append('\n');
+ progress.append(new Date()).append(": ");
+ progress.append("completed syncing.");
+ tracker.setResults(progress.toString());
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.SUCCESS);
+ log.debug("synchronizeRepo :: Success");
+ } catch (GenericJDBCException jdbc) {
+ log.debug("Caught GenericJDBCException");
+ progress.append("\n ** Cancelled syncing **");
+ tracker.getProgressWatcher().resetToZero();
+ tracker = updatePercentComplete(tracker, repoManager);
+ tracker.setResults(progress.toString());
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.CANCELLED);
+ ie = jdbc;
+ } catch (InterruptedException ieinner) {
+ log.debug("Caught InterruptedException");
+ progress.append("\n ** Cancelled syncing **");
+ tracker.setResults(progress.toString());
+ tracker.getProgressWatcher().resetToZero();
+ tracker = updatePercentComplete(tracker, repoManager);
+ tracker = updateSyncStatus(tracker, ContentSyncStatus.CANCELLED);
+ ie = ieinner;
+ }
if (tracker.getRepoSyncResults() != null) {
// pw.stop();
tracker.getRepoSyncResults().setEndTime(System.currentTimeMillis());
- // results.setPercentComplete(new Long(pw.getPercentComplete()));
+ // results.setPercentComplete(new
+ // Long(pw.getPercentComplete()));
repoManager.mergeRepoSyncResults(tracker.getRepoSyncResults());
log.debug("synchronizeRepo :: merging results.");
}
+ if (ie != null) {
+ log.debug("rethrowing the InterruptedException");
+ throw new InterruptedException(ie.toString());
+ } else {
+ return true;
+ }
- return true;
}
private SyncTracker updatePercentComplete(SyncTracker tracker, RepoManagerLocal repoManager) {
@@ -393,7 +460,8 @@ public class ContentProviderManager {
log.error("Error while synchronizing repo [" + repo + "] with content provider [" + source
+ "]. Synchronization for the repo will continue for other providers.", e);
- // try to reload the results in case it was updated by the SLSB before the
+ // try to reload the results in case it was updated by the SLSB before
+ // the
// exception happened
RepoSyncResults reloadedResults = repoManager.getRepoSyncResults(tracker.getRepoSyncResults().getId());
if (reloadedResults != null) {
@@ -425,11 +493,14 @@ public class ContentProviderManager {
/**
* Tests the connection to the content source that has the given ID.
- *
- * @param contentSourceId refers to a valid content source in the database
- * @return <code>true</code> if there is an adapter that can successfully connect to the given
- * content source <code>false</code> if there is an adapter but it cannot connect
- * @throws Exception if failed to get an adapter to attempt the connection
+ *
+ * @param contentSourceId
+ * refers to a valid content source in the database
+ * @return <code>true</code> if there is an adapter that can successfully
+ * connect to the given content source <code>false</code> if there
+ * is an adapter but it cannot connect
+ * @throws Exception
+ * if failed to get an adapter to attempt the connection
*/
public boolean testConnection(int contentSourceId) throws Exception {
ContentProvider adapter = getIsolatedContentProvider(contentSourceId);
@@ -444,8 +515,9 @@ public class ContentProviderManager {
}
/**
- * Returns a set of all content sources whose adapters are managed by this object.
- *
+ * Returns a set of all content sources whose adapters are managed by this
+ * object.
+ *
* @return all content sources
*/
public Set<ContentSource> getAllContentSources() {
@@ -455,20 +527,25 @@ public class ContentProviderManager {
}
/**
- * Call this method when a new content source is added to the system during runtime. This can
- * also be used to restart an adapter that was previously {@link #shutdownAdapter(ContentSource)
- * shutdown}.
- *
- * <p>If there is already an adapter currently started for the given content source, this
- * returns silently.</p>
- *
- * @param contentSource the new content source that was added
- * @throws InitializationException if the provider throws an error on its startup
+ * Call this method when a new content source is added to the system during
+ * runtime. This can also be used to restart an adapter that was previously
+ * {@link #shutdownAdapter(ContentSource) shutdown}.
+ *
+ * <p>
+ * If there is already an adapter currently started for the given content
+ * source, this returns silently.
+ * </p>
+ *
+ * @param contentSource
+ * the new content source that was added
+ * @throws InitializationException
+ * if the provider throws an error on its startup
*/
public void startAdapter(ContentSource contentSource) throws InitializationException {
synchronized (this.adapters) {
if (this.adapters.containsKey(contentSource)) {
- return; // already exists, which means it was already initialized
+ return; // already exists, which means it was already
+ // initialized
}
}
@@ -482,8 +559,10 @@ public class ContentProviderManager {
adapter.initialize(contentSource.getConfiguration());
} catch (Exception e) {
log.warn("Failed to initialize adapter for content source [" + contentSource.getName() + "]");
- // The adapter is put in the adapter cache when it is instantiated. If it failed to start, remove it
- // from the cache so we don't immediately return at the start of this method.
+ // The adapter is put in the adapter cache when it is instantiated.
+ // If it failed to start, remove it
+ // from the cache so we don't immediately return at the start of
+ // this method.
this.adapters.remove(contentSource);
throw new InitializationException(e);
@@ -491,14 +570,18 @@ public class ContentProviderManager {
}
/**
- * Call this method when a content source is removed from the system during runtime or if you
- * just want to shutdown the adapter for whatever reason. You can restart the adapter by calling
+ * Call this method when a content source is removed from the system during
+ * runtime or if you just want to shutdown the adapter for whatever reason.
+ * You can restart the adapter by calling
* {@link #startAdapter(ContentSource)}.
- *
- * <p>If there are no adapters currently started for the given content source, this returns
- * silently.</p>
- *
- * @param contentSource the content source being deleted
+ *
+ * <p>
+ * If there are no adapters currently started for the given content source,
+ * this returns silently.
+ * </p>
+ *
+ * @param contentSource
+ * the content source being deleted
*/
public void shutdownAdapter(ContentSource contentSource) {
synchronized (this.adapters) {
@@ -521,12 +604,15 @@ public class ContentProviderManager {
}
/**
- * Convienence method that simply {@link #shutdownAdapter(ContentSource) shuts down the adapter}
- * and then {@link #startAdapter(ContentSource) restarts it}. Call this when, for example, a
- * content source's {@link ContentSource#getConfiguration() configuration} has changed.
- *
- * @param contentSource the content source whose adapter is to be restarted
- * @throws Exception if there is an error asking the provider to shutdown or start
+ * Convienence method that simply {@link #shutdownAdapter(ContentSource)
+ * shuts down the adapter} and then {@link #startAdapter(ContentSource)
+ * restarts it}. Call this when, for example, a content source's
+ * {@link ContentSource#getConfiguration() configuration} has changed.
+ *
+ * @param contentSource
+ * the content source whose adapter is to be restarted
+ * @throws Exception
+ * if there is an error asking the provider to shutdown or start
*/
public void restartAdapter(ContentSource contentSource) throws Exception {
shutdownAdapter(contentSource);
@@ -534,13 +620,17 @@ 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
+ * 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) {
@@ -555,12 +645,16 @@ public class ContentProviderManager {
}
/**
- * 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>
- *
- * @param pluginManager the plugin manager this object can use to obtain information from (like
- * classloaders)
+ * 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>
+ *
+ * @param pluginManager
+ * the plugin manager this object can use to obtain information
+ * from (like classloaders)
*/
protected void initialize(ContentServerPluginManager pluginManager) {
this.pluginManager = pluginManager;
@@ -568,8 +662,10 @@ public class ContentProviderManager {
ContentSourceMetadataManagerLocal metadataManager = LookupUtil.getContentSourceMetadataManager();
ContentSourceManagerLocal contentSourceManager = LookupUtil.getContentSourceManager();
- // Our plugin manager should have parsed all descriptors and have our types for us.
- // Let's register the types to make sure they are merged with the old existing types.
+ // Our plugin manager should have parsed all descriptors and have our
+ // types for us.
+ // Let's register the types to make sure they are merged with the old
+ // existing types.
ContentSourcePluginMetadataManager pluginMetadataManager = this.pluginManager.getMetadataManager();
Set<ContentSourceType> allTypes = pluginMetadataManager.getAllContentSourceTypes();
metadataManager.registerTypes(allTypes);
@@ -594,14 +690,18 @@ public class ContentProviderManager {
}
/**
- * Tells this manager to shutdown. This will effectively shutdown all of its adapters.
- *
- * <p>This is protected so only the plugin container and subclasses can use it.</p>
+ * Tells this manager to shutdown. This will effectively shutdown all of its
+ * adapters.
+ *
+ * <p>
+ * This is protected so only the plugin container and subclasses can use it.
+ * </p>
*/
protected void shutdown() {
HashMap<ContentSource, ContentProvider> adaptersCopy;
- // shutdown all adapters to give them a chance to clean up after themselves
+ // shutdown all adapters to give them a chance to clean up after
+ // themselves
synchronized (this.adapters) {
adaptersCopy = new HashMap<ContentSource, ContentProvider>(this.adapters);
}
@@ -623,12 +723,16 @@ public class ContentProviderManager {
}
/**
- * 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.
- *
- * @param contentSource the returned adapter communicates with this content source
- * @return the adapter that is communicating with the content source, isolated to its classloader
- * @throws RuntimeException if there is no content source adapter available
+ * 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.
+ *
+ * @param contentSource
+ * the returned adapter communicates with this content source
+ * @return the adapter that is communicating with the content source,
+ * isolated to its classloader
+ * @throws RuntimeException
+ * if there is no content source adapter available
*/
protected ContentProvider getIsolatedContentSourceAdapter(ContentSource contentSource) throws RuntimeException {
ContentProvider adapter;
@@ -671,10 +775,13 @@ public class ContentProviderManager {
}
/**
- * Creates a provider instance that will service the give {@link ContentSource}.
- *
- * @param contentSource the source that the adapter will connect to
- * @return an adapter instance; will be <code>null</code> if failed to create adapter
+ * Creates a provider instance that will service the give
+ * {@link ContentSource}.
+ *
+ * @param contentSource
+ * the source that the adapter will connect to
+ * @return an adapter instance; will be <code>null</code> if failed to
+ * create adapter
*/
protected ContentProvider instantiateAdapter(ContentSource contentSource) {
ContentProvider adapter = null;
@@ -718,8 +825,8 @@ public class ContentProviderManager {
}
/**
- * This will handle invocations to an object ensuring that the call is isolated to within the
- * appropriate classloader.
+ * This will handle invocations to an object ensuring that the call is
+ * isolated to within the appropriate classloader.
*/
private class IsolatedInvocationHandler implements InvocationHandler {
private final Object instance;
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 da28caa..3418ae7 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
@@ -22,6 +22,7 @@ import java.util.Date;
import java.util.Set;
import org.quartz.JobDetail;
+import org.quartz.JobExecutionContext;
import org.quartz.SchedulerException;
import org.quartz.SimpleTrigger;
@@ -137,8 +138,8 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
* @throws SchedulerException if the job cannot be scheduled
*/
public void syncRepoNow(Repo repo) throws SchedulerException {
- JobDetail job = new JobDetail(RepoSyncJob.createUniqueJobName(repo), CONTENT_SRC_SYNC_JOB_GROUP_NAME,
- RepoSyncJob.class, false, false, false);
+ JobDetail job = new JobDetail(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME, RepoSyncJob.class,
+ false, false, false);
RepoSyncJob.createJobDataMap(job, repo);
@@ -153,6 +154,22 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
+ "] for [" + repo + "]");
}
+ public void cancelRepoSync(Repo repo) throws SchedulerException {
+ JobDetail jobDetail = new JobDetail(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME,
+ RepoSyncJob.class, false, false, false);
+
+ RepoSyncJob.createJobDataMap(jobDetail, repo);
+
+ SimpleTrigger trigger = new SimpleTrigger(jobDetail.getName(), jobDetail.getGroup());
+ trigger.setVolatility(false);
+
+ SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
+
+ boolean cancelled = scheduler.interrupt(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME);
+
+ getLog().info("cancelled repo sync job [" + jobDetail.getName() + ':' + jobDetail.getGroup() + "] ");
+ }
+
/**
* This will schedule the sync job for the given content source. Once the scheduling is complete, the content
* source's adapter will be asked to synchronize with the remote content source according to the time(s) specified
@@ -268,4 +285,5 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
ContentProviderManager am = new ContentProviderManager();
return am;
}
+
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/DistributionSource.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/DistributionSource.java
index 9efd9c7..e2cbc7c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/DistributionSource.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/DistributionSource.java
@@ -42,8 +42,7 @@ public interface DistributionSource {
* source cannot be connected to.
*/
void synchronizeDistribution(String repoName, DistributionSyncReport report,
- Collection<DistributionDetails> existingDistros)
- throws Exception;
+ Collection<DistributionDetails> existingDistros) throws SyncException, InterruptedException;
/**
* Get an input stream for the specified distribution.
@@ -64,4 +63,3 @@ public interface DistributionSource {
String getDistFileRemoteLocation(String repoName, String label, String relativeFilename);
}
-
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/PackageSource.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/PackageSource.java
index 459d78f..33c66aa 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/PackageSource.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/PackageSource.java
@@ -48,8 +48,7 @@ public interface PackageSource {
* source cannot be connected to.
*/
void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages)
- throws Exception;
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException, InterruptedException;
/**
* Get an input stream for the specified package.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncException.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncException.java
new file mode 100644
index 0000000..9b901f0
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/SyncException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.plugin.pc.content;
+
+/**
+ * @author mmccune
+ *
+ */
+public class SyncException extends Exception {
+
+ public SyncException(String errorMsg, Exception e) {
+ super(errorMsg, e);
+ }
+
+ public SyncException(String errorMsg) {
+ super(errorMsg);
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ThreadUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ThreadUtil.java
new file mode 100644
index 0000000..bd04b65
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ThreadUtil.java
@@ -0,0 +1,21 @@
+/**
+ *
+ */
+package org.rhq.enterprise.server.plugin.pc.content;
+
+/**
+ * @author mmccune
+ *
+ */
+public class ThreadUtil {
+
+ public static void checkInterrupted() throws InterruptedException {
+ Thread cthread = Thread.currentThread();
+ System.out.println("ThreadInterrupt : [" + cthread.getName() + "]");
+ if (Thread.interrupted()) {
+ throw new InterruptedException();
+ }
+
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java
index 2fc7ae9..dbc0987 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/AdvisorySourceSynchronizer.java
@@ -49,7 +49,9 @@ import org.rhq.enterprise.server.plugin.pc.content.AdvisoryPackageDetails;
import org.rhq.enterprise.server.plugin.pc.content.AdvisorySource;
import org.rhq.enterprise.server.plugin.pc.content.AdvisorySyncReport;
import org.rhq.enterprise.server.plugin.pc.content.ContentProvider;
+import org.rhq.enterprise.server.plugin.pc.content.SyncException;
import org.rhq.enterprise.server.plugin.pc.content.SyncTracker;
+import org.rhq.enterprise.server.plugin.pc.content.ThreadUtil;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -83,7 +85,7 @@ public class AdvisorySourceSynchronizer {
overlord = subjectManager.getOverlord();
}
- public SyncTracker synchronizeAdvisoryMetadata(SyncTracker tracker) throws Exception {
+ public SyncTracker synchronizeAdvisoryMetadata(SyncTracker tracker) throws SyncException, InterruptedException {
if (!(provider instanceof AdvisorySource)) {
log.error(" Advisory Instance:" + provider);
return tracker;
@@ -97,10 +99,12 @@ public class AdvisorySourceSynchronizer {
List<Advisory> advs = repoManager.findAssociatedAdvisory(overlord, repo.getId(), pc);
log.error("Found " + advs.size() + " Advisory for repo " + repo.getId());
+ ThreadUtil.checkInterrupted();
AdvisorySyncReport advReport = new AdvisorySyncReport(repo.getId());
List<AdvisoryDetails> advDetails = new ArrayList<AdvisoryDetails>(advs.size());
translateDomainToDto(advs, advDetails);
+ ThreadUtil.checkInterrupted();
log.error("Synchronize Advisory: [" + source.getName() + "]: loaded existing list of size=[" + advs.size()
+ "] (" + (System.currentTimeMillis() - start) + ")ms");
@@ -110,12 +114,18 @@ public class AdvisorySourceSynchronizer {
start = System.currentTimeMillis();
advisorySource.synchronizeAdvisory(repo.getName(), advReport, advDetails);
+ ThreadUtil.checkInterrupted();
log.error("Synchronize Advisory: [" + source.getName() + "]: got sync report from adapter=[" + advReport
+ "] (" + (System.currentTimeMillis() - start) + ")ms");
RepoSyncResults syncResults = contentSourceManager.mergeAdvisorySyncReport(source, advReport, tracker
.getRepoSyncResults());
+ ThreadUtil.checkInterrupted();
+
+ log.error("Synchronize Advisory: [" + source.getName() + "]: finished mergeAdvisorySyncReport ("
+ + (System.currentTimeMillis() - start) + ")ms");
+
tracker.setRepoSyncResults(syncResults);
tracker.finishAdvisoryMetadataWork(provider);
return tracker;
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 d145421..e5dfd67 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
@@ -44,6 +44,7 @@ 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.plugin.pc.content.SyncException;
import org.rhq.enterprise.server.plugin.pc.content.SyncTracker;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -75,7 +76,7 @@ public class DistributionSourceSynchronizer {
subjectManager = LookupUtil.getSubjectManager();
}
- public SyncTracker synchronizeDistributionMetadata(SyncTracker tracker) throws Exception {
+ public SyncTracker synchronizeDistributionMetadata(SyncTracker tracker) throws SyncException, InterruptedException {
if (!(provider instanceof DistributionSource)) {
return tracker;
}
@@ -118,7 +119,7 @@ public class DistributionSourceSynchronizer {
return tracker;
}
- public SyncTracker synchronizeDistributionBits(SyncTracker tracker) throws Exception {
+ public SyncTracker synchronizeDistributionBits(SyncTracker tracker) throws SyncException, InterruptedException {
if (!(provider instanceof DistributionSource)) {
return tracker;
}
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 e196b6d..4f7d05a 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,7 @@ 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.plugin.pc.content.SyncException;
import org.rhq.enterprise.server.plugin.pc.content.SyncProgressWeight;
import org.rhq.enterprise.server.plugin.pc.content.SyncTracker;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -82,7 +83,7 @@ public class PackageSourceSynchronizer {
repoManager = LookupUtil.getRepoManagerLocal();
}
- public SyncTracker synchronizePackageMetadata(SyncTracker tracker) throws Exception {
+ public SyncTracker synchronizePackageMetadata(SyncTracker tracker) throws SyncException, InterruptedException {
if (!(provider instanceof PackageSource)) {
return tracker;
}
@@ -133,7 +134,8 @@ public class PackageSourceSynchronizer {
return tracker;
}
- public SyncTracker synchronizePackageBits(SyncTracker tracker, ContentProvider provider) throws Exception {
+ public SyncTracker synchronizePackageBits(SyncTracker tracker, ContentProvider provider)
+ throws InterruptedException, SyncException {
SyncProgressWeight sw = provider.getSyncProgressWeight();
// Determine if the sync even needs to take place
@@ -207,8 +209,7 @@ public class PackageSourceSynchronizer {
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);
+ throw new SyncException(errorMsg, e);
}
}
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 664b592..9d1ba80 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
@@ -26,11 +26,13 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.quartz.InterruptableJob;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.StatefulJob;
+import org.quartz.UnableToInterruptJobException;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.content.Repo;
@@ -59,16 +61,21 @@ import org.rhq.enterprise.server.util.LookupUtil;
*
* @author Jason Dobies
*/
-public class RepoSyncJob implements StatefulJob {
+public class RepoSyncJob implements StatefulJob, InterruptableJob {
public static final String KEY_REPO_NAME = "repoName";
private final Log log = LogFactory.getLog(this.getClass());
+ private Thread executionThread;
+
/**
* {@inheritDoc}
*/
public void execute(JobExecutionContext context) throws JobExecutionException {
+
+ executionThread = Thread.currentThread();
+
try {
JobDetail jobDetail = context.getJobDetail();
if (jobDetail == null) {
@@ -87,13 +94,13 @@ public class RepoSyncJob implements StatefulJob {
}
sync(repoName);
- }
- catch (Exception e) {
+ } catch (InterruptedException ie) {
+ log.error("Cancelled job [" + context.getJobDetail() + "]");
+ } catch (Exception e) {
String errorMsg = "Failed to sync repo in job [" + context.getJobDetail() + "]";
log.error(errorMsg, e);
- JobExecutionException jobExecutionException = new JobExecutionException(errorMsg, e,
- false);
+ JobExecutionException jobExecutionException = new JobExecutionException(errorMsg, e, false);
// Do not retrigger if we threw IllegalStateException because it'll never work anyway
if (!(e instanceof IllegalStateException)) {
@@ -142,8 +149,8 @@ public class RepoSyncJob implements StatefulJob {
String jobName = Integer.toHexString(repo.getName().hashCode());
if (jobName.length() > 80) {
- throw new IllegalArgumentException("Job names max size is 80 chars due to DB column " +
- "size restrictions: " + jobName);
+ throw new IllegalArgumentException("Job names max size is 80 chars due to DB column "
+ + "size restrictions: " + jobName);
}
return jobName;
@@ -165,14 +172,13 @@ public class RepoSyncJob implements StatefulJob {
jobName = jobName + "-" + uniquifier;
if (jobName.length() > 80) {
- throw new IllegalArgumentException("Job names max size is 80 chars due to DB column " +
- "size restrictions: " + jobName);
+ throw new IllegalArgumentException("Job names max size is 80 chars due to DB column "
+ + "size restrictions: " + jobName);
}
return jobName;
}
-
/**
* Performs the repo synchronization.
* <p/>
@@ -182,9 +188,11 @@ public class RepoSyncJob implements StatefulJob {
* timeout a transaction.
*
* @param repoName may not be <code>null</code>
+ * @throws InterruptedException
+ * @throws
* @throws Exception if there is an error in the sync
*/
- private void sync(String repoName) throws Exception {
+ private void sync(String repoName) throws InterruptedException {
SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
@@ -198,12 +206,24 @@ public class RepoSyncJob implements StatefulJob {
List<Repo> repoList = repoManager.getRepoByName(repoName);
if (repoList.size() != 1) {
- throw new Exception("Unexpected number of repos found for name [" + repoName + "]. " +
- "Found [" + repoList.size() + "] repos");
+ throw new RuntimeException("Unexpected number of repos found for name [" + repoName + "]. " + "Found ["
+ + repoList.size() + "] repos");
}
Repo repoToSync = repoList.get(0);
// This call executes all of the logic associated with synchronizing the given repo
- repoManager.internalSynchronizeRepos(overlord, new Integer[]{repoToSync.getId()});
+ repoManager.internalSynchronizeRepos(overlord, new Integer[] { repoToSync.getId() });
+ }
+
+ @Override
+ public void interrupt() throws UnableToInterruptJobException {
+
+ if (executionThread == null) {
+ log.error("execution thread is null, cant interrupt", new IllegalStateException());
+
+ } else {
+ log.debug("exeThread : [" + executionThread.getName() + "]");
+ executionThread.interrupt();
+ }
}
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java
index df07fbf..fd5c521 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoSyncingTest.java
@@ -19,12 +19,16 @@ import org.rhq.core.domain.content.DistributionFile;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.content.RepoDistribution;
import org.rhq.core.domain.content.RepoSyncResults;
+import org.rhq.enterprise.server.content.ContentManagerHelper;
+import org.rhq.enterprise.server.plugin.pc.content.ContentServerPluginContainer;
import org.rhq.enterprise.server.plugin.pc.content.TestContentProvider;
import org.rhq.enterprise.server.plugin.pc.content.TestContentServerPluginService;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
public class RepoSyncingTest extends AbstractEJB3Test {
+ private static final boolean ENABLED = false;
+
private EntityManager em;
private Repo repo;
private ContentSource contentSource;
@@ -53,7 +57,7 @@ public class RepoSyncingTest extends AbstractEJB3Test {
em.flush();
}
- @Test(enabled = false)
+ @Test(enabled = ENABLED)
public void testSyncResults() throws Exception {
// We have to commit because bean has new transaction inside it
getTransactionManager().commit();
@@ -66,7 +70,7 @@ public class RepoSyncingTest extends AbstractEJB3Test {
assert (results.getPercentComplete().equals(new Long(100)));
}
- @Test(enabled = false)
+ @Test(enabled = ENABLED)
public void testMultipleSyncResults() throws Exception {
getTransactionManager().commit();
// Sync 2x so we get multiple results
@@ -88,9 +92,9 @@ public class RepoSyncingTest extends AbstractEJB3Test {
assert (r1.getId() > r2.getId());
}
- @Test(enabled = true)
+ @Test(enabled = ENABLED)
public void testSyncRepos() throws Exception {
- p1.setLongRunningSyncs(true);
+ p1.setLongRunningSynchSleep(5000);
assert repo.getContentSources().size() == 1;
// We have to commit because bean has new transaction inside it
@@ -140,7 +144,7 @@ public class RepoSyncingTest extends AbstractEJB3Test {
}
- @Test(enabled = false)
+ @Test(enabled = ENABLED)
public void testSyncCount() throws Exception {
Integer[] ids = { repo.getId() };
@@ -152,6 +156,39 @@ public class RepoSyncingTest extends AbstractEJB3Test {
}
+ @Test(enabled = true)
+ public void testCancelSync() throws Exception {
+ getTransactionManager().commit();
+ p1 = new TestContentProvider();
+ p1.setLongRunningSynchSleep(10000);
+ pluginService.associateContentProvider(contentSource, p1);
+
+ prepareScheduler();
+ ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer();
+ pc.syncRepoNow(repo);
+
+ for (int i = 0; i < 100; i++) {
+ RepoSyncResults res = getSyncResults(repo.getId());
+ if (res != null) {
+ System.out.println("status: [" + res.getStatus() + "] CTRL+C to exit");
+ if (res.getStatus() == ContentSyncStatus.CANCELLED) {
+ break;
+ }
+ } else {
+ System.out.println("CTRL+C to exit");
+ }
+ Thread.sleep(1000);
+ if (i == 5) {
+ pc.cancelRepoSync(repo);
+ }
+
+ }
+ RepoSyncResults res = getSyncResults(repo.getId());
+ assert res != null;
+ assert res.getStatus() == ContentSyncStatus.CANCELLED;
+ unprepareScheduler();
+ }
+
private RepoSyncResults getSyncResults(int repoId) {
Query q = em.createNamedQuery(RepoSyncResults.QUERY_GET_ALL_BY_REPO_ID);
q.setParameter("repoId", repoId);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
index ad0766d..c157729 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/plugin/pc/content/TestContentProvider.java
@@ -14,21 +14,25 @@ import org.rhq.core.domain.configuration.Configuration;
public class TestContentProvider implements ContentProvider, PackageSource, RepoSource, DistributionSource {
/**
- * Packages returned in a call to {@link #synchronizePackages(String, PackageSyncReport, Collection)} will
- * indicate they are of this type. Any test attempting to call this synchronize method should be sure to
- * create a package type of this name in the database prior to calling it.
+ * Packages returned in a call to
+ * {@link #synchronizePackages(String, PackageSyncReport, Collection)} will
+ * indicate they are of this type. Any test attempting to call this
+ * synchronize method should be sure to create a package type of this name
+ * in the database prior to calling it.
*/
public static final String PACKAGE_TYPE_NAME = "testContentProviderFakePackage";
/**
- * In order to create a package type (as needed to create the type indicated in {@link #PACKAGE_TYPE_NAME}), the
- * package type must be created as part of this resource type.
+ * In order to create a package type (as needed to create the type indicated
+ * in {@link #PACKAGE_TYPE_NAME}), the package type must be created as part
+ * of this resource type.
*/
public static final String RESOURCE_TYPE_NAME = "testContentProviderFakeResourceType";
/**
- * In order to create a resource type (as needed to create the type indicated in {@link #RESOURCE_TYPE_NAME}), this
- * resource type plugin name should be used.
+ * In order to create a resource type (as needed to create the type
+ * indicated in {@link #RESOURCE_TYPE_NAME}), this resource type plugin name
+ * should be used.
*/
public static final String RESOURCE_TYPE_PLUGIN_NAME = "testContentProviderFakeResourceTypePlugin";
@@ -36,19 +40,21 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
public static final String EXISTING_CANDIDATE_REPO_NAME = "testRepoCandidateExisting";
/**
- * This content provider will return packages when asked to synchronize a repo with this name.
+ * This content provider will return packages when asked to synchronize a
+ * repo with this name.
*/
public static final String REPO_WITH_PACKAGES = EXISTING_IMPORTED_REPO_NAME;
/**
- * This content provider will return distributions when asked to synchronize a repo with this name.
+ * This content provider will return distributions when asked to synchronize
+ * a repo with this name.
*/
public static final String REPO_WITH_DISTRIBUTIONS = EXISTING_IMPORTED_REPO_NAME;
/**
* Collection of packages that will be returned from calling
- * {@link #synchronizePackages(String, PackageSyncReport, Collection)} passing in a repo with the name
- * {@link #REPO_WITH_PACKAGES}.
+ * {@link #synchronizePackages(String, PackageSyncReport, Collection)}
+ * passing in a repo with the name {@link #REPO_WITH_PACKAGES}.
*/
public static final Map<ContentProviderPackageDetailsKey, ContentProviderPackageDetails> PACKAGES = new HashMap<ContentProviderPackageDetailsKey, ContentProviderPackageDetails>(
2);
@@ -86,17 +92,18 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
public static final Map<String, DistributionDetails> DISTRIBUTIONS = new HashMap<String, DistributionDetails>(2);
static {
- // Note: The type "kickstart" should already be in the database from installation
+ // Note: The type "kickstart" should already be in the database from
+ // installation
- /* Note: The md5 sums below will be used to determine if the file needs to be loaded through
- a call to getPackageBits. I set these to an invalid MD5 so they will *always* be downloaded.
+ /*
+ * Note: The md5 sums below will be used to determine if the file needs
+ * to be loaded through a call to getPackageBits. I set these to an
+ * invalid MD5 so they will *always* be downloaded.
*/
DistributionDetails dis1 = new DistributionDetails(DISTRIBUTION_1_LABEL, "kickstart");
dis1.setDistributionPath("/kstrees");
- DistributionFileDetails file11 = new DistributionFileDetails("dist1file1", System.currentTimeMillis(),
- "zzz");
- DistributionFileDetails file12 = new DistributionFileDetails("dist1file2", System.currentTimeMillis(),
- "zzz");
+ DistributionFileDetails file11 = new DistributionFileDetails("dist1file1", System.currentTimeMillis(), "zzz");
+ DistributionFileDetails file12 = new DistributionFileDetails("dist1file2", System.currentTimeMillis(), "zzz");
dis1.addFile(file11);
dis1.addFile(file12);
@@ -104,37 +111,45 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
DistributionDetails dis2 = new DistributionDetails(DISTRIBUTION_2_LABEL, "kickstart");
dis2.setDistributionPath("/kstrees");
- DistributionFileDetails file21 = new DistributionFileDetails("dist2file1", System.currentTimeMillis(),
- "zzz");
+ DistributionFileDetails file21 = new DistributionFileDetails("dist2file1", System.currentTimeMillis(), "zzz");
dis2.addFile(file21);
DISTRIBUTIONS.put(dis2.getLabel(), dis2);
}
- public static final int PACKAGE_COUNT_FOR_BITS = PACKAGES.size() + 3; // packages + number of distro files
+ public static final int PACKAGE_COUNT_FOR_BITS = PACKAGES.size() + 3; // packages
+ // +
+ // number
+ // of
+ // distro
+ // files
/**
- * If <code>true</code>, the call to {@link #testConnection()} will throw an exception.
+ * If <code>true</code>, the call to {@link #testConnection()} will throw an
+ * exception.
*/
private boolean failTest = false;
- private boolean longRunningSyncs = false;
+ // Set this value if you want the packageSync step to take a while
+ private int longRunningSynchSleep = 0;
/**
* Holds a list of all repo names that were passed into calls to
- * {@link #synchronizePackages(String, PackageSyncReport, Collection)} to track when and with
- * what data these calls are made.
+ * {@link #synchronizePackages(String, PackageSyncReport, Collection)} to
+ * track when and with what data these calls are made.
*/
private List<String> logSynchronizePackagesRepos = new ArrayList<String>();
/**
- * Holds a list of all locations passed into calls to {@link #getInputStream(String)}.
+ * Holds a list of all locations passed into calls to
+ * {@link #getInputStream(String)}.
*/
private List<String> logGetInputStreamLocations = new ArrayList<String>();
/**
* Holds a list of all repo names that were passed into calls to
- * {@link #synchronizeDistribution(String, DistributionSyncReport, Collection)}.
+ * {@link #synchronizeDistribution(String, DistributionSyncReport, Collection)}
+ * .
*/
private List<String> logSynchronizeDistroRepos = new ArrayList<String>();
@@ -173,7 +188,8 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
report.addRepo(repo2);
// Repo with a parent repo created in this sync
- // Parent explicitly added to this list *after* this child to ensure that's not a problem
+ // Parent explicitly added to this list *after* this child to ensure
+ // that's not a problem
RepoDetails repo3 = new RepoDetails("testRepo3");
report.addRepo(repo3);
@@ -193,7 +209,7 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
}
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws Exception {
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException, InterruptedException {
logSynchronizePackagesRepos.add(repoName);
@@ -201,9 +217,12 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
return;
}
- // For each package this provider wants to introduce, make sure it doesn't exist already.
- // This basically means the report will only ever contain "added" packages and will only do so
- // on the first call to this method. This will likely be changed as new requirements emerge.
+ // For each package this provider wants to introduce, make sure it
+ // doesn't exist already.
+ // This basically means the report will only ever contain "added"
+ // packages and will only do so
+ // on the first call to this method. This will likely be changed as new
+ // requirements emerge.
for (ContentProviderPackageDetails pkg : PACKAGES.values()) {
ContentProviderPackageDetails existingPackage = findDetailsByKey(pkg.getContentProviderPackageDetailsKey(),
@@ -214,10 +233,9 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
}
}
- if (this.longRunningSyncs) {
- System.out.println(this.getClass().getSimpleName() + ".synchronizePackages sleeping for 5 seconds");
- Thread.sleep(5000);
- }
+ System.out.println(this.getClass().getSimpleName() + ".synchronizePackages sleeping for "
+ + this.longRunningSynchSleep + " seconds");
+ Thread.sleep(this.longRunningSynchSleep);
}
public InputStream getInputStream(String location) throws Exception {
@@ -232,7 +250,7 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
}
public void synchronizeDistribution(String repoName, DistributionSyncReport report,
- Collection<DistributionDetails> existingDistros) throws Exception {
+ Collection<DistributionDetails> existingDistros) throws SyncException, InterruptedException {
logSynchronizeDistroRepos.add(repoName);
@@ -254,6 +272,10 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
report.addDistro(distro);
}
}
+ System.out.println(this.getClass().getSimpleName() + ".synchronizeDistribution sleeping for "
+ + this.longRunningSynchSleep + " seconds");
+
+ Thread.sleep(this.longRunningSynchSleep);
}
public String getDistFileRemoteLocation(String repoName, String label, String relativeFilename) {
@@ -266,28 +288,42 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
/**
* Returns a list of repo names that were used to all calls to
- * {@link #synchronizePackages(String, PackageSyncReport, Collection)} either since the creation
- * of this instance or the last call to {@link #reset()}.
- *
- * @return handle to the actual list used to capture these names; be careful about iterating this
- * list while making other calls against this instance
+ * {@link #synchronizePackages(String, PackageSyncReport, Collection)}
+ * either since the creation of this instance or the last call to
+ * {@link #reset()}.
+ *
+ * @return handle to the actual list used to capture these names; be careful
+ * about iterating this list while making other calls against this
+ * instance
*/
public List<String> getLogSynchronizePackagesRepos() {
return logSynchronizePackagesRepos;
}
/**
- * Returns a list of locations passed into all calls to {@link #getInputStream(String)} since
- * the creation of this instance or the lsat call to {@link #reset()}.
- *
- * @return handle to the actual list used to capture these names; be careful about iterating this
- * list while making other calls against this instance
+ * Returns a list of locations passed into all calls to
+ * {@link #getInputStream(String)} since the creation of this instance or
+ * the lsat call to {@link #reset()}.
+ *
+ * @return handle to the actual list used to capture these names; be careful
+ * about iterating this list while making other calls against this
+ * instance
*/
public List<String> getLogGetInputStreamLocations() {
return logGetInputStreamLocations;
}
/**
+ * Indicate how long you want the provider to sleep during the PackageSync
+ * step
+ *
+ * @param longRunningSynchSleep
+ */
+ public void setLongRunningSynchSleep(int longRunningSynchSleep) {
+ this.longRunningSynchSleep = longRunningSynchSleep;
+ }
+
+ /**
* Rests the logging of calls made into this instance.
*/
public void reset() {
@@ -296,16 +332,6 @@ public class TestContentProvider implements ContentProvider, PackageSource, Repo
logSynchronizeDistroRepos.clear();
}
- /**
- * Indicate you want this test to simulate a long running sync. Will pause for ~10 seconds during
- * the package sync phase.
- *
- * @param longRunningSyncs enables/disables long syncs
- */
- public void setLongRunningSyncs(boolean longRunningSyncs) {
- this.longRunningSyncs = longRunningSyncs;
- }
-
private ContentProviderPackageDetails findDetailsByKey(ContentProviderPackageDetailsKey key,
Collection<ContentProviderPackageDetails> packages) {
diff --git a/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java b/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
index 6f9bb8b..ffac623 100644
--- a/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
+++ b/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
@@ -20,6 +20,7 @@ package org.rhq.enterprise.server.plugins.disk;
import java.io.File;
import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
@@ -42,6 +43,7 @@ import org.rhq.enterprise.server.plugin.pc.content.PackageSyncReport;
import org.rhq.enterprise.server.plugin.pc.content.RepoDetails;
import org.rhq.enterprise.server.plugin.pc.content.RepoImportReport;
import org.rhq.enterprise.server.plugin.pc.content.RepoSource;
+import org.rhq.enterprise.server.plugin.pc.content.SyncException;
import org.rhq.enterprise.server.plugin.pc.content.SyncProgressWeight;
/**
@@ -117,11 +119,7 @@ public class DiskSource implements ContentProvider, PackageSource, RepoSource {
}
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws Exception {
-
- if (!isPackageSource) {
- return;
- }
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException {
if (!isPackageSource) {
return;
@@ -195,7 +193,7 @@ public class DiskSource implements ContentProvider, PackageSource, RepoSource {
* @throws Exception if the sync fails
*/
protected void syncPackages(PackageSyncReport report, String repoName,
- List<ContentProviderPackageDetails> packages, File directory) throws Exception {
+ List<ContentProviderPackageDetails> packages, File directory) throws SyncException {
for (File file : directory.listFiles()) {
if (file.isDirectory()) {
@@ -228,7 +226,7 @@ public class DiskSource implements ContentProvider, PackageSource, RepoSource {
}
}
- protected ContentProviderPackageDetails createPackage(File file) throws Exception {
+ protected ContentProviderPackageDetails createPackage(File file) throws SyncException {
SupportedPackageType supportedPackageType = determinePackageType(file);
if (supportedPackageType == null) {
@@ -236,7 +234,12 @@ public class DiskSource implements ContentProvider, PackageSource, RepoSource {
}
ContentFileInfo fileInfo = ContentFileInfoFactory.createContentFileInfo(file);
- String md5 = MessageDigestGenerator.getDigestString(file);
+ String md5;
+ try {
+ md5 = MessageDigestGenerator.getDigestString(file);
+ } catch (IOException e) {
+ throw new SyncException("Error digesting file", e);
+ }
String name = file.getName();
String version = fileInfo.getVersion(md5);
String packageTypeName = supportedPackageType.packageTypeName;
diff --git a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
index 47a473d..c9d5880 100644
--- a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
+++ b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
@@ -23,6 +23,8 @@ import java.net.URI;
import java.net.URL;
import java.util.Collection;
+import javax.xml.parsers.ParserConfigurationException;
+
import churchillobjects.rss4j.RssDocument;
import churchillobjects.rss4j.parser.RssParser;
@@ -42,6 +44,7 @@ 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.PackageSource;
import org.rhq.enterprise.server.plugin.pc.content.PackageSyncReport;
+import org.rhq.enterprise.server.plugin.pc.content.SyncException;
import org.rhq.enterprise.server.plugin.pc.content.SyncProgressWeight;
/**
@@ -112,17 +115,26 @@ public class JBossSoftwareContentSourceAdapter implements ContentProvider, Packa
}
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws Exception {
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException {
if (!active)
return;
- RssDocument rssDocument = retrieveRssDocument();
+ RssDocument rssDocument;
+ try {
+ rssDocument = retrieveRssDocument();
+ } catch (Exception e) {
+ throw new SyncException("Error retrieving rss doc", e);
+ }
if (rssDocument == null) {
- throw new Exception("Null RSS document received from adapter: " + this);
+ throw new SyncException("Null RSS document received from adapter: " + this);
}
- parser.parseResults(rssDocument, report, existingPackages);
+ try {
+ parser.parseResults(rssDocument, report, existingPackages);
+ } catch (ParserConfigurationException e) {
+ throw new SyncException("error parsing results.", e);
+ }
}
public InputStream getInputStream(String location) throws Exception {
@@ -195,17 +207,17 @@ public class JBossSoftwareContentSourceAdapter implements ContentProvider, Packa
int status = client.executeMethod(method);
if (status == 404) {
- throw new Exception("Could not find the feed at URL [" + url + "]. Make sure the URL field correctly "
- + "refers to the CSP feed location.");
+ throw new SyncException("Could not find the feed at URL [" + url
+ + "]. Make sure the URL field correctly " + "refers to the CSP feed location.");
}
if (status == 401 || status == 403) {
- throw new Exception("Invalid login credentials specified for user [" + username + "]. Make sure "
+ throw new SyncException("Invalid login credentials specified for user [" + username + "]. Make sure "
+ "this user has an active account at the CSP and that the password is correct.");
}
if (status != 200) {
- throw new Exception("The call to retrieve the RSS feed failed with status code: " + status);
+ throw new SyncException("The call to retrieve the RSS feed failed with status code: " + status);
}
rawFeed = method.getResponseBodyAsString();
diff --git a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/RssFeedParser.java b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/RssFeedParser.java
index 9f35bee..c65a7b9 100644
--- a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/RssFeedParser.java
+++ b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/RssFeedParser.java
@@ -26,9 +26,17 @@ import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
+import churchillobjects.rss4j.RssChannel;
+import churchillobjects.rss4j.RssChannelItem;
+import churchillobjects.rss4j.RssDocument;
+import churchillobjects.rss4j.RssDublinCore;
+import churchillobjects.rss4j.RssJbnDependency;
+import churchillobjects.rss4j.RssJbnPatch;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
@@ -40,13 +48,6 @@ 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.PackageSyncReport;
-import churchillobjects.rss4j.RssChannel;
-import churchillobjects.rss4j.RssChannelItem;
-import churchillobjects.rss4j.RssDocument;
-import churchillobjects.rss4j.RssDublinCore;
-import churchillobjects.rss4j.RssJbnDependency;
-import churchillobjects.rss4j.RssJbnPatch;
-
/**
* Parses the contents of the JBoss RSS feed into the server's domain model.
*
@@ -86,7 +87,7 @@ public class RssFeedParser {
// Public --------------------------------------------
public void parseResults(RssDocument feed, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws Exception {
+ Collection<ContentProviderPackageDetails> existingPackages) throws ParserConfigurationException {
// Used to determine if a package was already sent to the server or is new
Map<PackageDetailsKey, ContentProviderPackageDetails> existingPackageMap = unpack(existingPackages);
@@ -202,8 +203,7 @@ public class RssFeedParser {
// bytes will be retrieved using platform encoding on the agent side so use the same
// on the server side and assume they are identical
packageDetails.setMetadata(choppedInstructions.trim().getBytes());
- }
- catch (Exception e) {
+ } catch (Exception e) {
log.error("Could not parse or set automated installation instructions for package: "
+ packageName);
continue;
@@ -254,8 +254,7 @@ public class RssFeedParser {
*/
private Map<PackageDetailsKey, ContentProviderPackageDetails> unpack(
Collection<ContentProviderPackageDetails> existingPackages) {
- Map<PackageDetailsKey, ContentProviderPackageDetails> map =
- new HashMap<PackageDetailsKey, ContentProviderPackageDetails>();
+ Map<PackageDetailsKey, ContentProviderPackageDetails> map = new HashMap<PackageDetailsKey, ContentProviderPackageDetails>();
if (existingPackages == null) {
return map;
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
index 56c21d4..04fdbba 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
@@ -49,7 +49,9 @@ import org.rhq.enterprise.server.plugin.pc.content.PackageSyncReport;
import org.rhq.enterprise.server.plugin.pc.content.RepoDetails;
import org.rhq.enterprise.server.plugin.pc.content.RepoImportReport;
import org.rhq.enterprise.server.plugin.pc.content.RepoSource;
+import org.rhq.enterprise.server.plugin.pc.content.SyncException;
import org.rhq.enterprise.server.plugin.pc.content.SyncProgressWeight;
+import org.rhq.enterprise.server.plugin.pc.content.ThreadUtil;
import org.rhq.enterprise.server.plugins.rhnhosted.certificate.Certificate;
import org.rhq.enterprise.server.plugins.rhnhosted.certificate.CertificateFactory;
import org.rhq.enterprise.server.plugins.rhnhosted.certificate.PublicKeyRing;
@@ -152,7 +154,7 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
* @inheritDoc
*/
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws Exception {
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException, InterruptedException {
log.info("synchronizePackages(repoName = " + repoName + ", report = " + report + ", existingPackages.size() = "
+ existingPackages.size());
RHNSummary summary = new RHNSummary(helper);
@@ -187,6 +189,7 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
long endTimeSlice = System.currentTimeMillis();
log.debug("Slice processed in " + (endTimeSlice - startTimeSlice) + "ms current size of pkgDetails is "
+ pkgDetails.size());
+ ThreadUtil.checkInterrupted();
}
long endTime = System.currentTimeMillis();
log.info("It took " + (endTime - startTime) + "ms too get PackageDetails for " + pkgIds.size()
@@ -202,6 +205,7 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
report.addNewPackage(p);
summary.added++;
}
+ ThreadUtil.checkInterrupted();
}
for (ContentProviderPackageDetails p : deletedPackages) {
log.debug("Package at (" + p.getDisplayName() + ") marked as deleted");
@@ -210,7 +214,7 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
}
} catch (Exception e) {
summary.errors.add(e.toString());
- throw e;
+ throw new SyncException("error synching packages.", e);
} finally {
//helper.disconnect();
summary.markEnded();
@@ -223,7 +227,7 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
* @inheritDoc
*/
public void synchronizeAdvisory(String repoName, AdvisorySyncReport report,
- Collection<AdvisoryDetails> existingAdvisory) throws Exception {
+ Collection<AdvisoryDetails> existingAdvisory) throws SyncException {
List<String> existingLabels = new ArrayList<String>();
for (AdvisoryDetails ad : existingAdvisory) {
@@ -233,17 +237,21 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
List<String> deletedAdvs = new ArrayList<String>(); //Existing advisories we want to remove.
deletedAdvs.addAll(existingLabels);
- List<String> errataIds = helper.getChannelAdvisory(repoName);
- List<AdvisoryDetails> advList = helper.getAdvisoryMetadata(errataIds, repoName);
- log.debug("Found " + advList.size() + " available errata");
- for (AdvisoryDetails adv : advList) {
- log.debug("Processing Advisory ::" + adv.getAdvisory());
- deletedAdvs.remove(adv.getAdvisory());
- if (!existingLabels.contains(adv.getAdvisory())) {
- log.debug("New Advisory " + adv.getAdvisory() + ") detected" + " with bugs" + adv.getBugs()
- + "with cves" + adv.getCVEs() + "wiuth packages" + adv.getPkgs());
- report.addAdvisory(adv);
+ try {
+ List<String> errataIds = helper.getChannelAdvisory(repoName);
+ List<AdvisoryDetails> advList = helper.getAdvisoryMetadata(errataIds, repoName);
+ log.debug("Found " + advList.size() + " available errata");
+ for (AdvisoryDetails adv : advList) {
+ log.debug("Processing Advisory ::" + adv.getAdvisory());
+ deletedAdvs.remove(adv.getAdvisory());
+ if (!existingLabels.contains(adv.getAdvisory())) {
+ log.debug("New Advisory " + adv.getAdvisory() + ") detected" + " with bugs" + adv.getBugs()
+ + "with cves" + adv.getCVEs() + "wiuth packages" + adv.getPkgs());
+ report.addAdvisory(adv);
+ }
}
+ } catch (Exception e) {
+ throw new SyncException("Error syncing advisory meta", e);
}
for (String adv : deletedAdvs) {
@@ -259,7 +267,7 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
* @inheritDoc
*/
public void synchronizeDistribution(String repoName, DistributionSyncReport report,
- Collection<DistributionDetails> existingDistros) throws Exception {
+ Collection<DistributionDetails> existingDistros) throws SyncException {
// Goal:
// This method will create the metadata representing what kickstart tree files need to be downloaded.
@@ -274,7 +282,12 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
List<String> deletedDistros = new ArrayList<String>(); //Existing distros we want to remove.
deletedDistros.addAll(existingLabels);
- List<String> availableLabels = helper.getSyncableKickstartLabels(repoName);
+ List<String> availableLabels;
+ try {
+ availableLabels = helper.getSyncableKickstartLabels(repoName);
+ } catch (Exception e) {
+ throw new SyncException("Error synching kickstart labels", e);
+ }
log.debug("Found " + availableLabels.size() + " available kickstart trees");
for (String label : availableLabels) {
log.debug("Processing kickstart: " + label);
@@ -294,7 +307,12 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
}
}
- List<DistributionDetails> ddList = helper.getDistributionMetaData(toSyncDistros);
+ List<DistributionDetails> ddList;
+ try {
+ ddList = helper.getDistributionMetaData(toSyncDistros);
+ } catch (Exception e) {
+ throw new SyncException("Error synching distro metadata", e);
+ }
report.addDistros(ddList);
}
diff --git a/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java b/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java
index 0af228e..c229a2b 100644
--- a/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java
+++ b/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java
@@ -38,6 +38,7 @@ 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.plugin.pc.content.SyncException;
import org.rhq.enterprise.server.plugin.pc.content.SyncProgressWeight;
import org.rhq.enterprise.server.plugins.url.RemotePackageInfo.SupportedPackageType;
@@ -176,7 +177,7 @@ public class UrlProvider implements ContentProvider, PackageSource {
}
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws Exception {
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException {
// put all existing packages in a "to be deleted" list. As we sync, we will remove
// packages from this list that still exist on the remote system. Any leftover in the list
@@ -187,9 +188,13 @@ public class UrlProvider implements ContentProvider, PackageSource {
// sync now
long before = System.currentTimeMillis();
- Map<String, RemotePackageInfo> locationList = getRemotePackageInfosFromIndex();
- for (RemotePackageInfo rpi : locationList.values()) {
- syncPackage(report, deletedPackages, rpi);
+ try {
+ Map<String, RemotePackageInfo> locationList = getRemotePackageInfosFromIndex();
+ for (RemotePackageInfo rpi : locationList.values()) {
+ syncPackage(report, deletedPackages, rpi);
+ }
+ } catch (Exception e) {
+ throw new SyncException("error synching packages", e);
}
long elapsed = System.currentTimeMillis() - before;
diff --git a/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java b/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
index 00bdb0f..36d000c 100644
--- a/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
+++ b/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
@@ -31,6 +31,7 @@ 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.PackageSource;
import org.rhq.enterprise.server.plugin.pc.content.PackageSyncReport;
+import org.rhq.enterprise.server.plugin.pc.content.SyncException;
import org.rhq.enterprise.server.plugin.pc.content.SyncProgressWeight;
/**
@@ -131,7 +132,7 @@ public class RepoProvider implements ContentProvider, PackageSource {
* @throws Exception On all errors.
*/
public void synchronizePackages(String repoName, PackageSyncReport report,
- Collection<ContentProviderPackageDetails> existingPackages) throws Exception {
+ Collection<ContentProviderPackageDetails> existingPackages) throws SyncException {
Summary summary = new Summary(reader);
log.info("synchronizing with repo: " + reader + " started");
try {
@@ -157,7 +158,7 @@ public class RepoProvider implements ContentProvider, PackageSource {
}
} catch (Exception e) {
summary.errors.add(e.toString());
- throw e;
+ throw new SyncException("error synching synchronizePackages", e);
} finally {
repo.disconnect();
summary.markEnded();
commit 8a0a2ac291b4fe17019c3622544d33be150477d1
Author: John Matthews <jmatthew(a)redhat.com>
Date: Tue Jan 19 10:01:44 2010 -0500
1358 - generate yum metadata from database entries, expose through http
tested yum install/list of packages through http content
diff --git a/modules/enterprise/gui/content_http-war/pom.xml b/modules/enterprise/gui/content_http-war/pom.xml
index 452c0ce..4bbad94 100644
--- a/modules/enterprise/gui/content_http-war/pom.xml
+++ b/modules/enterprise/gui/content_http-war/pom.xml
@@ -131,6 +131,12 @@
</dependency>
<dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.4</version>
+ </dependency>
+
+ <dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2</version>
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
index 9c4a712..e2f96f5 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -55,6 +55,7 @@ public class ContentHTTPServlet extends DefaultServlet {
protected static final String PACKAGES = "packages";
protected static final String DISTRIBUTIONS = "distributions";
+ protected static final String REPODATA = "repodata";
protected RepoManagerLocal repoMgr;
protected ContentManagerLocal contentMgr;
@@ -176,20 +177,29 @@ public class ContentHTTPServlet extends DefaultServlet {
log.info("Parsed file name = " + fileName);
if (StringUtils.isBlank(fileName)) {
// form a directory listing for each package in repository.
- log.info("TODO: create index.html listing all the packages for this repo: " + repo.getName());
+ log.info("create listing of all packages for this repo: " + repo.getName());
renderPackageIndex(request, response, repo);
return;
- } else {
- log.info("fetch package bits and return them.");
- PackageVersion pv = getPackageVersionFromFileName(repo, fileName);
- if (pv == null) {
- log.info("Unable to find PackageVersion from filename: " + fileName);
- renderErrorPage(request, response);
- return;
- }
- response.setContentType("application/octet-stream");
- writePackageVersionBits(response.getOutputStream(), pv);
}
+ /*
+ * This will likely change in a future sprint.
+ * For now we are assuming that metadata is only yum metadata
+ * and it's accessed as 'packages/repodata/primary.xml'
+ */
+ if (StringUtils.equals(fileName, REPODATA)) {
+ renderMetadata(request, response, repo);
+ return;
+ }
+
+ log.info("fetch package bits and return them.");
+ PackageVersion pv = getPackageVersionFromFileName(repo, fileName);
+ if (pv == null) {
+ log.info("Unable to find PackageVersion from filename: " + fileName);
+ renderErrorPage(request, response);
+ return;
+ }
+ response.setContentType("application/octet-stream");
+ writePackageVersionBits(response.getOutputStream(), pv);
}
protected void renderPackageIndex(HttpServletRequest request, HttpServletResponse response, Repo repo)
@@ -210,6 +220,46 @@ public class ContentHTTPServlet extends DefaultServlet {
writeResponse(sb.toString(), response);
}
+ protected void renderMetadata(HttpServletRequest request, HttpServletResponse response, Repo repo)
+ throws IOException {
+ log.info("renderMetadata(repo name = " + repo.getName() + ", id = " + repo.getId());
+
+ String metadataFilename = getMetadataFileName(request.getRequestURI());
+ if (StringUtils.isBlank(metadataFilename)) {
+ renderMetadataIndex(request, response, repo);
+ return;
+ }
+ // Generate Yum Metadata
+ log.info("Generate Yum Metadata for : " + metadataFilename);
+ List<PackageVersion> pvs = repoMgr.findPackageVersionsInRepo(LookupUtil.getSubjectManager().getOverlord(), repo
+ .getId(), PageControl.getUnlimitedInstance());
+ log.info(pvs.size() + " packages were found for repo : " + repo.getName());
+ StringBuffer sb = new StringBuffer();
+ if (!YumMetadata.generate(sb, repo, pvs, metadataFilename)) {
+ log.info("Error generating: " + metadataFilename + " for repo: " + repo.getName() + " with " + pvs.size()
+ + " packages");
+ renderErrorPage(request, response);
+ return;
+ }
+ writeResponse(sb.toString(), response, "text/xml; charset=utf-8");
+ }
+
+ protected void renderMetadataIndex(HttpServletRequest request, HttpServletResponse response, Repo repo)
+ throws IOException {
+ log.info("renderMetadataIndex(repo name = " + repo.getName() + ", id = " + repo.getId());
+
+ StringBuffer sb = new StringBuffer();
+ HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
+ HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
+
+ // We are only supporting 2 types of yum metadata
+ HtmlRenderer.formFileEntry(sb, request, "primary.xml", new Date().toString(), -1);
+ HtmlRenderer.formFileEntry(sb, request, "repomd.xml", new Date().toString(), -1);
+
+ HtmlRenderer.formEnd(sb);
+ writeResponse(sb.toString(), response);
+ }
+
protected void renderDistributions(HttpServletRequest request, HttpServletResponse response, Repo repo)
throws IOException {
log.info("renderDistributions(repo name = " + repo.getName() + ", id = " + repo.getId() + ", isCandidate = "
@@ -301,8 +351,12 @@ public class ContentHTTPServlet extends DefaultServlet {
}
protected boolean writeResponse(String data, HttpServletResponse response) throws IOException {
+ return writeResponse(data, response, "text/html");
+ }
- response.setContentType("text/html");
+ protected boolean writeResponse(String data, HttpServletResponse response, String contentType) throws IOException {
+
+ response.setContentType(contentType);
PrintWriter out = response.getWriter();
out.write(data);
out.flush();
@@ -360,6 +414,16 @@ public class ContentHTTPServlet extends DefaultServlet {
return getNthPiece(4, requestURI);
}
+ /**
+ *
+ * @param requestURI
+ * @return metadata file name or "" if no file name could be determined
+ */
+ protected String getMetadataFileName(String requestURI) {
+ // expecting something like '.../packages/repodata/primary.xml'
+ return getNthPiece(5, requestURI);
+ }
+
protected String getDistLabel(String requestURI) {
return getNthPiece(4, requestURI);
}
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/YumMetadata.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/YumMetadata.java
new file mode 100644
index 0000000..0210d53
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/YumMetadata.java
@@ -0,0 +1,167 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.gui.content;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.security.DigestInputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.List;
+import java.util.zip.GZIPInputStream;
+
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.content.PackageVersion;
+import org.rhq.core.domain.content.Repo;
+import org.rhq.core.util.stream.StreamUtil;
+
+public class YumMetadata {
+ final private static Log log = LogFactory.getLog(YumMetadata.class);
+
+ final public static String PRIMARY_XML = "primary.xml";
+ final public static String REPOMD_XML = "repomd.xml";
+
+ /*
+
+ This class is implementing a temporary way to grab yum metadata.
+ It's following the approach done by: org.rhq.plugins.platform.content.yum.Primary
+ In a future sprint this topic will be revisited and this approach should change.
+
+ Each package has the ability to store it's metadata in the database.
+ We are assuming the metadata was stored as a xml string which has been gzipped.
+ We'll grab this from the DB, uncompress, and adjust the "location" element.
+ Note: The location element is what yum will use to form the GET request to fetch the package.
+
+ All of these entries are added together to form the primary.xml
+ */
+
+ public static boolean generate(StringBuffer sb, Repo repo, List<PackageVersion> pvs, String filename) {
+ if (StringUtils.equalsIgnoreCase(filename, PRIMARY_XML)) {
+ generatePrimary(sb, repo, pvs);
+ return true;
+ }
+ if (StringUtils.equalsIgnoreCase(filename, REPOMD_XML)) {
+ return generateRepoMD(sb, repo, pvs);
+ }
+ return false;
+ }
+
+ protected static void generatePrimary(StringBuffer sb, Repo repo, List<PackageVersion> pvs) {
+ sb.append("<metadata xmlns=\"http://linux.duke.edu/metadata/common\" ");
+ sb.append("packages=\"" + pvs.size() + "\">\n");
+ sb.append("xmlns:rpm=\"http://linux.duke.edu/metadata/rpm\" ");
+ for (PackageVersion p : pvs) {
+ String metadata = unzip(p.getMetadata());
+ metadata = modifyLocation(metadata, repo.getName(), p.getFileName());
+ if (StringUtils.isBlank(metadata)) {
+ log.warn("No metadata for package : " + p.getDisplayName() + " not adding this to primary.xml");
+ continue;
+ }
+ sb.append(metadata + "\n");
+ }
+ sb.append("</metadata>");
+ }
+
+ protected static boolean generateRepoMD(StringBuffer sb, Repo repo, List<PackageVersion> pvs) {
+ StringBuffer primaryXML = new StringBuffer();
+ generatePrimary(primaryXML, repo, pvs);
+ sb.append("<repomd xmlns=\"http://linux.duke.edu/metadata/repo\">");
+ try {
+ writeRepoMDEntry(sb, "primary", getSHA(primaryXML), "0");
+ } catch (NoSuchAlgorithmException e) {
+ log.info(e);
+ return false;
+ } catch (IOException e) {
+ log.info(e);
+ return false;
+ }
+ sb.append("</repomd>");
+ return true;
+ }
+
+ protected static String getSHA(StringBuffer primaryXML) throws NoSuchAlgorithmException, IOException {
+ // Note: For RHEL6 this may need to change to "SHA-256",
+ // going for SHA for now, as it's a lowest common denominator so it can work with older clients.
+ MessageDigest md = MessageDigest.getInstance("SHA");
+ ByteArrayInputStream bis = new ByteArrayInputStream(primaryXML.toString().getBytes());
+ DigestInputStream mdistr = new DigestInputStream(bis, md);
+ while (mdistr.read() != -1) {
+ ;
+ }
+ mdistr.close();
+ return Hex.encodeHexString(md.digest());
+ }
+
+ protected static void writeRepoMDEntry(StringBuffer sb, String type, String sum, String ts) {
+ sb.append("\t<data type=\"" + type + "\">\n");
+ sb.append("\t<location href=\"repodata/" + type + ".xml\"/>\n");
+ sb.append("\t<checksum type=\"sha\">" + sum + "</checksum>\n");
+ sb.append("\t<timestamp>" + ts + "</timestamp>\n");
+ sb.append("\t</data>\n\n");
+ }
+
+ protected static String unzip(byte[] zippedMetadata) {
+ try {
+ ByteArrayInputStream bis = new ByteArrayInputStream(zippedMetadata);
+ ByteArrayOutputStream unzipped = new ByteArrayOutputStream();
+ GZIPInputStream gis = new GZIPInputStream(bis);
+ StreamUtil.copy(gis, unzipped);
+ return unzipped.toString();
+ } catch (IOException e) {
+ log.warn(e);
+ return "";
+ }
+ }
+
+ protected static String modifyLocation(String metadata, String repoName, String filename) {
+ /**
+ * We will wipe out the current <location href=""> and insert our own which has the package filename.
+ *
+ * Note: this might be a redundant step for content synced from RHN Hosted, yet to avoid cases where the
+ * location might not be what we want, we'll always drop it and put the filename in so we are guaranteed it's
+ * correct.
+ */
+ final String START_STR = "<location ";
+ final String END_STR = "/>";
+
+ int startIndex = metadata.indexOf(START_STR);
+ if (startIndex == -1) {
+ log.info("Unable to find " + START_STR + " in metadata.");
+ return metadata;
+ }
+ // adjust startIndex to point to after START_STR
+ startIndex = startIndex + START_STR.length();
+ int endIndex = metadata.indexOf(END_STR, startIndex);
+ if (endIndex == -1) {
+ log.info("Unable to find " + END_STR + " in metadata.");
+ return metadata;
+ }
+
+ String partA = metadata.substring(0, startIndex);
+ String partB = metadata.substring(endIndex);
+
+ String href = " href=\"" + filename + "\"";
+ return partA + href + partB;
+ }
+}
commit 95922e034c4bbce4a9e976f765c115af5f3d4f76
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Tue Jan 19 09:42:24 2010 -0500
1424 - Work towards content web service APIs -- remove cyclical dependencies
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryBuglist.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryBuglist.java
index cff35be..ab4f537 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryBuglist.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryBuglist.java
@@ -36,9 +36,10 @@ import javax.persistence.NamedQuery;
import javax.persistence.PrePersist;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlTransient;
/**
- * This is the entity mapping that correlates an advisory with associated bugid.
+ * This is the entity mapping that correlates an advisory with associated bugid.
*
* @author Pradeep Kilambi
*/
@@ -68,6 +69,7 @@ public class AdvisoryBuglist implements Serializable {
@Id
private int id;
+ @XmlTransient
@ManyToOne
@JoinColumn(name = "ADVISORY_ID", referencedColumnName = "ID", nullable = false)
private Advisory advisory;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java
index a87d997..bc9ad68 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryCVE.java
@@ -36,9 +36,10 @@ import javax.persistence.NamedQuery;
import javax.persistence.PrePersist;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlTransient;
/**
- * This is the many-to-many entity that correlates an advisory with a package.
+ * This is the many-to-many entity that correlates an advisory with a package.
*
* @author Pradeep Kilambi
*/
@@ -65,6 +66,7 @@ public class AdvisoryCVE implements Serializable {
@Id
private int id;
+ @XmlTransient
@ManyToOne
@JoinColumn(name = "ADVISORY_ID", referencedColumnName = "ID", nullable = false)
private Advisory advisory;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryPackage.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryPackage.java
index c2b6d30..17bd2d8 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryPackage.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/AdvisoryPackage.java
@@ -36,9 +36,10 @@ import javax.persistence.NamedQuery;
import javax.persistence.PrePersist;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlTransient;
/**
- * This is the many-to-many entity that correlates an advisory with a package.
+ * This is the many-to-many entity that correlates an advisory with a package.
*
* @author Pradeep Kilambi
*/
@@ -69,6 +70,7 @@ public class AdvisoryPackage implements Serializable {
@Id
private int id;
+ @XmlTransient
@ManyToOne
@JoinColumn(name = "ADVISORY_ID", referencedColumnName = "ID", nullable = false)
private Advisory advisory;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java
index 6826442..0ba61b0 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/DistributionFile.java
@@ -37,6 +37,7 @@ import javax.persistence.NamedQuery;
import javax.persistence.PrePersist;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlTransient;
/**
* This is the many-to-many entity that correlates a distribution with its associated files.
@@ -67,6 +68,7 @@ public class DistributionFile {
@Id
private int id;
+ @XmlTransient
@JoinColumn(name = "DISTRIBUTION_ID", referencedColumnName = "ID", nullable = false)
@ManyToOne(cascade = { CascadeType.MERGE, CascadeType.PERSIST })
private Distribution distribution;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
index 5f4061c..1180f6e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
@@ -46,6 +46,7 @@ import javax.persistence.PreUpdate;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
+import javax.xml.bind.annotation.XmlTransient;
import org.rhq.core.domain.common.Tag;
import org.rhq.core.domain.common.Taggable;
@@ -169,9 +170,11 @@ public class Repo implements Serializable, Taggable {
// latest appears first, oldest last
private List<RepoSyncResults> syncResults;
+ @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Set<RepoDistribution> repoDistributions;
+ @XmlTransient
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Set<RepoAdvisory> repoAdvisories;
@@ -382,13 +385,13 @@ public class Repo implements Serializable, Taggable {
/**
* Get the overall sync status of this Repository. This is a summation of all the syncs.
- *
+ *
* There is a weight to the status since this returns the most 'relevant' status:
- *
+ *
* 1) ContentSourceSyncStatus.FAILURE
* 2) ContentSourceSyncStatus.INPROGRESS
* 3) ContentSourceSyncStatus.SUCCESS
- *
+ *
* @return String summary of the status of this Repository
*/
@Transient
@@ -819,7 +822,7 @@ public class Repo implements Serializable, Taggable {
}
/**
- * Removes association with a tag, if it exists.
+ * Removes association with a tag, if it exists.
*/
public void removeTag(Tag tag) {
if ((this.repoTags == null) || (tag == null)) {
commit daf920f22a6f325d98534761f58074130520b207
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Mon Jan 18 15:03:51 2010 -0500
Removed unnecessary method; was replaced by retrieving the distribution files and getting their bits.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
index 56082a3..14dc8fb 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerBean.java
@@ -110,11 +110,6 @@ public class DistributionManagerBean implements DistributionManagerLocal, Distri
}
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public void getDistributionBits(Subject user, String kslabel) {
- //TODO: Implement the ks tree bit downloads
- }
-
@SuppressWarnings("unchecked")
public Distribution getDistributionByLabel(String kslabel) {
Query query = entityManager.createNamedQuery(Distribution.QUERY_FIND_BY_DIST_LABEL);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java
index 89e40a2..8528da8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerLocal.java
@@ -47,7 +47,7 @@ public interface DistributionManagerLocal {
/**
* Deletes a given instance of distribution object. If the object does not exist
- * @param subject
+ * @param subject
* @param repoId
*/
void deleteDistributionMappingsForRepo(Subject subject, int repoId);
@@ -60,14 +60,6 @@ public interface DistributionManagerLocal {
void deleteDistributionByDistId(Subject subject, int distId);
/**
- * get the kickstart tree bits either from database or filesystem based on kickstart label
- * @param subject
- * @param kslabel
- * @return
- */
- void getDistributionBits(Subject subject, String kslabel);
-
- /**
* get distribution based on a given label
* @param kslabel distribution tree label
* @return kickstart tree object
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java
index 00be58b..bebd3a1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/DistributionManagerRemote.java
@@ -67,16 +67,6 @@ public interface DistributionManagerRemote {
@WebParam(name = "distId") int distId) throws Exception;
/**
- * get the kickstart tree bits either from database or filesystem based on kickstart label
- * @param subject
- * @param kslabel
- * @return
- */
- @WebMethod
- void getDistributionBits(@WebParam(name = "subject") Subject subject, //
- @WebParam(name = "kslabel") String kslabel) throws Exception;
-
- /**
* get kickstart tree based on a given label
* @param kslabel kickstart tree label
* @return kickstart tree object
commit 8e734d142794008ba3def73f187741ec313d38e0
Author: John Matthews <jmatthew(a)redhat.com>
Date: Fri Jan 15 18:41:13 2010 -0500
1357 - adding support to browse/download distribution files
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
index b5b3604..9c4a712 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -35,6 +35,8 @@ 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.Distribution;
+import org.rhq.core.domain.content.DistributionFile;
import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
@@ -42,6 +44,7 @@ import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.content.ContentManagerLocal;
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.util.LookupUtil;
@@ -56,6 +59,7 @@ public class ContentHTTPServlet extends DefaultServlet {
protected RepoManagerLocal repoMgr;
protected ContentManagerLocal contentMgr;
protected ContentSourceManagerLocal contentSourceMgr;
+ protected DistributionManagerLocal distroMgr;
public ContentHTTPServlet() {
super();
@@ -66,6 +70,7 @@ public class ContentHTTPServlet extends DefaultServlet {
repoMgr = LookupUtil.getRepoManagerLocal();
contentMgr = LookupUtil.getContentManager();
contentSourceMgr = LookupUtil.getContentSourceManager();
+ distroMgr = LookupUtil.getDistributionManagerLocal();
log.info("ContentHTTPServlet resolved references in init.");
}
@@ -142,7 +147,7 @@ public class ContentHTTPServlet extends DefaultServlet {
// Skip candidate repos
if (!r.isCandidate()) {
String lastMod = new Date(r.getLastModifiedDate()).toString();
- HtmlRenderer.formDirEntry(request, sb, r.getName(), lastMod);
+ HtmlRenderer.formDirEntry(sb, request, r.getName(), lastMod);
}
}
HtmlRenderer.formEnd(sb);
@@ -155,8 +160,8 @@ public class ContentHTTPServlet extends DefaultServlet {
StringBuffer sb = new StringBuffer();
HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
- HtmlRenderer.formDirEntry(request, sb, PACKAGES, "-");
- HtmlRenderer.formDirEntry(request, sb, DISTRIBUTIONS, "-");
+ HtmlRenderer.formDirEntry(sb, request, PACKAGES, "-");
+ HtmlRenderer.formDirEntry(sb, request, DISTRIBUTIONS, "-");
HtmlRenderer.formEnd(sb);
writeResponse(sb.toString(), response);
}
@@ -183,7 +188,7 @@ public class ContentHTTPServlet extends DefaultServlet {
return;
}
response.setContentType("application/octet-stream");
- writePackageVersionBits(pv, response.getOutputStream());
+ writePackageVersionBits(response.getOutputStream(), pv);
}
}
@@ -198,7 +203,7 @@ public class ContentHTTPServlet extends DefaultServlet {
HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
for (PackageVersion pv : pvs) {
- HtmlRenderer.formFileEntry(request, sb, pv.getFileName(), new Date(pv.getFileCreatedDate()).toString(), pv
+ HtmlRenderer.formFileEntry(sb, request, pv.getFileName(), new Date(pv.getFileCreatedDate()).toString(), pv
.getFileSize());
}
HtmlRenderer.formEnd(sb);
@@ -207,10 +212,85 @@ public class ContentHTTPServlet extends DefaultServlet {
protected void renderDistributions(HttpServletRequest request, HttpServletResponse response, Repo repo)
throws IOException {
+ log.info("renderDistributions(repo name = " + repo.getName() + ", id = " + repo.getId() + ", isCandidate = "
+ + repo.isCandidate() + ")");
+
+ String distLabel = getDistLabel(request.getRequestURI());
+ log.info("Parsed dist label is = " + distLabel);
+ if (StringUtils.isBlank(distLabel)) {
+ // form a directory listing for each distribution in repository.
+ log.info("TODO: create index.html listing all the distribution labels for this repo: " + repo.getName());
+ renderDistributionLabels(request, response, repo);
+ return;
+ }
+ // Get Distribution
+ Distribution dist = distroMgr.getDistributionByLabel(distLabel);
+ if (dist == null) {
+ log.info("Unable to find Distribution by label '" + distLabel + "'");
+ renderErrorPage(request, response);
+ return;
+ }
+ String fileRequest = getDistFilePath(request.getRequestURI());
+ if (StringUtils.isEmpty(fileRequest)) {
+ log.info("no distribution file was found in request, so render list of all distribution files");
+ renderDistributionFileList(request, response, dist);
+ return;
+ }
+ log.info("Parsed DistributionFile request is for: " + fileRequest);
+ // Looks like a request for a distribution file
+ List<DistributionFile> distFiles = distroMgr.getDistributionFilesByDistId(dist.getId());
+ if (distFiles.isEmpty()) {
+ log.info("Unable to find any distribution files for dist: " + dist.getLabel());
+ renderErrorPage(request, response);
+ return;
+ }
+ for (DistributionFile dFile : distFiles) {
+ log.info("Compare: " + dFile.getRelativeFilename() + " to " + fileRequest);
+ if (StringUtils.equalsIgnoreCase(dFile.getRelativeFilename(), fileRequest)) {
+ response.setContentType("application/octet-stream");
+ writeDistributionFileBits(response.getOutputStream(), dFile);
+ return;
+ }
+ }
+ log.info("Searched through DistributionFiles and unable to find: " + fileRequest + ", in Distribution: "
+ + dist.getLabel());
+
+ renderErrorPage(request, response);
+
+ }
+
+ protected void renderDistributionFileList(HttpServletRequest request, HttpServletResponse response,
+ Distribution dist) throws IOException {
+
+ List<DistributionFile> distFiles = distroMgr.getDistributionFilesByDistId(dist.getId());
+ log.info("For Distribution label '" + dist.getLabel() + "' " + distFiles.size()
+ + " distribution files were found");
+
+ StringBuffer sb = new StringBuffer();
+ HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
+ HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
+ for (DistributionFile dFile : distFiles) {
+ HtmlRenderer.formFileEntry(sb, request, dFile.getRelativeFilename(), new Date(dFile.getLastModified())
+ .toString(), -1);
+ }
+ HtmlRenderer.formEnd(sb);
+ writeResponse(sb.toString(), response);
+ }
+
+ protected void renderDistributionLabels(HttpServletRequest request, HttpServletResponse response, Repo repo)
+ throws IOException {
StringBuffer sb = new StringBuffer();
HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
+ // Get list of Distributions per repo
+ List<Distribution> distros = repoMgr.findAssociatedDistributions(LookupUtil.getSubjectManager().getOverlord(),
+ repo.getId(), PageControl.getUnlimitedInstance());
+ log.info("Found " + distros.size() + " for repo " + repo.getName());
+ for (Distribution d : distros) {
+ log.info("Creating link for distribution label: " + d.getLabel());
+ HtmlRenderer.formDirEntry(sb, request, d.getLabel(), new Date(d.getLastModifiedDate()).toString());
+ }
HtmlRenderer.formEnd(sb);
writeResponse(sb.toString(), response);
}
@@ -280,6 +360,37 @@ public class ContentHTTPServlet extends DefaultServlet {
return getNthPiece(4, requestURI);
}
+ protected String getDistLabel(String requestURI) {
+ return getNthPiece(4, requestURI);
+ }
+
+ /**
+ *
+ * @param requestURI
+ * @return
+ */
+ protected String getDistFilePath(String requestURI) {
+ // Goal is we find where the distribution file path starts
+ // then we return the entire path, it may include an unknown
+ // level of sub-directories.
+ StrTokenizer st = new StrTokenizer(requestURI, "/");
+ List<String> tokens = st.getTokenList();
+ if (tokens.isEmpty()) {
+ return "";
+ }
+ int startIndex = 4;
+ String distFilePath = "";
+ for (int index = startIndex; index < tokens.size(); index++) {
+ distFilePath = distFilePath + "/" + tokens.get(index);
+ log.info("index = " + index + ", distFilePath = " + distFilePath);
+ }
+ // Remove the '/' we added to the front of this string
+ if (distFilePath.startsWith("/")) {
+ distFilePath = distFilePath.substring(1);
+ }
+ return distFilePath;
+ }
+
/**
* @param n nth element to return from requestURI, (first element corresponds to 1, not 0)
* @param requestURI
@@ -326,7 +437,24 @@ public class ContentHTTPServlet extends DefaultServlet {
return pv;
}
- protected boolean writePackageVersionBits(PackageVersion pkgVer, ServletOutputStream output) {
+ protected boolean writeDistributionFileBits(ServletOutputStream output, DistributionFile distFile)
+ throws IOException {
+
+ try {
+ contentSourceMgr.outputDistributionFileBits(distFile, output);
+ output.flush();
+ output.close();
+ } catch (IllegalStateException e) {
+ log.error(e);
+ return false;
+ } catch (IOException e) {
+ log.error(e);
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean writePackageVersionBits(ServletOutputStream output, PackageVersion pkgVer) {
try {
contentSourceMgr.outputPackageVersionBits(pkgVer, output);
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java
index 0b47d95..1d52ae7 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java
@@ -66,11 +66,11 @@ public class HtmlRenderer {
public static String formDirEntry(HttpServletRequest request, String dirName, String lastMod) {
StringBuffer sb = new StringBuffer();
- formDirEntry(request, sb, dirName, lastMod);
+ formDirEntry(sb, request, dirName, lastMod);
return sb.toString();
}
- public static void formDirEntry(HttpServletRequest request, StringBuffer sb, String dirName, String lastMod) {
+ public static void formDirEntry(StringBuffer sb, HttpServletRequest request, String dirName, String lastMod) {
if (!dirName.endsWith("/")) {
dirName = dirName + "/";
}
@@ -82,16 +82,22 @@ public class HtmlRenderer {
public static String formFileEntry(HttpServletRequest request, String fileName, String lastModDate, long fileSize) {
StringBuffer sb = new StringBuffer();
- formFileEntry(request, sb, fileName, lastModDate, fileSize);
+ formFileEntry(sb, request, fileName, lastModDate, fileSize);
return sb.toString();
}
- public static void formFileEntry(HttpServletRequest request, StringBuffer sb, String fileName, String lastMod,
+ public static void formFileEntry(StringBuffer sb, HttpServletRequest request, String fileName, String lastMod,
long fileSize) {
+
+ String fSize = new Long(fileSize).toString();
+ if (fileSize < 0) {
+ fSize = "-";
+ }
sb.append("<tr><td valign=\"top\"><img src=\"" + getIconPath("/icons/unknown.gif")
+ "\" alt=\"[DIR]\" width=\"20\" height=\"22\"></td>\n");
sb.append("<td><a href=\"" + getLink(request, fileName) + "\">" + fileName + "</a></td>\n");
- sb.append("<td align=\"right\">" + lastMod + "</td><td align=\"right\"> - </td><td> </td></tr>\n");
+ sb.append("<td align=\"right\">" + lastMod + "</td><td align=\"right\">" + fSize
+ + "</td><td> </td></tr>\n");
}
protected static String getIconPath(String path) {
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 fbfaedb..09aad7e 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
@@ -2068,4 +2068,33 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
return packageBitsFile;
}
+
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ @TransactionTimeout(45 * 60)
+ public long outputDistributionFileBits(DistributionFile distFile, OutputStream outputStream) {
+
+ long numBytes = 0;
+ InputStream bitStream = null;
+ try {
+ Distribution dist = distFile.getDistribution();
+ log.info("Distribution has a basePath of " + dist.getBasePath());
+ String distFilePath = dist.getBasePath() + "/" + distFile.getRelativeFilename();
+ File f = getDistributionFileBitsLocalFilesystemFile(dist.getLabel(), distFilePath);
+ log.info("Fetching: " + distFilePath + " on local file store from: " + f.getAbsolutePath());
+ bitStream = new FileInputStream(f);
+ numBytes = StreamUtil.copy(bitStream, outputStream);
+
+ } catch (Exception e) {
+ log.info(e);
+ } finally {
+ // close our stream but leave the output stream open
+ try {
+ bitStream.close();
+ } catch (Exception closeError) {
+ log.warn("Failed to close the bits stream", closeError);
+ }
+ }
+ log.debug("Retrieved and sent [" + numBytes + "] bytes for [" + distFile.getRelativeFilename() + "]");
+ return numBytes;
+ }
}
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 5fa9fa3..cc742e7 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
@@ -30,6 +30,7 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.content.ContentSource;
import org.rhq.core.domain.content.ContentSourceSyncResults;
import org.rhq.core.domain.content.ContentSourceType;
+import org.rhq.core.domain.content.DistributionFile;
import org.rhq.core.domain.content.DownloadMode;
import org.rhq.core.domain.content.PackageBits;
import org.rhq.core.domain.content.PackageDetailsKey;
@@ -576,6 +577,20 @@ public interface ContentSourceManagerLocal {
long outputPackageVersionBits(PackageVersion packageVersion, OutputStream outputStream);
/**
+ * Requests the bits of a distribution file be streamed down to the caller over the given output stream.
+ * This method will <b>not</b> take care of closing the stream when it is finished;
+ * it is the caller's responsibility.
+ *
+ * @param distFile distribution file to fetch
+ * @param outputStream an output stream where the server should write the package contents. It is up to the
+ * caller to prepare this output stream in order to write the package content to an
+ * appropriate location.
+ *
+ * @return the number of bytes written to the output stream
+ */
+ long outputDistributionFileBits(DistributionFile distFile, OutputStream outputStream);
+
+ /**
* Adds the specified content source to the database but does not attempt to create or start
* the server-side plugin provider implementation associated with it.
* <p/>
commit 74bb7ee71f05a2d58f28322fe247c5383339fea1
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Fri Jan 15 15:20:57 2010 -0500
Added the database keys to the schema to help the plugin writer.
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
index 5a6473e..9d09ba1 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
@@ -245,7 +245,8 @@ public class ConfigurationMetadataParser {
.deCamelCase(dynamicProperty.getName());
PropertyDefinitionDynamic property = new PropertyDefinitionDynamic(dynamicProperty.getName(), description,
- dynamicProperty.isRequired(), PropertyDynamicType.DATABASE, dynamicProperty.getDatabaseBacking().getKey());
+ dynamicProperty.isRequired(), PropertyDynamicType.DATABASE,
+ dynamicProperty.getDatabaseBacking().getKey().value());
property.setReadOnly(dynamicProperty.isReadOnly());
property.setSummary(dynamicProperty.isSummary());
diff --git a/modules/core/client-api/src/main/resources/rhq-configuration.xsd b/modules/core/client-api/src/main/resources/rhq-configuration.xsd
index e6c479d..869de57 100644
--- a/modules/core/client-api/src/main/resources/rhq-configuration.xsd
+++ b/modules/core/client-api/src/main/resources/rhq-configuration.xsd
@@ -232,14 +232,21 @@
<xs:documentation>Configures a property to look up values from the database.</xs:documentation>
</xs:annotation>
- <xs:attribute name="key" type="xs:string" use="required">
+ <xs:attribute name="key" type="config:databaseBackingKeys" use="required">
<xs:annotation>
<xs:documentation>Key RHQ will use to determine what values to retieve from the database.</xs:documentation>
</xs:annotation>
</xs:attribute>
-
</xs:complexType>
+ <xs:simpleType name="databaseBackingKeys">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="users"/>
+ <xs:enumeration value="roles"/>
+ <xs:enumeration value="package-types"/>
+ </xs:restriction>
+ </xs:simpleType>
+
<xs:element name="simple-property" type="config:simpleProperty" substitutionGroup="config:configuration-property"/>
<xs:complexType name="simpleProperty">
<xs:complexContent>
commit fe67a23b0b7df690999fe8fc0300b0c2e6a816f6
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Fri Jan 15 11:05:41 2010 -0500
Updated to more fully exercise the options available when defining properties.
diff --git a/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
index b7f98cb..2d3161e 100644
--- a/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -19,21 +19,24 @@
<c:simple-property name="rootDirectory" type="directory" required="true"
description="The root directory that contains all content that is to be served by this content provider. In an HA environment, this must be on a distributed file system that all servers can access."/>
- <c:dynamic-property name="users" description="TEST - List of all users in the system.">
+ <c:dynamic-property name="users" displayName="User Display Name" description="TEST - List of all users in the system."
+ required="true" activationPolicy="shutdown">
<c:database-backing key="users"/>
</c:dynamic-property>
-<!-- <c:dynamic-property name="roles" description="TEST - List of all roles in the system.">
+ <c:dynamic-property name="roles" description="TEST - List of all roles in the system."
+ readOnly="true" required="false">
<c:database-backing key="roles"/>
</c:dynamic-property>
- <c:dynamic-property name="packageTypes" description="TEST - List of all package types in the system.">
+ <c:dynamic-property name="packageTypes" description="TEST - List of all package types in the system."
+ required="false" summary="true">
<c:database-backing key="package-types"/>
- </c:dynamic-property>-->
+ </c:dynamic-property>
</c:group>
<c:group name="Package Source">
- <c:simple-property name="packageSourceEnabled" required="true" summary="true" default="true"
+ <c:simple-property name="packageSourceEnabled" required="true" summary="true" default="true" readOnly="true"
type="boolean" description="Indicates if this instance of the plugin should act as a package source"/>
<c:simple-property name="filenameFilter" required="true" summary="true" default=".*"
description="A regular expression that identifies a file of this package type (e.g. '.*\.jar', '.*/i686/.*\.rpm$')"/>
commit 03963af2d460248c9b6dee0ce235fb67a3f39ba8
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Fri Jan 15 11:05:22 2010 -0500
Fixed required indicator not appearing for dynamic configuration properties.
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
index 03d01c3..c73205a 100644
--- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
@@ -360,8 +360,10 @@ public class PropertyRenderingUtility {
Property property, boolean configReadOnly) {
String displayName = (propertyDefinition != null) ? propertyDefinition.getDisplayName() : property.getName();
FacesComponentUtility.addOutputText(parent, null, displayName, CssStyleClasses.PROPERTY_DISPLAY_NAME_TEXT);
- if (!configReadOnly && propertyDefinition != null && propertyDefinition.isRequired()
- && (propertyDefinition instanceof PropertyDefinitionSimple)) {
+ if (!configReadOnly && propertyDefinition != null &&
+ propertyDefinition.isRequired() &&
+ (propertyDefinition instanceof PropertyDefinitionSimple ||
+ propertyDefinition instanceof PropertyDefinitionDynamic) ) {
// Print a required marker next to required simples.
// Ignore the required field for maps and lists, as it is has no significance for them.
FacesComponentUtility.addOutputText(parent, null, " * ", CssStyleClasses.REQUIRED_MARKER_TEXT);
commit 2612b772597ed556e7655514218cdbe54a28f97b
Author: John Matthews <jmatthew(a)redhat.com>
Date: Thu Jan 14 18:09:18 2010 -0500
1357 - update to how we render links
fixes a problem I saw while testing, after I traversed back from a page using the parent link
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
index d301413..b5b3604 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -48,7 +48,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class ContentHTTPServlet extends DefaultServlet {
private final Log log = LogFactory.getLog(ContentHTTPServlet.class);
- protected static final String CONTENT_URI = "/content";
+ protected static final String CONTENT_URI = "/content/";
protected static final String PACKAGES = "packages";
protected static final String DISTRIBUTIONS = "distributions";
@@ -77,13 +77,15 @@ public class ContentHTTPServlet extends DefaultServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
log.info("doGet(): requestURI = " + request.getRequestURI());
if (isIconRequest(request)) {
+ // this request is for our icons which are static content in the webapp
+ // defer back to DefaultServlet.doGet and this will be served automatically
super.doGet(request, response);
return;
}
// Check if repo has been specified
Repo repo = getRepo(request, response);
if (repo == null) {
- log.info("No repo found so we'll render a list of all repos.");
+ log.info("No repo found, possibly bad repo name, or no name was entered.");
renderRepoList(request, response);
return;
}
@@ -196,7 +198,7 @@ public class ContentHTTPServlet extends DefaultServlet {
HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
for (PackageVersion pv : pvs) {
- HtmlRenderer.formFileEntry(sb, pv.getFileName(), new Date(pv.getFileCreatedDate()).toString(), pv
+ HtmlRenderer.formFileEntry(request, sb, pv.getFileName(), new Date(pv.getFileCreatedDate()).toString(), pv
.getFileSize());
}
HtmlRenderer.formEnd(sb);
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java
index f1f0826..0b47d95 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java
@@ -76,24 +76,41 @@ public class HtmlRenderer {
}
sb.append("<tr><td valign=\"top\"><img src=\"" + getIconPath("/icons/folder.gif")
+ "\" alt=\"[DIR]\" width=\"20\" height=\"22\"></td>\n");
- sb.append("<td><a href=\"" + request.getRequestURI() + "/" + dirName + "\">" + dirName + "</a></td>\n");
+ sb.append("<td><a href=\"" + getLink(request, dirName) + "\">" + dirName + "</a></td>\n");
sb.append("<td align=\"right\">" + lastMod + "</td><td align=\"right\"> - </td><td> </td></tr>\n");
}
- public static String formFileEntry(String fileName, String lastModDate, long fileSize) {
+ public static String formFileEntry(HttpServletRequest request, String fileName, String lastModDate, long fileSize) {
StringBuffer sb = new StringBuffer();
- formFileEntry(sb, fileName, lastModDate, fileSize);
+ formFileEntry(request, sb, fileName, lastModDate, fileSize);
return sb.toString();
}
- public static void formFileEntry(StringBuffer sb, String fileName, String lastMod, long fileSize) {
+ public static void formFileEntry(HttpServletRequest request, StringBuffer sb, String fileName, String lastMod,
+ long fileSize) {
sb.append("<tr><td valign=\"top\"><img src=\"" + getIconPath("/icons/unknown.gif")
+ "\" alt=\"[DIR]\" width=\"20\" height=\"22\"></td>\n");
- sb.append("<td><a href=\"" + fileName + "\">" + fileName + "</a></td>\n");
+ sb.append("<td><a href=\"" + getLink(request, fileName) + "\">" + fileName + "</a></td>\n");
sb.append("<td align=\"right\">" + lastMod + "</td><td align=\"right\"> - </td><td> </td></tr>\n");
}
protected static String getIconPath(String path) {
+ if (!ContentHTTPServlet.CONTENT_URI.endsWith("/")) {
+ if (!path.startsWith("/")) {
+ path = "/" + path;
+ }
+ }
return ContentHTTPServlet.CONTENT_URI + path;
}
+
+ protected static String getLink(HttpServletRequest request, String path) {
+ String reqUri = request.getRequestURI();
+ if (!reqUri.endsWith("/")) {
+ reqUri = reqUri + "/"; // we need to ensure this ends with a "/"
+ }
+ if (path.startsWith("/")) {
+ path = path.substring(1); // this is just to make the link look nice, it's not "needed"
+ }
+ return reqUri + path;
+ }
}
commit 5649627a5d942e7185d5f0ff7c31112cf9d8fa65
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Thu Jan 14 14:15:31 2010 -0800
Fixing unit test and adding hacked ejb exception class to help testing
Added src/test/java/javax/ejb/EJBTransactionRolledbackException.java to
assist finding source of exceptions in our SLSB classes.
diff --git a/.classpath b/.classpath
index 527d92e..020776a 100644
--- a/.classpath
+++ b/.classpath
@@ -20,7 +20,7 @@
<classpathentry kind="var" path="M2_REPO/org/jboss/integration/jboss-profileservice-spi/5.1.0.SP1/jboss-profileservice-spi-5.1.0.SP1.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-managed/2.1.1.GA/jboss-managed-2.1.1.GA.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/man/jboss-metatype/2.1.1.GA/jboss-metatype-2.1.1.GA.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.jar" sourcepath="/M2_REPO/commons-io/commons-io/1.3.1/commons-io-1.3.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/com/sun/xml/bind/jaxb-impl/2.1.6/jaxb-impl-2.1.6.jar"/>
<classpathentry kind="src" path="modules/core/util/src/main/java"/>
<classpathentry kind="src" path="modules/core/util/src/test/java"/>
diff --git a/modules/enterprise/server/jar/src/test/java/javax/ejb/EJBTransactionRolledbackException.java b/modules/enterprise/server/jar/src/test/java/javax/ejb/EJBTransactionRolledbackException.java
new file mode 100644
index 0000000..a50c4d2
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/javax/ejb/EJBTransactionRolledbackException.java
@@ -0,0 +1,58 @@
+/*
+ * 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 javax.ejb;
+
+/**
+ * This was placed into our source tree to get around the fact jboss-ejb3-all-1.0.0.Alpha9.jar
+ * expects this constructor:
+ *
+ * public EJBTransactionRolledbackException(Exception ex) {
+ * super(ex);
+ * }
+ *
+ * but jboss-ejb3x-4.2.3.GA.jar which shows up in the classpath first
+ * does not provide this implementation.
+ *
+ * Without this unit tests will often blow up with:
+ *
+ * javax.ejb.EJBTransactionRolledbackException: method <init>(Ljava/lang/Exception;)V not found
+ *
+ * and you are left scratching your head as to why it failed. This is only used in our unit
+ * test runs.
+ *
+ * @author mmccune
+ *
+ */
+public class EJBTransactionRolledbackException extends EJBException {
+
+ public EJBTransactionRolledbackException() {
+ }
+
+ public EJBTransactionRolledbackException(String message) {
+ super(message);
+ }
+
+ public EJBTransactionRolledbackException(String message, Exception ex) {
+ super(message, ex);
+ }
+
+ public EJBTransactionRolledbackException(Exception ex) {
+ super(ex);
+ }
+}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
index bf7657a..be68961 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
@@ -25,7 +25,6 @@ import java.util.Random;
import java.util.Set;
import javax.persistence.EntityManager;
-import javax.transaction.TransactionManager;
import org.apache.commons.lang.RandomStringUtils;
import org.testng.annotations.AfterMethod;
@@ -64,25 +63,23 @@ public class RepoManagerBeanTest extends AbstractEJB3Test {
@BeforeMethod
public void setupBeforeMethod() throws Exception {
- TransactionManager tx = getTransactionManager();
- tx.begin();
+ overlord = LookupUtil.getSubjectManager().getOverlord();
+ prepareScheduler();
repoManager = LookupUtil.getRepoManagerLocal();
contentSourceManager = LookupUtil.getContentSourceManager();
contentSourceMetadataManager = LookupUtil.getContentSourceMetadataManager();
TestContentServerPluginService pluginService = new TestContentServerPluginService(this);
- overlord = LookupUtil.getSubjectManager().getOverlord();
+ getTransactionManager().begin();
+
}
@AfterMethod
public void tearDownAfterMethod() throws Exception {
unprepareServerPluginService();
-
- TransactionManager tx = getTransactionManager();
- if (tx != null) {
- tx.rollback();
- }
+ unprepareScheduler();
+ getTransactionManager().rollback();
}
@Test(enabled = ENABLED)
commit 4d7c2ae1b9788610f12311c07c19432949bbb475
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Thu Jan 14 16:07:32 2010 -0500
1348 - Changes to allow dynamic configuration property values to be retrieved and displayed. Enterprise additions to support database backed values. Additions to disk plugin as an example.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
index 7c2af68..3615a6a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
@@ -71,7 +71,7 @@ import org.rhq.core.domain.resource.ResourceType;
+ "JOIN pt.resourceType rt "
+ "LEFT JOIN FETCH pt.deploymentConfigurationDefinition cd "
+ "LEFT JOIN FETCH cd.templates cts " + "WHERE rt.id = :typeId AND pt.isCreationData = true"),
- @NamedQuery(name = PackageType.QUERY_DYNAMIC_CONFIG_VALUES, query = "SELECT pt.name FROM PackageType AS pt")
+ @NamedQuery(name = PackageType.QUERY_DYNAMIC_CONFIG_VALUES, query = "SELECT pt.displayName FROM PackageType AS pt")
})
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_PACKAGE_TYPE_ID_SEQ")
@Table(name = "RHQ_PACKAGE_TYPE")
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractPropertyBagUIComponentTreeFactory.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractPropertyBagUIComponentTreeFactory.java
index a70907a..e17f23c 100644
--- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractPropertyBagUIComponentTreeFactory.java
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/AbstractPropertyBagUIComponentTreeFactory.java
@@ -44,6 +44,7 @@ import org.richfaces.component.html.HtmlModalPanel;
import org.rhq.core.domain.configuration.AbstractPropertyMap;
import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -284,11 +285,69 @@ public abstract class AbstractPropertyBagUIComponentTreeFactory {
addListProperty(parent, (PropertyDefinitionList) propertyDefinition, rowStyleClass);
} else if (propertyDefinition instanceof PropertyDefinitionMap) {
addMapProperty(parent, (PropertyDefinitionMap) propertyDefinition, rowStyleClass);
- } else {
+ } else if (propertyDefinition instanceof PropertyDefinitionDynamic) {
+ addDynamicProperty(parent, (PropertyDefinitionDynamic) propertyDefinition, rowStyleClass);
+ }
+ else {
throw new IllegalStateException("Unsupported subclass of " + PropertyDefinition.class.getName() + ".");
}
}
+ /**
+ * Adds a new property to the UI based on a dynamic property definition.
+ *
+ * @param parent owner in which the UI rendering of the property will live
+ * @param propertyDefinitionDynamic describes the property being rendered
+ * @param rowStyleClass indicates the CSS style (i.e. background color) of this row in the property list
+ */
+ private void addDynamicProperty(UIComponent parent, PropertyDefinitionDynamic propertyDefinitionDynamic,
+ String rowStyleClass) {
+ addDebug(parent, true, ".addDynamicProperty()");
+
+ FacesComponentUtility.addVerbatimText(parent, "\n\n<tr class='" + rowStyleClass + "'>");
+
+ PropertySimple propertySimple = this.propertyMap.getSimple(propertyDefinitionDynamic.getName());
+ ValueExpression propertyValueExpression = createPropertyValueExpression(propertySimple.getName(),
+ this.valueExpressionFormat);
+
+ UIInput input = null;
+ if (!this.isGroup || (propertySimple.getOverride() != null && propertySimple.getOverride())) {
+ // We need to create the input component ahead of when we need to add it to the component tree, since we
+ // need to know the input component's id in order to render the unset control.
+ input = PropertyRenderingUtility.createInputForDynamicProperty(propertyDefinitionDynamic, propertySimple,
+ propertyValueExpression, getListIndex(), this.isGroup, this.config.isReadOnly(), this.config
+ .isFullyEditable(), this.config.isPrevalidate());
+ }
+
+ FacesComponentUtility
+ .addVerbatimText(parent, "<td class='" + CssStyleClasses.PROPERTY_DISPLAY_NAME_CELL + "'>");
+ PropertyRenderingUtility.addPropertyDisplayName(parent, propertyDefinitionDynamic, propertySimple, this.config
+ .isReadOnly());
+ FacesComponentUtility.addVerbatimText(parent, "</td>");
+
+ FacesComponentUtility.addVerbatimText(parent, "<td class='" + CssStyleClasses.PROPERTY_ENABLED_CELL + "'>");
+ if (!propertyDefinitionDynamic.isRequired())
+ PropertyRenderingUtility.addUnsetControl(parent, propertyDefinitionDynamic.isRequired(),
+ propertyDefinitionDynamic.isReadOnly(), propertySimple, this.config.getListIndex(), input, this.isGroup,
+ this.config.isReadOnly(), this.config.isFullyEditable());
+ FacesComponentUtility.addVerbatimText(parent, "</td>");
+
+ FacesComponentUtility.addVerbatimText(parent, "<td class='" + CssStyleClasses.PROPERTY_VALUE_CELL + "'>");
+ addPropertySimpleValue(parent, input, propertyValueExpression);
+ FacesComponentUtility.addVerbatimText(parent, "<br/>");
+ if (input != null)
+ PropertyRenderingUtility.addMessageComponentForInput(parent, input);
+ FacesComponentUtility.addVerbatimText(parent, "</td>");
+
+ FacesComponentUtility.addVerbatimText(parent, "<td class='" + CssStyleClasses.PROPERTY_DESCRIPTION_CELL + "'>");
+ PropertyRenderingUtility.addPropertyDescription(parent, propertyDefinitionDynamic);
+ FacesComponentUtility.addVerbatimText(parent, "</td>");
+
+ FacesComponentUtility.addVerbatimText(parent, "</tr>");
+
+ addDebug(parent, false, ".addSimpleProperty()");
+ }
+
private void addSimpleProperty(UIComponent parent, PropertyDefinitionSimple propertyDefinitionSimple,
String rowStyleClass) {
addDebug(parent, true, ".addSimpleProperty()");
@@ -323,8 +382,9 @@ public abstract class AbstractPropertyBagUIComponentTreeFactory {
FacesComponentUtility.addVerbatimText(parent, "<td class='" + CssStyleClasses.PROPERTY_ENABLED_CELL + "'>");
if (!propertyDefinitionSimple.isRequired())
- PropertyRenderingUtility.addUnsetControl(parent, propertyDefinitionSimple, propertySimple, this.config
- .getListIndex(), input, this.isGroup, this.config.isReadOnly(), this.config.isFullyEditable());
+ PropertyRenderingUtility.addUnsetControl(parent, propertyDefinitionSimple.isRequired(),
+ propertyDefinitionSimple.isReadOnly(), propertySimple, this.config.getListIndex(), input, this.isGroup,
+ this.config.isReadOnly(), this.config.isFullyEditable());
FacesComponentUtility.addVerbatimText(parent, "</td>");
FacesComponentUtility.addVerbatimText(parent, "<td class='" + CssStyleClasses.PROPERTY_VALUE_CELL + "'>");
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java
new file mode 100644
index 0000000..1010cc7
--- /dev/null
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/DynamicPropertyRetriever.java
@@ -0,0 +1,52 @@
+/*
+* 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.core.gui.configuration.helper;
+
+import java.util.List;
+
+import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
+
+/**
+ * Plugins to the dynamic property rendering sections of {@link PropertyRenderingUtility} that perform
+ * the actual retrieval of the values.
+ * <p/>
+ * <strong>In order to associate implementations of this interface with the rendering code, calls must be made to
+ * {@link PropertyRenderingUtility#putDynamicPropertyRetriever(org.rhq.core.domain.configuration.PropertyDynamicType,
+ * DynamicPropertyRetriever)} to map the property type to the instance.</strong>
+ * <p/>
+ * This functionality is abstracted out to prevent the core-gui module from having to make non-core
+ * dependencies. Modules using core-gui can implement this interface using whatever means available,
+ * such as accessing a database or making a network hop, without having to modify the core-gui dependencies.
+ *
+ * @author Jason Dobies
+ */
+public interface DynamicPropertyRetriever {
+
+ /**
+ * Returns a list of values to display to the user when prompting for the property given.
+ *
+ * @param propertyDefinition cannot be <code>null</code>
+ * @return list of values to use as both the name and value of the UI inputs; empty list if none are found
+ */
+ List<String> loadValues(PropertyDefinitionDynamic propertyDefinition);
+}
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
index ac91723..03d01c3 100644
--- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/PropertyRenderingUtility.java
@@ -19,7 +19,9 @@
package org.rhq.core.gui.configuration.helper;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.UUID;
import javax.el.ValueExpression;
@@ -43,6 +45,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
+import org.rhq.core.domain.configuration.PropertyDynamicType;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionEnumeration;
@@ -56,7 +60,7 @@ import org.rhq.core.gui.util.PropertyIdGeneratorUtility;
import org.rhq.core.gui.validator.PropertySimpleValueValidator;
/**
- * A class that provides methods for rendering RHQ {@link Property}s.
+ * A class that provides methods for rendering RHQ {@link Property}s.
*
* @author Ian Springer
*/
@@ -72,6 +76,14 @@ public class PropertyRenderingUtility {
private static final String UNIQUE_ID_PREFIX = "rhq_id";
+ /**
+ * Holds a mapping from dynamic property backing type (i.e. database, server-side-plugin) to the
+ * {@link DynamicPropertyRetriever} instance that should be called to retrieve the values. Code using
+ * this class as a core UI dependency
+ */
+ private static final Map<PropertyDynamicType, DynamicPropertyRetriever> DYNAMIC_PROPERTY_RETRIEVERS =
+ new HashMap<PropertyDynamicType, DynamicPropertyRetriever>();
+
@NotNull
public static UIInput createInputForSimpleProperty(PropertyDefinitionSimple propertyDefinitionSimple,
PropertySimple propertySimple, ValueExpression propertyValueExpression, Integer listIndex,
@@ -81,8 +93,9 @@ public class PropertyRenderingUtility {
if (propertySimple != null)
addTitleAttribute(input, propertySimple.getStringValue());
- boolean isUnset = isUnset(propertyDefinitionSimple, propertySimple, isGroupConfig);
- boolean isReadOnly = isReadOnly(propertyDefinitionSimple, propertySimple, configReadOnly, configFullyEditable);
+ boolean isUnset = isUnset(propertyDefinitionSimple.isRequired(), propertySimple, isGroupConfig);
+ boolean isReadOnly = isReadOnly(propertyDefinitionSimple.isReadOnly(), propertyDefinitionSimple.isRequired(),
+ propertySimple, configReadOnly, configFullyEditable);
String propertyId = PropertyIdGeneratorUtility.getIdentifier(propertySimple, listIndex);
input.setId(propertyId);
@@ -98,6 +111,61 @@ public class PropertyRenderingUtility {
return input;
}
+ public static UIInput createInputForDynamicProperty(PropertyDefinitionDynamic propertyDefinitionDynamic,
+ PropertySimple property, ValueExpression valueExpression, Integer listIndex, boolean isGroupConfig,
+ boolean configReadOnly, boolean configFullyEditable, boolean prevalidate) {
+
+ // Simply use a drop down in all cases
+ UISelectOne input = FacesComponentUtility.createComponent(HtmlSelectOneMenu.class, null);
+
+ // Determine where to retrieve the values from
+ PropertyDynamicType propertyType = propertyDefinitionDynamic.getDynamicType();
+ DynamicPropertyRetriever retriever = DYNAMIC_PROPERTY_RETRIEVERS.get(propertyType);
+
+ if (retriever == null) {
+ throw new IllegalStateException("Attempt to render a dynamic property but no retrievers are " +
+ "configured for the type. Dynamic property type: " + propertyType + ", Definition: " +
+ propertyDefinitionDynamic);
+ }
+
+ // Retrieve the values and load them into UI options
+ List<String> values = retriever.loadValues(propertyDefinitionDynamic);
+ for (String option : values) {
+ UISelectItem selectItem = FacesComponentUtility.createComponent(UISelectItem.class, null);
+ selectItem.setItemLabel(option);
+ selectItem.setItemValue(option);
+ input.getChildren().add(selectItem);
+ }
+
+ boolean isUnset = isUnset(propertyDefinitionDynamic.isRequired(), property, isGroupConfig);
+ boolean isReadOnly = isReadOnly(propertyDefinitionDynamic.isReadOnly(), propertyDefinitionDynamic.isRequired(),
+ property, configReadOnly, configFullyEditable);
+
+ String propertyId = PropertyIdGeneratorUtility.getIdentifier(property, listIndex);
+ input.setId(propertyId);
+
+ // Revert to the previously selected value
+ input.setValueExpression("value", valueExpression);
+
+ FacesComponentUtility.setUnset(input, isUnset);
+ FacesComponentUtility.setReadonly(input, isReadOnly);
+
+ // If there is a PC-detected error associated with the property, associate it with the input.
+ addPluginContainerDetectedErrorMessage(input, property);
+
+ return input;
+ }
+
+ /**
+ * Sets the object used to retrieve property values for dynamic properties of the given type.
+ *
+ * @param type each type in the enum will only have one retriever associated with it at any given time
+ * @param retriever may not be <code>null</code>
+ */
+ public static void putDynamicPropertyRetriever(PropertyDynamicType type, DynamicPropertyRetriever retriever) {
+ DYNAMIC_PROPERTY_RETRIEVERS.put(type, retriever);
+ }
+
public static UIInput createInput(PropertyDefinitionSimple propertyDefinitionSimple) {
UIInput input;
PropertySimpleType type = (propertyDefinitionSimple != null) ? propertyDefinitionSimple.getType()
@@ -156,7 +224,7 @@ public class PropertyRenderingUtility {
}
public static HtmlSelectBooleanCheckbox addUnsetControl(UIComponent parent,
- PropertyDefinitionSimple propertyDefinitionSimple, PropertySimple propertySimple, Integer listIndex,
+ boolean isRequired, boolean isReadOnly, PropertySimple propertySimple, Integer listIndex,
UIInput valueInput, boolean isGroupConfig, boolean configReadOnly, boolean configFullyEditable) {
HtmlSelectBooleanCheckbox unsetCheckbox = FacesComponentUtility.createComponent(
@@ -166,8 +234,8 @@ public class PropertyRenderingUtility {
unsetCheckbox.setId(unsetCheckboxId);
}
parent.getChildren().add(unsetCheckbox);
- unsetCheckbox.setValue(isUnset(propertyDefinitionSimple, propertySimple, isGroupConfig));
- if (isReadOnly(propertyDefinitionSimple, propertySimple, configReadOnly, configFullyEditable)
+ unsetCheckbox.setValue(isUnset(isRequired, propertySimple, isGroupConfig));
+ if (isReadOnly(isReadOnly, isRequired, propertySimple, configReadOnly, configFullyEditable)
|| isGroupConfigWithDifferingValues(propertySimple, isGroupConfig)) {
FacesComponentUtility.setDisabled(unsetCheckbox, true);
} else {
@@ -456,33 +524,34 @@ public class PropertyRenderingUtility {
}
}
- private static boolean isUnset(PropertyDefinitionSimple propertyDefinitionSimple, PropertySimple propertySimple,
+ private static boolean isUnset(boolean isRequired, PropertySimple propertySimple,
boolean isGroupConfig) {
if (isGroupConfigWithDifferingValues(propertySimple, isGroupConfig))
// Properties from group configs that have differing values should not be marked unset.
return false;
if (propertySimple == null)
return false;
- return ((propertyDefinitionSimple == null || !propertyDefinitionSimple.isRequired()) && propertySimple
- .getStringValue() == null);
+
+ return (!isRequired && propertySimple.getStringValue() == null);
}
- public static boolean isReadOnly(PropertyDefinitionSimple propertyDefinitionSimple, PropertySimple propertySimple,
+ public static boolean isReadOnly(boolean isReadOnly, boolean isRequired, PropertySimple propertySimple,
boolean configReadOnly, boolean configFullyEditable) {
// A fully editable config overrides any other means of setting read-only.
- return (!configFullyEditable && (configReadOnly || ((propertyDefinitionSimple != null && propertyDefinitionSimple
- .isReadOnly()) && (propertySimple == null || !isInvalidRequiredProperty(propertyDefinitionSimple,
- propertySimple)))));
+ return (!configFullyEditable && //
+ (configReadOnly || //
+ isReadOnly && //
+ (propertySimple == null || //
+ !isInvalidRequiredProperty(isRequired, propertySimple))));
}
public static boolean isGroupConfigWithDifferingValues(PropertySimple propertySimple, boolean isGroupConfig) {
return isGroupConfig && (propertySimple.getOverride() == null || !propertySimple.getOverride());
}
- private static boolean isInvalidRequiredProperty(PropertyDefinitionSimple propertyDefinitionSimple,
- PropertySimple propertySimple) {
+ private static boolean isInvalidRequiredProperty(boolean isRequired, PropertySimple propertySimple) {
boolean isInvalidRequiredProperty = false;
- if (propertyDefinitionSimple.isRequired()) {
+ if (isRequired) {
String errorMessage = propertySimple.getErrorMessage();
if ((null == propertySimple.getStringValue()) || "".equals(propertySimple.getStringValue())
|| ((null != errorMessage) && (!"".equals(errorMessage.trim())))) {
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/PropertySetRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/PropertySetRenderer.java
index 04891a3..de1620e 100644
--- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/PropertySetRenderer.java
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/PropertySetRenderer.java
@@ -94,7 +94,7 @@ public class PropertySetRenderer extends Renderer {
// If it's an AJAX request for this component, apply the group config to the member configs
// and clear our child components. NOTE: This can *not* be done in decode(), because the model
- // will not have been updated yet with any changes made to child UIInput values.
+ // will not have been updated yet with any changes made to child UIInput values.
String refresh = FacesContextUtility.getOptionalRequestParameter("refresh");
if (refresh != null && refresh.equals(ConfigRenderer.PROPERTY_SET_COMPONENT_ID)) {
propertySetComponent.getConfigurationSet().applyGroupConfiguration();
@@ -122,8 +122,8 @@ public class PropertySetRenderer extends Renderer {
addPropertyDisplayNameAndDescription(propertySetComponent, propertyDefinitionSimple, propertySimple);
boolean configReadOnly = propertySetComponent.getReadOnly() != null && propertySetComponent.getReadOnly();
- boolean propIsReadOnly = PropertyRenderingUtility.isReadOnly(propertyDefinitionSimple, null, configReadOnly,
- false);
+ boolean propIsReadOnly = PropertyRenderingUtility.isReadOnly(propertyDefinitionSimple.isReadOnly(),
+ propertyDefinitionSimple.isRequired(), null, configReadOnly,false);
HtmlPanelGroup setAllToSameValueControlPanel = null;
if (!propIsReadOnly) {
// NOTE: We'll add children to the below panel a bit later when we know the id's of the inputs.
@@ -184,8 +184,9 @@ public class PropertySetRenderer extends Renderer {
HtmlSelectBooleanCheckbox unsetCheckbox = null;
if (isOptional(propertyDefinitionSimple)) {
FacesComponentUtility.addOutputText(panelGrid, null, "Unset All: ", null);
- unsetCheckbox = PropertyRenderingUtility.addUnsetControl(panelGrid, propertyDefinitionSimple, null,
- propertySetComponent.getListIndex(), input, false, propertySetComponent.getReadOnly(), false);
+ unsetCheckbox = PropertyRenderingUtility.addUnsetControl(panelGrid, propertyDefinitionSimple.isRequired(),
+ propertyDefinitionSimple.isReadOnly(), null, propertySetComponent.getListIndex(), input, false,
+ propertySetComponent.getReadOnly(), false);
}
// the 'APPLY' button
@@ -382,8 +383,8 @@ public class PropertySetRenderer extends Renderer {
FacesComponentUtility.addVerbatimText(propertySetComponent, "<td class='"
+ CssStyleClasses.MEMBER_PROPERTY_UNSET_CELL + "'>");
HtmlSelectBooleanCheckbox unsetCheckbox = PropertyRenderingUtility.addUnsetControl(propertySetComponent,
- propertyDefinitionSimple, propertyInfo.getProperty(), propertySetComponent.getListIndex(), input,
- false, propertySetComponent.getReadOnly(), false);
+ propertyDefinitionSimple.isRequired(), propertyDefinitionSimple.isReadOnly(), propertyInfo.getProperty(),
+ propertySetComponent.getListIndex(), input, false, propertySetComponent.getReadOnly(), false);
propertyInfo.setUnsetCheckbox(unsetCheckbox);
FacesComponentUtility.addVerbatimText(propertySetComponent, "</td>");
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java
new file mode 100644
index 0000000..3dc4e3e
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/DatabaseDynamicPropertyRetriever.java
@@ -0,0 +1,46 @@
+/*
+* 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.gui.configuration;
+
+import java.util.List;
+
+import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
+import org.rhq.core.gui.configuration.helper.DynamicPropertyRetriever;
+import org.rhq.enterprise.server.configuration.DynamicConfigurationPropertyLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * Handles retrieving the values of a database backed dynamic configuration property.
+ *
+ * @author Jason Dobies
+ */
+public class DatabaseDynamicPropertyRetriever implements DynamicPropertyRetriever {
+
+ public List<String> loadValues(PropertyDefinitionDynamic propertyDefinition) {
+ String key = propertyDefinition.getKey();
+ DynamicConfigurationPropertyLocal bean = LookupUtil.getDynamicConfigurationProperty();
+ List<String> values = bean.lookupValues(key);
+
+ return values;
+ }
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
index 2697759..9d84205 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
@@ -39,11 +39,14 @@ import org.jboss.mx.util.MBeanServerLocator;
import org.rhq.core.db.DatabaseTypeFactory;
import org.rhq.core.domain.cloud.Server;
import org.rhq.core.domain.cloud.Server.OperationMode;
+import org.rhq.core.domain.configuration.PropertyDynamicType;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.util.serial.ExternalizableStrategy;
+import org.rhq.core.gui.configuration.helper.PropertyRenderingUtility;
import org.rhq.core.util.ObjectNameFactory;
import org.rhq.enterprise.communications.ServiceContainerConfigurationConstants;
import org.rhq.enterprise.communications.util.SecurityUtil;
+import org.rhq.enterprise.gui.configuration.DatabaseDynamicPropertyRetriever;
import org.rhq.enterprise.server.alert.engine.internal.AlertConditionCacheCoordinator;
import org.rhq.enterprise.server.auth.SessionManager;
import org.rhq.enterprise.server.auth.prefs.SubjectPreferencesCache;
@@ -87,7 +90,7 @@ public class StartupServlet extends HttpServlet {
// As a security measure, make sure the installer has been undeployed
LookupUtil.getSystemManager().undeployInstaller();
- // get singletons right now so we load the classes immediately into our classloader
+ // get singletons right now so we load the classes immediately into our classloader
AlertConditionCacheCoordinator.getInstance();
SessionManager.getInstance();
SubjectPreferencesCache.getInstance();
@@ -126,11 +129,15 @@ public class StartupServlet extends HttpServlet {
startEmbeddedAgent();
registerShutdownListener();
+ // Configures the configuration rendering to be able to support database backed dynamic configuration properties
+ PropertyRenderingUtility.putDynamicPropertyRetriever(PropertyDynamicType.DATABASE,
+ new DatabaseDynamicPropertyRetriever());
+
return;
}
private void initializeServer() {
- // Ensure the class is loaded and the dbType is set for our current db
+ // Ensure the class is loaded and the dbType is set for our current db
try {
DataSource ds = LookupUtil.getDataSource();
Connection conn = ds.getConnection();
@@ -161,7 +168,7 @@ public class StartupServlet extends HttpServlet {
* For developer builds that don't use the HA installer to write a localhost entry into the {@link Server}
* table, we will create a default one here. Then, if the "rhq.high-availability.name" property is missing, the
* {@link ServerManagerLocal} will return this localhost entry.
- *
+ *
* If the installer was already run, then this method should be a no-op because a row would already exist
* in the {@link Server} table
*/
@@ -204,7 +211,7 @@ public class StartupServlet extends HttpServlet {
/**
* Starts the plugin deployer which will effectively ask the plugin deployer to persist information about all
- * detected agent and server plugins.
+ * detected agent and server plugins.
*
* Because this will scan and register the initial plugins right now, make sure this is called prior
* to starting the master plugin container; otherwise, the master PC will not have any plugins to start.
diff --git a/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
index 560bc9e..b7f98cb 100644
--- a/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/disk/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -18,6 +18,18 @@
<c:group name="General">
<c:simple-property name="rootDirectory" type="directory" required="true"
description="The root directory that contains all content that is to be served by this content provider. In an HA environment, this must be on a distributed file system that all servers can access."/>
+
+ <c:dynamic-property name="users" description="TEST - List of all users in the system.">
+ <c:database-backing key="users"/>
+ </c:dynamic-property>
+
+<!-- <c:dynamic-property name="roles" description="TEST - List of all roles in the system.">
+ <c:database-backing key="roles"/>
+ </c:dynamic-property>
+
+ <c:dynamic-property name="packageTypes" description="TEST - List of all package types in the system.">
+ <c:database-backing key="package-types"/>
+ </c:dynamic-property>-->
</c:group>
<c:group name="Package Source">
commit a86cb92866d71049f5440181267489d14c37f678
Author: John Matthews <jmatthew(a)redhat.com>
Date: Thu Jan 14 13:34:01 2010 -0500
1357 - added browsing for packages through http
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
index 549850f..d301413 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -19,6 +19,8 @@
package org.rhq.gui.content;
import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Date;
import java.util.List;
import javax.servlet.ServletException;
@@ -46,6 +48,8 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class ContentHTTPServlet extends DefaultServlet {
private final Log log = LogFactory.getLog(ContentHTTPServlet.class);
+ protected static final String CONTENT_URI = "/content";
+
protected static final String PACKAGES = "packages";
protected static final String DISTRIBUTIONS = "distributions";
@@ -65,9 +69,17 @@ public class ContentHTTPServlet extends DefaultServlet {
log.info("ContentHTTPServlet resolved references in init.");
}
+ protected boolean isIconRequest(HttpServletRequest request) {
+ String dir = getNthPiece(2, request.getRequestURI());
+ return StringUtils.equalsIgnoreCase(dir, "icons");
+ }
+
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
log.info("doGet(): requestURI = " + request.getRequestURI());
-
+ if (isIconRequest(request)) {
+ super.doGet(request, response);
+ return;
+ }
// Check if repo has been specified
Repo repo = getRepo(request, response);
if (repo == null) {
@@ -121,12 +133,30 @@ public class ContentHTTPServlet extends DefaultServlet {
log.info("Potential repo: Name = " + r.getName() + ", ID = " + r.getId());
}
log.info("TODO: generate index.html");
-
- // dont include candidate repos
+ StringBuffer sb = new StringBuffer();
+ HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
+ for (Repo r : repos) {
+ log.info("Potential repo: Name = " + r.getName() + ", ID = " + r.getId());
+ // Skip candidate repos
+ if (!r.isCandidate()) {
+ String lastMod = new Date(r.getLastModifiedDate()).toString();
+ HtmlRenderer.formDirEntry(request, sb, r.getName(), lastMod);
+ }
+ }
+ HtmlRenderer.formEnd(sb);
+ writeResponse(sb.toString(), response);
}
- protected void renderChoiceOfContent(HttpServletRequest request, HttpServletResponse response, Repo repo) {
+ protected void renderChoiceOfContent(HttpServletRequest request, HttpServletResponse response, Repo repo)
+ throws IOException {
log.info("Choice of content is: {" + PACKAGES + ", " + DISTRIBUTIONS + "}");
+ StringBuffer sb = new StringBuffer();
+ HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
+ HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
+ HtmlRenderer.formDirEntry(request, sb, PACKAGES, "-");
+ HtmlRenderer.formDirEntry(request, sb, DISTRIBUTIONS, "-");
+ HtmlRenderer.formEnd(sb);
+ writeResponse(sb.toString(), response);
}
protected void renderPackages(HttpServletRequest request, HttpServletResponse response, Repo repo)
@@ -143,33 +173,44 @@ public class ContentHTTPServlet extends DefaultServlet {
renderPackageIndex(request, response, repo);
return;
} else {
- log.info("TODO: fetch package bits and return them.");
+ log.info("fetch package bits and return them.");
PackageVersion pv = getPackageVersionFromFileName(repo, fileName);
if (pv == null) {
log.info("Unable to find PackageVersion from filename: " + fileName);
renderErrorPage(request, response);
return;
}
- response.setContentType("application/x-rpm");
+ response.setContentType("application/octet-stream");
writePackageVersionBits(pv, response.getOutputStream());
}
}
- protected void renderPackageIndex(HttpServletRequest request, HttpServletResponse response, Repo repo) {
- // placeholder for packages index.html
+ protected void renderPackageIndex(HttpServletRequest request, HttpServletResponse response, Repo repo)
+ throws IOException {
log.info("Forming packages index.html for repo: " + repo.getName() + ", ID = " + repo.getId());
List<PackageVersion> pvs = repoMgr.findPackageVersionsInRepo(LookupUtil.getSubjectManager().getOverlord(), repo
.getId(), PageControl.getUnlimitedInstance());
+ StringBuffer sb = new StringBuffer();
+ HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
+ HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
for (PackageVersion pv : pvs) {
- log.info("Add PackageVersion: " + pv);
+ HtmlRenderer.formFileEntry(sb, pv.getFileName(), new Date(pv.getFileCreatedDate()).toString(), pv
+ .getFileSize());
}
-
+ HtmlRenderer.formEnd(sb);
+ writeResponse(sb.toString(), response);
}
- protected void renderDistributions(HttpServletRequest request, HttpServletResponse response, Repo repo) {
+ protected void renderDistributions(HttpServletRequest request, HttpServletResponse response, Repo repo)
+ throws IOException {
+ StringBuffer sb = new StringBuffer();
+ HtmlRenderer.formStart(sb, "Index of ", request.getRequestURI());
+ HtmlRenderer.formParentLink(sb, getParentURI(request.getRequestURI()));
+ HtmlRenderer.formEnd(sb);
+ writeResponse(sb.toString(), response);
}
protected void renderErrorPage(HttpServletRequest request, HttpServletResponse response) throws IOException {
@@ -177,6 +218,16 @@ public class ContentHTTPServlet extends DefaultServlet {
response.sendError(response.SC_NOT_FOUND);
}
+ protected boolean writeResponse(String data, HttpServletResponse response) throws IOException {
+
+ response.setContentType("text/html");
+ PrintWriter out = response.getWriter();
+ out.write(data);
+ out.flush();
+ out.close();
+ return true;
+ }
+
protected Repo getRepo(HttpServletRequest request, HttpServletResponse response) {
String repoName = getRepoName(request.getRequestURI());
@@ -233,13 +284,23 @@ public class ContentHTTPServlet extends DefaultServlet {
*
*/
protected String getNthPiece(int n, String requestURI) {
- int index = n - 1;
StrTokenizer st = new StrTokenizer(requestURI, "/");
List<String> tokens = st.getTokenList();
- if (tokens.size() < index) {
+ if (tokens.size() < n) {
return "";
}
- return tokens.get(index);
+ return tokens.get(n - 1); // caller is starting at 1 not 0
+ }
+
+ protected String getParentURI(String uri) {
+ if (uri.endsWith("/")) {
+ uri = uri.substring(0, uri.length() - 1);
+ }
+ int index = uri.lastIndexOf("/");
+ if (index == -1) {
+ return uri;
+ }
+ return uri.substring(0, index);
}
protected PackageVersion getPackageVersionFromFileName(Repo repo, String fileName) {
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java
new file mode 100644
index 0000000..f1f0826
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/HtmlRenderer.java
@@ -0,0 +1,99 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.gui.content;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class HtmlRenderer {
+
+ public static String formStart(String title, String currentURI) {
+ StringBuffer sb = new StringBuffer();
+ formStart(sb, title, currentURI);
+ return sb.toString();
+ }
+
+ public static void formStart(StringBuffer sb, String title, String currentURI) {
+ sb.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n");
+ sb.append("<html>\n");
+ sb.append("<head>\n");
+ sb.append("<title>Index of " + currentURI + "</title>\n");
+ sb.append("</head>\n");
+ sb.append("<body>\n");
+ sb.append("<h1>Index of " + currentURI + "</h1>\n");
+ sb.append("<table><tr><th><img src=\"" + getIconPath("/icons/blank.gif")
+ + "\" alt=\"[ICO]\" width=\"20\" height=\"22\"></th>");
+ sb.append("<th>Name</th><th>Last modified</th><th>Size</th></tr>\n");
+ sb.append("<tr><th colspan=\"4\"><hr></th></tr>\n");
+ }
+
+ public static String formParentLink(String parentURI) {
+ StringBuffer sb = new StringBuffer();
+ formParentLink(sb, parentURI);
+ return sb.toString();
+ }
+
+ public static void formParentLink(StringBuffer sb, String parentURI) {
+ sb.append("<tr><td valign=\"top\"><img src=\"" + getIconPath("/icons/back.gif")
+ + "\" alt=\"[DIR]\" width=\"20\" height=\"22\"></td><td><a href=\"" + parentURI
+ + "\">Parent Directory</a></td><td> </td><td align=\"right\"> - </td><td> </td></tr>");
+ }
+
+ public static String formEnd() {
+ StringBuffer sb = new StringBuffer();
+ formEnd(sb);
+ return sb.toString();
+ }
+
+ public static void formEnd(StringBuffer sb) {
+ sb.append("<tr><th colspan=\"4\"><hr></th></tr>\n" + "</table>\n" + "</body></html>\n");
+ }
+
+ public static String formDirEntry(HttpServletRequest request, String dirName, String lastMod) {
+ StringBuffer sb = new StringBuffer();
+ formDirEntry(request, sb, dirName, lastMod);
+ return sb.toString();
+ }
+
+ public static void formDirEntry(HttpServletRequest request, StringBuffer sb, String dirName, String lastMod) {
+ if (!dirName.endsWith("/")) {
+ dirName = dirName + "/";
+ }
+ sb.append("<tr><td valign=\"top\"><img src=\"" + getIconPath("/icons/folder.gif")
+ + "\" alt=\"[DIR]\" width=\"20\" height=\"22\"></td>\n");
+ sb.append("<td><a href=\"" + request.getRequestURI() + "/" + dirName + "\">" + dirName + "</a></td>\n");
+ sb.append("<td align=\"right\">" + lastMod + "</td><td align=\"right\"> - </td><td> </td></tr>\n");
+ }
+
+ public static String formFileEntry(String fileName, String lastModDate, long fileSize) {
+ StringBuffer sb = new StringBuffer();
+ formFileEntry(sb, fileName, lastModDate, fileSize);
+ return sb.toString();
+ }
+
+ public static void formFileEntry(StringBuffer sb, String fileName, String lastMod, long fileSize) {
+ sb.append("<tr><td valign=\"top\"><img src=\"" + getIconPath("/icons/unknown.gif")
+ + "\" alt=\"[DIR]\" width=\"20\" height=\"22\"></td>\n");
+ sb.append("<td><a href=\"" + fileName + "\">" + fileName + "</a></td>\n");
+ sb.append("<td align=\"right\">" + lastMod + "</td><td align=\"right\"> - </td><td> </td></tr>\n");
+ }
+
+ protected static String getIconPath(String path) {
+ return ContentHTTPServlet.CONTENT_URI + path;
+ }
+}
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/icons/back.gif b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/back.gif
new file mode 100644
index 0000000..a694ae1
Binary files /dev/null and b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/back.gif differ
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/icons/blank.gif b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/blank.gif
new file mode 100644
index 0000000..0ccf01e
Binary files /dev/null and b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/blank.gif differ
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/icons/bomb.gif b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/bomb.gif
new file mode 100644
index 0000000..270fdb1
Binary files /dev/null and b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/bomb.gif differ
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/icons/folder.gif b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/folder.gif
new file mode 100644
index 0000000..4826460
Binary files /dev/null and b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/folder.gif differ
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/icons/text.gif b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/text.gif
new file mode 100644
index 0000000..4c62390
Binary files /dev/null and b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/text.gif differ
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/icons/unknown.gif b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/unknown.gif
new file mode 100644
index 0000000..32b1ea2
Binary files /dev/null and b/modules/enterprise/gui/content_http-war/src/main/webapp/icons/unknown.gif differ
commit 76bfba92397380f968b8bdc40dc2d51d5f369f0e
Author: Jeff Ortel <jortel(a)redhat.com>
Date: Thu Jan 14 09:18:18 2010 -0600
Add API for retrieving subscribed repos by id. Returns truncated Repo.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/SubscribedRepo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/SubscribedRepo.java
new file mode 100644
index 0000000..0f0e191
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/transfer/SubscribedRepo.java
@@ -0,0 +1,47 @@
+package org.rhq.core.domain.content.transfer;
+
+import java.io.Serializable;
+
+public class SubscribedRepo implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private int id;
+ private String name;
+
+ public SubscribedRepo() {
+ }
+
+ public SubscribedRepo(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ /**
+ * @return the repo id
+ */
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id the repo id to set
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the repo name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param repoName the repo name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+}
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 c79d561..1f0f62b 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
@@ -60,6 +60,7 @@ import org.rhq.core.domain.content.RepoRepoRelationship;
import org.rhq.core.domain.content.RepoSyncResults;
import org.rhq.core.domain.content.ResourceRepo;
import org.rhq.core.domain.content.composite.RepoComposite;
+import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.resource.Resource;
@@ -228,6 +229,17 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
return new PageList<RepoComposite>(results, (int) count, pc);
}
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public PageList<SubscribedRepo> findSubscriptions(Subject subject, int resourceId, PageControl pc) {
+ PageList<SubscribedRepo> list = new PageList<SubscribedRepo>();
+ for (RepoComposite repoComposite : findResourceSubscriptions(subject, resourceId, pc)) {
+ Repo repo = repoComposite.getRepo();
+ SubscribedRepo summary = new SubscribedRepo(repo.getId(), repo.getName());
+ list.add(summary);
+ }
+ return list;
+ }
+
@SuppressWarnings("unchecked")
@RequiredPermission(Permission.MANAGE_INVENTORY)
public PageList<RepoComposite> findAvailableResourceSubscriptions(Subject subject, int resourceId, PageControl pc) {
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 b77abb5..d6d061d 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
@@ -32,6 +32,7 @@ import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
import org.rhq.core.domain.content.RepoSyncResults;
import org.rhq.core.domain.content.composite.RepoComposite;
+import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.resource.Resource;
@@ -63,6 +64,15 @@ public interface RepoManagerLocal {
PageList<RepoComposite> findResourceSubscriptions(Subject subject, int resourceId, PageControl pc);
/**
+ * Gets all repos that are subscribed to by the given resource.
+ * @param subject
+ * @param resourceId
+ * @param pc
+ * @return
+ */
+ PageList<SubscribedRepo> findSubscriptions(Subject subject, int resourceId, PageControl pc);
+
+ /**
* Gets all repos that aren't subscribed to for the given resource.
*
* @param subject
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 04789b7..3ff4f3a 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
@@ -31,6 +31,7 @@ import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
+import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.PackageVersionCriteria;
import org.rhq.core.domain.criteria.RepoCriteria;
import org.rhq.core.domain.resource.Resource;
@@ -283,4 +284,9 @@ public interface RepoManagerRemote {
int synchronizeRepos(@WebParam(name = "subject") Subject subject, @WebParam(name = "repoIds") Integer[] repoIds)
throws Exception;
+ @WebMethod
+ PageList<SubscribedRepo> findSubscriptions( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "resourceId") int resourceId, //
+ @WebParam(name = "resource") PageControl pc);
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index c531297..19e07ac 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -55,6 +55,7 @@ import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.content.Repo;
import org.rhq.core.domain.content.RepoGroup;
import org.rhq.core.domain.content.RepoGroupType;
+import org.rhq.core.domain.content.transfer.SubscribedRepo;
import org.rhq.core.domain.criteria.AlertCriteria;
import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
import org.rhq.core.domain.criteria.Criteria;
@@ -927,4 +928,8 @@ public class WebservicesManagerBean implements WebservicesRemote {
return repoManager.findAssociatedAdvisory(subject, repoId, pc);
}
+ public PageList<SubscribedRepo> findSubscriptions(Subject subject, int resourceId,
+ PageControl pc) {
+ return repoManager.findSubscriptions(subject, resourceId, pc);
+ }
}
commit 25aeb6d063e910ddeabc62d47cc35c59202f99b3
Author: Todd B Sanders <tsanders(a)dhcp231-67.rdu.redhat.com>
Date: Thu Jan 14 08:45:05 2010 -0500
Removed incorrect @Override annotations. These annotations will cause compiler errors with the OpenJDK (v1.6.0 in F12).
diff --git a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
index c65a1b0..47a473d 100644
--- a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
+++ b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java
@@ -244,9 +244,8 @@ public class JBossSoftwareContentSourceAdapter implements ContentProvider, Packa
}
}
- @Override
public SyncProgressWeight getSyncProgressWeight() {
return SyncProgressWeight.DEFAULT_WEIGHTS;
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
index 9a6e9c0..56c21d4 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/RHNProvider.java
@@ -357,7 +357,6 @@ public class RHNProvider implements ContentProvider, PackageSource, RepoSource,
return helper.constructKickstartFileUrl(repoName, label, relativeFilename);
}
- @Override
public SyncProgressWeight getSyncProgressWeight() {
return new SyncProgressWeight(10, 1, 0, 0, 1);
}
diff --git a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java
index f3c75e2..004608a 100644
--- a/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java
+++ b/modules/enterprise/server/plugins/rhnhosted/src/main/java/org/rhq/enterprise/server/plugins/rhnhosted/xmlrpc/ApacheXmlRpcExecutor.java
@@ -32,12 +32,10 @@ public class ApacheXmlRpcExecutor implements XmlRpcExecutor {
this.client = clientIn;
}
- @Override
public Object execute(String methodName, Object[] params) throws XmlRpcException {
return client.execute(methodName, params);
}
- @Override
public Object execute(String pMethodName, List pParams) throws XmlRpcException {
return client.execute(pMethodName, pParams);
}
diff --git a/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java b/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java
index 061f860..0af228e 100644
--- a/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java
+++ b/modules/enterprise/server/plugins/url/src/main/java/org/rhq/enterprise/server/plugins/url/UrlProvider.java
@@ -393,8 +393,7 @@ public class UrlProvider implements ContentProvider, PackageSource {
return null; // the file doesn't match any known types for this content source
}
- @Override
public SyncProgressWeight getSyncProgressWeight() {
return SyncProgressWeight.DEFAULT_WEIGHTS;
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java b/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
index f45c0a4..00bdb0f 100644
--- a/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
+++ b/modules/enterprise/server/plugins/yum/src/main/java/org/rhq/enterprise/server/plugins/yum/RepoProvider.java
@@ -191,8 +191,7 @@ public class RepoProvider implements ContentProvider, PackageSource {
return path;
}
- @Override
public SyncProgressWeight getSyncProgressWeight() {
return SyncProgressWeight.DEFAULT_WEIGHTS;
}
-}
\ No newline at end of file
+}
commit b138416f64a8a0d80eba1bb720779430e9a1ba9e
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 13 16:31:50 2010 -0500
Deleted invalid use of @Override (not allowed when implementing an interface method). I wasn't seeing issues with this in place but it was causing the build to break for at least one other developer.
diff --git a/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java b/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
index 8c3f163..6f9bb8b 100644
--- a/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
+++ b/modules/enterprise/server/plugins/disk/src/main/java/org/rhq/enterprise/server/plugins/disk/DiskSource.java
@@ -353,7 +353,6 @@ public class DiskSource implements ContentProvider, PackageSource, RepoSource {
public String resourceTypePluginName;
}
- @Override
public SyncProgressWeight getSyncProgressWeight() {
return new SyncProgressWeight(10, 1, 0, 0, 0);
}
commit 4c49062b9cc93140f5f39197fe4e72c2cbe9c320
Author: John Matthews <jmatthew(a)redhat.com>
Date: Wed Jan 13 13:42:10 2010 -0500
1357 - added support for 'wget' of a package through http
Example URL (supports repo name or repo id in URL)
http://127.0.0.1:7080/content/rhel-i386-server-vt-5/packages/gnome-applet...
http://127.0.0.1:7080/content/10055/packages/gnome-applet-vm-0.1.2-1.el5....
diff --git a/modules/enterprise/gui/content_http-war/pom.xml b/modules/enterprise/gui/content_http-war/pom.xml
index 5966c8e..452c0ce 100644
--- a/modules/enterprise/gui/content_http-war/pom.xml
+++ b/modules/enterprise/gui/content_http-war/pom.xml
@@ -162,6 +162,12 @@
<version>1.1.4</version>
</dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ </dependency>
+
</dependencies>
<build>
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
index 2ac2061..549850f 100644
--- a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -1,34 +1,281 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.gui.content;
import java.io.IOException;
+import java.util.List;
import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.servlets.DefaultServlet;
-
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.text.StrTokenizer;
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.PackageVersion;
+import org.rhq.core.domain.content.Repo;
+import org.rhq.core.domain.criteria.PackageVersionCriteria;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.server.content.ContentManagerLocal;
+import org.rhq.enterprise.server.content.ContentSourceManagerLocal;
+import org.rhq.enterprise.server.content.RepoManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
public class ContentHTTPServlet extends DefaultServlet {
private final Log log = LogFactory.getLog(ContentHTTPServlet.class);
+ protected static final String PACKAGES = "packages";
+ protected static final String DISTRIBUTIONS = "distributions";
+
+ protected RepoManagerLocal repoMgr;
+ protected ContentManagerLocal contentMgr;
+ protected ContentSourceManagerLocal contentSourceMgr;
+
public ContentHTTPServlet() {
super();
}
public void init() throws ServletException {
- log.info("** *** ** ** ** *** Inside of ContentHTTPServlet::init()");
super.init();
+ repoMgr = LookupUtil.getRepoManagerLocal();
+ contentMgr = LookupUtil.getContentManager();
+ contentSourceMgr = LookupUtil.getContentSourceManager();
+ log.info("ContentHTTPServlet resolved references in init.");
}
- protected void doGet(HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException {
- log.info("** ** ** Inside of ContentHTTPServlet::doGet()");
- super.doGet(request, response);
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+ log.info("doGet(): requestURI = " + request.getRequestURI());
+
+ // Check if repo has been specified
+ Repo repo = getRepo(request, response);
+ if (repo == null) {
+ log.info("No repo found so we'll render a list of all repos.");
+ renderRepoList(request, response);
+ return;
+ }
+ // Check if type of content has been specified
+ String typeOfContent = getTypeOfContent(request.getRequestURI());
+ if (StringUtils.isBlank(typeOfContent)) {
+ log.info("no info was specified for type of content.");
+ renderChoiceOfContent(request, response, repo);
+ return;
+ }
+ //
+ // Determine what we should render, i.e.: packages or distributions
+ //
+ if (StringUtils.equalsIgnoreCase(typeOfContent, PACKAGES)) {
+ log.info("render packages");
+ renderPackages(request, response, repo);
+ return;
+
+ } else if (StringUtils.equalsIgnoreCase(typeOfContent, DISTRIBUTIONS)) {
+ log.info("render distributions");
+ renderDistributions(request, response, repo);
+ return;
+ } else {
+ log.info("Unable to determine what type of content was requested: " + typeOfContent);
+ renderErrorPage(request, response);
+ return;
+ }
}
-}
+ protected void renderRepoList(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ // Two known situations
+ // #1 User entered a bad URL
+ // #2 User entered no repo name
+
+ String repoName = getRepoName(request.getRequestURI());
+ if (!StringUtils.isEmpty(repoName)) {
+ log.info("Assuming bad repo name for: " + repoName + ", will render error page");
+ renderErrorPage(request, response);
+ return;
+ }
+ // Entered repo name is blank, so we'll render a list of repos
+
+ Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+ PageList<Repo> repos = repoMgr.findRepos(overlord, PageControl.getUnlimitedInstance());
+ log.info("Returned list of repos: " + repos.getTotalSize() + " entries");
+ for (Repo r : repos) {
+ log.info("Potential repo: Name = " + r.getName() + ", ID = " + r.getId());
+ }
+ log.info("TODO: generate index.html");
+
+ // dont include candidate repos
+ }
+
+ protected void renderChoiceOfContent(HttpServletRequest request, HttpServletResponse response, Repo repo) {
+ log.info("Choice of content is: {" + PACKAGES + ", " + DISTRIBUTIONS + "}");
+ }
+
+ protected void renderPackages(HttpServletRequest request, HttpServletResponse response, Repo repo)
+ throws IOException {
+
+ log.info("renderPackages(repo name = " + repo.getName() + ", id = " + repo.getId() + ", isCandidate = "
+ + repo.isCandidate() + ")");
+
+ String fileName = getFileName(request.getRequestURI());
+ log.info("Parsed file name = " + fileName);
+ if (StringUtils.isBlank(fileName)) {
+ // form a directory listing for each package in repository.
+ log.info("TODO: create index.html listing all the packages for this repo: " + repo.getName());
+ renderPackageIndex(request, response, repo);
+ return;
+ } else {
+ log.info("TODO: fetch package bits and return them.");
+ PackageVersion pv = getPackageVersionFromFileName(repo, fileName);
+ if (pv == null) {
+ log.info("Unable to find PackageVersion from filename: " + fileName);
+ renderErrorPage(request, response);
+ return;
+ }
+ response.setContentType("application/x-rpm");
+ writePackageVersionBits(pv, response.getOutputStream());
+ }
+ }
+
+ protected void renderPackageIndex(HttpServletRequest request, HttpServletResponse response, Repo repo) {
+ // placeholder for packages index.html
+ log.info("Forming packages index.html for repo: " + repo.getName() + ", ID = " + repo.getId());
+
+ List<PackageVersion> pvs = repoMgr.findPackageVersionsInRepo(LookupUtil.getSubjectManager().getOverlord(), repo
+ .getId(), PageControl.getUnlimitedInstance());
+
+ for (PackageVersion pv : pvs) {
+ log.info("Add PackageVersion: " + pv);
+ }
+
+ }
+
+ protected void renderDistributions(HttpServletRequest request, HttpServletResponse response, Repo repo) {
+
+ }
+
+ protected void renderErrorPage(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ log.info("render error page for request: " + request.getRequestURI());
+ response.sendError(response.SC_NOT_FOUND);
+ }
+
+ protected Repo getRepo(HttpServletRequest request, HttpServletResponse response) {
+
+ String repoName = getRepoName(request.getRequestURI());
+ log.info("Parsed repo name = " + repoName);
+ List<Repo> targetRepos = repoMgr.getRepoByName(repoName);
+ if (targetRepos.isEmpty()) {
+ // Check if maybe this is the repoID passed in as an int, instead of repo name
+ try {
+ Integer repoId = Integer.parseInt(repoName);
+ return repoMgr.getRepo(LookupUtil.getSubjectManager().getOverlord(), repoId);
+ } catch (NumberFormatException e) {
+ //ignore
+ }
+ return null;
+ }
+ return targetRepos.get(0);
+ }
+
+ /**
+ * Expecting URI format of:
+ * 127.0.0.1:7080/content/$REPONAME/$TYPE_OF_CONTENT/$FILENAME
+ */
+
+ /**
+ *
+ * @param requestURI
+ * @return repo name or "" if no repo name could be determined
+ */
+ protected String getRepoName(String requestURI) {
+ return getNthPiece(2, requestURI);
+ }
+
+ /**
+ *
+ * @param requestURI
+ * @return string that denotes if this is a package/distribution/etc kind of request
+ */
+ protected String getTypeOfContent(String requestURI) {
+ return getNthPiece(3, requestURI);
+ }
+
+ /**
+ *
+ * @param requestURI
+ * @return file name or "" if no file name could be determined
+ */
+ protected String getFileName(String requestURI) {
+ return getNthPiece(4, requestURI);
+ }
+
+ /**
+ * @param n nth element to return from requestURI, (first element corresponds to 1, not 0)
+ * @param requestURI
+ *
+ */
+ protected String getNthPiece(int n, String requestURI) {
+ int index = n - 1;
+ StrTokenizer st = new StrTokenizer(requestURI, "/");
+ List<String> tokens = st.getTokenList();
+ if (tokens.size() < index) {
+ return "";
+ }
+ return tokens.get(index);
+ }
+
+ protected PackageVersion getPackageVersionFromFileName(Repo repo, String fileName) {
+
+ PackageVersionCriteria criteria = new PackageVersionCriteria();
+ criteria.addFilterFileName(fileName);
+ criteria.addFilterRepoId(repo.getId());
+ log.info("Created criteria for repoId = " + repo.getId() + ", fileName = " + fileName);
+ List<PackageVersion> pkgVers = contentMgr.findPackageVersionsByCriteria(LookupUtil.getSubjectManager()
+ .getOverlord(), criteria);
+ for (PackageVersion pkgV : pkgVers) {
+ log.info("PackageVersion found: " + pkgVers);
+ }
+ log.info("Found " + pkgVers.size() + " entries");
+ PackageVersion pv = null;
+ if (pkgVers.size() > 0) {
+ pv = pkgVers.get(0);
+ } else {
+ log.info("Couldn't find " + fileName + " in " + repo.getName());
+ }
+ return pv;
+ }
+
+ protected boolean writePackageVersionBits(PackageVersion pkgVer, ServletOutputStream output) {
+
+ try {
+ contentSourceMgr.outputPackageVersionBits(pkgVer, output);
+ output.flush();
+ output.close();
+ } catch (IllegalStateException e) {
+ log.error(e);
+ return false;
+ } catch (IOException e) {
+ log.error(e);
+ return false;
+ }
+ return true;
+ }
+}
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 7421961..fbfaedb 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
@@ -1737,6 +1737,22 @@ public class ContentSourceManagerBean implements ContentSourceManagerLocal {
packageVersionId);
}
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ @TransactionTimeout(45 * 60)
+ public long outputPackageVersionBits(PackageVersion packageVersion, OutputStream outputStream) {
+ // Used by export of content through http
+
+ PackageDetailsKey packageDetailsKey = new PackageDetailsKey(packageVersion.getDisplayName(), packageVersion
+ .getDisplayVersion(), packageVersion.getGeneralPackage().getPackageType().toString(), packageVersion
+ .getArchitecture().toString());
+
+ int resourceId = 0; //set to dummy value
+
+ log.info("Calling outputPackageVersionBitsRangeHelper() with package details: " + packageDetailsKey);
+ return outputPackageVersionBitsRangeHelper(resourceId, packageDetailsKey, outputStream, 0, -1, packageVersion
+ .getId());
+ }
+
@SuppressWarnings("unchecked")
private long outputPackageVersionBitsRangeHelper(int resourceId, PackageDetailsKey packageDetailsKey,
OutputStream outputStream, long startByte, long endByte, int packageVersionId) {
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 25fefdc..5fa9fa3 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
@@ -559,6 +559,23 @@ public interface ContentSourceManagerLocal {
PackageDetailsKey packageDetailsKey, OutputStream outputStream);
/**
+ * Requests the bits of a package be streamed down to the caller over the given output stream.
+ * This method will <b>not</b> take care of closing the stream when it is finished;
+ * it is the caller's responsibility. This may be a time-consuming method call because
+ * if the bits have not yet been loaded (i.e. the content source where the package version lives
+ * {@link ContentSource#isLazyLoad() is lazy loading} then this may be the time when it is downloaded from the
+ * remote repository.
+ *
+ * @param packageVersion packageVersion to fetch
+ * @param outputStream an output stream where the server should write the package contents. It is up to the
+ * caller to prepare this output stream in order to write the package content to an
+ * appropriate location.
+ *
+ * @return the number of bytes written to the output stream
+ */
+ long outputPackageVersionBits(PackageVersion packageVersion, OutputStream outputStream);
+
+ /**
* Adds the specified content source to the database but does not attempt to create or start
* the server-side plugin provider implementation associated with it.
* <p/>
commit c078896bcb5067ae66e67358c5c3257104914b2a
Author: John Matthews <jmatthew(a)redhat.com>
Date: Wed Jan 13 13:41:05 2010 -0500
Adding eclipse changes for exposing content through http
diff --git a/.classpath b/.classpath
index 4598f49..527d92e 100644
--- a/.classpath
+++ b/.classpath
@@ -67,6 +67,7 @@
<classpathentry kind="src" path="modules/enterprise/gui/portal-war/src/test/java"/>
<classpathentry kind="src" path="modules/enterprise/gui/installer-war/src/main/java"/>
<classpathentry kind="src" path="modules/enterprise/gui/webdav-war/src/main/java"/>
+ <classpathentry kind="src" path="modules/enterprise/gui/content_http-war/src/main/java"/>
<classpathentry kind="src" path="modules/enterprise/remoting/cli/src/main/java"/>
<classpathentry kind="src" path="modules/enterprise/remoting/cli/src/test/java"/>
<classpathentry kind="src" path="modules/enterprise/remoting/webservices/src/main/java"/>
@@ -224,5 +225,6 @@
<classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.2.1/byteman-1.2.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.2/antlr-runtime-3.2.jar"/>
<classpathentry exported="true" kind="lib" path="modules/enterprise/remoting/webservices/target/rhq-remoting-webservices-1.4.0-SNAPSHOT/wsconsume-output"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/jboss/web/jbossweb/2.0.1.GA/jbossweb-2.0.1.GA.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
commit 5cce671275d5820067e49afda67ae19ff62633a3
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Wed Jan 13 09:52:40 2010 -0500
Backend changes (configuration XML schema, parser, and data model) for supporting dynamic configuration property values.
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
index 79cd764..74a864e 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/configuration/ConfigurationUtility.java
@@ -31,6 +31,7 @@ import org.jetbrains.annotations.Nullable;
import org.rhq.core.domain.configuration.AbstractPropertyMap;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -135,6 +136,9 @@ public abstract class ConfigurationUtility {
property = new PropertyMap(propertyDefinition.getName());
} else if (propertyDefinition instanceof PropertyDefinitionList) {
property = new PropertyList(propertyDefinition.getName());
+ } else if (propertyDefinition instanceof PropertyDefinitionDynamic) {
+ // Dynamic property values should simply be stored as simple
+ property = new PropertySimple(propertyDefinition.getName(), null);
} else {
throw new IllegalStateException("Unsupported PropertyDefinition subclass: "
+ propertyDefinition.getClass().getName());
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
index de68ca6..5a6473e 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
@@ -34,6 +34,7 @@ import org.rhq.core.clientapi.descriptor.configuration.ConfigurationDescriptor;
import org.rhq.core.clientapi.descriptor.configuration.ConfigurationProperty;
import org.rhq.core.clientapi.descriptor.configuration.ConfigurationTemplateDescriptor;
import org.rhq.core.clientapi.descriptor.configuration.ConstraintType;
+import org.rhq.core.clientapi.descriptor.configuration.DynamicProperty;
import org.rhq.core.clientapi.descriptor.configuration.FloatConstraintType;
import org.rhq.core.clientapi.descriptor.configuration.IntegerConstraintType;
import org.rhq.core.clientapi.descriptor.configuration.ListProperty;
@@ -44,8 +45,9 @@ import org.rhq.core.clientapi.descriptor.configuration.PropertyOptions;
import org.rhq.core.clientapi.descriptor.configuration.PropertyType;
import org.rhq.core.clientapi.descriptor.configuration.RegexConstraintType;
import org.rhq.core.clientapi.descriptor.configuration.SimpleProperty;
-import org.rhq.core.clientapi.descriptor.configuration.ConfigurationFormat;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertyDefinitionDynamic;
+import org.rhq.core.domain.configuration.PropertyDynamicType;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.AbstractPropertyMap;
import org.rhq.core.domain.configuration.PropertyMap;
@@ -81,7 +83,7 @@ public class ConfigurationMetadataParser {
configurationDefinition.setConfigurationFormat(getConfigurationFormat(descriptor));
if (configurationDefinition.getConfigurationFormat() == RAW) {
- return configurationDefinition;
+ return configurationDefinition;
}
for (ConfigurationTemplateDescriptor templateDescriptor : descriptor.getTemplate()) {
@@ -195,6 +197,8 @@ public class ConfigurationMetadataParser {
property = parseListProperty((ListProperty) uncastedProperty);
} else if (uncastedProperty instanceof MapProperty) {
property = parseMapProperty((MapProperty) uncastedProperty, defaultConfigurationParentMap);
+ } else if (uncastedProperty instanceof DynamicProperty) {
+ property = parseDynamicProperty((DynamicProperty) uncastedProperty);
}
if (property != null) {
@@ -234,6 +238,23 @@ public class ConfigurationMetadataParser {
return property;
}
+ private static PropertyDefinitionDynamic parseDynamicProperty(DynamicProperty dynamicProperty)
+ throws InvalidPluginDescriptorException {
+ String description = parseMultiValue(dynamicProperty.getDescription(), dynamicProperty.getLongDescription());
+ String displayName = (dynamicProperty.getDisplayName() != null) ? dynamicProperty.getDisplayName() : StringUtils
+ .deCamelCase(dynamicProperty.getName());
+
+ PropertyDefinitionDynamic property = new PropertyDefinitionDynamic(dynamicProperty.getName(), description,
+ dynamicProperty.isRequired(), PropertyDynamicType.DATABASE, dynamicProperty.getDatabaseBacking().getKey());
+
+ property.setReadOnly(dynamicProperty.isReadOnly());
+ property.setSummary(dynamicProperty.isSummary());
+ property.setDisplayName(displayName);
+ property.setActivationPolicy(translateActivationPolicy(dynamicProperty.getActivationPolicy()));
+
+ return property;
+ }
+
private static List<PropertyDefinitionEnumeration> parsePropertyOptions(PropertyDefinitionSimple parentProperty,
PropertyOptions options) {
List<PropertyDefinitionEnumeration> results = new ArrayList<PropertyDefinitionEnumeration>();
diff --git a/modules/core/client-api/src/main/resources/rhq-configuration.xsd b/modules/core/client-api/src/main/resources/rhq-configuration.xsd
index 65ff6b7..e6c479d 100644
--- a/modules/core/client-api/src/main/resources/rhq-configuration.xsd
+++ b/modules/core/client-api/src/main/resources/rhq-configuration.xsd
@@ -23,7 +23,7 @@
<jaxb:class name="ConfigurationDescriptor"/>
</xs:appinfo>
<xs:documentation>Describes all configurable elements of a resource.</xs:documentation>
- </xs:annotation>
+ </xs:annotation>
<xs:sequence>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1">
<xs:annotation>
@@ -201,6 +201,45 @@
</xs:complexType>
+ <xs:element name="dynamic-property" type="config:dynamicProperty" substitutionGroup="config:configuration-property"/>
+ <xs:complexType name="dynamicProperty">
+ <xs:complexContent>
+ <xs:extension base="config:configurationProperty">
+ <xs:sequence>
+ <xs:choice minOccurs="1" maxOccurs="1">
+ <xs:element name="database-backing" type="config:databaseBackingType">
+ <xs:annotation>
+ <xs:documentation>Indicates where to retrieve the values for this property.</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <!-- This will ultimately have other options in the choice, such as from a plugin call. -->
+ </xs:choice>
+ </xs:sequence>
+
+ <xs:attribute name="activationPolicy" default="immediate" type="config:activationPolicy" use="optional">
+ <xs:annotation>
+ <xs:documentation>conditions under which a change to this property will become effective
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+ <xs:complexType name="databaseBackingType">
+ <xs:annotation>
+ <xs:documentation>Configures a property to look up values from the database.</xs:documentation>
+ </xs:annotation>
+
+ <xs:attribute name="key" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation>Key RHQ will use to determine what values to retieve from the database.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ </xs:complexType>
+
<xs:element name="simple-property" type="config:simpleProperty" substitutionGroup="config:configuration-property"/>
<xs:complexType name="simpleProperty">
<xs:complexContent>
@@ -261,7 +300,7 @@
property that is not defined in a configuration</xs:documentation>
<xs:appinfo>
<jaxb:property name="initialValue"/>
- </xs:appinfo>
+ </xs:appinfo>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index a9f912b..256f287 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.75</db.schema.version>
+ <db.schema.version>2.76</db.schema.version>
</properties>
<dependencies>
@@ -92,13 +92,13 @@
if (!project.properties.dbreset) {
return
}
-
+
database = project.properties['rhq.test.ds.db-name']
project.properties.dbsetup = 'true'
sql = Sql.newInstance(
- "jdbc:postgresql://127.0.0.1:5432/postgres",
- "postgres",
+ "jdbc:postgresql://127.0.0.1:5432/postgres",
+ "postgres",
"postgres",
"org.postgresql.Driver")
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
index 04d5fb3..95dd243 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
@@ -44,6 +44,10 @@
<!-- only simple properties (not lists and maps) have this -->
<column name="UNITS" type="SMALLINT" required="false"/>
+
+ <!-- only dynamic properties (not simple) have this -->
+ <column name="DYNAMIC_TYPE" type="VARCHAR2" size="20" required="false"/>
+ <column name="DYNAMIC_KEY" type="VARCHAR2" size="128" required="false"/>
</table>
<table name="RHQ_CONF_PROP_DEF_ENUM">
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index cd9ebc3..144c793 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2756,10 +2756,16 @@
</statement>
</schema-directSQL>
</schemaSpec>
-
+
<schemaSpec version="2.75">
<schema-addColumn table="RHQ_REPO" column="SYNC_SCHEDULE" columnType="VARCHAR2" precision="64" />
</schemaSpec>
+
+ <schemaSpec version="2.76">
+ <schema-addColumn table="RHQ_CONFIG_PROP_DEF" column="DYNAMIC_TYPE" columnType="VARCHAR2" precision="20" />
+ <schema-addColumn table="RHQ_CONFIG_PROP_DEF" column="DYNAMIC_KEY" columnType="VARCHAR2" precision="128" />
+ </schemaSpec>
+
</dbupgrade>
</target>
</project>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyDefinitionDynamic.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyDefinitionDynamic.java
new file mode 100644
index 0000000..e2395c6
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyDefinitionDynamic.java
@@ -0,0 +1,82 @@
+/*
+* 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.core.domain.configuration;
+
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+
+/**
+ * Describes a property whose values are retrieved from a dynamic source. Currently, the only source supported
+ * is database. Changes will likely need to be made when plugin based value sources are introduced.
+ *
+ * @author Jason Dobies
+ */
+@DiscriminatorValue("dynamic")
+@Entity(name = "PropertyDefinitionDynamic")
+@XmlRootElement(name = "PropertyDefinitionDynamic")
+(a)XmlAccessorType(XmlAccessType.FIELD)
+public class PropertyDefinitionDynamic extends PropertyDefinition {
+
+ private static final long serialVersionUID = 1L;
+
+ @Column(name = "DYNAMIC_TYPE")
+ @Enumerated(EnumType.STRING)
+ private PropertyDynamicType dynamicType;
+
+ @Column(name = "DYNAMIC_KEY")
+ private String key;
+
+ public PropertyDefinitionDynamic() {
+ }
+
+ public PropertyDefinitionDynamic(String name, String description, boolean required,
+ PropertyDynamicType dynamicType, String key) {
+ super(name, description, required);
+ this.dynamicType = dynamicType;
+ this.key = key;
+ }
+
+ public PropertyDynamicType getDynamicType() {
+ return dynamicType;
+ }
+
+ public void setDynamicType(PropertyDynamicType dynamicType) {
+ this.dynamicType = dynamicType;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyDynamicType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyDynamicType.java
new file mode 100644
index 0000000..e413039
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/PropertyDynamicType.java
@@ -0,0 +1,33 @@
+/*
+* 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.core.domain.configuration;
+
+/**
+ * @author Jason Dobies
+ */
+public enum PropertyDynamicType {
+
+ DATABASE
+ // SERVER-SIDE-PLUGIN - Not supported yet, but ultimately this is an example of why this enum exists
+
+}
commit 0f194a7fb5ea6889a6e978e4be2f1c045dc7f151
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Tue Jan 12 17:00:52 2010 -0800
1384 - validate format of cron input
diff --git a/modules/core/domain/src/test/java/org/rhq/core/domain/content/test/RepoTest.java b/modules/core/domain/src/test/java/org/rhq/core/domain/content/test/RepoTest.java
new file mode 100644
index 0000000..7b5a402
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/content/test/RepoTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.domain.content.test;
+
+import javax.persistence.EntityManager;
+
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.content.Repo;
+import org.rhq.core.domain.test.AbstractEJB3Test;
+
+@Test
+public class RepoTest extends AbstractEJB3Test {
+ public void testInsert() throws Exception {
+ getTransactionManager().begin();
+ try {
+ EntityManager em = getEntityManager();
+ Repo repo = new Repo("testRepoTest");
+ repo.setSyncSchedule("0 0 5 * * ?");
+ em.persist(repo);
+ em.flush();
+ em.close();
+ em = getEntityManager();
+
+ Repo lookedUp = em.find(Repo.class, repo.getId());
+ assert lookedUp != null;
+ assert lookedUp.getSyncSchedule().equals("0 0 5 * * ?");
+
+ } finally {
+ getTransactionManager().rollback();
+ }
+ }
+
+}
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 2d969cf..c79d561 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
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.server.content;
+import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -33,6 +34,7 @@ import javax.persistence.Query;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.quartz.CronExpression;
import org.quartz.SchedulerException;
import org.jboss.annotation.IgnoreDependency;
@@ -300,10 +302,7 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
@RequiredPermission(Permission.MANAGE_INVENTORY)
public Repo updateRepo(Subject subject, Repo repo) throws RepoException {
- if (repo.getName() == null || repo.getName().trim().equals("")) {
- throw new RepoException("Repo name is required");
- }
-
+ validateFields(repo);
// HHH-2864 - Leave this in until we move to hibernate > 3.2.r14201-2
getRepo(subject, repo.getId());
@@ -790,10 +789,21 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
repo.addRepoRelationship(repoRelationship);
}
- private void validateRepo(Repo c) throws RepoException {
- if (c.getName() == null || c.getName().trim().equals("")) {
+ private void validateFields(Repo repo) throws RepoException {
+ if (repo.getName() == null || repo.getName().trim().equals("")) {
throw new RepoException("Repo name is required");
}
+ if (repo.getSyncSchedule() != null) {
+ try {
+ CronExpression ce = new CronExpression(repo.getSyncSchedule());
+ } catch (ParseException e) {
+ throw new RepoException("Repo sync schedule is not a vaild format.");
+ }
+ }
+ }
+
+ private void validateRepo(Repo c) throws RepoException {
+ this.validateFields(c);
List<Repo> repos = getRepoByName(c.getName());
if (repos.size() != 0) {
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/QuartzScheduleFormatTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/QuartzScheduleFormatTest.java
new file mode 100644
index 0000000..01c1f88
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/QuartzScheduleFormatTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.content.test;
+
+import java.text.ParseException;
+
+import junit.framework.TestCase;
+
+import org.quartz.CronExpression;
+
+/**
+ * @author mmccune
+ *
+ */
+public class QuartzScheduleFormatTest extends TestCase {
+
+ public void testValidFormat() {
+ String test = "23asdf";
+ boolean failed = false;
+ try {
+ CronExpression ce = new CronExpression(test);
+ } catch (ParseException e) {
+ failed = true;
+ }
+ assert failed;
+
+ test = "0 0 3 * * ?";
+ failed = false;
+ try {
+ CronExpression ce = new CronExpression(test);
+ } catch (ParseException e) {
+ failed = true;
+ }
+
+ assert !failed;
+
+ }
+}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
index 2d9f78b..bf7657a 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/content/test/RepoManagerBeanTest.java
@@ -466,4 +466,27 @@ public class RepoManagerBeanTest extends AbstractEJB3Test {
assert reposWithOldName.size() == 0;
}
+
+ @Test(enabled = ENABLED)
+ public void updateSyncSchedule() {
+ Repo repo = new Repo("updateSyncSchedule");
+ repo.setSyncSchedule("NOT A VALID CRON");
+ boolean failed = false;
+ try {
+ repo = repoManager.createRepo(overlord, repo);
+ } catch (RepoException e) {
+ failed = true;
+ }
+ assert failed;
+
+ failed = false;
+ repo.setSyncSchedule("0 0 3 * * ?");
+ try {
+ repo = repoManager.createRepo(overlord, repo);
+ } catch (RepoException e) {
+ failed = true;
+ }
+ assert !failed;
+ }
+
}
\ No newline at end of file
commit f13bee90803cd5713c80f58310e7d561691b0461
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Tue Jan 12 16:16:02 2010 -0800
1383, 1385, 1387 - can now edit/save the sync schedule.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
index 2fdbb50..5f4061c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/Repo.java
@@ -143,6 +143,9 @@ public class Repo implements Serializable, Taggable {
@Column(name = "IS_CANDIDATE", nullable = false)
private boolean candidate;
+ @Column(name = "SYNC_SCHEDULE", nullable = true)
+ private String syncSchedule = "0 0 3 * * ?";
+
@OneToMany(mappedBy = "repo", fetch = FetchType.LAZY)
private Set<ResourceRepo> resourceRepos;
@@ -254,6 +257,25 @@ public class Repo implements Serializable, Taggable {
}
/**
+ * Periodically, the Repo will be asked to synchronize with the remote ContentProviders associated with it
+ * This attribute defines the schedule, as a cron string. The default will be set for everyday at
+ * 3:00am local time. If this content source should never automatically sync, this should be null, but
+ * an empty string would also indicate this, too.
+ *
+ * @return sync schedule as a cron string or null if the sync should not automatically occur
+ */
+ public String getSyncSchedule() {
+ return syncSchedule;
+ }
+
+ public void setSyncSchedule(String syncSchedule) {
+ if (syncSchedule != null && syncSchedule.trim().length() == 0) {
+ syncSchedule = null;
+ }
+ this.syncSchedule = syncSchedule;
+ }
+
+ /**
* Returns the explicit mapping entities.
*
* @return the mapping entities
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
index 39b2056..c80471e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/content/repo.xhtml
@@ -66,6 +66,14 @@
value="#{RepoDetailsUIBean.repo.description}" /></td>
</tr>
<tr>
+ <td align="right"><b>Sync Schedule:</b></td>
+ <td align="left"><h:inputText
+ rendered="${mode eq 'edit'}"
+ value="#{RepoDetailsUIBean.repo.syncSchedule}" /> <h:outputText
+ rendered="${mode ne 'edit'}"
+ value="#{RepoDetailsUIBean.repo.syncSchedule}" /></td>
+ </tr>
+ <tr>
<td align="right"><b>Creation Date:</b></td>
<td align="left"><h:outputText
value="#{RepoDetailsUIBean.repo.creationDate}">
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 6c6d77e..2d969cf 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
@@ -312,6 +312,14 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
repo = entityManager.merge(repo);
log.debug("User [" + subject + "] updated repo [" + repo + "]");
+ try {
+ ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer();
+ pc.unscheduleRepoSyncJob(repo);
+ pc.scheduleRepoSyncJob(repo);
+ } catch (Exception e) {
+ log.warn("Failed to reschedule for [" + repo + "]", e);
+ }
+
return repo;
}
@@ -324,6 +332,16 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
entityManager.persist(repo);
log.debug("User [" + subject + "] created repo [" + repo + "]");
+ // Schedule the repo sync job.
+ try {
+ ContentServerPluginContainer pc = ContentManagerHelper.getPluginContainer();
+ // Schedule a job for the future
+ pc.scheduleRepoSyncJob(repo);
+ } catch (Exception e) {
+ log.error("error trying to schedule RepoSync", e);
+ throw new RuntimeException(e);
+ }
+
return repo; // now has the ID set
}
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 6fa249a..da28caa 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
@@ -19,6 +19,7 @@
package org.rhq.enterprise.server.plugin.pc.content;
import java.util.Date;
+import java.util.Set;
import org.quartz.JobDetail;
import org.quartz.SchedulerException;
@@ -44,7 +45,8 @@ import org.rhq.enterprise.server.xmlschema.generated.serverplugin.content.Conten
*/
public class ContentServerPluginContainer extends AbstractTypeServerPluginContainer {
- private static final String SYNC_JOB_GROUP_NAME = "syncContentSource";
+ private static final String CONTENT_SRC_SYNC_JOB_GROUP_NAME = "syncContentSource";
+ private static final String REPO_SYNC_JOB_GROUP_NAME = "syncRepo";
private ContentProviderManager adapterManager;
@@ -111,8 +113,8 @@ 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(ContentProviderSyncJob.createUniqueJobName(contentSource), SYNC_JOB_GROUP_NAME,
- ContentProviderSyncJob.class, false, false, false);
+ JobDetail job = new JobDetail(ContentProviderSyncJob.createUniqueJobName(contentSource),
+ CONTENT_SRC_SYNC_JOB_GROUP_NAME, ContentProviderSyncJob.class, false, false, false);
ContentProviderSyncJob.createJobDataMap(contentSource, job);
@@ -122,8 +124,9 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
Date next = scheduler.scheduleJob(job, trigger);
- getLog().info("Scheduled content provider sync job [" + job.getName() + ':' + job.getGroup() +
- "] to fire now at [" + next + "] for [" + contentSource + "]");
+ getLog().info(
+ "Scheduled content provider sync job [" + job.getName() + ':' + job.getGroup() + "] to fire now at ["
+ + next + "] for [" + contentSource + "]");
}
/**
@@ -134,7 +137,7 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
* @throws SchedulerException if the job cannot be scheduled
*/
public void syncRepoNow(Repo repo) throws SchedulerException {
- JobDetail job = new JobDetail(RepoSyncJob.createUniqueJobName(repo), SYNC_JOB_GROUP_NAME,
+ JobDetail job = new JobDetail(RepoSyncJob.createUniqueJobName(repo), CONTENT_SRC_SYNC_JOB_GROUP_NAME,
RepoSyncJob.class, false, false, false);
RepoSyncJob.createJobDataMap(job, repo);
@@ -145,8 +148,9 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
Date next = scheduler.scheduleJob(job, trigger);
- getLog().info("Scheduled repo sync job [" + job.getName() + ':' + job.getGroup() +
- "] to fire now at [" + next + "] for [" + repo + "]");
+ getLog().info(
+ "Scheduled repo sync job [" + job.getName() + ':' + job.getGroup() + "] to fire now at [" + next
+ + "] for [" + repo + "]");
}
/**
@@ -169,12 +173,37 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
}
SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
- scheduler.scheduleCronJob(ContentProviderSyncJob.createJobName(contentSource), SYNC_JOB_GROUP_NAME,
+ scheduler.scheduleCronJob(ContentProviderSyncJob.createJobName(contentSource), CONTENT_SRC_SYNC_JOB_GROUP_NAME,
ContentProviderSyncJob.createJobDataMap(contentSource, null), ContentProviderSyncJob.class, true, false,
syncSchedule);
}
/**
+ * This will schedule the sync job for the given content source. Once the scheduling is complete, the content
+ * source's adapter will be asked to synchronize with the remote content source according to the time(s) specified
+ * in the {@link ContentSource#getSyncSchedule() schedule}.
+ *
+ * <p>If the content source's sync schedule is empty, this method assumes it should not be automatically sync'ed so
+ * no schedule will be created and this method simply returns.</p>
+ *
+ * @param contentSource provider to sync
+ *
+ * @throws SchedulerException if failed to schedule the job
+ */
+ public void scheduleRepoSyncJob(Repo repo) throws SchedulerException {
+ String syncSchedule = repo.getSyncSchedule();
+ if ((syncSchedule == null) || (syncSchedule.trim().length() == 0)) {
+ getLog().warn(repo.toString() + " does not define a sync schedule - not scheduling");
+ return;
+ }
+
+ SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
+
+ scheduler.scheduleCronJob(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME, RepoSyncJob
+ .createJobDataMap(null, repo), RepoSyncJob.class, true, false, syncSchedule);
+ }
+
+ /**
* It will schedule one job per adapter such that each adapter is scheduled to be synchronized as per its defined
* sync schedule. This must only be called when all content source adapters have been initialized.
*/
@@ -182,7 +211,15 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
if (this.adapterManager != null) {
for (ContentSource contentSource : this.adapterManager.getAllContentSources()) {
try {
+ getLog().debug("scheduleSyncJobs :: Scheduling CP job: " + contentSource.getName());
scheduleProviderSyncJob(contentSource);
+ Set<Repo> repos = contentSource.getRepos();
+ if (repos != null) {
+ for (Repo repo : repos) {
+ getLog().debug("scheduleSyncJobs :: Scheduling REPO job: " + repo.getName());
+ scheduleRepoSyncJob(repo);
+ }
+ }
} catch (Exception e) {
getLog().warn("Could not schedule sync job for content source [" + contentSource + "]", e);
}
@@ -200,7 +237,19 @@ public class ContentServerPluginContainer extends AbstractTypeServerPluginContai
*/
public void unscheduleProviderSyncJob(ContentSource contentSource) throws SchedulerException {
SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
- scheduler.deleteJob(ContentProviderSyncJob.createJobName(contentSource), SYNC_JOB_GROUP_NAME);
+ scheduler.deleteJob(ContentProviderSyncJob.createJobName(contentSource), CONTENT_SRC_SYNC_JOB_GROUP_NAME);
+ }
+
+ /**
+ * This will unschedule the sync job for the given Repo.
+ *
+ * @param repo cannot be <code>null</code>
+ *
+ * @throws SchedulerException if failed to unschedule the job
+ */
+ public void unscheduleRepoSyncJob(Repo repo) throws SchedulerException {
+ SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
+ scheduler.deleteJob(RepoSyncJob.createJobName(repo), REPO_SYNC_JOB_GROUP_NAME);
}
protected ServerPluginManager createPluginManager() {
commit 8150ad6b7fe304d4b27e4a393737cf0508003bf0
Merge: abb58c7... 8c6f3cf...
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Tue Jan 12 10:07:54 2010 -0800
Merge branch 'master' into content
commit abb58c79dbca0284913fdd9dbb6f524ed508ef3c
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Tue Jan 12 13:05:30 2010 -0500
fix unittest failure
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
index c0295b2..3293933 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
@@ -67,14 +67,16 @@ public class RegistrationBeanTest extends AbstractEJB3Test {
public void testReleaseRepoMap() throws Exception {
String release = "5Server";
+ String version = "5.4.0";
String arch = "x86_64";
- ReleaseRepoMapping repomap = new ReleaseRepoMapping(release, arch);
+ ReleaseRepoMapping repomap = new ReleaseRepoMapping(release, version, arch);
String repo = repomap.getCompatibleRepo();
assert (repo == "rhel-x86_64-server-5");
String release2 = "5Client";
String arch2 = "x86_64";
- ReleaseRepoMapping repomap2 = new ReleaseRepoMapping(release2, arch2);
+ String version2 = "5.4.0";
+ ReleaseRepoMapping repomap2 = new ReleaseRepoMapping(release2, version2, arch2);
String repo2 = repomap2.getCompatibleRepo();
assert (repo2 == "rhel-x86_64-client-5");
commit db2f300fbf1bf9c17e66d13c4f4ebc44380bd539
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Mon Jan 11 16:36:01 2010 -0800
1382 - sync schedule
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 356e6ac..a9f912b 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.74</db.schema.version>
+ <db.schema.version>2.75</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
index 5ba8ebb..261ac25 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/content-schema.xml
@@ -79,6 +79,7 @@
<column name="CREATION_TIME" type="LONG" required="true"/>
<column name="LAST_MODIFIED_TIME" type="LONG" required="true"/>
<column name="IS_CANDIDATE" type="BOOLEAN" required="true"/>
+ <column name="SYNC_SCHEDULE" size="64" type="VARCHAR2" required="false"/>
<index name="RHQ_REPO_IDX" unique="true">
<field ref="NAME"/>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 5e8a703..cd9ebc3 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2756,6 +2756,11 @@
</statement>
</schema-directSQL>
</schemaSpec>
+
+ <schemaSpec version="2.75">
+ <schema-addColumn table="RHQ_REPO" column="SYNC_SCHEDULE" columnType="VARCHAR2" precision="64" />
+ </schemaSpec>
</dbupgrade>
</target>
</project>
+
commit d40066dbc341965193e07109395a5d9badec5a46
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Mon Jan 11 19:36:19 2010 -0500
Supporting bean layer calls for bootstrap process to leverage to register a rhel client, import it as a managed resource, subscribe the resource to compatible base channel if available based on release,version and arch information sent from the clients. The resource created is associated to a dummy agent which will have the same host and port as the resource but does nothing. More work left to sync the agents once they are installed on the clients. These basic calls should siffice the goal of bootstrapping.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
index 7cd0da7..6253c8d 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeModelUIBean.java
@@ -20,10 +20,10 @@ package org.rhq.enterprise.gui.navigation.resource;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.HashSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -88,7 +88,6 @@ public class ResourceTreeModelUIBean {
HibernatePerformanceMonitor.get().stop(monitorId, "ResourceTree agent resource");
log.debug("Loaded " + resources.size() + " raw resources in " + (end - start));
-
start = System.currentTimeMillis();
monitorId = HibernatePerformanceMonitor.get().start();
rootNode = load(rootResource.getId(), resources, false);
@@ -110,7 +109,6 @@ public class ResourceTreeModelUIBean {
return root;
}
-
public static void load(ResourceTreeNode parentNode, boolean alwaysGroup) {
if (parentNode.getData() instanceof Resource) {
@@ -169,9 +167,9 @@ public class ResourceTreeModelUIBean {
if (rsc instanceof ResourceSubCategory) {
agc = new AutoGroupComposite(avail, parentResource, (ResourceSubCategory) rsc, entries.size());
} else if (rsc instanceof ResourceType) {
- boolean isDupResourceTypeName = dupResourceTypeNames.contains(((ResourceType)rsc).getName());
+ boolean isDupResourceTypeName = dupResourceTypeNames.contains(((ResourceType) rsc).getName());
agc = new AutoGroupComposite(avail, parentResource, (ResourceType) rsc, entries.size(),
- isDupResourceTypeName);
+ isDupResourceTypeName);
}
ResourceTreeNode node = new ResourceTreeNode(agc);
load(node, alwaysGroup);
@@ -198,42 +196,45 @@ public class ResourceTreeModelUIBean {
AutoGroupComposite compositeParent = (AutoGroupComposite) parentNode.getData();
Map<Object, List<Resource>> children = new HashMap<Object, List<Resource>>();
- for (Resource res : compositeParent.getParentResource().getChildResources()) {
- if (compositeParent.getSubcategory() != null) {
- // parent is a sub category
- if (res.getResourceType().getSubCategory() != null
- && compositeParent.getSubcategory().equals(
- res.getResourceType().getSubCategory().getParentSubCategory())
- && compositeParent.getParentResource().equals(res.getParentResource())) {
-
- // A subSubCategory in a subcategory
- if (children.containsKey(res.getResourceType().getSubCategory())) {
- children.get(res.getResourceType().getSubCategory()).add(res);
- } else {
- ArrayList<Resource> list = new ArrayList<Resource>();
- list.add(res);
- children.put(res.getResourceType().getSubCategory(), list);
+ log.error("composite parent" + compositeParent);
+ if (compositeParent != null) {
+ for (Resource res : compositeParent.getParentResource().getChildResources()) {
+ if (compositeParent.getSubcategory() != null) {
+ // parent is a sub category
+ if (res.getResourceType().getSubCategory() != null
+ && compositeParent.getSubcategory().equals(
+ res.getResourceType().getSubCategory().getParentSubCategory())
+ && compositeParent.getParentResource().equals(res.getParentResource())) {
+
+ // A subSubCategory in a subcategory
+ if (children.containsKey(res.getResourceType().getSubCategory())) {
+ children.get(res.getResourceType().getSubCategory()).add(res);
+ } else {
+ ArrayList<Resource> list = new ArrayList<Resource>();
+ list.add(res);
+ children.put(res.getResourceType().getSubCategory(), list);
+ }
+ } else if (compositeParent.getSubcategory().equals(res.getResourceType().getSubCategory())
+ && compositeParent.getParentResource().equals(res.getParentResource())) {
+ // Direct entries in a subcategory... now group them by autogroup (type)
+ if (children.containsKey(res.getResourceType())) {
+ children.get(res.getResourceType()).add(res);
+ } else {
+ ArrayList<Resource> list = new ArrayList<Resource>();
+ list.add(res);
+ children.put(res.getResourceType(), list);
+ }
}
- } else if (compositeParent.getSubcategory().equals(res.getResourceType().getSubCategory())
- && compositeParent.getParentResource().equals(res.getParentResource())) {
- // Direct entries in a subcategory... now group them by autogroup (type)
- if (children.containsKey(res.getResourceType())) {
- children.get(res.getResourceType()).add(res);
- } else {
- ArrayList<Resource> list = new ArrayList<Resource>();
- list.add(res);
- children.put(res.getResourceType(), list);
- }
- }
- } else if (compositeParent.getResourceType() != null) {
- if (compositeParent.getResourceType().equals(res.getResourceType())
- && compositeParent.getParentResource().getId() == res.getParentResource().getId()) {
- if (children.containsKey(res.getResourceType())) {
- children.get(res.getResourceType()).add(res);
- } else {
- ArrayList<Resource> list = new ArrayList<Resource>();
- list.add(res);
- children.put(res.getResourceType(), list);
+ } else if (compositeParent.getResourceType() != null) {
+ if (compositeParent.getResourceType().equals(res.getResourceType())
+ && compositeParent.getParentResource().getId() == res.getParentResource().getId()) {
+ if (children.containsKey(res.getResourceType())) {
+ children.get(res.getResourceType()).add(res);
+ } else {
+ ArrayList<Resource> list = new ArrayList<Resource>();
+ list.add(res);
+ children.put(res.getResourceType(), list);
+ }
}
}
}
@@ -324,9 +325,9 @@ public class ResourceTreeModelUIBean {
Set<String> dupResourceTypeNames = new HashSet();
for (Object rsc : children.keySet()) {
if (rsc != null
- && (rsc instanceof ResourceType && (children.get(rsc).size() > 1 || (alwaysGroup && children
- .get(rsc).size() == 1)))) {
- String resourceTypeName = ((ResourceType)rsc).getName();
+ && (rsc instanceof ResourceType && (children.get(rsc).size() > 1 || (alwaysGroup && children.get(rsc)
+ .size() == 1)))) {
+ String resourceTypeName = ((ResourceType) rsc).getName();
if (resourceTypeNames.contains(resourceTypeName)) {
dupResourceTypeNames.add(resourceTypeName);
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java
index 28adc98..a848358 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/navigation/resource/ResourceTreeNode.java
@@ -18,15 +18,15 @@
*/
package org.rhq.enterprise.gui.navigation.resource;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.composite.ResourceWithAvailability;
import org.rhq.core.domain.resource.group.composite.AutoGroupComposite;
import org.rhq.core.util.sort.HumaneStringComparator;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
/**
* Just a basic node to hold resources, resource auto groups and subcategories
* in a tree.
@@ -58,8 +58,11 @@ public class ResourceTreeNode implements Comparable<ResourceTreeNode> {
}
public String toString() {
+ if (level == null) {
+ return "";
+ }
if (level instanceof AutoGroupComposite) {
- AutoGroupComposite composite = ((AutoGroupComposite) level) ;
+ AutoGroupComposite composite = ((AutoGroupComposite) level);
return composite.getName();
} else if (level instanceof ResourceWithAvailability) {
return ((ResourceWithAvailability) level).getResource().getName();
@@ -79,12 +82,15 @@ public class ResourceTreeNode implements Comparable<ResourceTreeNode> {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
ResourceTreeNode that = (ResourceTreeNode) o;
- if (!level.equals(that.level)) return false;
+ if (!level.equals(that.level))
+ return false;
return true;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationException.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationException.java
new file mode 100644
index 0000000..f7a3b40
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationException.java
@@ -0,0 +1,38 @@
+/*
+ * 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.registration;
+
+public class RegistrationException extends Exception {
+ private static final long serialVersionUID = -2258189843514401027L;
+
+ public RegistrationException() {
+ }
+
+ public RegistrationException(String message) {
+ super(message);
+ }
+
+ public RegistrationException(Throwable cause) {
+ super(cause);
+ }
+
+ public RegistrationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
new file mode 100644
index 0000000..2ebc9f2
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerBean.java
@@ -0,0 +1,222 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.registration;
+
+import java.util.List;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.jboss.annotation.IgnoreDependency;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.content.Repo;
+import org.rhq.core.domain.resource.Agent;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.server.RHQConstants;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
+import org.rhq.enterprise.server.content.RepoManagerLocal;
+import org.rhq.enterprise.server.core.AgentManagerLocal;
+import org.rhq.enterprise.server.resource.ResourceAlreadyExistsException;
+import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+@Stateless
+public class RegistrationManagerBean implements RegistrationManagerLocal, RegistrationManagerRemote {
+
+ private final Log log = LogFactory.getLog(RegistrationManagerBean.class.getName());
+
+ @PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
+ private EntityManager entityManager;
+ @EJB
+ @IgnoreDependency
+ private ResourceManagerLocal resourceManager;
+ @EJB
+ private SubjectManagerLocal subjectManager;
+ @EJB
+ private AgentManagerLocal agentManager;
+
+ /**
+ * Registers the platform as a resource on RHQ server
+ * @param user secure id user
+ * @param platform to be registered
+ * @param parenId if any.
+ *
+ */
+ public void registerPlatform(Subject user, Resource platform, int parentId) {
+ try {
+ validatePlatform(platform);
+ } catch (RegistrationException e) {
+ throw new IllegalStateException(e);
+ }
+
+ platform.setInventoryStatus(InventoryStatus.COMMITTED);
+
+ Agent agent = createFakeAgent(platform);
+ platform.setAgent(agent);
+
+ try {
+ resourceManager.createResource(user, platform, parentId);
+ } catch (ResourceAlreadyExistsException e) {
+ throw new IllegalStateException(e);
+ }
+
+ log.error("Resource " + platform + "persisted");
+
+ }
+
+ /**
+ * Imports the registered resource into inventory and makes it a managed resource
+ * @param user secure id user
+ * @param platform to be imported
+ *
+ */
+ public void importPlatform(Subject user, Resource resource) {
+ resource.setInventoryStatus(InventoryStatus.COMMITTED);
+ entityManager.persist(resource);
+ }
+
+ /**
+ * subscribe the requested platform to a compatible base repo based on release
+ * and arch information. This method does a lookup in ReleaseRepoMapping
+ * to get the compatible base channel and tried to tie the platform to
+ * the repo.
+ * @param user secure id user
+ * @param platform to be imported
+ * @param release the release string of the client
+ * @param arch arch of the platform
+ */
+ public void subscribePlatformToBaseRepo(Subject user, Resource platform, String release, String version, String arch)
+ throws RegistrationException {
+ log.debug("Trying to subscribe " + platform + " to a compatible baserepo");
+ ReleaseRepoMapping rm = new ReleaseRepoMapping(release, version, arch);
+ String repoName = rm.getCompatibleRepo();
+ try {
+ RepoManagerLocal repoManager = LookupUtil.getRepoManagerLocal();
+ List<Repo> repos = repoManager.getRepoByName(repoName);
+ int[] repoIds = getIntRepoIdArray(repos);
+ repoManager.subscribeResourceToRepos(user, platform.getId(), repoIds);
+ } catch (Exception e) {
+ throw new RegistrationException("No Compatible Base repo Found." + e);
+ }
+ }
+
+ /**
+ * Validates the sanity of the resource to be created. Also checks to see if the platform
+ * alreday exists.
+ * @param platform
+ * @throws RegistrationException
+ */
+ private void validatePlatform(Resource platform) throws RegistrationException {
+ if (platform.getResourceType() == null) {
+ throw new RegistrationException("Reported resource [" + platform + "] has a null type.");
+ }
+
+ if (platform.getResourceKey() == null) {
+ throw new RegistrationException("Reported resource [" + platform + "] has a null key.");
+ }
+
+ if (platform.getInventoryStatus() == InventoryStatus.DELETED) {
+ throw new RegistrationException(
+ "Reported resource ["
+ + platform
+ + "] has an illegal inventory status of 'DELETED' - agents are not allowed to delete platforms from inventory.");
+ }
+
+ //check if the resource already exists
+ Resource existingPlatform = checkResourceExists(platform);
+
+ if (existingPlatform != null) {
+ throw new RegistrationException("Reported resource [" + platform + "] Already Exists.");
+ }
+
+ }
+
+ /**
+ * Checks to see if the resource already exists in rhq
+ * @param platform
+ * @return
+ */
+ private Resource checkResourceExists(Resource platform) {
+ Resource existingResource = null;
+
+ if (platform.getId() != 0) {
+ existingResource = entityManager.find(Resource.class, platform.getId());
+ }
+
+ if (existingResource == null) {
+ ResourceType resourceType = platform.getResourceType();
+ existingResource = resourceManager.getResourceByParentAndKey(subjectManager.getOverlord(), platform
+ .getParentResource(), platform.getResourceKey(), resourceType.getPlugin(), resourceType.getName());
+ if (existingResource != null) {
+ platform.setId(existingResource.getId());
+ } else {
+
+ if (platform.getId() != 0) {
+ platform.setId(0);
+ }
+ }
+ }
+
+ return existingResource;
+ }
+
+ /**
+ * Creates an agent for a given resource and persist in the db. The agents role is noop
+ * until its installed on the client and tied to this row in the db.
+ * @param resource
+ * @return
+ */
+ private Agent createFakeAgent(Resource resource) {
+ String address = resource.getName();
+ int port = 16163;
+ String endPoint = "socket://" + address + ":" + port + "/?rhq.communications.connector.rhqtype=agent";
+ Agent agent = agentManager.getAgentByAddressAndPort(resource.getName(), 16163);
+ if (agent == null) {
+ agent = new Agent(resource.getName(), address, port, endPoint, resource.getResourceKey());
+
+ entityManager.persist(agent);
+ entityManager.flush();
+ }
+ return agent;
+
+ }
+
+ private int[] getIntRepoIdArray(List<Repo> input) {
+ if (input == null) {
+ return new int[0];
+ }
+
+ int[] output = new int[input.size()];
+ for (int i = 0; i < input.size(); i++) {
+ output[i] = Integer.valueOf(input.get(i).getId()).intValue();
+ }
+
+ return output;
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerLocal.java
new file mode 100644
index 0000000..a1ef1c9
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerLocal.java
@@ -0,0 +1,52 @@
+/*
+ * 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.registration;
+
+import javax.ejb.Local;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.resource.Resource;
+
+@Local
+public interface RegistrationManagerLocal {
+ /**
+ * Register the platform in the inventory
+ * @param user
+ * @param resource
+ */
+ void registerPlatform(Subject user, Resource resource, int parentId);
+
+ /**
+ * Import the inventoried resource as a managed resource object
+ * @param user
+ * @param resourceId
+ */
+ void importPlatform(Subject user, Resource resource);
+
+ /**
+ * subscribe a platform to a compatible baserepo
+ * @param user
+ * @param platform
+ * @param release
+ * @param arch
+ */
+ void subscribePlatformToBaseRepo(Subject user, Resource platform, String release, String version, String arch)
+ throws RegistrationException;
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerRemote.java
new file mode 100644
index 0000000..7ee0ac6
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/RegistrationManagerRemote.java
@@ -0,0 +1,52 @@
+/*
+ * 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.registration;
+
+import javax.ejb.Remote;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.resource.Resource;
+
+@Remote
+public interface RegistrationManagerRemote {
+ /**
+ * Register the platform in the inventory
+ * @param user
+ * @param resource
+ */
+ void registerPlatform(Subject user, Resource resource, int parentId);
+
+ /**
+ * Import the inventoried resource as a managed resource object
+ * @param user
+ * @param resourceId
+ */
+ void importPlatform(Subject user, Resource resource);
+
+ /**
+ * subscribe a platform to a compatible baserepo
+ * @param user
+ * @param platform
+ * @param release
+ * @param arch
+ */
+ void subscribePlatformToBaseRepo(Subject user, Resource platform, String release, String version, String arch)
+ throws RegistrationException;
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/ReleaseRepoMapping.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/ReleaseRepoMapping.java
new file mode 100644
index 0000000..5f98da4
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/registration/ReleaseRepoMapping.java
@@ -0,0 +1,76 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.registration;
+
+import java.util.HashMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Class representing the repo to release relationship.
+ * Ideally This should be persisted in the database at the sync time
+ * from hosted and should do a lookup in the db to extract compatible repos.
+ *
+ * Since we're still unsure if we want go the agentless route,
+ * Just using static mappings for now. This will be eventually replaced
+ * by persisting these mapping in the db.
+ *
+ * @author pkilambi
+ *
+ */
+public class ReleaseRepoMapping {
+ private final Log log = LogFactory.getLog(ReleaseRepoMapping.class.getName());
+ private String release;
+ private String arch;
+ private String version;
+
+ public ReleaseRepoMapping(String release, String version, String arch) {
+ this.release = release;
+ this.arch = arch;
+ this.version = version; //ignored for now, used for z-stream repos in future
+ }
+
+ public String getCompatibleRepo() {
+ HashMap<String, String> repomap = generateRepoMap();
+ log.debug("mapping generated " + repomap);
+ return repomap.get(this.release + "." + this.arch);
+ }
+
+ /**
+ * Static mappings for base repos
+ * @return
+ */
+ private HashMap<String, String> generateRepoMap() {
+ HashMap<String, String> hm = new HashMap<String, String>();
+
+ hm.put("5Server.arch", "rhel-arch-server-5");
+ hm.put("5Client.arch", "rhel-arch-client-5");
+
+ String[] arches = { "i386", "x86_64", "ia64", "s390x", "ppc" };
+ HashMap<String, String> newhm = new HashMap();
+ for (String k : hm.keySet()) {
+ for (String arch : arches) {
+ newhm.put(k.replace("arch", arch), hm.get(k).replace("arch", arch));
+ }
+ }
+ return newhm;
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index 5b2716c..01c9b7d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -159,18 +159,17 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
if (parent == null) {
throw new ResourceNotFoundException("Intended parent for new resource does not exist.");
}
- }
- if (!authorizationManager.hasResourcePermission(user, Permission.CREATE_CHILD_RESOURCES, parent.getId())) {
- throw new PermissionException("You do not have permission to add this resource as a child.");
- }
+ if (!authorizationManager.hasResourcePermission(user, Permission.CREATE_CHILD_RESOURCES, parent.getId())) {
+ throw new PermissionException("You do not have permission to add this resource as a child.");
+ }
- if (getResourceByParentAndKey(user, parent, resource.getResourceKey(), resource.getResourceType().getPlugin(),
- resource.getResourceType().getName()) != null) {
- throw new ResourceAlreadyExistsException("Resource with key '" + resource.getResourceKey()
- + "' already exists.");
+ if (getResourceByParentAndKey(user, parent, resource.getResourceKey(), resource.getResourceType()
+ .getPlugin(), resource.getResourceType().getName()) != null) {
+ throw new ResourceAlreadyExistsException("Resource with key '" + resource.getResourceKey()
+ + "' already exists.");
+ }
}
-
if (parent != Resource.ROOT) {
// Only set the relationships if this is not a root resource.
// The cardinal rule is to add the relationship in both directions,
@@ -180,7 +179,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
}
entityManager.persist(resource);
-
+ log.error("********* resource persisted ************");
// Execute sub-methods as overlord to bypass additional security checks.
Subject overlord = this.subjectManager.getOverlord();
updateImplicitMembership(overlord, resource);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index fe9a2ef..9d2a8aa 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -130,6 +130,8 @@ import org.rhq.enterprise.server.perspective.PerspectiveManagerLocal;
import org.rhq.enterprise.server.plugin.ServerPluginsBean;
import org.rhq.enterprise.server.plugin.ServerPluginsLocal;
import org.rhq.enterprise.server.plugin.pc.ServerPluginServiceManagement;
+import org.rhq.enterprise.server.registration.RegistrationManagerBean;
+import org.rhq.enterprise.server.registration.RegistrationManagerLocal;
import org.rhq.enterprise.server.report.DataAccessManagerBean;
import org.rhq.enterprise.server.report.DataAccessManagerLocal;
import org.rhq.enterprise.server.resource.ProductVersionManagerBean;
@@ -484,6 +486,10 @@ public final class LookupUtil {
return lookupRemote(ResourceTypeManagerBean.class);
}
+ public static RegistrationManagerLocal getRegistrationManager() {
+ return lookupLocal(RegistrationManagerBean.class);
+ }
+
public static RoleManagerLocal getRoleManager() {
return lookupLocal(RoleManagerBean.class);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
index 3d768ab..8c43cb4 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/RemoteAPIValidator.java
@@ -38,8 +38,8 @@ import org.rhq.enterprise.server.alert.AlertManagerBean;
import org.rhq.enterprise.server.auth.SubjectManagerBean;
import org.rhq.enterprise.server.authz.RoleManagerBean;
import org.rhq.enterprise.server.configuration.ConfigurationManagerBean;
-import org.rhq.enterprise.server.content.RepoManagerBean;
import org.rhq.enterprise.server.content.ContentManagerBean;
+import org.rhq.enterprise.server.content.RepoManagerBean;
import org.rhq.enterprise.server.event.EventManagerBean;
import org.rhq.enterprise.server.measurement.AvailabilityManagerBean;
import org.rhq.enterprise.server.measurement.CallTimeDataManagerBean;
@@ -49,6 +49,7 @@ import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerBean;
import org.rhq.enterprise.server.measurement.MeasurementProblemManagerBean;
import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerBean;
import org.rhq.enterprise.server.operation.OperationManagerBean;
+import org.rhq.enterprise.server.registration.RegistrationManagerBean;
import org.rhq.enterprise.server.report.DataAccessManagerBean;
import org.rhq.enterprise.server.resource.ResourceFactoryManagerBean;
import org.rhq.enterprise.server.resource.ResourceManagerBean;
@@ -84,6 +85,7 @@ public class RemoteAPIValidator {
ResourceGroupManagerBean.class, //
ResourceManagerBean.class, //
ResourceTypeManagerBean.class, //
+ RegistrationManagerBean.class, //
RoleManagerBean.class, //
SubjectManagerBean.class, //
SupportManagerBean.class, //
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 409d7b3..c531297 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -124,6 +124,8 @@ import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal;
import org.rhq.enterprise.server.operation.GroupOperationSchedule;
import org.rhq.enterprise.server.operation.OperationManagerLocal;
import org.rhq.enterprise.server.operation.ResourceOperationSchedule;
+import org.rhq.enterprise.server.registration.RegistrationException;
+import org.rhq.enterprise.server.registration.RegistrationManagerLocal;
import org.rhq.enterprise.server.resource.ResourceFactoryManagerLocal;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.resource.ResourceNotFoundException;
@@ -173,6 +175,7 @@ public class WebservicesManagerBean implements WebservicesRemote {
private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
private ResourceGroupManagerLocal resourceGroupManager = LookupUtil.getResourceGroupManager();
private ResourceTypeManagerLocal resourceTypeManager = LookupUtil.getResourceTypeManager();
+ private RegistrationManagerLocal registrationManager = LookupUtil.getRegistrationManager();
private RoleManagerLocal roleManager = LookupUtil.getRoleManager();
private SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
private SupportManagerLocal supportManager = LookupUtil.getSupportManager();
@@ -372,8 +375,8 @@ public class WebservicesManagerBean implements WebservicesRemote {
}
public ResourceConfigurationUpdate updateStructuredOrRawConfiguration(Subject subject, int resourceId,
- Configuration newConfiguration, boolean fromStructured)
- throws ResourceNotFoundException, ConfigurationUpdateStillInProgressException {
+ Configuration newConfiguration, boolean fromStructured) throws ResourceNotFoundException,
+ ConfigurationUpdateStillInProgressException {
return configurationManager.updateStructuredOrRawConfiguration(subject, resourceId, newConfiguration,
fromStructured);
}
@@ -656,6 +659,19 @@ public class WebservicesManagerBean implements WebservicesRemote {
pluginConfiguration, resourceConfiguration);
}
+ public void registerPlatform(Subject subject, Resource resource, int parentId) {
+ registrationManager.registerPlatform(subject, resource, parentId);
+ }
+
+ public void importPlatform(Subject subject, Resource resource) {
+ registrationManager.importPlatform(subject, resource);
+ }
+
+ public void subscribePlatformToBaseRepo(Subject user, Resource platform, String release, String version, String arch)
+ throws RegistrationException {
+ registrationManager.subscribePlatformToBaseRepo(user, platform, release, version, arch);
+ }
+
public void createPackageBackedResource(Subject subject, int parentResourceId, int newResourceTypeId,
String newResourceName,//
@XmlJavaTypeAdapter(value = ConfigurationAdapter.class)//
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
index 596d737..8f72716 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesRemote.java
@@ -9,8 +9,8 @@ import org.rhq.enterprise.server.alert.AlertManagerRemote;
import org.rhq.enterprise.server.auth.SubjectManagerRemote;
import org.rhq.enterprise.server.authz.RoleManagerRemote;
import org.rhq.enterprise.server.configuration.ConfigurationManagerRemote;
-import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.content.ContentManagerRemote;
+import org.rhq.enterprise.server.content.RepoManagerRemote;
import org.rhq.enterprise.server.discovery.DiscoveryBossRemote;
import org.rhq.enterprise.server.event.EventManagerRemote;
import org.rhq.enterprise.server.measurement.AvailabilityManagerRemote;
@@ -21,6 +21,7 @@ import org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerRemote;
import org.rhq.enterprise.server.measurement.MeasurementProblemManagerRemote;
import org.rhq.enterprise.server.measurement.MeasurementScheduleManagerRemote;
import org.rhq.enterprise.server.operation.OperationManagerRemote;
+import org.rhq.enterprise.server.registration.RegistrationManagerRemote;
import org.rhq.enterprise.server.resource.ResourceFactoryManagerRemote;
import org.rhq.enterprise.server.resource.ResourceManagerRemote;
import org.rhq.enterprise.server.resource.ResourceTypeManagerRemote;
@@ -57,5 +58,6 @@ public interface WebservicesRemote extends //
RoleManagerRemote,//
SubjectManagerRemote,//
SupportManagerRemote,//
- SystemManagerRemote {
+ SystemManagerRemote, //
+ RegistrationManagerRemote {
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
new file mode 100644
index 0000000..c0295b2
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/registration/test/RegistrationBeanTest.java
@@ -0,0 +1,94 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.registration.test;
+
+import javax.persistence.EntityManager;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.resource.Agent;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.server.registration.RegistrationManagerLocal;
+import org.rhq.enterprise.server.registration.ReleaseRepoMapping;
+import org.rhq.enterprise.server.test.AbstractEJB3Test;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+public class RegistrationBeanTest extends AbstractEJB3Test {
+ private RegistrationManagerLocal registrationManager;
+ private ResourceType platformType;
+ private Agent agent;
+ private int parentId = -1;
+ private Subject overlord;
+
+ @BeforeClass
+ public void beforeClass() throws Exception {
+ this.registrationManager = LookupUtil.getRegistrationManager();
+ this.overlord = LookupUtil.getSubjectManager().getOverlord();
+ }
+
+ @Test(groups = "integration.ejb3")
+ public void testRegisterPlatform() throws Exception {
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ try {
+ createResourceTypes(em);
+ createAgent(em);
+ em.flush();
+
+ Resource platform = new Resource("alpha", "platform", platformType);
+
+ registrationManager.registerPlatform(overlord, platform, parentId);
+
+ } finally {
+ getTransactionManager().rollback();
+ }
+ }
+
+ public void testReleaseRepoMap() throws Exception {
+ String release = "5Server";
+ String arch = "x86_64";
+ ReleaseRepoMapping repomap = new ReleaseRepoMapping(release, arch);
+ String repo = repomap.getCompatibleRepo();
+ assert (repo == "rhel-x86_64-server-5");
+
+ String release2 = "5Client";
+ String arch2 = "x86_64";
+ ReleaseRepoMapping repomap2 = new ReleaseRepoMapping(release2, arch2);
+ String repo2 = repomap2.getCompatibleRepo();
+ assert (repo2 == "rhel-x86_64-client-5");
+
+ }
+
+ private void createAgent(EntityManager em) {
+ agent = new Agent("TestAgent-dbbt", "0.0.0.0", 1, "http://here", "tok");
+ em.persist(agent);
+ }
+
+ private void createResourceTypes(EntityManager entityManager) {
+ platformType = new ResourceType("test platform", "test", ResourceCategory.PLATFORM, null);
+
+ entityManager.persist(platformType);
+ }
+
+}
commit 60cd5aa9ecd61b2548c6be87c38bb38857574908
Author: John Matthews <jmatthew(a)redhat.com>
Date: Mon Jan 11 12:18:24 2010 -0500
build fix
diff --git a/modules/enterprise/gui/content_http-war/pom.xml b/modules/enterprise/gui/content_http-war/pom.xml
index 50e0ad6..5966c8e 100644
--- a/modules/enterprise/gui/content_http-war/pom.xml
+++ b/modules/enterprise/gui/content_http-war/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.rhq</groupId>
- <artifactId>rhq-parent</artifactId>
+ <artifactId>rhq-enterprise-gui-parent</artifactId>
<version>1.4.0-SNAPSHOT</version>
</parent>
diff --git a/modules/enterprise/gui/pom.xml b/modules/enterprise/gui/pom.xml
index ea3588d..9ae5584 100644
--- a/modules/enterprise/gui/pom.xml
+++ b/modules/enterprise/gui/pom.xml
@@ -34,10 +34,11 @@
<modules>
<module>portal-war</module>
<module>installer-war</module>
- <module>webdav-war</module>
+ <module>webdav-war</module>
+ <module>content_http-war</module>
</modules>
</profile>
</profiles>
-</project>
\ No newline at end of file
+</project>
commit 8ac53e72f020d5dd778d373838d6824ac7b4d2e4
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Mon Jan 11 10:01:48 2010 -0500
1347 - Added mechanism to translate and lookup database configuration property values
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java
index ef70fed..f10dc64 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java
@@ -182,7 +182,10 @@ import org.rhq.core.domain.util.serial.ExternalizableStrategy;
+ " FROM Role rr JOIN rr.subjects AS ss " //
+ " WHERE rr.id = :roleId" + " ) " //
+ " AND s.fsystem = FALSE " //
- + " AND s.factive = TRUE") })
+ + " AND s.factive = TRUE"), //
+ @NamedQuery(name = Subject.QUERY_DYNAMIC_CONFIG_VALUES, query = "" //
+ + "SELECT s.name FROM Subject AS s WHERE s.fsystem = false")
+})
@SequenceGenerator(name = "RHQ_SUBJECT_ID_SEQ", sequenceName = "RHQ_SUBJECT_ID_SEQ")
@Table(name = "RHQ_SUBJECT")
/*@Cache(usage= CacheConcurrencyStrategy.TRANSACTIONAL)*/
@@ -211,6 +214,8 @@ public class Subject implements Externalizable {
public static final String QUERY_FIND_AVAILABLE_SUBJECTS_FOR_ALERT_DEFINITION_WITH_EXCLUDES = "Subject.findAvailableSubjectsForAlertDefinitionWithExcludes";
public static final String QUERY_FIND_AVAILABLE_SUBJECTS_FOR_ALERT_DEFINITION = "Subject.findAvailableSubjectForAlertDefinition";
+ public static final String QUERY_DYNAMIC_CONFIG_VALUES = "Subject.dynamicConfigValues";
+
private static final long serialVersionUID = 1L;
@Column(name = "ID", nullable = false)
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java
index 87a1287..089ca55 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java
@@ -90,7 +90,10 @@ import org.rhq.core.domain.auth.Subject;
+ " FROM Role r" //
+ " WHERE r.id NOT IN ( SELECT rn.role.id " //
+ " FROM RoleNotification rn" //
- + " WHERE rn.alertDefinition.id = :alertDefinitionId ) ") })
+ + " WHERE rn.alertDefinition.id = :alertDefinitionId ) "), //
+ @NamedQuery(name = Role.QUERY_DYNAMIC_CONFIG_VALUES, query = "" //
+ + "SELECT r.name FROM Role AS r")
+})
@SequenceGenerator(name = "RHQ_ROLE_ID_SEQ", sequenceName = "RHQ_ROLE_ID_SEQ")
@Table(name = "RHQ_ROLE")
public class Role implements Serializable {
@@ -101,6 +104,8 @@ public class Role implements Serializable {
public static final String QUERY_FIND_AVAILABLE_ROLES_FOR_ALERT_DEFINITION_WITH_EXCLUDES = "Role.findAvailableRolesForAlertDefinitionWithExcludes";
public static final String QUERY_FIND_AVAILABLE_ROLES_FOR_ALERT_DEFINITION = "Role.findAvailableRolesForAlertDefinition";
+ public static final String QUERY_DYNAMIC_CONFIG_VALUES = "Role.dynamicConfigValues";
+
private static final long serialVersionUID = 1L;
@Column(name = "ID", nullable = false)
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
index a4e8530..7c2af68 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/PackageType.java
@@ -64,12 +64,15 @@ import org.rhq.core.domain.resource.ResourceType;
*/
@Entity
@NamedQueries( {
+ @NamedQuery(name = PackageType.QUERY_FIND_ALL, query = "SELECT pt FROM PackageType pt"),
@NamedQuery(name = PackageType.QUERY_FIND_BY_RESOURCE_TYPE_ID, query = "SELECT pt FROM PackageType pt WHERE pt.resourceType.id = :typeId"),
@NamedQuery(name = PackageType.QUERY_FIND_BY_RESOURCE_TYPE_ID_AND_NAME, query = "SELECT pt FROM PackageType pt WHERE pt.resourceType.id = :typeId AND pt.name = :name"),
@NamedQuery(name = PackageType.QUERY_FIND_BY_RESOURCE_TYPE_ID_AND_CREATION_FLAG, query = "SELECT pt FROM PackageType pt "
+ "JOIN pt.resourceType rt "
+ "LEFT JOIN FETCH pt.deploymentConfigurationDefinition cd "
- + "LEFT JOIN FETCH cd.templates cts " + "WHERE rt.id = :typeId AND pt.isCreationData = true") })
+ + "LEFT JOIN FETCH cd.templates cts " + "WHERE rt.id = :typeId AND pt.isCreationData = true"),
+ @NamedQuery(name = PackageType.QUERY_DYNAMIC_CONFIG_VALUES, query = "SELECT pt.name FROM PackageType AS pt")
+})
@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_PACKAGE_TYPE_ID_SEQ")
@Table(name = "RHQ_PACKAGE_TYPE")
@XmlAccessorType(XmlAccessType.FIELD)
@@ -78,10 +81,14 @@ public class PackageType implements Serializable {
private static final long serialVersionUID = 1L;
+ public static final String QUERY_FIND_ALL = "PackageType.findAll";
+
public static final String QUERY_FIND_BY_RESOURCE_TYPE_ID = "PackageType.findByResourceTypeId";
public static final String QUERY_FIND_BY_RESOURCE_TYPE_ID_AND_NAME = "PackageType.findByResourceTypeIdAndName";
public static final String QUERY_FIND_BY_RESOURCE_TYPE_ID_AND_CREATION_FLAG = "PackageType.findByResourceTypeIdAndCreationFlag";
+ public static final String QUERY_DYNAMIC_CONFIG_VALUES = "PackageType.dynamicConfigValues";
+
// Attributes --------------------------------------------
@Column(name = "ID", nullable = false)
@@ -221,7 +228,7 @@ public class PackageType implements Serializable {
/**
* Indicates if this package type will be of any specific architecture. If this is <code>true</code>, each package
* may be of a different architecture. If this is <code>false</code>, all packages will be of architecture
- * "noarch".
+ * "noarch".
*/
public boolean isSupportsArchitecture() {
return supportsArchitecture;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.java
new file mode 100644
index 0000000..dd9f844
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBean.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.configuration;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.enterprise.server.RHQConstants;
+
+/**
+ * @see DynamicConfigurationPropertyLocal
+ *
+ * @author Jason Dobies
+ */
+@Stateless
+public class DynamicConfigurationPropertyBean implements DynamicConfigurationPropertyLocal {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ @PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
+ private EntityManager entityManager;
+
+ @SuppressWarnings("unchecked")
+ public List<String> lookupValues(String key) {
+
+ String queryName = PropertyExpressionEvaluator.getQueryNameForKey(key);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Lookup value for key [" + key + "] found query name [" + queryName + "]");
+ }
+
+ if (queryName == null) {
+ return Collections.emptyList();
+ }
+
+ Query query = entityManager.createNamedQuery(queryName);
+ List<String> results = query.getResultList();
+
+ return results;
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java
new file mode 100644
index 0000000..613e28c
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyLocal.java
@@ -0,0 +1,44 @@
+/*
+* 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.configuration;
+
+import java.util.List;
+
+/**
+ * Responsible for retrieving configuration property values from the database.
+ *
+ * @author Jason Dobies
+ */
+public interface DynamicConfigurationPropertyLocal {
+
+ /**
+ * Translates the provided property value key into its corresponding domain query and returns the
+ * results.
+ *
+ * @param key indicates the data being retrieved from the database; should be one of the constants
+ * in {@link PropertyExpressionEvaluator}
+ * @return list of values matching the requested key; empty list if the key is not supported
+ */
+ List<String> lookupValues(String key);
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/PropertyExpressionEvaluator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/PropertyExpressionEvaluator.java
new file mode 100644
index 0000000..4a4993d
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/PropertyExpressionEvaluator.java
@@ -0,0 +1,75 @@
+/*
+* 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.configuration;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.content.PackageType;
+
+/**
+ * Translates the configuration property value lookup key into a named query in the system.
+ *
+ * @see DynamicConfigurationPropertyBean
+ *
+ * @author Jason Dobies
+ */
+public class PropertyExpressionEvaluator {
+
+ public static final String KEY_USERS = "users";
+ public static final String KEY_ROLES = "roles";
+ public static final String KEY_PACKAGE_TYPES = "package-types";
+
+ /**
+ * @see #getQueryNameForKey(String)
+ */
+ private static final Map<String, String> KEY_TO_QUERY_NAME;
+ static {
+ Map<String, String> temp = new HashMap<String, String>();
+
+ temp.put(KEY_USERS, Subject.QUERY_DYNAMIC_CONFIG_VALUES);
+ temp.put(KEY_ROLES, Role.QUERY_DYNAMIC_CONFIG_VALUES);
+ temp.put(KEY_PACKAGE_TYPES, PackageType.QUERY_DYNAMIC_CONFIG_VALUES);
+
+ KEY_TO_QUERY_NAME = Collections.unmodifiableMap(temp);
+ }
+
+ /**
+ * Returns the name of the query to use to retrieve the configuration values for properties
+ * defined with the given key. Each query referenced by the return result should only return
+ * a list of <code>String</code> objects, not any form of complex object (such as <code>Resource</code>
+ * or <code>Subject</code>).
+ *
+ * @param key plugin writer specified key to indicate what values to look up; this should be one
+ * of the KEY_* values defined in this class.
+ * @return name of a named query, where the query is defined elsewhere; <code>null</code> if the
+ * key is not supported by the system
+ */
+ public static String getQueryNameForKey(String key) {
+ return KEY_TO_QUERY_NAME.get(key);
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
index e46e8d9..fe9a2ef 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java
@@ -73,6 +73,8 @@ import org.rhq.enterprise.server.common.EntityManagerFacade;
import org.rhq.enterprise.server.common.EntityManagerFacadeLocal;
import org.rhq.enterprise.server.configuration.ConfigurationManagerBean;
import org.rhq.enterprise.server.configuration.ConfigurationManagerLocal;
+import org.rhq.enterprise.server.configuration.DynamicConfigurationPropertyBean;
+import org.rhq.enterprise.server.configuration.DynamicConfigurationPropertyLocal;
import org.rhq.enterprise.server.configuration.metadata.ConfigurationMetadataManagerBean;
import org.rhq.enterprise.server.configuration.metadata.ConfigurationMetadataManagerLocal;
import org.rhq.enterprise.server.content.AdvisoryManagerBean;
@@ -204,7 +206,7 @@ public final class LookupUtil {
/**
* Returns the main data source that can be used to directly access the database.
- *
+ *
* @return a transactional data source to connect to the database
*/
public static DataSource getDataSource() {
@@ -220,7 +222,7 @@ public final class LookupUtil {
/**
* Returns the transaction manager that you can use for your own managed transactions.
* Use this sparingly and only inside code that is outside of any CMT-scoped objects.
- *
+ *
* @return the transaction manager
*/
public static TransactionManager getTransactionManager() {
@@ -314,6 +316,10 @@ public final class LookupUtil {
return lookupLocal(ConfigurationManagerBean.class);
}
+ public static DynamicConfigurationPropertyLocal getDynamicConfigurationProperty() {
+ return lookupLocal(DynamicConfigurationPropertyBean.class);
+ }
+
public static ConfigurationSubsystemManagerLocal getConfigurationSubsystemManager() {
return lookupLocal(ConfigurationSubsystemManagerBean.class);
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java
new file mode 100644
index 0000000..6367f92
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/DynamicConfigurationPropertyBeanTest.java
@@ -0,0 +1,164 @@
+/*
+* 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.configuration;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import javax.transaction.NotSupportedException;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Role;
+import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.server.test.AbstractEJB3Test;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * @author Jason Dobies
+ */
+public class DynamicConfigurationPropertyBeanTest extends AbstractEJB3Test {
+
+ private static final boolean ENABLED = true;
+
+ private DynamicConfigurationPropertyLocal bean;
+
+ @BeforeMethod
+ public void setUp() {
+ bean = LookupUtil.getDynamicConfigurationProperty();
+ }
+
+ @Test(enabled = ENABLED)
+ public void invalidKey() throws Exception {
+ // Test
+ List<String> stringList = bean.lookupValues("foo");
+
+ // Verify
+ assert stringList != null;
+ assert stringList.size() == 0;
+ }
+
+ @Test(enabled = ENABLED)
+ public void user() throws Exception {
+ // Setup
+ int existingUserCount = countForQuery(Subject.QUERY_FIND_ALL);
+
+ // Test
+ List<String> users = bean.lookupValues(PropertyExpressionEvaluator.KEY_USERS);
+
+ // Verify
+ outputList(users);
+ assert users.size() == existingUserCount : "Expected: " + existingUserCount + ", Found: " + users.size();
+ }
+
+ @Test(enabled = ENABLED)
+ public void roles() throws Exception {
+ // Setup
+ int existingRoleCount = countForQuery(Role.QUERY_FIND_ALL);
+
+ // Test
+ List<String> roles = bean.lookupValues(PropertyExpressionEvaluator.KEY_ROLES);
+
+ // Verify
+ outputList(roles);
+ assert roles.size() == existingRoleCount : "Expected: " + existingRoleCount + ", Found: " + roles.size();
+ }
+
+ @Test(enabled = ENABLED)
+ public void packageType() throws Exception {
+ // Setup
+ ResourceType resourceType = null;
+ PackageType packageType = null;
+
+ TransactionManager tx = getTransactionManager();
+ try {
+ tx.begin();
+ EntityManager entityManager = getEntityManager();
+
+ resourceType = new ResourceType("dynamicConfigPropBeanTestType", "foo", ResourceCategory.PLATFORM, null);
+ entityManager.persist(resourceType);
+
+ packageType = new PackageType("dynamicConfigPropBeanTestType", resourceType);
+ entityManager.persist(packageType);
+ tx.commit();
+ }
+ catch (Exception e) {
+ tx.rollback();
+ }
+
+ int existingPackageTypes = countForQuery(PackageType.QUERY_FIND_ALL);
+ assert existingPackageTypes > 0 : "Package type created in setup was not written correctly";
+
+ // Test
+ List<String> types = bean.lookupValues(PropertyExpressionEvaluator.KEY_PACKAGE_TYPES);
+
+ // Verify
+ assert types.size() == existingPackageTypes : "Expected: " + existingPackageTypes + ", Found: " + types.size();
+
+ // Clean up
+ tx = getTransactionManager();
+ try {
+ tx.begin();
+ EntityManager entityManager = getEntityManager();
+
+ resourceType = entityManager.find(ResourceType.class, resourceType.getId());
+ entityManager.remove(resourceType);
+
+ packageType = entityManager.find(PackageType.class, packageType.getId());
+ entityManager.remove(packageType);
+
+ tx.commit();
+ }
+ catch (Exception e) {
+ tx.rollback();
+ }
+ }
+
+ private int countForQuery(String queryName) throws NotSupportedException, SystemException {
+ getTransactionManager().begin();
+ EntityManager entityManager = getEntityManager();
+
+ Query query = entityManager.createNamedQuery(queryName);
+ List existing = query.getResultList();
+
+ int count = existing.size();
+
+ getTransactionManager().rollback();
+
+ return count;
+ }
+
+ private void outputList(List<String> items) {
+ System.out.println("Items returned from lookupValues:");
+ for (String item : items) {
+ System.out.println(item);
+ }
+ }
+}
commit 299fb0615d893c0f061d45c65c1f7dcd2aa3d10b
Author: John Matthews <jmatthew(a)redhat.com>
Date: Fri Jan 8 16:25:00 2010 -0500
1357 - adding war to expose content through http
diff --git a/modules/enterprise/server/ear/pom.xml b/modules/enterprise/server/ear/pom.xml
index 0666bbe..4ab1ee1 100644
--- a/modules/enterprise/server/ear/pom.xml
+++ b/modules/enterprise/server/ear/pom.xml
@@ -66,6 +66,13 @@
<version>${project.version}</version>
<type>war</type>
</dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-content_http</artifactId>
+ <version>${project.version}</version>
+ <type>war</type>
+ </dependency>
<!-- ** SARs -->
<!--
@@ -168,6 +175,15 @@
<bundleFileName>rhq-webdav.war</bundleFileName>
<contextRoot>/webdav</contextRoot>
</webModule>
+
+ <!-- used to expose content through http -->
+ <webModule>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-content_http</artifactId>
+ <excluded>${exclude-content_http}</excluded>
+ <bundleFileName>rhq-content_http.war</bundleFileName>
+ <contextRoot>/content</contextRoot>
+ </webModule>
<!-- ** EJB-JARs -->
commit 6c15cabd5c29e3a5d4cf543a3d122c0747febd28
Author: John Matthews <jmatthew(a)redhat.com>
Date: Fri Jan 8 16:18:02 2010 -0500
1357 - first step at creating a placeholder for fetching content through http
Intent is to get the guts of http content working from this module
We can refactor this later so it's integrated into RHQ in a cleaner manner.
diff --git a/modules/enterprise/gui/content_http-war/pom.xml b/modules/enterprise/gui/content_http-war/pom.xml
new file mode 100644
index 0000000..50e0ad6
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/pom.xml
@@ -0,0 +1,280 @@
+<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-content_http</artifactId>
+ <packaging>war</packaging>
+
+ <name>RHQ Enterprise Content HTTP Support</name>
+ <description>Provides http export for content in RHQ.</description>
+
+ <scm>
+ <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/gui/con...</connection>
+ <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/gui/con...</developerConnection>
+ </scm>
+
+ <properties>
+ <scm.module.path>modules/enterprise/gui/content_http-war/</scm.module.path>
+ </properties>
+
+ <dependencies>
+
+ <!-- Internal Deps -->
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope> <!-- by rhq.ear (as ejb-jar) -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-gui</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-enterprise-server</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope> <!-- by rhq.ear (as ejb-jar) -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-util</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope> <!-- by rhq.ear -->
+ </dependency>
+
+ <!-- 3rd Party Deps -->
+
+ <dependency>
+ <groupId>hibernate</groupId>
+ <artifactId>hibernate3</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <!-- used by a test JSP -->
+ <dependency>
+ <groupId>hibernate-entitymanager</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <!-- needed for referenced domain entities that use Hibernate annotations (due to JDK5 bug) -->
+ <dependency>
+ <groupId>hibernate-annotations</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+
+ <!-- needed for referenced domain entities that use JPA annotations (due to JDK5 bug) -->
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <!--
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+ -->
+
+ <!-- adding to pick up javax.servlet.http.HttpServlet -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <!-- adding so we can extend DefaultServlet
+ Chose version 2.0.1 so it's compatible with info here for JBoss 4.2.3
+ http://community.jboss.org/wiki/VersionOfTomcatInJBossAS-->
+ <dependency>
+ <groupId>jboss.web</groupId>
+ <artifactId>jbossweb</artifactId>
+ <version>2.0.1.GA</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <!-- needed for EJB3 annotations (e.g. ApplicationException) -->
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-ejb3x</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.0.1</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.3.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <scope>provided</scope> <!-- by JBossAS -->
+ </dependency>
+
+ <dependency>
+ <groupId>commons-validator</groupId>
+ <artifactId>commons-validator</artifactId>
+ <version>1.1.4</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>rhq-content_http</finalName>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.1-alpha-1</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ </manifest>
+ <manifestEntries>
+ <Build-Number>${buildNumber}</Build-Number>
+ </manifestEntries>
+ </archive>
+ <webResources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>${basedir}/src/main/webapp</directory>
+ </resource>
+ </webResources>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+
+ <profiles>
+
+ <profile>
+ <id>dev</id>
+
+ <properties>
+ <rhq.rootDir>../../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentName>${project.build.finalName}.war</rhq.deploymentName>
+ <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/${rhq.deploymentName}</rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+
+ <execution>
+ <id>deploy-classes</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <property name="classes.dir" location="${rhq.deploymentDir}/WEB-INF/classes" />
+ <echo>*** Copying updated files from target/classes to ${classes.dir}...</echo>
+ <copy todir="${classes.dir}" verbose="${rhq.verbose}">
+ <fileset dir="target/classes" />
+ </copy>
+ <property name="deployment.dir" location="${rhq.deploymentDir}" />
+ <echo>*** Copying updated files from src${file.separator}main${file.separator}webapp${file.separator} to ${deployment.dir}${file.separator}...</echo>
+ <copy todir="${deployment.dir}" verbose="${rhq.verbose}">
+ <fileset dir="${basedir}/src/main/webapp" />
+ </copy>
+ <!-- TODO: Also copy the files from src/main/webapp-filtered/, and then filter them ourselves. -->
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>deploy</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.dir" location="${rhq.deploymentDir}" />
+ <echo>*** Copying updated files from target${file.separator}${project.build.finalName}${file.separator} to ${deployment.dir}${file.separator}...</echo>
+ <copy todir="${deployment.dir}" verbose="${rhq.verbose}">
+ <fileset dir="${basedir}/target/${project.build.finalName}" />
+ </copy>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.dir" location="${rhq.deploymentDir}" />
+ <echo>*** Deleting ${deployment.dir}${file.separator}...</echo>
+ <delete dir="${deployment.dir}" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
+</project>
diff --git a/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
new file mode 100644
index 0000000..2ac2061
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/java/org/rhq/gui/content/ContentHTTPServlet.java
@@ -0,0 +1,34 @@
+package org.rhq.gui.content;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.catalina.servlets.DefaultServlet;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+public class ContentHTTPServlet extends DefaultServlet {
+ private final Log log = LogFactory.getLog(ContentHTTPServlet.class);
+
+ public ContentHTTPServlet() {
+ super();
+ }
+
+ public void init() throws ServletException {
+ log.info("** *** ** ** ** *** Inside of ContentHTTPServlet::init()");
+ super.init();
+ }
+
+ protected void doGet(HttpServletRequest request,
+ HttpServletResponse response)
+ throws IOException, ServletException {
+ log.info("** ** ** Inside of ContentHTTPServlet::doGet()");
+ super.doGet(request, response);
+ }
+}
+
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/WEB-INF/jboss-web.xml b/modules/enterprise/gui/content_http-war/src/main/webapp/WEB-INF/jboss-web.xml
new file mode 100644
index 0000000..e1505f7
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/webapp/WEB-INF/jboss-web.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+
+<jboss-web>
+ <context-root>content</context-root>
+</jboss-web>
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/content_http-war/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..afa7bcd
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+
+ <display-name>RHQ Content HTTP Support</display-name>
+
+
+ <!-- Export content through http support -->
+ <servlet>
+ <servlet-name>ContentHTTP</servlet-name>
+ <servlet-class>org.rhq.gui.content.ContentHTTPServlet</servlet-class>
+ <!-- <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class> -->
+ <init-param>
+ <param-name>listings</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ <init-param>
+ <param-name>readonly</param-name>
+ <param-value>true</param-value>
+ </init-param>
+
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>ContentHTTP</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+
+</web-app>
+
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/testfile b/modules/enterprise/gui/content_http-war/src/main/webapp/testfile
new file mode 100644
index 0000000..9767b7a
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/webapp/testfile
@@ -0,0 +1,2 @@
+This is a test file
+
diff --git a/modules/enterprise/gui/content_http-war/src/main/webapp/testfile2 b/modules/enterprise/gui/content_http-war/src/main/webapp/testfile2
new file mode 100644
index 0000000..e5c132d
--- /dev/null
+++ b/modules/enterprise/gui/content_http-war/src/main/webapp/testfile2
@@ -0,0 +1,2 @@
+This is the second test file
+
commit 5bbf830ec4f443df72f0a5f273c0e7df14b480d8
Merge: 505bfa4... b9e3538...
Author: Mike McCune <mmccune(a)gibson.pdx.redhat.com>
Date: Wed Jan 6 13:16:49 2010 -0800
Merge branch 'master' into content
Conflicts:
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
commit 505bfa4fe0453bf3157e166f054aef287334d240
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Wed Jan 6 13:28:55 2010 -0500
fixing db error
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 161ebed..b7d3a0e 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2755,6 +2755,7 @@
ALTER TABLE RHQ_ADVISORY_PACKAGE ALTER COLUMN ID SET DEFAULT NEXTVAL('RHQ_ADVISORY_PKG_SEQ')
</statement>
</schema-directSQL>
+ </schemaSpec>
</dbupgrade>
</target>
</project>
14 years, 4 months
[rhq] Branch 'gwt' - 4 commits - modules/core modules/enterprise
by Greg Hinkle
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java | 11 -
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/InstalledPackageCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDefinitionCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementScheduleCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationDefinitionCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java | 6
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RoleCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java | 5
modules/enterprise/gui/portal-war/pom.xml | 44 +++++
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/RHQPortal.gwt.xml | 14 +
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/RHQPortal.java | 75 ++++++++++
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/inventory/group/ResourceGroupGWTService.java | 43 +++++
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/inventory/group/ResourceGroupGWTServiceAsync.java | 28 +++
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/inventory/resource/ResourceGWTService.java | 49 ++++++
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/inventory/resource/ResourceGWTServiceAsync.java | 37 ++++
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/server/inventory/group/ResourceGroupGWTServiceImpl.java | 31 ++++
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/server/inventory/resource/ResourceGWTServiceImpl.java | 45 ++++++
modules/enterprise/gui/portal-war/src/main/webapp/RHQPortal.css | 7
modules/enterprise/gui/portal-war/src/main/webapp/RHQPortal.html | 16 ++
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml | 22 ++
modules/enterprise/gui/portal-war/src/main/webapp/org.rhq.enterprise.gui.gwt.RHQPortal/RHQDomain.css | 7
modules/enterprise/gui/portal-war/src/main/webapp/org.rhq.enterprise.gui.gwt.RHQPortal/RHQDomain.html | 10 +
modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClientProxy.java | 2
31 files changed, 502 insertions(+), 15 deletions(-)
New commits:
commit 306621b484969e19a087d83f3aec25d08642eaa1
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Wed Jan 27 14:47:58 2010 -0500
First attempt at a GWT UI in the portal-war
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/org.rhq.enterprise.gui.gwt.RHQPortal/RHQDomain.css b/modules/enterprise/gui/portal-war/src/main/webapp/org.rhq.enterprise.gui.gwt.RHQPortal/RHQDomain.css
new file mode 100644
index 0000000..a111f82
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/org.rhq.enterprise.gui.gwt.RHQPortal/RHQDomain.css
@@ -0,0 +1,7 @@
+body {
+ background-color: white;
+ color: black;
+ font-family: Arial, sans-serif;
+ font-size: small;
+ margin: 8px;
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/org.rhq.enterprise.gui.gwt.RHQPortal/RHQDomain.html b/modules/enterprise/gui/portal-war/src/main/webapp/org.rhq.enterprise.gui.gwt.RHQPortal/RHQDomain.html
new file mode 100644
index 0000000..3878eb5
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/org.rhq.enterprise.gui.gwt.RHQPortal/RHQDomain.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+ <title>RHQDomain Application</title>
+ <link rel="stylesheet" href="RHQDomain.css">
+</head>
+<body>
+<script type="text/javascript" language="javascript" src="org.rhq.core.RHQDomain.nocache.js"></script>
+<h1>RHQDomain Application</h1>
+</body>
+</html>
commit 4cc815c691e42364959b5dec0afd41b847efdf95
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Wed Jan 27 14:45:32 2010 -0500
Fix compile error
diff --git a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClientProxy.java b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClientProxy.java
index 36dbf2b..f3c15a2 100644
--- a/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClientProxy.java
+++ b/modules/enterprise/remoting/client-api/src/main/java/org/rhq/enterprise/client/RemoteClientProxy.java
@@ -33,7 +33,7 @@ import javassist.bytecode.ParameterAnnotationsAttribute;
import org.jboss.remoting.invocation.NameBasedInvocation;
import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.util.serial.ExternalizableStrategy;
+import org.rhq.core.server.ExternalizableStrategy;
/**
* This class acts as a local SLSB proxy to make remote invocations
commit f48fa3c6c066dc360c0b08728f3d9bc36eec81e1
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Wed Jan 27 14:44:18 2010 -0500
First attempt at a GWT UI in the portal-war
diff --git a/modules/enterprise/gui/portal-war/pom.xml b/modules/enterprise/gui/portal-war/pom.xml
index 7de6682..95cbbb7 100644
--- a/modules/enterprise/gui/portal-war/pom.xml
+++ b/modules/enterprise/gui/portal-war/pom.xml
@@ -28,6 +28,8 @@
<seam.version>2.1.0.SP1</seam.version>
<jetty-jspc.version>7.0.0.RC6</jetty-jspc.version>
+ <gwt.version>2.0.0</gwt.version>
+
<product.shortName>RHQ</product.shortName>
<product.name>RHQ</product.name>
<product.fullName>RHQ</product.fullName>
@@ -40,7 +42,22 @@
<dependencies>
- <!-- Internal Deps -->
+
+ <dependency>
+ <groupId>com.google.gwt</groupId>
+ <artifactId>gwt-servlet</artifactId>
+ <version>${gwt.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.gwt</groupId>
+ <artifactId>gwt-user</artifactId>
+ <version>${gwt.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+
+ <!-- Internal Deps -->
<dependency>
<groupId>org.rhq</groupId>
@@ -360,12 +377,12 @@
</dependency>
<!-- new jetty based jsp compiler -->
- <dependency>
+ <!--<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-jspc-maven-plugin</artifactId>
<version>${jetty-jspc.version}</version>
<scope>provided</scope>
- </dependency>
+ </dependency>-->
<dependency>
<groupId>xalan</groupId>
@@ -381,12 +398,33 @@
<scope>provided</scope> <!-- by JBossAS -->
</dependency>
+
</dependencies>
<build>
<finalName>rhq-portal</finalName>
<plugins>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>gwt-maven-plugin</artifactId>
+ <version>1.2.0-11137</version>
+ <configuration>
+ <inplace>true</inplace>
+ <logLevel>INFO</logLevel>
+ <runTarget>RHQPortal.html</runTarget>
+ <extraJvmArgs>-Xmx512m</extraJvmArgs>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-alpha-1</version>
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/RHQPortal.gwt.xml b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/RHQPortal.gwt.xml
new file mode 100644
index 0000000..1490ef6
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/RHQPortal.gwt.xml
@@ -0,0 +1,14 @@
+<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.6//EN"
+ "http://google-web-toolkit.googlecode.com/svn/releases/1.6/distro-source/c...">
+<module>
+
+ <inherits name='com.google.gwt.user.User'/>
+ <inherits name='org.rhq.core.RHQDomain'/>
+
+
+ <entry-point class='org.rhq.enterprise.gui.gwt.client.RHQPortal'/>
+ <servlet path="/ResourceGroupGWTService" class="org.rhq.enterprise.gui.gwt.server.inventory.group.ResourceGroupGWTServiceImpl"/>
+ <servlet path="/ResourceGWTService"
+ class="org.rhq.enterprise.gui.gwt.server.inventory.resource.ResourceGWTServiceImpl"/>
+
+</module>
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/RHQPortal.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/RHQPortal.java
new file mode 100644
index 0000000..2e53e67
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/RHQPortal.java
@@ -0,0 +1,75 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.gui.gwt.client;
+
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.gwt.client.inventory.resource.ResourceGWTService;
+import org.rhq.enterprise.gui.gwt.client.inventory.resource.ResourceGWTServiceAsync;
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.*;
+
+import java.util.ArrayList;
+
+
+
+/**
+ * @author Greg Hinkle
+ */
+public class RHQPortal implements EntryPoint {
+ ResourceGWTServiceAsync resourceService;
+
+ private VerticalPanel mainPanel;
+
+
+ public void onModuleLoad() {
+ resourceService = ResourceGWTService.App.getInstance();
+
+ mainPanel = new VerticalPanel();
+
+
+ DOM.setInnerHTML(RootPanel.get("Loading-Panel").getElement(), "");
+
+
+ RootPanel.get().add(mainPanel);
+
+
+ final HTML loading = new HTML(" <img src=\"/images/ajax-loader.gif\" alt=\"loading\"> Loading Resources, please wait...");
+ mainPanel.add(loading);
+
+
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.addFilterName("ghinkle");
+
+ resourceService.findResourcesByCriteria(criteria, new AsyncCallback<PageList<Resource>>() {
+ public void onFailure(Throwable caught) {
+ Window.alert("Failed to load" + caught.getMessage());
+ }
+
+ public void onSuccess(PageList<Resource> result) {
+ Window.alert("Loaded resources " + result.size());
+ }
+ });
+ }
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/inventory/group/ResourceGroupGWTService.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/inventory/group/ResourceGroupGWTService.java
new file mode 100644
index 0000000..d43d916
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/inventory/group/ResourceGroupGWTService.java
@@ -0,0 +1,43 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.gui.gwt.client.inventory.group;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
+import com.google.gwt.core.client.GWT;
+
+
+
+/**
+ * @author Greg Hinkle
+ */
+@RemoteServiceRelativePath("ResourceGroupGWTService")
+public interface ResourceGroupGWTService extends RemoteService {
+ /**
+ * Utility/Convenience class.
+ * Use ResourceGroupGWTService.App.getInstance() to access static instance of ResourceGroupGWTServiceAsync
+ */
+ public static class App {
+ private static final ResourceGroupGWTServiceAsync ourInstance = (ResourceGroupGWTServiceAsync) GWT.create(ResourceGroupGWTService.class);
+
+ public static ResourceGroupGWTServiceAsync getInstance() {
+ return ourInstance;
+ }
+ }
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/inventory/group/ResourceGroupGWTServiceAsync.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/inventory/group/ResourceGroupGWTServiceAsync.java
new file mode 100644
index 0000000..526a5e7
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/inventory/group/ResourceGroupGWTServiceAsync.java
@@ -0,0 +1,28 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.gui.gwt.client.inventory.group;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+
+/**
+ * @author Greg Hinkle
+ */
+public interface ResourceGroupGWTServiceAsync {
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/inventory/resource/ResourceGWTService.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/inventory/resource/ResourceGWTService.java
new file mode 100644
index 0000000..3e8ebf5
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/inventory/resource/ResourceGWTService.java
@@ -0,0 +1,49 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.gui.gwt.client.inventory.resource;
+
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.util.PageList;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
+import com.google.gwt.core.client.GWT;
+
+
+/**
+ * @author Greg Hinkle
+ */
+@RemoteServiceRelativePath("ResourceGWTService")
+public interface ResourceGWTService extends RemoteService {
+
+ PageList<Resource> findResourcesByCriteria(ResourceCriteria criteria);
+
+ /**
+ * Utility/Convenience class.
+ * Use ResourceGWTService.App.getInstance() to access static instance of ResourceGWTServiceAsync
+ */
+ public static class App {
+ private static final ResourceGWTServiceAsync ourInstance = (ResourceGWTServiceAsync) GWT.create(ResourceGWTService.class);
+
+ public static ResourceGWTServiceAsync getInstance() {
+ return ourInstance;
+ }
+ }
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/inventory/resource/ResourceGWTServiceAsync.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/inventory/resource/ResourceGWTServiceAsync.java
new file mode 100644
index 0000000..f46eb95
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/client/inventory/resource/ResourceGWTServiceAsync.java
@@ -0,0 +1,37 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.gui.gwt.client.inventory.resource;
+
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.util.PageList;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+
+
+/**
+ * @author Greg Hinkle
+ */
+public interface ResourceGWTServiceAsync {
+
+
+ void findResourcesByCriteria(ResourceCriteria criteria, AsyncCallback<PageList<Resource>> callback);
+
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/server/inventory/group/ResourceGroupGWTServiceImpl.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/server/inventory/group/ResourceGroupGWTServiceImpl.java
new file mode 100644
index 0000000..08be2e4
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/server/inventory/group/ResourceGroupGWTServiceImpl.java
@@ -0,0 +1,31 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.gui.gwt.server.inventory.group;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+import org.rhq.enterprise.gui.gwt.client.inventory.group.ResourceGroupGWTService;
+
+
+
+/**
+ * @author Greg Hinkle
+ */
+public class ResourceGroupGWTServiceImpl extends RemoteServiceServlet implements ResourceGroupGWTService {
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/server/inventory/resource/ResourceGWTServiceImpl.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/server/inventory/resource/ResourceGWTServiceImpl.java
new file mode 100644
index 0000000..02d2fe7
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/gwt/server/inventory/resource/ResourceGWTServiceImpl.java
@@ -0,0 +1,45 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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.gui.gwt.server.inventory.resource;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.gwt.client.inventory.resource.ResourceGWTService;
+import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
+import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * @author Greg Hinkle
+ */
+public class ResourceGWTServiceImpl extends RemoteServiceServlet implements ResourceGWTService {
+
+
+ public PageList<Resource> findResourcesByCriteria(ResourceCriteria criteria) {
+ ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
+ SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
+ return resourceManager.findResourcesByCriteria(subjectManager.getOverlord(), criteria);
+ }
+
+
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/RHQPortal.css b/modules/enterprise/gui/portal-war/src/main/webapp/RHQPortal.css
new file mode 100644
index 0000000..a111f82
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/RHQPortal.css
@@ -0,0 +1,7 @@
+body {
+ background-color: white;
+ color: black;
+ font-family: Arial, sans-serif;
+ font-size: small;
+ margin: 8px;
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/RHQPortal.html b/modules/enterprise/gui/portal-war/src/main/webapp/RHQPortal.html
new file mode 100644
index 0000000..4ee0eef
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/RHQPortal.html
@@ -0,0 +1,16 @@
+<html>
+<head>
+ <title>RHQPortal Application</title>
+ <link rel="stylesheet" href="RHQPortal.css">
+</head>
+<body>
+<script type="text/javascript" language="javascript"
+ src="org.rhq.enterprise.gui.gwt.RHQPortal/org.rhq.enterprise.gui.gwt.RHQPortal.nocache.js"></script>
+<h1>RHQPortal Application</h1>
+
+<div id="Loading-Panel">
+ <img src="/images/ajax-loader.gif" alt="loading"> Loading RHQ, please wait...
+</div>
+
+</body>
+</html>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
index 0038c7d..5658dc5 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/web.xml
@@ -398,8 +398,16 @@
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
-
- <!-- The endpoints to the agent update servlet -->
+ <servlet>
+ <servlet-name>org.rhq.enterprise.gui.gwt.RHQPortal ResourceGroupGWTService</servlet-name>
+ <servlet-class>org.rhq.enterprise.gui.gwt.server.inventory.group.ResourceGroupGWTServiceImpl</servlet-class>
+ </servlet>
+ <servlet>
+ <servlet-name>org.rhq.enterprise.gui.gwt.RHQPortal ResourceGWTService</servlet-name>
+ <servlet-class>org.rhq.enterprise.gui.gwt.server.inventory.resource.ResourceGWTServiceImpl</servlet-class>
+ </servlet>
+
+ <!-- The endpoints to the agent update servlet -->
<servlet-mapping>
<servlet-name>AgentUpdateServlet</servlet-name>
<url-pattern>/agentupdate/version</url-pattern>
@@ -468,7 +476,15 @@
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
- <session-config>
+ <servlet-mapping>
+ <servlet-name>org.rhq.enterprise.gui.gwt.RHQPortal ResourceGroupGWTService</servlet-name>
+ <url-pattern>/org.rhq.enterprise.gui.gwt.RHQPortal/ResourceGroupGWTService</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>org.rhq.enterprise.gui.gwt.RHQPortal ResourceGWTService</servlet-name>
+ <url-pattern>/org.rhq.enterprise.gui.gwt.RHQPortal/ResourceGWTService</url-pattern>
+ </servlet-mapping>
+ <session-config>
<session-timeout>30</session-timeout>
</session-config>
commit 5e96417e3ab8648844421d94ad39beefbf167a29
Author: Greg Hinkle <ghinkle(a)redhat.com>
Date: Wed Jan 27 14:40:42 2010 -0500
Get rid of unsupported field type of Class<?> by implementing an abstract persistence class lookup
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertCriteria.java
index 119924b..b1965e4 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertCriteria.java
@@ -88,6 +88,11 @@ public class AlertCriteria extends Criteria {
sortOverrides.put("priority", "alertDefinition.priority");
}
+ @Override
+ public Class getPersistentClass() {
+ return Alert.class;
+ }
+
public void addFilterId(Integer filterId) {
this.filterId = filterId;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
index 7f16a8e..756dc5a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
@@ -71,6 +71,11 @@ public class AlertDefinitionCriteria extends Criteria {
filterOverrides.put("operationName", "operationDefinition.name like ?");
}
+ @Override
+ public Class getPersistentClass() {
+ return AlertDefinition.class;
+ }
+
public void addFilterId(Integer filterId) {
this.filterId = filterId;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java
index 821e9a0..7d288ea 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java
@@ -64,16 +64,12 @@ public abstract class Criteria implements Serializable {
private List<String> orderingFieldNames;
- private Class<?> persistentClass;
-
//added no args constructor for bean and JAXB requirement
@SuppressWarnings("unused")
- private Criteria() {
+ public Criteria() {
}
public Criteria(Class<?> persistentClass) {
- this.persistentClass = persistentClass;
-
filterOverrides = new HashMap<String, String>();
sortOverrides = new HashMap<String, String>();
@@ -86,9 +82,8 @@ public abstract class Criteria implements Serializable {
setPaging(0, 200);
}
- public Class<?> getPersistentClass() {
- return persistentClass;
- }
+ public abstract Class getPersistentClass();
+
public String getJPQLFilterOverride(String fieldName) {
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java
index 1a39995..1192dd5 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/EventCriteria.java
@@ -77,6 +77,11 @@ public class EventCriteria extends Criteria {
+ " WHERE parent.id = ? )");
}
+ @Override
+ public Class getPersistentClass() {
+ return Event.class;
+ }
+
public void addFilterId(Integer filterId) {
this.filterId = filterId;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/InstalledPackageCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/InstalledPackageCriteria.java
index 0713324..c2ab51b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/InstalledPackageCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/InstalledPackageCriteria.java
@@ -34,6 +34,11 @@ public class InstalledPackageCriteria extends Criteria {
filterOverrides.put("userId", "user.id = ? ");
}
+ @Override
+ public Class getPersistentClass() {
+ return InstalledPackage.class;
+ }
+
public void addFilterId(Integer filterId) {
this.filterId = filterId;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDefinitionCriteria.java
index 4c45ef6..de78ff3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDefinitionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementDefinitionCriteria.java
@@ -75,6 +75,11 @@ public class MeasurementDefinitionCriteria extends Criteria {
sortOverrides.put("resourceTypeName", "resourceType.name");
}
+ @Override
+ public Class getPersistentClass() {
+ return MeasurementDefinition.class;
+ }
+
public void addFilterId(Integer filterId) {
this.filterId = filterId;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementScheduleCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementScheduleCriteria.java
index 268e57a..f56098c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementScheduleCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/MeasurementScheduleCriteria.java
@@ -76,6 +76,11 @@ public class MeasurementScheduleCriteria extends Criteria {
sortOverrides.put("name", "definition.name");
}
+ @Override
+ public Class getPersistentClass() {
+ return MeasurementSchedule.class;
+ }
+
public void addFilterId(Integer filterId) {
this.filterId = filterId;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationDefinitionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationDefinitionCriteria.java
index c6aa98e..c36681a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationDefinitionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationDefinitionCriteria.java
@@ -73,6 +73,11 @@ public class OperationDefinitionCriteria extends Criteria {
+ " WHERE group.id = ? ) ");
}
+ @Override
+ public Class getPersistentClass() {
+ return OperationDefinition.class;
+ }
+
public void addFilterId(Integer filterId) {
this.filterId = filterId;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java
index 79dfec2..c770f3c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/OperationHistoryCriteria.java
@@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
import org.rhq.core.domain.operation.JobId;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.operation.OperationHistory;
+import org.rhq.core.domain.operation.ResourceOperationHistory;
import org.rhq.core.domain.util.PageOrdering;
/**
@@ -66,6 +67,11 @@ public abstract class OperationHistoryCriteria extends Criteria {
init();
}
+ @Override
+ public Class getPersistentClass() {
+ return ResourceOperationHistory.class;
+ }
+
private void init() {
filterOverrides.put("operationDefinitionId", "operationDefinition.id = ?");
filterOverrides.put("operationName", "operationDefinition.name like ?");
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java
index 4a0d4bb..d6c128d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/PackageVersionCriteria.java
@@ -51,6 +51,11 @@ public class PackageVersionCriteria extends Criteria {
+ " WHERE ip.resource.id = ? )");
}
+ @Override
+ public Class getPersistentClass() {
+ return PackageVersion.class;
+ }
+
public void addFilterId(Integer filterId) {
this.filterId = filterId;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java
index 188c955..2084cf2 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RepoCriteria.java
@@ -64,6 +64,11 @@ public class RepoCriteria extends Criteria {
"WHERE rcs.contentSource.id IN ( ? ))");
}
+ @Override
+ public Class getPersistentClass() {
+ return Repo.class;
+ }
+
public void addFilterId(Integer filterId) {
this.filterId = filterId;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
index a695476..0e84b1e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
@@ -110,6 +110,11 @@ public class ResourceCriteria extends Criteria {
sortOverrides.put("currentAvailability", "currentAvailability.availabilityType");
}
+ @Override
+ public Class getPersistentClass() {
+ return Resource.class;
+ }
+
public void addFilterId(Integer filterId) {
this.filterId = filterId;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
index dab95e8..7f594c0 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceGroupCriteria.java
@@ -81,6 +81,11 @@ public class ResourceGroupCriteria extends Criteria {
sortOverrides.put("resourceTypeName", "resourceType.name");
}
+ @Override
+ public Class getPersistentClass() {
+ return ResourceGroup.class;
+ }
+
public void addFilterId(Integer filterId) {
this.filterId = filterId;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java
index 184c3bd..dc92a71 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java
@@ -75,6 +75,11 @@ public class ResourceTypeCriteria extends Criteria {
sortOverrides.put("pluginName", "plugin");
}
+ @Override
+ public Class getPersistentClass() {
+ return ResourceType.class;
+ }
+
public void addFilterId(Integer filterId) {
this.filterId = filterId;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RoleCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RoleCriteria.java
index 9b63c01..7009737 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RoleCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/RoleCriteria.java
@@ -51,6 +51,11 @@ public class RoleCriteria extends Criteria {
super(Role.class);
}
+ @Override
+ public Class getPersistentClass() {
+ return Role.class;
+ }
+
public Integer getFilterId() {
return this.filterId;
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java
index 43e156e..9557539 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/SubjectCriteria.java
@@ -62,6 +62,11 @@ public class SubjectCriteria extends Criteria {
super(Subject.class);
}
+ @Override
+ public Class getPersistentClass() {
+ return Subject.class;
+ }
+
public void addFilterId(Integer filterId) {
this.filterId = filterId;
}
14 years, 4 months
[rhq] 5 commits - modules/core modules/enterprise
by jharris
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java | 3
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java | 1
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java | 81 ++---
modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml | 26 +
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml | 160 +++++-----
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/notificationTemplates.xhtml | 2
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml | 18 -
modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java | 4
modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml | 6
10 files changed, 181 insertions(+), 122 deletions(-)
New commits:
commit d2913885ba5aeee5d6efcdca1350b0a70bbcff61
Merge: 2dde4f5... c5470ae...
Author: Justin Harris <jharris(a)redhat.com>
Date: Wed Jan 27 13:58:28 2010 -0500
Merge remote branch 'origin/master' into alertPlugin
commit 2dde4f55abe2517db8330f7a700816a6e68b8e57
Merge: 82d2bf3... 52e5199...
Author: Heiko W. Rupp <pilhuhn(a)fedorapeople.org>
Date: Wed Jan 27 12:31:09 2010 +0100
Merge branch 'alertPlugin' of ssh://git.fedorahosted.org/git/rhq/rhq into alertPlugin
commit 82d2bf38963877ec23fabe8452fa32ab53a34f4b
Author: Heiko W. Rupp <pilhuhn(a)fedorapeople.org>
Date: Wed Jan 27 12:19:23 2010 +0100
Add alert id BZ 555091, comment 10
diff --git a/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java b/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
index 341b1bf..a2795c8 100644
--- a/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
+++ b/modules/enterprise/server/plugins/alert-microblog/src/main/java/org/rhq/enterprise/server/plugins/alertMicroblog/MicroblogSender.java
@@ -51,7 +51,8 @@ public class MicroblogSender extends AlertSender {
Twitter twitter = new Twitter(user,password,baseUrl);
AlertManagerLocal alertManager = LookupUtil.getAlertManager();
twitter.setSource("Jopr");
- StringBuilder b = new StringBuilder("Alert: '");
+ StringBuilder b = new StringBuilder("Alert ");
+ b.append(alert.getId()).append(":'"); // Alert id
b.append(alert.getAlertDefinition().getResource().getName());
b.append("' (");
b.append(alert.getAlertDefinition().getResource().getId());
@@ -69,6 +70,7 @@ public class MicroblogSender extends AlertSender {
log.warn("Notification via Microblog failed for " + txt + " ", e);
result = new SenderResult(ResultState.FAILURE,"Sending failed :" + e.getMessage());
+
}
return result;
}
commit 52e5199beafae566462444a61033503a5a9a839a
Author: Justin Harris <jharris(a)redhat.com>
Date: Tue Jan 26 16:05:41 2010 -0500
Making lots of small cosmetic changes to the alert definition page.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml
index 2c9edb9..cd9e56c 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/listAlertSender.xhtml
@@ -42,12 +42,14 @@
ignoreDupResponses="true"
requestDelay="25"
reRender="alertConfig,senderName"
- oncomplete="updateCustomContent();" />
+ oncomplete="updateCustomContent();"
+ onsubmit="showLoadConfig();" />
<a4j:support event="onkeyup"
ignoreDupResponses="true"
requestDelay="150"
reRender="alertConfig,senderName"
- oncomplete="updateCustomContent();" />
+ oncomplete="updateCustomContent();"
+ onsubmit="showLoadConfig();" />
<a4j:support event="onorderchanged"
ignoreDupResponses="true"
requestDelay="250"
@@ -78,6 +80,12 @@
</h:panelGroup>
<h:panelGroup>
+ <div id="configLoader" style="display: none; margin: auto;">
+ <strong><h:outputText value="Loading Configuration..." /></strong>
+ <br /><br />
+ <img src="/images/ajax-loader.gif" alt="Loading Configuration..." />
+ </div>
+
<h:form id="alertConfig">
<input type="hidden" name="id" value="${param.id}"/>
<input type="hidden" name="ad" value="${param.ad}"/>
@@ -108,77 +116,81 @@
</rich:panel>
<rich:modalPanel id="addAlertPanel" moveable="false" autosized="true">
- <f:facet name="header">
- <h:outputText value="Add Alert Notification" />
- </f:facet>
- <h:form id="newNotificationForm">
- <input type="hidden" name="id" value="${param.id}"/>
- <input type="hidden" name="ad" value="${param.ad}"/>
-
- <h:outputLabel for="alertNameInput" value="Alert Notification Name:" />
- <br />
- <h:inputText id="alertNameInput"
- value="#{alertNotificationsUIBean.newAlertName}"
- maxlength="100"
- required="true" />
-
- <h:message for="alertNameInput"
- infoClass="InfoBlock"
- warnClass="WarnBlock"
- errorClass="ErrorBlock"
- fatalClass="FatalBlock" />
- <br /><br />
-
- <h:outputLabel for="senderList" value="Alert Sender Type:" />
- <br />
- <h:selectOneMenu id="senderList" value="#{alertNotificationsUIBean.selectedNewSender}">
- <f:selectItems value="#{alertNotificationsUIBean.allAlertSenders}" />
- </h:selectOneMenu>
- <br /><br />
-
- <h:commandButton id="addAlertButton"
- value="Add Alert Notification"
- action="#{alertNotificationsUIBean.addAlertSender}"
- styleClass="buttonmed">
- </h:commandButton>
-
- <br /><br />
- <h:outputLink id="notificationCancelLink" styleClass="buttonmed" value="#">
- <h:outputText value="Cancel" />
- <rich:componentControl for="addAlertPanel" attachTo="notificationCancelLink" operation="hide" event="onclick" />
- </h:outputLink>
- </h:form>
- </rich:modalPanel>
+ <h:panelGrid columns="2" width="100%" columnClasses="col1,col2">
+ <rich:panel id="addNewAlertPanel">
+ <f:facet name="header">
+ <h:outputText value="Add New Alert Notifications"/>
+ </f:facet>
- <rich:panel id="addAlertFromTemplatePanel">
- <f:facet name="header">
- <h:outputText value="Add Alert Notifications from template"/>
- </f:facet>
+ <h:form id="newNotificationForm">
+ <input type="hidden" name="id" value="${param.id}"/>
+ <input type="hidden" name="ad" value="${param.ad}"/>
- <h:form id="newNotificationsFromTemplateForm">
- <input type="hidden" name="id" value="${param.id}"/>
- <input type="hidden" name="ad" value="${param.ad}"/>
+ <div style="height: 100px;">
+ <h:outputLabel for="alertNameInput" value="Alert Notification Name:" />
+ <br />
+ <h:inputText id="alertNameInput"
+ value="#{alertNotificationsUIBean.newAlertName}"
+ maxlength="100"
+ required="true" />
+
+ <h:message for="alertNameInput"
+ infoClass="InfoBlock"
+ warnClass="WarnBlock"
+ errorClass="ErrorBlock"
+ fatalClass="FatalBlock" />
+ <br /><br />
+
+ <h:outputLabel for="senderList" value="Alert Sender Type:" />
+ <br />
+ <h:selectOneMenu id="senderList" value="#{alertNotificationsUIBean.selectedNewSender}">
+ <f:selectItems value="#{alertNotificationsUIBean.allAlertSenders}" />
+ </h:selectOneMenu>
+ </div>
+
+ <h:commandButton id="addAlertButton"
+ value="Add Alert Notification"
+ action="#{alertNotificationsUIBean.addAlertSender}"
+ styleClass="buttonmed">
+ </h:commandButton>
+ </h:form>
+ </rich:panel>
- <h:selectOneMenu id="templateList" value="#{alertNotificationsUIBean.selectedTemplate}">
- <f:selectItems value="#{alertNotificationsUIBean.allNotificationTemplates}"/>
- </h:selectOneMenu>
+ <rich:panel id="addAlertFromTemplatePanel">
+ <f:facet name="header">
+ <h:outputText value="Add Alert Notifications from template"/>
+ </f:facet>
+ <h:form id="newNotificationsFromTemplateForm">
+ <input type="hidden" name="id" value="${param.id}"/>
+ <input type="hidden" name="ad" value="${param.ad}"/>
- <br/>
+ <div style="height: 100px;">
+ <h:selectOneMenu id="templateList" value="#{alertNotificationsUIBean.selectedTemplate}">
+ <f:selectItems value="#{alertNotificationsUIBean.allNotificationTemplates}"/>
+ </h:selectOneMenu>
- <h:selectBooleanCheckbox title="clearExisting" value="#{alertNotificationsUIBean.clearExistingNotifications}"/>
- <h:outputText value="Clear existing notifications"/>
+ <br/>
- <br /><br />
+ <h:selectBooleanCheckbox title="clearExisting" value="#{alertNotificationsUIBean.clearExistingNotifications}"/>
+ <h:outputText value="Clear existing notifications"/>
+ </div>
- <h:commandButton id="addTemplateButton"
- value="Add Alert Notification from Template"
- action="#{alertNotificationsUIBean.addAlertSenderFromTemplate}"
- styleClass="buttonmed">
- </h:commandButton>
- </h:form>
+ <h:commandButton id="addTemplateButton"
+ value="Add Alert Notification from Template"
+ action="#{alertNotificationsUIBean.addAlertSenderFromTemplate}"
+ styleClass="buttonmed"
+ style="margin-top: auto;">
+ </h:commandButton>
+ </h:form>
+ </rich:panel>
+ </h:panelGrid>
- </rich:panel>
+ <h:outputLink id="notificationCancelLink" styleClass="buttonmed" value="#" style="float: right;">
+ <h:outputText value="Cancel" />
+ <rich:componentControl for="addAlertPanel" attachTo="notificationCancelLink" operation="hide" event="onclick" />
+ </h:outputLink>
+ </rich:modalPanel>
<br />
<br />
@@ -189,16 +201,28 @@
- <script>
+ <script type="text/javascript">
function updateCustomContent() {
var sender = $('senderName').innerHTML;
new Ajax.Updater('customContentArea',
'notif/customContent.xhtml',
{ method: 'get',
- parameters: {'senderName': sender,
- 'ad': #{param.ad},
- 'id': #{param.id}}
+ parameters: {'senderName': sender, 'ad': #{param.ad}, 'id': #{param.id}}
});
+
+ hideLoadConfig();
+ }
+
+ function showLoadConfig() {
+ $('alertConfig').hide();
+ $('customContentArea').hide();
+ $('configLoader').show();
+ }
+
+ function hideLoadConfig() {
+ $('configLoader').hide();
+ $('alertConfig').show();
+ $('customContentArea').show();
}
Event.observe(window, 'load', function() {
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml
index 5b3e6d4..8716d01 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml
@@ -164,12 +164,12 @@
<input type="hidden" name="ad" value="#{param.ad}" />
<input type="hidden" name="id" value="#{param.id}" />
- <h:panelGrid columns="2" border="1" cellpadding="5">
+ <h:panelGrid columns="2" border="1" cellpadding="5" style="margin: 15px;">
<h:outputLabel for="alertNameInput" value="Name: " />
- <h:inputText id="alertNameInput" value="#{alertUIBean.alertDefinition.name}" />
+ <h:inputText id="alertNameInput" value="#{alertUIBean.alertDefinition.name}" style="width: 300px;" />
<h:outputLabel for="alertDescriptionInput" value="Description: " />
- <h:inputTextarea id="alertDescriptionInput" value="#{alertUIBean.alertDefinition.description}" />
+ <h:inputTextarea id="alertDescriptionInput" value="#{alertUIBean.alertDefinition.description}" style="width: 300px;" />
<h:outputLabel for="alertPriorityInput" value="Priority: " />
<h:selectOneMenu id="alertPriorityInput" value="#{alertUIBean.alertDefinition.priority}">
@@ -180,14 +180,14 @@
<h:selectBooleanCheckbox id="alertEnabledInput" value="#{alertUIBean.alertDefinition.enabled}" />
</h:panelGrid>
+ <h:outputLink id="cancelLink" styleClass="buttonmed" value="#" style="float: right;">
+ <h:outputText value="Cancel" />
+ <rich:componentControl for="editAlertDefinitionPanel" attachTo="cancelLink" operation="hide" event="onclick" />
+ </h:outputLink>
+
<h:commandButton id="saveButton" value="Save Changes" styleClass="buttonmed" action="#{alertUIBean.saveAlertDefinition}" />
</h:form>
-
- <br />
- <h:outputLink id="cancelLink" styleClass="buttonmed" value="#">
- <h:outputText value="Cancel" />
- <rich:componentControl for="editAlertDefinitionPanel" attachTo="cancelLink" operation="hide" event="onclick" />
- </h:outputLink>
+
</rich:modalPanel>
</ui:define>
commit a40c6a2f7f6f98c47891563b7f42f4a0808b3615
Author: Justin Harris <jharris(a)redhat.com>
Date: Tue Jan 26 13:55:56 2010 -0500
Altering navigation rules for notification templates.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java
index 53d5c19..208f15d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/NotificationTemplate.java
@@ -43,7 +43,7 @@ import javax.persistence.Table;
@NamedQueries({
@NamedQuery(name = NotificationTemplate.FIND_BY_NAME, query = "SELECT t FROM NotificationTemplate t WHERE t.name = :name"),
- @NamedQuery(name = NotificationTemplate.FIND_ALL, query = "SELECT t FROM NotificationTemplate t LEFT JOIN FETCH t.notifications")
+ @NamedQuery(name = NotificationTemplate.FIND_ALL, query = "SELECT t FROM NotificationTemplate AS t")
})
@Entity
@Table(name="RHQ_ALERT_NOTIF_TEMPL")
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java
index 2b6b2dd..b2b1df3 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertNotificationsUIBean.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.alert;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -49,7 +50,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
@Scope(ScopeType.PAGE)
@Name("alertNotificationsUIBean")
-public class AlertNotificationsUIBean {
+public class AlertNotificationsUIBean implements Serializable {
private final static String SUCCESS_OUTCOME = "success";
@RequestParameter("ad")
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java
index b11f958..4b01d25 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/AlertUIBean.java
@@ -29,7 +29,6 @@ import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.datamodel.DataModel;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.log.Log;
import org.rhq.core.domain.alert.AlertCondition;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java
index b82c2d4..e9afb57 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java
@@ -38,7 +38,6 @@ import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.web.RequestParameter;
-import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
import org.rhq.core.domain.alert.notification.NotificationTemplate;
import org.rhq.core.domain.auth.Subject;
@@ -46,7 +45,6 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
-import org.rhq.enterprise.server.alert.AlertDefinitionManagerLocal;
import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -61,11 +59,12 @@ import org.rhq.enterprise.server.util.LookupUtil;
@SuppressWarnings("unused")
public class NotificationTemplatesUIBean implements Serializable {
- private final static String SUCCESS_OUTCOME = "success";
- @RequestParameter("ad")
- private Integer alertDefinitionId;
+ private final static String CONTINUE_OUTCOME = "continue";
+ private final static String NEW_OUTCOME = "new";
@RequestParameter("nid")
private Integer notificationId;
+ @RequestParameter("tid")
+ private Integer templateId;
private String opMode;
private List<AlertNotification> alertNotifications;
private Set<AlertNotification> selectedNotifications;
@@ -81,7 +80,7 @@ public class NotificationTemplatesUIBean implements Serializable {
private AlertNotificationConverter notificationConverter;
private AlertNotificationManagerLocal alertNotificationManager;
private static final String EDIT = "EDIT";
- private List<NotificationTemplate> listOfTemplates;
+ private List<NotificationTemplate> notificationTemplates;
NotificationTemplate selectedTemplate;
public List<AlertNotification> getAlertNotifications() {
@@ -192,6 +191,10 @@ public class NotificationTemplatesUIBean implements Serializable {
this.selectedTemplate = selectedTemplate;
}
+ public List<NotificationTemplate> getNotificationTemplates() {
+ return this.notificationTemplates;
+ }
+
private void lookupActiveConfigDefinition() {
System.out.println("lookupActiveConfigDef: activeNotification is " + activeNotification);
@@ -201,13 +204,6 @@ public class NotificationTemplatesUIBean implements Serializable {
}
}
- public AlertDefinition getAlertDefinition() {
- AlertDefinitionManagerLocal definitionManager = LookupUtil.getAlertDefinitionManager();
- Subject subject = EnterpriseFacesContextUtility.getSubject();
-
- return definitionManager.getAlertDefinitionById(subject, alertDefinitionId);
- }
-
@Create
public void initNotifications() {
this.alertNotificationManager = LookupUtil.getAlertNotificationManager();
@@ -218,10 +214,26 @@ public class NotificationTemplatesUIBean implements Serializable {
this.selectedNotifications = new HashSet<AlertNotification>();
this.notificationConverter = new AlertNotificationConverter();
this.notificationConverter.setAlertNotifications(alertNotifications);
+ this.notificationTemplates = alertNotificationManager.listNotificationTemplates(EnterpriseFacesContextUtility.getSubject());
+ selectActiveTemplate();
selectActiveNotification();
}
+ private void selectActiveTemplate() {
+ if (this.templateId != null) {
+ for (NotificationTemplate template : this.notificationTemplates) {
+ if (template.getId() == this.templateId) {
+ selectTemplate(template);
+
+ return;
+ }
+ }
+ }
+
+ opMode = "";
+ }
+
// Sets the initial state of the bean given the requrest parameters, this allows
// us to maintain the selected item across requests.
private void selectActiveNotification() {
@@ -271,7 +283,7 @@ public class NotificationTemplatesUIBean implements Serializable {
FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR,"Adding the sender failed: " + iae.getMessage() );
}
- return SUCCESS_OUTCOME;
+ return CONTINUE_OUTCOME;
}
public String saveConfiguration() {
@@ -281,7 +293,7 @@ public class NotificationTemplatesUIBean implements Serializable {
this.alertNotificationManager.updateAlertNotification(this.activeNotification);
}
- return SUCCESS_OUTCOME;
+ return CONTINUE_OUTCOME;
}
public String removeSelected() {
@@ -291,7 +303,7 @@ public class NotificationTemplatesUIBean implements Serializable {
alertNotificationManager.removeNotificationsFromTemplate(subject, selectedTemplate.getId(), toArray(ids));
- return SUCCESS_OUTCOME;
+ return CONTINUE_OUTCOME;
}
public String saveOrder() {
@@ -304,7 +316,7 @@ public class NotificationTemplatesUIBean implements Serializable {
this.alertNotificationManager.updateAlertNotification(notification);
}
- return SUCCESS_OUTCOME;
+ return CONTINUE_OUTCOME;
}
private List<Integer> getSelectedIds(Collection<AlertNotification> notifications) {
@@ -332,14 +344,7 @@ public class NotificationTemplatesUIBean implements Serializable {
return result;
}
- public List<NotificationTemplate> getNotificationTemplates() {
-
- List<NotificationTemplate> templates = alertNotificationManager.listNotificationTemplates(EnterpriseFacesContextUtility.getSubject());
- listOfTemplates = templates;
- return templates;
- }
-
- public String createNoticationTemplate() {
+ public String createNotificationTemplate() {
NotificationTemplate templ;
@@ -352,7 +357,7 @@ public class NotificationTemplatesUIBean implements Serializable {
FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR,"Creation of template failed: " + iae.getMessage());
}
- return SUCCESS_OUTCOME;
+ return NEW_OUTCOME;
}
public String deleteNotificationTemplate() {
@@ -362,7 +367,7 @@ public class NotificationTemplatesUIBean implements Serializable {
Iterator<Object> iter = selectedTemplates.getKeys();
while (iter.hasNext()) {
Integer row = (Integer) iter.next();
- NotificationTemplate templ = listOfTemplates.get(row);
+ NotificationTemplate templ = notificationTemplates.get(row);
ids.add(templ.getId());
}
@@ -375,26 +380,30 @@ public class NotificationTemplatesUIBean implements Serializable {
summary+="s";
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, summary);
- return SUCCESS_OUTCOME;
+ return NEW_OUTCOME;
}
- public String editNotificationTemplate() {
+ public void editNotificationTemplate() {
Subject subject = EnterpriseFacesContextUtility.getSubject();
System.out.println("in edit Template");
Iterator<Object> iter = selectedTemplates.getKeys();
if (selectedTemplates.size()==1) {
Integer row = (Integer) iter.next();
- selectedTemplate = listOfTemplates.get(row);
- alertNotifications = alertNotificationManager.getNotificationsForTemplate(subject,selectedTemplate.getId());
- this.notificationConverter.setAlertNotifications(alertNotifications);
- System.out.println("Selected template is " + selectedTemplate);
- opMode = EDIT;
+ selectTemplate(notificationTemplates.get(row));
}
- else
+ else {
opMode = "";
+ }
+ }
- return SUCCESS_OUTCOME;
+ private void selectTemplate(NotificationTemplate template) {
+ Subject subject = EnterpriseFacesContextUtility.getSubject();
+ selectedTemplate = template;
+ alertNotifications = alertNotificationManager.getNotificationsForTemplate(subject, selectedTemplate.getId());
+ this.notificationConverter.setAlertNotifications(alertNotifications);
+ System.out.println("Selected template is " + selectedTemplate);
+ opMode = EDIT;
}
}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml
index fbff540..a760608 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml
@@ -106,5 +106,29 @@
</navigation-case>
</navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/rhq/resource/alert/notif/notificationTemplates.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-outcome>continue</from-outcome>
+ <to-view-id>/rhq/resource/alert/notif/notificationTemplates.xhtml?nid=#{notificationTemplateUIBean.activeNotification.id}&tid=#{notificationTemplateUIBean.selectedTemplate.id}</to-view-id>
+
+ <redirect />
+ </navigation-case>
+
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/rhq/resource/alert/notif/notificationTemplates.xhtml</from-view-id>
+
+ <navigation-case>
+ <from-outcome>new</from-outcome>
+ <to-view-id>/rhq/resource/alert/notif/notificationTemplates.xhtml</to-view-id>
+
+ <redirect />
+ </navigation-case>
+
+ </navigation-rule>
-</faces-config>
\ No newline at end of file
+</faces-config>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/notificationTemplates.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/notificationTemplates.xhtml
index 18aedb0..17f5128 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/notificationTemplates.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/notif/notificationTemplates.xhtml
@@ -102,7 +102,7 @@
<p/>
<h:commandButton id="newTemplateButton"
value="Create new Template"
- action="#{notificationTemplateUIBean.createNoticationTemplate}"
+ action="#{notificationTemplateUIBean.createNotificationTemplate}"
styleClass="buttonmed"/>
</h:form>
</rich:panel>
diff --git a/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml
index 8dba350..ae84d32 100644
--- a/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -17,7 +17,7 @@
<!-- Global preferences for all snmp alerts -->
<serverplugin:plugin-configuration>
- <c:simple-property name="snmpVersion" displayName="Snmp protcol version" type="string" required="false" default="1">
+ <c:simple-property name="snmpVersion" displayName="SNMP protcol version" type="string" required="false" default="1">
<c:property-options>
<c:option value="1"/>
<c:option value="2c"/>
@@ -28,7 +28,7 @@
<c:simple-property name="trapOid" displayName="Trap OID" description="OID for the trap sent" type="string" />
<c:simple-property name="community" type="string" default="public" description="Community - v1 and v2c only" required="false"/>
- <c:group name="1" displayName="Snmp version 1 properties" hiddenByDefault="true" >
+ <c:group name="1" displayName="SNMP version 1 properties" hiddenByDefault="true" >
<c:simple-property name="engineId" required="false"/>
<c:simple-property name="genericId" required="false"/>
<c:simple-property name="enterpriseOid" required="false"/>
@@ -40,7 +40,7 @@
Nothing special
</c:group>
-->
- <c:group name="3" displayName="Snmp version 3 properties" hiddenByDefault="true">
+ <c:group name="3" displayName="SNMP version 3 properties" hiddenByDefault="true">
<c:simple-property name="authProtocol" type="string" default="MD5">
<c:property-options>
<c:option value="none"/>
14 years, 4 months