[rhq] Branch 'perftest' - 16 commits - modules/core modules/enterprise modules/plugins
by Heiko W. Rupp
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/measurement/MeasurementAgentService.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementDataRequest.java | 61 +
modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java | 8
modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java | 85 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceTypeGWTService.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java | 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java | 8
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientProxy.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java | 30
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerLocal.java | 25
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/TemporarySessionPasswordGenerator.java | 259 -------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java | 14
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/TempSessionLoginModule.java | 100 --
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java | 17
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java | 23
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerLocal.java | 3
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java | 8
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java | 7
modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java | 358 ----------
modules/enterprise/server/plugins/alert-operations/src/main/resources/META-INF/rhq-serverplugin.xml | 17
modules/enterprise/server/plugins/alert-operations/src/main/resources/operations.xhtml | 79 --
modules/plugins/jboss-as-5/testsuite/src/main/java/org/rhq/plugins/jbossas5/JBossServerTest.java | 13
35 files changed, 272 insertions(+), 991 deletions(-)
New commits:
commit 58c4c2c16107e05136cddbb8322731dd12146892
Merge: 28acd40... 74c6ac2...
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Oct 14 12:40:28 2010 +0200
Merge branch 'master' into perftest
commit 74c6ac20bd7ff5f12842f6a2c5962f8a3b179fee
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Oct 13 15:15:08 2010 -0400
need to populate the operations drop down when changing the descendant selection
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
index b2e9c05..e1bad9b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
@@ -172,7 +172,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
ancestorTypeSelectItem.addChangedHandler(new ChangedHandler() {
@Override
public void onChanged(ChangedEvent event) {
- populateRelativeDescendantsDropDownMenu(null);
+ populateRelativeDescendantsDropDownMenu(null, null, null);
}
});
@@ -186,6 +186,12 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
descendantTypeSelectItem
.setTooltip("The resource type to search for under the root type defined in the Start Search From selection.");
descendantTypeSelectItem.setShowIfCondition(new ShowIfModeFunction(ResourceSelectionMode.RELATIVE));
+ descendantTypeSelectItem.addChangedHandler(new ChangedHandler() {
+ @Override
+ public void onChanged(ChangedEvent event) {
+ setOperationDropDownMenuValues(Integer.valueOf(event.getItem().getValue().toString()), null, null);
+ }
+ });
descendantNameTextItem = new TextItem("descendantNameTextItem");
descendantNameTextItem.setStartRow(false);
@@ -229,7 +235,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
descendantTypeSelectItem.clearValue();
descendantNameTextItem.clearValue();
hideOperationDropDownMenu();
- populateRelativeDropDownMenus(null, null);
+ populateRelativeDropDownMenus(null, null, null, null);
break;
}
}
@@ -260,7 +266,8 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
break;
}
case RELATIVE: {
- populateRelativeDropDownMenus(notifInfo.getAncestorTypeId(), notifInfo.getDescendantTypeId());
+ populateRelativeDropDownMenus(notifInfo.getAncestorTypeId(), notifInfo.getDescendantTypeId(), notifInfo
+ .getOperationId(), notifInfo.getOperationArguments());
if (notifInfo.getDescendantName() != null) {
descendantNameTextItem.setValue(notifInfo.getDescendantName());
}
@@ -274,7 +281,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
}
private void populateRelativeDropDownMenus(final Integer selectedResourceTypeId,
- final Integer descendantResourceTypeId) {
+ final Integer descendantResourceTypeId, final Integer selectedOpId, final Configuration opArgs) {
if (ancestorTypeSelectItem.getValue() == null) {
AsyncCallback<ArrayList<ResourceType>> callback = new AsyncCallback<ArrayList<ResourceType>>() {
@@ -290,7 +297,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
} else {
ancestorTypeSelectItem.setValue(String.valueOf(results.get(0).getId()));
}
- populateRelativeDescendantsDropDownMenu(descendantResourceTypeId);
+ populateRelativeDescendantsDropDownMenu(descendantResourceTypeId, selectedOpId, opArgs);
}
@Override
@@ -306,10 +313,13 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
GWTServiceLookup.getResourceTypeGWTService().getAllResourceTypeAncestors(this.resourceType.getId(),
callback);
}
+ } else {
+ populateRelativeDescendantsDropDownMenu(descendantResourceTypeId, selectedOpId, opArgs);
}
}
- private void populateRelativeDescendantsDropDownMenu(final Integer selectedDescendantResourceTypeId) {
+ private void populateRelativeDescendantsDropDownMenu(final Integer selectedDescendantResourceTypeId,
+ final Integer selectedOpId, final Configuration opArgs) {
Object rootResourceTypeIdObj = ancestorTypeSelectItem.getValue();
final int rootResourceTypeId;
@@ -331,9 +341,13 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
descendantTypeSelectItem.setValueMap(map);
if (selectedDescendantResourceTypeId != null) {
descendantTypeSelectItem.setValue(selectedDescendantResourceTypeId.toString());
+ setOperationDropDownMenuValues(selectedDescendantResourceTypeId.intValue(), selectedOpId,
+ opArgs);
} else {
descendantTypeSelectItem.setValue(String.valueOf(rootResourceTypeId));
+ setOperationDropDownMenuValues(rootResourceTypeId, selectedOpId, opArgs);
}
+
}
@Override
@@ -394,10 +408,10 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
* If args is non-null (and if opId is non-null), this will pre-populate the argument config editor.
*
* @param resourceTypeId the type whose operation definitions are to be shown in the operation drop down menu
- * @param opId if not-null, the selected operation
+ * @param selectedOpId if not-null, the selected operation
* @param args if not-null (and opId is not null), this will prepopulate the argument config
*/
- private void setOperationDropDownMenuValues(int resourceTypeId, final Integer opId, final Configuration args) {
+ private void setOperationDropDownMenuValues(int resourceTypeId, final Integer selectedOpId, final Configuration args) {
ResourceTypeCriteria criteria = new ResourceTypeCriteria();
criteria.addFilterId(resourceTypeId);
criteria.fetchOperationDefinitions(true);
@@ -423,9 +437,10 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
}
operationSelectItem.setAttribute(OPERATION_DEFS_ATTRIBUTE, (Object) opDefs);
operationSelectItem.setValueMap(valueMap);
- if (opId != null && opId > 0 && opDefs.containsKey(opId)) {
- operationSelectItem.setValue(String.valueOf(opId));
- showOperationArguments(opDefs.get(opId).getParametersConfigurationDefinition(), args);
+ if (selectedOpId != null && selectedOpId > 0 && opDefs.containsKey(selectedOpId)) {
+ operationSelectItem.setValue(String.valueOf(selectedOpId));
+ showOperationArguments(opDefs.get(selectedOpId).getParametersConfigurationDefinition(),
+ args);
} else {
operationSelectItem.clearValue(); // sets it to the default
hideOperationArguments();
commit 3b9b30f9582b0255ba2425b91dfa60735e8184b1
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Oct 13 14:18:04 2010 -0400
Changes to let selenium locators properly identify the nodes. I'm not
sure why we were passing the "new TreeNode[0]" as a child in the
constructors, it doesn't seem right, does not seem to adversely affect
our tree creation (perhaps it will help?) and removal seems to solve the
selenium issue.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
index 41e70c6..f4b69ae 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
@@ -27,11 +27,16 @@ import org.rhq.core.domain.util.StringUtils;
*/
public class EnhancedTreeNode extends TreeNode {
public EnhancedTreeNode() {
- this(null);
+ super();
+ // this(null);
}
public EnhancedTreeNode(String name) {
- this(name, new TreeNode[0]);
+ //this(name, new TreeNode[0]);
+ super(name);
+ if (name != null) {
+ setTitle(StringUtils.deCamelCase(name));
+ }
}
public EnhancedTreeNode(String name, TreeNode... children) {
@@ -65,8 +70,7 @@ public class EnhancedTreeNode extends TreeNode {
String className = this.getClass().getName();
String simpleClassName = className.substring(className.lastIndexOf(".") + 1);
innerClassName = simpleClassName.substring(simpleClassName.lastIndexOf("$") + 1);
- }
- catch (RuntimeException e) {
+ } catch (RuntimeException e) {
innerClassName = "EnhancedTreeNode";
}
commit 3e90719a317d577fc6fc90c0efae8b840aa8cc99
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Oct 13 11:45:13 2010 -0400
remove legacy TempSessionLoginModule and all related classes
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
index 6359a23..3b125e1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
@@ -93,11 +93,6 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
private SessionManager sessionManager = SessionManager.getInstance();
/**
- * This is used to generate temporary session passwords and to validate those passwords.
- */
- private TemporarySessionPasswordGenerator m_sessionPasswordGenerator = new TemporarySessionPasswordGenerator();
-
- /**
* @see org.rhq.enterprise.server.auth.SubjectManagerLocal#loadUserConfiguration(Integer)
*/
public Subject loadUserConfiguration(Integer subjectId) {
@@ -253,31 +248,6 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
}
/**
- * @see org.rhq.enterprise.server.auth.SubjectManagerLocal#generateTemporarySessionPassword(int)
- */
- public String generateTemporarySessionPassword(int sessionId) {
- return m_sessionPasswordGenerator.generateSessionPassword(sessionId);
- }
-
- /**
- * @see org.rhq.enterprise.server.auth.SubjectManagerLocal#authenticateTemporarySessionPassword(java.lang.String)
- */
- public boolean authenticateTemporarySessionPassword(String password) throws Exception {
- Integer sessionId = m_sessionPasswordGenerator.authenticateSessionPassword(password);
- boolean validPassword = false;
-
- if (sessionId != null) {
- // If the password was valid, sessionId will be the ID to its associated session. We now have to make
- // sure that session is still valid - this just makes sure the session hasn't timed out or was invalidated
- if (sessionManager.getSubject(sessionId.intValue()) != null) {
- validPassword = true;
- }
- }
-
- return validPassword;
- }
-
- /**
* @see org.rhq.enterprise.server.auth.SubjectManagerLocal#login(String, String)
*/
public Subject login(String username, String password) throws LoginException {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerLocal.java
index b4b7d55..d62096b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerLocal.java
@@ -72,31 +72,6 @@ public interface SubjectManagerLocal {
PageList<Subject> findAllSubjects(PageControl pageControl);
/**
- * Generates a one-time temporary session password for the given session. This can be used to authenticate the user
- * of that session for one time and one time only (i.e. to login as the user this temporary password can be used as
- * opposed to the user's real password).
- *
- * <p>Note that this method should only be available on this EJB's local interface.</p>
- *
- * @param sessionId the session to assign a temporary password to
- *
- * @return a temporary password that can be used once to login as the user
- */
- String generateTemporarySessionPassword(int sessionId);
-
- /**
- * Tests the validity of the given session password. Returns <code>true</code> if the password is valid and the
- * session is still valid.
- *
- * @param password a temporary session password that was created by {@link #generateTemporarySessionPassword(int)}.
- *
- * @return <code>true</code> if the given <code>password</code> is valid and its associated session is still valid
- *
- * @throws Exception if the password was valid but its associated session has either timed out or was invalidated
- */
- boolean authenticateTemporarySessionPassword(String password) throws Exception;
-
- /**
* Logs in a user without performing any authentication. This method should be used with care and not available to
* remote clients. Because of the unauthenticated nature of this login, the new login session will have a session
* timeout of only a few seconds. However, if you pass in <code>true</code> for the "reattach", this method will
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/TemporarySessionPasswordGenerator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/TemporarySessionPasswordGenerator.java
deleted file mode 100644
index fc82ce2..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/TemporarySessionPasswordGenerator.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.server.auth;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import org.jboss.security.Util;
-
-/**
- * Provides a random password generator and a storage area that helps temporarily authenticate users even though their
- * true passwords are not known. This is necessary when a scheduled action is triggered and we want to run as the user,
- * but we don't know the user's true password. In other words, these temporary passwords should only be used if we have
- * previously validated the user for a given session ID. Session passwords generated by this object can only be used
- * once, and they must be validated fairly quickly after being generated.
- *
- * <p>This object is thread-safe.</p>
- *
- * @author John Mazzitelli
- */
-public class TemporarySessionPasswordGenerator {
- /**
- * This is a separator character that will appear between the session ID and a random set of characters in a
- * generated session password. This character must NOT be in {@link #SESSION_PASSWORD_PREFIX}.
- */
- private static final char SESSION_PASSWORD_SEPARATOR = '$';
-
- /**
- * A prefix to all generated session passwords; this makes it possible to quickly identify a possible session
- * password. While this doesn't exclusively identify only session passwords, it helps eliminate most passwords from
- * being recognized as a session password. None of the characters in this string will be the same as
- * {@link #SESSION_PASSWORD_SEPARATOR}.
- */
- private static final String SESSION_PASSWORD_PREFIX = "_x|=~";
-
- /**
- * Map keyed on session Integers whose values are Longs indicating when the session's password was created.
- */
- private final Map<Integer, Long> m_sessionPasswordCreationDates;
-
- /**
- * Map keyed on session Integers whose values are the MD5 strings of the generated passwords.
- */
- private final Map<Integer, String> m_sessionPasswordMD5Strings;
-
- /**
- * The amount of milliseconds that a temporary password is guaranteed to remain valid (a password may actually live
- * longer than this, but it is not guaranteed to do so)
- */
- private final int m_timeoutMillis;
-
- /**
- * Constructor for {@link TemporarySessionPasswordGenerator}.
- */
- public TemporarySessionPasswordGenerator() {
- this(60 * 60 * 1000); // be default, give a copious 60 minutes - this is easily enough for what we need to use this class for
- }
-
- /**
- * Constructor for {@link TemporarySessionPasswordGenerator}.
- *
- * @param timeoutMillis the amount of milliseconds that a temporary password is guaranteed to remain valid (a
- * password may actually live longer than this, but it is not guaranteed to do so)
- */
- public TemporarySessionPasswordGenerator(int timeoutMillis) {
- m_sessionPasswordCreationDates = new HashMap<Integer, Long>();
- m_sessionPasswordMD5Strings = new HashMap<Integer, String>();
- m_timeoutMillis = timeoutMillis;
-
- return;
- }
-
- /**
- * Given a session identifier, this will generate a temporary password that can be used to identify the user whose
- * session that is. Use {@link #authenticateSessionPassword(String)} to later check for this password's
- * authenticity. This session password can only be authenticated once.
- *
- * @param sessionId the session of a user who needs a temporary password assigned
- *
- * @return a password that can be used to associate a session with a user
- *
- * @see #authenticateSessionPassword(String)
- */
- public String generateSessionPassword(int sessionId) {
- StringBuffer pwBuf = new StringBuffer(SESSION_PASSWORD_PREFIX);
-
- pwBuf.append(sessionId);
- pwBuf.append(SESSION_PASSWORD_SEPARATOR);
- pwBuf.append(generateRandomPassword());
-
- String pw = pwBuf.toString();
-
- storeSessionPassword(new Integer(sessionId), pw);
-
- return pw;
- }
-
- /**
- * Returns the session's ID if the given session's password was one that was generated by this object. Returns
- * <code>null</code> if the password was invalid and thus the user attempting to log in should be denied access.
- * Once authenticated, the password will no longer be valid and can not be used to validate the session again.
- *
- * @param password the password to test
- *
- * @return session's ID if the session's <code>password</code> was one that was generated by this object; <code>
- * null</code> otherwise
- *
- * @throws IllegalStateException if the password was in a valid format but the password's MD5 does not match; this
- * exception will only be thrown when it looks like someone is trying to hack a
- * session password
- *
- * @see #generateSessionPassword(int)
- */
- public Integer authenticateSessionPassword(String password) throws IllegalStateException {
- int separator = (password != null) ? password.indexOf(SESSION_PASSWORD_SEPARATOR) : -1;
-
- // let's quickly eliminate most passwords
- if ((separator == -1) || !password.startsWith(SESSION_PASSWORD_PREFIX)) {
- return null;
- }
-
- String sessionStr = password.substring(SESSION_PASSWORD_PREFIX.length(), separator);
- Integer sessionId;
-
- try {
- sessionId = new Integer(sessionStr);
- } catch (NumberFormatException e) {
- // kinda looked like our password, but it can't be since this should have been a valid session ID number
- return null;
- }
-
- String passwordMD5 = generateMD5(password);
- String sessionMD5;
-
- synchronized (this) {
- purgeOldSessionPasswords(); // let's do this cleanup now; must do this inside the sychronized block
-
- // we only allow a session password to be authenticated once, so remove all traces of it while retrieving it
- sessionMD5 = m_sessionPasswordMD5Strings.remove(sessionId);
- m_sessionPasswordCreationDates.remove(sessionId);
- }
-
- // the session password was either already authenticated or was removed because it was too old
- if (sessionMD5 == null) {
- return null;
- }
-
- // the password was wrong, if we got this far and the password was wrong, someone is trying to hack
- if (!sessionMD5.equals(passwordMD5)) {
- throw new IllegalStateException(
- "WARNING! A session was attempted to be reattached but the login password was invalid");
- }
-
- return sessionId;
- }
-
- /**
- * Stores the generated session password in our internal data structures so we can authenticate the session using
- * the password.
- *
- * @param sessionId the session identifier
- * @param pw the password to store
- */
- private void storeSessionPassword(Integer sessionId, String pw) {
- synchronized (this) {
- purgeOldSessionPasswords(); // let's do this cleanup now; must do this inside the sychronized block
-
- m_sessionPasswordCreationDates.put(sessionId, new Long(System.currentTimeMillis()));
- m_sessionPasswordMD5Strings.put(sessionId, generateMD5(pw));
- }
-
- return;
- }
-
- /**
- * Looks at the current set of session passwords and removes those that are old. Not sure why these passwords would
- * be hanging around, since usually generated session passwords are authenticated fairly quickly thereafter. But
- * just in case something went wrong between the time the password was generated and the time it was to be
- * authenticated, this method is used to clean up.
- *
- * <p>To avoid having to enter another synchronized block and again attempt to aquire a lock, make sure you call
- * this method from within a sychronized block - this method requires "this" object's lock.</p>
- */
- private void purgeOldSessionPasswords() {
- long earliestAllowed = System.currentTimeMillis() - m_timeoutMillis;
- List<Integer> doomedSessions = new ArrayList<Integer>();
-
- for (Map.Entry<Integer, Long> entry : m_sessionPasswordCreationDates.entrySet()) {
- Long creationTime = entry.getValue();
-
- if (creationTime.longValue() < earliestAllowed) {
- doomedSessions.add(entry.getKey());
- }
- }
-
- for (Integer doomedSession : doomedSessions) {
- m_sessionPasswordCreationDates.remove(doomedSession);
- m_sessionPasswordMD5Strings.remove(doomedSession);
- }
-
- return;
- }
-
- /**
- * Generates a random password that will be used as part of the session password.
- *
- * @return a random password
- */
- private String generateRandomPassword() {
- // generate a random password - this will usually be used as part of a Basic Authentication to our WebDAV server
- // make sure these can be encoded in a URL (no + signs - don't ask - see UrlUtil.encodeMore)
- // make sure SESSION_PASSWORD_SEPARATOR character is NOT in the chars variable!
- StringBuffer password = new StringBuffer();
- String chars = "0a3X1bWd-2VeU*fTgH7sGtF6YS^KpJqI4rh7RiQj_5P.kOZlNm|0Mn~Lou!9EvD4wACxB8yz";
- Random random = new Random(System.currentTimeMillis());
- int passwordLength = 0;
-
- while (passwordLength < 64) {
- passwordLength = random.nextInt(129);
- }
-
- random = new Random(System.currentTimeMillis() + passwordLength);
-
- for (int i = 0; i < passwordLength; i++) {
- password.append(chars.charAt(random.nextInt(chars.length())));
- }
-
- return password.toString();
- }
-
- /**
- * Given a password string, this will return its MD5.
- *
- * @param password the string whose MD5 is to be calculated
- *
- * @return the MD5 string
- */
- private String generateMD5(String password) {
- return Util.createPasswordHash("MD5", "base64", null, null, password);
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
index caec439..7787dba 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
@@ -113,20 +113,6 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM
this.log.info("Enabling RHQ JDBC JAAS Provider");
configEntries.add(ace);
- /*
- * NOT USED ANYMORE
- // to support the need for authenticating temporary session passwords, add a login module that can do that
- // we set an empty set of config options, but if we need to, we can store the config items
- // in the RHQ_config_props table, which would allow the GUI to modify them (just in case we want to add that capability)
- // the "conf" Properties value has all RHQ_config_props values, so we have that now
- // for now, there are no config properties we need in this login module, so just create an empty map
- ace = new AppConfigurationEntry(TempSessionLoginModule.class.getName(),
- AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT, new HashMap<String, String>());
- this.log.info("Enabled the temporary session login module");
- configEntries.add(ace);
- *
- */
-
String provider = conf.getProperty(RHQConstants.JAASProvider);
if ((provider != null) && provider.equals(RHQConstants.LDAPJAASProvider)) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/TempSessionLoginModule.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/TempSessionLoginModule.java
deleted file mode 100644
index a58f275..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/TempSessionLoginModule.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.server.core.jaas;
-
-import java.security.acl.Group;
-import java.util.Map;
-import javax.security.auth.Subject;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.login.LoginException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.security.SimpleGroup;
-import org.jboss.security.auth.spi.UsernamePasswordLoginModule;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-/**
- * A "special" JAAS login module that checks to see if the password is a valid temporary session password. If it is, the
- * user is authenticated; if not, the user is denied access.
- *
- * <p>This is used mainly to support the use-case where a server component needs to submit a request that needs to again
- * be authenticated. In this case, the server doesn't know the user's true password; instead a temporary session
- * password was created for the user.
- *
- * @author John Mazzitelli
- */
-public class TempSessionLoginModule extends UsernamePasswordLoginModule {
- /**
- * Logger
- */
- private static final Log LOG = LogFactory.getLog(TempSessionLoginModule.class);
-
- /**
- * A place where this login module can initialize itself.
- *
- * @param theSubject
- * @param theHandler
- * @param theSharedState
- * @param theOptions
- */
- public void initialize(Subject theSubject, CallbackHandler theHandler, Map theSharedState, Map theOptions) {
- super.initialize(theSubject, theHandler, theSharedState, theOptions);
- }
-
- /**
- * We don't know the user's true password, so we don't know the expected password; therefore, this returns an empty
- * string. This class overrides {@link #validatePassword(String, String)} so it can validate on the input password
- * that was entered by the client, since it is all we need to check validity.
- *
- * @return empty string
- */
- protected String getUsersPassword() {
- return "";
- }
-
- /**
- * Authenticates the user by seeing if the <code>inputPassword</code> is a valid temporary session password. <code>
- * expectedPassword</code> is ignored.
- *
- * @see UsernamePasswordLoginModule#validatePassword(String, String)
- */
- protected boolean validatePassword(String inputPassword, String expectedPassword) {
- boolean validPassword = false;
-
- // call into the JON authentication subsystem to see if the input password was valid.
- try {
- validPassword = LookupUtil.getSubjectManager().authenticateTemporarySessionPassword(inputPassword);
- } catch (Exception e) {
- LOG.error("Failed to authenticate a session password for user [" + getUsername() + "]", e);
- }
-
- return validPassword;
- }
-
- /**
- * @see org.jboss.security.auth.spi.AbstractServerLoginModule#getRoleSets()
- */
- protected Group[] getRoleSets() throws LoginException {
- SimpleGroup roles = new SimpleGroup("Roles");
-
- //roles.addMember( new SimplePrincipal( "some role" ) );
-
- return new Group[] { roles };
- }
-}
\ No newline at end of file
commit fa51b77cce5f9e3d5af5d72099d93fa7c9efc0c2
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Oct 13 10:31:09 2010 -0400
don't show id fields in grids
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index eb7175b..7c6aaf9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -105,6 +105,7 @@ public class ResourceSearchView extends Table {
protected void configureTable() {
ListGridField idField = new ListGridField("id", "Id", 55);
idField.setType(ListGridFieldType.INTEGER);
+ idField.setHidden(true);
ListGridField iconField = new ListGridField("icon", "", 40);
ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(), 250);
nameField.setCellFormatter(new CellFormatter() {
commit 08566cc2f400a51b1c81f7a8be6b7e405d47eb26
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Oct 12 17:40:26 2010 -0400
Fix issues with sticky tab navigation between different resources or
resources and autogroups.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
index cf9e470..3544941 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/CoreGUI.java
@@ -40,6 +40,7 @@ import org.rhq.enterprise.gui.coregui.client.admin.AdministrationView;
import org.rhq.enterprise.gui.coregui.client.alert.AlertsView;
import org.rhq.enterprise.gui.coregui.client.bundle.BundleTopView;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardsView;
+import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupDetailView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupTopView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.InventoryView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTopView;
@@ -60,6 +61,10 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
private static final String DEFAULT_VIEW_PATH = DashboardsView.VIEW_ID;
+ // just to avoid constructing this over and over
+ private static final String TREE_NAV_VIEW_PATTERN = "(" + ResourceTopView.VIEW_ID + "|"
+ + ResourceGroupTopView.VIEW_ID + "|" + ResourceGroupDetailView.AUTO_GROUP_VIEW_PATH + ")/[^/]*";
+
public static final String CONTENT_CANVAS_ID = "BaseContent";
private static ErrorHandler errorHandler = new ErrorHandler();
@@ -255,8 +260,8 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
// We're already there - just refresh the view.
refresh();
} else {
- if (viewPath.matches("(" + ResourceTopView.VIEW_ID + "|" + ResourceGroupTopView.VIEW_ID + ")/[^/]*")) {
- // e.g. "Resource/10001"
+ if (viewPath.matches(TREE_NAV_VIEW_PATTERN)) {
+ // e.g. "Resource/10001" or "Resource/AutoGroup/10003"
if (!currentViewPath.startsWith(viewPath)) {
// The Node that was selected is not the same Node that was previously selected - it
// may not even be the same node type. For example, the user could have moved from a
@@ -265,6 +270,10 @@ public class CoreGUI implements EntryPoint, ValueChangeHandler<String> {
// history URL and append it to the new history URL. The suffix is assumed to follow the
// ID (numeric) portion of the currentViewPath.
String suffix = currentViewPath.replaceFirst("\\D*[^/]*", "");
+ // make sure we're not *too* sticky, stop no deeper than the subtab level. This prevents
+ // trying to render non-applicable detail views. We'll do this by chopping at the start
+ // of any other numeric in the path
+ suffix = suffix.replaceFirst("\\d.*", "");
viewPath += suffix;
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
index f63e185..79606f6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
@@ -208,7 +208,7 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo
// Do *not* select the tab and trigger the tab selected event until the subtab has been selected first.
SubTab subtab = (subtabTitle != null) ? tab.getSubTabByTitle(subtabTitle) : tab.getDefaultSubTab();
- if (subtab == null || tab.getLayout().isDisabled()) {
+ if (subtab == null || tab.getLayout().isSubTabDisabled(subtab)) {
CoreGUI.getErrorHandler().handleError("Invalid subtab name: " + subtabTitle);
// TODO: Should we fire a history event here to redirect to a valid bookmark?
subtab = tab.getLayout().getDefaultSubTab();
commit bc08fd4b21cdde7b5bde37a5cdd73ce47647e035
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Oct 12 17:00:19 2010 -0400
no longer need the DELETEME jsf tab - gwt ui should now be able to do everything the jsf alert def ui was able to do
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 159a679..0e22ac2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -100,7 +100,6 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
private SubTab opSched;
private SubTab alertHistory;
private SubTab alertDef;
- private SubTab alertDelete;
private SubTab configCurrent;
private SubTab configHistory;
private SubTab eventHistory;
@@ -157,8 +156,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
alertsTab = new TwoLevelTab(getTabSet().extendLocatorId("Alerts"), "Alerts", "/images/icons/Alert_grey_16.png");
this.alertHistory = new SubTab(alertsTab.extendLocatorId("History"), "History", null);
this.alertDef = new SubTab(alertsTab.extendLocatorId("Definitions"), "Definitions", null);
- this.alertDelete = new SubTab(alertsTab.extendLocatorId("DELETEME"), "DELETEME", null);
- alertsTab.registerSubTabs(alertHistory, alertDef, alertDelete);
+ alertsTab.registerSubTabs(alertHistory, alertDef);
tabs.add(alertsTab);
configurationTab = new TwoLevelTab(getTabSet().extendLocatorId("Configuration"), "Configuration",
@@ -269,8 +267,6 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
"/rhq/resource/alert/listAlertHistory-plain.xhtml?id=" + resource.getId()), true, true);
updateSubTab(this.alertsTab, this.alertDef, new ResourceAlertDefinitionsView(alertsTab
.extendLocatorId("AlertDefView"), this.resourceComposite), true, true);
- updateSubTab(this.alertsTab, this.alertDelete, new FullHTMLPane(
- "/rhq/resource/alert/listAlertDefinitions-plain.xhtml?id=" + resource.getId()), true, true);
if (updateTab(this.configurationTab, facets.contains(ResourceTypeFacet.CONFIGURATION), resourcePermissions
.isConfigureRead())) {
commit c8cd1d264fb1f59d19e2016e35ac2d271c2022f8
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Oct 12 16:49:35 2010 -0400
monumental commit. I think this finishes the initial coding of the entire resource alert definition UI. this commit completes the relative resource operation notification.
lots-o-testing and lots-o-bug-fixing is still required.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
index 1b7b233..b2e9c05 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
@@ -24,8 +24,10 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
+import java.util.Map;
import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -167,6 +169,12 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
ancestorTypeSelectItem
.setTooltip("Select the top of the type hierarchy from which to search its descedant tree for the Filter By type");
ancestorTypeSelectItem.setShowIfCondition(new ShowIfModeFunction(ResourceSelectionMode.RELATIVE));
+ ancestorTypeSelectItem.addChangedHandler(new ChangedHandler() {
+ @Override
+ public void onChanged(ChangedEvent event) {
+ populateRelativeDescendantsDropDownMenu(null);
+ }
+ });
descendantTypeSelectItem = new SelectItem("descendantTypeSelectItem", "Then Filter By");
descendantTypeSelectItem.setStartRow(true);
@@ -221,8 +229,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
descendantTypeSelectItem.clearValue();
descendantNameTextItem.clearValue();
hideOperationDropDownMenu();
- populateRelativeAncestorDropDownMenu(null);
- // TODO
+ populateRelativeDropDownMenus(null, null);
break;
}
}
@@ -253,9 +260,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
break;
}
case RELATIVE: {
- populateRelativeAncestorDropDownMenu(notifInfo.getAncestorTypeId());
- // TODO
- descendantTypeSelectItem.setValue(notifInfo.getDescendantTypeId());
+ populateRelativeDropDownMenus(notifInfo.getAncestorTypeId(), notifInfo.getDescendantTypeId());
if (notifInfo.getDescendantName() != null) {
descendantNameTextItem.setValue(notifInfo.getDescendantName());
}
@@ -268,7 +273,9 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
}
}
- private void populateRelativeAncestorDropDownMenu(final Integer selectedResourceTypeId) {
+ private void populateRelativeDropDownMenus(final Integer selectedResourceTypeId,
+ final Integer descendantResourceTypeId) {
+
if (ancestorTypeSelectItem.getValue() == null) {
AsyncCallback<ArrayList<ResourceType>> callback = new AsyncCallback<ArrayList<ResourceType>>() {
@Override
@@ -283,6 +290,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
} else {
ancestorTypeSelectItem.setValue(String.valueOf(results.get(0).getId()));
}
+ populateRelativeDescendantsDropDownMenu(descendantResourceTypeId);
}
@Override
@@ -301,6 +309,40 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
}
}
+ private void populateRelativeDescendantsDropDownMenu(final Integer selectedDescendantResourceTypeId) {
+ Object rootResourceTypeIdObj = ancestorTypeSelectItem.getValue();
+ final int rootResourceTypeId;
+
+ if (rootResourceTypeIdObj == null) {
+ rootResourceTypeId = this.resourceType.getId();
+ } else {
+ rootResourceTypeId = Integer.parseInt(rootResourceTypeIdObj.toString());
+ }
+ GWTServiceLookup.getResourceTypeGWTService().getResourceTypeDescendantsWithOperations(rootResourceTypeId,
+ new AsyncCallback<HashMap<Integer, String>>() {
+
+ @Override
+ public void onSuccess(HashMap<Integer, String> results) {
+ LinkedHashMap<String, String> map = new LinkedHashMap<String, String>(results.size() + 1);
+ map.put(String.valueOf(rootResourceTypeId), "Root Ancestor Type");
+ for (Map.Entry<Integer, String> entry : results.entrySet()) {
+ map.put(entry.getKey().toString(), entry.getValue());
+ }
+ descendantTypeSelectItem.setValueMap(map);
+ if (selectedDescendantResourceTypeId != null) {
+ descendantTypeSelectItem.setValue(selectedDescendantResourceTypeId.toString());
+ } else {
+ descendantTypeSelectItem.setValue(String.valueOf(rootResourceTypeId));
+ }
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Cannot get type descendants", caught);
+ }
+ });
+ }
+
/**
* This assumes the user or our code selected a specific operation from the drop down list.
* This will show the operation arguments as appropriate for the selected operation.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceTypeGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceTypeGWTService.java
index 2b2bd45..e2eeb96 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceTypeGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceTypeGWTService.java
@@ -1,6 +1,7 @@
package org.rhq.enterprise.gui.coregui.client.gwt;
import java.util.ArrayList;
+import java.util.HashMap;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@@ -18,5 +19,5 @@ public interface ResourceTypeGWTService extends RemoteService {
ArrayList<ResourceType> getAllResourceTypeAncestors(int resourceTypeId);
- ArrayList<ResourceType> getResourceTypeDescendantsWithOperations(int resourceTypeId);
+ HashMap<Integer, String> getResourceTypeDescendantsWithOperations(int resourceTypeId);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
index e99d65d..be25a0b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceTypeGWTServiceImpl.java
@@ -1,6 +1,7 @@
package org.rhq.enterprise.gui.coregui.server.gwt;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import org.rhq.core.domain.criteria.ResourceTypeCriteria;
@@ -61,13 +62,12 @@ public class ResourceTypeGWTServiceImpl extends AbstractGWTServiceImpl implement
}
@Override
- public ArrayList<ResourceType> getResourceTypeDescendantsWithOperations(int resourceTypeId) {
+ public HashMap<Integer, String> getResourceTypeDescendantsWithOperations(int resourceTypeId) {
try {
ResourceTypeManagerLocal typeManager = LookupUtil.getResourceTypeManager();
- List<ResourceType> list = typeManager.getResourceTypeDescendantsWithOperations(getSessionSubject(),
+ HashMap<Integer, String> map = typeManager.getResourceTypeDescendantsWithOperations(getSessionSubject(),
resourceTypeId);
- return SerialUtility.prepare(new ArrayList<ResourceType>(list),
- "ResourceTypes.getResourceTypeDescendantsWithOperations");
+ return SerialUtility.prepare(map, "ResourceTypes.getResourceTypeDescendantsWithOperations");
} catch (Exception e) {
throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java
index 9dc348c..1837023 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerBean.java
@@ -23,6 +23,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -44,6 +45,7 @@ import org.jboss.annotation.IgnoreDependency;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.ResourceTypeCriteria;
+import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
@@ -426,20 +428,25 @@ public class ResourceTypeManagerBean implements ResourceTypeManagerLocal, Resour
return results;
}
- public List<ResourceType> getResourceTypeDescendantsWithOperations(Subject subject, int resourceTypeId) {
+ public HashMap<Integer, String> getResourceTypeDescendantsWithOperations(Subject subject, int resourceTypeId) {
List<ResourceType> types = getAllResourceTypeDescendants(subject, resourceTypeId);
- List<ResourceType> results = excludeThoseWithoutOperations(types);
+ excludeThoseWithoutOperations(types);
+ HashMap<Integer, String> results = new HashMap<Integer, String>(types.size());
+ for (ResourceType type : types) {
+ results.put(type.getId(), type.getName());
+ }
return results;
}
- private List<ResourceType> excludeThoseWithoutOperations(List<ResourceType> types) {
- List<ResourceType> results = new ArrayList<ResourceType>();
- for (ResourceType next : types) {
- if (next.getOperationDefinitions() != null && next.getOperationDefinitions().size() != 0) {
- results.add(next);
+ private void excludeThoseWithoutOperations(List<ResourceType> types) {
+ Iterator<ResourceType> iterator = types.iterator();
+ while (iterator.hasNext()) {
+ ResourceType next = iterator.next();
+ Set<OperationDefinition> operations = next.getOperationDefinitions();
+ if (operations == null || operations.isEmpty()) {
+ iterator.remove();
}
}
- return results;
}
public List<ResourceType> getAllResourceTypeAncestors(Subject subject, int resourceTypeId) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerLocal.java
index 6cd3639..6886944 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceTypeManagerLocal.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.server.resource;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
@@ -133,7 +134,7 @@ public interface ResourceTypeManagerLocal {
ResourceType getResourceTypeByNameAndPlugin(Subject subject, String name, String plugin);
- List<ResourceType> getResourceTypeDescendantsWithOperations(Subject subject, int resourceTypeId);
+ HashMap<Integer, String> getResourceTypeDescendantsWithOperations(Subject subject, int resourceTypeId);
List<ResourceType> getAllResourceTypeAncestors(Subject subject, int resourceTypeId);
diff --git a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java b/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java
deleted file mode 100644
index 2d85548..0000000
--- a/modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * 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.plugins.alertOperations;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.rhq.core.domain.alert.AlertDefinition;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.enterprise.server.plugin.pc.alert.CustomAlertSenderBackingBean;
-import org.rhq.enterprise.server.plugins.alertOperations.OperationInfo.ResourceSelectionMode;
-import org.rhq.enterprise.server.resource.ResourceTypeNotFoundException;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-/**
- * Backing bean for the operations alert sender
- * @author Joseph Marques
- */
-public class OperationsBackingBean extends CustomAlertSenderBackingBean {
-
- private Map<String, String> selectionModeOptions = new LinkedHashMap<String, String>();
- private Map<String, String> ancestorTypeOptions = new LinkedHashMap<String, String>();
- private Map<String, String> descendantTypeOptions = new LinkedHashMap<String, String>();
- private Map<String, String> operationNameOptions = new LinkedHashMap<String, String>();
-
- private String selectionMode = "";
- private String resourceId;
- private String ancestorTypeId;
- private String descendantName;
- private String descendantTypeId;
- private String operationDefinitionId;
-
- private String effectiveResourceTypeName;
- private String effectiveResourceTypeId;
-
- private ConfigurationDefinition argumentsConfigurationDefinition;
- private Configuration argumentsConfiguration;
-
- private Subject overlord;
-
- private Subject getOverlord() {
- if (overlord == null) {
- overlord = LookupUtil.getSubjectManager().getOverlord();
- }
- return overlord;
- }
-
- @Override
- public void loadView() {
- selectionMode = get(OperationInfo.Constants.SELECTION_MODE, "none");
-
- // always load first list
- for (ResourceSelectionMode mode : ResourceSelectionMode.values()) {
- selectionModeOptions.put(mode.displayString, mode.name());
- }
-
- Configuration previousArguments = extraParameters;
-
- // load secondList if currentType is selected
- if (selectionMode.equals("none")) {
- return;
- }
-
- if (selectionMode.equals(ResourceSelectionMode.SPECIFIC.name())) {
- resourceId = get(OperationInfo.Constants.SPECIFIC_RESOURCE_ID, "");
- } else if (selectionMode.equals(ResourceSelectionMode.RELATIVE.name())) {
- ancestorTypeId = get(OperationInfo.Constants.RELATIVE_ANCESTOR_TYPE_ID, "none");
- descendantName = get(OperationInfo.Constants.RELATIVE_DESCENDANT_NAME, "Name (optional)");
- descendantTypeId = get(OperationInfo.Constants.RELATIVE_DESCENDANT_TYPE_ID, "none");
-
- ResourceType contextType = computeResourceTypeFromContext(); // should not be null
- List<ResourceType> ancestors = null;
- if (context.equals("resource")) {
- try {
- List<Resource> ancestry = LookupUtil.getResourceManager().getResourceLineage(
- Integer.parseInt(contextSubId));
- ancestors = new ArrayList<ResourceType>();
- for (Resource next : ancestry) {
- ancestors.add(next.getResourceType());
- }
- } catch (Throwable t) {
- // ignore, we'll default to a different loading style below
- }
- }
-
- if (ancestors == null) { // if not in the resource content or fallback if resource ancestry loading bombs
- // mazz was here - I replaced getResourceTypeAcestorsWithOperations - this entire backing bean
- // will be deleted soon, so we don't care - i just needed to get this to compile again
- ancestors = LookupUtil.getResourceTypeManager().getAllResourceTypeAncestors(getOverlord(),
- contextType.getId());
- }
- load(ancestorTypeOptions, ancestors);
-
- if (ancestorTypeId.equals("none") == false) {
- List<ResourceType> descendants = LookupUtil.getResourceTypeManager()
- .getResourceTypeDescendantsWithOperations(getOverlord(), Integer.parseInt(ancestorTypeId));
- load(descendantTypeOptions, descendants);
- } else {
- List<ResourceType> descendants = LookupUtil.getResourceTypeManager()
- .getResourceTypeDescendantsWithOperations(getOverlord(), contextType.getId());
- load(descendantTypeOptions, descendants);
- }
- }
-
- // compute effectiveResourceTypeId from given info
- ResourceType type = null;
- if (selectionMode.equals(ResourceSelectionMode.SELF.name())) {
- type = computeResourceTypeFromContext();
-
- } else if (selectionMode.equals(ResourceSelectionMode.SPECIFIC.name())) {
- if (resourceId.equals("") == false) {
- Resource resource = LookupUtil.getResourceManager().getResource(getOverlord(),
- Integer.parseInt(resourceId));
- type = resource.getResourceType();
- }
-
- } else if (selectionMode.equals(ResourceSelectionMode.RELATIVE.name())) {
- try {
- if (descendantTypeId.equals("none") == false) {
- type = LookupUtil.getResourceTypeManager().getResourceTypeById(getOverlord(),
- Integer.parseInt(descendantTypeId));
- } else if (ancestorTypeId.equals("none") == false) {
- type = LookupUtil.getResourceTypeManager().getResourceTypeById(getOverlord(),
- Integer.parseInt(ancestorTypeId));
- }
- } catch (ResourceTypeNotFoundException rtnfe) {
- // debugging message
- }
- }
-
- if (type == null) {
- return;
- }
-
- effectiveResourceTypeId = String.valueOf(type.getId());
- effectiveResourceTypeName = type.getName();
-
- operationDefinitionId = get(OperationInfo.Constants.OPERATION_ID, "none");
- List<OperationDefinition> definitions = LookupUtil.getOperationManager().findSupportedResourceTypeOperations(
- getOverlord(), Integer.valueOf(effectiveResourceTypeId), false);
- for (OperationDefinition nextDefinition : definitions) {
- operationNameOptions.put(nextDefinition.getDisplayName(), String.valueOf(nextDefinition.getId()));
- }
-
- if (operationDefinitionId.equals("none")) {
- return;
- }
-
- try {
- OperationDefinition operation = LookupUtil.getOperationManager().getOperationDefinition(getOverlord(),
- Integer.parseInt(operationDefinitionId));
- argumentsConfigurationDefinition = operation.getParametersConfigurationDefinition();
-
- if (argumentsConfigurationDefinition == null) {
- return;
- }
-
- if (previousArguments == null) {
- // create it for the first time or if this was previous removed due to switching form options
- Configuration emptyConfiguration = LookupUtil.getConfigurationManager()
- .getConfigurationFromDefaultTemplate(argumentsConfigurationDefinition);
- argumentsConfiguration = emptyConfiguration.deepCopy(false);
- } else {
- argumentsConfiguration = previousArguments;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void load(Map<String, String> resourceTypeOptions, List<ResourceType> types) {
- for (ResourceType nextType : types) {
- resourceTypeOptions.put(nextType.getName(), String.valueOf(nextType.getId()));
- }
- }
-
- private ResourceType computeResourceTypeFromContext() {
- AlertDefinition definition = LookupUtil.getAlertDefinitionManager().getAlertDefinitionById(getOverlord(),
- Integer.parseInt(contextId));
-
- ResourceType type = null;
- if (definition.getResource() != null) {
- type = definition.getResource().getResourceType();
- } else if (definition.getResourceGroup() != null) {
- type = definition.getResourceGroup().getResourceType();
- } else {
- type = definition.getResourceType();
- }
- return type;
- }
-
- private String get(OperationInfo.Constants operationInfoConstant, String defaultValue) {
- return alertParameters.getSimpleValue(operationInfoConstant.propertyName, defaultValue);
- }
-
- @Override
- public void saveView() {
- set(selectionMode, OperationInfo.Constants.SELECTION_MODE);
- set(resourceId, OperationInfo.Constants.SPECIFIC_RESOURCE_ID);
- set(ancestorTypeId, OperationInfo.Constants.RELATIVE_ANCESTOR_TYPE_ID);
- set("Name (optional)".equals(descendantName) ? null : descendantName,
- OperationInfo.Constants.RELATIVE_DESCENDANT_NAME);
- set(descendantTypeId, OperationInfo.Constants.RELATIVE_DESCENDANT_TYPE_ID);
- set(operationDefinitionId, OperationInfo.Constants.OPERATION_ID);
-
- // persist the updates to the argumentsConfiguration
- if (operationDefinitionId != null && !operationDefinitionId.equals("none") && argumentsConfiguration != null) {
- extraParameters = persistConfiguration(argumentsConfiguration);
- } else {
- extraParameters = null;
- //deleteExtraParameters();
- }
-
- alertParameters = persistConfiguration(alertParameters);
- }
-
- private boolean set(String value, OperationInfo.Constants operationInfoConstant) {
- String propertyName = operationInfoConstant.propertyName;
- if (value == null) {
- Property previous = alertParameters.remove(propertyName);
- if (previous == null) {
- return false; // removing a non-existence property, no change
- }
- return ((PropertySimple) previous).getStringValue() != null;
- }
- PropertySimple property = alertParameters.getSimple(propertyName);
- if (property == null) {
- property = new PropertySimple(propertyName, value);
- alertParameters.put(property);
- return true; // adding a property that previously didn't exist
- } else {
- String oldStringValue = property.getStringValue();
- property.setStringValue(value);
- return !value.equals(oldStringValue);
- }
- }
-
- public Map<String, String> getSelectionModeOptions() {
- return selectionModeOptions;
- }
-
- public Map<String, String> getAncestorTypeOptions() {
- return ancestorTypeOptions;
- }
-
- public Map<String, String> getDescendantTypeOptions() {
- return descendantTypeOptions;
- }
-
- public Map<String, String> getOperationNameOptions() {
- return operationNameOptions;
- }
-
- public String getSelectionMode() {
- return selectionMode;
- }
-
- public void setSelectionMode(String selectionMode) {
- this.selectionMode = selectionMode;
- }
-
- public String getResourceId() {
- return resourceId;
- }
-
- public void setResourceId(String resourceId) {
- this.resourceId = resourceId;
- }
-
- public String getAncestorTypeId() {
- return ancestorTypeId;
- }
-
- public void setAncestorTypeId(String ancestorTypeId) {
- this.ancestorTypeId = ancestorTypeId;
- }
-
- public String getDescendantName() {
- return descendantName;
- }
-
- public void setDescendantName(String descendantName) {
- this.descendantName = descendantName;
- }
-
- public String getDescendantTypeId() {
- return descendantTypeId;
- }
-
- public void setDescendantTypeId(String descendantTypeId) {
- this.descendantTypeId = descendantTypeId;
- }
-
- public String getOperationDefinitionId() {
- return operationDefinitionId;
- }
-
- public void setOperationDefinitionId(String operationDefinitionId) {
- this.operationDefinitionId = operationDefinitionId;
- }
-
- public String getEffectiveResourceTypeId() {
- return effectiveResourceTypeId;
- }
-
- public String getEffectiveResourceTypeName() {
- return effectiveResourceTypeName;
- }
-
- public ConfigurationDefinition getArgumentsConfigurationDefinition() {
- return argumentsConfigurationDefinition;
- }
-
- public void setArgumentsConfigurationDefinition(ConfigurationDefinition argumentsConfigurationDefinition) {
- this.argumentsConfigurationDefinition = argumentsConfigurationDefinition;
- }
-
- public Configuration getArgumentsConfiguration() {
- return argumentsConfiguration;
- }
-
- public void setArgumentsConfiguration(Configuration argumentsConfiguration) {
- this.argumentsConfiguration = argumentsConfiguration;
- }
-
- public String getNoParametersMessage() {
- return "This operation does not take any parameters.";
- }
-
- public String getNotInitializedMessage() {
- return "This operation parameters definition has not been initialized.";
- }
-}
diff --git a/modules/enterprise/server/plugins/alert-operations/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/alert-operations/src/main/resources/META-INF/rhq-serverplugin.xml
index 752f5b3..9c5debe 100644
--- a/modules/enterprise/server/plugins/alert-operations/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/alert-operations/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -14,19 +14,18 @@
Used to execute known operations on resources currently in inventory.
</serverplugin:help>
- <!-- startup & tear down listener, + scheduled jobs
- <serverplugin:plugin-component class="Foo" />
- -->
-
<!-- How does this sender show up in drop downs etc -->
<short-name>Resource Operations</short-name>
<!-- Class that does the actual sending -->
<plugin-class>OperationsSender</plugin-class>
- <custom-ui>
- <ui-snippet-name>operations.xhtml</ui-snippet-name>
- <backing-bean-class>OperationsBackingBean</backing-bean-class>
- <backing-bean-name>operationsBean</backing-bean-name>
- </custom-ui>
+ <alert-configuration>
+ <c:simple-property name="selection-mode" type="string" required="true" description="How the resource is to be identified: SELF, SPECIFIC or RELATIVE"/>
+ <c:simple-property name="selection-specific-resource-id" type="integer" required="true" description="If SPECIFIC mode, identifies the resource"/>
+ <c:simple-property name="selection-relative-ancestor-type-id" type="integer" required="true" description="If RELATIVE, the type at the top of the hierarchy"/>
+ <c:simple-property name="selection-relative-descendant-type-id" type="integer" required="true" description="If RELATIVE, the type at the bottom of the hierarchy to identify the resource by its type"/>
+ <c:simple-property name="selection-relative-descendant-name" type="integer" required="false" description="If RELATIVE and not-null, this further helps identify the resource by its name"/>
+ <c:simple-property name="operation-definition-id" type="integer" required="true" description="Identifies the operation to be invoked"/>
+ </alert-configuration>
</alert-plugin>
\ No newline at end of file
diff --git a/modules/enterprise/server/plugins/alert-operations/src/main/resources/operations.xhtml b/modules/enterprise/server/plugins/alert-operations/src/main/resources/operations.xhtml
deleted file mode 100644
index 0502e73..0000000
--- a/modules/enterprise/server/plugins/alert-operations/src/main/resources/operations.xhtml
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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:a4j="https://richfaces.org/a4j"
- xmlns:rich="http://richfaces.ajax4jsf.org/rich"
- xmlns:onc="http://jboss.org/on/component" >
-
-<body>
-
- <h:panelGrid columns="2">
- <h:outputText value="Resource Selection Mode:" style="width: 150px;" />
- <h:selectOneMenu value="#{operationsBean.selectionMode}" >
- <f:selectItem itemValue="none" itemLabel="Select..." />
- <f:selectItems value="#{operationsBean.selectionModeOptions}" />
- </h:selectOneMenu>
-
- <h:outputText value="Resource ID:" rendered="#{operationsBean.selectionMode eq 'SPECIFIC'}" />
- <h:panelGroup rendered="#{operationsBean.selectionMode eq 'SPECIFIC'}">
- <h:inputText value="#{operationsBean.resourceId}" id="resourceId" />
- <a href="#"
- onclick="window.open('/rhq/inventory/resourcePicker.xhtml?nomenu=true&fieldId=customContentForm:resourceId', 'ResourcePicker','width=1000,height=700,scrollbars=yes,toolbar=no,resizable=yes,location=no,status=no,left=100,top=100'); return false;"
- class="buttonmed">Pick</a>
- </h:panelGroup>
-
- <h:outputText value="Start Search From:" style="width: 200px;" rendered="#{operationsBean.selectionMode eq 'RELATIVE'}" />
- <h:selectOneMenu value="#{operationsBean.ancestorTypeId}" rendered="#{operationsBean.selectionMode eq 'RELATIVE'}">
- <f:selectItem itemValue="none" itemLabel="Select..." />
- <f:selectItems value="#{operationsBean.ancestorTypeOptions}" />
- </h:selectOneMenu>
-
- <h:outputText value="Then Filter By:" style="width: 200px;" rendered="#{operationsBean.selectionMode eq 'RELATIVE'}"/>
- <h:panelGroup rendered="#{operationsBean.selectionMode eq 'RELATIVE'}">
- <h:selectOneMenu value="#{operationsBean.descendantTypeId}">
- <f:selectItem itemValue="none" itemLabel="Select..." />
- <f:selectItems value="#{operationsBean.descendantTypeOptions}" />
- </h:selectOneMenu>
- <h:inputText value="#{operationsBean.descendantName}" id="nameFilter"
- onfocus="if (this.value == 'Name (optional)') { this.value = ''; this.style.color = 'black'; } "
- onblur="if (this.value == '') { this.value = 'Name (optional)'; this.style.color = 'gray'; } "/>
- </h:panelGroup>
-
- <h:outputText value="Operation Name:" rendered="#{!empty operationsBean.effectiveResourceTypeId}"/>
- <h:selectOneMenu value="#{operationsBean.operationDefinitionId}"
- rendered="#{!empty operationsBean.effectiveResourceTypeId}" >
- <f:selectItem itemValue="none" itemLabel="Select..." />
- <f:selectItems value="#{operationsBean.operationNameOptions}"/>
- </h:selectOneMenu>
- </h:panelGrid>
-
- <h:panelGroup rendered="#{!empty operationsBean.operationDefinitionId and operationsBean.operationDefinitionId ne 'none'}">
- <onc:config configurationDefinition="#{operationsBean.argumentsConfigurationDefinition}"
- configuration="#{operationsBean.argumentsConfiguration}"
- nullConfigurationDefinitionMessage="#{operationsBean.noParametersMessage}"
- nullConfigurationMessage="#{operationsBean.notInitializedMessage}"
- nullConfigurationStyle="InfoBlock"
- readOnly="false" />
- </h:panelGroup>
-
- <script>
- addWindowOnLoadEvent(function() {
- var nameFilterElement = getElementCrossBrowser('customContentForm:nameFilter')
- if (nameFilterElement.value == 'Name (optional)') {
- nameFilterElement.style.color = 'gray';
- }
- });
- </script>
-
-<rich:modalPanel id="ResourcePicker">
- <h:outputLink>Hello World</h:outputLink>
- <p/>
- <a onclick="Richfaces.hideModalPanel('ResourcePicker');" href="#">Hide</a>
-</rich:modalPanel>
-
-
-</body>
-</html>
commit 63f55447f31e96dfdf6bc0459069634b248f0549
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Oct 12 16:45:54 2010 -0400
we can't assume our server will be able to respond within 10s for every request. increase to 60s just to be safe (a slow UI is better than a broken UI)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
index d0760d2..ebd0ab5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
@@ -139,7 +139,7 @@ public class GWTServiceLookup {
public static class SessionRpcRequestBuilder extends RpcRequestBuilder {
- private static int RPC_TIMEOUT = 10000;
+ private static int RPC_TIMEOUT = 60000;
@Override
protected RequestBuilder doCreate(String serviceEntryPoint) {
commit a59dda22140b5b001fdc1d91cfaec59d44827e21
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Oct 12 14:17:25 2010 -0400
Fix issue with empty condition and notif alert def tabs
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
index bdaff67..bea63ba 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
@@ -136,6 +136,8 @@ public abstract class AbstractAlertDefinitionsView extends TableSection {
final AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
criteria.addFilterId(id);
criteria.fetchGroupAlertDefinition(true);
+ criteria.fetchConditions(true);
+ criteria.fetchAlertNotifications(true);
GWTServiceLookup.getAlertDefinitionService().findAlertDefinitionsByCriteria(criteria,
new AsyncCallback<PageList<AlertDefinition>>() {
public void onFailure(Throwable caught) {
commit df34ecb6adae45dfcc15c60b216d3454eca4d6c5
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Oct 12 12:26:30 2010 -0400
build form in constructor - for some reason, onInit was also getting called during destroy which in turn caused "global exception" to occur
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
index 2519e6e..1b7b233 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
@@ -94,11 +94,11 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
super(locatorId, notif, sender);
this.resourceType = resourceType;
this.theResource = res;
+
+ buildUI();
}
- @Override
- protected void onInit() {
- super.onInit();
+ private void buildUI() {
dynamicForm = new LocatableDynamicForm(extendLocatorId("resOpForm"));
dynamicForm.setNumCols(3);
commit d12d99072c8fba68ddc2cbffc93df618c7733e91
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Oct 12 11:11:48 2010 -0400
[BZ 614251] Forgot to include updated interface in previous commit
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/measurement/MeasurementAgentService.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/measurement/MeasurementAgentService.java
index 66a5524..786e60f 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/measurement/MeasurementAgentService.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/measurement/MeasurementAgentService.java
@@ -22,11 +22,13 @@
*/
package org.rhq.core.clientapi.agent.measurement;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementData;
+import org.rhq.core.domain.measurement.MeasurementDataRequest;
import org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest;
/**
@@ -74,7 +76,7 @@ public interface MeasurementAgentService {
* @param measurementNames the names of the numeric metrics or traits to be collected
* @return the set of collected measurements with their data values collected
*/
- Set<MeasurementData> getRealTimeMeasurementValue(int resourceId, DataType dataType, String... measurementNames);
+ Set<MeasurementData> getRealTimeMeasurementValue(int resourceId, List<MeasurementDataRequest> requests);
Map<String, Object> getMeasurementScheduleInfoForResource(int resourceId);
}
\ No newline at end of file
commit e4530b09fd5e37ebca580153107090e4a10e06a8
Merge: ca28918... 04f6d32...
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Oct 12 11:03:19 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit ca289182efed696e10cbda5c8ad2b53ff2bc5acb
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Oct 12 10:55:23 2010 -0400
[BZ 614251] Making multiple changes so that live metric data can be fetched and displayed
There are two changes with this commit. First, in the CLI the ResourceProxy class
was using a criteria query that is too broad, at least when the jboss-as and
jboss-as-5 plugins are involved.
Secondly, the server/agent API used to get the
metric data is inadequate. It accepts a variable number of measurement names but
only a single data type for those measurements. This is problematic because
there is nothing to guarantee that all of the metrics are of the same type.
On the server side, we were using a hard-coded value of METRIC for the data
type argument. The method(s) MeasurementManagerLocal.findLiveData and
MeasurementManagerRemote.findLiveData will fail any time one of the
measurement definitions has a data type other than METRIC.
MeasurementManager.getRealTimeMeasurementValue has been refactored to take a list
of MeasurementDataRequest objects. Each request specifies the metric name along
with its corresponding data type.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementDataRequest.java b/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementDataRequest.java
new file mode 100644
index 0000000..3417777
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementDataRequest.java
@@ -0,0 +1,61 @@
+package org.rhq.core.domain.measurement;
+
+import java.io.Serializable;
+
+public class MeasurementDataRequest implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /** The meausurement name */
+ private String name;
+
+ /** The meausurement's data type */
+ private DataType type;
+
+ public MeasurementDataRequest(MeasurementDefinition definition) {
+ name = definition.getName();
+ type = definition.getDataType();
+ }
+
+ public MeasurementDataRequest(String metricName, DataType type) {
+ name = metricName;
+ this.type = type;
+ }
+
+ /**
+ * @return The requested measurement's name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return The requested measurement's data type
+ */
+ public DataType getType() {
+ return type;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+
+ if (obj == this) {
+ return true;
+ }
+
+ if (obj instanceof MeasurementDataRequest) {
+ MeasurementDataRequest that = (MeasurementDataRequest) obj;
+ return this.name.equals(that.name) && this.type.equals(that.name);
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return 41 * (name.hashCode() + type.hashCode());
+ }
+
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
index e8c1c05..c777284 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
@@ -43,6 +43,7 @@ import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementData;
+import org.rhq.core.domain.measurement.MeasurementDataRequest;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pc.inventory.InventoryManager;
@@ -613,8 +614,13 @@ public class StandaloneContainer {
String[] metricNames = new String[tokens.length - 2];
System.arraycopy(tokens, 2, metricNames, 0, tokens.length - 2);
+ List<MeasurementDataRequest> requests = new ArrayList<MeasurementDataRequest>();
+ for (String metric : metricNames) {
+ requests.add(new MeasurementDataRequest(metric, dataType));
+ }
+
MeasurementManager mm = pc.getMeasurementManager();
- Set<MeasurementData> dataset = mm.getRealTimeMeasurementValue(resourceId, dataType, metricNames);
+ Set<MeasurementData> dataset = mm.getRealTimeMeasurementValue(resourceId, requests);
if (dataset == null) {
System.err.println("No data returned");
return;
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
index b58f607..2cf62d1 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
@@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
@@ -46,6 +47,7 @@ import org.rhq.core.clientapi.agent.measurement.MeasurementAgentService;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementData;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementDataRequest;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
@@ -398,9 +400,8 @@ public class MeasurementManager extends AgentService implements MeasurementAgent
// corresponding metric defs - one for the raw value and one for the derived per-minute value. There's no
// way to tell which value the caller wants. For now, it assumes the caller wants the raw value.
// (ips, 09/05/08)
- public Set<MeasurementData> getRealTimeMeasurementValue(int resourceId, DataType dataType,
- String... measurementName) {
- if (measurementName.length == 0) {
+ public Set<MeasurementData> getRealTimeMeasurementValue(int resourceId, List<MeasurementDataRequest> requests) {
+ if (requests.size() == 0) {
// There's no need to even call getValues() on the ResourceComponent if the list of metric names is empty.
return Collections.emptySet();
}
@@ -426,9 +427,9 @@ public class MeasurementManager extends AgentService implements MeasurementAgent
MeasurementReport report = new MeasurementReport();
Set<MeasurementScheduleRequest> allMeasurements = new HashSet<MeasurementScheduleRequest>();
- for (String name : measurementName) {
- MeasurementScheduleRequest request = new MeasurementScheduleRequest(1, name, 0, true, dataType);
- allMeasurements.add(request);
+ for (MeasurementDataRequest dataRequest : requests) {
+ allMeasurements.add(new MeasurementScheduleRequest(1, dataRequest.getName(), 0, true,
+ dataRequest.getType()));
}
try {
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientProxy.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientProxy.java
index d1ff605..a76a0ad 100644
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientProxy.java
+++ b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/proxy/ResourceClientProxy.java
@@ -222,7 +222,9 @@ public class ResourceClientProxy {
private void initMeasurements() {
MeasurementDefinitionCriteria criteria = new MeasurementDefinitionCriteria();
- criteria.addFilterResourceTypeName(resource.getResourceType().getName());
+ criteria.addFilterResourceTypeId(resource.getResourceType().getId());
+// criteria.addFilterResourceTypeName(resource.getResourceType().getName());
+// criteria.setStrict(true);
this.measurementDefinitions = remoteClient.getMeasurementDefinitionManagerRemote()
.findMeasurementDefinitionsByCriteria(remoteClient.getSubject(), criteria);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java
index c65cc8c..df006e8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBean.java
@@ -61,6 +61,7 @@ import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.DisplayType;
import org.rhq.core.domain.measurement.MeasurementData;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementDataRequest;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.MeasurementReport;
@@ -783,19 +784,21 @@ public class MeasurementDataManagerBean implements MeasurementDataManagerLocal,
q.setParameter("ids", ArrayUtils.wrapInList(definitionIds));
List<MeasurementDefinition> definitions = q.getResultList();
- String[] names = new String[definitions.size()];
- int i = 0;
- for (MeasurementDefinition def : definitions) {
- names[i++] = def.getName();
- }
-
AgentClient ac = agentClientManager.getAgentClient(agent);
Set<MeasurementData> values = ac.getMeasurementAgentService().getRealTimeMeasurementValue(resourceId,
- DataType.MEASUREMENT, names);
+ createRequests(definitions));
return values;
}
+ private List<MeasurementDataRequest> createRequests(List<MeasurementDefinition> definitions) {
+ List<MeasurementDataRequest> requests = new ArrayList<MeasurementDataRequest>();
+ for (MeasurementDefinition definition : definitions) {
+ requests.add(new MeasurementDataRequest(definition));
+ }
+ return requests;
+ }
+
/**
* Return all known trait data for the passed schedule, defined by resourceId and definitionId
*
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java
index b279a5a..d8effb3 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java
@@ -50,6 +50,7 @@ import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.ResourceTypeCriteria;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementData;
+import org.rhq.core.domain.measurement.MeasurementDataRequest;
import org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest;
import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.domain.resource.Agent;
@@ -266,10 +267,9 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
*/
public class MockAgentService implements MeasurementAgentService {
- public Set<MeasurementData> getRealTimeMeasurementValue(int resourceId, DataType dataType,
- String... measurementNames) {
- // TODO Auto-generated method stub
- return null;
+ @Override
+ public Set<MeasurementData> getRealTimeMeasurementValue(int resourceId, List<MeasurementDataRequest> requests) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
}
public void scheduleCollection(Set<ResourceMeasurementScheduleRequest> resourceSchedules) {
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 a02e6cf..2c08880 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
@@ -57,6 +57,7 @@ import org.rhq.core.domain.discovery.ResourceSyncInfo;
import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementData;
+import org.rhq.core.domain.measurement.MeasurementDataRequest;
import org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
@@ -124,9 +125,9 @@ public class TestAgentClient implements AgentClient, BundleAgentService, Content
// provide no-ops for all agent services
- public Set<MeasurementData> getRealTimeMeasurementValue(int resourceId, DataType dataType,
- String... measurementNames) {
- return null;
+
+ public Set<MeasurementData> getRealTimeMeasurementValue(int resourceId, List<MeasurementDataRequest> requests) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
}
public void scheduleCollection(Set<ResourceMeasurementScheduleRequest> resourceSchedules) {
diff --git a/modules/plugins/jboss-as-5/testsuite/src/main/java/org/rhq/plugins/jbossas5/JBossServerTest.java b/modules/plugins/jboss-as-5/testsuite/src/main/java/org/rhq/plugins/jbossas5/JBossServerTest.java
index 0a09f56..6192478 100644
--- a/modules/plugins/jboss-as-5/testsuite/src/main/java/org/rhq/plugins/jbossas5/JBossServerTest.java
+++ b/modules/plugins/jboss-as-5/testsuite/src/main/java/org/rhq/plugins/jbossas5/JBossServerTest.java
@@ -460,16 +460,13 @@ public class JBossServerTest extends ServletTestCase
PluginContainer pc = PluginContainer.getInstance();
Set<MeasurementDefinition> definitions = defaultDS.getResourceType().getMetricDefinitions();
- List<String> defNames = new ArrayList<String>();
- for (MeasurementDefinition definition : definitions)
- {
- defNames.add(definition.getName());
+ List<MeasurementDataRequest> requests = new ArrayList<MeasurementDataRequest>();
+ for (MeasurementDefinition definition : definitions) {
+ requests.add(new MeasurementDataRequest(definition));
}
- String[] stringArray = new String[definitions.size()];
- defNames.toArray(stringArray);
- Set<MeasurementData> data = pc.getMeasurementAgentService().getRealTimeMeasurementValue(defaultDS.getId(), null, stringArray);
+ Set<MeasurementData> data = pc.getMeasurementAgentService().getRealTimeMeasurementValue(defaultDS.getId(),
+ requests);
assert data.size() > 0 : "We should be getting some kind of measurement data back";
-
}
commit 04f6d32e9f68614cb913085211d8393d6cf63d83
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Oct 12 10:02:15 2010 -0400
Fixed some Selenium Locator issues
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
index 84ccc47..f63e185 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java
@@ -126,15 +126,13 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo
if (getSelectedItemId() == null) {
CoreGUI.goToView(History.getToken());
} else {
-
- // selectSubTabByTitle(tabSelectedEvent.getId(), tabSelectedEvent.getSubTabId());
String tabPath = "/" + tabSelectedEvent.getId() + "/" + tabSelectedEvent.getSubTabId();
String path = this.baseViewPath + "/" + getSelectedItemId() + tabPath;
// If the tab that was selected is not already the current history item, the user clicked on the tab, rather
// than going directly to the tab's URL. In this case, fire a history event to go to the tab and make it the
// current history item.
- if (!History.getToken().equals(path)) {
+ if (!History.getToken().equals(path) && !History.getToken().startsWith(path)) {
CoreGUI.goToView(path);
}
}
@@ -223,10 +221,10 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo
// Handle any remaining view items (e.g. id of a selected item in a subtab that contains a Master-Details view).
Canvas subView = subtab.getCanvas();
if (subView instanceof RefreshableView) {
- ((RefreshableView)subView).refresh();
+ ((RefreshableView) subView).refresh();
}
if (subView instanceof BookmarkableView) {
- ((BookmarkableView)subView).renderView(viewPath);
+ ((BookmarkableView) subView).renderView(viewPath);
}
this.tabSet.markForRedraw();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
index 28e91f6..4bdfdd4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/event/EventCompositeHistoryView.java
@@ -56,22 +56,22 @@ public class EventCompositeHistoryView extends TableSection {
private EntityContext context;
private boolean hasWriteAccess;
- public static EventCompositeHistoryView get(ResourceGroupComposite composite) {
+ public static EventCompositeHistoryView get(String locatorId, ResourceGroupComposite composite) {
String tableTitle = "Group Event History";
EntityContext context = EntityContext.forGroup(composite.getResourceGroup().getId());
boolean hasWriteAccess = composite.getResourcePermission().isEvent();
- return new EventCompositeHistoryView(tableTitle, context, hasWriteAccess);
+ return new EventCompositeHistoryView(locatorId, tableTitle, context, hasWriteAccess);
}
- public static EventCompositeHistoryView get(ResourceComposite composite) {
+ public static EventCompositeHistoryView get(String locatorId, ResourceComposite composite) {
String tableTitle = "Resource Event History";
EntityContext context = EntityContext.forResource(composite.getResource().getId());
boolean hasWriteAccess = composite.getResourcePermission().isEvent();
- return new EventCompositeHistoryView(tableTitle, context, hasWriteAccess);
+ return new EventCompositeHistoryView(locatorId, tableTitle, context, hasWriteAccess);
}
- private EventCompositeHistoryView(String tableTitle, EntityContext context, boolean hasWriteAccess) {
- super("EventCompositeHistoryTable", tableTitle, new SortSpecifier[] { DEFAULT_SORT_SPECIFIER });
+ private EventCompositeHistoryView(String locatorId, String tableTitle, EntityContext context, boolean hasWriteAccess) {
+ super(locatorId, tableTitle, new SortSpecifier[] { DEFAULT_SORT_SPECIFIER });
this.context = context;
this.hasWriteAccess = hasWriteAccess;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index b41d7f0..4f71441 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -253,16 +253,16 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
if (updateTab(this.configurationTab, visible, visible && this.permissions.isConfigureRead())) {
//updateSubTab(this.configurationTab, this.configCurrent, new FullHTMLPane(
// "/rhq/group/configuration/viewCurrent-plain.xhtml?groupId=" + groupId), true, true);
- updateSubTab(this.configurationTab, this.configCurrent,
- new GroupResourceConfigurationEditView(this.configCurrent.extendLocatorId("View"),
- this.groupComposite), true, true);
+ updateSubTab(this.configurationTab, this.configCurrent, new GroupResourceConfigurationEditView(
+ this.configCurrent.extendLocatorId("View"), this.groupComposite), true, true);
updateSubTab(this.configurationTab, this.configHistory, new FullHTMLPane(
"/rhq/group/configuration/history-plain.xhtml?groupId=" + groupId), true, true);
}
if (updateTab(this.eventsTab, groupCategory == GroupCategory.COMPATIBLE
&& facets.contains(ResourceTypeFacet.EVENT), true)) {
- updateSubTab(this.eventsTab, this.eventHistory, EventCompositeHistoryView.get(groupComposite), true, true);
+ updateSubTab(this.eventsTab, this.eventHistory, EventCompositeHistoryView.get(this.eventsTab
+ .extendLocatorId("CompositeHistView"), groupComposite), true, true);
}
this.show();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 05c37b6..159a679 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -276,13 +276,13 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
.isConfigureRead())) {
updateSubTab(this.configurationTab, this.configCurrent, new ResourceConfigurationEditView(this
.extendLocatorId("ResourceConfigView"), resourceComposite), true, true);
- updateSubTab(this.configurationTab, this.configHistory, ConfigurationHistoryView.getHistoryOf(
- resource.getId()), true, true);
+ updateSubTab(this.configurationTab, this.configHistory, ConfigurationHistoryView.getHistoryOf(this
+ .extendLocatorId("ConfigHistView"), resource.getId()), true, true);
}
if (updateTab(this.eventsTab, facets.contains(ResourceTypeFacet.EVENT), true)) {
- updateSubTab(this.eventsTab, this.eventHistory, EventCompositeHistoryView.get(resourceComposite), true,
- true);
+ updateSubTab(this.eventsTab, this.eventHistory, EventCompositeHistoryView.get(this.eventsTab
+ .extendLocatorId("CompositeHistoryView"), resourceComposite), true, true);
}
if (updateTab(this.contentTab, facets.contains(ResourceTypeFacet.CONTENT), true)) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
index aa11b05..8b84889 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ConfigurationHistoryView.java
@@ -40,7 +40,6 @@ import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
*/
public class ConfigurationHistoryView extends TableSection {
public static final String VIEW_ID = "RecentConfigurationChanges";
- private static final String LOCATOR_ID = "ConfigurationHistory";
private static final String TITLE = "Configuration History";
private Integer resourceId;
@@ -48,8 +47,8 @@ public class ConfigurationHistoryView extends TableSection {
/**
* Use this constructor to view config histories for all viewable Resources.
*/
- public ConfigurationHistoryView() {
- super(LOCATOR_ID, TITLE);
+ public ConfigurationHistoryView(String locatorId) {
+ super(locatorId, TITLE);
final ConfigurationHistoryDataSource datasource = new ConfigurationHistoryDataSource();
setDataSource(datasource);
}
@@ -59,8 +58,8 @@ public class ConfigurationHistoryView extends TableSection {
*
* @param resourceId a Resource ID
*/
- public ConfigurationHistoryView(int resourceId) {
- super(LOCATOR_ID, TITLE, createCriteria(resourceId));
+ public ConfigurationHistoryView(String locatorId, int resourceId) {
+ super(locatorId, TITLE, createCriteria(resourceId));
this.resourceId = resourceId;
ConfigurationHistoryDataSource datasource = new ConfigurationHistoryDataSource();
setDataSource(datasource);
@@ -157,11 +156,10 @@ public class ConfigurationHistoryView extends TableSection {
}
-
// -------- Static Utility loaders ------------
- public static ConfigurationHistoryView getHistoryOf(int resourceId) {
- return new ConfigurationHistoryView(resourceId);
+ public static ConfigurationHistoryView getHistoryOf(String locatorId, int resourceId) {
+ return new ConfigurationHistoryView(locatorId, resourceId);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
index 0a9359e..4970242 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
@@ -216,7 +216,7 @@ public class ReportTopView extends LocatableHLayout implements BookmarkableView
} else if (MeasurementOOBView.VIEW_ID.equals(pageName)) {
content = new MeasurementOOBView(this.extendLocatorId("SuspectMetrics"));
} else if (ConfigurationHistoryView.VIEW_ID.equals(pageName)) {
- content = new ConfigurationHistoryView();
+ content = new ConfigurationHistoryView(this.extendLocatorId("ConfigHistory"));
} else if (OperationHistoryView.VIEW_ID.equals(pageName)) {
content = new OperationHistoryView(this.extendLocatorId("RecentOps"));
} else if (AlertsView.VIEW_ID.equals(pageName)) {
commit f1000879c9f75dfa1153919ca5ca335ef6bf0286
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Oct 12 10:01:52 2010 -0400
Fix an issue where an F5 refresh while viewing a details page messed
up the history and rendering. The problem seemed due to an assumption in
the master-details impl that the master (list view) would always be
rendered prior to a details page.
Also, fix an issue with null protection for RefreshableViews. Removed a
showDetails() override in AbstractAlertDefinitionsView as the default
behavior seems adequate.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
index 89a6c8b..bdaff67 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
@@ -18,7 +18,6 @@
*/
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
-import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.widgets.Canvas;
@@ -102,17 +101,6 @@ public abstract class AbstractAlertDefinitionsView extends TableSection {
}
@Override
- public void showDetails(ListGridRecord record) {
- Canvas canvas = getDetailsView(record);
- setDetailsView(canvas);
-
- Integer id = record.getAttributeAsInt("id");
- History.newItem(getBasePath() + "/" + id.intValue(), false);
-
- switchToDetailsView();
- }
-
- @Override
public Canvas getDetailsView(ListGridRecord record) {
if (record == null) {
return getDetailsView(0);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index fe69ec7..b4aff2b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -437,14 +437,18 @@ public class Table extends LocatableHLayout implements RefreshableView {
private ArrayList<Integer> fieldSizes = new ArrayList<Integer>();
public void refresh(Criteria criteria) {
- this.listGrid.invalidateCache();
- this.listGrid.setCriteria(criteria);
- this.listGrid.markForRedraw();
+ if (null != this.listGrid) {
+ this.listGrid.invalidateCache();
+ this.listGrid.setCriteria(criteria);
+ this.listGrid.markForRedraw();
+ }
}
public void refresh() {
- this.listGrid.invalidateCache();
- this.listGrid.markForRedraw();
+ if (null != this.listGrid) {
+ this.listGrid.invalidateCache();
+ this.listGrid.markForRedraw();
+ }
}
public void setTableTitle(String titleString) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
index c8ab12b..f5118f7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TableSection.java
@@ -85,6 +85,12 @@ public abstract class TableSection extends Table implements BookmarkableView {
detailsHolder.hide();
addMember(detailsHolder);
+
+ // if the detailsView is already defined it means we want the details view to be rendered prior to
+ // the master view, probably due to a direct navigation or refresh (like F5 when sitting on the details page)
+ if (null != detailsView) {
+ switchToDetailsView();
+ }
}
@Override
@@ -222,6 +228,8 @@ public abstract class TableSection extends Table implements BookmarkableView {
*/
protected void switchToDetailsView() {
Canvas contents = getTableContents();
+
+ // If the Table has not yet been initialized then ignore
if (contents != null) {
if (contents.isVisible()) {
contents.animateHide(AnimationEffect.WIPE, new AnimationCallback() {
13 years, 8 months
[rhq] Branch 'perftest' - 5 commits - modules/enterprise modules/helpers
by Heiko W. Rupp
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java | 13
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java | 11
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/EventsInsertPurgeTest.java | 170 ++++++++++
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/reporting/ExcelExporter.java | 43 +-
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java | 39 ++
modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java | 4
6 files changed, 245 insertions(+), 35 deletions(-)
New commits:
commit 28acd40f69627f32523cd6e0f7c46f6f7b4ec1d4
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Oct 14 12:38:51 2010 +0200
Move required database state to class level.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java
index 6bc40b5..17520c3 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/AvailabilityInsertPurgeTest.java
@@ -47,7 +47,6 @@ import org.rhq.helpers.perftest.support.testng.DatabaseSetupInterceptor;
import org.rhq.helpers.perftest.support.testng.DatabaseState;
import org.rhq.helpers.perftest.support.testng.PerformanceReporting;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
@@ -61,6 +60,7 @@ import org.testng.annotations.Test;
@Test(groups = "PERF")
@Listeners({ DatabaseSetupInterceptor.class })
@PerformanceReporting(exporter=ExcelExporter.class)
+@DatabaseState(url = "perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip", dbVersion="2.94")
public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest {
ResourceManagerLocal resourceManager;
@@ -72,8 +72,7 @@ public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest {
private static final String ROUND__FORMAT = "Round %6d";
private static final String PURGE__FORMAT = "Purge %6d";
private static final int[] ROUNDS = new int[]{1000,2000,3000,5000,10000};
- // private static final int[] ROUNDS = new int[]{10,20};
- private Subject overlord ;
+// private static final int[] ROUNDS = new int[]{10,20};
@BeforeMethod
public void beforeMethod() {
@@ -106,7 +105,6 @@ public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest {
* @throws Exception If anything goes wrong
* @see #ROUNDS for the number of availability reports per round
*/
- @DatabaseState(url = "perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip", dbVersion="2.94")
public void testAlternating() throws Exception {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
@@ -184,7 +182,6 @@ public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest {
* @throws Exception If anything goes wrong
* @see #ROUNDS for the number of availability reports per round
*/
- @DatabaseState(url = "perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip", dbVersion="2.94")
public void testRandom() throws Exception {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
@@ -254,7 +251,6 @@ public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest {
* @throws Exception If anything goes wrong
* @see #ROUNDS for the number of availability reports per round
*/
- @DatabaseState(url = "perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip", dbVersion="2.94")
public void testAlwaysUp() throws Exception {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
@@ -327,7 +323,6 @@ public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest {
* @throws Exception If anything goes wrong
* @see #ROUNDS for the number of availability reports per round
*/
- @DatabaseState(url = "perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip", dbVersion="2.94")
public void testAlternatingWithAlert() throws Exception {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
@@ -411,6 +406,4 @@ public class AvailabilityInsertPurgeTest extends AbstractEJB3PerformanceTest {
assertLinear(purge1000,purge5000,5,"Purge3");
}
-
-
}
commit ab845b5e3713b03f77e79735cef81a6fb2dff1d1
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Oct 14 11:54:38 2010 +0200
Change naming of sheets to Class.method
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/reporting/ExcelExporter.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/reporting/ExcelExporter.java
index 6662b71..1314ce8 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/reporting/ExcelExporter.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/reporting/ExcelExporter.java
@@ -116,16 +116,22 @@ public class ExcelExporter implements PerformanceReportExporter {
*/
private void createDetailsSheet(Workbook wb, Map<String,Long> timings, ITestResult result) {
- Sheet sheet = wb.getSheet(result.getName());
+ String name = result.getTestClass().getName();
+ if (name.contains("."))
+ name = name.substring(name.lastIndexOf(".")+1);
+ name += "." + result.getName();
+
+ Sheet sheet = wb.getSheet(name);
if (sheet ==null)
- sheet = wb.createSheet(result.getName());
+ sheet = wb.createSheet(name);
Row row = appendRow(sheet);
Cell cell = row.createCell(0);
cell.setCellStyle(boldText);
cell.setCellValue("Class");
- String name = result.getTestClass().getName();
- name = name.replace("org.rhq.enterprise.server.performance.test.","");
+ name = result.getTestClass().getName();
+ if (name.contains("."))
+ name = name.substring(name.lastIndexOf(".")+1);
row.createCell(1).setCellValue(name);
row = appendRow(sheet);
@@ -197,32 +203,29 @@ public class ExcelExporter implements PerformanceReportExporter {
* @param result the TestNG result object
*/
private void createOverviewEntry(Sheet sheet, long testTime, ITestResult result) {
- // Class name
+ // Test name
Row row = appendRow(sheet);
Cell cell = row.createCell(0);
cell.setCellType(Cell.CELL_TYPE_STRING);
String name = result.getTestClass().getName();
- name = name.replace("org.rhq.enterprise.server.performance.test.","");
+ if (name.contains("."))
+ name = name.substring(name.lastIndexOf(".")+1);
+ name += "." + result.getName();
cell.setCellValue(name);
- // Test name
- cell = row.createCell(1);
- cell.setCellType(Cell.CELL_TYPE_STRING);
- cell.setCellValue(result.getName());
-
// success ?
- cell = row.createCell(2);
+ cell = row.createCell(1);
cell.setCellType(Cell.CELL_TYPE_BOOLEAN);
cell.setCellValue(result.isSuccess());
// timing from TestNG
- cell = row.createCell(3);
+ cell = row.createCell(2);
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
cell.setCellStyle(integerStyle);
cell.setCellValue(result.getEndMillis()-result.getStartMillis());
// timing of our business logic
- cell = row.createCell(4);
+ cell = row.createCell(3);
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
cell.setCellStyle(integerStyle);
cell.setCellValue(testTime);
@@ -239,25 +242,21 @@ public class ExcelExporter implements PerformanceReportExporter {
Cell cell = row.createCell(0);
cell.setCellStyle(boldText);
- cell.setCellValue("Class");
- cell = row.createCell(1);
- cell.setCellStyle(boldText);
cell.setCellValue("Name");
- cell = row.createCell(2);
+ cell = row.createCell(1);
cell.setCellStyle(boldText);
cell.setCellValue("Success");
- cell = row.createCell(3);
+ cell = row.createCell(2);
cell.setCellStyle(boldText);
cell.setCellValue("TestNG timing");
cell.setCellStyle(boldText);
- cell = row.createCell(4);
+ cell = row.createCell(3);
cell.setCellValue("Perf timing");
cell.setCellStyle(boldText);
sheet.autoSizeColumn(0);
- sheet.autoSizeColumn(1);
+ sheet.autoSizeColumn(2);
sheet.autoSizeColumn(3);
- sheet.autoSizeColumn(4);
}
commit 85d31a919a4912995d39ba6f5097d9fc8988a910
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Oct 14 10:15:55 2010 +0200
First event insertion and purge test.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/EventsInsertPurgeTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/EventsInsertPurgeTest.java
new file mode 100644
index 0000000..0332905
--- /dev/null
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/performance/test/EventsInsertPurgeTest.java
@@ -0,0 +1,170 @@
+/*
+ * 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.performance.test;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.event.Event;
+import org.rhq.core.domain.event.EventDefinition;
+import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.core.domain.event.EventSource;
+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.alert.AlertDefinitionManagerLocal;
+import org.rhq.enterprise.server.core.AgentManagerLocal;
+import org.rhq.enterprise.server.event.EventManagerLocal;
+import org.rhq.enterprise.server.measurement.AvailabilityManagerLocal;
+import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+import org.rhq.enterprise.server.system.SystemManagerLocal;
+import org.rhq.enterprise.server.test.AbstractEJB3PerformanceTest;
+import org.rhq.enterprise.server.util.LookupUtil;
+import org.rhq.helpers.perftest.support.reporting.ExcelExporter;
+import org.rhq.helpers.perftest.support.testng.DatabaseSetupInterceptor;
+import org.rhq.helpers.perftest.support.testng.DatabaseState;
+import org.rhq.helpers.perftest.support.testng.PerformanceReporting;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Listeners;
+import org.testng.annotations.Test;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Performance test the events subsystem
+ *
+ * @author Heiko W. Rupp
+ */
+@Test(groups = "PERF")
+@Listeners({ DatabaseSetupInterceptor.class })
+(a)PerformanceReporting(exporter=ExcelExporter.class)
+@DatabaseState(url = "perftest/AvailabilityInsertPurgeTest-testOne-data.xml.zip", dbVersion="2.94")
+public class EventsInsertPurgeTest extends AbstractEJB3PerformanceTest {
+
+ private static final int ROUNDS = 20000;
+ private static final int NUM_SOURCES = 10;
+ private static final int LINES_PER_REPORT = 50;
+ ResourceManagerLocal resourceManager;
+ AvailabilityManagerLocal availabilityManager;
+ AgentManagerLocal agentManager;
+ SystemManagerLocal systemManager;
+ AlertDefinitionManagerLocal alertDefinitionManager;
+ EventManagerLocal eventManager;
+ private static final int MILLIS_APART = 2000;
+ private static final String ROUND__FORMAT = "Round %6d";
+ private static final String PURGE__FORMAT = "Purge %6d";
+
+
+ @BeforeMethod
+ public void beforeMethod() {
+ Date now = new Date();
+ System.out.println(">>>>> beforeMethod (AI Purge Test) === " + now.getTime());
+ try {
+ this.availabilityManager = LookupUtil.getAvailabilityManager();
+ this.resourceManager = LookupUtil.getResourceManager();
+ this.agentManager = LookupUtil.getAgentManager();
+ this.systemManager = LookupUtil.getSystemManager();
+ this.alertDefinitionManager = LookupUtil.getAlertDefinitionManager();
+ this.eventManager = LookupUtil.getEventManager();
+ /*
+ * NOTE: do not try to get Subjects or other DB stuff in here, as they will only
+ * be available after this method has finished and the DatabaseSetupInterceptor
+ * has initialized the database.
+ */
+ } catch (Throwable t) {
+ // Catch RuntimeExceptions and Errors and dump their stack trace, because Surefire will completely swallow them
+ // and throw a cryptic NPE (see http://jira.codehaus.org/browse/SUREFIRE-157)!
+ t.printStackTrace();
+ throw new RuntimeException(t);
+ }
+ }
+
+ /**
+ * This test insertsevents from NUM_SOURCES sources into the
+ * event subsystem, where each set of events is LINES_PER_REPORT long.
+ * In total ROUNDS are inserted.
+ * After this, events are purged in two steps: first the first half of them
+ * and then the remaining ones.
+ * @throws Exception
+ */
+ public void testSimpleInserts() throws Exception {
+ Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+
+
+ EntityManager em = getEntityManager();
+ Query q = em.createQuery("SELECT r FROM Resource r");
+ List<Resource> resources = q.getResultList();
+ Resource res = resources.get(0);
+ if (!(res.getResourceType().getCategory()== ResourceCategory.PLATFORM))
+ res = resourceManager.getPlaformOfResource(overlord,res.getId());
+ ResourceType type = res.getResourceType();
+
+ EventDefinition def ;
+ Set<EventDefinition> eventDefs = type.getEventDefinitions();
+ if (eventDefs!=null && !eventDefs.isEmpty()) {
+ def = eventDefs.iterator().next();
+ }
+ else {
+ throw new RuntimeException("No event definition found, should not happen");
+ }
+
+
+ EventSource[] evSrc = new EventSource[NUM_SOURCES];
+ for (int i = 0; i < NUM_SOURCES; i++) {
+ evSrc[i] = new EventSource("ESource"+1, def, res);
+ }
+ long now = new Date().getTime() - ROUNDS * LINES_PER_REPORT;
+
+ for (int round = 1; round < ROUNDS; round++) {
+
+ Map<EventSource, Set<Event>> events = new HashMap<EventSource, Set<Event>>();
+ for (int sourceNum = 0 ; sourceNum < NUM_SOURCES; sourceNum++) {
+ Set<Event> eventSet = new HashSet<Event>();
+ for (int i = 0 ; i < LINES_PER_REPORT; i++) {
+ Event ev = new Event("EType", "ESource"+sourceNum, now+round*i, EventSeverity.INFO, "This is a 2nd test", evSrc[sourceNum]);
+ eventSet.add(ev);
+ }
+ events.put(evSrc[sourceNum], eventSet);
+ }
+ startTiming("add");
+ eventManager.addEventData(events);
+ endTiming("add");
+ }
+
+ try {
+ startTiming("purge_half");
+ eventManager.purgeEventData(new Date(now+(ROUNDS/2)*LINES_PER_REPORT));
+ endTiming("purge_half");
+ startTiming("purge_final");
+ eventManager.purgeEventData(new Date());
+ endTiming("purge_final");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ throw e;
+ }
+
+ }
+
+}
commit 6a51d174ea673b88d052cca23c53fc186c1bf478
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Oct 14 10:02:09 2010 +0200
Be somewhat more verbose on exceptions
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java
index 31b283b..293c456 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/event/EventManagerBean.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.server.event;
+import java.sql.BatchUpdateException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@@ -193,6 +194,14 @@ public class EventManagerBean implements EventManagerLocal, EventManagerRemote {
} catch (Throwable t) {
// TODO what do we want to do here ?
log.warn("addEventData: Insert of events failed : " + t.getMessage());
+ if (t instanceof SQLException) {
+ SQLException e = (SQLException) t;
+ Exception e2 = e.getNextException();
+ if (e2!=null)
+ log.warn(" : " + e2.getMessage());
+ if (t.getCause()!=null)
+ log.warn(" : " + t.getCause().getMessage());
+ }
} finally {
JDBCUtil.safeClose(conn);
}
@@ -345,9 +354,9 @@ public class EventManagerBean implements EventManagerLocal, EventManagerRemote {
criteria.addFilterStartTime(begin);
criteria.addFilterEndTime(end);
- /*
+ /*
* if the bucket computation is pushed into the database, it saves on data transfer across the wire. this
- * solution is currently querying N number of strings (event.severity) and N number of longs (event.timestamp),
+ * solution is currently querying N number of strings (event.severity) and N number of longs (event.timestamp),
* where N is the number of events between 'begin' and 'end'. if the severity buckets are computed in a single
* query, the wire load would only be K integers, where K is the bucketCount.
*/
commit baeefa7b2f1e2afe98bebebaf9525c840b8bd6d3
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Oct 13 10:19:23 2010 +0200
Allow to put the DatabaseState annotation at class level too.
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
index 57cd217..d7f10ef 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseSetupInterceptor.java
@@ -23,6 +23,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.SQLException;
@@ -43,6 +44,12 @@ import org.rhq.helpers.perftest.support.input.InputStreamProvider;
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener;
import org.testng.ITestResult;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.BeforeTest;
import javax.naming.InitialContext;
@@ -138,10 +145,40 @@ public class DatabaseSetupInterceptor implements IInvokedMethodListener {
}
+ /**
+ * Obtain the required database state by looking for the @DatabaseState annotation.
+ * Lookup is first done at method level and if not found done at class level.
+ * @param method Method that TestNG is about to invoke
+ * @return the desired database state or null if @DatabaseState is not given.
+ * @see org.rhq.helpers.perftest.support.testng.DatabaseState
+ */
private static DatabaseState getRequiredDatabaseState(IInvokedMethod method) {
Method javaMethod = method.getTestMethod().getMethod();
- return javaMethod.getAnnotation(DatabaseState.class);
+ DatabaseState annotation = javaMethod.getAnnotation(DatabaseState.class);
+ if (annotation==null) {
+ System.out.println("Method : " + javaMethod.getName());
+
+ boolean skip = false;
+
+ // Filter out methods that are marked as setup/tear down
+ Annotation[] annots = javaMethod.getAnnotations();
+ for (Annotation an : annots) {
+ System.out.println(" : " + an.toString());
+ if (an.annotationType().equals(BeforeMethod.class) || an.annotationType().equals(AfterMethod.class) ||
+ an.annotationType().equals(BeforeSuite.class) || an.annotationType().equals(AfterSuite.class) ||
+ an.annotationType().equals(BeforeTest.class) || an.annotationType().equals(AfterTest.class)
+ )
+ skip = true;
+ }
+
+ if (!skip)
+ annotation = javaMethod.getDeclaringClass().getAnnotation(DatabaseState.class);
+ else
+ System.out.println(" ..... Skipped");
+
+ }
+ return annotation;
}
diff --git a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java
index b7e66fa..9a7c476 100644
--- a/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java
+++ b/modules/helpers/perftest-support/src/main/java/org/rhq/helpers/perftest/support/testng/DatabaseState.java
@@ -28,11 +28,13 @@ import org.rhq.helpers.perftest.support.FileFormat;
/**
* An annotation to associate a test method with a required state of the database.
+ * The annotation can be given at class or method level, where a method level annotation
+ * overrides a class level one.
*
* @author Lukas Krejci
*/
@Retention(value = RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.METHOD })
+@Target(value = { ElementType.METHOD, ElementType.TYPE })
public @interface DatabaseState {
/**
13 years, 8 months
[rhq] Branch 'gwt-ldap' - 2 commits - modules/enterprise
by Simeon Pinder
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java | 36 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java | 152 ++++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleLdapGroupSelector.java | 37 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 42 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java | 37 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java | 74 +---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java | 47 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java | 44 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java | 45 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 15
11 files changed, 313 insertions(+), 218 deletions(-)
New commits:
commit 96463b629a150b7df7792d0b23040851470ed96e
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Wed Oct 13 17:24:00 2010 -0400
i)new user registration validation ii)check client side for loggedIn before fetches.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
index 69ff0ae..97a97d9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
@@ -22,9 +22,11 @@
*/
package org.rhq.enterprise.gui.coregui.client;
+import java.util.ArrayList;
import java.util.EnumSet;
import java.util.Map;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
@@ -55,6 +57,8 @@ import com.smartgwt.client.widgets.form.fields.SubmitItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
+import com.smartgwt.client.widgets.form.validator.LengthRangeValidator;
+import com.smartgwt.client.widgets.form.validator.RegExpValidator;
import com.smartgwt.client.widgets.layout.HStack;
import com.smartgwt.client.widgets.layout.VLayout;
@@ -81,6 +85,21 @@ public class LoginView extends Canvas {
public LoginView() {
}
+ //registration fields
+ private TextItem first;
+ private TextItem last;
+ private TextItem email;
+ private TextItem phone;
+ private TextItem department;
+ private ArrayList<DynamicForm> forms;
+ private static final String FIRST = "first";
+ private static final String LAST = "last";
+ private static final String USERNAME = "username";
+ private static final String EMAIL = "email";
+ private static final String PHONE = "phone";
+ private static final String DEPARTMENT = "department";
+ private static final String SESSIONID = "sessionid";
+
public void showLoginDialog() {
if (!loginShowing) {
loginShowing = true;
@@ -166,6 +185,8 @@ public class LoginView extends Canvas {
if (!loginShowing) {
loginShowing = true;
+ forms = new ArrayList<DynamicForm>();
+
form = new DynamicForm();
form.setMargin(25);
form.setAutoFocus(true);
@@ -179,18 +200,18 @@ public class LoginView extends Canvas {
+ "<br/> Once you click \"OK\" you will be logged in.<br/><br/>");
column.addMember(wrapInDynamicForm(1, header));
//build ui elements for registration screen
- final TextItem first = new TextItem("first", "First Name");
+ first = new TextItem(FIRST, "First Name");
{
first.setRequired(true);
first.setWrapTitle(false);
first.setWidth(100);
}
- final TextItem last = new TextItem("last", "Last Name");
+ last = new TextItem(LAST, "Last Name");
{
last.setWrapTitle(false);
last.setWidth(100);
}
- final TextItem username = new TextItem("username", "Username");
+ final TextItem username = new TextItem(USERNAME, "Username");
{
username.setRequired(true);
username.setValue(user);
@@ -198,12 +219,12 @@ public class LoginView extends Canvas {
username.setWidth(100);
column.addMember(wrapInDynamicForm(6, first, last, username));
}
- final TextItem email = new TextItem("email", "Email");
+ email = new TextItem(EMAIL, "Email");
email.setRequired(true);
email.setWidth(100);
- final TextItem phone = new TextItem("phone", "Phone");
+ phone = new TextItem(PHONE, "Phone");
phone.setWidth(100);
- final TextItem department = new TextItem("department", "Department");
+ department = new TextItem(DEPARTMENT, "Department");
department.setWidth(100);
SpacerItem space = new SpacerItem();
space.setColSpan(1);
@@ -219,20 +240,30 @@ public class LoginView extends Canvas {
IButton okButton = new IButton("OK");
okButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
- //pull in all relevant fields and do regular create
- //TODO: validation
- if (form.validate()) {
+ //validation
+ if (validateForms(forms)) {
+ Log.trace("Successfully validated all forms");
//populate form
- form.setValue("first", String.valueOf(first.getValue()));
- form.setValue("last", String.valueOf(last.getValue()));
- form.setValue("username", String.valueOf(username.getValue()));
- form.setValue("email", String.valueOf(email.getValue()));
- form.setValue("phone", String.valueOf(phone.getValue()));
- form.setValue("department", String.valueOf(department.getValue()));
- form.setValue("sessionid", sessionId);
+ form.setValue(FIRST, String.valueOf(first.getValue()));
+ form.setValue(LAST, String.valueOf(last.getValue()));
+ form.setValue(USERNAME, String.valueOf(username.getValue()));
+ form.setValue(EMAIL, String.valueOf(email.getValue()));
+ form.setValue(PHONE, String.valueOf(phone.getValue()));
+ form.setValue(DEPARTMENT, String.valueOf(department.getValue()));
+ form.setValue(SESSIONID, sessionId);
registerLdapUser(form, callback);
}
}
+
+ private boolean validateForms(ArrayList<DynamicForm> forms) {
+ boolean allValid = true;
+ for (DynamicForm form : forms) {
+ if (!form.validate()) {
+ allValid = false;
+ }
+ }
+ return allValid;
+ }
});
row.addMember(okButton);
@@ -251,7 +282,6 @@ public class LoginView extends Canvas {
IButton logout = new IButton("Logout");
logout.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
- // System.out.println("---------- CLICKED logout");
UserSessionManager.logout();
window.destroy();
loginShowing = false;
@@ -281,15 +311,6 @@ public class LoginView extends Canvas {
window.addItem(form);
window.show();
-
- // form.addSubmitValuesHandler(new SubmitValuesHandler() {
- // public void onSubmitValues(SubmitValuesEvent submitValuesEvent) {
- // System.out.println("IN SUBMIT HANDER");
- // if (form.validate()) {
- // login(form.getValueAsString("user"), form.getValueAsString("password"));
- // }
- // }
- // });
}
}
@@ -298,36 +319,36 @@ public class LoginView extends Canvas {
//insert some required data checking
boolean proceed = true;
- String retrieved = populatedForm.getValueAsString("username");
+ String retrieved = populatedForm.getValueAsString(USERNAME);
if ((retrieved == null) || retrieved.isEmpty() || retrieved.equalsIgnoreCase("null")) {
proceed = false;
}
- retrieved = populatedForm.getValueAsString("sessionid");
+ retrieved = populatedForm.getValueAsString(SESSIONID);
if ((retrieved == null) || retrieved.isEmpty() || retrieved.equalsIgnoreCase("null")) {
proceed = false;
}
- newSubject.setName(populatedForm.getValueAsString("username"));
- newSubject.setSessionId(Integer.valueOf(populatedForm.getValueAsString("sessionid")));
+ newSubject.setName(populatedForm.getValueAsString(USERNAME));
+ newSubject.setSessionId(Integer.valueOf(populatedForm.getValueAsString(SESSIONID)));
//don't load null values not set or returned from ldap server
- retrieved = populatedForm.getValueAsString("first");
+ retrieved = populatedForm.getValueAsString(FIRST);
if ((retrieved != null) && (!retrieved.equalsIgnoreCase("null")))
- newSubject.setFirstName(populatedForm.getValueAsString("first"));
- retrieved = populatedForm.getValueAsString("last");
+ newSubject.setFirstName(populatedForm.getValueAsString(FIRST));
+ retrieved = populatedForm.getValueAsString(LAST);
if ((retrieved != null) && (!retrieved.equalsIgnoreCase("null")))
- newSubject.setLastName(populatedForm.getValueAsString("last"));
+ newSubject.setLastName(populatedForm.getValueAsString(LAST));
- retrieved = populatedForm.getValueAsString("department");
+ retrieved = populatedForm.getValueAsString(DEPARTMENT);
if ((retrieved != null) && (!retrieved.equalsIgnoreCase("null")))
- newSubject.setDepartment(populatedForm.getValueAsString("department"));
+ newSubject.setDepartment(populatedForm.getValueAsString(DEPARTMENT));
- retrieved = populatedForm.getValueAsString("email");
+ retrieved = populatedForm.getValueAsString(EMAIL);
if ((retrieved != null) && (!retrieved.equalsIgnoreCase("null")))
- newSubject.setEmailAddress(populatedForm.getValueAsString("email"));
+ newSubject.setEmailAddress(populatedForm.getValueAsString(EMAIL));
- retrieved = populatedForm.getValueAsString("phone");
+ retrieved = populatedForm.getValueAsString(PHONE);
if ((retrieved != null) && (!retrieved.equalsIgnoreCase("null")))
- newSubject.setPhoneNumber(populatedForm.getValueAsString("phone"));
+ newSubject.setPhoneNumber(populatedForm.getValueAsString(PHONE));
// newSubject.setSmsAddress(populatedForm.getValueAsString("sms"));
newSubject.setFactive(true);
@@ -360,8 +381,10 @@ public class LoginView extends Canvas {
CoreGUI.getErrorHandler().handleError("Failed to create ldap Subject.", caught);
}
});
- } else {
+ } else {//log them out then reload LoginView
com.allen_sauer.gwt.log.client.Log.warn("Failed to locate username required to create LDAP subject.");
+ UserSessionManager.logout();
+ new LoginView().showLoginDialog();
}
}
@@ -373,15 +396,51 @@ public class LoginView extends Canvas {
*/
private Canvas wrapInDynamicForm(int columnCount, FormItem... header) {
DynamicForm form = new DynamicForm();
- if (columnCount < 1) {//default to label and details for each form item
- form.setNumCols(header.length * 2);
- } else {
- form.setNumCols(columnCount);
+ if (header != null) {
+ if (columnCount < 1) {//default to label and details for each form item
+ form.setNumCols(header.length * 2);
+ } else {
+ form.setNumCols(columnCount);
+ }
+ form.setFields(header);
+ //store away all forms for final validation
+ forms.add(form);
+ //load validators for form
+ loadValidators(form);
}
- form.setFields(header);
return form;
}
+ /**Build and loads the custom validators for each of the formItems
+ *
+ * @param form
+ */
+ private void loadValidators(DynamicForm form) {
+ if (form != null) {
+ for (FormItem item : form.getFields()) {
+ String name = item.getName();
+ if ((name != null) && (!name.isEmpty())) {
+ if (name.equals(USERNAME)) {
+ LengthRangeValidator validator = new LengthRangeValidator();
+ validator.setMin(6);
+ item.setValidators(validator);
+ }
+ if (name.equals(FIRST)) {
+ LengthRangeValidator validator = new LengthRangeValidator();
+ validator.setMin(1);
+ item.setValidators(validator);
+ }
+ if (name.equals(EMAIL)) {
+ RegExpValidator emailValidator = new RegExpValidator();
+ emailValidator.setErrorMessage("Invalid email address");
+ emailValidator.setExpression("^([a-zA-Z0-9_.\\-+])+(a)(([a-zA-Z0-9\\-])+\\.)+[a-zA-Z0-9]{2,4}$");
+ item.setValidators(emailValidator);
+ }
+ }
+ }
+ }
+ }
+
private void login(final String user, final String password) {
BrowserUtility.forceIe6Hacks();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleLdapGroupSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleLdapGroupSelector.java
index 82305b3..2443c5b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleLdapGroupSelector.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleLdapGroupSelector.java
@@ -104,26 +104,27 @@ public class RoleLdapGroupSelector extends AbstractSelector<HashSet<Map<String,
if ((currentlyAssignedLdapGroups != null)
&& (!currentlyAssignedLdapGroups.isEmpty())) {
RecordList loaded = availableGrid.getDataAsRecordList();
- ArrayList<Integer> located = new ArrayList<Integer>();
- // for (LdapGroup group : currentlyAssignedLdapGroups) {
- for (Map groupMap : currentlyAssignedLdapGroups) {
- int index = loaded.findIndex(name, (String) groupMap.get(name));
- if (index > -1) {
- located.add(Integer.valueOf(index));
+ if (loaded != null) {
+ ArrayList<Integer> located = new ArrayList<Integer>();
+ for (Map groupMap : currentlyAssignedLdapGroups) {
+ int index = loaded.findIndex(name, (String) groupMap.get(name));
+ if (index > -1) {
+ located.add(Integer.valueOf(index));
+ }
}
+ int[] records = new int[located.size()];
+ int i = 0;
+ for (Integer index : located) {
+ records[i++] = index.intValue();
+ }
+ availableGrid.selectRecords(records);
+ //now simulate button push
+ assignedGrid.transferSelectedData(availableGrid);
+ initialLdapSelectionsLoad = false;
+ select(assignedGrid.getSelection());
+ updateButtons();
+ assignedGrid.deselectAllRecords();
}
- int[] records = new int[located.size()];
- int i = 0;
- for (Integer index : located) {
- records[i++] = index.intValue();
- }
- availableGrid.selectRecords(records);
- //now simulate button push
- assignedGrid.transferSelectedData(availableGrid);
- initialLdapSelectionsLoad = false;
- select(assignedGrid.getSelection());
- updateButtons();
- assignedGrid.deselectAllRecords();
}
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java
index 17b4074..7d4ab76 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java
@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
@@ -42,6 +43,7 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.RecentlyAddedResourceComposite;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
@@ -126,59 +128,35 @@ public class RecentlyAddedResourceDS extends DataSource {
// TODO GH: Enhance resourceCriteria query to support itime based filtering for
// "Recently imported" resources
- // GWTServiceLookup.getResourceService().findRecentlyAddedResources(0, 100,
- GWTServiceLookup.getResourceService().findRecentlyAddedResources(ctime, maxItems,
- new AsyncCallback<List<RecentlyAddedResourceComposite>>() {
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to load recently added resources", throwable);
- }
+ //if logged in then proceed making server side calls
+ if (UserSessionManager.isLoggedIn()) {
+ GWTServiceLookup.getResourceService().findRecentlyAddedResources(ctime, maxItems,
+ new AsyncCallback<List<RecentlyAddedResourceComposite>>() {
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError("Failed to load recently added resources", throwable);
+ }
- public void onSuccess(List<RecentlyAddedResourceComposite> recentlyAddedList) {
- List<RecentlyAddedResourceComposite> list = new ArrayList<RecentlyAddedResourceComposite>();
+ public void onSuccess(List<RecentlyAddedResourceComposite> recentlyAddedList) {
+ List<RecentlyAddedResourceComposite> list = new ArrayList<RecentlyAddedResourceComposite>();
- for (RecentlyAddedResourceComposite recentlyAdded : recentlyAddedList) {
- list.add(recentlyAdded);
- list.addAll(recentlyAdded.getChildren());
- }
+ for (RecentlyAddedResourceComposite recentlyAdded : recentlyAddedList) {
+ list.add(recentlyAdded);
+ list.addAll(recentlyAdded.getChildren());
+ }
- response.setData(buildNodes(list));
- response.setTotalRows(list.size());
- processResponse(request.getRequestId(), response);
- }
- });
- //
- // GWTServiceLookup.getResourceService().findResourcesByCriteria(c, new AsyncCallback<PageList<Resource>>() {
- // public void onFailure(Throwable caught) {
- // CoreGUI.getErrorHandler().handleError("Failed to load recently added resources data",caught);
- // response.setStatus(DSResponse.STATUS_FAILURE);
- // processResponse(request.getRequestId(), response);
- // }
- //
- // public void onSuccess(PageList<Resource> result) {
- // PageList<Resource> all = new PageList<Resource>();
- //
- // for (Resource root : result) {
- // all.add(root);
- // if (root.getChildResources() != null)
- // all.addAll(root.getChildResources());
- // }
- //
- //
- // response.setData(buildNodes(all));
- // response.setTotalRows(all.getTotalSize());
- // processResponse(request.getRequestId(), response);
- // }
- // });
+ response.setData(buildNodes(list));
+ response.setTotalRows(list.size());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ } else {//
+ Log.debug("user is not logged in. Not fetching recently added resource now.");
+ //answer the datasource
+ response.setTotalRows(0);
+ processResponse(request.getRequestId(), response);
+ }
}
- // private TreeNode[] buildNodes(PageList<Resource> list) {
- // TreeNode[] treeNodes = new TreeNode[list.size()];
- // for (int i = 0; i < list.size(); ++i) {
- // treeNodes[i] = new ResourceTreeNode(list.get(i));
- // }
- // return treeNodes;
- // }
-
private TreeNode[] buildNodes(List<RecentlyAddedResourceComposite> list) {
TreeNode[] treeNodes = new TreeNode[list.size()];
for (int i = 0; i < list.size(); ++i) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
index 863afe2..c79dbd5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.operation;
import java.util.Date;
import java.util.List;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -132,28 +133,36 @@ public class RecentOperationsDataSource extends
}
}
- GWTServiceLookup.getOperationService().findRecentCompletedOperations(pageSize,
- new AsyncCallback<List<DisambiguationReport<ResourceOperationLastCompletedComposite>>>() {
+ if (userStillLoggedIn()) {//check session validity
+ GWTServiceLookup.getOperationService().findRecentCompletedOperations(pageSize,
+ new AsyncCallback<List<DisambiguationReport<ResourceOperationLastCompletedComposite>>>() {
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to load recently completed operations.", throwable);
- }
-
- public void onSuccess(
- List<DisambiguationReport<ResourceOperationLastCompletedComposite>> recentOperationsList) {
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError("Failed to load recently completed operations.",
+ throwable);
+ }
- //translate DisambiguationReport into dataset entries
- response.setData(buildList(recentOperationsList));
- //entry count
- if (null != recentOperationsList) {
- response.setTotalRows(recentOperationsList.size());
- } else {
- response.setTotalRows(0);
+ public void onSuccess(
+ List<DisambiguationReport<ResourceOperationLastCompletedComposite>> recentOperationsList) {
+
+ //translate DisambiguationReport into dataset entries
+ response.setData(buildList(recentOperationsList));
+ //entry count
+ if (null != recentOperationsList) {
+ response.setTotalRows(recentOperationsList.size());
+ } else {
+ response.setTotalRows(0);
+ }
+ //pass off for processing
+ processResponse(request.getRequestId(), response);
}
- //pass off for processing
- processResponse(request.getRequestId(), response);
- }
- });
+ });
+ } else {
+ Log.debug("user not logged in. Not fetching recently completed operations.");
+ //answer datasource
+ response.setTotalRows(0);
+ processResponse(request.getRequestId(), response);
+ }
}
/** Translates the DisambiguationReport of ResourceOperationLastCompletedComposites into specific
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
index ebb1185..ad86135 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.operation;
import java.util.Date;
import java.util.List;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -125,27 +126,34 @@ public class ScheduledOperationsDataSource extends
}
}
- GWTServiceLookup.getOperationService().findScheduledOperations(pageSize,
- new AsyncCallback<List<DisambiguationReport<ResourceOperationScheduleComposite>>>() {
+ if (userStillLoggedIn()) {
+ GWTServiceLookup.getOperationService().findScheduledOperations(pageSize,
+ new AsyncCallback<List<DisambiguationReport<ResourceOperationScheduleComposite>>>() {
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to load scheduled operations.", throwable);
- }
-
- public void onSuccess(List<DisambiguationReport<ResourceOperationScheduleComposite>> scheduledOpsList) {
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError("Failed to load scheduled operations.", throwable);
+ }
- //translate DisambiguationReport into dataset entries
- response.setData(buildList(scheduledOpsList));
- //entry count
- if (null != scheduledOpsList) {
- response.setTotalRows(scheduledOpsList.size());
- } else {
- response.setTotalRows(0);
+ public void onSuccess(
+ List<DisambiguationReport<ResourceOperationScheduleComposite>> scheduledOpsList) {
+
+ //translate DisambiguationReport into dataset entries
+ response.setData(buildList(scheduledOpsList));
+ //entry count
+ if (null != scheduledOpsList) {
+ response.setTotalRows(scheduledOpsList.size());
+ } else {
+ response.setTotalRows(0);
+ }
+ //pass off for processing
+ processResponse(request.getRequestId(), response);
}
- //pass off for processing
- processResponse(request.getRequestId(), response);
- }
- });
+ });
+ } else {
+ Log.debug("user not logged in. Not fetching scheduled operations.");
+ response.setTotalRows(0);
+ processResponse(request.getRequestId(), response);
+ }
}
/** Translates the DisambiguationReport of ProblemResourceComposites into specific
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
index 38c316b..af364e1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/resource/ProblemResourcesDataSource.java
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.resource;
import java.util.List;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -123,28 +124,34 @@ public class ProblemResourcesDataSource extends RPCDataSource<DisambiguationRepo
}
}
- GWTServiceLookup.getResourceService().findProblemResources(ctime, maxItems,
- new AsyncCallback<List<DisambiguationReport<ProblemResourceComposite>>>() {
+ if (userStillLoggedIn()) {
+ GWTServiceLookup.getResourceService().findProblemResources(ctime, maxItems,
+ new AsyncCallback<List<DisambiguationReport<ProblemResourceComposite>>>() {
- public void onFailure(Throwable throwable) {
- CoreGUI.getErrorHandler().handleError("Failed to load resources with alerts/unavailability.",
- throwable);
- }
-
- public void onSuccess(List<DisambiguationReport<ProblemResourceComposite>> problemResourcesList) {
+ public void onFailure(Throwable throwable) {
+ CoreGUI.getErrorHandler().handleError("Failed to load resources with alerts/unavailability.",
+ throwable);
+ }
- //translate DisambiguationReport into dataset entries
- response.setData(buildList(problemResourcesList));
- //entry count
- if (null != problemResourcesList) {
- response.setTotalRows(problemResourcesList.size());
- } else {
- response.setTotalRows(0);
+ public void onSuccess(List<DisambiguationReport<ProblemResourceComposite>> problemResourcesList) {
+
+ //translate DisambiguationReport into dataset entries
+ response.setData(buildList(problemResourcesList));
+ //entry count
+ if (null != problemResourcesList) {
+ response.setTotalRows(problemResourcesList.size());
+ } else {
+ response.setTotalRows(0);
+ }
+ //pass off for processing
+ processResponse(request.getRequestId(), response);
}
- //pass off for processing
- processResponse(request.getRequestId(), response);
- }
- });
+ });
+ } else {
+ Log.debug("user not logged in. Not fetching resources with alerts/unavailability.");
+ response.setTotalRows(0);
+ processResponse(request.getRequestId(), response);
+ }
}
/** Translates the DisambiguationReport of ProblemResourceComposites into specific
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index 014ce99..46f37b9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -24,7 +24,6 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
-import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.JavaScriptObject;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
@@ -319,7 +318,6 @@ public abstract class RPCDataSource<T> extends DataSource {
* @return boolean indication of logged in status.
*/
protected boolean userStillLoggedIn() {
- Log.debug("User still logged in:" + UserSessionManager.isLoggedIn());
return UserSessionManager.isLoggedIn();
}
commit a377d0793945449b692773321e346c0bd5874c0d
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Wed Oct 13 13:51:16 2010 -0400
i)inserted client side checking to lower amount of invalid requests for alerts ii)modified RPCDataSource to include login check method for all DataSources
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
index d7121e3..53e1ba4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -149,22 +150,27 @@ public class Footer extends LocatableToolStrip {
// last eight hours
alertCriteria.addFilterStartTime(System.currentTimeMillis() - (1000L * 60 * 60 * 8));
- GWTServiceLookup.getAlertService().findAlertsByCriteria(alertCriteria,
- new AsyncCallback<PageList<Alert>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Latest alerts lookup failed", caught);
- }
-
- public void onSuccess(PageList<Alert> result) {
- if (result.isEmpty()) {
- setContents("no recent alerts");
- setIcon("subsystems/alert/Alert_LOW_16.png");
- } else {
- setContents(result.getTotalSize() + " recent alerts");
- setIcon("subsystems/alert/Alert_HIGH_16.png");
+ //check for still logged in before submitting server side request
+ if (UserSessionManager.isLoggedIn()) {
+ GWTServiceLookup.getAlertService().findAlertsByCriteria(alertCriteria,
+ new AsyncCallback<PageList<Alert>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Latest alerts lookup failed", caught);
+ }
+
+ public void onSuccess(PageList<Alert> result) {
+ if (result.isEmpty()) {
+ setContents("no recent alerts");
+ setIcon("subsystems/alert/Alert_LOW_16.png");
+ } else {
+ setContents(result.getTotalSize() + " recent alerts");
+ setIcon("subsystems/alert/Alert_HIGH_16.png");
+ }
}
- }
- });
+ });
+ } else {//dump request
+ Log.debug("user not logged in. Not fetching any alerts now.");
+ }
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
index f6ca18f..69ff0ae 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
@@ -294,7 +294,6 @@ public class LoginView extends Canvas {
}
protected void registerLdapUser(DynamicForm populatedForm, final AsyncCallback<Void> callback) {
- System.out.println("--------- In registerLdapUser:");
Subject newSubject = new Subject();
//insert some required data checking
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
index 7d7e738..2722ea4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/UserSessionManager.java
@@ -54,7 +54,6 @@ import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
* @author Joseph Marques
*/
public class UserSessionManager {
-
private static int SESSION_TIMEOUT = 29 * 60 * 1000; // 29 mins, just shorter than the 30-min web session timeout
private static int LOGOUT_DELAY = 5 * 1000; // wait 5 seconds for in-flight requests to complete before logout
@@ -237,7 +236,6 @@ public class UserSessionManager {
}
});
} else {
- // System.out.println("--------------- Registration needed.");
Log.info("Proceeding with registration for ldap user '" + user + "'.");
loggedIn = true;
new LoginView().showRegistrationDialog(user, sessionId, callback);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
index a950c34..c8dbad3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -143,23 +144,31 @@ public class AlertDataSource extends RPCDataSource<Alert> {
AlertCriteria criteria = getCriteria(request);
- this.alertService.findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
+ //check for still logged in before submitting server side request
+ if (userStillLoggedIn()) {
+ this.alertService.findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to fetch alerts data", caught);
- response.setStatus(RPCResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to fetch alerts data", caught);
+ response.setStatus(RPCResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(PageList<Alert> result) {
+ long fetchTime = System.currentTimeMillis() - start;
+ com.allen_sauer.gwt.log.client.Log.info(result.size() + " alerts fetched in: " + fetchTime + "ms");
+ response.setData(buildRecords(result));
+ // For paging to work, we have to specify size of full result set.
+ response.setTotalRows(result.getTotalSize());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ } else {//dump request
+ response.setTotalRows(0);
+ processResponse(request.getRequestId(), response);
+ Log.debug("user not logged in. Not fetching any alerts now.");
+ }
- public void onSuccess(PageList<Alert> result) {
- long fetchTime = System.currentTimeMillis() - start;
- com.allen_sauer.gwt.log.client.Log.info(result.size() + " alerts fetched in: " + fetchTime + "ms");
- response.setData(buildRecords(result));
- // For paging to work, we have to specify size of full result set.
- response.setTotalRows(result.getTotalSize());
- processResponse(request.getRequestId(), response);
- }
- });
}
protected AlertCriteria getCriteria(DSRequest request) {
@@ -284,7 +293,8 @@ public class AlertDataSource extends RPCDataSource<Alert> {
CoreGUI.getMessageCenter().notify(
new Message("Acknowledged [" + alertIds.length + "] alerts", Message.Severity.Info));
- com.allen_sauer.gwt.log.client.Log.info("Acknowledged Alerts with id's: " + Arrays.toString(alertIds) + ".");
+ com.allen_sauer.gwt.log.client.Log.info("Acknowledged Alerts with id's: " + Arrays.toString(alertIds)
+ + ".");
alertsView.refresh();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java
index ad825a9..28da47f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java
@@ -1,5 +1,6 @@
package org.rhq.enterprise.gui.coregui.client.alert;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -86,22 +87,30 @@ public class AlertPortletDataSource extends AlertDataSource {
criteria.addFilterPriority(AlertPriority.getByLegacyIndex(getAlertPriorityIndex()));
}
- getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
+ //check for still logged in before submitting server side request
+ if (userStillLoggedIn()) {
+ getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to fetch alerts data", caught);
- response.setStatus(RPCResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to fetch alerts data", caught);
+ response.setStatus(RPCResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
- public void onSuccess(PageList<Alert> result) {
- long fetchTime = System.currentTimeMillis() - start;
- com.allen_sauer.gwt.log.client.Log.info(result.size() + " alerts fetched in: " + fetchTime + "ms");
- response.setData(buildRecords(result));
- response.setTotalRows(result.size());
- processResponse(request.getRequestId(), response);
- }
- });
+ public void onSuccess(PageList<Alert> result) {
+ long fetchTime = System.currentTimeMillis() - start;
+ Log.info(result.size() + " alerts fetched in: " + fetchTime + "ms");
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.size());
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ } else {//dump request
+ response.setTotalRows(0);
+ processResponse(request.getRequestId(), response);
+ //TODO: spinder 10/13/10: not sure if we should log anything here. Could be noisy in log with not a lot of gain.
+ Log.debug("user not logged in. Not fetching any alerts now.");
+ }
}
public int getAlertRangeCompleted() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index 86ab57e..014ce99 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -18,12 +18,13 @@
*/
package org.rhq.enterprise.gui.coregui.client.util;
-import java.util.Arrays;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.JavaScriptObject;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
@@ -39,6 +40,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.util.effects.ColoringUtility;
/**
@@ -229,7 +231,7 @@ public abstract class RPCDataSource<T> extends DataSource {
addField(field);
}
}
-
+
public void addFields(DataSourceField... fields) {
addFields(Arrays.asList(fields));
}
@@ -310,4 +312,15 @@ public abstract class RPCDataSource<T> extends DataSource {
return result;
}
+
+ /** Quick method to determine if current user is still logged in.
+ * Builds a
+ *
+ * @return boolean indication of logged in status.
+ */
+ protected boolean userStillLoggedIn() {
+ Log.debug("User still logged in:" + UserSessionManager.isLoggedIn());
+ return UserSessionManager.isLoggedIn();
+ }
+
}
13 years, 8 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java | 37 +++++++---
1 file changed, 26 insertions(+), 11 deletions(-)
New commits:
commit 74c6ac20bd7ff5f12842f6a2c5962f8a3b179fee
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Oct 13 15:15:08 2010 -0400
need to populate the operations drop down when changing the descendant selection
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
index b2e9c05..e1bad9b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceOperationNotificationSenderForm.java
@@ -172,7 +172,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
ancestorTypeSelectItem.addChangedHandler(new ChangedHandler() {
@Override
public void onChanged(ChangedEvent event) {
- populateRelativeDescendantsDropDownMenu(null);
+ populateRelativeDescendantsDropDownMenu(null, null, null);
}
});
@@ -186,6 +186,12 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
descendantTypeSelectItem
.setTooltip("The resource type to search for under the root type defined in the Start Search From selection.");
descendantTypeSelectItem.setShowIfCondition(new ShowIfModeFunction(ResourceSelectionMode.RELATIVE));
+ descendantTypeSelectItem.addChangedHandler(new ChangedHandler() {
+ @Override
+ public void onChanged(ChangedEvent event) {
+ setOperationDropDownMenuValues(Integer.valueOf(event.getItem().getValue().toString()), null, null);
+ }
+ });
descendantNameTextItem = new TextItem("descendantNameTextItem");
descendantNameTextItem.setStartRow(false);
@@ -229,7 +235,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
descendantTypeSelectItem.clearValue();
descendantNameTextItem.clearValue();
hideOperationDropDownMenu();
- populateRelativeDropDownMenus(null, null);
+ populateRelativeDropDownMenus(null, null, null, null);
break;
}
}
@@ -260,7 +266,8 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
break;
}
case RELATIVE: {
- populateRelativeDropDownMenus(notifInfo.getAncestorTypeId(), notifInfo.getDescendantTypeId());
+ populateRelativeDropDownMenus(notifInfo.getAncestorTypeId(), notifInfo.getDescendantTypeId(), notifInfo
+ .getOperationId(), notifInfo.getOperationArguments());
if (notifInfo.getDescendantName() != null) {
descendantNameTextItem.setValue(notifInfo.getDescendantName());
}
@@ -274,7 +281,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
}
private void populateRelativeDropDownMenus(final Integer selectedResourceTypeId,
- final Integer descendantResourceTypeId) {
+ final Integer descendantResourceTypeId, final Integer selectedOpId, final Configuration opArgs) {
if (ancestorTypeSelectItem.getValue() == null) {
AsyncCallback<ArrayList<ResourceType>> callback = new AsyncCallback<ArrayList<ResourceType>>() {
@@ -290,7 +297,7 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
} else {
ancestorTypeSelectItem.setValue(String.valueOf(results.get(0).getId()));
}
- populateRelativeDescendantsDropDownMenu(descendantResourceTypeId);
+ populateRelativeDescendantsDropDownMenu(descendantResourceTypeId, selectedOpId, opArgs);
}
@Override
@@ -306,10 +313,13 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
GWTServiceLookup.getResourceTypeGWTService().getAllResourceTypeAncestors(this.resourceType.getId(),
callback);
}
+ } else {
+ populateRelativeDescendantsDropDownMenu(descendantResourceTypeId, selectedOpId, opArgs);
}
}
- private void populateRelativeDescendantsDropDownMenu(final Integer selectedDescendantResourceTypeId) {
+ private void populateRelativeDescendantsDropDownMenu(final Integer selectedDescendantResourceTypeId,
+ final Integer selectedOpId, final Configuration opArgs) {
Object rootResourceTypeIdObj = ancestorTypeSelectItem.getValue();
final int rootResourceTypeId;
@@ -331,9 +341,13 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
descendantTypeSelectItem.setValueMap(map);
if (selectedDescendantResourceTypeId != null) {
descendantTypeSelectItem.setValue(selectedDescendantResourceTypeId.toString());
+ setOperationDropDownMenuValues(selectedDescendantResourceTypeId.intValue(), selectedOpId,
+ opArgs);
} else {
descendantTypeSelectItem.setValue(String.valueOf(rootResourceTypeId));
+ setOperationDropDownMenuValues(rootResourceTypeId, selectedOpId, opArgs);
}
+
}
@Override
@@ -394,10 +408,10 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
* If args is non-null (and if opId is non-null), this will pre-populate the argument config editor.
*
* @param resourceTypeId the type whose operation definitions are to be shown in the operation drop down menu
- * @param opId if not-null, the selected operation
+ * @param selectedOpId if not-null, the selected operation
* @param args if not-null (and opId is not null), this will prepopulate the argument config
*/
- private void setOperationDropDownMenuValues(int resourceTypeId, final Integer opId, final Configuration args) {
+ private void setOperationDropDownMenuValues(int resourceTypeId, final Integer selectedOpId, final Configuration args) {
ResourceTypeCriteria criteria = new ResourceTypeCriteria();
criteria.addFilterId(resourceTypeId);
criteria.fetchOperationDefinitions(true);
@@ -423,9 +437,10 @@ public class ResourceOperationNotificationSenderForm extends AbstractNotificatio
}
operationSelectItem.setAttribute(OPERATION_DEFS_ATTRIBUTE, (Object) opDefs);
operationSelectItem.setValueMap(valueMap);
- if (opId != null && opId > 0 && opDefs.containsKey(opId)) {
- operationSelectItem.setValue(String.valueOf(opId));
- showOperationArguments(opDefs.get(opId).getParametersConfigurationDefinition(), args);
+ if (selectedOpId != null && selectedOpId > 0 && opDefs.containsKey(selectedOpId)) {
+ operationSelectItem.setValue(String.valueOf(selectedOpId));
+ showOperationArguments(opDefs.get(selectedOpId).getParametersConfigurationDefinition(),
+ args);
} else {
operationSelectItem.clearValue(); // sets it to the default
hideOperationArguments();
13 years, 8 months
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java | 12 ++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
New commits:
commit 3b9b30f9582b0255ba2425b91dfa60735e8184b1
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Oct 13 14:18:04 2010 -0400
Changes to let selenium locators properly identify the nodes. I'm not
sure why we were passing the "new TreeNode[0]" as a child in the
constructors, it doesn't seem right, does not seem to adversely affect
our tree creation (perhaps it will help?) and removal seems to solve the
selenium issue.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
index 41e70c6..f4b69ae 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/tree/EnhancedTreeNode.java
@@ -27,11 +27,16 @@ import org.rhq.core.domain.util.StringUtils;
*/
public class EnhancedTreeNode extends TreeNode {
public EnhancedTreeNode() {
- this(null);
+ super();
+ // this(null);
}
public EnhancedTreeNode(String name) {
- this(name, new TreeNode[0]);
+ //this(name, new TreeNode[0]);
+ super(name);
+ if (name != null) {
+ setTitle(StringUtils.deCamelCase(name));
+ }
}
public EnhancedTreeNode(String name, TreeNode... children) {
@@ -65,8 +70,7 @@ public class EnhancedTreeNode extends TreeNode {
String className = this.getClass().getName();
String simpleClassName = className.substring(className.lastIndexOf(".") + 1);
innerClassName = simpleClassName.substring(simpleClassName.lastIndexOf("$") + 1);
- }
- catch (RuntimeException e) {
+ } catch (RuntimeException e) {
innerClassName = "EnhancedTreeNode";
}
13 years, 8 months
[rhq] modules/enterprise
by Joseph Marques
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java | 30 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerLocal.java | 25
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/TemporarySessionPasswordGenerator.java | 259 ----------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java | 14
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/TempSessionLoginModule.java | 100 ---
5 files changed, 428 deletions(-)
New commits:
commit 3e90719a317d577fc6fc90c0efae8b840aa8cc99
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Oct 13 11:45:13 2010 -0400
remove legacy TempSessionLoginModule and all related classes
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
index 6359a23..3b125e1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java
@@ -93,11 +93,6 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
private SessionManager sessionManager = SessionManager.getInstance();
/**
- * This is used to generate temporary session passwords and to validate those passwords.
- */
- private TemporarySessionPasswordGenerator m_sessionPasswordGenerator = new TemporarySessionPasswordGenerator();
-
- /**
* @see org.rhq.enterprise.server.auth.SubjectManagerLocal#loadUserConfiguration(Integer)
*/
public Subject loadUserConfiguration(Integer subjectId) {
@@ -253,31 +248,6 @@ public class SubjectManagerBean implements SubjectManagerLocal, SubjectManagerRe
}
/**
- * @see org.rhq.enterprise.server.auth.SubjectManagerLocal#generateTemporarySessionPassword(int)
- */
- public String generateTemporarySessionPassword(int sessionId) {
- return m_sessionPasswordGenerator.generateSessionPassword(sessionId);
- }
-
- /**
- * @see org.rhq.enterprise.server.auth.SubjectManagerLocal#authenticateTemporarySessionPassword(java.lang.String)
- */
- public boolean authenticateTemporarySessionPassword(String password) throws Exception {
- Integer sessionId = m_sessionPasswordGenerator.authenticateSessionPassword(password);
- boolean validPassword = false;
-
- if (sessionId != null) {
- // If the password was valid, sessionId will be the ID to its associated session. We now have to make
- // sure that session is still valid - this just makes sure the session hasn't timed out or was invalidated
- if (sessionManager.getSubject(sessionId.intValue()) != null) {
- validPassword = true;
- }
- }
-
- return validPassword;
- }
-
- /**
* @see org.rhq.enterprise.server.auth.SubjectManagerLocal#login(String, String)
*/
public Subject login(String username, String password) throws LoginException {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerLocal.java
index b4b7d55..d62096b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerLocal.java
@@ -72,31 +72,6 @@ public interface SubjectManagerLocal {
PageList<Subject> findAllSubjects(PageControl pageControl);
/**
- * Generates a one-time temporary session password for the given session. This can be used to authenticate the user
- * of that session for one time and one time only (i.e. to login as the user this temporary password can be used as
- * opposed to the user's real password).
- *
- * <p>Note that this method should only be available on this EJB's local interface.</p>
- *
- * @param sessionId the session to assign a temporary password to
- *
- * @return a temporary password that can be used once to login as the user
- */
- String generateTemporarySessionPassword(int sessionId);
-
- /**
- * Tests the validity of the given session password. Returns <code>true</code> if the password is valid and the
- * session is still valid.
- *
- * @param password a temporary session password that was created by {@link #generateTemporarySessionPassword(int)}.
- *
- * @return <code>true</code> if the given <code>password</code> is valid and its associated session is still valid
- *
- * @throws Exception if the password was valid but its associated session has either timed out or was invalidated
- */
- boolean authenticateTemporarySessionPassword(String password) throws Exception;
-
- /**
* Logs in a user without performing any authentication. This method should be used with care and not available to
* remote clients. Because of the unauthenticated nature of this login, the new login session will have a session
* timeout of only a few seconds. However, if you pass in <code>true</code> for the "reattach", this method will
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/TemporarySessionPasswordGenerator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/TemporarySessionPasswordGenerator.java
deleted file mode 100644
index fc82ce2..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/TemporarySessionPasswordGenerator.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.server.auth;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import org.jboss.security.Util;
-
-/**
- * Provides a random password generator and a storage area that helps temporarily authenticate users even though their
- * true passwords are not known. This is necessary when a scheduled action is triggered and we want to run as the user,
- * but we don't know the user's true password. In other words, these temporary passwords should only be used if we have
- * previously validated the user for a given session ID. Session passwords generated by this object can only be used
- * once, and they must be validated fairly quickly after being generated.
- *
- * <p>This object is thread-safe.</p>
- *
- * @author John Mazzitelli
- */
-public class TemporarySessionPasswordGenerator {
- /**
- * This is a separator character that will appear between the session ID and a random set of characters in a
- * generated session password. This character must NOT be in {@link #SESSION_PASSWORD_PREFIX}.
- */
- private static final char SESSION_PASSWORD_SEPARATOR = '$';
-
- /**
- * A prefix to all generated session passwords; this makes it possible to quickly identify a possible session
- * password. While this doesn't exclusively identify only session passwords, it helps eliminate most passwords from
- * being recognized as a session password. None of the characters in this string will be the same as
- * {@link #SESSION_PASSWORD_SEPARATOR}.
- */
- private static final String SESSION_PASSWORD_PREFIX = "_x|=~";
-
- /**
- * Map keyed on session Integers whose values are Longs indicating when the session's password was created.
- */
- private final Map<Integer, Long> m_sessionPasswordCreationDates;
-
- /**
- * Map keyed on session Integers whose values are the MD5 strings of the generated passwords.
- */
- private final Map<Integer, String> m_sessionPasswordMD5Strings;
-
- /**
- * The amount of milliseconds that a temporary password is guaranteed to remain valid (a password may actually live
- * longer than this, but it is not guaranteed to do so)
- */
- private final int m_timeoutMillis;
-
- /**
- * Constructor for {@link TemporarySessionPasswordGenerator}.
- */
- public TemporarySessionPasswordGenerator() {
- this(60 * 60 * 1000); // be default, give a copious 60 minutes - this is easily enough for what we need to use this class for
- }
-
- /**
- * Constructor for {@link TemporarySessionPasswordGenerator}.
- *
- * @param timeoutMillis the amount of milliseconds that a temporary password is guaranteed to remain valid (a
- * password may actually live longer than this, but it is not guaranteed to do so)
- */
- public TemporarySessionPasswordGenerator(int timeoutMillis) {
- m_sessionPasswordCreationDates = new HashMap<Integer, Long>();
- m_sessionPasswordMD5Strings = new HashMap<Integer, String>();
- m_timeoutMillis = timeoutMillis;
-
- return;
- }
-
- /**
- * Given a session identifier, this will generate a temporary password that can be used to identify the user whose
- * session that is. Use {@link #authenticateSessionPassword(String)} to later check for this password's
- * authenticity. This session password can only be authenticated once.
- *
- * @param sessionId the session of a user who needs a temporary password assigned
- *
- * @return a password that can be used to associate a session with a user
- *
- * @see #authenticateSessionPassword(String)
- */
- public String generateSessionPassword(int sessionId) {
- StringBuffer pwBuf = new StringBuffer(SESSION_PASSWORD_PREFIX);
-
- pwBuf.append(sessionId);
- pwBuf.append(SESSION_PASSWORD_SEPARATOR);
- pwBuf.append(generateRandomPassword());
-
- String pw = pwBuf.toString();
-
- storeSessionPassword(new Integer(sessionId), pw);
-
- return pw;
- }
-
- /**
- * Returns the session's ID if the given session's password was one that was generated by this object. Returns
- * <code>null</code> if the password was invalid and thus the user attempting to log in should be denied access.
- * Once authenticated, the password will no longer be valid and can not be used to validate the session again.
- *
- * @param password the password to test
- *
- * @return session's ID if the session's <code>password</code> was one that was generated by this object; <code>
- * null</code> otherwise
- *
- * @throws IllegalStateException if the password was in a valid format but the password's MD5 does not match; this
- * exception will only be thrown when it looks like someone is trying to hack a
- * session password
- *
- * @see #generateSessionPassword(int)
- */
- public Integer authenticateSessionPassword(String password) throws IllegalStateException {
- int separator = (password != null) ? password.indexOf(SESSION_PASSWORD_SEPARATOR) : -1;
-
- // let's quickly eliminate most passwords
- if ((separator == -1) || !password.startsWith(SESSION_PASSWORD_PREFIX)) {
- return null;
- }
-
- String sessionStr = password.substring(SESSION_PASSWORD_PREFIX.length(), separator);
- Integer sessionId;
-
- try {
- sessionId = new Integer(sessionStr);
- } catch (NumberFormatException e) {
- // kinda looked like our password, but it can't be since this should have been a valid session ID number
- return null;
- }
-
- String passwordMD5 = generateMD5(password);
- String sessionMD5;
-
- synchronized (this) {
- purgeOldSessionPasswords(); // let's do this cleanup now; must do this inside the sychronized block
-
- // we only allow a session password to be authenticated once, so remove all traces of it while retrieving it
- sessionMD5 = m_sessionPasswordMD5Strings.remove(sessionId);
- m_sessionPasswordCreationDates.remove(sessionId);
- }
-
- // the session password was either already authenticated or was removed because it was too old
- if (sessionMD5 == null) {
- return null;
- }
-
- // the password was wrong, if we got this far and the password was wrong, someone is trying to hack
- if (!sessionMD5.equals(passwordMD5)) {
- throw new IllegalStateException(
- "WARNING! A session was attempted to be reattached but the login password was invalid");
- }
-
- return sessionId;
- }
-
- /**
- * Stores the generated session password in our internal data structures so we can authenticate the session using
- * the password.
- *
- * @param sessionId the session identifier
- * @param pw the password to store
- */
- private void storeSessionPassword(Integer sessionId, String pw) {
- synchronized (this) {
- purgeOldSessionPasswords(); // let's do this cleanup now; must do this inside the sychronized block
-
- m_sessionPasswordCreationDates.put(sessionId, new Long(System.currentTimeMillis()));
- m_sessionPasswordMD5Strings.put(sessionId, generateMD5(pw));
- }
-
- return;
- }
-
- /**
- * Looks at the current set of session passwords and removes those that are old. Not sure why these passwords would
- * be hanging around, since usually generated session passwords are authenticated fairly quickly thereafter. But
- * just in case something went wrong between the time the password was generated and the time it was to be
- * authenticated, this method is used to clean up.
- *
- * <p>To avoid having to enter another synchronized block and again attempt to aquire a lock, make sure you call
- * this method from within a sychronized block - this method requires "this" object's lock.</p>
- */
- private void purgeOldSessionPasswords() {
- long earliestAllowed = System.currentTimeMillis() - m_timeoutMillis;
- List<Integer> doomedSessions = new ArrayList<Integer>();
-
- for (Map.Entry<Integer, Long> entry : m_sessionPasswordCreationDates.entrySet()) {
- Long creationTime = entry.getValue();
-
- if (creationTime.longValue() < earliestAllowed) {
- doomedSessions.add(entry.getKey());
- }
- }
-
- for (Integer doomedSession : doomedSessions) {
- m_sessionPasswordCreationDates.remove(doomedSession);
- m_sessionPasswordMD5Strings.remove(doomedSession);
- }
-
- return;
- }
-
- /**
- * Generates a random password that will be used as part of the session password.
- *
- * @return a random password
- */
- private String generateRandomPassword() {
- // generate a random password - this will usually be used as part of a Basic Authentication to our WebDAV server
- // make sure these can be encoded in a URL (no + signs - don't ask - see UrlUtil.encodeMore)
- // make sure SESSION_PASSWORD_SEPARATOR character is NOT in the chars variable!
- StringBuffer password = new StringBuffer();
- String chars = "0a3X1bWd-2VeU*fTgH7sGtF6YS^KpJqI4rh7RiQj_5P.kOZlNm|0Mn~Lou!9EvD4wACxB8yz";
- Random random = new Random(System.currentTimeMillis());
- int passwordLength = 0;
-
- while (passwordLength < 64) {
- passwordLength = random.nextInt(129);
- }
-
- random = new Random(System.currentTimeMillis() + passwordLength);
-
- for (int i = 0; i < passwordLength; i++) {
- password.append(chars.charAt(random.nextInt(chars.length())));
- }
-
- return password.toString();
- }
-
- /**
- * Given a password string, this will return its MD5.
- *
- * @param password the string whose MD5 is to be calculated
- *
- * @return the MD5 string
- */
- private String generateMD5(String password) {
- return Util.createPasswordHash("MD5", "base64", null, null, password);
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
index caec439..7787dba 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
@@ -113,20 +113,6 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM
this.log.info("Enabling RHQ JDBC JAAS Provider");
configEntries.add(ace);
- /*
- * NOT USED ANYMORE
- // to support the need for authenticating temporary session passwords, add a login module that can do that
- // we set an empty set of config options, but if we need to, we can store the config items
- // in the RHQ_config_props table, which would allow the GUI to modify them (just in case we want to add that capability)
- // the "conf" Properties value has all RHQ_config_props values, so we have that now
- // for now, there are no config properties we need in this login module, so just create an empty map
- ace = new AppConfigurationEntry(TempSessionLoginModule.class.getName(),
- AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT, new HashMap<String, String>());
- this.log.info("Enabled the temporary session login module");
- configEntries.add(ace);
- *
- */
-
String provider = conf.getProperty(RHQConstants.JAASProvider);
if ((provider != null) && provider.equals(RHQConstants.LDAPJAASProvider)) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/TempSessionLoginModule.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/TempSessionLoginModule.java
deleted file mode 100644
index a58f275..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/TempSessionLoginModule.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.server.core.jaas;
-
-import java.security.acl.Group;
-import java.util.Map;
-import javax.security.auth.Subject;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.login.LoginException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.security.SimpleGroup;
-import org.jboss.security.auth.spi.UsernamePasswordLoginModule;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-/**
- * A "special" JAAS login module that checks to see if the password is a valid temporary session password. If it is, the
- * user is authenticated; if not, the user is denied access.
- *
- * <p>This is used mainly to support the use-case where a server component needs to submit a request that needs to again
- * be authenticated. In this case, the server doesn't know the user's true password; instead a temporary session
- * password was created for the user.
- *
- * @author John Mazzitelli
- */
-public class TempSessionLoginModule extends UsernamePasswordLoginModule {
- /**
- * Logger
- */
- private static final Log LOG = LogFactory.getLog(TempSessionLoginModule.class);
-
- /**
- * A place where this login module can initialize itself.
- *
- * @param theSubject
- * @param theHandler
- * @param theSharedState
- * @param theOptions
- */
- public void initialize(Subject theSubject, CallbackHandler theHandler, Map theSharedState, Map theOptions) {
- super.initialize(theSubject, theHandler, theSharedState, theOptions);
- }
-
- /**
- * We don't know the user's true password, so we don't know the expected password; therefore, this returns an empty
- * string. This class overrides {@link #validatePassword(String, String)} so it can validate on the input password
- * that was entered by the client, since it is all we need to check validity.
- *
- * @return empty string
- */
- protected String getUsersPassword() {
- return "";
- }
-
- /**
- * Authenticates the user by seeing if the <code>inputPassword</code> is a valid temporary session password. <code>
- * expectedPassword</code> is ignored.
- *
- * @see UsernamePasswordLoginModule#validatePassword(String, String)
- */
- protected boolean validatePassword(String inputPassword, String expectedPassword) {
- boolean validPassword = false;
-
- // call into the JON authentication subsystem to see if the input password was valid.
- try {
- validPassword = LookupUtil.getSubjectManager().authenticateTemporarySessionPassword(inputPassword);
- } catch (Exception e) {
- LOG.error("Failed to authenticate a session password for user [" + getUsername() + "]", e);
- }
-
- return validPassword;
- }
-
- /**
- * @see org.jboss.security.auth.spi.AbstractServerLoginModule#getRoleSets()
- */
- protected Group[] getRoleSets() throws LoginException {
- SimpleGroup roles = new SimpleGroup("Roles");
-
- //roles.addMember( new SimplePrincipal( "some role" ) );
-
- return new Group[] { roles };
- }
-}
\ No newline at end of file
13 years, 8 months
[rhq] modules/enterprise
by Joseph Marques
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java | 1 +
1 file changed, 1 insertion(+)
New commits:
commit fa51b77cce5f9e3d5af5d72099d93fa7c9efc0c2
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Oct 13 10:31:09 2010 -0400
don't show id fields in grids
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
index eb7175b..7c6aaf9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceSearchView.java
@@ -105,6 +105,7 @@ public class ResourceSearchView extends Table {
protected void configureTable() {
ListGridField idField = new ListGridField("id", "Id", 55);
idField.setType(ListGridFieldType.INTEGER);
+ idField.setHidden(true);
ListGridField iconField = new ListGridField("icon", "", 40);
ListGridField nameField = new ListGridField(NAME.propertyName(), NAME.title(), 250);
nameField.setCellFormatter(new CellFormatter() {
13 years, 8 months
[rhq] Branch 'gwt-ldap' - modules/enterprise
by Simeon Pinder
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AuthorizationGWTService.java | 9 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java | 55 ++++++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java | 16 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java | 1
7 files changed, 73 insertions(+), 13 deletions(-)
New commits:
commit d44ae2f95128ade4a1081e11e61a927e548f6746
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Wed Oct 13 08:52:39 2010 -0400
fix for manage inventory permissions warnings with discovery queue
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
index 062b882..b5e820e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/queue/AutodiscoveryPortlet.java
@@ -64,7 +64,7 @@ public class AutodiscoveryPortlet extends ResourceAutodiscoveryView implements C
protected void onInit() {
super.onInit();
//initialize the datasource to include Portlet instance
- this.dataSource = new AutodiscoveryQueueDataSource();
+ this.dataSource = new AutodiscoveryQueueDataSource(getTreeGrid());
if ((getTreeGrid() != null) && (getDataSource() != null)) {
getTreeGrid().setDataSource(getDataSource());
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AuthorizationGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AuthorizationGWTService.java
index 5beb2b6..58bae69 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AuthorizationGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AuthorizationGWTService.java
@@ -22,7 +22,6 @@ import java.util.Set;
import com.google.gwt.user.client.rpc.RemoteService;
-import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
/**
@@ -66,7 +65,6 @@ public interface AuthorizationGWTService extends RemoteService {
*/
Set<Permission> getImplicitGroupPermissions(int groupId);
-
/**
* Gets the set of global permissions that the current user explicitly possesses.
*
@@ -74,6 +72,11 @@ public interface AuthorizationGWTService extends RemoteService {
*/
Set<Permission> getExplicitGlobalPermissions();
-
+ /**
+ * Lightweight check of whether current user has manage inventory permissions.
+ *
+ * @return Boolean answer to manage inventory permissions status.
+ */
+ Boolean checkUserGlobalPermission(Permission permission);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
index ab4ae27..c1ad38b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
@@ -72,4 +72,5 @@ public interface ResourceGWTService extends RemoteService {
List<ResourceError> findResourceErrors(int resourceId);
Resource manuallyAddResource(int resourceTypeId, int parentResourceId, Configuration pluginConfiguration);
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
index a881444..a947c57 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
@@ -24,6 +24,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -31,14 +32,17 @@ import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
+import com.smartgwt.client.widgets.tree.TreeGrid;
import com.smartgwt.client.widgets.tree.TreeNode;
+import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.AuthorizationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
@@ -50,6 +54,11 @@ public class AutodiscoveryQueueDataSource extends DataSource {
private int unlimited = -1;
private int maximumPlatformsToDisplay = -1;
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
+ private AuthorizationGWTServiceAsync authorizationService = GWTServiceLookup.getAuthorizationService();
+ public static final String NO_MANAGE_INVENTORY_PERMS_EMPTY_MESSAGE = "(Required manage inventory permissions missing. See Administrator to change)";
+ public static final String EMPTY_MESSAGE = "No items to show";
+ private TreeGrid dataContainerReference = null;
+ private static final Permission MANAGE_INVENTORY = Permission.MANAGE_INVENTORY;
public AutodiscoveryQueueDataSource() {
setClientOnly(false);
@@ -78,6 +87,11 @@ public class AutodiscoveryQueueDataSource extends DataSource {
statusField, timestampField);
}
+ public AutodiscoveryQueueDataSource(TreeGrid treeGrid) {
+ this();
+ this.dataContainerReference = treeGrid;
+ }
+
protected Object transformRequest(DSRequest request) {
DSResponse response = new DSResponse();
response.setAttribute("clientContext", request.getAttributeAsObject("clientContext"));
@@ -95,9 +109,9 @@ public class AutodiscoveryQueueDataSource extends DataSource {
}
protected void executeFetch(final DSRequest request, final DSResponse response) {
- PageControl pc = getPageControl(request);
+ final PageControl pc = getPageControl(request);
- HashSet<InventoryStatus> statuses = new HashSet<InventoryStatus>();
+ final HashSet<InventoryStatus> statuses = new HashSet<InventoryStatus>();
String statusesString = request.getCriteria().getAttributeAsString("statuses");
if (statusesString != null) {
@@ -113,16 +127,41 @@ public class AutodiscoveryQueueDataSource extends DataSource {
statuses.add(InventoryStatus.NEW);
}
- resourceService.getQueuedPlatformsAndServers(statuses, pc, new AsyncCallback<Map<Resource, List<Resource>>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load inventory discovery queue", caught);
+ //determine if has manage inventory perms, if so then chain and proceed with getting discovered resources
+ authorizationService.checkUserGlobalPermission(MANAGE_INVENTORY, new AsyncCallback<Boolean>() {
+ public void onSuccess(Boolean hasManageInventoryPermissions) {
+ if (hasManageInventoryPermissions) {
+ if (dataContainerReference != null) {
+ dataContainerReference.setEmptyMessage(EMPTY_MESSAGE);
+ }
+ resourceService.getQueuedPlatformsAndServers(statuses, pc,
+ new AsyncCallback<Map<Resource, List<Resource>>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load inventory discovery queue",
+ caught);
+ }
+
+ public void onSuccess(Map<Resource, List<Resource>> result) {
+ response.setData(buildNodes(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ } else {
+ Log.debug("(User does not have required managed inventory permissions. " + EMPTY_MESSAGE);
+ response.setTotalRows(0);
+ if (dataContainerReference != null) {
+ Log.debug("Setting better empty container message." + NO_MANAGE_INVENTORY_PERMS_EMPTY_MESSAGE);
+ dataContainerReference.setEmptyMessage(NO_MANAGE_INVENTORY_PERMS_EMPTY_MESSAGE);
+ }
+ processResponse(request.getRequestId(), response);
+ }
}
- public void onSuccess(Map<Resource, List<Resource>> result) {
- response.setData(buildNodes(result));
- processResponse(request.getRequestId(), response);
+ public void onFailure(Throwable caught) {
+ Log.error("Unable to determine whether if user has manage inventory permissions - check server logs.");
}
});
+
}
private TreeNode[] buildNodes(Map<Resource, List<Resource>> result) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
index e1ea25e..1fee831 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
@@ -121,7 +121,7 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
treeGrid.setHeight100();
- treeGrid.setDataSource(dataSource = new AutodiscoveryQueueDataSource());
+ treeGrid.setDataSource(dataSource = new AutodiscoveryQueueDataSource(treeGrid));
treeGrid.setAutoFetchData(true);
treeGrid.setResizeFieldsInRealTime(true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java
index 4b8d73f..7a13a94 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AuthorizationGWTServiceImpl.java
@@ -82,4 +82,20 @@ public class AuthorizationGWTServiceImpl extends AbstractGWTServiceImpl implemen
throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
}
+
+ /** Lightweight check of whether user has requested permission.
+ *
+ * @return Boolean data point.
+ */
+ public Boolean checkUserGlobalPermission(Permission permission) {
+ Boolean accessGranted = false;
+ try {
+ Set<Permission> globalPermissions = authorizationManager.getExplicitGlobalPermissions(getSessionSubject());
+ accessGranted = globalPermissions.contains(permission);
+ return accessGranted;
+ } catch (Exception e) {
+ throw new RuntimeException(ThrowableUtil.getAllMessages(e));
+ }
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
index 861fe72..dac630f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -297,4 +297,5 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
throw new RuntimeException(ThrowableUtil.getAllMessages(e));
}
}
+
}
13 years, 8 months