[rhq] modules/enterprise
by Joseph Marques
modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/list.xhtml | 2 --
1 file changed, 2 deletions(-)
New commits:
commit dbd83ebec16eafff8561e524cd089998c98ba356
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 15:08:41 2010 -0400
fix sorting bug on the group definitions list page
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/list.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/list.xhtml
index 41f8728..61f9d89 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/list.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/definition/group/list.xhtml
@@ -26,8 +26,6 @@
<ui:define name="content">
<h:form id="groupDefinitionsListForm">
- <input type="hidden" name="id" value="${param.id}"/>
-
<h:panelGrid columns="1" styleClass="data-table">
<ui:param name="groupDefinitionsDataModel" value="#{ListGroupDefinitionsUIBean.dataModel}"/>
14 years, 1 month
[rhq] modules/enterprise
by Joseph Marques
modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 051595ca85f346a5f4f673632b2be17c62c2af25
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 13:23:22 2010 -0400
suppress debugging statement
diff --git a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
index 4fa879e..6816a1e 100644
--- a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
+++ b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
@@ -75,7 +75,7 @@ tokens {
*/
searchExpression
- : conditionalExpression { System.out.println($conditionalExpression.tree.toStringTree()); }
+ : conditionalExpression { /* System.out.println($conditionalExpression.tree.toStringTree()); */ }
;
conditionalExpression
14 years, 1 month
[rhq] modules/enterprise
by Joseph Marques
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java | 9 ++++
modules/enterprise/server/plugins/alert-operations/src/main/java/org/rhq/enterprise/server/plugins/alertOperations/OperationsBackingBean.java | 21 +++++++++-
3 files changed, 30 insertions(+), 2 deletions(-)
New commits:
commit b3751bd05aca5af3d7fdf12971953231ffe491ac
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 13:03:37 2010 -0400
if possible, use the resource-specific ancestry to populate relative resource drop-down
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
index eb7d500..64bf25a 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
@@ -77,6 +77,8 @@ public class CustomContentUIBean extends EnterpriseFacesContextUIBean {
customBackingBean.setWebUser(getSubject());
customBackingBean.setContext(FacesContextUtility.getRequiredRequestParameter("context"));
customBackingBean.setContextId(FacesContextUtility.getRequiredRequestParameter("contextId"));
+ customBackingBean.setContextSubId(FacesContextUtility.getOptionalRequestParameter("contextSubId",
+ (String) null));
customBackingBean.loadView();
outjectBean(backingBeanName, customBackingBean);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
index 2f8b323..848765f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/alert/CustomAlertSenderBackingBean.java
@@ -36,6 +36,7 @@ public class CustomAlertSenderBackingBean {
protected Subject webUser;
protected String context;
protected String contextId;
+ protected String contextSubId;
public Configuration getAlertParameters() {
return alertParameters;
@@ -69,6 +70,14 @@ public class CustomAlertSenderBackingBean {
this.contextId = contextId;
}
+ public String getContextSubId() {
+ return contextSubId;
+ }
+
+ public void setContextSubId(String contextSubId) {
+ this.contextSubId = contextSubId;
+ }
+
public void loadView() {
}
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
index 7fd8cc1..2880800 100644
--- 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
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.server.plugins.alertOperations;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
@@ -100,8 +101,24 @@ public class OperationsBackingBean extends CustomAlertSenderBackingBean {
descendantTypeId = get(OperationInfo.Constants.RELATIVE_DESCENDANT_TYPE_ID, "none");
ResourceType contextType = computeResourceTypeFromContext(); // should not be null
- List<ResourceType> ancestors = LookupUtil.getResourceTypeManager().getResourceTypeAncestorsWithOperations(
- getOverlord(), contextType.getId());
+ 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
+ ancestors = LookupUtil.getResourceTypeManager().getResourceTypeAncestorsWithOperations(getOverlord(),
+ contextType.getId());
+ }
load(ancestorTypeOptions, ancestors);
if (ancestorTypeId.equals("none") == false) {
14 years, 1 month
[rhq] modules/core
by mazz
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 32 ++++++----
1 file changed, 22 insertions(+), 10 deletions(-)
New commits:
commit 901a44092dd5031653ac056bd9fd925dc97ab43e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Apr 21 13:36:48 2010 -0400
bz535436 - removed all usages of collection.toArray in InventoryManager to avoid concurrency bug.
now using synchronized block that should protect against this.
(cherry picked from commit ac4460c69494fc6720de5d9ba03af5c6b89ed989)
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
index f4785f8..8b6cf68 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -1821,7 +1821,9 @@ public class InventoryManager extends AgentService implements ContainerService,
* @param listener instance to notify of change events
*/
public void addInventoryEventListener(InventoryEventListener listener) {
- this.inventoryEventListeners.add(listener);
+ synchronized (this.inventoryEventListeners) {
+ this.inventoryEventListeners.add(listener);
+ }
}
/**
@@ -1830,7 +1832,21 @@ public class InventoryManager extends AgentService implements ContainerService,
* @param listener instance to remove from event notification
*/
public void removeInventoryEventListener(InventoryEventListener listener) {
- this.inventoryEventListeners.remove(listener);
+ synchronized (this.inventoryEventListeners) {
+ this.inventoryEventListeners.remove(listener);
+ }
+ }
+
+ /**
+ * Always use this before accessing the event listeners because this ensures
+ * thread safety.
+ *
+ * @return all inventory event listeners
+ */
+ private Set<InventoryEventListener> getInventoryEventListeners() {
+ synchronized (this.inventoryEventListeners) {
+ return new HashSet<InventoryEventListener>(this.inventoryEventListeners);
+ }
}
/**
@@ -1844,8 +1860,7 @@ public class InventoryManager extends AgentService implements ContainerService,
return;
}
- InventoryEventListener[] iteratorSafeListeners = new InventoryEventListener[inventoryEventListeners.size()];
- iteratorSafeListeners = inventoryEventListeners.toArray(iteratorSafeListeners);
+ Set<InventoryEventListener> iteratorSafeListeners = getInventoryEventListeners();
for (InventoryEventListener listener : iteratorSafeListeners) {
// Catch anything to make sure we don't stop firing to other listeners
try {
@@ -1868,8 +1883,7 @@ public class InventoryManager extends AgentService implements ContainerService,
log.debug("Firing activated for resource: " + resource);
}
- InventoryEventListener[] iteratorSafeListeners = new InventoryEventListener[inventoryEventListeners.size()];
- iteratorSafeListeners = inventoryEventListeners.toArray(iteratorSafeListeners);
+ Set<InventoryEventListener> iteratorSafeListeners = getInventoryEventListeners();
for (InventoryEventListener listener : iteratorSafeListeners) {
// Catch anything to make sure we don't stop firing to other listeners
try {
@@ -1893,8 +1907,7 @@ public class InventoryManager extends AgentService implements ContainerService,
log.debug("Firing deactivated for resource: " + resource);
}
- InventoryEventListener[] iteratorSafeListeners = new InventoryEventListener[inventoryEventListeners.size()];
- iteratorSafeListeners = inventoryEventListeners.toArray(iteratorSafeListeners);
+ Set<InventoryEventListener> iteratorSafeListeners = getInventoryEventListeners();
for (InventoryEventListener listener : iteratorSafeListeners) {
// Catch anything to make sure we don't stop firing to other listeners
try {
@@ -1917,8 +1930,7 @@ public class InventoryManager extends AgentService implements ContainerService,
return;
}
- InventoryEventListener[] iteratorSafeListeners = new InventoryEventListener[inventoryEventListeners.size()];
- iteratorSafeListeners = inventoryEventListeners.toArray(iteratorSafeListeners);
+ Set<InventoryEventListener> iteratorSafeListeners = getInventoryEventListeners();
for (InventoryEventListener listener : iteratorSafeListeners) {
// Catch anything to make sure we don't stop firing to other listeners
try {
14 years, 1 month
[rhq] modules/enterprise
by Simeon Pinder
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java | 111 ++++
modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp | 2
modules/enterprise/gui/portal-war/src/main/webapp/admin/role/RoleLdapGroupsForm.jsp | 263 ++++++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java | 2
4 files changed, 372 insertions(+), 6 deletions(-)
New commits:
commit bdbc5d990cd959005e9a7355fc1ba5c1296187d7
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Apr 27 12:49:48 2010 -0400
BZ 584994:i)pagination fix ii)added ldapgroupform iii)cache ldap group list
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
index bd38c20..39fe62e 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java
@@ -19,11 +19,14 @@
package org.rhq.enterprise.gui.admin.role;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.NavigableSet;
import java.util.Properties;
import java.util.Set;
+import java.util.TreeMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -43,6 +46,7 @@ import org.rhq.core.domain.authz.Role;
import org.rhq.core.domain.resource.group.LdapGroup;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.legacy.Constants;
import org.rhq.enterprise.gui.legacy.util.RequestUtils;
import org.rhq.enterprise.gui.legacy.util.SessionUtils;
@@ -59,6 +63,8 @@ import org.rhq.enterprise.server.util.LookupUtil;
* An Action that retrieves data to facilitate display of the form for adding groups to a role.
*/
public class AddLdapGroupsFormPrepareAction extends TilesAction {
+ final String LDAP_GROUP_CACHE = "ldapGroupCache";
+
public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
Log log = LogFactory.getLog(AddLdapGroupsFormPrepareAction.class.getName());
@@ -76,6 +82,9 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
RequestUtils.setError(request, Constants.ERR_ROLE_NOT_FOUND);
return null;
}
+ //use cached LDAP group list to avoid hitting ldap server each time ui pref changed.
+ Set<Map<String, String>> cachedAvailableLdapGroups = null;
+ cachedAvailableLdapGroups = (Set<Map<String, String>>) request.getSession().getAttribute(LDAP_GROUP_CACHE);
addForm.setR(role.getId());
@@ -93,21 +102,31 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
PageList<Map<String, String>> pendingGroups = new PageList<Map<String, String>>(pendingSet, 0, pcp);
PageList<Map<String, String>> availableGroups = new PageList<Map<String, String>>(availableGroupsSet, 0, pca);
/* pending groups are those on the right side of the "add
- * to list" widget- awaiting association with the rolewhen the form's "ok" button is clicked. */
+ * to list" widget- awaiting association with the role when the form's "ok" button is clicked. */
pendingGroupIds = SessionUtils.getListAsListStr(request.getSession(), Constants.PENDING_RESGRPS_SES_ATTR);
log.trace("getting pending groups for role [" + roleId + ")");
String name = "foo";
try { //defend against ldap communication runtime difficulties.
- allGroups = LdapGroupManager.getInstance().findAvailableGroups();
- RoleManagerLocal roleManager = LookupUtil.getRoleManager();
+ if (cachedAvailableLdapGroups == null) {
+ allGroups = LdapGroupManager.getInstance().findAvailableGroups();
+ } else {//reuse cached.
+ allGroups = cachedAvailableLdapGroups;
+ }
+ //store unmodified list in session.
+ cachedAvailableLdapGroups = allGroups;
+
+ RoleManagerLocal roleManager = LookupUtil.getRoleManager();
+ //retrieve currently assigned groups
assignedList = roleManager.findLdapGroupsByRole(role.getId(), PageControl.getUnlimitedInstance());
+ //trim already defined from all groups returned.
allGroups = filterExisting(assignedList, allGroups);
Set<String> pendingIds = new HashSet<String>(pendingGroupIds);
+ //retrieve pending information
pendingSet = findPendingGroups(pendingIds, allGroups);
pendingGroups = new PageList<Map<String, String>>(pendingSet, pendingSet.size(), pcp);
@@ -118,6 +137,86 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
availableGroupsSet = findAvailableGroups(pendingIds, allGroups);
availableGroups = new PageList<Map<String, String>>(availableGroupsSet, availableGroupsSet.size(), pca);
+
+ //We cannot reuse the PageControl mechanism as there are no database calls to retrieve list
+ // must replicate paging using existing web params, formula etc.
+
+ //determine count to return up to 15|30|45 and page index
+ int returnAmount = pca.getPageSize();
+ int returnIndex = pca.getPageNumber();
+
+ //determine sort order
+ PageOrdering sortOrder = pca.getPrimarySortOrder();
+ if (sortOrder == null) {
+ sortOrder = PageOrdering.ASC;
+ pca.setPrimarySortOrder(sortOrder);//reset on pc
+ }
+
+ //determine which column to sort on
+ String sortColumn = pca.getPrimarySortColumn();
+ if (sortColumn == null) {
+ sortColumn = "lg.name";
+ pca.setPrimarySort(sortColumn, sortOrder);//reset on pc
+ }
+
+ //now sort based off these values and populate sizedAvailableGroups accordingly
+ ArrayList<Map<String, String>> groupsValues = availableGroups.getValues();
+
+ //store maps based off the keys and sort()
+ Map<Integer, Map> groupLookup = new HashMap<Integer, Map>();
+ TreeMap<String, Integer> groupNames = new TreeMap<String, Integer>();
+ TreeMap<String, Integer> groupDescriptions = new TreeMap<String, Integer>();
+ for (int i = 0; i < groupsValues.size(); i++) {
+ Map<String, String> entry = groupsValues.get(i);
+ Integer key = Integer.valueOf(i);
+ groupLookup.put(key, entry);
+ groupNames.put(entry.get("name"), key);
+ groupDescriptions.put(entry.get("description"), key);
+ }
+
+ //do calculations to determine how many sorted values to return.
+ int start, end;
+ start = (int) (returnIndex * returnAmount);
+ end = start + returnAmount;
+ PageList<Map<String, String>> sizedAvailableGroups = new PageList<Map<String, String>>();
+
+ //detect sort order
+ boolean descending = false;
+ if (sortOrder.DESC == sortOrder) {
+ descending = true;
+ }
+ //use sort column to determine which list to use
+ if (sortColumn.equalsIgnoreCase("lg.name")) {
+ int i = 0;
+ NavigableSet<String> keyList = groupNames.navigableKeySet();
+ if (descending) {
+ keyList = groupNames.descendingKeySet();
+ }
+ for (String key : keyList) {
+ if ((i >= start) && (i < end)) {
+ sizedAvailableGroups.add(groupLookup.get(groupNames.get(key)));
+ }
+ i++;
+ }
+ } else {
+ int i = 0;
+ NavigableSet<String> keyList = groupDescriptions.navigableKeySet();
+ if (descending) {
+ keyList = groupNames.descendingKeySet();
+ }
+ for (String key : keyList) {
+ if ((i >= start) && (i < end)) {
+ sizedAvailableGroups.add(groupLookup.get(groupDescriptions.get(key)));
+ }
+ i++;
+ }
+ }
+ //make sizedAvailableGroup the new reference to return.
+ availableGroups = sizedAvailableGroups;
+ //populate pagination elements for loaded elements.
+ availableGroups.setTotalSize(groupLookup.size());
+ availableGroups.setPageControl(pca);
+
} catch (LdapFilterException lce) {
ActionMessages actionMessages = new ActionMessages();
actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("admin.role.LdapGroupFilterMessage"));
@@ -136,7 +235,9 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
request.setAttribute(Constants.PENDING_RESGRPS_ATTR, pendingGroups);
request.setAttribute(Constants.NUM_PENDING_RESGRPS_ATTR, new Integer(pendingGroups.getTotalSize()));
request.setAttribute(Constants.AVAIL_RESGRPS_ATTR, availableGroups);
- request.setAttribute(Constants.NUM_AVAIL_RESGRPS_ATTR, new Integer(availableGroups.getTotalSize()));
+ request.setAttribute(Constants.NUM_AVAIL_RESGRPS_ATTR, new Integer(allGroups.size()));
+ //store cachedAvailableGroups in session so trim down ldap communication chatter.
+ request.getSession().setAttribute(LDAP_GROUP_CACHE, cachedAvailableLdapGroups);
return null;
}
@@ -175,4 +276,4 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
}
return ret;
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp
index 93ec22e..4341a5e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp
@@ -13,7 +13,7 @@
<tiles:insert definition=".portlet.error"/>
-<tiles:insert page="/admin/role/RoleGroupsForm.jsp">
+<tiles:insert page="/admin/role/RoleLdapGroupsForm.jsp">
<tiles:put name="availableResGrps" beanName="AvailableResGrps"/>
<tiles:put name="numAvailableResGrps" beanName="NumAvailableResGrps"/>
<tiles:put name="pendingResGrps" beanName="PendingResGrps"/>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/RoleLdapGroupsForm.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/RoleLdapGroupsForm.jsp
new file mode 100644
index 0000000..2880f22
--- /dev/null
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/RoleLdapGroupsForm.jsp
@@ -0,0 +1,263 @@
+<%@ page language="java" %>
+<%@ page errorPage="/common/Error.jsp" %>
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" prefix="html" %>
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="/WEB-INF/tld/display.tld" prefix="display" %>
+
+<tiles:importAttribute name="availableResGrps"/>
+<tiles:importAttribute name="numAvailableResGrps"/>
+<tiles:importAttribute name="pendingResGrps"/>
+<tiles:importAttribute name="numPendingResGrps"/>
+
+<script language="JavaScript" src="<html:rewrite page="/js/addRemoveWidget.js"/>" type="text/javascript"></script>
+<c:set var="widgetInstanceName" value="addGroups"/>
+
+<script type="text/javascript">
+var pageData = new Array();
+initializeWidgetProperties('<c:out value="${widgetInstanceName}"/>');
+widgetProperties = getWidgetProperties('<c:out value="${widgetInstanceName}"/>');
+</script>
+
+<c:url var="selfPnaAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.psa}">
+ <c:param name="psa" value="${param.psa}"/>
+ </c:if>
+ <c:if test="${not empty param.soa}">
+ <c:param name="soa" value="${param.soa}"/>
+ </c:if>
+ <c:if test="${not empty param.sca}">
+ <c:param name="sca" value="${param.sca}"/>
+ </c:if>
+ <c:if test="${not empty param.psp}">
+ <c:param name="psp" value="${param.psp}"/>
+ </c:if>
+ <c:if test="${not empty param.pnp}">
+ <c:param name="pnp" value="${param.pnp}"/>
+ </c:if>
+ <c:if test="${not empty param.sop}">
+ <c:param name="sop" value="${param.sop}"/>
+ </c:if>
+ <c:if test="${not empty param.scp}">
+ <c:param name="scp" value="${param.scp}"/>
+ </c:if>
+</c:url>
+
+<c:url var="selfPnpAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.psa}">
+ <c:param name="psa" value="${param.psa}"/>
+ </c:if>
+ <c:if test="${not empty param.pna}">
+ <c:param name="pna" value="${param.pna}"/>
+ </c:if>
+ <c:if test="${not empty param.soa}">
+ <c:param name="soa" value="${param.soa}"/>
+ </c:if>
+ <c:if test="${not empty param.sca}">
+ <c:param name="sca" value="${param.sca}"/>
+ </c:if>
+ <c:if test="${not empty param.psp}">
+ <c:param name="psp" value="${param.psp}"/>
+ </c:if>
+ <c:if test="${not empty param.sop}">
+ <c:param name="sop" value="${param.sop}"/>
+ </c:if>
+ <c:if test="${not empty param.scp}">
+ <c:param name="scp" value="${param.scp}"/>
+ </c:if>
+</c:url>
+
+<c:url var="selfPsaAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.pna}">
+ <c:param name="pna" value="${param.pna}"/>
+ </c:if>
+ <c:if test="${not empty param.soa}">
+ <c:param name="soa" value="${param.soa}"/>
+ </c:if>
+ <c:if test="${not empty param.sca}">
+ <c:param name="sca" value="${param.sca}"/>
+ </c:if>
+ <c:if test="${not empty param.pnp}">
+ <c:param name="pnp" value="${param.pnp}"/>
+ </c:if>
+ <c:if test="${not empty param.psp}">
+ <c:param name="psp" value="${param.psp}"/>
+ </c:if>
+ <c:if test="${not empty param.sop}">
+ <c:param name="sop" value="${param.sop}"/>
+ </c:if>
+ <c:if test="${not empty param.scp}">
+ <c:param name="scp" value="${param.scp}"/>
+ </c:if>
+</c:url>
+
+
+<c:url var="selfPspAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.pna}">
+ <c:param name="pna" value="${param.pna}"/>
+ </c:if>
+ <c:if test="${not empty param.psa}">
+ <c:param name="psa" value="${param.psa}"/>
+ </c:if>
+ <c:if test="${not empty param.soa}">
+ <c:param name="soa" value="${param.soa}"/>
+ </c:if>
+ <c:if test="${not empty param.sca}">
+ <c:param name="sca" value="${param.sca}"/>
+ </c:if>
+ <c:if test="${not empty param.pnp}">
+ <c:param name="pnp" value="${param.pnp}"/>
+ </c:if>
+ <c:if test="${not empty param.sop}">
+ <c:param name="sop" value="${param.sop}"/>
+ </c:if>
+ <c:if test="${not empty param.scp}">
+ <c:param name="scp" value="${param.scp}"/>
+ </c:if>
+</c:url>
+
+<c:url var="selfPaAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.pna}">
+ <c:param name="pna" value="${param.pna}"/>
+ </c:if>
+ <c:if test="${not empty param.psa}">
+ <c:param name="psa" value="${param.psa}"/>
+ </c:if>
+ <c:if test="${not empty param.pnp}">
+ <c:param name="pnp" value="${param.pnp}"/>
+ </c:if>
+ <c:if test="${not empty param.psp}">
+ <c:param name="psp" value="${param.psp}"/>
+ </c:if>
+ <c:if test="${not empty param.sop}">
+ <c:param name="sop" value="${param.sop}"/>
+ </c:if>
+ <c:if test="${not empty param.scp}">
+ <c:param name="scp" value="${param.scp}"/>
+ </c:if>
+</c:url>
+
+<c:url var="selfPpAction" value="/admin/role/RoleAdmin.do">
+ <c:param name="mode" value="addLdapGroups"/>
+ <c:param name="r" value="${Role.id}"/>
+ <c:if test="${not empty param.pna}">
+ <c:param name="pna" value="${param.pna}"/>
+ </c:if>
+ <c:if test="${not empty param.psa}">
+ <c:param name="psa" value="${param.psa}"/>
+ </c:if>
+ <c:if test="${not empty param.soa}">
+ <c:param name="soa" value="${param.soa}"/>
+ </c:if>
+ <c:if test="${not empty param.sca}">
+ <c:param name="sca" value="${param.sca}"/>
+ </c:if>
+ <c:if test="${not empty param.pnp}">
+ <c:param name="pnp" value="${param.pnp}"/>
+ </c:if>
+ <c:if test="${not empty param.psp}">
+ <c:param name="psp" value="${param.psp}"/>
+ </c:if>
+</c:url>
+
+
+<!-- SELECT & ADD -->
+<table width="100%" cellpadding="0" cellspacing="0" border="0">
+ <tr>
+ <td width="50%" valign="top">
+
+<tiles:insert definition=".header.tab">
+ <tiles:put name="tabKey" value="admin.role.groups.GroupsTab"/>
+ <tiles:put name="useFromSideBar" value="true"/>
+</tiles:insert>
+
+ </td>
+ <td><html:img page="/images/spacer.gif" width="40" height="1" border="0"/></td>
+ <td>
+
+<tiles:insert definition=".header.tab">
+ <tiles:put name="tabKey" value="admin.role.groups.AssignToRoleTab"/>
+ <tiles:put name="useToSideBar" value="true"/>
+</tiles:insert>
+
+ </td>
+ </tr>
+ <tr>
+ <!-- SELECT COLUMN -->
+ <td width="50%" valign="top">
+ <!-- TABLED LIST CONTENTS (SELECT COLUMN) -->
+ <div id="<c:out value="${widgetInstanceName}"/>FromDiv">
+
+ <display:table padRows="true" rightSidebar="true" items="${AvailableResGrps}" var="group" action="${selfPaAction}"
+ postfix="a"
+ styleId="fromTable" width="100%" cellpadding="0" cellspacing="0" border="0">
+ <display:column width="1%" property="id" title="<input type=\"checkbox\" onclick=\"ToggleAll(this, widgetProperties)\" name=\"fromToggleAll\">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox">
+ <display:checkboxdecorator name="availableGroup" onclick="ToggleSelection(this, widgetProperties)" styleClass="availableListMember"/>
+ </display:column>
+ <display:column property="name" title="common.header.Group" sortAttr="lg.name" width="50%"/>
+ <display:column property="description" title="common.header.Description" sortAttr="lg.description" width="50%"/>
+ </display:table>
+
+ </div>
+ <!-- / -->
+
+<tiles:insert definition=".toolbar.new">
+ <tiles:put name="useFromSideBar" value="true"/>
+ <tiles:put name="pageList" beanName="AvailableResGrps"/>
+ <tiles:put name="pageAction" beanName="selfPsaAction"/>
+ <tiles:put name="postfix" value="a"/>
+</tiles:insert>
+
+ </td>
+ <!-- / SELECT COLUMN -->
+
+ <!-- ADD/REMOVE COLUMN -->
+ <td id="<c:out value="${widgetInstanceName}"/>AddRemoveButtonTd">
+ <div id="AddButtonDiv" align="left"><html:img page="/images/fb_addarrow_gray.gif" border="0" titleKey="AddToList.ClickToAdd"/></div>
+ <br> <br>
+ <div id="RemoveButtonDiv" align="right"><html:img page="/images/fb_removearrow_gray.gif" border="0" titleKey="AddToList.ClickToRemove"/></div>
+ </td>
+ <!-- / ADD/REMOVE COLUMN -->
+
+ <!-- ADD COLUMN -->
+ <td width="50%" valign="top">
+ <!-- TABLED LIST CONTENTS (SELECT COLUMN) -->
+ <div id='<c:out value="${widgetInstanceName}"/>ToDiv'>
+
+ <display:table padRows="true" leftSidebar="true" items="${PendingResGrps}" var="group" action="${selfPpAction}"
+ postfix="p"
+ styleId="toTable" width="100%" cellpadding="0" cellspacing="0" border="0">
+ <display:column width="1%" property="id" title="<input type=\"checkbox\" onclick=\"ToggleAll(this, widgetProperties)\" name=\"toToggleAll\">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox">
+ <display:checkboxdecorator name="pendingGroup" onclick="ToggleSelection(this, widgetProperties)" styleClass="pendingListMember"/>
+ </display:column>
+ <display:column property="name" title="common.header.Group" sortAttr="lg.name" width="50%"/>
+ <display:column property="description" title="common.header.Description" width="50%" sortAttr="lg.description"/>
+ </display:table>
+
+ </div>
+ <!-- / -->
+
+<tiles:insert definition=".toolbar.new">
+ <tiles:put name="newButtonKey" value="admin.role.groups.NewResourceGroupButton"/>
+ <tiles:put name="useToSideBar" value="true"/>
+ <tiles:put name="pageList" beanName="PendingResGrps"/>
+ <tiles:put name="pageAction" beanName="selfPspAction"/>
+ <tiles:put name="postfix" value="p"/>
+</tiles:insert>
+
+ </td>
+ <!-- / ADD COLUMN -->
+
+ </tr>
+</table>
+<!-- / SELECT & ADD -->
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java
index 0478fd8..e372777 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java
@@ -208,8 +208,10 @@ public class LdapGroupManager {
}
Map<String, String> entry = new HashMap<String, String>();
String name = (String) si.getAttributes().get("cn").get();
+ name = name.trim();
Attribute desc = si.getAttributes().get("description");
String description = desc != null ? (String) desc.get() : "";
+ description = description.trim();
entry.put("id", name);
entry.put("name", name);
entry.put("description", description);
14 years, 1 month
[rhq] Branch 'gwt' - 3 commits - modules/core modules/enterprise
by Jay Shaughnessy
modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml | 10
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 39 -
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java | 15
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationTemplate.java | 177 --------
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/AlertNotificationTemplateDetailsUIBean.java | 90 ----
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/ListAlertNotificationTemplatesUIBean.java | 76 ---
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/NewAlertNotificationTemplateUIBean.java | 86 ---
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java | 4
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/DefinitionNotificationsUIBean.java | 105 ----
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/details.xhtml | 136 ------
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/list.xhtml | 146 ------
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/new.xhtml | 74 ---
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml | 60 --
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java | 219 ----------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java | 68 ---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java | 7
16 files changed, 24 insertions(+), 1288 deletions(-)
New commits:
commit bb8f86dc6c3d983d7422616730614e9a99257a19
Merge: 9fa35dd... 33247dc...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 12:35:32 2010 -0400
Merge branch 'master' into gwt
commit 33247dceb1a722507ae16190333ffe9f2b09180b
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 12:32:55 2010 -0400
fix NPE seen during very first recalculation of saved search result counts
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
index 0e015e3..db826de 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
@@ -67,7 +67,10 @@ public class SavedSearchResultCountRecalculationJob extends AbstractStatefulJob
PageList<Resource> results = resourceManager.findResourcesByCriteria(overlord, criteria);
totalMillis += System.currentTimeMillis();
- if (results.getTotalSize() != next.getResultCount()) {
+ // TODO: should recent count be computed at the time of update/save for this saved search?
+ // it would obviate the need for null checking here as well as in the UI for conditional
+ // display of the result count
+ if (next.getResultCount() == null || results.getTotalSize() != next.getResultCount()) {
next.setResultCount((long) results.getTotalSize());
savedSearchManager.updateSavedSearch(overlord, next);
updated++;
@@ -76,7 +79,7 @@ public class SavedSearchResultCountRecalculationJob extends AbstractStatefulJob
} catch (Throwable t) {
// TODO: mark this saved search as "broken" so that future computation is suppressed for it
errors++;
- LOG.error("Could not calculate result count for SavedSearch[name=" + next.getName() + ", patter='"
+ LOG.error("Could not calculate result count for SavedSearch[name=" + next.getName() + ", pattern='"
+ next.getPattern() + "']");
}
}
commit 8bdaceac79897f786743a3607f287581565c9b6d
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 12:32:37 2010 -0400
removal of alert notification templates
* charles explained they will not be released in their current form
* reuse occurs at the alert definitions level (resource/group/type), not a component thereof
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
index b2db5f0..145b8e2 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
@@ -119,16 +119,6 @@
</index>
</table>
- <table name="RHQ_ALERT_NOTIF_TEMPL" tablespace="@@@LARGE_TABLESPACE_FOR_DATA@@@"
- storage-options="freelists 5" cache="true" logging="false">
- <column name="ID" default="sequence-only" initial="10001"
- primarykey="true" required="true" type="INTEGER"/>
- <column name="CTIME" required="true" type="LONG"/>
- <column name="MTIME" required="true" type="LONG"/>
- <column name="NAME" required="true" size="100" type="VARCHAR2"/>
- <column name="DESCRIPTION" required="false" size="250" type="VARCHAR2"/>
- </table>
-
<table name="RHQ_ALERT_NOTIFICATION" tablespace="@@@LARGE_TABLESPACE_FOR_DATA@@@"
storage-options="freelists 5" cache="true" logging="false">
<column name="ID" default="sequence-only" initial="10001"
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index d028a43..d97a230 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2058,8 +2058,9 @@
<schemaSpec version="2.70">
<schema-addColumn table="RHQ_ALERT" column="ACK_TIME" columnType="LONG" />
- <!-- TODO: this needs to change to ack_subject_name -->
<schema-addColumn table="RHQ_ALERT" column="ACK_SUBJECT" precision="100" columnType="VARCHAR2" />
+ </schemaSpec>
+ <schemaSpec version="2.70.1">
<schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_NAME" precision="100" columnType="VARCHAR2" />
<schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_CONFIG_ID" columnType="INTEGER" />
<schema-directSQL>
@@ -2071,35 +2072,7 @@
</statement>
</schema-directSQL>
</schemaSpec>
- <schemaSpec version="2.70.1">
- <schema-createSequence name="RHQ_ALERT_NOTIF_TEMPL_ID_SEQ" initial="10001" />
- <schema-directSQL>
- <statement desc="Creating table RHQ_ALERT_NOTIF_TEMPL">
- CREATE TABLE RHQ_ALERT_NOTIF_TEMPL ( ID INTEGER PRIMARY KEY )
- </statement>
- </schema-directSQL>
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="CTIME" columnType="LONG" />
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="CTIME" nullable="false" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="MTIME" columnType="LONG" />
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="MTIME" nullable="false" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="NAME" precision="100" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="NAME" nullable="false" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="DESCRIPTION" precision="250" columnType="VARCHAR2" />
- </schemaSpec>
<schemaSpec version="2.70.2">
- <!-- add structures for alert notification templates -->
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="TEMPLATE_ID" columnType="INTEGER" />
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_ALERT_NOTIFICATION
- ADD CONSTRAINT RHQ_AN_TEMPLATE_ID_FK
- FOREIGN KEY (TEMPLATE_ID)
- REFERENCES RHQ_ALERT_NOTIF_TEMPL (ID)
- </statement>
- </schema-directSQL>
- </schemaSpec>
- <schemaSpec version="2.70.3">
<!-- turn first-class notification data into configuration objects for custom alert senders -->
<schema-alterColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIFICATION_TYPE" nullable="TRUE" />
<schema-javaTask className="CustomAlertSenderUpgradeTask" />
@@ -2110,7 +2083,7 @@
</schema-directSQL>
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIFICATION_TYPE" />
</schemaSpec>
- <schemaSpec version="2.70.4">
+ <schemaSpec version="2.70.3">
<!-- remove first-class alert notification structures from definition side of the model-->
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_host" />
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_port" />
@@ -2120,19 +2093,19 @@
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="subject_id" />
<schema-deleteColumn table="RHQ_ALERT_DEFINITION" column="operation_def_id" />
</schemaSpec>
- <schemaSpec version="2.70.5">
+ <schemaSpec version="2.70.4">
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="roles" />
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="subjects" />
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="emails" />
</schemaSpec>
- <schemaSpec version="2.70.6">
+ <schemaSpec version="2.70.5">
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="SENDER" columnType="VARCHAR2" precision="200" />
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="RESULT_STATE" columnType="VARCHAR2" precision="20" />
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="MESSAGE" columnType="VARCHAR2" precision="255" />
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="ALL_EMAILS" columnType="VARCHAR2" precision="4000" />
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="EMAILS_FAILED" columnType="VARCHAR2" precision="4000" />
</schemaSpec>
- <schemaSpec version="2.70.7">
+ <schemaSpec version="2.70.6">
<schema-directSQL>
<statement>
DROP INDEX RHQ_ALERT_IDX_ALERT
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
index b77d8b0..b9c0401 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
@@ -49,7 +49,7 @@ import org.rhq.core.domain.configuration.Configuration;
@NamedQueries( {
@NamedQuery(name = AlertNotification.DELETE_BY_ID, query = "DELETE FROM AlertNotification an WHERE an.id IN ( :ids )"),
@NamedQuery(name = AlertNotification.QUERY_DELETE_BY_RESOURCES, query = "DELETE FROM AlertNotification an WHERE an.alertDefinition IN ( SELECT ad FROM AlertDefinition ad WHERE ad.resource.id IN ( :resourceIds ) )"),
- @NamedQuery(name = AlertNotification.QUERY_DELETE_ORPHANED, query = "DELETE FROM AlertNotification an WHERE an.alertDefinition IS NULL AND an.alertNotificationTemplate IS NULL") })
+ @NamedQuery(name = AlertNotification.QUERY_DELETE_ORPHANED, query = "DELETE FROM AlertNotification an WHERE an.alertDefinition IS NULL") })
@SequenceGenerator(name = "RHQ_ALERT_NOTIFICATION_ID_SEQ", sequenceName = "RHQ_ALERT_NOTIFICATION_ID_SEQ")
@Table(name = "RHQ_ALERT_NOTIFICATION")
public class AlertNotification implements Serializable {
@@ -74,10 +74,6 @@ public class AlertNotification implements Serializable {
@ManyToOne
private AlertDefinition alertDefinition;
- @JoinColumn(name = "TEMPLATE_ID")
- @ManyToOne
- private AlertNotificationTemplate alertNotificationTemplate;
-
@JoinColumn(name = "SENDER_CONFIG_ID", referencedColumnName = "ID")
@OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
private Configuration configuration;
@@ -162,14 +158,6 @@ public class AlertNotification implements Serializable {
this.configuration = configuration;
}
- public AlertNotificationTemplate getAlertNotificationTemplate() {
- return alertNotificationTemplate;
- }
-
- public void setAlertNotificationTemplate(AlertNotificationTemplate alertNotificationTemplate) {
- this.alertNotificationTemplate = alertNotificationTemplate;
- }
-
public int getAlertDefinitionId() {
return alertDefinitionId;
}
@@ -185,7 +173,6 @@ public class AlertNotification implements Serializable {
sb.append("{alertDefinitionId=").append(alertDefinitionId);
sb.append(", alertNotificationId=").append(alertNotificationId);
sb.append(", id=").append(id);
- sb.append(", notificationTemplate=").append(alertNotificationTemplate);
sb.append(", senderName='").append(senderName).append('\'');
sb.append('}');
return sb.toString();
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationTemplate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationTemplate.java
deleted file mode 100644
index df64a54..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationTemplate.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.core.domain.alert.notification;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.PrePersist;
-import javax.persistence.PreUpdate;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.Table;
-
-import org.rhq.core.domain.alert.AlertDefinition;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.group.ResourceGroup;
-
-/**
- * An {@link AlertNotificationTemplate} is a group of {@link AlertNotification}. This can be used to create
- * pre-configured sets of notifications which can then be applied to all types of {@link AlertDefinition}s -
- * those at the {@link Resource}-level, {@link ResourceGroup}-level, and {@link ResourceType}-level (a.k.a
- * Alert Template).
- *
- * @author Heiko W. Rupp
- */
-
-@NamedQueries( {
- @NamedQuery(name = AlertNotificationTemplate.FIND_BY_NAME, query = "SELECT t FROM AlertNotificationTemplate t WHERE t.name = :name"),
- @NamedQuery(name = AlertNotificationTemplate.FIND_ALL, query = "SELECT t FROM AlertNotificationTemplate AS t") })
-@Entity
-@Table(name = "RHQ_ALERT_NOTIF_TEMPL")
-@SequenceGenerator(name = "RHQ_ALERT_NOTIF_TEMPL_ID_SEQ", sequenceName = "RHQ_ALERT_NOTIF_TEMPL_ID_SEQ")
-public class AlertNotificationTemplate implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public static final String FIND_BY_NAME = "AlertNotificationTemplate.findByName";
- public static final String FIND_ALL = "AlertNotificationTemplate.findAll";
-
- @Column(name = "ID", nullable = false)
- @GeneratedValue(generator = "RHQ_ALERT_NOTIF_TEMPL_ID_SEQ")
- @Id
- private int id;
-
- @Column(name = "CTIME")
- private long ctime;
-
- @Column(name = "MTIME")
- private long mtime;
-
- @Column(name = "NAME")
- private String name;
-
- @Column(name = "DESCRIPTION")
- private String description;
-
- @OneToMany(mappedBy = "alertNotificationTemplate", cascade = CascadeType.ALL)
- List<AlertNotification> notifications = new ArrayList<AlertNotification>();
-
- protected AlertNotificationTemplate() {
- // for JPA
- }
-
- public AlertNotificationTemplate(String name, String description) {
- this.name = name;
- this.description = description;
- }
-
- public int getId() {
- return this.id;
- }
-
- public long getCtime() {
- return ctime;
- }
-
- public long getMtime() {
- return mtime;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public List<AlertNotification> getNotifications() {
- return notifications;
- }
-
- public void setNotifications(List<AlertNotification> notifications) {
- this.notifications = notifications;
- }
-
- public List<AlertNotification> addNotification(AlertNotification notification) {
- this.notifications.add(notification);
- return this.notifications;
- }
-
- @PrePersist
- void onPersist() {
- this.mtime = this.ctime = System.currentTimeMillis();
- }
-
- @PreUpdate
- void onPreUpdate() {
- this.mtime = System.currentTimeMillis();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
-
- AlertNotificationTemplate that = (AlertNotificationTemplate) o;
-
- if (description != null ? !description.equals(that.description) : that.description != null)
- return false;
- return name.equals(that.name);
-
- }
-
- @Override
- public int hashCode() {
- int result = name.hashCode();
- result = 31 * result + (description != null ? description.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("NotificationTemplate");
- sb.append("{id=").append(id);
- sb.append(", name='").append(name).append('\'');
- sb.append(", description='").append(description).append('\'');
- sb.append('}');
- return sb.toString();
- }
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/AlertNotificationTemplateDetailsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/AlertNotificationTemplateDetailsUIBean.java
deleted file mode 100644
index c3bad26..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/AlertNotificationTemplateDetailsUIBean.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.admin.alert;
-
-import javax.faces.application.FacesMessage;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.enterprise.gui.common.framework.EnterpriseFacesContextUIBean;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-
-(a)Scope(ScopeType.PAGE)
-@Name("AlertNotificationTemplateDetailsUIBean")
-public class AlertNotificationTemplateDetailsUIBean extends EnterpriseFacesContextUIBean {
-
- @In
- private AlertNotificationManagerLocal alertNotificationManager;
-
- private AlertNotificationTemplate template;
-
- private void loadTemplate() {
- if (template == null) {
- int templateId = FacesContextUtility.getRequiredRequestParameter("templateId", Integer.class);
- template = alertNotificationManager.getAlertNotificationTemplate(getSubject(), templateId);
- }
- }
-
- public AlertNotificationTemplate getTemplate() {
- loadTemplate();
-
- return template;
- }
-
- public int getNotificationCount() {
- loadTemplate();
-
- return template.getNotifications().size();
- }
-
- public String edit() {
- return OUTCOME_EDIT;
- }
-
- public String editNotifications() {
- return OUTCOME_EDIT;
- }
-
- public String save() {
- try {
- alertNotificationManager.updateNotificationTemplate(getSubject(), template.getId(), template.getName(),
- template.getDescription());
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
- "Alert notification template was successfully modified.");
- } catch (Throwable t) {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
- "Error while saving alert notification template: " + t.getMessage());
- }
-
- return OUTCOME_SAVE;
- }
-
- public String cancel() {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
- "Alert notification template modifications were cancelled.");
-
- return OUTCOME_CANCELLED;
- }
-
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/ListAlertNotificationTemplatesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/ListAlertNotificationTemplatesUIBean.java
deleted file mode 100644
index dd63d29..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/ListAlertNotificationTemplatesUIBean.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.admin.alert;
-
-import java.util.List;
-
-import javax.faces.application.FacesMessage;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.util.PageControl;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.core.gui.util.StringUtility;
-import org.rhq.enterprise.gui.common.framework.EnterpriseFacesContextUIBean;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-
-(a)Scope(ScopeType.PAGE)
-@Name("ListAlertNotificationTemplatesUIBean")
-public class ListAlertNotificationTemplatesUIBean extends EnterpriseFacesContextUIBean {
-
- @In
- private AlertNotificationManagerLocal alertNotificationManager;
-
- public PageList<AlertNotificationTemplate> getAlertNotificationTemplates() {
- List<AlertNotificationTemplate> templates = alertNotificationManager.listNotificationTemplates(getSubject());
- return new PageList<AlertNotificationTemplate>(templates, new PageControl(0, templates.size()));
- }
-
- public String deleteSelectedAlertNotificationTemplates() {
- try {
- Subject subject = getSubject();
- String[] selectedNotificationTemplates = getSelectedNotificationTemplates();
- Integer[] selectedNotificationTemplateIds = StringUtility.getIntegerArray(selectedNotificationTemplates);
- int deleted = alertNotificationManager
- .deleteNotificationTemplates(subject, selectedNotificationTemplateIds);
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Deleted " + deleted
- + " alert notification templates");
- } catch (Throwable t) {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Deletion failed: " + t.getMessage());
- }
-
- return OUTCOME_SUCCESS;
- }
-
- public String createNewAlertNotificationTemplate() {
- return OUTCOME_CREATE;
- }
-
- private String[] getSelectedNotificationTemplates() {
- String[] results = FacesContextUtility.getRequest().getParameterValues("selectedNotificationTemplates");
- return results;
- }
-
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/NewAlertNotificationTemplateUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/NewAlertNotificationTemplateUIBean.java
deleted file mode 100644
index b2e0b07..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/NewAlertNotificationTemplateUIBean.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.admin.alert;
-
-import java.util.ArrayList;
-
-import javax.faces.application.FacesMessage;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.enterprise.gui.common.framework.EnterpriseFacesContextUIBean;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-
-(a)Scope(ScopeType.PAGE)
-@Name("NewAlertNotificationTemplateUIBean")
-public class NewAlertNotificationTemplateUIBean extends EnterpriseFacesContextUIBean {
-
- @In
- private AlertNotificationManagerLocal alertNotificationManager;
-
- private String name;
- private String description;
-
- private int createdTemplateId; // will be set as a result of create(), used for JSF navigation rules
-
- public String create() {
- try {
- AlertNotificationTemplate template = alertNotificationManager.createNotificationTemplate(this.name,
- this.description, new ArrayList<AlertNotification>(), true);
- createdTemplateId = template.getId();
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Created new alert notification template");
- } catch (Throwable t) {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Creation failed: " + t.getMessage());
- }
-
- return OUTCOME_SUCCESS;
- }
-
- public String cancel() {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Template creation cancelled.");
- return OUTCOME_CANCELLED;
- }
-
- public int getCreatedTemplateId() {
- return createdTemplateId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
index 758383a..eb7d500 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
@@ -59,13 +59,15 @@ public class CustomContentUIBean extends EnterpriseFacesContextUIBean {
AlertNotification activeNotification = alertNotificationManager.getAlertNotification(getSubject(),
alertNotificationId);
+ if (activeNotification == null) {
+ return; // this was just removed on the previous request
+ }
String senderName = activeNotification.getSenderName();
AlertSenderInfo info = alertNotificationManager.getAlertInfoForSender(senderName);
if (info != null && info.getUiSnippetUrl() != null) {
this.contentUrl = info.getUiSnippetUrl().toString();
- //this.contentUrl = "rhq/custom/plugin/alert/" + senderName + "/" + info.getUiSnippetShortPath();
}
String backingBeanName = alertNotificationManager.getBackingBeanNameForSender(senderName);
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/DefinitionNotificationsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/DefinitionNotificationsUIBean.java
deleted file mode 100644
index 5b7cbeb..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/DefinitionNotificationsUIBean.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.alert.common;
-
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.enterprise.gui.common.framework.EnterpriseFacesContextUIBean;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-
-(a)Scope(ScopeType.EVENT)
-@Name("definitionNotificationsUIBean")
-public class DefinitionNotificationsUIBean extends EnterpriseFacesContextUIBean {
-
- @In
- private AlertNotificationsUIBean alertNotificationsUIBean;
- @In
- private AlertNotificationManagerLocal alertNotificationManager;
-
- private String selectedTemplate;
- private Boolean clearExistingNotifications;
- private Map<String, String> notificationTemplates;
-
- public String getSelectedTemplate() {
- return selectedTemplate;
- }
-
- public void setSelectedTemplate(String selectedTemplate) {
- this.selectedTemplate = selectedTemplate;
- }
-
- public Boolean getClearExistingNotifications() {
- return clearExistingNotifications;
- }
-
- public void setClearExistingNotifications(Boolean clearExistingNotifications) {
- this.clearExistingNotifications = clearExistingNotifications;
- }
-
- public Map<String, String> getNotificationTemplates() {
- return this.notificationTemplates;
- }
-
- public String addAlertSenderFromTemplate() {
- int alertDefinitionId = FacesContextUtility.getRequiredRequestParameter("ad", Integer.class);
- this.alertNotificationManager.applyNotificationTemplateToAlertDefinition(getSelectedTemplate(),
- alertDefinitionId, getClearExistingNotifications());
- this.alertNotificationsUIBean.reloadAlertNotifications();
- return "success";
- }
-
- @Create
- public void init() {
- this.notificationTemplates = lookupNotificationTemplates();
- }
-
- private Map<String, String> lookupNotificationTemplates() {
- Map<String, String> result = new TreeMap<String, String>();
- List<AlertNotificationTemplate> templates = this.alertNotificationManager
- .listNotificationTemplates(getSubject());
-
- for (AlertNotificationTemplate template : templates) {
- String displayName = getNotificationDisplayName(template);
- result.put(displayName, template.getName()); // displayed text, option value
- }
-
- return result;
- }
-
- private String getNotificationDisplayName(AlertNotificationTemplate template) {
- StringBuilder builder = new StringBuilder(template.getName());
-
- builder.append(" (");
- builder.append(template.getDescription());
- builder.append(")");
-
- return builder.toString();
- }
-
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/details.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/details.xhtml
deleted file mode 100644
index 69bfcb3..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/details.xhtml
+++ /dev/null
@@ -1,136 +0,0 @@
-<?xml version="1.0"?>
-
-<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:c="http://java.sun.com/jstl/core"
- xmlns:onc="http://jboss.org/on/component"
- xmlns:onf="http://jboss.org/on/function"
- xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
- xmlns:rich="http://richfaces.ajax4jsf.org/rich">
-
-<ui:composition template="/rhq/layout/main.xhtml">
-
- <ui:param name="pageTitle" value="Alert Notification Template Details"/>
-
- <ui:define name="breadcrumbs">
- <h:outputLink value="/rhq/admin/alert/template/notification/list.xhtml">
- <h:outputText value="Alert Notification Templates" />
- </h:outputLink>
- <h:outputText value=" > " />
- <h:outputLink value="/rhq/admin/alert/template/notification/details.xhtml">
- <f:param name="templateId" value="#{AlertNotificationTemplateDetailsUIBean.template.id}" />
- <f:param name="mode" value="view" />
- <h:outputText value="Details for '#{AlertNotificationTemplateDetailsUIBean.template.name}'" />
- </h:outputLink>
- </ui:define>
-
- <ui:define name="body">
-
- <ui:param name="mode" value="#{param.mode}" />
-
- <br/>
- <h:messages showDetail="true"
- globalOnly="true"
- infoClass="InfoBlock"
- warnClass="WarnBlock"
- errorClass="ErrorBlock"
- fatalClass="FatalBlock"
- layout="table" />
-
- <h:form id="alertNotificationTemplateDetailsForm">
-
- <input type="hidden" name="templateId" value="#{param.templateId}" />
- <input type="hidden" name="mode" value="#{param.mode}" />
-
- <rich:panel>
- <f:facet name="header">
- General Properties
- </f:facet>
- <table width="100%">
- <tr>
- <td align="right" style="white-space: no-wrap;"><b>Name<span class="required-marker-text">*</span>:</b></td>
- <td align="left">
- <h:inputText rendered="${mode eq 'edit'}" value="#{AlertNotificationTemplateDetailsUIBean.template.name}" />
- <h:outputText rendered="${mode ne 'edit'}" value="#{AlertNotificationTemplateDetailsUIBean.template.name}" />
- </td>
- </tr>
- <tr>
- <td align="right" style="white-space: no-wrap;"><b>Description:</b></td>
- <td align="left">
- <h:inputText rendered="${mode eq 'edit'}" value="#{AlertNotificationTemplateDetailsUIBean.template.description}" />
- <h:outputText rendered="${mode ne 'edit'}" value="#{AlertNotificationTemplateDetailsUIBean.template.description}" />
- </td>
- </tr>
- <tr>
- <td align="right" style="white-space: no-wrap;"><b>Date Created:</b></td>
- <td align="left">
- <h:outputText value="#{AlertNotificationTemplateDetailsUIBean.template.ctime}">
- <f:converter converterId="UserDateTimeConverter" />
- </h:outputText>
- </td>
- </tr>
- <tr>
- <td align="right" style="white-space: no-wrap;"><b>Last Modified:</b></td>
- <td align="left">
- <h:outputText value="#{AlertNotificationTemplateDetailsUIBean.template.mtime}">
- <f:converter converterId="UserDateTimeConverter" />
- </h:outputText>
- </td>
- </tr>
- </table>
- <h:panelGroup layout="block">
- <h:panelGrid columns="3" styleClass="buttons-table" columnClasses="button-cell" >
- <h:commandButton action="#{AlertNotificationTemplateDetailsUIBean.edit}"
- value="EDIT" styleClass="buttonmed" id="editPropertiesButton"
- rendered="${mode ne 'edit'}"/>
- <h:commandButton action="#{AlertNotificationTemplateDetailsUIBean.save}"
- value="SAVE" styleClass="buttonmed" id="saveButton"
- rendered="${mode eq 'edit'}"/>
- <h:commandButton action="#{AlertNotificationTemplateDetailsUIBean.cancel}"
- value="CANCEL" styleClass="buttonmed" id="cancelButton" immediate="true"
- rendered="${mode eq 'edit'}"/>
- </h:panelGrid>
- </h:panelGroup>
- </rich:panel>
- <br/>
- <rich:panel rendered="${mode ne 'edit'}">
- <f:facet name="header">
- Notification Actions
- </f:facet>
- <table width="100%">
- <tr>
- <td align="right" style="white-space: no-wrap;" width="20%"><b>Sender Info:</b></td>
- <td align="left">
- <h:outputText value="#{AlertNotificationTemplateDetailsUIBean.notificationCount} " />
- <h:outputText value="${msg['alert.current.detail.notify.Message']}" />
- </td>
- </tr>
- </table>
- <h:panelGroup layout="block">
- <h:panelGrid columns="3" styleClass="buttons-table" columnClasses="button-cell" >
- <h:commandButton action="#{AlertNotificationTemplateDetailsUIBean.editNotifications}"
- value="EDIT" styleClass="buttonmed" id="editNotificationsButton" />
- </h:panelGrid>
- </h:panelGroup>
- </rich:panel>
-
- <ui:remove>
- <ui:include src="/rhq/common/alert/notification/details.xhtml"
- rendered="${mode eq 'edit'}">
- <ui:param name="redirect" value="/rhq/admin/alert/template/notification/details.xhtml?mode=view&templateId=#{param.templateId}" />
- </ui:include>
- </ui:remove>
-
- </h:form>
-
- </ui:define>
-
-</ui:composition>
-
-</html>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/list.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/list.xhtml
deleted file mode 100644
index 3b2c868..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/list.xhtml
+++ /dev/null
@@ -1,146 +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:onc="http://jboss.org/on/component"
- xmlns:a4j="http://richfaces.org/a4j"
- xmlns:rich="http://richfaces.ajax4jsf.org/rich">
-
-<ui:composition template="/rhq/layout/main.xhtml">
-
- <ui:param name="pageTitle" value="List Alert Notification Templates"/>
-
- <ui:define name="metaHeaders">
- <style>
- #senderName {
- display: none;
- }
- </style>
- </ui:define>
-
- <ui:define name="breadcrumbs">
- <h:outputLink value="/rhq/admin/alert/template/notification/list.xhtml">
- <h:outputText value="Alert Notification Templates" />
- </h:outputLink>
- </ui:define>
-
- <ui:define name="body">
- <br/>
- <h:messages showDetail="true"
- globalOnly="true"
- infoClass="InfoBlock"
- warnClass="WarnBlock"
- errorClass="ErrorBlock"
- fatalClass="FatalBlock"
- layout="table" />
-
- <h:form id="listAlertNotificationTemplatesForm">
- <rich:panel>
- <f:facet name="header">
- <h:outputText value="Alert Notification Templates"/>
- </f:facet>
-
- <h:panelGrid columns="1" styleClass="data-table">
- <h:outputText value="*Templates are groups of notifications that can be applied to alert definitions en masse" />
- <br/>
-
- <ui:param name="notificationTemplateDataModel" value="#{ListAlertNotificationTemplatesUIBean.alertNotificationTemplates}"/>
- <rich:dataTable id="notificationTemplateDataModel"
- rows="0"
- value="#{notificationTemplateDataModel}"
- var="notificationTemplate"
- width="100%"
- columnsWidth="1%, 30%, 40%, 15%, 15%"
- styleClass="resources-table"
- headerClass="tableRowHeader"
- footerClass="on-pager-footer"
- onRowMouseOver="this.style.backgroundColor='#E7E7E7'"
- onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
-
- <f:facet name="PageControlView">
- <onc:paginationControl id="NONE" />
- </f:facet>
-
- <rich:column>
- <f:facet name="header">
- <onc:allSelect target="selectedNotificationTemplates" />
- </f:facet>
-
- <onc:select name="selectedNotificationTemplates" value="#{notificationTemplate.id}" />
- </rich:column>
-
- <rich:column>
- <f:facet name="header">
- <onc:sortableColumnHeader sort="name">
- <h:outputText styleClass="headerText" value="Name" />
- </onc:sortableColumnHeader>
- </f:facet>
-
- <h:outputLink value="/rhq/admin/alert/template/notification/details.xhtml">
- <f:param name="templateId" value="#{notificationTemplate.id}" />
- <f:param name="mode" value="view" />
- <h:outputText value="#{notificationTemplate.name}" />
- </h:outputLink>
- </rich:column>
-
- <rich:column>
- <f:facet name="header">
- <onc:sortableColumnHeader sort="description">
- <h:outputText styleClass="headerText" value="Description" />
- </onc:sortableColumnHeader>
- </f:facet>
-
- <h:outputText value="#{notificationTemplate.description}" />
- </rich:column>
-
- <rich:column>
- <f:facet name="header">
- <onc:sortableColumnHeader sort="ctime">
- <h:outputText styleClass="headerText" value="Created" />
- </onc:sortableColumnHeader>
- </f:facet>
-
- <h:outputText value="#{notificationTemplate.ctime}">
- <f:converter converterId="UserDateTimeConverter" />
- </h:outputText>
- </rich:column>
-
- <rich:column>
- <f:facet name="header">
- <onc:sortableColumnHeader sort="mtime">
- <h:outputText styleClass="headerText" value="Last Modified" />
- </onc:sortableColumnHeader>
- </f:facet>
-
- <h:outputText value="#{notificationTemplate.mtime}">
- <f:converter converterId="UserDateTimeConverter" />
- </h:outputText>
- </rich:column>
-
- <f:facet name="footer">
- <rich:columnGroup>
- <rich:column colspan="5" width="100%">
- <h:commandButton action="#{ListAlertNotificationTemplatesUIBean.createNewAlertNotificationTemplate}"
- value="CREATE NEW" styleClass="on-pager-button buttonsmall"
- rendered="#{GlobalPermissionsUIBean.inventory}" />
- <onc:selectCommandButton action="#{ListAlertNotificationTemplatesUIBean.deleteSelectedAlertNotificationTemplates}"
- value="DELETE SELECTED" target="selectedNotificationTemplates" styleClass="on-pager-button buttonsmall"
- rendered="#{GlobalPermissionsUIBean.inventory}" />
- </rich:column>
- </rich:columnGroup>
- </f:facet>
-
- <h:outputText value="Templates are groups of preconfigured alert notifications that can later be applied to alert definitions" />
-
- </rich:dataTable>
- </h:panelGrid>
- </rich:panel>
- </h:form>
-
- </ui:define>
-</ui:composition>
-
-</html>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/new.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/new.xhtml
deleted file mode 100644
index 25862c1..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/new.xhtml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0"?>
-
-<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:c="http://java.sun.com/jstl/core"
- xmlns:onc="http://jboss.org/on/component"
- xmlns:onf="http://jboss.org/on/function"
- xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
- xmlns:rich="http://richfaces.ajax4jsf.org/rich">
-
-<ui:composition template="/rhq/layout/main.xhtml">
-
- <ui:param name="pageTitle" value="Create New Alert Notification Template"/>
-
- <ui:define name="breadcrumbs">
- <h:outputLink value="/rhq/admin/alert/template/notification/list.xhtml">
- <h:outputText value="Alert Notification Templates" />
- </h:outputLink>
- <h:outputText value=" > " />
- <h:outputLink value="/rhq/admin/alert/template/notification/new.xhtml">
- <h:outputText value="Create New" />
- </h:outputLink>
- </ui:define>
-
- <ui:define name="body">
-
- <h:form>
-
- <rich:panel>
-
- <f:facet name="header">
- General Properties
- </f:facet>
-
- <table>
- <tr>
- <td align="right"><b>Name<span class="required-marker-text">*</span>:</b></td>
- <td align="left">
- <h:inputText value="#{NewAlertNotificationTemplateUIBean.name}" size="60" maxlength="100" />
- </td>
- </tr>
- <tr>
- <td align="right"><b>Description:</b></td>
- <td align="left">
- <h:inputText value="#{NewAlertNotificationTemplateUIBean.description}" size="60" maxlength="250" />
- </td>
- </tr>
- </table>
-
- </rich:panel>
-
- <h:panelGroup layout="block" styleClass="BlockContent">
- <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell">
- <h:commandButton action="#{NewAlertNotificationTemplateUIBean.create}"
- value="CREATE" styleClass="buttonmed"/>
- <h:commandButton action="#{NewAlertNotificationTemplateUIBean.cancel}"
- immediate="true"
- value="CANCEL" styleClass="buttonmed"/>
- </h:panelGrid>
- </h:panelGroup>
-
- </h:form>
-
- </ui:define>
-
-</ui:composition>
-
-</html>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
index 74b978e..0c25391 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
@@ -27,10 +27,8 @@
<ui:define name="body">
<a4j:keepAlive beanName="AlertNotificationContextUIBean" />
- <a4j:keepAlive beanName="alertNotificationStoreUIBean" />
<a4j:keepAlive beanName="alertNotificationsUIBean" />
<a4j:keepAlive beanName="customContentUIBean" />
- <a4j:keepAlive beanName="definitionNotificationsUIBean" />
<rich:panel id="existingAlertsPanel">
@@ -98,15 +96,6 @@
operation="show"
event="onclick" />
</h:outputLink>
- <ui:remove>
- <h:outputLink id="addAlertTemplateLink" styleClass="buttonmed" value="#" rendered="#{param.context ne 'template'}">
- <h:outputText value="Import Templates" />
- <rich:componentControl for="addAlertFromTemplatePanel"
- attachTo="addAlertTemplateLink"
- operation="show"
- event="onclick" />
- </h:outputLink>
- </ui:remove>
<h:commandButton id="removeAlertButton"
value="Remove Selected"
action="#{alertNotificationsUIBean.removeSelected}"
@@ -185,55 +174,6 @@
</h:form>
</rich:panel>
</rich:modalPanel>
-
-
- <rich:modalPanel id="addAlertFromTemplatePanel" moveable="false" autosized="true">
- <rich:panel id="importTemplatesPanel">
- <f:facet name="header">
- <h:outputText value="Import Notifications From Template" style="white-space: nowrap;"/>
- </f:facet>
-
- <h:form id="newNotificationsFromTemplateForm">
- <input type="hidden" name="ad" value="#{param.contextId}"/>
- <input type="hidden" name="context" value="#{param.context}"/>
- <input type="hidden" name="contextId" value="#{param.contextId}"/>
- <input type="hidden" name="contextSubId" value="#{param.contextSubId}"/>
-
- <rich:panel rendered="#{definitionNotificationsUIBean.notificationTemplates.size ne 0}">
- <div style="height: 100px;">
- <h:selectOneMenu id="templateList" value="#{definitionNotificationsUIBean.selectedTemplate}">
- <f:selectItems value="#{definitionNotificationsUIBean.notificationTemplates}"/>
- </h:selectOneMenu>
-
- <br/>
-
- <h:selectBooleanCheckbox title="clearExisting" value="#{definitionNotificationsUIBean.clearExistingNotifications}"/>
- <h:outputText value="Clear existing notifications"/>
- </div>
- </rich:panel>
-
- <rich:panel rendered="#{definitionNotificationsUIBean.notificationTemplates.size eq 0}">
- <div style="height: 100px;">
- No Alert Notification Templates have been defined yet.<br/>
- Please create some in Administration -> System Configuration -> Alert Notification Templates
- </div>
- </rich:panel>
-
- <h:panelGrid columns="4" styleClass="buttons-table" columnClasses="button-cell">
- <a4j:commandButton value="OK" action="#{definitionNotificationsUIBean.addAlertSenderFromTemplate}"
- styleClass="buttonmed" id="addTemplateButton"
- reRender="sendersList"
- rendered="#{definitionNotificationsUIBean.notificationTemplates.size ne 0}">
- <rich:componentControl for="addAlertFromTemplatePanel" attachTo="addTemplateButton" operation="hide" event="onclick" />
- </a4j:commandButton>
- <h:outputLink id="alertTemplateCancelLink" styleClass="buttonmed" value="#" style="float: right; margin: 10px;">
- <h:outputText value="Cancel" />
- <rich:componentControl for="addAlertFromTemplatePanel" attachTo="alertTemplateCancelLink" operation="hide" event="onclick" />
- </h:outputLink>
- </h:panelGrid>
- </h:form>
- </rich:panel>
- </rich:modalPanel>
</ui:define>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
index 0897dc7..3a9a56c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
@@ -27,7 +27,6 @@ import java.util.Set;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
-import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@@ -38,7 +37,6 @@ import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.AlertDefinitionContext;
import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.configuration.Configuration;
@@ -48,7 +46,6 @@ import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
-import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.plugin.ServerPluginsLocal;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderInfo;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderPluginManager;
@@ -152,7 +149,9 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
try {
bb.internalCleanup();
} catch (Throwable t) {
- LOG.error("removeNotifications, calling backingBean.internalCleanup() resulted in " + t.getMessage());
+ LOG
+ .error("removeNotifications, calling backingBean.internalCleanup() resulted in " + t.getMessage(),
+ t);
}
}
@@ -163,30 +162,6 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
return removed;
}
- public int removeNotificationsFromTemplate(Subject subject, int templateId, Integer[] notificationIds) {
- if ((notificationIds == null) || (notificationIds.length == 0)) {
- return 0;
- }
-
- AlertNotificationTemplate templ = entityManager.find(AlertNotificationTemplate.class, templateId);
- Set<Integer> notificationIdSet = new HashSet<Integer>(Arrays.asList(notificationIds));
- List<AlertNotification> notifications = templ.getNotifications();
- List<AlertNotification> toBeRemoved = new ArrayList<AlertNotification>();
-
- int removed = 0;
- for (AlertNotification notification : notifications) {
- if (notificationIdSet.contains(notification.getId())) {
- toBeRemoved.add(notification);
- removed--;
- }
- }
-
- templ.getNotifications().removeAll(toBeRemoved);
-
- return removed;
-
- }
-
public int purgeOrphanedAlertNotifications() {
Query purgeQuery = entityManager.createNamedQuery(AlertNotification.QUERY_DELETE_ORPHANED);
return purgeQuery.executeUpdate();
@@ -350,191 +325,15 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
entityManager.flush();
}
- /**
- * Take the passed NotificationTemplate and apply its Notifications to the passed AlertDefinition
- * @param templateName name of a pre-defined alert NotificationTemplate
- * @param alertDefinitionId id of an AlertDefinition on which the template should be applied
- * @param removeOldNotifications Shall old Notifications on the Definition be removed?
- */
- public void applyNotificationTemplateToAlertDefinition(String templateName, int alertDefinitionId,
- boolean removeOldNotifications) {
-
- AlertNotificationTemplate template = getNotificationTemplateByName(templateName);
-
- AlertDefinition definition = getDetachedAlertDefinition(alertDefinitionId);
-
- applyNotificationTemplateToAlertDefinition(template, definition, removeOldNotifications);
- }
-
- private AlertNotificationTemplate getNotificationTemplateByName(String templateName) {
- Query q = entityManager.createNamedQuery(AlertNotificationTemplate.FIND_BY_NAME);
- q.setParameter("name", templateName);
- AlertNotificationTemplate template;
- try {
- template = (AlertNotificationTemplate) q.getSingleResult();
- } catch (NoResultException nre) {
- LOG.info("There is no alert notification template with name '" + templateName + "'");
- template = new AlertNotificationTemplate("dummy", null);
- }
- return template;
- }
-
- /**
- * Take the passed NotificationTemplate and apply its Notifications to the passed AlertDefinition
- * @param template NotificationTemplate to apply
- * @param def AlertDefinition to apply the template to
- * @param removeOldNotifications Shall old Notifications on the Definition be removed?
- */
- public void applyNotificationTemplateToAlertDefinition(AlertNotificationTemplate template, AlertDefinition def,
- boolean removeOldNotifications) {
-
- if (removeOldNotifications)
- def.getAlertNotifications().clear();
-
- for (AlertNotification notif : template.getNotifications()) {
- AlertNotification notification = new AlertNotification(notif, true);
- notification.setAlertDefinition(notif.getAlertDefinition());
- entityManager.persist(notification.getConfiguration());
- entityManager.persist(notification);
- def.addAlertNotification(notification); // Attach a copy, as the ones in the template should not be shared
- }
- }
-
- /**
- * Create a new NotificationTemplate from the passed parameters. The passed AlertNotification objects need to have the
- * name and sender and any configuration properties already set; alert definitions must not be set.
- * @param name name of this notification template. Must be unique
- * @param description description of the template
- * @param notifications notifications that make up the template
- * @param copyNotifications
- * @return the newly created template
- * @throws IllegalArgumentException when a template with the passed name already exists
- */
- @SuppressWarnings("unchecked")
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public AlertNotificationTemplate createNotificationTemplate(String name, String description,
- List<AlertNotification> notifications, boolean copyNotifications) throws IllegalArgumentException {
-
- Query q = entityManager.createNamedQuery(AlertNotificationTemplate.FIND_BY_NAME);
- q.setParameter("name", name);
- List<AlertNotificationTemplate> tmp = q.getResultList();
- if (tmp.size() > 0) {
- throw new IllegalArgumentException("AlertNotificationTemplate with name [" + name + "] already exists");
- }
-
- AlertNotificationTemplate templ = new AlertNotificationTemplate(name, description);
- entityManager.persist(templ);
- for (AlertNotification n : notifications) {
- if (copyNotifications) {
- // AlertNotification alNo = n.copyWithAlertDefintion() TODO implement / fix this
- } else {
- n.setAlertNotificationTemplate(templ);
- templ.addNotification(n);
- entityManager.persist(n);
- }
-
- }
- return templ;
- }
-
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public void updateNotificationTemplate(Subject subject, int templateId, String newName, String newDescription) {
- AlertNotificationTemplate template = getAlertNotificationTemplate(subject, templateId);
- template.setName(newName);
- template.setDescription(newDescription);
- entityManager.merge(template);
- }
-
- /**
- * Delete the passed Notification Templates
- * @param subject subject of the caller
- * @param templateIds ids of the templates to delete
- * @return number of templates deleted
- */
- public int deleteNotificationTemplates(Subject subject, Integer[] templateIds) {
- if (templateIds.length == 0)
- return 0;
-
- int num = 0;
- for (int id : templateIds) {
- AlertNotificationTemplate templ = entityManager.find(AlertNotificationTemplate.class, id);
- if (templ == null) {
- LOG.warn("No notification template found with id [" + id + "]");
- continue;
- }
- entityManager.remove(templ);
- num++;
- }
-
- return num;
- }
-
- /**
- * Add a new alert Notification to a template
- * @param user subject of the caller
- * @param templateName name of the NotificationTemplate to use
- * @param sender the alert sender to use
- * @param notificationName the name of this notification
- * @param notificationConfiguration the configuration of this AlertNotification
- * @return the new AlertNotification
- */
- public AlertNotification addAlertNotificationToTemplate(Subject user, int templateId, String sender,
- String notificationName, Configuration notificationConfiguration) {
-
- AlertNotificationTemplate template = entityManager.find(AlertNotificationTemplate.class, templateId);
-
- entityManager.persist(notificationConfiguration);
- AlertNotification alertNotification = new AlertNotification(sender);
- alertNotification.setConfiguration(notificationConfiguration);
- alertNotification.setAlertNotificationTemplate(template);
- entityManager.persist(alertNotification);
- template.addNotification(alertNotification);
-
- return alertNotification;
-
- }
-
- public List<AlertNotification> getNotificationsForTemplate(Subject subject, int templateId) {
-
- AlertNotificationTemplate template = entityManager.find(AlertNotificationTemplate.class, templateId);
- if (template == null) {
- LOG.error("DId not find notification template for id [" + templateId + "]");
- return new ArrayList<AlertNotification>();
- }
-
- List<AlertNotification> notifications = template.getNotifications();
- for (AlertNotification notification : notifications) {
- notification.getConfiguration().getProperties().size(); // eager load
- }
-
- return notifications;
- }
-
- /**
- * Get all defined notification templates in the system along with their AlertNotifications
- * @param user Subject of the caller
- * @return List of all defined alert notification templates
- */
- @SuppressWarnings("unchecked")
- public List<AlertNotificationTemplate> listNotificationTemplates(Subject user) {
-
- Query q = entityManager.createNamedQuery(AlertNotificationTemplate.FIND_ALL);
- List<AlertNotificationTemplate> ret = q.getResultList();
-
- return ret;
- }
-
public AlertNotification getAlertNotification(Subject user, int alertNotificationId) {
AlertNotification notification = entityManager.find(AlertNotification.class, alertNotificationId);
- notification.getConfiguration().getProperties().size(); // eager load the alert properties
+ if (notification == null) {
+ return null;
+ }
+ if (notification.getConfiguration() != null) { // an "incomplete" notification might not have a config yet
+ notification.getConfiguration().getProperties().size(); // eager load the alert properties
+ }
return notification;
}
- public AlertNotificationTemplate getAlertNotificationTemplate(Subject user, int alertNotificationTemplateId) {
- AlertNotificationTemplate template = entityManager.find(AlertNotificationTemplate.class,
- alertNotificationTemplateId);
- template.getNotifications().size(); // eager load the children alert notifications
- return template;
- }
-
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
index 9db80cc..bfa4dbf 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
@@ -22,9 +22,7 @@ import java.util.List;
import javax.ejb.Local;
-import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
@@ -93,15 +91,6 @@ public interface AlertNotificationManagerLocal {
AlertSenderInfo getAlertInfoForSender(String shortName);
/**
- * Take the passed NotificationTemplate and apply its Notifications to the passed AlertDefinition
- * @param template NotificationTemplate to apply
- * @param def AlertDefinition to apply the template to
- * @param removeOldNotifications Shall old Notifications on the Definition be removed?
- */
- void applyNotificationTemplateToAlertDefinition(AlertNotificationTemplate template, AlertDefinition def,
- boolean removeOldNotifications);
-
- /**
* Return the backing bean for the AlertSender with the passed shortNama
* @param shortName name of a sender
* @param alertNotificationId
@@ -111,62 +100,5 @@ public interface AlertNotificationManagerLocal {
String getBackingBeanNameForSender(String shortName);
- /**
- * Create a new NotificationTemplate from the passed parameters. The passed AlertNotification objects need to have the
- * name and sender and any configuration properties already set; alert definitions must not be set.
- * @param name name of this notification template. Must be unique
- * @param description description of the template
- * @param notifications notifications that make up the template
- * @param copyNotifications
- * @return the newly created template
- * @throws IllegalArgumentException when a template with the passed name already exists
- */
- AlertNotificationTemplate createNotificationTemplate(String name, String description,
- List<AlertNotification> notifications, boolean copyNotifications) throws IllegalArgumentException;
-
- void updateNotificationTemplate(Subject subject, int templateId, String newName, String newDescription);
-
- /**
- * Get all defined notification templates in the system along with their AlertNotifications
- * @param user Subject of the caller
- * @return List of all defined alert notification templates
- */
- List<AlertNotificationTemplate> listNotificationTemplates(Subject user);
-
AlertNotification getAlertNotification(Subject user, int alertNotificationId);
-
- AlertNotificationTemplate getAlertNotificationTemplate(Subject user, int alertNotificationTemplateId);
-
- /**
- * Take the passed NotificationTemplate and apply its Notifications to the passed AlertDefinition
- * @param templateName name of a pre-defined alert NotificationTemplate
- * @param alertDefinitionId id of an AlertDefinition on which the template should be applied
- * @param removeOldNotifications Shall old Notifications on the Definition be removed?
- */
- void applyNotificationTemplateToAlertDefinition(String templateName, int alertDefinitionId,
- boolean removeOldNotifications);
-
- /**
- * Add a new alert Notification to a template
- * @param user subject of the caller
- * @param templateName name of the NotificationTemplate to use
- * @param sender the alert sender to use
- * @param notificationName the name of this notification
- * @param notificationConfiguration the configuration of this AlertNotification
- * @return the new AlertNotification
- */
- AlertNotification addAlertNotificationToTemplate(Subject user, int templateId, String sender,
- String notificationName, Configuration notificationConfiguration);
-
- int removeNotificationsFromTemplate(Subject subject, int templateId, Integer[] notificationIds);
-
- List<AlertNotification> getNotificationsForTemplate(Subject subject, int templateId);
-
- /**
- * Delete the passed Notification Templates
- * @param subject subject of the caller
- * @param templateIds ids of the templates to delete
- * @return number of templates deleted
- */
- int deleteNotificationTemplates(Subject subject, Integer[] templateIds);
}
14 years, 1 month
[rhq] 2 commits - modules/core modules/enterprise
by Joseph Marques
modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml | 10
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 39 -
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java | 15
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationTemplate.java | 177 --------
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/AlertNotificationTemplateDetailsUIBean.java | 90 ----
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/ListAlertNotificationTemplatesUIBean.java | 76 ---
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/NewAlertNotificationTemplateUIBean.java | 86 ---
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java | 4
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/DefinitionNotificationsUIBean.java | 105 ----
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/details.xhtml | 136 ------
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/list.xhtml | 146 ------
modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/new.xhtml | 74 ---
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml | 60 --
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java | 219 ----------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java | 68 ---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java | 7
16 files changed, 24 insertions(+), 1288 deletions(-)
New commits:
commit 33247dceb1a722507ae16190333ffe9f2b09180b
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 12:32:55 2010 -0400
fix NPE seen during very first recalculation of saved search result counts
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
index 0e015e3..db826de 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
@@ -67,7 +67,10 @@ public class SavedSearchResultCountRecalculationJob extends AbstractStatefulJob
PageList<Resource> results = resourceManager.findResourcesByCriteria(overlord, criteria);
totalMillis += System.currentTimeMillis();
- if (results.getTotalSize() != next.getResultCount()) {
+ // TODO: should recent count be computed at the time of update/save for this saved search?
+ // it would obviate the need for null checking here as well as in the UI for conditional
+ // display of the result count
+ if (next.getResultCount() == null || results.getTotalSize() != next.getResultCount()) {
next.setResultCount((long) results.getTotalSize());
savedSearchManager.updateSavedSearch(overlord, next);
updated++;
@@ -76,7 +79,7 @@ public class SavedSearchResultCountRecalculationJob extends AbstractStatefulJob
} catch (Throwable t) {
// TODO: mark this saved search as "broken" so that future computation is suppressed for it
errors++;
- LOG.error("Could not calculate result count for SavedSearch[name=" + next.getName() + ", patter='"
+ LOG.error("Could not calculate result count for SavedSearch[name=" + next.getName() + ", pattern='"
+ next.getPattern() + "']");
}
}
commit 8bdaceac79897f786743a3607f287581565c9b6d
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 12:32:37 2010 -0400
removal of alert notification templates
* charles explained they will not be released in their current form
* reuse occurs at the alert definitions level (resource/group/type), not a component thereof
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
index b2db5f0..145b8e2 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
@@ -119,16 +119,6 @@
</index>
</table>
- <table name="RHQ_ALERT_NOTIF_TEMPL" tablespace="@@@LARGE_TABLESPACE_FOR_DATA@@@"
- storage-options="freelists 5" cache="true" logging="false">
- <column name="ID" default="sequence-only" initial="10001"
- primarykey="true" required="true" type="INTEGER"/>
- <column name="CTIME" required="true" type="LONG"/>
- <column name="MTIME" required="true" type="LONG"/>
- <column name="NAME" required="true" size="100" type="VARCHAR2"/>
- <column name="DESCRIPTION" required="false" size="250" type="VARCHAR2"/>
- </table>
-
<table name="RHQ_ALERT_NOTIFICATION" tablespace="@@@LARGE_TABLESPACE_FOR_DATA@@@"
storage-options="freelists 5" cache="true" logging="false">
<column name="ID" default="sequence-only" initial="10001"
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index d028a43..d97a230 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2058,8 +2058,9 @@
<schemaSpec version="2.70">
<schema-addColumn table="RHQ_ALERT" column="ACK_TIME" columnType="LONG" />
- <!-- TODO: this needs to change to ack_subject_name -->
<schema-addColumn table="RHQ_ALERT" column="ACK_SUBJECT" precision="100" columnType="VARCHAR2" />
+ </schemaSpec>
+ <schemaSpec version="2.70.1">
<schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_NAME" precision="100" columnType="VARCHAR2" />
<schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_CONFIG_ID" columnType="INTEGER" />
<schema-directSQL>
@@ -2071,35 +2072,7 @@
</statement>
</schema-directSQL>
</schemaSpec>
- <schemaSpec version="2.70.1">
- <schema-createSequence name="RHQ_ALERT_NOTIF_TEMPL_ID_SEQ" initial="10001" />
- <schema-directSQL>
- <statement desc="Creating table RHQ_ALERT_NOTIF_TEMPL">
- CREATE TABLE RHQ_ALERT_NOTIF_TEMPL ( ID INTEGER PRIMARY KEY )
- </statement>
- </schema-directSQL>
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="ID" nullable="false" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="CTIME" columnType="LONG" />
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="CTIME" nullable="false" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="MTIME" columnType="LONG" />
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="MTIME" nullable="false" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="NAME" precision="100" columnType="VARCHAR2" />
- <schema-alterColumn table="RHQ_ALERT_NOTIF_TEMPL" column="NAME" nullable="false" />
- <schema-addColumn table="RHQ_ALERT_NOTIF_TEMPL" column="DESCRIPTION" precision="250" columnType="VARCHAR2" />
- </schemaSpec>
<schemaSpec version="2.70.2">
- <!-- add structures for alert notification templates -->
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="TEMPLATE_ID" columnType="INTEGER" />
- <schema-directSQL>
- <statement>
- ALTER TABLE RHQ_ALERT_NOTIFICATION
- ADD CONSTRAINT RHQ_AN_TEMPLATE_ID_FK
- FOREIGN KEY (TEMPLATE_ID)
- REFERENCES RHQ_ALERT_NOTIF_TEMPL (ID)
- </statement>
- </schema-directSQL>
- </schemaSpec>
- <schemaSpec version="2.70.3">
<!-- turn first-class notification data into configuration objects for custom alert senders -->
<schema-alterColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIFICATION_TYPE" nullable="TRUE" />
<schema-javaTask className="CustomAlertSenderUpgradeTask" />
@@ -2110,7 +2083,7 @@
</schema-directSQL>
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="NOTIFICATION_TYPE" />
</schemaSpec>
- <schemaSpec version="2.70.4">
+ <schemaSpec version="2.70.3">
<!-- remove first-class alert notification structures from definition side of the model-->
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_host" />
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="snmp_port" />
@@ -2120,19 +2093,19 @@
<schema-deleteColumn table="RHQ_ALERT_NOTIFICATION" column="subject_id" />
<schema-deleteColumn table="RHQ_ALERT_DEFINITION" column="operation_def_id" />
</schemaSpec>
- <schemaSpec version="2.70.5">
+ <schemaSpec version="2.70.4">
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="roles" />
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="subjects" />
<schema-deleteColumn table="RHQ_ALERT_NOTIF_LOG" column="emails" />
</schemaSpec>
- <schemaSpec version="2.70.6">
+ <schemaSpec version="2.70.5">
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="SENDER" columnType="VARCHAR2" precision="200" />
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="RESULT_STATE" columnType="VARCHAR2" precision="20" />
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="MESSAGE" columnType="VARCHAR2" precision="255" />
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="ALL_EMAILS" columnType="VARCHAR2" precision="4000" />
<schema-addColumn table="RHQ_ALERT_NOTIF_LOG" column="EMAILS_FAILED" columnType="VARCHAR2" precision="4000" />
</schemaSpec>
- <schemaSpec version="2.70.7">
+ <schemaSpec version="2.70.6">
<schema-directSQL>
<statement>
DROP INDEX RHQ_ALERT_IDX_ALERT
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
index b77d8b0..b9c0401 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
@@ -49,7 +49,7 @@ import org.rhq.core.domain.configuration.Configuration;
@NamedQueries( {
@NamedQuery(name = AlertNotification.DELETE_BY_ID, query = "DELETE FROM AlertNotification an WHERE an.id IN ( :ids )"),
@NamedQuery(name = AlertNotification.QUERY_DELETE_BY_RESOURCES, query = "DELETE FROM AlertNotification an WHERE an.alertDefinition IN ( SELECT ad FROM AlertDefinition ad WHERE ad.resource.id IN ( :resourceIds ) )"),
- @NamedQuery(name = AlertNotification.QUERY_DELETE_ORPHANED, query = "DELETE FROM AlertNotification an WHERE an.alertDefinition IS NULL AND an.alertNotificationTemplate IS NULL") })
+ @NamedQuery(name = AlertNotification.QUERY_DELETE_ORPHANED, query = "DELETE FROM AlertNotification an WHERE an.alertDefinition IS NULL") })
@SequenceGenerator(name = "RHQ_ALERT_NOTIFICATION_ID_SEQ", sequenceName = "RHQ_ALERT_NOTIFICATION_ID_SEQ")
@Table(name = "RHQ_ALERT_NOTIFICATION")
public class AlertNotification implements Serializable {
@@ -74,10 +74,6 @@ public class AlertNotification implements Serializable {
@ManyToOne
private AlertDefinition alertDefinition;
- @JoinColumn(name = "TEMPLATE_ID")
- @ManyToOne
- private AlertNotificationTemplate alertNotificationTemplate;
-
@JoinColumn(name = "SENDER_CONFIG_ID", referencedColumnName = "ID")
@OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
private Configuration configuration;
@@ -162,14 +158,6 @@ public class AlertNotification implements Serializable {
this.configuration = configuration;
}
- public AlertNotificationTemplate getAlertNotificationTemplate() {
- return alertNotificationTemplate;
- }
-
- public void setAlertNotificationTemplate(AlertNotificationTemplate alertNotificationTemplate) {
- this.alertNotificationTemplate = alertNotificationTemplate;
- }
-
public int getAlertDefinitionId() {
return alertDefinitionId;
}
@@ -185,7 +173,6 @@ public class AlertNotification implements Serializable {
sb.append("{alertDefinitionId=").append(alertDefinitionId);
sb.append(", alertNotificationId=").append(alertNotificationId);
sb.append(", id=").append(id);
- sb.append(", notificationTemplate=").append(alertNotificationTemplate);
sb.append(", senderName='").append(senderName).append('\'');
sb.append('}');
return sb.toString();
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationTemplate.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationTemplate.java
deleted file mode 100644
index df64a54..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotificationTemplate.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.core.domain.alert.notification;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.PrePersist;
-import javax.persistence.PreUpdate;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.Table;
-
-import org.rhq.core.domain.alert.AlertDefinition;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.group.ResourceGroup;
-
-/**
- * An {@link AlertNotificationTemplate} is a group of {@link AlertNotification}. This can be used to create
- * pre-configured sets of notifications which can then be applied to all types of {@link AlertDefinition}s -
- * those at the {@link Resource}-level, {@link ResourceGroup}-level, and {@link ResourceType}-level (a.k.a
- * Alert Template).
- *
- * @author Heiko W. Rupp
- */
-
-@NamedQueries( {
- @NamedQuery(name = AlertNotificationTemplate.FIND_BY_NAME, query = "SELECT t FROM AlertNotificationTemplate t WHERE t.name = :name"),
- @NamedQuery(name = AlertNotificationTemplate.FIND_ALL, query = "SELECT t FROM AlertNotificationTemplate AS t") })
-@Entity
-@Table(name = "RHQ_ALERT_NOTIF_TEMPL")
-@SequenceGenerator(name = "RHQ_ALERT_NOTIF_TEMPL_ID_SEQ", sequenceName = "RHQ_ALERT_NOTIF_TEMPL_ID_SEQ")
-public class AlertNotificationTemplate implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- public static final String FIND_BY_NAME = "AlertNotificationTemplate.findByName";
- public static final String FIND_ALL = "AlertNotificationTemplate.findAll";
-
- @Column(name = "ID", nullable = false)
- @GeneratedValue(generator = "RHQ_ALERT_NOTIF_TEMPL_ID_SEQ")
- @Id
- private int id;
-
- @Column(name = "CTIME")
- private long ctime;
-
- @Column(name = "MTIME")
- private long mtime;
-
- @Column(name = "NAME")
- private String name;
-
- @Column(name = "DESCRIPTION")
- private String description;
-
- @OneToMany(mappedBy = "alertNotificationTemplate", cascade = CascadeType.ALL)
- List<AlertNotification> notifications = new ArrayList<AlertNotification>();
-
- protected AlertNotificationTemplate() {
- // for JPA
- }
-
- public AlertNotificationTemplate(String name, String description) {
- this.name = name;
- this.description = description;
- }
-
- public int getId() {
- return this.id;
- }
-
- public long getCtime() {
- return ctime;
- }
-
- public long getMtime() {
- return mtime;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public List<AlertNotification> getNotifications() {
- return notifications;
- }
-
- public void setNotifications(List<AlertNotification> notifications) {
- this.notifications = notifications;
- }
-
- public List<AlertNotification> addNotification(AlertNotification notification) {
- this.notifications.add(notification);
- return this.notifications;
- }
-
- @PrePersist
- void onPersist() {
- this.mtime = this.ctime = System.currentTimeMillis();
- }
-
- @PreUpdate
- void onPreUpdate() {
- this.mtime = System.currentTimeMillis();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
-
- AlertNotificationTemplate that = (AlertNotificationTemplate) o;
-
- if (description != null ? !description.equals(that.description) : that.description != null)
- return false;
- return name.equals(that.name);
-
- }
-
- @Override
- public int hashCode() {
- int result = name.hashCode();
- result = 31 * result + (description != null ? description.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("NotificationTemplate");
- sb.append("{id=").append(id);
- sb.append(", name='").append(name).append('\'');
- sb.append(", description='").append(description).append('\'');
- sb.append('}');
- return sb.toString();
- }
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/AlertNotificationTemplateDetailsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/AlertNotificationTemplateDetailsUIBean.java
deleted file mode 100644
index c3bad26..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/AlertNotificationTemplateDetailsUIBean.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.admin.alert;
-
-import javax.faces.application.FacesMessage;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.enterprise.gui.common.framework.EnterpriseFacesContextUIBean;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-
-(a)Scope(ScopeType.PAGE)
-@Name("AlertNotificationTemplateDetailsUIBean")
-public class AlertNotificationTemplateDetailsUIBean extends EnterpriseFacesContextUIBean {
-
- @In
- private AlertNotificationManagerLocal alertNotificationManager;
-
- private AlertNotificationTemplate template;
-
- private void loadTemplate() {
- if (template == null) {
- int templateId = FacesContextUtility.getRequiredRequestParameter("templateId", Integer.class);
- template = alertNotificationManager.getAlertNotificationTemplate(getSubject(), templateId);
- }
- }
-
- public AlertNotificationTemplate getTemplate() {
- loadTemplate();
-
- return template;
- }
-
- public int getNotificationCount() {
- loadTemplate();
-
- return template.getNotifications().size();
- }
-
- public String edit() {
- return OUTCOME_EDIT;
- }
-
- public String editNotifications() {
- return OUTCOME_EDIT;
- }
-
- public String save() {
- try {
- alertNotificationManager.updateNotificationTemplate(getSubject(), template.getId(), template.getName(),
- template.getDescription());
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
- "Alert notification template was successfully modified.");
- } catch (Throwable t) {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
- "Error while saving alert notification template: " + t.getMessage());
- }
-
- return OUTCOME_SAVE;
- }
-
- public String cancel() {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
- "Alert notification template modifications were cancelled.");
-
- return OUTCOME_CANCELLED;
- }
-
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/ListAlertNotificationTemplatesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/ListAlertNotificationTemplatesUIBean.java
deleted file mode 100644
index dd63d29..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/ListAlertNotificationTemplatesUIBean.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.admin.alert;
-
-import java.util.List;
-
-import javax.faces.application.FacesMessage;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.util.PageControl;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.core.gui.util.StringUtility;
-import org.rhq.enterprise.gui.common.framework.EnterpriseFacesContextUIBean;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-
-(a)Scope(ScopeType.PAGE)
-@Name("ListAlertNotificationTemplatesUIBean")
-public class ListAlertNotificationTemplatesUIBean extends EnterpriseFacesContextUIBean {
-
- @In
- private AlertNotificationManagerLocal alertNotificationManager;
-
- public PageList<AlertNotificationTemplate> getAlertNotificationTemplates() {
- List<AlertNotificationTemplate> templates = alertNotificationManager.listNotificationTemplates(getSubject());
- return new PageList<AlertNotificationTemplate>(templates, new PageControl(0, templates.size()));
- }
-
- public String deleteSelectedAlertNotificationTemplates() {
- try {
- Subject subject = getSubject();
- String[] selectedNotificationTemplates = getSelectedNotificationTemplates();
- Integer[] selectedNotificationTemplateIds = StringUtility.getIntegerArray(selectedNotificationTemplates);
- int deleted = alertNotificationManager
- .deleteNotificationTemplates(subject, selectedNotificationTemplateIds);
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Deleted " + deleted
- + " alert notification templates");
- } catch (Throwable t) {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Deletion failed: " + t.getMessage());
- }
-
- return OUTCOME_SUCCESS;
- }
-
- public String createNewAlertNotificationTemplate() {
- return OUTCOME_CREATE;
- }
-
- private String[] getSelectedNotificationTemplates() {
- String[] results = FacesContextUtility.getRequest().getParameterValues("selectedNotificationTemplates");
- return results;
- }
-
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/NewAlertNotificationTemplateUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/NewAlertNotificationTemplateUIBean.java
deleted file mode 100644
index b2e0b07..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/alert/NewAlertNotificationTemplateUIBean.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.admin.alert;
-
-import java.util.ArrayList;
-
-import javax.faces.application.FacesMessage;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.enterprise.gui.common.framework.EnterpriseFacesContextUIBean;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-
-(a)Scope(ScopeType.PAGE)
-@Name("NewAlertNotificationTemplateUIBean")
-public class NewAlertNotificationTemplateUIBean extends EnterpriseFacesContextUIBean {
-
- @In
- private AlertNotificationManagerLocal alertNotificationManager;
-
- private String name;
- private String description;
-
- private int createdTemplateId; // will be set as a result of create(), used for JSF navigation rules
-
- public String create() {
- try {
- AlertNotificationTemplate template = alertNotificationManager.createNotificationTemplate(this.name,
- this.description, new ArrayList<AlertNotification>(), true);
- createdTemplateId = template.getId();
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Created new alert notification template");
- } catch (Throwable t) {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_ERROR, "Creation failed: " + t.getMessage());
- }
-
- return OUTCOME_SUCCESS;
- }
-
- public String cancel() {
- FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Template creation cancelled.");
- return OUTCOME_CANCELLED;
- }
-
- public int getCreatedTemplateId() {
- return createdTemplateId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
index 758383a..eb7d500 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/CustomContentUIBean.java
@@ -59,13 +59,15 @@ public class CustomContentUIBean extends EnterpriseFacesContextUIBean {
AlertNotification activeNotification = alertNotificationManager.getAlertNotification(getSubject(),
alertNotificationId);
+ if (activeNotification == null) {
+ return; // this was just removed on the previous request
+ }
String senderName = activeNotification.getSenderName();
AlertSenderInfo info = alertNotificationManager.getAlertInfoForSender(senderName);
if (info != null && info.getUiSnippetUrl() != null) {
this.contentUrl = info.getUiSnippetUrl().toString();
- //this.contentUrl = "rhq/custom/plugin/alert/" + senderName + "/" + info.getUiSnippetShortPath();
}
String backingBeanName = alertNotificationManager.getBackingBeanNameForSender(senderName);
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/DefinitionNotificationsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/DefinitionNotificationsUIBean.java
deleted file mode 100644
index 5b7cbeb..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/DefinitionNotificationsUIBean.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.alert.common;
-
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
-import org.rhq.core.gui.util.FacesContextUtility;
-import org.rhq.enterprise.gui.common.framework.EnterpriseFacesContextUIBean;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-
-(a)Scope(ScopeType.EVENT)
-@Name("definitionNotificationsUIBean")
-public class DefinitionNotificationsUIBean extends EnterpriseFacesContextUIBean {
-
- @In
- private AlertNotificationsUIBean alertNotificationsUIBean;
- @In
- private AlertNotificationManagerLocal alertNotificationManager;
-
- private String selectedTemplate;
- private Boolean clearExistingNotifications;
- private Map<String, String> notificationTemplates;
-
- public String getSelectedTemplate() {
- return selectedTemplate;
- }
-
- public void setSelectedTemplate(String selectedTemplate) {
- this.selectedTemplate = selectedTemplate;
- }
-
- public Boolean getClearExistingNotifications() {
- return clearExistingNotifications;
- }
-
- public void setClearExistingNotifications(Boolean clearExistingNotifications) {
- this.clearExistingNotifications = clearExistingNotifications;
- }
-
- public Map<String, String> getNotificationTemplates() {
- return this.notificationTemplates;
- }
-
- public String addAlertSenderFromTemplate() {
- int alertDefinitionId = FacesContextUtility.getRequiredRequestParameter("ad", Integer.class);
- this.alertNotificationManager.applyNotificationTemplateToAlertDefinition(getSelectedTemplate(),
- alertDefinitionId, getClearExistingNotifications());
- this.alertNotificationsUIBean.reloadAlertNotifications();
- return "success";
- }
-
- @Create
- public void init() {
- this.notificationTemplates = lookupNotificationTemplates();
- }
-
- private Map<String, String> lookupNotificationTemplates() {
- Map<String, String> result = new TreeMap<String, String>();
- List<AlertNotificationTemplate> templates = this.alertNotificationManager
- .listNotificationTemplates(getSubject());
-
- for (AlertNotificationTemplate template : templates) {
- String displayName = getNotificationDisplayName(template);
- result.put(displayName, template.getName()); // displayed text, option value
- }
-
- return result;
- }
-
- private String getNotificationDisplayName(AlertNotificationTemplate template) {
- StringBuilder builder = new StringBuilder(template.getName());
-
- builder.append(" (");
- builder.append(template.getDescription());
- builder.append(")");
-
- return builder.toString();
- }
-
-}
\ No newline at end of file
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/details.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/details.xhtml
deleted file mode 100644
index 69bfcb3..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/details.xhtml
+++ /dev/null
@@ -1,136 +0,0 @@
-<?xml version="1.0"?>
-
-<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:c="http://java.sun.com/jstl/core"
- xmlns:onc="http://jboss.org/on/component"
- xmlns:onf="http://jboss.org/on/function"
- xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
- xmlns:rich="http://richfaces.ajax4jsf.org/rich">
-
-<ui:composition template="/rhq/layout/main.xhtml">
-
- <ui:param name="pageTitle" value="Alert Notification Template Details"/>
-
- <ui:define name="breadcrumbs">
- <h:outputLink value="/rhq/admin/alert/template/notification/list.xhtml">
- <h:outputText value="Alert Notification Templates" />
- </h:outputLink>
- <h:outputText value=" > " />
- <h:outputLink value="/rhq/admin/alert/template/notification/details.xhtml">
- <f:param name="templateId" value="#{AlertNotificationTemplateDetailsUIBean.template.id}" />
- <f:param name="mode" value="view" />
- <h:outputText value="Details for '#{AlertNotificationTemplateDetailsUIBean.template.name}'" />
- </h:outputLink>
- </ui:define>
-
- <ui:define name="body">
-
- <ui:param name="mode" value="#{param.mode}" />
-
- <br/>
- <h:messages showDetail="true"
- globalOnly="true"
- infoClass="InfoBlock"
- warnClass="WarnBlock"
- errorClass="ErrorBlock"
- fatalClass="FatalBlock"
- layout="table" />
-
- <h:form id="alertNotificationTemplateDetailsForm">
-
- <input type="hidden" name="templateId" value="#{param.templateId}" />
- <input type="hidden" name="mode" value="#{param.mode}" />
-
- <rich:panel>
- <f:facet name="header">
- General Properties
- </f:facet>
- <table width="100%">
- <tr>
- <td align="right" style="white-space: no-wrap;"><b>Name<span class="required-marker-text">*</span>:</b></td>
- <td align="left">
- <h:inputText rendered="${mode eq 'edit'}" value="#{AlertNotificationTemplateDetailsUIBean.template.name}" />
- <h:outputText rendered="${mode ne 'edit'}" value="#{AlertNotificationTemplateDetailsUIBean.template.name}" />
- </td>
- </tr>
- <tr>
- <td align="right" style="white-space: no-wrap;"><b>Description:</b></td>
- <td align="left">
- <h:inputText rendered="${mode eq 'edit'}" value="#{AlertNotificationTemplateDetailsUIBean.template.description}" />
- <h:outputText rendered="${mode ne 'edit'}" value="#{AlertNotificationTemplateDetailsUIBean.template.description}" />
- </td>
- </tr>
- <tr>
- <td align="right" style="white-space: no-wrap;"><b>Date Created:</b></td>
- <td align="left">
- <h:outputText value="#{AlertNotificationTemplateDetailsUIBean.template.ctime}">
- <f:converter converterId="UserDateTimeConverter" />
- </h:outputText>
- </td>
- </tr>
- <tr>
- <td align="right" style="white-space: no-wrap;"><b>Last Modified:</b></td>
- <td align="left">
- <h:outputText value="#{AlertNotificationTemplateDetailsUIBean.template.mtime}">
- <f:converter converterId="UserDateTimeConverter" />
- </h:outputText>
- </td>
- </tr>
- </table>
- <h:panelGroup layout="block">
- <h:panelGrid columns="3" styleClass="buttons-table" columnClasses="button-cell" >
- <h:commandButton action="#{AlertNotificationTemplateDetailsUIBean.edit}"
- value="EDIT" styleClass="buttonmed" id="editPropertiesButton"
- rendered="${mode ne 'edit'}"/>
- <h:commandButton action="#{AlertNotificationTemplateDetailsUIBean.save}"
- value="SAVE" styleClass="buttonmed" id="saveButton"
- rendered="${mode eq 'edit'}"/>
- <h:commandButton action="#{AlertNotificationTemplateDetailsUIBean.cancel}"
- value="CANCEL" styleClass="buttonmed" id="cancelButton" immediate="true"
- rendered="${mode eq 'edit'}"/>
- </h:panelGrid>
- </h:panelGroup>
- </rich:panel>
- <br/>
- <rich:panel rendered="${mode ne 'edit'}">
- <f:facet name="header">
- Notification Actions
- </f:facet>
- <table width="100%">
- <tr>
- <td align="right" style="white-space: no-wrap;" width="20%"><b>Sender Info:</b></td>
- <td align="left">
- <h:outputText value="#{AlertNotificationTemplateDetailsUIBean.notificationCount} " />
- <h:outputText value="${msg['alert.current.detail.notify.Message']}" />
- </td>
- </tr>
- </table>
- <h:panelGroup layout="block">
- <h:panelGrid columns="3" styleClass="buttons-table" columnClasses="button-cell" >
- <h:commandButton action="#{AlertNotificationTemplateDetailsUIBean.editNotifications}"
- value="EDIT" styleClass="buttonmed" id="editNotificationsButton" />
- </h:panelGrid>
- </h:panelGroup>
- </rich:panel>
-
- <ui:remove>
- <ui:include src="/rhq/common/alert/notification/details.xhtml"
- rendered="${mode eq 'edit'}">
- <ui:param name="redirect" value="/rhq/admin/alert/template/notification/details.xhtml?mode=view&templateId=#{param.templateId}" />
- </ui:include>
- </ui:remove>
-
- </h:form>
-
- </ui:define>
-
-</ui:composition>
-
-</html>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/list.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/list.xhtml
deleted file mode 100644
index 3b2c868..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/list.xhtml
+++ /dev/null
@@ -1,146 +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:onc="http://jboss.org/on/component"
- xmlns:a4j="http://richfaces.org/a4j"
- xmlns:rich="http://richfaces.ajax4jsf.org/rich">
-
-<ui:composition template="/rhq/layout/main.xhtml">
-
- <ui:param name="pageTitle" value="List Alert Notification Templates"/>
-
- <ui:define name="metaHeaders">
- <style>
- #senderName {
- display: none;
- }
- </style>
- </ui:define>
-
- <ui:define name="breadcrumbs">
- <h:outputLink value="/rhq/admin/alert/template/notification/list.xhtml">
- <h:outputText value="Alert Notification Templates" />
- </h:outputLink>
- </ui:define>
-
- <ui:define name="body">
- <br/>
- <h:messages showDetail="true"
- globalOnly="true"
- infoClass="InfoBlock"
- warnClass="WarnBlock"
- errorClass="ErrorBlock"
- fatalClass="FatalBlock"
- layout="table" />
-
- <h:form id="listAlertNotificationTemplatesForm">
- <rich:panel>
- <f:facet name="header">
- <h:outputText value="Alert Notification Templates"/>
- </f:facet>
-
- <h:panelGrid columns="1" styleClass="data-table">
- <h:outputText value="*Templates are groups of notifications that can be applied to alert definitions en masse" />
- <br/>
-
- <ui:param name="notificationTemplateDataModel" value="#{ListAlertNotificationTemplatesUIBean.alertNotificationTemplates}"/>
- <rich:dataTable id="notificationTemplateDataModel"
- rows="0"
- value="#{notificationTemplateDataModel}"
- var="notificationTemplate"
- width="100%"
- columnsWidth="1%, 30%, 40%, 15%, 15%"
- styleClass="resources-table"
- headerClass="tableRowHeader"
- footerClass="on-pager-footer"
- onRowMouseOver="this.style.backgroundColor='#E7E7E7'"
- onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
-
- <f:facet name="PageControlView">
- <onc:paginationControl id="NONE" />
- </f:facet>
-
- <rich:column>
- <f:facet name="header">
- <onc:allSelect target="selectedNotificationTemplates" />
- </f:facet>
-
- <onc:select name="selectedNotificationTemplates" value="#{notificationTemplate.id}" />
- </rich:column>
-
- <rich:column>
- <f:facet name="header">
- <onc:sortableColumnHeader sort="name">
- <h:outputText styleClass="headerText" value="Name" />
- </onc:sortableColumnHeader>
- </f:facet>
-
- <h:outputLink value="/rhq/admin/alert/template/notification/details.xhtml">
- <f:param name="templateId" value="#{notificationTemplate.id}" />
- <f:param name="mode" value="view" />
- <h:outputText value="#{notificationTemplate.name}" />
- </h:outputLink>
- </rich:column>
-
- <rich:column>
- <f:facet name="header">
- <onc:sortableColumnHeader sort="description">
- <h:outputText styleClass="headerText" value="Description" />
- </onc:sortableColumnHeader>
- </f:facet>
-
- <h:outputText value="#{notificationTemplate.description}" />
- </rich:column>
-
- <rich:column>
- <f:facet name="header">
- <onc:sortableColumnHeader sort="ctime">
- <h:outputText styleClass="headerText" value="Created" />
- </onc:sortableColumnHeader>
- </f:facet>
-
- <h:outputText value="#{notificationTemplate.ctime}">
- <f:converter converterId="UserDateTimeConverter" />
- </h:outputText>
- </rich:column>
-
- <rich:column>
- <f:facet name="header">
- <onc:sortableColumnHeader sort="mtime">
- <h:outputText styleClass="headerText" value="Last Modified" />
- </onc:sortableColumnHeader>
- </f:facet>
-
- <h:outputText value="#{notificationTemplate.mtime}">
- <f:converter converterId="UserDateTimeConverter" />
- </h:outputText>
- </rich:column>
-
- <f:facet name="footer">
- <rich:columnGroup>
- <rich:column colspan="5" width="100%">
- <h:commandButton action="#{ListAlertNotificationTemplatesUIBean.createNewAlertNotificationTemplate}"
- value="CREATE NEW" styleClass="on-pager-button buttonsmall"
- rendered="#{GlobalPermissionsUIBean.inventory}" />
- <onc:selectCommandButton action="#{ListAlertNotificationTemplatesUIBean.deleteSelectedAlertNotificationTemplates}"
- value="DELETE SELECTED" target="selectedNotificationTemplates" styleClass="on-pager-button buttonsmall"
- rendered="#{GlobalPermissionsUIBean.inventory}" />
- </rich:column>
- </rich:columnGroup>
- </f:facet>
-
- <h:outputText value="Templates are groups of preconfigured alert notifications that can later be applied to alert definitions" />
-
- </rich:dataTable>
- </h:panelGrid>
- </rich:panel>
- </h:form>
-
- </ui:define>
-</ui:composition>
-
-</html>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/new.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/new.xhtml
deleted file mode 100644
index 25862c1..0000000
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/admin/alert/template/notification/new.xhtml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0"?>
-
-<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:c="http://java.sun.com/jstl/core"
- xmlns:onc="http://jboss.org/on/component"
- xmlns:onf="http://jboss.org/on/function"
- xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
- xmlns:rich="http://richfaces.ajax4jsf.org/rich">
-
-<ui:composition template="/rhq/layout/main.xhtml">
-
- <ui:param name="pageTitle" value="Create New Alert Notification Template"/>
-
- <ui:define name="breadcrumbs">
- <h:outputLink value="/rhq/admin/alert/template/notification/list.xhtml">
- <h:outputText value="Alert Notification Templates" />
- </h:outputLink>
- <h:outputText value=" > " />
- <h:outputLink value="/rhq/admin/alert/template/notification/new.xhtml">
- <h:outputText value="Create New" />
- </h:outputLink>
- </ui:define>
-
- <ui:define name="body">
-
- <h:form>
-
- <rich:panel>
-
- <f:facet name="header">
- General Properties
- </f:facet>
-
- <table>
- <tr>
- <td align="right"><b>Name<span class="required-marker-text">*</span>:</b></td>
- <td align="left">
- <h:inputText value="#{NewAlertNotificationTemplateUIBean.name}" size="60" maxlength="100" />
- </td>
- </tr>
- <tr>
- <td align="right"><b>Description:</b></td>
- <td align="left">
- <h:inputText value="#{NewAlertNotificationTemplateUIBean.description}" size="60" maxlength="250" />
- </td>
- </tr>
- </table>
-
- </rich:panel>
-
- <h:panelGroup layout="block" styleClass="BlockContent">
- <h:panelGrid columns="2" styleClass="buttons-table" columnClasses="button-cell">
- <h:commandButton action="#{NewAlertNotificationTemplateUIBean.create}"
- value="CREATE" styleClass="buttonmed"/>
- <h:commandButton action="#{NewAlertNotificationTemplateUIBean.cancel}"
- immediate="true"
- value="CANCEL" styleClass="buttonmed"/>
- </h:panelGrid>
- </h:panelGroup>
-
- </h:form>
-
- </ui:define>
-
-</ui:composition>
-
-</html>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
index 74b978e..0c25391 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
@@ -27,10 +27,8 @@
<ui:define name="body">
<a4j:keepAlive beanName="AlertNotificationContextUIBean" />
- <a4j:keepAlive beanName="alertNotificationStoreUIBean" />
<a4j:keepAlive beanName="alertNotificationsUIBean" />
<a4j:keepAlive beanName="customContentUIBean" />
- <a4j:keepAlive beanName="definitionNotificationsUIBean" />
<rich:panel id="existingAlertsPanel">
@@ -98,15 +96,6 @@
operation="show"
event="onclick" />
</h:outputLink>
- <ui:remove>
- <h:outputLink id="addAlertTemplateLink" styleClass="buttonmed" value="#" rendered="#{param.context ne 'template'}">
- <h:outputText value="Import Templates" />
- <rich:componentControl for="addAlertFromTemplatePanel"
- attachTo="addAlertTemplateLink"
- operation="show"
- event="onclick" />
- </h:outputLink>
- </ui:remove>
<h:commandButton id="removeAlertButton"
value="Remove Selected"
action="#{alertNotificationsUIBean.removeSelected}"
@@ -185,55 +174,6 @@
</h:form>
</rich:panel>
</rich:modalPanel>
-
-
- <rich:modalPanel id="addAlertFromTemplatePanel" moveable="false" autosized="true">
- <rich:panel id="importTemplatesPanel">
- <f:facet name="header">
- <h:outputText value="Import Notifications From Template" style="white-space: nowrap;"/>
- </f:facet>
-
- <h:form id="newNotificationsFromTemplateForm">
- <input type="hidden" name="ad" value="#{param.contextId}"/>
- <input type="hidden" name="context" value="#{param.context}"/>
- <input type="hidden" name="contextId" value="#{param.contextId}"/>
- <input type="hidden" name="contextSubId" value="#{param.contextSubId}"/>
-
- <rich:panel rendered="#{definitionNotificationsUIBean.notificationTemplates.size ne 0}">
- <div style="height: 100px;">
- <h:selectOneMenu id="templateList" value="#{definitionNotificationsUIBean.selectedTemplate}">
- <f:selectItems value="#{definitionNotificationsUIBean.notificationTemplates}"/>
- </h:selectOneMenu>
-
- <br/>
-
- <h:selectBooleanCheckbox title="clearExisting" value="#{definitionNotificationsUIBean.clearExistingNotifications}"/>
- <h:outputText value="Clear existing notifications"/>
- </div>
- </rich:panel>
-
- <rich:panel rendered="#{definitionNotificationsUIBean.notificationTemplates.size eq 0}">
- <div style="height: 100px;">
- No Alert Notification Templates have been defined yet.<br/>
- Please create some in Administration -> System Configuration -> Alert Notification Templates
- </div>
- </rich:panel>
-
- <h:panelGrid columns="4" styleClass="buttons-table" columnClasses="button-cell">
- <a4j:commandButton value="OK" action="#{definitionNotificationsUIBean.addAlertSenderFromTemplate}"
- styleClass="buttonmed" id="addTemplateButton"
- reRender="sendersList"
- rendered="#{definitionNotificationsUIBean.notificationTemplates.size ne 0}">
- <rich:componentControl for="addAlertFromTemplatePanel" attachTo="addTemplateButton" operation="hide" event="onclick" />
- </a4j:commandButton>
- <h:outputLink id="alertTemplateCancelLink" styleClass="buttonmed" value="#" style="float: right; margin: 10px;">
- <h:outputText value="Cancel" />
- <rich:componentControl for="addAlertFromTemplatePanel" attachTo="alertTemplateCancelLink" operation="hide" event="onclick" />
- </h:outputLink>
- </h:panelGrid>
- </h:form>
- </rich:panel>
- </rich:modalPanel>
</ui:define>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
index 0897dc7..3a9a56c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
@@ -27,7 +27,6 @@ import java.util.Set;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
-import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@@ -38,7 +37,6 @@ import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser;
import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.AlertDefinitionContext;
import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.configuration.Configuration;
@@ -48,7 +46,6 @@ import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
import org.rhq.enterprise.server.authz.PermissionException;
-import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.plugin.ServerPluginsLocal;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderInfo;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderPluginManager;
@@ -152,7 +149,9 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
try {
bb.internalCleanup();
} catch (Throwable t) {
- LOG.error("removeNotifications, calling backingBean.internalCleanup() resulted in " + t.getMessage());
+ LOG
+ .error("removeNotifications, calling backingBean.internalCleanup() resulted in " + t.getMessage(),
+ t);
}
}
@@ -163,30 +162,6 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
return removed;
}
- public int removeNotificationsFromTemplate(Subject subject, int templateId, Integer[] notificationIds) {
- if ((notificationIds == null) || (notificationIds.length == 0)) {
- return 0;
- }
-
- AlertNotificationTemplate templ = entityManager.find(AlertNotificationTemplate.class, templateId);
- Set<Integer> notificationIdSet = new HashSet<Integer>(Arrays.asList(notificationIds));
- List<AlertNotification> notifications = templ.getNotifications();
- List<AlertNotification> toBeRemoved = new ArrayList<AlertNotification>();
-
- int removed = 0;
- for (AlertNotification notification : notifications) {
- if (notificationIdSet.contains(notification.getId())) {
- toBeRemoved.add(notification);
- removed--;
- }
- }
-
- templ.getNotifications().removeAll(toBeRemoved);
-
- return removed;
-
- }
-
public int purgeOrphanedAlertNotifications() {
Query purgeQuery = entityManager.createNamedQuery(AlertNotification.QUERY_DELETE_ORPHANED);
return purgeQuery.executeUpdate();
@@ -350,191 +325,15 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
entityManager.flush();
}
- /**
- * Take the passed NotificationTemplate and apply its Notifications to the passed AlertDefinition
- * @param templateName name of a pre-defined alert NotificationTemplate
- * @param alertDefinitionId id of an AlertDefinition on which the template should be applied
- * @param removeOldNotifications Shall old Notifications on the Definition be removed?
- */
- public void applyNotificationTemplateToAlertDefinition(String templateName, int alertDefinitionId,
- boolean removeOldNotifications) {
-
- AlertNotificationTemplate template = getNotificationTemplateByName(templateName);
-
- AlertDefinition definition = getDetachedAlertDefinition(alertDefinitionId);
-
- applyNotificationTemplateToAlertDefinition(template, definition, removeOldNotifications);
- }
-
- private AlertNotificationTemplate getNotificationTemplateByName(String templateName) {
- Query q = entityManager.createNamedQuery(AlertNotificationTemplate.FIND_BY_NAME);
- q.setParameter("name", templateName);
- AlertNotificationTemplate template;
- try {
- template = (AlertNotificationTemplate) q.getSingleResult();
- } catch (NoResultException nre) {
- LOG.info("There is no alert notification template with name '" + templateName + "'");
- template = new AlertNotificationTemplate("dummy", null);
- }
- return template;
- }
-
- /**
- * Take the passed NotificationTemplate and apply its Notifications to the passed AlertDefinition
- * @param template NotificationTemplate to apply
- * @param def AlertDefinition to apply the template to
- * @param removeOldNotifications Shall old Notifications on the Definition be removed?
- */
- public void applyNotificationTemplateToAlertDefinition(AlertNotificationTemplate template, AlertDefinition def,
- boolean removeOldNotifications) {
-
- if (removeOldNotifications)
- def.getAlertNotifications().clear();
-
- for (AlertNotification notif : template.getNotifications()) {
- AlertNotification notification = new AlertNotification(notif, true);
- notification.setAlertDefinition(notif.getAlertDefinition());
- entityManager.persist(notification.getConfiguration());
- entityManager.persist(notification);
- def.addAlertNotification(notification); // Attach a copy, as the ones in the template should not be shared
- }
- }
-
- /**
- * Create a new NotificationTemplate from the passed parameters. The passed AlertNotification objects need to have the
- * name and sender and any configuration properties already set; alert definitions must not be set.
- * @param name name of this notification template. Must be unique
- * @param description description of the template
- * @param notifications notifications that make up the template
- * @param copyNotifications
- * @return the newly created template
- * @throws IllegalArgumentException when a template with the passed name already exists
- */
- @SuppressWarnings("unchecked")
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public AlertNotificationTemplate createNotificationTemplate(String name, String description,
- List<AlertNotification> notifications, boolean copyNotifications) throws IllegalArgumentException {
-
- Query q = entityManager.createNamedQuery(AlertNotificationTemplate.FIND_BY_NAME);
- q.setParameter("name", name);
- List<AlertNotificationTemplate> tmp = q.getResultList();
- if (tmp.size() > 0) {
- throw new IllegalArgumentException("AlertNotificationTemplate with name [" + name + "] already exists");
- }
-
- AlertNotificationTemplate templ = new AlertNotificationTemplate(name, description);
- entityManager.persist(templ);
- for (AlertNotification n : notifications) {
- if (copyNotifications) {
- // AlertNotification alNo = n.copyWithAlertDefintion() TODO implement / fix this
- } else {
- n.setAlertNotificationTemplate(templ);
- templ.addNotification(n);
- entityManager.persist(n);
- }
-
- }
- return templ;
- }
-
- @RequiredPermission(Permission.MANAGE_INVENTORY)
- public void updateNotificationTemplate(Subject subject, int templateId, String newName, String newDescription) {
- AlertNotificationTemplate template = getAlertNotificationTemplate(subject, templateId);
- template.setName(newName);
- template.setDescription(newDescription);
- entityManager.merge(template);
- }
-
- /**
- * Delete the passed Notification Templates
- * @param subject subject of the caller
- * @param templateIds ids of the templates to delete
- * @return number of templates deleted
- */
- public int deleteNotificationTemplates(Subject subject, Integer[] templateIds) {
- if (templateIds.length == 0)
- return 0;
-
- int num = 0;
- for (int id : templateIds) {
- AlertNotificationTemplate templ = entityManager.find(AlertNotificationTemplate.class, id);
- if (templ == null) {
- LOG.warn("No notification template found with id [" + id + "]");
- continue;
- }
- entityManager.remove(templ);
- num++;
- }
-
- return num;
- }
-
- /**
- * Add a new alert Notification to a template
- * @param user subject of the caller
- * @param templateName name of the NotificationTemplate to use
- * @param sender the alert sender to use
- * @param notificationName the name of this notification
- * @param notificationConfiguration the configuration of this AlertNotification
- * @return the new AlertNotification
- */
- public AlertNotification addAlertNotificationToTemplate(Subject user, int templateId, String sender,
- String notificationName, Configuration notificationConfiguration) {
-
- AlertNotificationTemplate template = entityManager.find(AlertNotificationTemplate.class, templateId);
-
- entityManager.persist(notificationConfiguration);
- AlertNotification alertNotification = new AlertNotification(sender);
- alertNotification.setConfiguration(notificationConfiguration);
- alertNotification.setAlertNotificationTemplate(template);
- entityManager.persist(alertNotification);
- template.addNotification(alertNotification);
-
- return alertNotification;
-
- }
-
- public List<AlertNotification> getNotificationsForTemplate(Subject subject, int templateId) {
-
- AlertNotificationTemplate template = entityManager.find(AlertNotificationTemplate.class, templateId);
- if (template == null) {
- LOG.error("DId not find notification template for id [" + templateId + "]");
- return new ArrayList<AlertNotification>();
- }
-
- List<AlertNotification> notifications = template.getNotifications();
- for (AlertNotification notification : notifications) {
- notification.getConfiguration().getProperties().size(); // eager load
- }
-
- return notifications;
- }
-
- /**
- * Get all defined notification templates in the system along with their AlertNotifications
- * @param user Subject of the caller
- * @return List of all defined alert notification templates
- */
- @SuppressWarnings("unchecked")
- public List<AlertNotificationTemplate> listNotificationTemplates(Subject user) {
-
- Query q = entityManager.createNamedQuery(AlertNotificationTemplate.FIND_ALL);
- List<AlertNotificationTemplate> ret = q.getResultList();
-
- return ret;
- }
-
public AlertNotification getAlertNotification(Subject user, int alertNotificationId) {
AlertNotification notification = entityManager.find(AlertNotification.class, alertNotificationId);
- notification.getConfiguration().getProperties().size(); // eager load the alert properties
+ if (notification == null) {
+ return null;
+ }
+ if (notification.getConfiguration() != null) { // an "incomplete" notification might not have a config yet
+ notification.getConfiguration().getProperties().size(); // eager load the alert properties
+ }
return notification;
}
- public AlertNotificationTemplate getAlertNotificationTemplate(Subject user, int alertNotificationTemplateId) {
- AlertNotificationTemplate template = entityManager.find(AlertNotificationTemplate.class,
- alertNotificationTemplateId);
- template.getNotifications().size(); // eager load the children alert notifications
- return template;
- }
-
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
index 9db80cc..bfa4dbf 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
@@ -22,9 +22,7 @@ import java.util.List;
import javax.ejb.Local;
-import org.rhq.core.domain.alert.AlertDefinition;
import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.alert.notification.AlertNotificationTemplate;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
@@ -93,15 +91,6 @@ public interface AlertNotificationManagerLocal {
AlertSenderInfo getAlertInfoForSender(String shortName);
/**
- * Take the passed NotificationTemplate and apply its Notifications to the passed AlertDefinition
- * @param template NotificationTemplate to apply
- * @param def AlertDefinition to apply the template to
- * @param removeOldNotifications Shall old Notifications on the Definition be removed?
- */
- void applyNotificationTemplateToAlertDefinition(AlertNotificationTemplate template, AlertDefinition def,
- boolean removeOldNotifications);
-
- /**
* Return the backing bean for the AlertSender with the passed shortNama
* @param shortName name of a sender
* @param alertNotificationId
@@ -111,62 +100,5 @@ public interface AlertNotificationManagerLocal {
String getBackingBeanNameForSender(String shortName);
- /**
- * Create a new NotificationTemplate from the passed parameters. The passed AlertNotification objects need to have the
- * name and sender and any configuration properties already set; alert definitions must not be set.
- * @param name name of this notification template. Must be unique
- * @param description description of the template
- * @param notifications notifications that make up the template
- * @param copyNotifications
- * @return the newly created template
- * @throws IllegalArgumentException when a template with the passed name already exists
- */
- AlertNotificationTemplate createNotificationTemplate(String name, String description,
- List<AlertNotification> notifications, boolean copyNotifications) throws IllegalArgumentException;
-
- void updateNotificationTemplate(Subject subject, int templateId, String newName, String newDescription);
-
- /**
- * Get all defined notification templates in the system along with their AlertNotifications
- * @param user Subject of the caller
- * @return List of all defined alert notification templates
- */
- List<AlertNotificationTemplate> listNotificationTemplates(Subject user);
-
AlertNotification getAlertNotification(Subject user, int alertNotificationId);
-
- AlertNotificationTemplate getAlertNotificationTemplate(Subject user, int alertNotificationTemplateId);
-
- /**
- * Take the passed NotificationTemplate and apply its Notifications to the passed AlertDefinition
- * @param templateName name of a pre-defined alert NotificationTemplate
- * @param alertDefinitionId id of an AlertDefinition on which the template should be applied
- * @param removeOldNotifications Shall old Notifications on the Definition be removed?
- */
- void applyNotificationTemplateToAlertDefinition(String templateName, int alertDefinitionId,
- boolean removeOldNotifications);
-
- /**
- * Add a new alert Notification to a template
- * @param user subject of the caller
- * @param templateName name of the NotificationTemplate to use
- * @param sender the alert sender to use
- * @param notificationName the name of this notification
- * @param notificationConfiguration the configuration of this AlertNotification
- * @return the new AlertNotification
- */
- AlertNotification addAlertNotificationToTemplate(Subject user, int templateId, String sender,
- String notificationName, Configuration notificationConfiguration);
-
- int removeNotificationsFromTemplate(Subject subject, int templateId, Integer[] notificationIds);
-
- List<AlertNotification> getNotificationsForTemplate(Subject subject, int templateId);
-
- /**
- * Delete the passed Notification Templates
- * @param subject subject of the caller
- * @param templateIds ids of the templates to delete
- * @return number of templates deleted
- */
- int deleteNotificationTemplates(Subject subject, Integer[] templateIds);
}
14 years, 1 month
[rhq] Branch 'gwt' - 8 commits - etc/modules modules/common modules/core modules/enterprise
by Jay Shaughnessy
etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.htmf | 70
etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.js | 42
etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/news.js | 380 +-
etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/rss.js | 220 -
etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/scroller.js | 1286 +++++-----
etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/styles.css | 260 +-
etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/tag.css | 94
modules/common/ant-bundle/src/main/assembly/bin/antenv.cmd | 196 -
modules/common/ant-bundle/src/main/assembly/bin/envset.cmd | 262 +-
modules/common/ant-bundle/src/main/assembly/bin/lcp.bat | 62
modules/common/ant-bundle/src/main/assembly/bin/rhq-ant.cmd | 186 -
modules/common/ant-bundle/src/main/assembly/bin/runrc.cmd | 120
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionEnumeration.java | 16
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java | 20
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java | 54
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java | 321 +-
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java | 4
17 files changed, 1811 insertions(+), 1782 deletions(-)
New commits:
commit 9fa35dd554222f3cb759ce59d61fde91c9501f95
Merge: 1c237ab... d6312fc...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 12:21:28 2010 -0400
Merge branch 'gwt-jay' into gwt
commit 1c237ab33221d8dda952f581f5b8ace1a72cbd02
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 12:21:19 2010 -0400
LT commit
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.htmf b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.htmf
index 8a3a4b3..b207a5a 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.htmf
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.htmf
@@ -1,36 +1,36 @@
-<!-- Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
-$Id: main.htmf,v 1.3 2006/05/03 22:00:33 inder Exp $ -->
-
- <table valign="top" id="bodyTable" border="0">
- <tr>
- <td>
- <map name="petmap">
- <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('BIRDS')"
- alt="Birds"
- coords="72,2,280,250">
- <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('FISH')"
- alt="Fish"
- coords="2,180,72,250">
- <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('DOGS')"
- alt="Dogs"
- coords="60,250,130,320">
- <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('REPTILES')"
- alt="Reptiles"
- coords="140,270,210,340">
- <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('CATS')"
- alt="Cats"
- coords="225,240,295,310">
- <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('BIRDS')"
- alt="Birds"
- coords="280,180,350,250">
- </map>
-
- <img src="images/splash.gif"
- alt="Pet Selection Map"
- usemap="#petmap"
- width="350"
- height="355"
- border="0">
- </td>
- </tr>
+<!-- Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
+$Id: main.htmf,v 1.3 2006/05/03 22:00:33 inder Exp $ -->
+
+ <table valign="top" id="bodyTable" border="0">
+ <tr>
+ <td>
+ <map name="petmap">
+ <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('BIRDS')"
+ alt="Birds"
+ coords="72,2,280,250">
+ <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('FISH')"
+ alt="Fish"
+ coords="2,180,72,250">
+ <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('DOGS')"
+ alt="Dogs"
+ coords="60,250,130,320">
+ <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('REPTILES')"
+ alt="Reptiles"
+ coords="140,270,210,340">
+ <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('CATS')"
+ alt="Cats"
+ coords="225,240,295,310">
+ <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('BIRDS')"
+ alt="Birds"
+ coords="280,180,350,250">
+ </map>
+
+ <img src="images/splash.gif"
+ alt="Pet Selection Map"
+ usemap="#petmap"
+ width="350"
+ height="355"
+ border="0">
+ </td>
+ </tr>
</table>
\ No newline at end of file
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.js
index c0a175d..b8de8fc 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.js
@@ -1,21 +1,21 @@
-/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
-$Id: main.js,v 1.9 2006/05/03 22:00:33 inder Exp $ */
-
-var isIE;
-var bodyRowText;
-
-dojo.require("dojo.widget.FisheyeList");
-init();
-
-function browse(category) {
- window.location.href="catalog.jsp?catid=" + category;
-}
-
-function loadPetstore() {
- init();
- showMain();
-}
-
-function init() {
- if (navigator.userAgent.indexOf("IE") != -1) isIE = true;
-}
+/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
+$Id: main.js,v 1.9 2006/05/03 22:00:33 inder Exp $ */
+
+var isIE;
+var bodyRowText;
+
+dojo.require("dojo.widget.FisheyeList");
+init();
+
+function browse(category) {
+ window.location.href="catalog.jsp?catid=" + category;
+}
+
+function loadPetstore() {
+ init();
+ showMain();
+}
+
+function init() {
+ if (navigator.userAgent.indexOf("IE") != -1) isIE = true;
+}
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/news.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/news.js
index 29bf8cf..5bcac34 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/news.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/news.js
@@ -1,190 +1,190 @@
-
-dojo.require("dojo.io.*");
-dojo.require("dojo.event.*");
-
-var bpuinews;
-if (typeof bpuinews == "undefined") {
- bpuinews = new Object();
-}
-
-bpuinews.RSS = function() {
- var currentItem = 0;
- var limitCharNum = 75;
- var itemNum=0;
- var rssData = null;
- var prev;
- var next;
- var prevHit=false;
-
- this.getRssInJson = function (method, uri) {
- prev = document.getElementById("previous");
- next = document.getElementById("next");
- dojo.event.connect(prev, "onclick", function(evt) {showPrevious();});
- dojo.event.connect(next, "onclick", function (evt) {showNext();});
- prev.disabled=true;
-
- var encodedURI = encodeURI(method + "?style=json&itemCount=0&url="+uri);
- var bindArgs = {
- url: encodedURI,
- mimetype: "text/json",
- load: function (type, data, http) {
- handleJsonRss(data);
- },
- error: function (t, e) {
- dojo.debug("ERROR : " + e.message);
- }
- }
- dojo.io.bind(bindArgs);
- return false;
- }
-
- function handleJsonRss(json) {
- rssData = json;
- itemNum = json.channel.item.length;
- showNext();
- }
-
- function createUl(skip) {
- var i;
- var cp="<ul>\n";
- for (i = currentItem; i<currentItem + skip; i++) {
- cp += "<li><b>"+decodeURL(rssData.channel.item[i].title)+"</b>\n";
- cp += "<p>" + decodeURL(rssData.channel.item[i].description) + "</p>\n</li>\n";
- }
- cp += "</ul>\n";
- return cp;
- }
-
- // Following funcs(showNext, showPrevious) should be connected to the button
- // by dojo.event.connect.
- function showNext() {
- var skip = 5;
- if (prevHit) {
- currentItem = currentItem + skip;
- prevHit = false;
- }
- var nextCurrentItem = currentItem + skip;
- if (nextCurrentItem >= itemNum) {
- skip = itemNum - currentItem;
- // deactivate "next" button
- next.disabled=true;
- nextCurrentItem = currentItem;
- }
- // activate "previous" button
- if (currentItem != 0) {
- prev.disabled=false;
- }
- var cp = createUl(skip);
- var elm = document.getElementById("news");
- elm.innerHTML = cp;
- currentItem = nextCurrentItem;
- }
-
- function showPrevious() {
- prevHit = true;
- var skip = 5;
- currentItem = currentItem - skip;
- if (currentItem <= 0) {
- currentItem = 0;
- // deactivate "previous" button
- prev.disabled=true;
- }
- next.disabled=false;
- var cp = createUl(skip);
- var elm = document.getElementById("news");
- elm.innerHTML = cp;
- }
-
-
- /* Compatible function to java.net.URLDecoder.decode().
- * (decodeURI() is not compatible)
- */
- function decodeURL(str){
- var targetStr="";
- var s, tmpStr, unicode, f;
- // take a look at every char in the source str
- var i, j;
- for (i = 0; i < str.length; i++) {
- s = str.charAt(i);
- // handle WS, which is the most common char
- if (s == "+") {
- targetStr += " ";
- } else {
- if (s != "%") {
- // Non-encoded char
- targetStr += s;
- } else{
- // encoding begin
- unicode = 0; // uncode representation
- f = 1; // flag to specify the escape sequence
- while (true) {
- tmpStr = "";
- // get the two HEX chars and put that in the temp string. If no char, that is not a HEX.
- for (j = 0; j < 2; j++ ) {
- tmptmpStr = str.charAt(++i);
- if (((tmptmpStr >= "0") && (tmptmpStr <= "9")) ||
- ((tmptmpStr >= "a") && (tmptmpStr <= "f")) ||
- ((tmptmpStr >= "A") && (tmptmpStr <= "F"))) {
- tmpStr += tmptmpStr;
- } else {
- --i;
- break;
- }
- }
- /* parse the HEX
- * <= 0x7f : Single byte
- * >=0xc0 && <=0xdf : Two bytes
- * >=0xe0 && <=0xef : Three bytes
- * >=0xf0 && <=0xf7 : Four bytes
- * >=0x80 && <=0xbf : may not occur - just shift it
- * <=1 : sequence terminated
- */
- var byte = parseInt(tmpStr, 16);
- if (byte <= 0x7f) {unicode = byte; f = 1;}
- if ((byte >= 0xc0) && (byte <= 0xdf)) {unicode = byte & 0x1f; f = 2;}
- if ((byte >= 0xe0) && (byte <= 0xef)) {unicode = byte & 0x0f; f = 3;}
- if ((byte >= 0xf0) && (byte <= 0xf7)) {unicode = byte & 0x07; f = 4;}
- if ((byte >= 0x80) && (byte <= 0xbf)) {unicode = (unicode << 6) + (byte & 0x3f); --f;}
- if (f <= 1) {
- break;
- }
- if (str.charAt(i + 1) == "%") {
- i++ ;
- } else {
- // Error. should not occur
- break;
- }
- }
- targetStr += String.fromCharCode(unicode);
- }
- }
- }
- return targetStr;
- }
-
- /* Cut the string at the WS so that it's shorter than the limitCharNum.
- */
- function cutStringatWs(str, limitCharNum) {
- var tmpStr = str;
- var cnum = 0;
- while (true) {
- cnum = tmpStr.lastIndexOf(" ");
- // no occurance of WS
- if (cnum < 0) {
- // if str is still longer than limit
- if (tmpStr.length >= limitCharNum) {
- tmpStr = tmpStr.substring(0, limitCharNum);
- }
- break;
- } else {
- tmpStr = tmpStr.substring(0, cnum);
- if (cnum <= limitCharNum) {
- break;
- }
- }
- }
- return tmpStr;
- }
-
-}
-
+
+dojo.require("dojo.io.*");
+dojo.require("dojo.event.*");
+
+var bpuinews;
+if (typeof bpuinews == "undefined") {
+ bpuinews = new Object();
+}
+
+bpuinews.RSS = function() {
+ var currentItem = 0;
+ var limitCharNum = 75;
+ var itemNum=0;
+ var rssData = null;
+ var prev;
+ var next;
+ var prevHit=false;
+
+ this.getRssInJson = function (method, uri) {
+ prev = document.getElementById("previous");
+ next = document.getElementById("next");
+ dojo.event.connect(prev, "onclick", function(evt) {showPrevious();});
+ dojo.event.connect(next, "onclick", function (evt) {showNext();});
+ prev.disabled=true;
+
+ var encodedURI = encodeURI(method + "?style=json&itemCount=0&url="+uri);
+ var bindArgs = {
+ url: encodedURI,
+ mimetype: "text/json",
+ load: function (type, data, http) {
+ handleJsonRss(data);
+ },
+ error: function (t, e) {
+ dojo.debug("ERROR : " + e.message);
+ }
+ }
+ dojo.io.bind(bindArgs);
+ return false;
+ }
+
+ function handleJsonRss(json) {
+ rssData = json;
+ itemNum = json.channel.item.length;
+ showNext();
+ }
+
+ function createUl(skip) {
+ var i;
+ var cp="<ul>\n";
+ for (i = currentItem; i<currentItem + skip; i++) {
+ cp += "<li><b>"+decodeURL(rssData.channel.item[i].title)+"</b>\n";
+ cp += "<p>" + decodeURL(rssData.channel.item[i].description) + "</p>\n</li>\n";
+ }
+ cp += "</ul>\n";
+ return cp;
+ }
+
+ // Following funcs(showNext, showPrevious) should be connected to the button
+ // by dojo.event.connect.
+ function showNext() {
+ var skip = 5;
+ if (prevHit) {
+ currentItem = currentItem + skip;
+ prevHit = false;
+ }
+ var nextCurrentItem = currentItem + skip;
+ if (nextCurrentItem >= itemNum) {
+ skip = itemNum - currentItem;
+ // deactivate "next" button
+ next.disabled=true;
+ nextCurrentItem = currentItem;
+ }
+ // activate "previous" button
+ if (currentItem != 0) {
+ prev.disabled=false;
+ }
+ var cp = createUl(skip);
+ var elm = document.getElementById("news");
+ elm.innerHTML = cp;
+ currentItem = nextCurrentItem;
+ }
+
+ function showPrevious() {
+ prevHit = true;
+ var skip = 5;
+ currentItem = currentItem - skip;
+ if (currentItem <= 0) {
+ currentItem = 0;
+ // deactivate "previous" button
+ prev.disabled=true;
+ }
+ next.disabled=false;
+ var cp = createUl(skip);
+ var elm = document.getElementById("news");
+ elm.innerHTML = cp;
+ }
+
+
+ /* Compatible function to java.net.URLDecoder.decode().
+ * (decodeURI() is not compatible)
+ */
+ function decodeURL(str){
+ var targetStr="";
+ var s, tmpStr, unicode, f;
+ // take a look at every char in the source str
+ var i, j;
+ for (i = 0; i < str.length; i++) {
+ s = str.charAt(i);
+ // handle WS, which is the most common char
+ if (s == "+") {
+ targetStr += " ";
+ } else {
+ if (s != "%") {
+ // Non-encoded char
+ targetStr += s;
+ } else{
+ // encoding begin
+ unicode = 0; // uncode representation
+ f = 1; // flag to specify the escape sequence
+ while (true) {
+ tmpStr = "";
+ // get the two HEX chars and put that in the temp string. If no char, that is not a HEX.
+ for (j = 0; j < 2; j++ ) {
+ tmptmpStr = str.charAt(++i);
+ if (((tmptmpStr >= "0") && (tmptmpStr <= "9")) ||
+ ((tmptmpStr >= "a") && (tmptmpStr <= "f")) ||
+ ((tmptmpStr >= "A") && (tmptmpStr <= "F"))) {
+ tmpStr += tmptmpStr;
+ } else {
+ --i;
+ break;
+ }
+ }
+ /* parse the HEX
+ * <= 0x7f : Single byte
+ * >=0xc0 && <=0xdf : Two bytes
+ * >=0xe0 && <=0xef : Three bytes
+ * >=0xf0 && <=0xf7 : Four bytes
+ * >=0x80 && <=0xbf : may not occur - just shift it
+ * <=1 : sequence terminated
+ */
+ var byte = parseInt(tmpStr, 16);
+ if (byte <= 0x7f) {unicode = byte; f = 1;}
+ if ((byte >= 0xc0) && (byte <= 0xdf)) {unicode = byte & 0x1f; f = 2;}
+ if ((byte >= 0xe0) && (byte <= 0xef)) {unicode = byte & 0x0f; f = 3;}
+ if ((byte >= 0xf0) && (byte <= 0xf7)) {unicode = byte & 0x07; f = 4;}
+ if ((byte >= 0x80) && (byte <= 0xbf)) {unicode = (unicode << 6) + (byte & 0x3f); --f;}
+ if (f <= 1) {
+ break;
+ }
+ if (str.charAt(i + 1) == "%") {
+ i++ ;
+ } else {
+ // Error. should not occur
+ break;
+ }
+ }
+ targetStr += String.fromCharCode(unicode);
+ }
+ }
+ }
+ return targetStr;
+ }
+
+ /* Cut the string at the WS so that it's shorter than the limitCharNum.
+ */
+ function cutStringatWs(str, limitCharNum) {
+ var tmpStr = str;
+ var cnum = 0;
+ while (true) {
+ cnum = tmpStr.lastIndexOf(" ");
+ // no occurance of WS
+ if (cnum < 0) {
+ // if str is still longer than limit
+ if (tmpStr.length >= limitCharNum) {
+ tmpStr = tmpStr.substring(0, limitCharNum);
+ }
+ break;
+ } else {
+ tmpStr = tmpStr.substring(0, cnum);
+ if (cnum <= limitCharNum) {
+ break;
+ }
+ }
+ }
+ return tmpStr;
+ }
+
+}
+
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/rss.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/rss.js
index 3458b06..66700d3 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/rss.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/rss.js
@@ -1,110 +1,110 @@
-/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
-$Id: rss.js,v 1.3 2006/05/31 19:13:03 basler Exp $ */
-
-dojo.require("dojo.io.*");
-
-if (bpui = 'undefined') {
- bpui = new Object();
-}
-
-bpui.RSS = function() {
- var jsonData = null;
- var rssItemNum = 0;
- var currentItem = 0;
- var rssTimeout = null;
- var itemIntervalMsec = 2000;
- var rssFadeoutCounter = 110;
- var rssFadeinCounter = 110;
- var itemIntervalId = 0;
-
- this.getRssInJson = function (uri, number) {
- rssItemNum = number;
- var encodedURI = encodeURI(bpui.contextRoot + "/faces/dynamic/bpui_rssfeedhandler/getRssfeed?style=json&itemNumber="+number+"&url="+uri);
- //alert("encoded url=" + encodedURI);
- var bindArgs = {
- url: encodedURI,
- mimetype: "text/json",
- load: function (type, data, http) {
- handleJsonRss(data);
- for (var key in data.channel.item) {
- dojo.debug("ITEM Title ", key, ":", data.channel.item[key].title);
- dojo.debug("ITEM LInk ", key, ":", data.channel.item[key].link);
- }
- },
- error: function (t, e) {
- dj_debug("ERROR : " + e.message);
- }
- }
- dojo.io.bind(bindArgs);
- return false;
- }
-
- function handleJsonRss(json) {
- jsonData = json;
- // setting top title and link
- generateHref(json.channel.title, json.channel.link, "rss-channel");
- // setting items
- generateHref(json.channel.item[0].title, json.channel.item[0].link, "rss-item");
- var aNodes = document.getElementById("rss-item").getElementsByTagName("a");
- dojo.event.connect(aNodes[0], "onmouseover", "pauseCycle");
- dojo.event.connect(aNodes[0], "onmouseout", "resumeCycle");
- cycleRss();
- }
-
- function generateHref (title, link, nodeId) {
- var node = document.getElementById(nodeId);
- var aNode = document.createElement("a");
- aNode.setAttribute("href", link);
- aNode.appendChild(document.createTextNode(title));
- if (node.hasChildNodes()) {
- node.removeChild(node.firstChild);
- }
- node.appendChild(aNode);
- }
-
- function cycleRss () {
- itemIntervalId = setTimeout(replaceItem, itemIntervalMsec);
- }
-
-
- function replaceItem() {
- if (itemIntervalId) {
- clearTimeout(itemIntervalId);
- }
- // fadeout the current item and pop the next one in.
- var cItem = document.getElementById("rss-item");
- dojo.fx.html.fadeOut(cItem.getElementsByTagName('a')[0], 500);
- var waitId = setTimeout(function(waitId) {
- clearTimeout(waitId);
- //cItem.removeChild(cItem.firstChild);
- if (currentItem < (rssItemNum -1)) {
- currentItem += 1;
- } else {
- currentItem = 0;
- }
- generateHref(jsonData.channel.item[currentItem].title, jsonData.channel.item[currentItem].link, "rss-item");
- // attach event for onmouseover(pause) and onmouseout(resume)
- var aNodes = cItem.getElementsByTagName("a");
- dojo.event.connect(aNodes[0], "onmouseover", "pauseCycle");
- dojo.event.connect(aNodes[0], "onmouseout", "resumeCycle");
- cycleRss();}, 500);
- }
-
- function pauseCycle(evt) {
- if (itemIntervalId) {
- clearTimeout(itemIntervalId);
- }
- }
-
- function resumeCycle (evt) {
- cycleRss();
- }
-
- bpui.getContextRoot = function() {
- var urlArray=window.location.toString().split("/", 4);
- return "/" + urlArray[3];
- }
-
- bpui.contextRoot = bpui.getContextRoot();
-}
-
+/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
+$Id: rss.js,v 1.3 2006/05/31 19:13:03 basler Exp $ */
+
+dojo.require("dojo.io.*");
+
+if (bpui = 'undefined') {
+ bpui = new Object();
+}
+
+bpui.RSS = function() {
+ var jsonData = null;
+ var rssItemNum = 0;
+ var currentItem = 0;
+ var rssTimeout = null;
+ var itemIntervalMsec = 2000;
+ var rssFadeoutCounter = 110;
+ var rssFadeinCounter = 110;
+ var itemIntervalId = 0;
+
+ this.getRssInJson = function (uri, number) {
+ rssItemNum = number;
+ var encodedURI = encodeURI(bpui.contextRoot + "/faces/dynamic/bpui_rssfeedhandler/getRssfeed?style=json&itemNumber="+number+"&url="+uri);
+ //alert("encoded url=" + encodedURI);
+ var bindArgs = {
+ url: encodedURI,
+ mimetype: "text/json",
+ load: function (type, data, http) {
+ handleJsonRss(data);
+ for (var key in data.channel.item) {
+ dojo.debug("ITEM Title ", key, ":", data.channel.item[key].title);
+ dojo.debug("ITEM LInk ", key, ":", data.channel.item[key].link);
+ }
+ },
+ error: function (t, e) {
+ dj_debug("ERROR : " + e.message);
+ }
+ }
+ dojo.io.bind(bindArgs);
+ return false;
+ }
+
+ function handleJsonRss(json) {
+ jsonData = json;
+ // setting top title and link
+ generateHref(json.channel.title, json.channel.link, "rss-channel");
+ // setting items
+ generateHref(json.channel.item[0].title, json.channel.item[0].link, "rss-item");
+ var aNodes = document.getElementById("rss-item").getElementsByTagName("a");
+ dojo.event.connect(aNodes[0], "onmouseover", "pauseCycle");
+ dojo.event.connect(aNodes[0], "onmouseout", "resumeCycle");
+ cycleRss();
+ }
+
+ function generateHref (title, link, nodeId) {
+ var node = document.getElementById(nodeId);
+ var aNode = document.createElement("a");
+ aNode.setAttribute("href", link);
+ aNode.appendChild(document.createTextNode(title));
+ if (node.hasChildNodes()) {
+ node.removeChild(node.firstChild);
+ }
+ node.appendChild(aNode);
+ }
+
+ function cycleRss () {
+ itemIntervalId = setTimeout(replaceItem, itemIntervalMsec);
+ }
+
+
+ function replaceItem() {
+ if (itemIntervalId) {
+ clearTimeout(itemIntervalId);
+ }
+ // fadeout the current item and pop the next one in.
+ var cItem = document.getElementById("rss-item");
+ dojo.fx.html.fadeOut(cItem.getElementsByTagName('a')[0], 500);
+ var waitId = setTimeout(function(waitId) {
+ clearTimeout(waitId);
+ //cItem.removeChild(cItem.firstChild);
+ if (currentItem < (rssItemNum -1)) {
+ currentItem += 1;
+ } else {
+ currentItem = 0;
+ }
+ generateHref(jsonData.channel.item[currentItem].title, jsonData.channel.item[currentItem].link, "rss-item");
+ // attach event for onmouseover(pause) and onmouseout(resume)
+ var aNodes = cItem.getElementsByTagName("a");
+ dojo.event.connect(aNodes[0], "onmouseover", "pauseCycle");
+ dojo.event.connect(aNodes[0], "onmouseout", "resumeCycle");
+ cycleRss();}, 500);
+ }
+
+ function pauseCycle(evt) {
+ if (itemIntervalId) {
+ clearTimeout(itemIntervalId);
+ }
+ }
+
+ function resumeCycle (evt) {
+ cycleRss();
+ }
+
+ bpui.getContextRoot = function() {
+ var urlArray=window.location.toString().split("/", 4);
+ return "/" + urlArray[3];
+ }
+
+ bpui.contextRoot = bpui.getContextRoot();
+}
+
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/scroller.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/scroller.js
index cb46fa2..1f72578 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/scroller.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/scroller.js
@@ -1,643 +1,643 @@
-/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
-$Id: scroller.js,v 1.32 2007/01/17 18:00:09 basler Exp $ */
-
-/**
-* ImageScroller - A multipurpose item brower
-* @ Author: Greg Murray
-*
-*/
-
-function getApplicationContextRoot() {
- var urlArray=window.location.toString().split("/", 4);
- return "/" + urlArray[3];
-}
-
-var applicationContextRoot=getApplicationContextRoot();
-
-
-function ImageScroller() {
- var _this = this;
- var initialized = false;
- // default sizes
-
- var VIEWPORT_WIDTH = 500;
- // all sizes are realitive the the viewport width
- var IMAGEPANE_WIDTH = VIEWPORT_WIDTH;
- var IMAGEPANE_HEIGHT = Math.round(VIEWPORT_WIDTH / 1.49);
- var INFOPANE_DEFAULT_HEIGHT = Math.round(VIEWPORT_WIDTH / 6.67);
- var INFOPANE_EXPAND_HEIGHT = Math.round(VIEWPORT_WIDTH / 2.86);
- var THUMB_WIDTH = Math.round(VIEWPORT_WIDTH / 5);;
- var THUMB_HEIGHT = Math.round(VIEWPORT_WIDTH / 6.67);
-
- var CHUNK_SIZE = 7;
- var PREFETCH_THRESHHOLD = 5;
-
- var IMAGE_PANE_ID = "imagePane";
- var IMAGE_PANE_BUFFER_ID = "imageBufferPane";
-
- var PADDING = 3;
-
- var MINIMIZE_IMG_URI = applicationContextRoot + "/images/minimize.gif";
- var MAXIMIZE_IMG_URI = applicationContextRoot + "/images/maximize.gif";
- var INDICATOR_IMG_URI = applicationContextRoot + "/images/indicator-black.gif";
- var MAXIMIZE_IMG_TOOLTIP = "Show Details";
- var MINIMIZE_IMG_TOOLTIP = "Show Less Details";
-
- // this is an array of the tiles which are divs for each thumb
- var tiles = [];
-
- var injectionPoint;
-
- // for scrolling
-
- var SCROLL_INCREMENT = 5;
- var INFOPANE_INCREMENT = 3;
- var tileY;
- var tileX;
- // this is the index of the image tile on the far left
- var index = 0;
- // keeps track how for the scroll has gone
- var offset = 0;
-
- var timeout = 30; // in ms
- var isScrollingRight = false;
- var isScrollingLeft = false;
-
- // large image pane
- var imagePane;
- var imageLoadingPane;
- var loadingPane;
- // images
- var minimizeImage;
-
- var indicatorImage;
- var leftButton;
- var rightButton;
-
- // infopane
- var infoPane;
- var infoTableMinimize;
- var indicatorCell;
- var minimizeLink;
- var infoPaneLoop = 0;
- var maximizing = false;
- var minimizing = false;
- var maximized = false;
-
- // prefetch thresh-hold
- var prefetchThreshold = 2;
-
- // a growing list of items;
- var items = [];
- // cached chunks that are already in the items array
- var loadedChunks = [];
-
- // used for debugging when debug is true
- var debug = false;
- var statusDiv;
- var status2Div;
-
- var showingBuffer = false;
- var imageBuffer;
- var imageReloadTries = 0;
- var IMG_RELOAD_RETRY_MAX = 30;
- // used for url book marking
-
-
- var pid;
- var currentChunk;
- // this map contains all the items
- var map;
- // this is the main container div
- var containerDiv;
-
- this.getItems = function() {
- return map;
- }
-
- this.getScrollerItems = function() {
- return items;
- }
-
-
- this.getGroupId = function() {
- return pid;
- }
-
- this.reset = function() {
- resetTitles()
- tiles = [];
- index = 0;
- offset = 0;
- currentChunk = 0;
- items = [];
- loadedChunks = [];
- }
-
- function resetTitles() {
- for (var l = 0; l < tiles.length; l++) {
- tiles[l].parentNode.removeChild(tiles[l]);
- }
- }
-
- // event bound to the mouseOut event of both scroll buttons
- function scrollDone() {
- isScrollingLeft = false;
- isScrollingRight = false;
- }
-
- // looping method for time out
- function scroll() {
- if (isScrollingRight) scrollRight();
- else if (isScrollingLeft) scrollLeft();
- }
-
-
- // do the value list pre-emptive fetching
- function prefetch() {
- //printDebug("** scoller index = " + index);
- if (isScrollingRight && (index + PREFETCH_THRESHHOLD) % CHUNK_SIZE == 0) {
-
- if ((Math.round(index / CHUNK_SIZE)) >= currentChunk) {
- currentChunk = Math.round(index / CHUNK_SIZE) + 1;
- // fire an event
- dojo.event.topic.publish("/catalog", {type:"getChunk", id: pid, index: index, currentChunk: currentChunk});
- }
- }
- }
-
- this.setGroupId = function(id) {
- pid = id;
- }
-
- this.containsChunk = function(chunkId) {
- printDebug("containsChunk = " + loadedChunks);
- ret=false;
- for(ii=0; ii < loadedChunks.length; ii++) {
- if(chunkId == loadedChunks[ii]) {
- ret=true;
- break;
- }
- }
- return ret;
- }
-
- this.addChunk = function(chunkId) {
- loadedChunks.push(chunkId);
- }
-
- this.addItems = function(inItems) {
- for (var loop=0; loop < inItems.length ; loop++) {
- items.push(inItems[loop]);
- map.put(inItems[loop].id, inItems[loop]);
- createTile(inItems[loop]);
- if (loop == 0 && !loadImage) {
- showImage(inItems[loop].id);
- }
-
- }
- drawTiles();
- rightButton.style.visibility="visible";
- _this.hideProgressIndicator();
- }
-
- this.showProgressIndicator = function() {
- if (indicatorImage) {
- indicatorImage.style.visibility = "visible";
- }
- }
-
- this.hideProgressIndicator = function() {
- indicatorImage.style.visibility = "hidden";
- }
-
- function postImageLoad(loadIntoBuffer) {
- if (debug) {
- status2Div.innerHTML = "Try " + imageReloadTries + " " + url + " image.complete=" + imageBuffer.complete;
- }
- // keep calling this funtion until imageReloadTries < IMG_RELOAD_RETRY_MAX
- if (!imageBuffer.complete) {
- if (imageReloadTries < IMG_RELOAD_RETRY_MAX) {
- setTimeout(function(){this.loadIntoBuffer = loadIntoBuffer;postImageLoad(loadIntoBuffer);},500);
- } else {
- this.hideProgressIndicator();
- }
- imageReloadTries = imageReloadTries + 1;
- return;
- }
- var id;
-
- _this.hideProgressIndicator();
- if (loadIntoBuffer) {
- imageLoadingPane.src = imageBuffer.src;
- } else {
- imagePane.src = imageBuffer.src;
-
- }
- // do a cross fade as long as the images aren't the same
- if (imageLoadingPane.src != imagePane.src) {
- crossFade(0,loadIntoBuffer );
- }
- }
-
-
- this.showImage = function(itemId) {
-
- _this.showProgressIndicator();
- //setTimeout(this.showProgressIndicator,0);
- var i = map.get(itemId);
-
- if (!i) {
- return;
- }
- dojo.event.topic.publish("/catalog", {type:"showingItem", id: itemId, rating: i.rating});
- // create the image pane and append the description nodes
- // asumption is that if the imagePane is not set neigher are the info children
- if (typeof imagePane == 'undefined') {
- imagePane = document.createElement("img");
- imagePane.style.width = IMAGEPANE_WIDTH + "px";
- imagePane.style.height = IMAGEPANE_HEIGHT + "px";
- imagePane.id = IMAGE_PANE_ID;
-
- var targetElement = document.getElementById("bodySpace");
- imageLoadingPane = document.createElement("img");
- imageLoadingPane.style.position = "absolute";
- imageLoadingPane.style.visibility = "hidden";
- imageLoadingPane.style.width = IMAGEPANE_WIDTH + "px";
- imageLoadingPane.style.height = IMAGEPANE_HEIGHT + "px";
- imageLoadingPane.id = IMAGE_PANE_BUFFER_ID;
- targetElement.appendChild(imagePane);
- targetElement.appendChild(imageLoadingPane);
- imageLoadingPane.style.left = tileX + "px";
-
- loadImage(i.image, false);
- } else {
- imageLoadingPane.style.visibility = "visible";
- if (showingBuffer) {
- showingBuffer = false;
- } else {
- showingBuffer = true;
- }
- loadImage(i.image, showingBuffer);
- }
- }
-
- function loadImage(url, loadIntoBuffer) {
- imageReloadTries = 0;
- imageBuffer = new Image();
- if (loadIntoBuffer) {
- imageBuffer.src = url;
- imageLoadingPane.onLoad = setTimeout(function(){this.url=url;this.loadIntoBuffer = loadIntoBuffer;postImageLoad(loadIntoBuffer,url);},0);
- } else {
- imageBuffer.src = url;
- imageBuffer.onLoad = setTimeout(function(){this.url = url;this.loadIntoBuffer = loadIntoBuffer;postImageLoad(loadIntoBuffer,url);},0);
- }
- }
-
- function setOpacity(opacity, id) {
- var target = document.getElementById(id);
- if (typeof target.style.filter != 'undefined') {
- target.style.filter = "alpha(opacity:" + opacity + ")";
- } else {
- target.style.opacity = opacity/100;
- }
- }
-
- function crossFade(count,loadIntoBuffer) {
- var percentage = Number(count);
- if (loadIntoBuffer) {
- setOpacity(100 - percentage, IMAGE_PANE_ID);
- setOpacity(percentage, IMAGE_PANE_BUFFER_ID);
- } else {
- setOpacity(100 - percentage, IMAGE_PANE_BUFFER_ID);
- setOpacity(percentage, IMAGE_PANE_ID);
-
- }
- if (percentage < 100) {
- percentage = percentage + 10;
- setTimeout(function(){this.loadIntoBuffer = loadIntoBuffer;this.percentage = percentage;crossFade(percentage,loadIntoBuffer);}, 25);
- }
- }
-
-
- // calling this function will result in the maximizing event being fired
- // if the pane is maximized it will asume the event want to minimize
- this.doMaximize = function() {
- if (!maximizing && !minimizing && !maximized) {
- infoPaneLoop = INFOPANE_DEFAULT_HEIGHT;
- maximizing = true;
- minimizing = false;
- } else if (!maximizing && !minimizing) {
- minimizing = true;
- maximizing = false;
- }
- setTimeout(changeInfoPane, 0);
- }
-
- // will handle either minimizing or maximing but not both
- // this method is called recursively until the maximinging
- // or minimizing is done.
- function changeInfoPane() {
- if (maximizing) {
- maxmizeInfoPane();
- } else if (minimizing) {
- minimizeInfoPane();
- }
- }
-
- function maxmizeInfoPane() {
- if (infoPaneLoop < INFOPANE_EXPAND_HEIGHT) {
- infoPaneLoop = infoPaneLoop + INFOPANE_INCREMENT;
- var clipMe = 'rect(' + '0px,' + VIEWPORT_WIDTH + 'px,'+ infoPaneLoop +'px,' + 0 + 'px)';
- infoPane.style.clip = clipMe;
- infoPane.style.height = infoPaneLoop;
- infoPane.style.top = (tileY + (PADDING *2) + INFOPANE_DEFAULT_HEIGHT + IMAGEPANE_HEIGHT) - infoPaneLoop;
- setTimeout(changeInfoPane, 5);
- } else {
- minimizeImage.src= MINIMIZE_IMG_URI;
- minimizeLink.title = MINIMIZE_IMG_TOOLTIP;
- maximized = true;
- maximizing = false;
- minimizing = false;
- }
- }
-
- function minimizeInfoPane() {
- if (infoPaneLoop > INFOPANE_DEFAULT_HEIGHT) {
- infoPaneLoop = infoPaneLoop - INFOPANE_INCREMENT;
- var clipMe = 'rect(' + '0px,' + VIEWPORT_WIDTH + 'px,'+ infoPaneLoop +'px,' + 0 + 'px)';
- infoPane.style.clip = clipMe;
- infoPane.style.height = infoPaneLoop;
- infoPane.style.top = (tileY + (PADDING *2) + INFOPANE_DEFAULT_HEIGHT + IMAGEPANE_HEIGHT) - infoPaneLoop;
- if (debug) {
- status2Div.innerHTML = "minimize infoPaneLoop =" + infoPaneLoop + " infopane.top=" + infoPane.style.top;
- }
- setTimeout(changeInfoPane, 5);
- } else {
- minimizeImage.src= MAXIMIZE_IMG_URI;
- minimizeLink.title = MAXIMIZE_IMG_TOOLTIP;
- maximizing = false;
- minimizing = false;
- maximized = false;
- }
- }
-
- function scrollRight() {
- isScrollingRight = true;
- if ( (index + 4) >= tiles.length) {
- // hide the rightButton
- rightButton.style.visibility="hidden";
- return;
- } else {
- leftButton.style.visibility="visible";
- }
- offset = offset - SCROLL_INCREMENT;
- drawTiles();
- setTimeout(scroll, timeout);
- }
-
- function getNext() {
- isScrollingRight = true;
- setTimeout(scroll, timeout);
- }
-
-
- function getPrevious () {
- isScrollingLeft = true;
- setTimeout(scroll, timeout);
- }
-
- function scrollLeft() {
- if (offset >= 0) {
- leftButton.style.visibility="hidden";
- return;
- } else {
- leftButton.style.visibility="visible";
- }
- offset = offset + SCROLL_INCREMENT;
- drawTiles();
- setTimeout(scroll, timeout);
- }
-
- function drawTiles() {
- // draw the first one if its off the screen
- // check if the far right image is out view
- var overHang;
- var temp = offset;
- index = Math.floor((offset)/THUMB_WIDTH);
- overHang = offset % THUMB_WIDTH;
- if (overHang < 0) {
- overHang = overHang * -1;
- }
- if (index < 0) {
- index = index * -1;
- }
- // check for next set of images
- prefetch();
- var startIndex = index;
- if (overHang > 0 && index >0) {
- startIndex = index -1;
- }
- var stopIndex = index + Math.round(VIEWPORT_WIDTH / THUMB_WIDTH);
- if (stopIndex > tiles.length) {
- stopIndex = tiles.length;
- }
- var displayX = 0;
- for (var tl=startIndex; tl < stopIndex; tl++) {
- if (debug) {
- statusDiv.innerHTML = "overhang=" + overHang + " startIndex=" + startIndex + " stopIndex=" + stopIndex + " offset=" + offset + " displayX=" + displayX;
- }
- if (overHang > 0 && tl == startIndex) {
- rightButton.style.visibility="visible";
- // clip: rect(top right bottom left) - borders of the clipped area
- // clip the left
- var clipMe = 'rect(' + '0px,' + THUMB_WIDTH + 'px,'+ THUMB_HEIGHT +'px,' + overHang + 'px)';
- tiles[tl].style.clip = clipMe;
- tiles[tl].style.left = (tileX - overHang) + "px";
- displayX = displayX + (THUMB_WIDTH - overHang);
- } else if (tl == stopIndex -1) {
- var underHang = VIEWPORT_WIDTH - displayX ;
- if (underHang > 0 && underHang) {
- var clipMe = 'rect(' + '0px,' + (underHang) + "px," + THUMB_HEIGHT +'px,' + 0 + 'px)';
- tiles[tl].style.clip = clipMe;
- tiles[tl].style.left = tileX + (offset + (tl * THUMB_WIDTH)) + 'px';
- tiles[tl].style.visibility = "visible";
- // resize the previous one to its real length
- } else if (underHang < 0 && tl > 0) {
- var clipMe = 'rect(' + '0px,' + (THUMB_WIDTH + underHang) + "px," + THUMB_HEIGHT +'px,' + 0 + 'px)';
- tiles[tl-1].style.clip = clipMe;
- tiles[tl-1].style.visibility = "visible";
- tiles[tl-1].style.left = tileX + (offset + ((tl -1) * THUMB_WIDTH)) + 'px';
- } else {
- tiles[tl].style.left = '0px';
- tiles[tl].style.visibility = "hidden";
- }
- } else {
- displayX = displayX + THUMB_WIDTH;
- tiles[tl].style.left = tileX + (offset + (tl * THUMB_WIDTH)) + 'px';
- tiles[tl].style.visibility = "visible";
- }
- }
- if (stopIndex < tiles.length) {
- tiles[stopIndex].style.visibility = "hidden";
- tiles[stopIndex].style.left = "0px";
- }
- }
-
-
- this.load = function () {
- map = new Map();
- dojo.event.connect(window, "onresize", layout);
- var loadImage;
-
- var targetRow = document.getElementById("targetRow");
- injectionPoint = document.getElementById("injection_point");
-
- // for status output
- statusDiv = document.getElementById("status");
- status2Div = document.getElementById("status_2");
-
- initLayout();
- initialized = true;
- }
-
- function initLayout() {
- containerDiv = document.getElementById("CatalogBrowser");
- rightButton = document.getElementById("right_button");
- leftButton = document.getElementById("left_button");
- layout();
- leftButton.style.visibility="hidden";
- if (typeof rightButton.attachEvent != 'undefined') {
- rightButton.attachEvent('onmouseover',function(e){scrollDone();getNext();});
- rightButton.attachEvent('onmouseout',function(e){scrollDone();});
- leftButton.attachEvent('onmouseover',function(e){scrollDone();getPrevious();});
- leftButton.attachEvent('onmouseout',function(e){scrollDone();});
- } else if (typeof rightButton.addEventListener != 'undefined') {
- rightButton.addEventListener('mouseover',function(e){scrollDone();getNext();}, false);
- rightButton.addEventListener('mouseout',function(e){scrollDone();}, false);
- leftButton.addEventListener('mouseover',function(e){scrollDone();getPrevious();}, false);
- leftButton.addEventListener('mouseout',function(e){scrollDone();}, false);
- }
- createInfoPane();
- }
-
- function layout() {
- var ua = navigator.userAgent.toLowerCase();
-
- // this will need to be made generic depending on the thumb height
- tileY = findY(containerDiv);
- tileX = findX(containerDiv) + 4;
- var rightX = tileX + VIEWPORT_WIDTH - 20;
- rightButton.style.left = rightX + "px";
- var buttonY = tileY + IMAGEPANE_HEIGHT + INFOPANE_DEFAULT_HEIGHT + 12;
- rightButton.style.top = buttonY + "px";
- leftButton.style.top = buttonY + "px";
-
- if (ua.indexOf('ie') != -1) {
- isIE = true;
- } else if (ua.indexOf('safari') != -1) {
- tileX = tileX + 8;
- timeout = 20;
- }
- drawTiles();
- if (infoPane) {
- infoPane.style.left = tileX + "px";
- if (maximized) {
-
- infoPane.style.top = (tileY + IMAGEPANE_HEIGHT + (PADDING*2) - infoPane.style.height) + "px";
- } else {
- infoPane.style.top = (tileY + IMAGEPANE_HEIGHT + (PADDING*2)) + "px";
- }
- if (maximized) {
- infoPaneLoop = infoPane.style.height;
- } else {
- infoPaneLoop = INFOPANE_DEFAULT_HEIGHT;
- }
- }
- if (typeof imageLoadingPane != 'undefined') {
- imageLoadingPane.style.left = tileX;
- imageLoadingPane.style.top = tileY;
- }
- }
-
- function createInfoPane() {
- infoPane = document.getElementById("infopane");
- infoPane.style.width = VIEWPORT_WIDTH + "px";
- // give room for 4 pixels above and below
- infoPane.style.height = (INFOPANE_DEFAULT_HEIGHT) + "px";
- // give 3px padding for a border
- infoPane.style.top = (tileY + IMAGEPANE_HEIGHT + (PADDING*2)) + "px";
- infoPane.style.left = tileX + "px";
- infoTableMinimize = document.getElementById("infopaneDetailsIcon");
- indicatorCell = document.getElementById("infopaneIndicator");
- indicatorCell.style.width = (10) + "px";
- indicatorImage = document.createElement("img");
- indicatorImage.className = "infopaneIndicator";
- indicatorImage.src = INDICATOR_IMG_URI;
- indicatorImage.style.visibility = "hidden";
- indicatorCell.appendChild(indicatorImage);
- minimizeLink = document.createElement("a");
- minimizeLink.className = "infopaneLink";
- minimizeLink.title = MAXIMIZE_IMG_TOOLTIP;
- minimizeImage = document.createElement("img");
- minimizeImage.src= MAXIMIZE_IMG_URI;
- minimizeLink.appendChild(minimizeImage);
- infoTableMinimize.appendChild(minimizeLink);
-
- if (typeof minimizeLink.attachEvent != 'undefined') {
- minimizeLink.attachEvent("onclick",function(e){_this.doMaximize();});
- } else {
- minimizeLink.addEventListener("click",function(e){_this.doMaximize();}, true);
- }
- var clipMe = 'rect(' + '0px,' + VIEWPORT_WIDTH + 'px,'+ INFOPANE_DEFAULT_HEIGHT +'px,' + 0 + 'px)';
- infoPane.style.clip = clipMe;
- }
-
- function createTile(i) {
- var div = document.createElement("div");
- div.className = "tile";
- div.id = i.id;
- var link = document.createElement("a");
- var img = document.createElement("img");
- img.title = i.name;
- img.src = i.thumbnail;
- img.className = "tileImage";
- link.appendChild(img);
- link.setAttribute("id", i.id);
- if (typeof div.attachEvent != 'undefined') {
- div.attachEvent('onclick',function(e){this.id = div.id; _this.showImage(this.id, false);});
- } else {
- link.addEventListener('click',function(e){this.id = div.id; _this.showImage(this.id, false);}, true);
- }
- div.appendChild(link);
- injectionPoint.appendChild(div);
- div.style.top = tileY + INFOPANE_DEFAULT_HEIGHT + IMAGEPANE_HEIGHT + (PADDING * 3) + "px";
- tiles.push(div);
- }
-
-
- function findY(element) {
- var t = 0;
- if (element.offsetParent) {
- while (element.offsetParent) {
- t += element.offsetTop
- element = element.offsetParent;
- }
- } else if (element.y) {
- t += element.y;
- }
- return t;
- }
-
- function findX(element) {
- var l = 0;
- if (element.offsetParent) {
- while (element.offsetParent) {
- l += element.offsetLeft
- element = element.offsetParent;
- }
- } else if (element.x)
- l += element.x;
- return l;
- }
-}
+/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
+$Id: scroller.js,v 1.32 2007/01/17 18:00:09 basler Exp $ */
+
+/**
+* ImageScroller - A multipurpose item brower
+* @ Author: Greg Murray
+*
+*/
+
+function getApplicationContextRoot() {
+ var urlArray=window.location.toString().split("/", 4);
+ return "/" + urlArray[3];
+}
+
+var applicationContextRoot=getApplicationContextRoot();
+
+
+function ImageScroller() {
+ var _this = this;
+ var initialized = false;
+ // default sizes
+
+ var VIEWPORT_WIDTH = 500;
+ // all sizes are realitive the the viewport width
+ var IMAGEPANE_WIDTH = VIEWPORT_WIDTH;
+ var IMAGEPANE_HEIGHT = Math.round(VIEWPORT_WIDTH / 1.49);
+ var INFOPANE_DEFAULT_HEIGHT = Math.round(VIEWPORT_WIDTH / 6.67);
+ var INFOPANE_EXPAND_HEIGHT = Math.round(VIEWPORT_WIDTH / 2.86);
+ var THUMB_WIDTH = Math.round(VIEWPORT_WIDTH / 5);;
+ var THUMB_HEIGHT = Math.round(VIEWPORT_WIDTH / 6.67);
+
+ var CHUNK_SIZE = 7;
+ var PREFETCH_THRESHHOLD = 5;
+
+ var IMAGE_PANE_ID = "imagePane";
+ var IMAGE_PANE_BUFFER_ID = "imageBufferPane";
+
+ var PADDING = 3;
+
+ var MINIMIZE_IMG_URI = applicationContextRoot + "/images/minimize.gif";
+ var MAXIMIZE_IMG_URI = applicationContextRoot + "/images/maximize.gif";
+ var INDICATOR_IMG_URI = applicationContextRoot + "/images/indicator-black.gif";
+ var MAXIMIZE_IMG_TOOLTIP = "Show Details";
+ var MINIMIZE_IMG_TOOLTIP = "Show Less Details";
+
+ // this is an array of the tiles which are divs for each thumb
+ var tiles = [];
+
+ var injectionPoint;
+
+ // for scrolling
+
+ var SCROLL_INCREMENT = 5;
+ var INFOPANE_INCREMENT = 3;
+ var tileY;
+ var tileX;
+ // this is the index of the image tile on the far left
+ var index = 0;
+ // keeps track how for the scroll has gone
+ var offset = 0;
+
+ var timeout = 30; // in ms
+ var isScrollingRight = false;
+ var isScrollingLeft = false;
+
+ // large image pane
+ var imagePane;
+ var imageLoadingPane;
+ var loadingPane;
+ // images
+ var minimizeImage;
+
+ var indicatorImage;
+ var leftButton;
+ var rightButton;
+
+ // infopane
+ var infoPane;
+ var infoTableMinimize;
+ var indicatorCell;
+ var minimizeLink;
+ var infoPaneLoop = 0;
+ var maximizing = false;
+ var minimizing = false;
+ var maximized = false;
+
+ // prefetch thresh-hold
+ var prefetchThreshold = 2;
+
+ // a growing list of items;
+ var items = [];
+ // cached chunks that are already in the items array
+ var loadedChunks = [];
+
+ // used for debugging when debug is true
+ var debug = false;
+ var statusDiv;
+ var status2Div;
+
+ var showingBuffer = false;
+ var imageBuffer;
+ var imageReloadTries = 0;
+ var IMG_RELOAD_RETRY_MAX = 30;
+ // used for url book marking
+
+
+ var pid;
+ var currentChunk;
+ // this map contains all the items
+ var map;
+ // this is the main container div
+ var containerDiv;
+
+ this.getItems = function() {
+ return map;
+ }
+
+ this.getScrollerItems = function() {
+ return items;
+ }
+
+
+ this.getGroupId = function() {
+ return pid;
+ }
+
+ this.reset = function() {
+ resetTitles()
+ tiles = [];
+ index = 0;
+ offset = 0;
+ currentChunk = 0;
+ items = [];
+ loadedChunks = [];
+ }
+
+ function resetTitles() {
+ for (var l = 0; l < tiles.length; l++) {
+ tiles[l].parentNode.removeChild(tiles[l]);
+ }
+ }
+
+ // event bound to the mouseOut event of both scroll buttons
+ function scrollDone() {
+ isScrollingLeft = false;
+ isScrollingRight = false;
+ }
+
+ // looping method for time out
+ function scroll() {
+ if (isScrollingRight) scrollRight();
+ else if (isScrollingLeft) scrollLeft();
+ }
+
+
+ // do the value list pre-emptive fetching
+ function prefetch() {
+ //printDebug("** scoller index = " + index);
+ if (isScrollingRight && (index + PREFETCH_THRESHHOLD) % CHUNK_SIZE == 0) {
+
+ if ((Math.round(index / CHUNK_SIZE)) >= currentChunk) {
+ currentChunk = Math.round(index / CHUNK_SIZE) + 1;
+ // fire an event
+ dojo.event.topic.publish("/catalog", {type:"getChunk", id: pid, index: index, currentChunk: currentChunk});
+ }
+ }
+ }
+
+ this.setGroupId = function(id) {
+ pid = id;
+ }
+
+ this.containsChunk = function(chunkId) {
+ printDebug("containsChunk = " + loadedChunks);
+ ret=false;
+ for(ii=0; ii < loadedChunks.length; ii++) {
+ if(chunkId == loadedChunks[ii]) {
+ ret=true;
+ break;
+ }
+ }
+ return ret;
+ }
+
+ this.addChunk = function(chunkId) {
+ loadedChunks.push(chunkId);
+ }
+
+ this.addItems = function(inItems) {
+ for (var loop=0; loop < inItems.length ; loop++) {
+ items.push(inItems[loop]);
+ map.put(inItems[loop].id, inItems[loop]);
+ createTile(inItems[loop]);
+ if (loop == 0 && !loadImage) {
+ showImage(inItems[loop].id);
+ }
+
+ }
+ drawTiles();
+ rightButton.style.visibility="visible";
+ _this.hideProgressIndicator();
+ }
+
+ this.showProgressIndicator = function() {
+ if (indicatorImage) {
+ indicatorImage.style.visibility = "visible";
+ }
+ }
+
+ this.hideProgressIndicator = function() {
+ indicatorImage.style.visibility = "hidden";
+ }
+
+ function postImageLoad(loadIntoBuffer) {
+ if (debug) {
+ status2Div.innerHTML = "Try " + imageReloadTries + " " + url + " image.complete=" + imageBuffer.complete;
+ }
+ // keep calling this funtion until imageReloadTries < IMG_RELOAD_RETRY_MAX
+ if (!imageBuffer.complete) {
+ if (imageReloadTries < IMG_RELOAD_RETRY_MAX) {
+ setTimeout(function(){this.loadIntoBuffer = loadIntoBuffer;postImageLoad(loadIntoBuffer);},500);
+ } else {
+ this.hideProgressIndicator();
+ }
+ imageReloadTries = imageReloadTries + 1;
+ return;
+ }
+ var id;
+
+ _this.hideProgressIndicator();
+ if (loadIntoBuffer) {
+ imageLoadingPane.src = imageBuffer.src;
+ } else {
+ imagePane.src = imageBuffer.src;
+
+ }
+ // do a cross fade as long as the images aren't the same
+ if (imageLoadingPane.src != imagePane.src) {
+ crossFade(0,loadIntoBuffer );
+ }
+ }
+
+
+ this.showImage = function(itemId) {
+
+ _this.showProgressIndicator();
+ //setTimeout(this.showProgressIndicator,0);
+ var i = map.get(itemId);
+
+ if (!i) {
+ return;
+ }
+ dojo.event.topic.publish("/catalog", {type:"showingItem", id: itemId, rating: i.rating});
+ // create the image pane and append the description nodes
+ // asumption is that if the imagePane is not set neigher are the info children
+ if (typeof imagePane == 'undefined') {
+ imagePane = document.createElement("img");
+ imagePane.style.width = IMAGEPANE_WIDTH + "px";
+ imagePane.style.height = IMAGEPANE_HEIGHT + "px";
+ imagePane.id = IMAGE_PANE_ID;
+
+ var targetElement = document.getElementById("bodySpace");
+ imageLoadingPane = document.createElement("img");
+ imageLoadingPane.style.position = "absolute";
+ imageLoadingPane.style.visibility = "hidden";
+ imageLoadingPane.style.width = IMAGEPANE_WIDTH + "px";
+ imageLoadingPane.style.height = IMAGEPANE_HEIGHT + "px";
+ imageLoadingPane.id = IMAGE_PANE_BUFFER_ID;
+ targetElement.appendChild(imagePane);
+ targetElement.appendChild(imageLoadingPane);
+ imageLoadingPane.style.left = tileX + "px";
+
+ loadImage(i.image, false);
+ } else {
+ imageLoadingPane.style.visibility = "visible";
+ if (showingBuffer) {
+ showingBuffer = false;
+ } else {
+ showingBuffer = true;
+ }
+ loadImage(i.image, showingBuffer);
+ }
+ }
+
+ function loadImage(url, loadIntoBuffer) {
+ imageReloadTries = 0;
+ imageBuffer = new Image();
+ if (loadIntoBuffer) {
+ imageBuffer.src = url;
+ imageLoadingPane.onLoad = setTimeout(function(){this.url=url;this.loadIntoBuffer = loadIntoBuffer;postImageLoad(loadIntoBuffer,url);},0);
+ } else {
+ imageBuffer.src = url;
+ imageBuffer.onLoad = setTimeout(function(){this.url = url;this.loadIntoBuffer = loadIntoBuffer;postImageLoad(loadIntoBuffer,url);},0);
+ }
+ }
+
+ function setOpacity(opacity, id) {
+ var target = document.getElementById(id);
+ if (typeof target.style.filter != 'undefined') {
+ target.style.filter = "alpha(opacity:" + opacity + ")";
+ } else {
+ target.style.opacity = opacity/100;
+ }
+ }
+
+ function crossFade(count,loadIntoBuffer) {
+ var percentage = Number(count);
+ if (loadIntoBuffer) {
+ setOpacity(100 - percentage, IMAGE_PANE_ID);
+ setOpacity(percentage, IMAGE_PANE_BUFFER_ID);
+ } else {
+ setOpacity(100 - percentage, IMAGE_PANE_BUFFER_ID);
+ setOpacity(percentage, IMAGE_PANE_ID);
+
+ }
+ if (percentage < 100) {
+ percentage = percentage + 10;
+ setTimeout(function(){this.loadIntoBuffer = loadIntoBuffer;this.percentage = percentage;crossFade(percentage,loadIntoBuffer);}, 25);
+ }
+ }
+
+
+ // calling this function will result in the maximizing event being fired
+ // if the pane is maximized it will asume the event want to minimize
+ this.doMaximize = function() {
+ if (!maximizing && !minimizing && !maximized) {
+ infoPaneLoop = INFOPANE_DEFAULT_HEIGHT;
+ maximizing = true;
+ minimizing = false;
+ } else if (!maximizing && !minimizing) {
+ minimizing = true;
+ maximizing = false;
+ }
+ setTimeout(changeInfoPane, 0);
+ }
+
+ // will handle either minimizing or maximing but not both
+ // this method is called recursively until the maximinging
+ // or minimizing is done.
+ function changeInfoPane() {
+ if (maximizing) {
+ maxmizeInfoPane();
+ } else if (minimizing) {
+ minimizeInfoPane();
+ }
+ }
+
+ function maxmizeInfoPane() {
+ if (infoPaneLoop < INFOPANE_EXPAND_HEIGHT) {
+ infoPaneLoop = infoPaneLoop + INFOPANE_INCREMENT;
+ var clipMe = 'rect(' + '0px,' + VIEWPORT_WIDTH + 'px,'+ infoPaneLoop +'px,' + 0 + 'px)';
+ infoPane.style.clip = clipMe;
+ infoPane.style.height = infoPaneLoop;
+ infoPane.style.top = (tileY + (PADDING *2) + INFOPANE_DEFAULT_HEIGHT + IMAGEPANE_HEIGHT) - infoPaneLoop;
+ setTimeout(changeInfoPane, 5);
+ } else {
+ minimizeImage.src= MINIMIZE_IMG_URI;
+ minimizeLink.title = MINIMIZE_IMG_TOOLTIP;
+ maximized = true;
+ maximizing = false;
+ minimizing = false;
+ }
+ }
+
+ function minimizeInfoPane() {
+ if (infoPaneLoop > INFOPANE_DEFAULT_HEIGHT) {
+ infoPaneLoop = infoPaneLoop - INFOPANE_INCREMENT;
+ var clipMe = 'rect(' + '0px,' + VIEWPORT_WIDTH + 'px,'+ infoPaneLoop +'px,' + 0 + 'px)';
+ infoPane.style.clip = clipMe;
+ infoPane.style.height = infoPaneLoop;
+ infoPane.style.top = (tileY + (PADDING *2) + INFOPANE_DEFAULT_HEIGHT + IMAGEPANE_HEIGHT) - infoPaneLoop;
+ if (debug) {
+ status2Div.innerHTML = "minimize infoPaneLoop =" + infoPaneLoop + " infopane.top=" + infoPane.style.top;
+ }
+ setTimeout(changeInfoPane, 5);
+ } else {
+ minimizeImage.src= MAXIMIZE_IMG_URI;
+ minimizeLink.title = MAXIMIZE_IMG_TOOLTIP;
+ maximizing = false;
+ minimizing = false;
+ maximized = false;
+ }
+ }
+
+ function scrollRight() {
+ isScrollingRight = true;
+ if ( (index + 4) >= tiles.length) {
+ // hide the rightButton
+ rightButton.style.visibility="hidden";
+ return;
+ } else {
+ leftButton.style.visibility="visible";
+ }
+ offset = offset - SCROLL_INCREMENT;
+ drawTiles();
+ setTimeout(scroll, timeout);
+ }
+
+ function getNext() {
+ isScrollingRight = true;
+ setTimeout(scroll, timeout);
+ }
+
+
+ function getPrevious () {
+ isScrollingLeft = true;
+ setTimeout(scroll, timeout);
+ }
+
+ function scrollLeft() {
+ if (offset >= 0) {
+ leftButton.style.visibility="hidden";
+ return;
+ } else {
+ leftButton.style.visibility="visible";
+ }
+ offset = offset + SCROLL_INCREMENT;
+ drawTiles();
+ setTimeout(scroll, timeout);
+ }
+
+ function drawTiles() {
+ // draw the first one if its off the screen
+ // check if the far right image is out view
+ var overHang;
+ var temp = offset;
+ index = Math.floor((offset)/THUMB_WIDTH);
+ overHang = offset % THUMB_WIDTH;
+ if (overHang < 0) {
+ overHang = overHang * -1;
+ }
+ if (index < 0) {
+ index = index * -1;
+ }
+ // check for next set of images
+ prefetch();
+ var startIndex = index;
+ if (overHang > 0 && index >0) {
+ startIndex = index -1;
+ }
+ var stopIndex = index + Math.round(VIEWPORT_WIDTH / THUMB_WIDTH);
+ if (stopIndex > tiles.length) {
+ stopIndex = tiles.length;
+ }
+ var displayX = 0;
+ for (var tl=startIndex; tl < stopIndex; tl++) {
+ if (debug) {
+ statusDiv.innerHTML = "overhang=" + overHang + " startIndex=" + startIndex + " stopIndex=" + stopIndex + " offset=" + offset + " displayX=" + displayX;
+ }
+ if (overHang > 0 && tl == startIndex) {
+ rightButton.style.visibility="visible";
+ // clip: rect(top right bottom left) - borders of the clipped area
+ // clip the left
+ var clipMe = 'rect(' + '0px,' + THUMB_WIDTH + 'px,'+ THUMB_HEIGHT +'px,' + overHang + 'px)';
+ tiles[tl].style.clip = clipMe;
+ tiles[tl].style.left = (tileX - overHang) + "px";
+ displayX = displayX + (THUMB_WIDTH - overHang);
+ } else if (tl == stopIndex -1) {
+ var underHang = VIEWPORT_WIDTH - displayX ;
+ if (underHang > 0 && underHang) {
+ var clipMe = 'rect(' + '0px,' + (underHang) + "px," + THUMB_HEIGHT +'px,' + 0 + 'px)';
+ tiles[tl].style.clip = clipMe;
+ tiles[tl].style.left = tileX + (offset + (tl * THUMB_WIDTH)) + 'px';
+ tiles[tl].style.visibility = "visible";
+ // resize the previous one to its real length
+ } else if (underHang < 0 && tl > 0) {
+ var clipMe = 'rect(' + '0px,' + (THUMB_WIDTH + underHang) + "px," + THUMB_HEIGHT +'px,' + 0 + 'px)';
+ tiles[tl-1].style.clip = clipMe;
+ tiles[tl-1].style.visibility = "visible";
+ tiles[tl-1].style.left = tileX + (offset + ((tl -1) * THUMB_WIDTH)) + 'px';
+ } else {
+ tiles[tl].style.left = '0px';
+ tiles[tl].style.visibility = "hidden";
+ }
+ } else {
+ displayX = displayX + THUMB_WIDTH;
+ tiles[tl].style.left = tileX + (offset + (tl * THUMB_WIDTH)) + 'px';
+ tiles[tl].style.visibility = "visible";
+ }
+ }
+ if (stopIndex < tiles.length) {
+ tiles[stopIndex].style.visibility = "hidden";
+ tiles[stopIndex].style.left = "0px";
+ }
+ }
+
+
+ this.load = function () {
+ map = new Map();
+ dojo.event.connect(window, "onresize", layout);
+ var loadImage;
+
+ var targetRow = document.getElementById("targetRow");
+ injectionPoint = document.getElementById("injection_point");
+
+ // for status output
+ statusDiv = document.getElementById("status");
+ status2Div = document.getElementById("status_2");
+
+ initLayout();
+ initialized = true;
+ }
+
+ function initLayout() {
+ containerDiv = document.getElementById("CatalogBrowser");
+ rightButton = document.getElementById("right_button");
+ leftButton = document.getElementById("left_button");
+ layout();
+ leftButton.style.visibility="hidden";
+ if (typeof rightButton.attachEvent != 'undefined') {
+ rightButton.attachEvent('onmouseover',function(e){scrollDone();getNext();});
+ rightButton.attachEvent('onmouseout',function(e){scrollDone();});
+ leftButton.attachEvent('onmouseover',function(e){scrollDone();getPrevious();});
+ leftButton.attachEvent('onmouseout',function(e){scrollDone();});
+ } else if (typeof rightButton.addEventListener != 'undefined') {
+ rightButton.addEventListener('mouseover',function(e){scrollDone();getNext();}, false);
+ rightButton.addEventListener('mouseout',function(e){scrollDone();}, false);
+ leftButton.addEventListener('mouseover',function(e){scrollDone();getPrevious();}, false);
+ leftButton.addEventListener('mouseout',function(e){scrollDone();}, false);
+ }
+ createInfoPane();
+ }
+
+ function layout() {
+ var ua = navigator.userAgent.toLowerCase();
+
+ // this will need to be made generic depending on the thumb height
+ tileY = findY(containerDiv);
+ tileX = findX(containerDiv) + 4;
+ var rightX = tileX + VIEWPORT_WIDTH - 20;
+ rightButton.style.left = rightX + "px";
+ var buttonY = tileY + IMAGEPANE_HEIGHT + INFOPANE_DEFAULT_HEIGHT + 12;
+ rightButton.style.top = buttonY + "px";
+ leftButton.style.top = buttonY + "px";
+
+ if (ua.indexOf('ie') != -1) {
+ isIE = true;
+ } else if (ua.indexOf('safari') != -1) {
+ tileX = tileX + 8;
+ timeout = 20;
+ }
+ drawTiles();
+ if (infoPane) {
+ infoPane.style.left = tileX + "px";
+ if (maximized) {
+
+ infoPane.style.top = (tileY + IMAGEPANE_HEIGHT + (PADDING*2) - infoPane.style.height) + "px";
+ } else {
+ infoPane.style.top = (tileY + IMAGEPANE_HEIGHT + (PADDING*2)) + "px";
+ }
+ if (maximized) {
+ infoPaneLoop = infoPane.style.height;
+ } else {
+ infoPaneLoop = INFOPANE_DEFAULT_HEIGHT;
+ }
+ }
+ if (typeof imageLoadingPane != 'undefined') {
+ imageLoadingPane.style.left = tileX;
+ imageLoadingPane.style.top = tileY;
+ }
+ }
+
+ function createInfoPane() {
+ infoPane = document.getElementById("infopane");
+ infoPane.style.width = VIEWPORT_WIDTH + "px";
+ // give room for 4 pixels above and below
+ infoPane.style.height = (INFOPANE_DEFAULT_HEIGHT) + "px";
+ // give 3px padding for a border
+ infoPane.style.top = (tileY + IMAGEPANE_HEIGHT + (PADDING*2)) + "px";
+ infoPane.style.left = tileX + "px";
+ infoTableMinimize = document.getElementById("infopaneDetailsIcon");
+ indicatorCell = document.getElementById("infopaneIndicator");
+ indicatorCell.style.width = (10) + "px";
+ indicatorImage = document.createElement("img");
+ indicatorImage.className = "infopaneIndicator";
+ indicatorImage.src = INDICATOR_IMG_URI;
+ indicatorImage.style.visibility = "hidden";
+ indicatorCell.appendChild(indicatorImage);
+ minimizeLink = document.createElement("a");
+ minimizeLink.className = "infopaneLink";
+ minimizeLink.title = MAXIMIZE_IMG_TOOLTIP;
+ minimizeImage = document.createElement("img");
+ minimizeImage.src= MAXIMIZE_IMG_URI;
+ minimizeLink.appendChild(minimizeImage);
+ infoTableMinimize.appendChild(minimizeLink);
+
+ if (typeof minimizeLink.attachEvent != 'undefined') {
+ minimizeLink.attachEvent("onclick",function(e){_this.doMaximize();});
+ } else {
+ minimizeLink.addEventListener("click",function(e){_this.doMaximize();}, true);
+ }
+ var clipMe = 'rect(' + '0px,' + VIEWPORT_WIDTH + 'px,'+ INFOPANE_DEFAULT_HEIGHT +'px,' + 0 + 'px)';
+ infoPane.style.clip = clipMe;
+ }
+
+ function createTile(i) {
+ var div = document.createElement("div");
+ div.className = "tile";
+ div.id = i.id;
+ var link = document.createElement("a");
+ var img = document.createElement("img");
+ img.title = i.name;
+ img.src = i.thumbnail;
+ img.className = "tileImage";
+ link.appendChild(img);
+ link.setAttribute("id", i.id);
+ if (typeof div.attachEvent != 'undefined') {
+ div.attachEvent('onclick',function(e){this.id = div.id; _this.showImage(this.id, false);});
+ } else {
+ link.addEventListener('click',function(e){this.id = div.id; _this.showImage(this.id, false);}, true);
+ }
+ div.appendChild(link);
+ injectionPoint.appendChild(div);
+ div.style.top = tileY + INFOPANE_DEFAULT_HEIGHT + IMAGEPANE_HEIGHT + (PADDING * 3) + "px";
+ tiles.push(div);
+ }
+
+
+ function findY(element) {
+ var t = 0;
+ if (element.offsetParent) {
+ while (element.offsetParent) {
+ t += element.offsetTop
+ element = element.offsetParent;
+ }
+ } else if (element.y) {
+ t += element.y;
+ }
+ return t;
+ }
+
+ function findX(element) {
+ var l = 0;
+ if (element.offsetParent) {
+ while (element.offsetParent) {
+ l += element.offsetLeft
+ element = element.offsetParent;
+ }
+ } else if (element.x)
+ l += element.x;
+ return l;
+ }
+}
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/styles.css b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/styles.css
index 7762d70..24ffbf9 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/styles.css
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/styles.css
@@ -1,130 +1,130 @@
-
-.dojoHtmlFisheyeListBar {
- cursor:pointer;
- margin: 0;
- width: 300px;
- text-align: right;
-}
-
-.outerbar {
- background-color: white;
- text-align: left;
- width: 300px;
-}
-
-.editText {
- height:25;
- font-size:18px;
- font-weight: bold;
- font-family: Arial;
-}
-
-.plainText {
- height:25;
- font-size:20px;
- font-weight: bold;
- font-family: Arial
-}
-
-.plainTextSelect {
- height:25;
- font-size:20px;
- font-weight: bold;
- font-family: Arial;
- background: red
-}
-
-.smallText {
- height:15;
- font-size:13px;
- font-weight: bold;
- font-family: Arial
-}
-
-.banner {
- height:35;
- font-size:35;
- font-weight: bold;
- font-family: Arial
-}
-
-
-.menuItem {
- background: white;
- color: black;
- text-decoration: none;
- font-size: 1.4em;
-}
-
-.menuLink {
- cursor:pointer;
- color: black;
- text-decoration: none;
- font-size: 1.3em;
-}
-
-.menuLinkHover {
- cursor:pointer;
- color: black;
- font-size: 1.3em;
- text-decoration: underline;
-}
-
-.autocomplete {
- position:absolute;
-}
-
-.autocompleteTable {
- padding:0;
- visibility: hidden;
- border-spacing: 0;
- border-width:1px;
- border-style:solid;
- border-color:black;
-}
-
-.popupRowHover {
- color: #FFFAFA;
- cursor:pointer;
- padding-left:3;
- padding-right:3;
- border-spacing: 0;
- border-width:0px;
- background: #7A8AFF;
-}
-
-.popupRow {
- padding-left:3;
- padding-right:3;
- border-spacing: 0;
- border-width:0px;
- background: #FFFAFA;
-}
-
-.popupRowEven {
- padding-left:3;
- padding-right:3;
- border-spacing: 0;
- border-width:0px;
- background: #FFFADA;
-}
-
-.popupItem {
- background: #FFFAFA;
- color: #000000;
- text-decoration: none;
- font-size: 1.2em;
-}
-
-.shadow {
- top:0px;
- left:0px;
- position: absolute;
- visibility: hidden;
- width:0;
- height:0;
- z-index:0;
- background:gray;
- opacity: .5;
-}
-
+
+.dojoHtmlFisheyeListBar {
+ cursor:pointer;
+ margin: 0;
+ width: 300px;
+ text-align: right;
+}
+
+.outerbar {
+ background-color: white;
+ text-align: left;
+ width: 300px;
+}
+
+.editText {
+ height:25;
+ font-size:18px;
+ font-weight: bold;
+ font-family: Arial;
+}
+
+.plainText {
+ height:25;
+ font-size:20px;
+ font-weight: bold;
+ font-family: Arial
+}
+
+.plainTextSelect {
+ height:25;
+ font-size:20px;
+ font-weight: bold;
+ font-family: Arial;
+ background: red
+}
+
+.smallText {
+ height:15;
+ font-size:13px;
+ font-weight: bold;
+ font-family: Arial
+}
+
+.banner {
+ height:35;
+ font-size:35;
+ font-weight: bold;
+ font-family: Arial
+}
+
+
+.menuItem {
+ background: white;
+ color: black;
+ text-decoration: none;
+ font-size: 1.4em;
+}
+
+.menuLink {
+ cursor:pointer;
+ color: black;
+ text-decoration: none;
+ font-size: 1.3em;
+}
+
+.menuLinkHover {
+ cursor:pointer;
+ color: black;
+ font-size: 1.3em;
+ text-decoration: underline;
+}
+
+.autocomplete {
+ position:absolute;
+}
+
+.autocompleteTable {
+ padding:0;
+ visibility: hidden;
+ border-spacing: 0;
+ border-width:1px;
+ border-style:solid;
+ border-color:black;
+}
+
+.popupRowHover {
+ color: #FFFAFA;
+ cursor:pointer;
+ padding-left:3;
+ padding-right:3;
+ border-spacing: 0;
+ border-width:0px;
+ background: #7A8AFF;
+}
+
+.popupRow {
+ padding-left:3;
+ padding-right:3;
+ border-spacing: 0;
+ border-width:0px;
+ background: #FFFAFA;
+}
+
+.popupRowEven {
+ padding-left:3;
+ padding-right:3;
+ border-spacing: 0;
+ border-width:0px;
+ background: #FFFADA;
+}
+
+.popupItem {
+ background: #FFFAFA;
+ color: #000000;
+ text-decoration: none;
+ font-size: 1.2em;
+}
+
+.shadow {
+ top:0px;
+ left:0px;
+ position: absolute;
+ visibility: hidden;
+ width:0;
+ height:0;
+ z-index:0;
+ background:gray;
+ opacity: .5;
+}
+
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/tag.css b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/tag.css
index f72529a..bfbab6e 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/tag.css
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/tag.css
@@ -1,47 +1,47 @@
- .itemTable {
- padding: 0.3cm;
- border-style: double;
- width: 800px;
- border-color: darkgreen;
- }
- .itemCell {
- border-style: solid;
- border-color: darkgreen;
- border-width: thin;
- padding: 5px
- }
- .tagCell {
- padding: 0.3cm;
- }
- .xxlarge
- {
- font-size: xx-large;
- color: red;
- cursor: pointer;
- text-decoration: underline;
- }
- .xlarge
- {
- font-size: x-large;
- color: blue;
- cursor: pointer;
- text-decoration: underline;
- }
- .large
- {
- font-size: large;
- color: green;
- cursor: pointer;
- text-decoration: underline;
- }
- .medium
- {
- font-size: medium;
- cursor: pointer;
- color: black;
- text-decoration: underline;
- }
- .items
- {
- visibility: hidden;
- }
+ .itemTable {
+ padding: 0.3cm;
+ border-style: double;
+ width: 800px;
+ border-color: darkgreen;
+ }
+ .itemCell {
+ border-style: solid;
+ border-color: darkgreen;
+ border-width: thin;
+ padding: 5px
+ }
+ .tagCell {
+ padding: 0.3cm;
+ }
+ .xxlarge
+ {
+ font-size: xx-large;
+ color: red;
+ cursor: pointer;
+ text-decoration: underline;
+ }
+ .xlarge
+ {
+ font-size: x-large;
+ color: blue;
+ cursor: pointer;
+ text-decoration: underline;
+ }
+ .large
+ {
+ font-size: large;
+ color: green;
+ cursor: pointer;
+ text-decoration: underline;
+ }
+ .medium
+ {
+ font-size: medium;
+ cursor: pointer;
+ color: black;
+ text-decoration: underline;
+ }
+ .items
+ {
+ visibility: hidden;
+ }
diff --git a/modules/common/ant-bundle/src/main/assembly/bin/antenv.cmd b/modules/common/ant-bundle/src/main/assembly/bin/antenv.cmd
index 0460266..170d89f 100644
--- a/modules/common/ant-bundle/src/main/assembly/bin/antenv.cmd
+++ b/modules/common/ant-bundle/src/main/assembly/bin/antenv.cmd
@@ -1,98 +1,98 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-'@echo off'
-call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
-call SysLoadFuncs
-
-/* Prepare the parameters for later use */
-parse arg argv
-mode = ''
-args = ''
-opts = ''
-cp = ''
-lcp = ''
-
-do i = 1 to words(argv)
- param = word(argv, i)
- select
- when param='-lcp' then mode = 'l'
- when param='-cp' | param='-classpath' then mode = 'c'
- when abbrev('-opts', param, 4) then mode = 'o'
- when abbrev('-args', param, 4) then mode = 'a'
- otherwise
- select
- when mode = 'a' then args = space(args param, 1)
- when mode = 'c' then cp = space(cp param, 1)
- when mode = 'l' then lcp = space(lcp param, 1)
- when mode = 'o' then opts = space(opts param, 1)
- otherwise
- say 'Option' param 'ignored'
- end
- end
-end
-
-env="OS2ENVIRONMENT"
-antconf = _getenv_('antconf' 'antconf.cmd')
-runrc = _getenv_('runrc')
-interpret 'call "' || runrc || '"' '"' || antconf || '"' 'ETC'
-ANT_HOME = value('ANT_HOME',,env)
-JAVA_HOME = value('JAVA_HOME',,env)
-classpath = value('CLASSPATH',,env)
-classes = stream(JAVA_HOME || "\lib\classes.zip", "C", "QUERY EXISTS")
-if classes \= '' then classpath = prepend(classpath classes)
-classes = stream(JAVA_HOME || "\lib\tools.jar", "C", "QUERY EXISTS")
-if classes \= '' then classpath = prepend(classpath classes)
-
-classpath = prepend(classpath ANT_HOME || '\lib\ant-launcher.jar')
-'SET CLASSPATH=' || classpath
-
-/* Setting classpathes, options and arguments */
-envset = _getenv_('envset')
-if cp\='' then interpret 'call "' || envset || '"' '"; CLASSPATH"' '"' || cp || '"'
-if lcp\='' then interpret 'call "' || envset || '"' '"; LOCALCLASSPATH"' '"' || lcp || '"'
-if opts\='' then interpret 'call "' || envset || '"' '"-D ANT_OPTS"' '"' || opts || '"'
-if args\='' then interpret 'call "' || envset || '"' '"ANT_ARGS"' '"' || args || '"'
-
-exit 0
-
-addpath: procedure
-parse arg path elem
-if elem = '' then do
- if path\='' & right(path, 1)\=';' then path = path || ';'
- return path
-end
-if substr(path, length(path)) = ';' then glue = ''
-else glue = ';'
-if pos(translate(elem), translate(path)) = 0 then path = path || glue || elem || ';'
-return path
-
-prepend: procedure
-parse arg path elem
-if elem = '' then do
- if path\='' & right(path, 1)\=';' then path = path || ';'
- return path
-end
-if pos(translate(elem), translate(path)) = 0 then path = elem || ';' || path
-return path
-
-_getenv_: procedure expose env
-parse arg envar default
-if default = '' then default = envar
-var = value(translate(envar),,env)
-if var = '' then var = default
-return var
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+'@echo off'
+call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
+call SysLoadFuncs
+
+/* Prepare the parameters for later use */
+parse arg argv
+mode = ''
+args = ''
+opts = ''
+cp = ''
+lcp = ''
+
+do i = 1 to words(argv)
+ param = word(argv, i)
+ select
+ when param='-lcp' then mode = 'l'
+ when param='-cp' | param='-classpath' then mode = 'c'
+ when abbrev('-opts', param, 4) then mode = 'o'
+ when abbrev('-args', param, 4) then mode = 'a'
+ otherwise
+ select
+ when mode = 'a' then args = space(args param, 1)
+ when mode = 'c' then cp = space(cp param, 1)
+ when mode = 'l' then lcp = space(lcp param, 1)
+ when mode = 'o' then opts = space(opts param, 1)
+ otherwise
+ say 'Option' param 'ignored'
+ end
+ end
+end
+
+env="OS2ENVIRONMENT"
+antconf = _getenv_('antconf' 'antconf.cmd')
+runrc = _getenv_('runrc')
+interpret 'call "' || runrc || '"' '"' || antconf || '"' 'ETC'
+ANT_HOME = value('ANT_HOME',,env)
+JAVA_HOME = value('JAVA_HOME',,env)
+classpath = value('CLASSPATH',,env)
+classes = stream(JAVA_HOME || "\lib\classes.zip", "C", "QUERY EXISTS")
+if classes \= '' then classpath = prepend(classpath classes)
+classes = stream(JAVA_HOME || "\lib\tools.jar", "C", "QUERY EXISTS")
+if classes \= '' then classpath = prepend(classpath classes)
+
+classpath = prepend(classpath ANT_HOME || '\lib\ant-launcher.jar')
+'SET CLASSPATH=' || classpath
+
+/* Setting classpathes, options and arguments */
+envset = _getenv_('envset')
+if cp\='' then interpret 'call "' || envset || '"' '"; CLASSPATH"' '"' || cp || '"'
+if lcp\='' then interpret 'call "' || envset || '"' '"; LOCALCLASSPATH"' '"' || lcp || '"'
+if opts\='' then interpret 'call "' || envset || '"' '"-D ANT_OPTS"' '"' || opts || '"'
+if args\='' then interpret 'call "' || envset || '"' '"ANT_ARGS"' '"' || args || '"'
+
+exit 0
+
+addpath: procedure
+parse arg path elem
+if elem = '' then do
+ if path\='' & right(path, 1)\=';' then path = path || ';'
+ return path
+end
+if substr(path, length(path)) = ';' then glue = ''
+else glue = ';'
+if pos(translate(elem), translate(path)) = 0 then path = path || glue || elem || ';'
+return path
+
+prepend: procedure
+parse arg path elem
+if elem = '' then do
+ if path\='' & right(path, 1)\=';' then path = path || ';'
+ return path
+end
+if pos(translate(elem), translate(path)) = 0 then path = elem || ';' || path
+return path
+
+_getenv_: procedure expose env
+parse arg envar default
+if default = '' then default = envar
+var = value(translate(envar),,env)
+if var = '' then var = default
+return var
diff --git a/modules/common/ant-bundle/src/main/assembly/bin/envset.cmd b/modules/common/ant-bundle/src/main/assembly/bin/envset.cmd
index 3149be4..3b07419 100644
--- a/modules/common/ant-bundle/src/main/assembly/bin/envset.cmd
+++ b/modules/common/ant-bundle/src/main/assembly/bin/envset.cmd
@@ -1,131 +1,131 @@
-/*
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-SET environment variables
-First optional parameter:
- ; parameters are considered parts of a path variable, semicolons are
- appended to each element if not already present
- -D parameters are properties for Java or Makefile etc., -D will be
- prepended and the parameters will be separated by a space
- =D the same as above but equal sign is not required
- , parameters should be comma separated in the environment variable
- - parameters should be separated by the next parameter
- Other values mean that the first parameter is missing and the environment
- variable will be set to the space separated parameters
-
-Second parameter: name of the environment variable
-
-Next parameters: values
-; implies that the equal sign is considered a part of the parameter and is
-not interpreted
-
--D requires parameters in the form name=value. If the equal sign is not found,
-the parameters are changed to name=expanded_name
-
-Other options have optional equal sign. If it is found, only the part after
-the equal sign will be oprionally expanded.
-
-If the parameter is the minus sign, the next parameter will not be expanded.
-If the parameter is a single dot, it will be replaced with the value of the
-environment variable as it existed before envset was invoked.
-
-For other parameters the batch looks for the environment variable with the
-same name (in uppercase). If it is found, it forms the expanded_name. If
-the environment variable with such a name does not exist, the expanded_name
-will hold the parameter name without case conversion.
-*/
-
-parse arg mode envar args
-
-equal = 0
-sep = ' '
-
-/* Parse command line parameters */
-select
- when mode='-' then do
- sep = envar
- parse var args envar args
- end
- when mode=';' then do
- sep = ''
- equal = -1
- end
- when mode='-D' then equal = 1
- when mode='=D' then mode = '-D'
- when mode=',' then sep = ','
-otherwise
- args = envar args
- envar = mode
- mode = ''
-end
-
-env = 'OS2ENVIRONMENT'
-envar = translate(envar)
-orig = value(envar,,env)
-newval = ''
-expand = 1
-
-/* for each parameter... */
-do i = 1 to words(args)
- if expand > 0 & word(args, i) = '-' then expand = 0
- else call addval word(args, i)
-end
-
-/* Optionally enclose path variable by quotes */
-if mode = ';' & pos(' ', newval) > 0 then newval = '"' || newval || '"'
-
-/* Set the new value, 'SET' cannot be used since it does not allow '=' */
-x = value(envar, newval, env)
-exit 0
-
-addval: procedure expose sep equal orig expand newval mode env
-parse arg var
-
-if var = '.' then expvar = orig
-else do
- if equal >= 0 then do
- parse var var name '=' val
- if val = '' then var = name
- else var = val
- end
- if expand = 0 then expvar = var
- else expvar = value(translate(var),,env)
- if expvar = '' then expvar = var
- if equal >= 0 then do
- if val = '' then do
- parse var expvar key '=' val
- if val <> '' then name = key
- else do
- if equal > 0 then val = key
- else name = key
- end
- end
- else val = expvar
- if pos(' ', val) > 0 | pos('=', val) > 0 then val = '"' || val || '"'
- if val = '' then expvar = name
- else expvar = name || '=' || val
- end
- if mode = '-D' then expvar = '-D' || expvar
- if mode = ';' then do
- if right(expvar, 1) <> ';' then expvar = expvar || ';'
- end
-end
-
-if newval = '' then newval = expvar
-else newval = newval || sep || expvar
-expand = 1
-return
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+SET environment variables
+First optional parameter:
+ ; parameters are considered parts of a path variable, semicolons are
+ appended to each element if not already present
+ -D parameters are properties for Java or Makefile etc., -D will be
+ prepended and the parameters will be separated by a space
+ =D the same as above but equal sign is not required
+ , parameters should be comma separated in the environment variable
+ - parameters should be separated by the next parameter
+ Other values mean that the first parameter is missing and the environment
+ variable will be set to the space separated parameters
+
+Second parameter: name of the environment variable
+
+Next parameters: values
+; implies that the equal sign is considered a part of the parameter and is
+not interpreted
+
+-D requires parameters in the form name=value. If the equal sign is not found,
+the parameters are changed to name=expanded_name
+
+Other options have optional equal sign. If it is found, only the part after
+the equal sign will be oprionally expanded.
+
+If the parameter is the minus sign, the next parameter will not be expanded.
+If the parameter is a single dot, it will be replaced with the value of the
+environment variable as it existed before envset was invoked.
+
+For other parameters the batch looks for the environment variable with the
+same name (in uppercase). If it is found, it forms the expanded_name. If
+the environment variable with such a name does not exist, the expanded_name
+will hold the parameter name without case conversion.
+*/
+
+parse arg mode envar args
+
+equal = 0
+sep = ' '
+
+/* Parse command line parameters */
+select
+ when mode='-' then do
+ sep = envar
+ parse var args envar args
+ end
+ when mode=';' then do
+ sep = ''
+ equal = -1
+ end
+ when mode='-D' then equal = 1
+ when mode='=D' then mode = '-D'
+ when mode=',' then sep = ','
+otherwise
+ args = envar args
+ envar = mode
+ mode = ''
+end
+
+env = 'OS2ENVIRONMENT'
+envar = translate(envar)
+orig = value(envar,,env)
+newval = ''
+expand = 1
+
+/* for each parameter... */
+do i = 1 to words(args)
+ if expand > 0 & word(args, i) = '-' then expand = 0
+ else call addval word(args, i)
+end
+
+/* Optionally enclose path variable by quotes */
+if mode = ';' & pos(' ', newval) > 0 then newval = '"' || newval || '"'
+
+/* Set the new value, 'SET' cannot be used since it does not allow '=' */
+x = value(envar, newval, env)
+exit 0
+
+addval: procedure expose sep equal orig expand newval mode env
+parse arg var
+
+if var = '.' then expvar = orig
+else do
+ if equal >= 0 then do
+ parse var var name '=' val
+ if val = '' then var = name
+ else var = val
+ end
+ if expand = 0 then expvar = var
+ else expvar = value(translate(var),,env)
+ if expvar = '' then expvar = var
+ if equal >= 0 then do
+ if val = '' then do
+ parse var expvar key '=' val
+ if val <> '' then name = key
+ else do
+ if equal > 0 then val = key
+ else name = key
+ end
+ end
+ else val = expvar
+ if pos(' ', val) > 0 | pos('=', val) > 0 then val = '"' || val || '"'
+ if val = '' then expvar = name
+ else expvar = name || '=' || val
+ end
+ if mode = '-D' then expvar = '-D' || expvar
+ if mode = ';' then do
+ if right(expvar, 1) <> ';' then expvar = expvar || ';'
+ end
+end
+
+if newval = '' then newval = expvar
+else newval = newval || sep || expvar
+expand = 1
+return
diff --git a/modules/common/ant-bundle/src/main/assembly/bin/lcp.bat b/modules/common/ant-bundle/src/main/assembly/bin/lcp.bat
index dc7e9bf..4bf2e7c 100644
--- a/modules/common/ant-bundle/src/main/assembly/bin/lcp.bat
+++ b/modules/common/ant-bundle/src/main/assembly/bin/lcp.bat
@@ -1,31 +1,31 @@
-REM
-REM Licensed to the Apache Software Foundation (ASF) under one or more
-REM contributor license agreements. See the NOTICE file distributed with
-REM this work for additional information regarding copyright ownership.
-REM The ASF licenses this file to You under the Apache License, Version 2.0
-REM (the "License"); you may not use this file except in compliance with
-REM the License. You may obtain a copy of the License at
-REM
-REM http://www.apache.org/licenses/LICENSE-2.0
-REM
-REM Unless required by applicable law or agreed to in writing, software
-REM distributed under the License is distributed on an "AS IS" BASIS,
-REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-REM See the License for the specific language governing permissions and
-REM limitations under the License.
-REM
-REM
-
-set _CLASSPATHCOMPONENT=%1
-if ""%1""=="""" goto gotAllArgs
-shift
-
-:argCheck
-if ""%1""=="""" goto gotAllArgs
-set _CLASSPATHCOMPONENT=%_CLASSPATHCOMPONENT% %1
-shift
-goto argCheck
-
-:gotAllArgs
-set LOCALCLASSPATH=%LOCALCLASSPATH%;%_CLASSPATHCOMPONENT%
-
+REM
+REM Licensed to the Apache Software Foundation (ASF) under one or more
+REM contributor license agreements. See the NOTICE file distributed with
+REM this work for additional information regarding copyright ownership.
+REM The ASF licenses this file to You under the Apache License, Version 2.0
+REM (the "License"); you may not use this file except in compliance with
+REM the License. You may obtain a copy of the License at
+REM
+REM http://www.apache.org/licenses/LICENSE-2.0
+REM
+REM Unless required by applicable law or agreed to in writing, software
+REM distributed under the License is distributed on an "AS IS" BASIS,
+REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+REM See the License for the specific language governing permissions and
+REM limitations under the License.
+REM
+REM
+
+set _CLASSPATHCOMPONENT=%1
+if ""%1""=="""" goto gotAllArgs
+shift
+
+:argCheck
+if ""%1""=="""" goto gotAllArgs
+set _CLASSPATHCOMPONENT=%_CLASSPATHCOMPONENT% %1
+shift
+goto argCheck
+
+:gotAllArgs
+set LOCALCLASSPATH=%LOCALCLASSPATH%;%_CLASSPATHCOMPONENT%
+
diff --git a/modules/common/ant-bundle/src/main/assembly/bin/rhq-ant.cmd b/modules/common/ant-bundle/src/main/assembly/bin/rhq-ant.cmd
index 70665c0..d221a40 100644
--- a/modules/common/ant-bundle/src/main/assembly/bin/rhq-ant.cmd
+++ b/modules/common/ant-bundle/src/main/assembly/bin/rhq-ant.cmd
@@ -1,93 +1,93 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- Run ant
-*/
-
-'@echo off'
-parse arg mode envarg '::' antarg
-
-if mode\='.' & mode\='..' & mode\='/' then do
- envarg = mode envarg
- mode = ''
-end
-
-if antarg = '' then do
- antarg = envarg
- envarg = ''
-end
-
-x = setlocal()
-
-env="OS2ENVIRONMENT"
-antenv = _getenv_('antenv')
-if _testenv_() = 0 then interpret 'call "' || antenv || '"' '"' || envarg || '"'
-
-if mode = '' then mode = _getenv_('ANT_MODE' '..')
-if mode \= '/' then do
- runrc = _getenv_('runrc')
- antrc = _getenv_('antrc' 'antrc.cmd')
- if mode = '..' then mode = '-r'
- else mode = ''
- interpret 'call "' || runrc || '"' antrc '"' || mode || '"'
-end
-
-if _testenv_() = 0 then do
- say 'Ant environment is not set properly'
- x = endlocal()
- exit 16
-end
-
-settings = '-Dant.home=' || ANT_HOME '-Djava.home=' || JAVA_HOME
-
-java = _getenv_('javacmd' 'java')
-opts = value('ANT_OPTS',,env)
-args = value('ANT_ARGS',,env)
-lcp = value('LOCALCLASSPATH',,env)
-cp = value('CLASSPATH',,env)
-if value('ANT_USE_CP',,env) \= '' then do
- if lcp \= '' & right(lcp, 1) \= ';' then lcp = lcp || ';'
- lcp = lcp || cp
- 'SET CLASSPATH='
-end
-if lcp\='' then lcp = '-classpath' lcp
-
-cmd = java opts lcp '-jar' ANT_HOME ||'\lib\ant-launcher.jar' settings args antarg
-launcher = stream(ANT_HOME ||'\lib\ant-launcher.jar', 'C', 'query exists')
-if launcher = '' then entry = 'org.apache.tools.ant.Main'
-else entry = 'org.apache.tools.ant.launch.Launcher'
-java opts lcp entry settings args antarg
-
-x = endlocal()
-
-return rc
-
-_testenv_: procedure expose env ANT_HOME JAVA_HOME
-ANT_HOME = value('ANT_HOME',,env)
-if ANT_HOME = '' then return 0
-JAVA_HOME = value('JAVA_HOME',,env)
-if JAVA_HOME = '' then return 0
-cp = translate(value('CLASSPATH',,env))
-if pos(translate(ANT_HOME), cp) = 0 then return 0
-if pos(translate(JAVA_HOME), cp) = 0 then return 0
-return 1
-
-_getenv_: procedure expose env
-parse arg envar default
-if default = '' then default = envar
-var = value(translate(envar),,env)
-if var = '' then var = default
-return var
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ Run ant
+*/
+
+'@echo off'
+parse arg mode envarg '::' antarg
+
+if mode\='.' & mode\='..' & mode\='/' then do
+ envarg = mode envarg
+ mode = ''
+end
+
+if antarg = '' then do
+ antarg = envarg
+ envarg = ''
+end
+
+x = setlocal()
+
+env="OS2ENVIRONMENT"
+antenv = _getenv_('antenv')
+if _testenv_() = 0 then interpret 'call "' || antenv || '"' '"' || envarg || '"'
+
+if mode = '' then mode = _getenv_('ANT_MODE' '..')
+if mode \= '/' then do
+ runrc = _getenv_('runrc')
+ antrc = _getenv_('antrc' 'antrc.cmd')
+ if mode = '..' then mode = '-r'
+ else mode = ''
+ interpret 'call "' || runrc || '"' antrc '"' || mode || '"'
+end
+
+if _testenv_() = 0 then do
+ say 'Ant environment is not set properly'
+ x = endlocal()
+ exit 16
+end
+
+settings = '-Dant.home=' || ANT_HOME '-Djava.home=' || JAVA_HOME
+
+java = _getenv_('javacmd' 'java')
+opts = value('ANT_OPTS',,env)
+args = value('ANT_ARGS',,env)
+lcp = value('LOCALCLASSPATH',,env)
+cp = value('CLASSPATH',,env)
+if value('ANT_USE_CP',,env) \= '' then do
+ if lcp \= '' & right(lcp, 1) \= ';' then lcp = lcp || ';'
+ lcp = lcp || cp
+ 'SET CLASSPATH='
+end
+if lcp\='' then lcp = '-classpath' lcp
+
+cmd = java opts lcp '-jar' ANT_HOME ||'\lib\ant-launcher.jar' settings args antarg
+launcher = stream(ANT_HOME ||'\lib\ant-launcher.jar', 'C', 'query exists')
+if launcher = '' then entry = 'org.apache.tools.ant.Main'
+else entry = 'org.apache.tools.ant.launch.Launcher'
+java opts lcp entry settings args antarg
+
+x = endlocal()
+
+return rc
+
+_testenv_: procedure expose env ANT_HOME JAVA_HOME
+ANT_HOME = value('ANT_HOME',,env)
+if ANT_HOME = '' then return 0
+JAVA_HOME = value('JAVA_HOME',,env)
+if JAVA_HOME = '' then return 0
+cp = translate(value('CLASSPATH',,env))
+if pos(translate(ANT_HOME), cp) = 0 then return 0
+if pos(translate(JAVA_HOME), cp) = 0 then return 0
+return 1
+
+_getenv_: procedure expose env
+parse arg envar default
+if default = '' then default = envar
+var = value(translate(envar),,env)
+if var = '' then var = default
+return var
diff --git a/modules/common/ant-bundle/src/main/assembly/bin/runrc.cmd b/modules/common/ant-bundle/src/main/assembly/bin/runrc.cmd
index 34b4f5d..c68f04d 100644
--- a/modules/common/ant-bundle/src/main/assembly/bin/runrc.cmd
+++ b/modules/common/ant-bundle/src/main/assembly/bin/runrc.cmd
@@ -1,60 +1,60 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- Run RC file, name is in the first arg, second arg is either PATH
- ENV or -r or nothing
-*/
-
-parse arg name path rest
-
-if name = '' then do
- say 'RC file name is missing'
- exit 1
-end
-
-if rest \= '' then do
- say 'Too many parameters'
- exit 1
-end
-
-call runit name path
-exit 0
-
-runit: procedure
-parse arg name path dir
-
-if path \= '' & path \= '-r' then do
- dir = value(translate(path),,'OS2ENVIRONMENT')
- if dir = '' then return
- dir = translate(dir, '\', '/') /* change UNIX-like path to OS/2 */
-end
-
-if dir = '' then dir = directory()
-
-if path = '-r' then do /* recursive call */
- subdir = filespec('path', dir)
- if subdir \= '\' then do
- subdir = left(subdir, length(subdir)-1)
- call runit name path filespec('drive', dir) || subdir
- end
-end
-
-/* Look for the file and run it */
-if right(dir, 1) \= '\' then dir = dir || '\'
-rcfile = stream(dir || name, 'c', 'query exists')
-if rcfile \= '' then interpret 'call "' || rcfile || '"'
-
-return
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ Run RC file, name is in the first arg, second arg is either PATH
+ ENV or -r or nothing
+*/
+
+parse arg name path rest
+
+if name = '' then do
+ say 'RC file name is missing'
+ exit 1
+end
+
+if rest \= '' then do
+ say 'Too many parameters'
+ exit 1
+end
+
+call runit name path
+exit 0
+
+runit: procedure
+parse arg name path dir
+
+if path \= '' & path \= '-r' then do
+ dir = value(translate(path),,'OS2ENVIRONMENT')
+ if dir = '' then return
+ dir = translate(dir, '\', '/') /* change UNIX-like path to OS/2 */
+end
+
+if dir = '' then dir = directory()
+
+if path = '-r' then do /* recursive call */
+ subdir = filespec('path', dir)
+ if subdir \= '\' then do
+ subdir = left(subdir, length(subdir)-1)
+ call runit name path filespec('drive', dir) || subdir
+ end
+end
+
+/* Look for the file and run it */
+if right(dir, 1) \= '\' then dir = dir || '\'
+rcfile = stream(dir || name, 'c', 'query exists')
+if rcfile \= '' then interpret 'call "' || rcfile || '"'
+
+return
commit d6312fc475ab98b38720907aa9b224078db5fda7
Merge: c158d10... e782ace...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 11:14:39 2010 -0400
Merge branch 'master' into gwt-jay
commit c158d1058b09766457a201f7f3a052f9a431ea64
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 11:14:23 2010 -0400
LT commit
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.htmf b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.htmf
index 8a3a4b3..b207a5a 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.htmf
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.htmf
@@ -1,36 +1,36 @@
-<!-- Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
-$Id: main.htmf,v 1.3 2006/05/03 22:00:33 inder Exp $ -->
-
- <table valign="top" id="bodyTable" border="0">
- <tr>
- <td>
- <map name="petmap">
- <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('BIRDS')"
- alt="Birds"
- coords="72,2,280,250">
- <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('FISH')"
- alt="Fish"
- coords="2,180,72,250">
- <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('DOGS')"
- alt="Dogs"
- coords="60,250,130,320">
- <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('REPTILES')"
- alt="Reptiles"
- coords="140,270,210,340">
- <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('CATS')"
- alt="Cats"
- coords="225,240,295,310">
- <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('BIRDS')"
- alt="Birds"
- coords="280,180,350,250">
- </map>
-
- <img src="images/splash.gif"
- alt="Pet Selection Map"
- usemap="#petmap"
- width="350"
- height="355"
- border="0">
- </td>
- </tr>
+<!-- Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
+$Id: main.htmf,v 1.3 2006/05/03 22:00:33 inder Exp $ -->
+
+ <table valign="top" id="bodyTable" border="0">
+ <tr>
+ <td>
+ <map name="petmap">
+ <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('BIRDS')"
+ alt="Birds"
+ coords="72,2,280,250">
+ <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('FISH')"
+ alt="Fish"
+ coords="2,180,72,250">
+ <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('DOGS')"
+ alt="Dogs"
+ coords="60,250,130,320">
+ <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('REPTILES')"
+ alt="Reptiles"
+ coords="140,270,210,340">
+ <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('CATS')"
+ alt="Cats"
+ coords="225,240,295,310">
+ <area onmouseover="javascript:this.style.cursor='pointer';" onclick="loadCategory('BIRDS')"
+ alt="Birds"
+ coords="280,180,350,250">
+ </map>
+
+ <img src="images/splash.gif"
+ alt="Pet Selection Map"
+ usemap="#petmap"
+ width="350"
+ height="355"
+ border="0">
+ </td>
+ </tr>
</table>
\ No newline at end of file
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.js
index c0a175d..b8de8fc 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/main.js
@@ -1,21 +1,21 @@
-/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
-$Id: main.js,v 1.9 2006/05/03 22:00:33 inder Exp $ */
-
-var isIE;
-var bodyRowText;
-
-dojo.require("dojo.widget.FisheyeList");
-init();
-
-function browse(category) {
- window.location.href="catalog.jsp?catid=" + category;
-}
-
-function loadPetstore() {
- init();
- showMain();
-}
-
-function init() {
- if (navigator.userAgent.indexOf("IE") != -1) isIE = true;
-}
+/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
+$Id: main.js,v 1.9 2006/05/03 22:00:33 inder Exp $ */
+
+var isIE;
+var bodyRowText;
+
+dojo.require("dojo.widget.FisheyeList");
+init();
+
+function browse(category) {
+ window.location.href="catalog.jsp?catid=" + category;
+}
+
+function loadPetstore() {
+ init();
+ showMain();
+}
+
+function init() {
+ if (navigator.userAgent.indexOf("IE") != -1) isIE = true;
+}
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/news.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/news.js
index 29bf8cf..5bcac34 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/news.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/news.js
@@ -1,190 +1,190 @@
-
-dojo.require("dojo.io.*");
-dojo.require("dojo.event.*");
-
-var bpuinews;
-if (typeof bpuinews == "undefined") {
- bpuinews = new Object();
-}
-
-bpuinews.RSS = function() {
- var currentItem = 0;
- var limitCharNum = 75;
- var itemNum=0;
- var rssData = null;
- var prev;
- var next;
- var prevHit=false;
-
- this.getRssInJson = function (method, uri) {
- prev = document.getElementById("previous");
- next = document.getElementById("next");
- dojo.event.connect(prev, "onclick", function(evt) {showPrevious();});
- dojo.event.connect(next, "onclick", function (evt) {showNext();});
- prev.disabled=true;
-
- var encodedURI = encodeURI(method + "?style=json&itemCount=0&url="+uri);
- var bindArgs = {
- url: encodedURI,
- mimetype: "text/json",
- load: function (type, data, http) {
- handleJsonRss(data);
- },
- error: function (t, e) {
- dojo.debug("ERROR : " + e.message);
- }
- }
- dojo.io.bind(bindArgs);
- return false;
- }
-
- function handleJsonRss(json) {
- rssData = json;
- itemNum = json.channel.item.length;
- showNext();
- }
-
- function createUl(skip) {
- var i;
- var cp="<ul>\n";
- for (i = currentItem; i<currentItem + skip; i++) {
- cp += "<li><b>"+decodeURL(rssData.channel.item[i].title)+"</b>\n";
- cp += "<p>" + decodeURL(rssData.channel.item[i].description) + "</p>\n</li>\n";
- }
- cp += "</ul>\n";
- return cp;
- }
-
- // Following funcs(showNext, showPrevious) should be connected to the button
- // by dojo.event.connect.
- function showNext() {
- var skip = 5;
- if (prevHit) {
- currentItem = currentItem + skip;
- prevHit = false;
- }
- var nextCurrentItem = currentItem + skip;
- if (nextCurrentItem >= itemNum) {
- skip = itemNum - currentItem;
- // deactivate "next" button
- next.disabled=true;
- nextCurrentItem = currentItem;
- }
- // activate "previous" button
- if (currentItem != 0) {
- prev.disabled=false;
- }
- var cp = createUl(skip);
- var elm = document.getElementById("news");
- elm.innerHTML = cp;
- currentItem = nextCurrentItem;
- }
-
- function showPrevious() {
- prevHit = true;
- var skip = 5;
- currentItem = currentItem - skip;
- if (currentItem <= 0) {
- currentItem = 0;
- // deactivate "previous" button
- prev.disabled=true;
- }
- next.disabled=false;
- var cp = createUl(skip);
- var elm = document.getElementById("news");
- elm.innerHTML = cp;
- }
-
-
- /* Compatible function to java.net.URLDecoder.decode().
- * (decodeURI() is not compatible)
- */
- function decodeURL(str){
- var targetStr="";
- var s, tmpStr, unicode, f;
- // take a look at every char in the source str
- var i, j;
- for (i = 0; i < str.length; i++) {
- s = str.charAt(i);
- // handle WS, which is the most common char
- if (s == "+") {
- targetStr += " ";
- } else {
- if (s != "%") {
- // Non-encoded char
- targetStr += s;
- } else{
- // encoding begin
- unicode = 0; // uncode representation
- f = 1; // flag to specify the escape sequence
- while (true) {
- tmpStr = "";
- // get the two HEX chars and put that in the temp string. If no char, that is not a HEX.
- for (j = 0; j < 2; j++ ) {
- tmptmpStr = str.charAt(++i);
- if (((tmptmpStr >= "0") && (tmptmpStr <= "9")) ||
- ((tmptmpStr >= "a") && (tmptmpStr <= "f")) ||
- ((tmptmpStr >= "A") && (tmptmpStr <= "F"))) {
- tmpStr += tmptmpStr;
- } else {
- --i;
- break;
- }
- }
- /* parse the HEX
- * <= 0x7f : Single byte
- * >=0xc0 && <=0xdf : Two bytes
- * >=0xe0 && <=0xef : Three bytes
- * >=0xf0 && <=0xf7 : Four bytes
- * >=0x80 && <=0xbf : may not occur - just shift it
- * <=1 : sequence terminated
- */
- var byte = parseInt(tmpStr, 16);
- if (byte <= 0x7f) {unicode = byte; f = 1;}
- if ((byte >= 0xc0) && (byte <= 0xdf)) {unicode = byte & 0x1f; f = 2;}
- if ((byte >= 0xe0) && (byte <= 0xef)) {unicode = byte & 0x0f; f = 3;}
- if ((byte >= 0xf0) && (byte <= 0xf7)) {unicode = byte & 0x07; f = 4;}
- if ((byte >= 0x80) && (byte <= 0xbf)) {unicode = (unicode << 6) + (byte & 0x3f); --f;}
- if (f <= 1) {
- break;
- }
- if (str.charAt(i + 1) == "%") {
- i++ ;
- } else {
- // Error. should not occur
- break;
- }
- }
- targetStr += String.fromCharCode(unicode);
- }
- }
- }
- return targetStr;
- }
-
- /* Cut the string at the WS so that it's shorter than the limitCharNum.
- */
- function cutStringatWs(str, limitCharNum) {
- var tmpStr = str;
- var cnum = 0;
- while (true) {
- cnum = tmpStr.lastIndexOf(" ");
- // no occurance of WS
- if (cnum < 0) {
- // if str is still longer than limit
- if (tmpStr.length >= limitCharNum) {
- tmpStr = tmpStr.substring(0, limitCharNum);
- }
- break;
- } else {
- tmpStr = tmpStr.substring(0, cnum);
- if (cnum <= limitCharNum) {
- break;
- }
- }
- }
- return tmpStr;
- }
-
-}
-
+
+dojo.require("dojo.io.*");
+dojo.require("dojo.event.*");
+
+var bpuinews;
+if (typeof bpuinews == "undefined") {
+ bpuinews = new Object();
+}
+
+bpuinews.RSS = function() {
+ var currentItem = 0;
+ var limitCharNum = 75;
+ var itemNum=0;
+ var rssData = null;
+ var prev;
+ var next;
+ var prevHit=false;
+
+ this.getRssInJson = function (method, uri) {
+ prev = document.getElementById("previous");
+ next = document.getElementById("next");
+ dojo.event.connect(prev, "onclick", function(evt) {showPrevious();});
+ dojo.event.connect(next, "onclick", function (evt) {showNext();});
+ prev.disabled=true;
+
+ var encodedURI = encodeURI(method + "?style=json&itemCount=0&url="+uri);
+ var bindArgs = {
+ url: encodedURI,
+ mimetype: "text/json",
+ load: function (type, data, http) {
+ handleJsonRss(data);
+ },
+ error: function (t, e) {
+ dojo.debug("ERROR : " + e.message);
+ }
+ }
+ dojo.io.bind(bindArgs);
+ return false;
+ }
+
+ function handleJsonRss(json) {
+ rssData = json;
+ itemNum = json.channel.item.length;
+ showNext();
+ }
+
+ function createUl(skip) {
+ var i;
+ var cp="<ul>\n";
+ for (i = currentItem; i<currentItem + skip; i++) {
+ cp += "<li><b>"+decodeURL(rssData.channel.item[i].title)+"</b>\n";
+ cp += "<p>" + decodeURL(rssData.channel.item[i].description) + "</p>\n</li>\n";
+ }
+ cp += "</ul>\n";
+ return cp;
+ }
+
+ // Following funcs(showNext, showPrevious) should be connected to the button
+ // by dojo.event.connect.
+ function showNext() {
+ var skip = 5;
+ if (prevHit) {
+ currentItem = currentItem + skip;
+ prevHit = false;
+ }
+ var nextCurrentItem = currentItem + skip;
+ if (nextCurrentItem >= itemNum) {
+ skip = itemNum - currentItem;
+ // deactivate "next" button
+ next.disabled=true;
+ nextCurrentItem = currentItem;
+ }
+ // activate "previous" button
+ if (currentItem != 0) {
+ prev.disabled=false;
+ }
+ var cp = createUl(skip);
+ var elm = document.getElementById("news");
+ elm.innerHTML = cp;
+ currentItem = nextCurrentItem;
+ }
+
+ function showPrevious() {
+ prevHit = true;
+ var skip = 5;
+ currentItem = currentItem - skip;
+ if (currentItem <= 0) {
+ currentItem = 0;
+ // deactivate "previous" button
+ prev.disabled=true;
+ }
+ next.disabled=false;
+ var cp = createUl(skip);
+ var elm = document.getElementById("news");
+ elm.innerHTML = cp;
+ }
+
+
+ /* Compatible function to java.net.URLDecoder.decode().
+ * (decodeURI() is not compatible)
+ */
+ function decodeURL(str){
+ var targetStr="";
+ var s, tmpStr, unicode, f;
+ // take a look at every char in the source str
+ var i, j;
+ for (i = 0; i < str.length; i++) {
+ s = str.charAt(i);
+ // handle WS, which is the most common char
+ if (s == "+") {
+ targetStr += " ";
+ } else {
+ if (s != "%") {
+ // Non-encoded char
+ targetStr += s;
+ } else{
+ // encoding begin
+ unicode = 0; // uncode representation
+ f = 1; // flag to specify the escape sequence
+ while (true) {
+ tmpStr = "";
+ // get the two HEX chars and put that in the temp string. If no char, that is not a HEX.
+ for (j = 0; j < 2; j++ ) {
+ tmptmpStr = str.charAt(++i);
+ if (((tmptmpStr >= "0") && (tmptmpStr <= "9")) ||
+ ((tmptmpStr >= "a") && (tmptmpStr <= "f")) ||
+ ((tmptmpStr >= "A") && (tmptmpStr <= "F"))) {
+ tmpStr += tmptmpStr;
+ } else {
+ --i;
+ break;
+ }
+ }
+ /* parse the HEX
+ * <= 0x7f : Single byte
+ * >=0xc0 && <=0xdf : Two bytes
+ * >=0xe0 && <=0xef : Three bytes
+ * >=0xf0 && <=0xf7 : Four bytes
+ * >=0x80 && <=0xbf : may not occur - just shift it
+ * <=1 : sequence terminated
+ */
+ var byte = parseInt(tmpStr, 16);
+ if (byte <= 0x7f) {unicode = byte; f = 1;}
+ if ((byte >= 0xc0) && (byte <= 0xdf)) {unicode = byte & 0x1f; f = 2;}
+ if ((byte >= 0xe0) && (byte <= 0xef)) {unicode = byte & 0x0f; f = 3;}
+ if ((byte >= 0xf0) && (byte <= 0xf7)) {unicode = byte & 0x07; f = 4;}
+ if ((byte >= 0x80) && (byte <= 0xbf)) {unicode = (unicode << 6) + (byte & 0x3f); --f;}
+ if (f <= 1) {
+ break;
+ }
+ if (str.charAt(i + 1) == "%") {
+ i++ ;
+ } else {
+ // Error. should not occur
+ break;
+ }
+ }
+ targetStr += String.fromCharCode(unicode);
+ }
+ }
+ }
+ return targetStr;
+ }
+
+ /* Cut the string at the WS so that it's shorter than the limitCharNum.
+ */
+ function cutStringatWs(str, limitCharNum) {
+ var tmpStr = str;
+ var cnum = 0;
+ while (true) {
+ cnum = tmpStr.lastIndexOf(" ");
+ // no occurance of WS
+ if (cnum < 0) {
+ // if str is still longer than limit
+ if (tmpStr.length >= limitCharNum) {
+ tmpStr = tmpStr.substring(0, limitCharNum);
+ }
+ break;
+ } else {
+ tmpStr = tmpStr.substring(0, cnum);
+ if (cnum <= limitCharNum) {
+ break;
+ }
+ }
+ }
+ return tmpStr;
+ }
+
+}
+
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/rss.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/rss.js
index 3458b06..66700d3 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/rss.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/rss.js
@@ -1,110 +1,110 @@
-/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
-$Id: rss.js,v 1.3 2006/05/31 19:13:03 basler Exp $ */
-
-dojo.require("dojo.io.*");
-
-if (bpui = 'undefined') {
- bpui = new Object();
-}
-
-bpui.RSS = function() {
- var jsonData = null;
- var rssItemNum = 0;
- var currentItem = 0;
- var rssTimeout = null;
- var itemIntervalMsec = 2000;
- var rssFadeoutCounter = 110;
- var rssFadeinCounter = 110;
- var itemIntervalId = 0;
-
- this.getRssInJson = function (uri, number) {
- rssItemNum = number;
- var encodedURI = encodeURI(bpui.contextRoot + "/faces/dynamic/bpui_rssfeedhandler/getRssfeed?style=json&itemNumber="+number+"&url="+uri);
- //alert("encoded url=" + encodedURI);
- var bindArgs = {
- url: encodedURI,
- mimetype: "text/json",
- load: function (type, data, http) {
- handleJsonRss(data);
- for (var key in data.channel.item) {
- dojo.debug("ITEM Title ", key, ":", data.channel.item[key].title);
- dojo.debug("ITEM LInk ", key, ":", data.channel.item[key].link);
- }
- },
- error: function (t, e) {
- dj_debug("ERROR : " + e.message);
- }
- }
- dojo.io.bind(bindArgs);
- return false;
- }
-
- function handleJsonRss(json) {
- jsonData = json;
- // setting top title and link
- generateHref(json.channel.title, json.channel.link, "rss-channel");
- // setting items
- generateHref(json.channel.item[0].title, json.channel.item[0].link, "rss-item");
- var aNodes = document.getElementById("rss-item").getElementsByTagName("a");
- dojo.event.connect(aNodes[0], "onmouseover", "pauseCycle");
- dojo.event.connect(aNodes[0], "onmouseout", "resumeCycle");
- cycleRss();
- }
-
- function generateHref (title, link, nodeId) {
- var node = document.getElementById(nodeId);
- var aNode = document.createElement("a");
- aNode.setAttribute("href", link);
- aNode.appendChild(document.createTextNode(title));
- if (node.hasChildNodes()) {
- node.removeChild(node.firstChild);
- }
- node.appendChild(aNode);
- }
-
- function cycleRss () {
- itemIntervalId = setTimeout(replaceItem, itemIntervalMsec);
- }
-
-
- function replaceItem() {
- if (itemIntervalId) {
- clearTimeout(itemIntervalId);
- }
- // fadeout the current item and pop the next one in.
- var cItem = document.getElementById("rss-item");
- dojo.fx.html.fadeOut(cItem.getElementsByTagName('a')[0], 500);
- var waitId = setTimeout(function(waitId) {
- clearTimeout(waitId);
- //cItem.removeChild(cItem.firstChild);
- if (currentItem < (rssItemNum -1)) {
- currentItem += 1;
- } else {
- currentItem = 0;
- }
- generateHref(jsonData.channel.item[currentItem].title, jsonData.channel.item[currentItem].link, "rss-item");
- // attach event for onmouseover(pause) and onmouseout(resume)
- var aNodes = cItem.getElementsByTagName("a");
- dojo.event.connect(aNodes[0], "onmouseover", "pauseCycle");
- dojo.event.connect(aNodes[0], "onmouseout", "resumeCycle");
- cycleRss();}, 500);
- }
-
- function pauseCycle(evt) {
- if (itemIntervalId) {
- clearTimeout(itemIntervalId);
- }
- }
-
- function resumeCycle (evt) {
- cycleRss();
- }
-
- bpui.getContextRoot = function() {
- var urlArray=window.location.toString().split("/", 4);
- return "/" + urlArray[3];
- }
-
- bpui.contextRoot = bpui.getContextRoot();
-}
-
+/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
+$Id: rss.js,v 1.3 2006/05/31 19:13:03 basler Exp $ */
+
+dojo.require("dojo.io.*");
+
+if (bpui = 'undefined') {
+ bpui = new Object();
+}
+
+bpui.RSS = function() {
+ var jsonData = null;
+ var rssItemNum = 0;
+ var currentItem = 0;
+ var rssTimeout = null;
+ var itemIntervalMsec = 2000;
+ var rssFadeoutCounter = 110;
+ var rssFadeinCounter = 110;
+ var itemIntervalId = 0;
+
+ this.getRssInJson = function (uri, number) {
+ rssItemNum = number;
+ var encodedURI = encodeURI(bpui.contextRoot + "/faces/dynamic/bpui_rssfeedhandler/getRssfeed?style=json&itemNumber="+number+"&url="+uri);
+ //alert("encoded url=" + encodedURI);
+ var bindArgs = {
+ url: encodedURI,
+ mimetype: "text/json",
+ load: function (type, data, http) {
+ handleJsonRss(data);
+ for (var key in data.channel.item) {
+ dojo.debug("ITEM Title ", key, ":", data.channel.item[key].title);
+ dojo.debug("ITEM LInk ", key, ":", data.channel.item[key].link);
+ }
+ },
+ error: function (t, e) {
+ dj_debug("ERROR : " + e.message);
+ }
+ }
+ dojo.io.bind(bindArgs);
+ return false;
+ }
+
+ function handleJsonRss(json) {
+ jsonData = json;
+ // setting top title and link
+ generateHref(json.channel.title, json.channel.link, "rss-channel");
+ // setting items
+ generateHref(json.channel.item[0].title, json.channel.item[0].link, "rss-item");
+ var aNodes = document.getElementById("rss-item").getElementsByTagName("a");
+ dojo.event.connect(aNodes[0], "onmouseover", "pauseCycle");
+ dojo.event.connect(aNodes[0], "onmouseout", "resumeCycle");
+ cycleRss();
+ }
+
+ function generateHref (title, link, nodeId) {
+ var node = document.getElementById(nodeId);
+ var aNode = document.createElement("a");
+ aNode.setAttribute("href", link);
+ aNode.appendChild(document.createTextNode(title));
+ if (node.hasChildNodes()) {
+ node.removeChild(node.firstChild);
+ }
+ node.appendChild(aNode);
+ }
+
+ function cycleRss () {
+ itemIntervalId = setTimeout(replaceItem, itemIntervalMsec);
+ }
+
+
+ function replaceItem() {
+ if (itemIntervalId) {
+ clearTimeout(itemIntervalId);
+ }
+ // fadeout the current item and pop the next one in.
+ var cItem = document.getElementById("rss-item");
+ dojo.fx.html.fadeOut(cItem.getElementsByTagName('a')[0], 500);
+ var waitId = setTimeout(function(waitId) {
+ clearTimeout(waitId);
+ //cItem.removeChild(cItem.firstChild);
+ if (currentItem < (rssItemNum -1)) {
+ currentItem += 1;
+ } else {
+ currentItem = 0;
+ }
+ generateHref(jsonData.channel.item[currentItem].title, jsonData.channel.item[currentItem].link, "rss-item");
+ // attach event for onmouseover(pause) and onmouseout(resume)
+ var aNodes = cItem.getElementsByTagName("a");
+ dojo.event.connect(aNodes[0], "onmouseover", "pauseCycle");
+ dojo.event.connect(aNodes[0], "onmouseout", "resumeCycle");
+ cycleRss();}, 500);
+ }
+
+ function pauseCycle(evt) {
+ if (itemIntervalId) {
+ clearTimeout(itemIntervalId);
+ }
+ }
+
+ function resumeCycle (evt) {
+ cycleRss();
+ }
+
+ bpui.getContextRoot = function() {
+ var urlArray=window.location.toString().split("/", 4);
+ return "/" + urlArray[3];
+ }
+
+ bpui.contextRoot = bpui.getContextRoot();
+}
+
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/scroller.js b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/scroller.js
index cb46fa2..1f72578 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/scroller.js
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/scroller.js
@@ -1,643 +1,643 @@
-/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
-$Id: scroller.js,v 1.32 2007/01/17 18:00:09 basler Exp $ */
-
-/**
-* ImageScroller - A multipurpose item brower
-* @ Author: Greg Murray
-*
-*/
-
-function getApplicationContextRoot() {
- var urlArray=window.location.toString().split("/", 4);
- return "/" + urlArray[3];
-}
-
-var applicationContextRoot=getApplicationContextRoot();
-
-
-function ImageScroller() {
- var _this = this;
- var initialized = false;
- // default sizes
-
- var VIEWPORT_WIDTH = 500;
- // all sizes are realitive the the viewport width
- var IMAGEPANE_WIDTH = VIEWPORT_WIDTH;
- var IMAGEPANE_HEIGHT = Math.round(VIEWPORT_WIDTH / 1.49);
- var INFOPANE_DEFAULT_HEIGHT = Math.round(VIEWPORT_WIDTH / 6.67);
- var INFOPANE_EXPAND_HEIGHT = Math.round(VIEWPORT_WIDTH / 2.86);
- var THUMB_WIDTH = Math.round(VIEWPORT_WIDTH / 5);;
- var THUMB_HEIGHT = Math.round(VIEWPORT_WIDTH / 6.67);
-
- var CHUNK_SIZE = 7;
- var PREFETCH_THRESHHOLD = 5;
-
- var IMAGE_PANE_ID = "imagePane";
- var IMAGE_PANE_BUFFER_ID = "imageBufferPane";
-
- var PADDING = 3;
-
- var MINIMIZE_IMG_URI = applicationContextRoot + "/images/minimize.gif";
- var MAXIMIZE_IMG_URI = applicationContextRoot + "/images/maximize.gif";
- var INDICATOR_IMG_URI = applicationContextRoot + "/images/indicator-black.gif";
- var MAXIMIZE_IMG_TOOLTIP = "Show Details";
- var MINIMIZE_IMG_TOOLTIP = "Show Less Details";
-
- // this is an array of the tiles which are divs for each thumb
- var tiles = [];
-
- var injectionPoint;
-
- // for scrolling
-
- var SCROLL_INCREMENT = 5;
- var INFOPANE_INCREMENT = 3;
- var tileY;
- var tileX;
- // this is the index of the image tile on the far left
- var index = 0;
- // keeps track how for the scroll has gone
- var offset = 0;
-
- var timeout = 30; // in ms
- var isScrollingRight = false;
- var isScrollingLeft = false;
-
- // large image pane
- var imagePane;
- var imageLoadingPane;
- var loadingPane;
- // images
- var minimizeImage;
-
- var indicatorImage;
- var leftButton;
- var rightButton;
-
- // infopane
- var infoPane;
- var infoTableMinimize;
- var indicatorCell;
- var minimizeLink;
- var infoPaneLoop = 0;
- var maximizing = false;
- var minimizing = false;
- var maximized = false;
-
- // prefetch thresh-hold
- var prefetchThreshold = 2;
-
- // a growing list of items;
- var items = [];
- // cached chunks that are already in the items array
- var loadedChunks = [];
-
- // used for debugging when debug is true
- var debug = false;
- var statusDiv;
- var status2Div;
-
- var showingBuffer = false;
- var imageBuffer;
- var imageReloadTries = 0;
- var IMG_RELOAD_RETRY_MAX = 30;
- // used for url book marking
-
-
- var pid;
- var currentChunk;
- // this map contains all the items
- var map;
- // this is the main container div
- var containerDiv;
-
- this.getItems = function() {
- return map;
- }
-
- this.getScrollerItems = function() {
- return items;
- }
-
-
- this.getGroupId = function() {
- return pid;
- }
-
- this.reset = function() {
- resetTitles()
- tiles = [];
- index = 0;
- offset = 0;
- currentChunk = 0;
- items = [];
- loadedChunks = [];
- }
-
- function resetTitles() {
- for (var l = 0; l < tiles.length; l++) {
- tiles[l].parentNode.removeChild(tiles[l]);
- }
- }
-
- // event bound to the mouseOut event of both scroll buttons
- function scrollDone() {
- isScrollingLeft = false;
- isScrollingRight = false;
- }
-
- // looping method for time out
- function scroll() {
- if (isScrollingRight) scrollRight();
- else if (isScrollingLeft) scrollLeft();
- }
-
-
- // do the value list pre-emptive fetching
- function prefetch() {
- //printDebug("** scoller index = " + index);
- if (isScrollingRight && (index + PREFETCH_THRESHHOLD) % CHUNK_SIZE == 0) {
-
- if ((Math.round(index / CHUNK_SIZE)) >= currentChunk) {
- currentChunk = Math.round(index / CHUNK_SIZE) + 1;
- // fire an event
- dojo.event.topic.publish("/catalog", {type:"getChunk", id: pid, index: index, currentChunk: currentChunk});
- }
- }
- }
-
- this.setGroupId = function(id) {
- pid = id;
- }
-
- this.containsChunk = function(chunkId) {
- printDebug("containsChunk = " + loadedChunks);
- ret=false;
- for(ii=0; ii < loadedChunks.length; ii++) {
- if(chunkId == loadedChunks[ii]) {
- ret=true;
- break;
- }
- }
- return ret;
- }
-
- this.addChunk = function(chunkId) {
- loadedChunks.push(chunkId);
- }
-
- this.addItems = function(inItems) {
- for (var loop=0; loop < inItems.length ; loop++) {
- items.push(inItems[loop]);
- map.put(inItems[loop].id, inItems[loop]);
- createTile(inItems[loop]);
- if (loop == 0 && !loadImage) {
- showImage(inItems[loop].id);
- }
-
- }
- drawTiles();
- rightButton.style.visibility="visible";
- _this.hideProgressIndicator();
- }
-
- this.showProgressIndicator = function() {
- if (indicatorImage) {
- indicatorImage.style.visibility = "visible";
- }
- }
-
- this.hideProgressIndicator = function() {
- indicatorImage.style.visibility = "hidden";
- }
-
- function postImageLoad(loadIntoBuffer) {
- if (debug) {
- status2Div.innerHTML = "Try " + imageReloadTries + " " + url + " image.complete=" + imageBuffer.complete;
- }
- // keep calling this funtion until imageReloadTries < IMG_RELOAD_RETRY_MAX
- if (!imageBuffer.complete) {
- if (imageReloadTries < IMG_RELOAD_RETRY_MAX) {
- setTimeout(function(){this.loadIntoBuffer = loadIntoBuffer;postImageLoad(loadIntoBuffer);},500);
- } else {
- this.hideProgressIndicator();
- }
- imageReloadTries = imageReloadTries + 1;
- return;
- }
- var id;
-
- _this.hideProgressIndicator();
- if (loadIntoBuffer) {
- imageLoadingPane.src = imageBuffer.src;
- } else {
- imagePane.src = imageBuffer.src;
-
- }
- // do a cross fade as long as the images aren't the same
- if (imageLoadingPane.src != imagePane.src) {
- crossFade(0,loadIntoBuffer );
- }
- }
-
-
- this.showImage = function(itemId) {
-
- _this.showProgressIndicator();
- //setTimeout(this.showProgressIndicator,0);
- var i = map.get(itemId);
-
- if (!i) {
- return;
- }
- dojo.event.topic.publish("/catalog", {type:"showingItem", id: itemId, rating: i.rating});
- // create the image pane and append the description nodes
- // asumption is that if the imagePane is not set neigher are the info children
- if (typeof imagePane == 'undefined') {
- imagePane = document.createElement("img");
- imagePane.style.width = IMAGEPANE_WIDTH + "px";
- imagePane.style.height = IMAGEPANE_HEIGHT + "px";
- imagePane.id = IMAGE_PANE_ID;
-
- var targetElement = document.getElementById("bodySpace");
- imageLoadingPane = document.createElement("img");
- imageLoadingPane.style.position = "absolute";
- imageLoadingPane.style.visibility = "hidden";
- imageLoadingPane.style.width = IMAGEPANE_WIDTH + "px";
- imageLoadingPane.style.height = IMAGEPANE_HEIGHT + "px";
- imageLoadingPane.id = IMAGE_PANE_BUFFER_ID;
- targetElement.appendChild(imagePane);
- targetElement.appendChild(imageLoadingPane);
- imageLoadingPane.style.left = tileX + "px";
-
- loadImage(i.image, false);
- } else {
- imageLoadingPane.style.visibility = "visible";
- if (showingBuffer) {
- showingBuffer = false;
- } else {
- showingBuffer = true;
- }
- loadImage(i.image, showingBuffer);
- }
- }
-
- function loadImage(url, loadIntoBuffer) {
- imageReloadTries = 0;
- imageBuffer = new Image();
- if (loadIntoBuffer) {
- imageBuffer.src = url;
- imageLoadingPane.onLoad = setTimeout(function(){this.url=url;this.loadIntoBuffer = loadIntoBuffer;postImageLoad(loadIntoBuffer,url);},0);
- } else {
- imageBuffer.src = url;
- imageBuffer.onLoad = setTimeout(function(){this.url = url;this.loadIntoBuffer = loadIntoBuffer;postImageLoad(loadIntoBuffer,url);},0);
- }
- }
-
- function setOpacity(opacity, id) {
- var target = document.getElementById(id);
- if (typeof target.style.filter != 'undefined') {
- target.style.filter = "alpha(opacity:" + opacity + ")";
- } else {
- target.style.opacity = opacity/100;
- }
- }
-
- function crossFade(count,loadIntoBuffer) {
- var percentage = Number(count);
- if (loadIntoBuffer) {
- setOpacity(100 - percentage, IMAGE_PANE_ID);
- setOpacity(percentage, IMAGE_PANE_BUFFER_ID);
- } else {
- setOpacity(100 - percentage, IMAGE_PANE_BUFFER_ID);
- setOpacity(percentage, IMAGE_PANE_ID);
-
- }
- if (percentage < 100) {
- percentage = percentage + 10;
- setTimeout(function(){this.loadIntoBuffer = loadIntoBuffer;this.percentage = percentage;crossFade(percentage,loadIntoBuffer);}, 25);
- }
- }
-
-
- // calling this function will result in the maximizing event being fired
- // if the pane is maximized it will asume the event want to minimize
- this.doMaximize = function() {
- if (!maximizing && !minimizing && !maximized) {
- infoPaneLoop = INFOPANE_DEFAULT_HEIGHT;
- maximizing = true;
- minimizing = false;
- } else if (!maximizing && !minimizing) {
- minimizing = true;
- maximizing = false;
- }
- setTimeout(changeInfoPane, 0);
- }
-
- // will handle either minimizing or maximing but not both
- // this method is called recursively until the maximinging
- // or minimizing is done.
- function changeInfoPane() {
- if (maximizing) {
- maxmizeInfoPane();
- } else if (minimizing) {
- minimizeInfoPane();
- }
- }
-
- function maxmizeInfoPane() {
- if (infoPaneLoop < INFOPANE_EXPAND_HEIGHT) {
- infoPaneLoop = infoPaneLoop + INFOPANE_INCREMENT;
- var clipMe = 'rect(' + '0px,' + VIEWPORT_WIDTH + 'px,'+ infoPaneLoop +'px,' + 0 + 'px)';
- infoPane.style.clip = clipMe;
- infoPane.style.height = infoPaneLoop;
- infoPane.style.top = (tileY + (PADDING *2) + INFOPANE_DEFAULT_HEIGHT + IMAGEPANE_HEIGHT) - infoPaneLoop;
- setTimeout(changeInfoPane, 5);
- } else {
- minimizeImage.src= MINIMIZE_IMG_URI;
- minimizeLink.title = MINIMIZE_IMG_TOOLTIP;
- maximized = true;
- maximizing = false;
- minimizing = false;
- }
- }
-
- function minimizeInfoPane() {
- if (infoPaneLoop > INFOPANE_DEFAULT_HEIGHT) {
- infoPaneLoop = infoPaneLoop - INFOPANE_INCREMENT;
- var clipMe = 'rect(' + '0px,' + VIEWPORT_WIDTH + 'px,'+ infoPaneLoop +'px,' + 0 + 'px)';
- infoPane.style.clip = clipMe;
- infoPane.style.height = infoPaneLoop;
- infoPane.style.top = (tileY + (PADDING *2) + INFOPANE_DEFAULT_HEIGHT + IMAGEPANE_HEIGHT) - infoPaneLoop;
- if (debug) {
- status2Div.innerHTML = "minimize infoPaneLoop =" + infoPaneLoop + " infopane.top=" + infoPane.style.top;
- }
- setTimeout(changeInfoPane, 5);
- } else {
- minimizeImage.src= MAXIMIZE_IMG_URI;
- minimizeLink.title = MAXIMIZE_IMG_TOOLTIP;
- maximizing = false;
- minimizing = false;
- maximized = false;
- }
- }
-
- function scrollRight() {
- isScrollingRight = true;
- if ( (index + 4) >= tiles.length) {
- // hide the rightButton
- rightButton.style.visibility="hidden";
- return;
- } else {
- leftButton.style.visibility="visible";
- }
- offset = offset - SCROLL_INCREMENT;
- drawTiles();
- setTimeout(scroll, timeout);
- }
-
- function getNext() {
- isScrollingRight = true;
- setTimeout(scroll, timeout);
- }
-
-
- function getPrevious () {
- isScrollingLeft = true;
- setTimeout(scroll, timeout);
- }
-
- function scrollLeft() {
- if (offset >= 0) {
- leftButton.style.visibility="hidden";
- return;
- } else {
- leftButton.style.visibility="visible";
- }
- offset = offset + SCROLL_INCREMENT;
- drawTiles();
- setTimeout(scroll, timeout);
- }
-
- function drawTiles() {
- // draw the first one if its off the screen
- // check if the far right image is out view
- var overHang;
- var temp = offset;
- index = Math.floor((offset)/THUMB_WIDTH);
- overHang = offset % THUMB_WIDTH;
- if (overHang < 0) {
- overHang = overHang * -1;
- }
- if (index < 0) {
- index = index * -1;
- }
- // check for next set of images
- prefetch();
- var startIndex = index;
- if (overHang > 0 && index >0) {
- startIndex = index -1;
- }
- var stopIndex = index + Math.round(VIEWPORT_WIDTH / THUMB_WIDTH);
- if (stopIndex > tiles.length) {
- stopIndex = tiles.length;
- }
- var displayX = 0;
- for (var tl=startIndex; tl < stopIndex; tl++) {
- if (debug) {
- statusDiv.innerHTML = "overhang=" + overHang + " startIndex=" + startIndex + " stopIndex=" + stopIndex + " offset=" + offset + " displayX=" + displayX;
- }
- if (overHang > 0 && tl == startIndex) {
- rightButton.style.visibility="visible";
- // clip: rect(top right bottom left) - borders of the clipped area
- // clip the left
- var clipMe = 'rect(' + '0px,' + THUMB_WIDTH + 'px,'+ THUMB_HEIGHT +'px,' + overHang + 'px)';
- tiles[tl].style.clip = clipMe;
- tiles[tl].style.left = (tileX - overHang) + "px";
- displayX = displayX + (THUMB_WIDTH - overHang);
- } else if (tl == stopIndex -1) {
- var underHang = VIEWPORT_WIDTH - displayX ;
- if (underHang > 0 && underHang) {
- var clipMe = 'rect(' + '0px,' + (underHang) + "px," + THUMB_HEIGHT +'px,' + 0 + 'px)';
- tiles[tl].style.clip = clipMe;
- tiles[tl].style.left = tileX + (offset + (tl * THUMB_WIDTH)) + 'px';
- tiles[tl].style.visibility = "visible";
- // resize the previous one to its real length
- } else if (underHang < 0 && tl > 0) {
- var clipMe = 'rect(' + '0px,' + (THUMB_WIDTH + underHang) + "px," + THUMB_HEIGHT +'px,' + 0 + 'px)';
- tiles[tl-1].style.clip = clipMe;
- tiles[tl-1].style.visibility = "visible";
- tiles[tl-1].style.left = tileX + (offset + ((tl -1) * THUMB_WIDTH)) + 'px';
- } else {
- tiles[tl].style.left = '0px';
- tiles[tl].style.visibility = "hidden";
- }
- } else {
- displayX = displayX + THUMB_WIDTH;
- tiles[tl].style.left = tileX + (offset + (tl * THUMB_WIDTH)) + 'px';
- tiles[tl].style.visibility = "visible";
- }
- }
- if (stopIndex < tiles.length) {
- tiles[stopIndex].style.visibility = "hidden";
- tiles[stopIndex].style.left = "0px";
- }
- }
-
-
- this.load = function () {
- map = new Map();
- dojo.event.connect(window, "onresize", layout);
- var loadImage;
-
- var targetRow = document.getElementById("targetRow");
- injectionPoint = document.getElementById("injection_point");
-
- // for status output
- statusDiv = document.getElementById("status");
- status2Div = document.getElementById("status_2");
-
- initLayout();
- initialized = true;
- }
-
- function initLayout() {
- containerDiv = document.getElementById("CatalogBrowser");
- rightButton = document.getElementById("right_button");
- leftButton = document.getElementById("left_button");
- layout();
- leftButton.style.visibility="hidden";
- if (typeof rightButton.attachEvent != 'undefined') {
- rightButton.attachEvent('onmouseover',function(e){scrollDone();getNext();});
- rightButton.attachEvent('onmouseout',function(e){scrollDone();});
- leftButton.attachEvent('onmouseover',function(e){scrollDone();getPrevious();});
- leftButton.attachEvent('onmouseout',function(e){scrollDone();});
- } else if (typeof rightButton.addEventListener != 'undefined') {
- rightButton.addEventListener('mouseover',function(e){scrollDone();getNext();}, false);
- rightButton.addEventListener('mouseout',function(e){scrollDone();}, false);
- leftButton.addEventListener('mouseover',function(e){scrollDone();getPrevious();}, false);
- leftButton.addEventListener('mouseout',function(e){scrollDone();}, false);
- }
- createInfoPane();
- }
-
- function layout() {
- var ua = navigator.userAgent.toLowerCase();
-
- // this will need to be made generic depending on the thumb height
- tileY = findY(containerDiv);
- tileX = findX(containerDiv) + 4;
- var rightX = tileX + VIEWPORT_WIDTH - 20;
- rightButton.style.left = rightX + "px";
- var buttonY = tileY + IMAGEPANE_HEIGHT + INFOPANE_DEFAULT_HEIGHT + 12;
- rightButton.style.top = buttonY + "px";
- leftButton.style.top = buttonY + "px";
-
- if (ua.indexOf('ie') != -1) {
- isIE = true;
- } else if (ua.indexOf('safari') != -1) {
- tileX = tileX + 8;
- timeout = 20;
- }
- drawTiles();
- if (infoPane) {
- infoPane.style.left = tileX + "px";
- if (maximized) {
-
- infoPane.style.top = (tileY + IMAGEPANE_HEIGHT + (PADDING*2) - infoPane.style.height) + "px";
- } else {
- infoPane.style.top = (tileY + IMAGEPANE_HEIGHT + (PADDING*2)) + "px";
- }
- if (maximized) {
- infoPaneLoop = infoPane.style.height;
- } else {
- infoPaneLoop = INFOPANE_DEFAULT_HEIGHT;
- }
- }
- if (typeof imageLoadingPane != 'undefined') {
- imageLoadingPane.style.left = tileX;
- imageLoadingPane.style.top = tileY;
- }
- }
-
- function createInfoPane() {
- infoPane = document.getElementById("infopane");
- infoPane.style.width = VIEWPORT_WIDTH + "px";
- // give room for 4 pixels above and below
- infoPane.style.height = (INFOPANE_DEFAULT_HEIGHT) + "px";
- // give 3px padding for a border
- infoPane.style.top = (tileY + IMAGEPANE_HEIGHT + (PADDING*2)) + "px";
- infoPane.style.left = tileX + "px";
- infoTableMinimize = document.getElementById("infopaneDetailsIcon");
- indicatorCell = document.getElementById("infopaneIndicator");
- indicatorCell.style.width = (10) + "px";
- indicatorImage = document.createElement("img");
- indicatorImage.className = "infopaneIndicator";
- indicatorImage.src = INDICATOR_IMG_URI;
- indicatorImage.style.visibility = "hidden";
- indicatorCell.appendChild(indicatorImage);
- minimizeLink = document.createElement("a");
- minimizeLink.className = "infopaneLink";
- minimizeLink.title = MAXIMIZE_IMG_TOOLTIP;
- minimizeImage = document.createElement("img");
- minimizeImage.src= MAXIMIZE_IMG_URI;
- minimizeLink.appendChild(minimizeImage);
- infoTableMinimize.appendChild(minimizeLink);
-
- if (typeof minimizeLink.attachEvent != 'undefined') {
- minimizeLink.attachEvent("onclick",function(e){_this.doMaximize();});
- } else {
- minimizeLink.addEventListener("click",function(e){_this.doMaximize();}, true);
- }
- var clipMe = 'rect(' + '0px,' + VIEWPORT_WIDTH + 'px,'+ INFOPANE_DEFAULT_HEIGHT +'px,' + 0 + 'px)';
- infoPane.style.clip = clipMe;
- }
-
- function createTile(i) {
- var div = document.createElement("div");
- div.className = "tile";
- div.id = i.id;
- var link = document.createElement("a");
- var img = document.createElement("img");
- img.title = i.name;
- img.src = i.thumbnail;
- img.className = "tileImage";
- link.appendChild(img);
- link.setAttribute("id", i.id);
- if (typeof div.attachEvent != 'undefined') {
- div.attachEvent('onclick',function(e){this.id = div.id; _this.showImage(this.id, false);});
- } else {
- link.addEventListener('click',function(e){this.id = div.id; _this.showImage(this.id, false);}, true);
- }
- div.appendChild(link);
- injectionPoint.appendChild(div);
- div.style.top = tileY + INFOPANE_DEFAULT_HEIGHT + IMAGEPANE_HEIGHT + (PADDING * 3) + "px";
- tiles.push(div);
- }
-
-
- function findY(element) {
- var t = 0;
- if (element.offsetParent) {
- while (element.offsetParent) {
- t += element.offsetTop
- element = element.offsetParent;
- }
- } else if (element.y) {
- t += element.y;
- }
- return t;
- }
-
- function findX(element) {
- var l = 0;
- if (element.offsetParent) {
- while (element.offsetParent) {
- l += element.offsetLeft
- element = element.offsetParent;
- }
- } else if (element.x)
- l += element.x;
- return l;
- }
-}
+/* Copyright 2006 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
+$Id: scroller.js,v 1.32 2007/01/17 18:00:09 basler Exp $ */
+
+/**
+* ImageScroller - A multipurpose item brower
+* @ Author: Greg Murray
+*
+*/
+
+function getApplicationContextRoot() {
+ var urlArray=window.location.toString().split("/", 4);
+ return "/" + urlArray[3];
+}
+
+var applicationContextRoot=getApplicationContextRoot();
+
+
+function ImageScroller() {
+ var _this = this;
+ var initialized = false;
+ // default sizes
+
+ var VIEWPORT_WIDTH = 500;
+ // all sizes are realitive the the viewport width
+ var IMAGEPANE_WIDTH = VIEWPORT_WIDTH;
+ var IMAGEPANE_HEIGHT = Math.round(VIEWPORT_WIDTH / 1.49);
+ var INFOPANE_DEFAULT_HEIGHT = Math.round(VIEWPORT_WIDTH / 6.67);
+ var INFOPANE_EXPAND_HEIGHT = Math.round(VIEWPORT_WIDTH / 2.86);
+ var THUMB_WIDTH = Math.round(VIEWPORT_WIDTH / 5);;
+ var THUMB_HEIGHT = Math.round(VIEWPORT_WIDTH / 6.67);
+
+ var CHUNK_SIZE = 7;
+ var PREFETCH_THRESHHOLD = 5;
+
+ var IMAGE_PANE_ID = "imagePane";
+ var IMAGE_PANE_BUFFER_ID = "imageBufferPane";
+
+ var PADDING = 3;
+
+ var MINIMIZE_IMG_URI = applicationContextRoot + "/images/minimize.gif";
+ var MAXIMIZE_IMG_URI = applicationContextRoot + "/images/maximize.gif";
+ var INDICATOR_IMG_URI = applicationContextRoot + "/images/indicator-black.gif";
+ var MAXIMIZE_IMG_TOOLTIP = "Show Details";
+ var MINIMIZE_IMG_TOOLTIP = "Show Less Details";
+
+ // this is an array of the tiles which are divs for each thumb
+ var tiles = [];
+
+ var injectionPoint;
+
+ // for scrolling
+
+ var SCROLL_INCREMENT = 5;
+ var INFOPANE_INCREMENT = 3;
+ var tileY;
+ var tileX;
+ // this is the index of the image tile on the far left
+ var index = 0;
+ // keeps track how for the scroll has gone
+ var offset = 0;
+
+ var timeout = 30; // in ms
+ var isScrollingRight = false;
+ var isScrollingLeft = false;
+
+ // large image pane
+ var imagePane;
+ var imageLoadingPane;
+ var loadingPane;
+ // images
+ var minimizeImage;
+
+ var indicatorImage;
+ var leftButton;
+ var rightButton;
+
+ // infopane
+ var infoPane;
+ var infoTableMinimize;
+ var indicatorCell;
+ var minimizeLink;
+ var infoPaneLoop = 0;
+ var maximizing = false;
+ var minimizing = false;
+ var maximized = false;
+
+ // prefetch thresh-hold
+ var prefetchThreshold = 2;
+
+ // a growing list of items;
+ var items = [];
+ // cached chunks that are already in the items array
+ var loadedChunks = [];
+
+ // used for debugging when debug is true
+ var debug = false;
+ var statusDiv;
+ var status2Div;
+
+ var showingBuffer = false;
+ var imageBuffer;
+ var imageReloadTries = 0;
+ var IMG_RELOAD_RETRY_MAX = 30;
+ // used for url book marking
+
+
+ var pid;
+ var currentChunk;
+ // this map contains all the items
+ var map;
+ // this is the main container div
+ var containerDiv;
+
+ this.getItems = function() {
+ return map;
+ }
+
+ this.getScrollerItems = function() {
+ return items;
+ }
+
+
+ this.getGroupId = function() {
+ return pid;
+ }
+
+ this.reset = function() {
+ resetTitles()
+ tiles = [];
+ index = 0;
+ offset = 0;
+ currentChunk = 0;
+ items = [];
+ loadedChunks = [];
+ }
+
+ function resetTitles() {
+ for (var l = 0; l < tiles.length; l++) {
+ tiles[l].parentNode.removeChild(tiles[l]);
+ }
+ }
+
+ // event bound to the mouseOut event of both scroll buttons
+ function scrollDone() {
+ isScrollingLeft = false;
+ isScrollingRight = false;
+ }
+
+ // looping method for time out
+ function scroll() {
+ if (isScrollingRight) scrollRight();
+ else if (isScrollingLeft) scrollLeft();
+ }
+
+
+ // do the value list pre-emptive fetching
+ function prefetch() {
+ //printDebug("** scoller index = " + index);
+ if (isScrollingRight && (index + PREFETCH_THRESHHOLD) % CHUNK_SIZE == 0) {
+
+ if ((Math.round(index / CHUNK_SIZE)) >= currentChunk) {
+ currentChunk = Math.round(index / CHUNK_SIZE) + 1;
+ // fire an event
+ dojo.event.topic.publish("/catalog", {type:"getChunk", id: pid, index: index, currentChunk: currentChunk});
+ }
+ }
+ }
+
+ this.setGroupId = function(id) {
+ pid = id;
+ }
+
+ this.containsChunk = function(chunkId) {
+ printDebug("containsChunk = " + loadedChunks);
+ ret=false;
+ for(ii=0; ii < loadedChunks.length; ii++) {
+ if(chunkId == loadedChunks[ii]) {
+ ret=true;
+ break;
+ }
+ }
+ return ret;
+ }
+
+ this.addChunk = function(chunkId) {
+ loadedChunks.push(chunkId);
+ }
+
+ this.addItems = function(inItems) {
+ for (var loop=0; loop < inItems.length ; loop++) {
+ items.push(inItems[loop]);
+ map.put(inItems[loop].id, inItems[loop]);
+ createTile(inItems[loop]);
+ if (loop == 0 && !loadImage) {
+ showImage(inItems[loop].id);
+ }
+
+ }
+ drawTiles();
+ rightButton.style.visibility="visible";
+ _this.hideProgressIndicator();
+ }
+
+ this.showProgressIndicator = function() {
+ if (indicatorImage) {
+ indicatorImage.style.visibility = "visible";
+ }
+ }
+
+ this.hideProgressIndicator = function() {
+ indicatorImage.style.visibility = "hidden";
+ }
+
+ function postImageLoad(loadIntoBuffer) {
+ if (debug) {
+ status2Div.innerHTML = "Try " + imageReloadTries + " " + url + " image.complete=" + imageBuffer.complete;
+ }
+ // keep calling this funtion until imageReloadTries < IMG_RELOAD_RETRY_MAX
+ if (!imageBuffer.complete) {
+ if (imageReloadTries < IMG_RELOAD_RETRY_MAX) {
+ setTimeout(function(){this.loadIntoBuffer = loadIntoBuffer;postImageLoad(loadIntoBuffer);},500);
+ } else {
+ this.hideProgressIndicator();
+ }
+ imageReloadTries = imageReloadTries + 1;
+ return;
+ }
+ var id;
+
+ _this.hideProgressIndicator();
+ if (loadIntoBuffer) {
+ imageLoadingPane.src = imageBuffer.src;
+ } else {
+ imagePane.src = imageBuffer.src;
+
+ }
+ // do a cross fade as long as the images aren't the same
+ if (imageLoadingPane.src != imagePane.src) {
+ crossFade(0,loadIntoBuffer );
+ }
+ }
+
+
+ this.showImage = function(itemId) {
+
+ _this.showProgressIndicator();
+ //setTimeout(this.showProgressIndicator,0);
+ var i = map.get(itemId);
+
+ if (!i) {
+ return;
+ }
+ dojo.event.topic.publish("/catalog", {type:"showingItem", id: itemId, rating: i.rating});
+ // create the image pane and append the description nodes
+ // asumption is that if the imagePane is not set neigher are the info children
+ if (typeof imagePane == 'undefined') {
+ imagePane = document.createElement("img");
+ imagePane.style.width = IMAGEPANE_WIDTH + "px";
+ imagePane.style.height = IMAGEPANE_HEIGHT + "px";
+ imagePane.id = IMAGE_PANE_ID;
+
+ var targetElement = document.getElementById("bodySpace");
+ imageLoadingPane = document.createElement("img");
+ imageLoadingPane.style.position = "absolute";
+ imageLoadingPane.style.visibility = "hidden";
+ imageLoadingPane.style.width = IMAGEPANE_WIDTH + "px";
+ imageLoadingPane.style.height = IMAGEPANE_HEIGHT + "px";
+ imageLoadingPane.id = IMAGE_PANE_BUFFER_ID;
+ targetElement.appendChild(imagePane);
+ targetElement.appendChild(imageLoadingPane);
+ imageLoadingPane.style.left = tileX + "px";
+
+ loadImage(i.image, false);
+ } else {
+ imageLoadingPane.style.visibility = "visible";
+ if (showingBuffer) {
+ showingBuffer = false;
+ } else {
+ showingBuffer = true;
+ }
+ loadImage(i.image, showingBuffer);
+ }
+ }
+
+ function loadImage(url, loadIntoBuffer) {
+ imageReloadTries = 0;
+ imageBuffer = new Image();
+ if (loadIntoBuffer) {
+ imageBuffer.src = url;
+ imageLoadingPane.onLoad = setTimeout(function(){this.url=url;this.loadIntoBuffer = loadIntoBuffer;postImageLoad(loadIntoBuffer,url);},0);
+ } else {
+ imageBuffer.src = url;
+ imageBuffer.onLoad = setTimeout(function(){this.url = url;this.loadIntoBuffer = loadIntoBuffer;postImageLoad(loadIntoBuffer,url);},0);
+ }
+ }
+
+ function setOpacity(opacity, id) {
+ var target = document.getElementById(id);
+ if (typeof target.style.filter != 'undefined') {
+ target.style.filter = "alpha(opacity:" + opacity + ")";
+ } else {
+ target.style.opacity = opacity/100;
+ }
+ }
+
+ function crossFade(count,loadIntoBuffer) {
+ var percentage = Number(count);
+ if (loadIntoBuffer) {
+ setOpacity(100 - percentage, IMAGE_PANE_ID);
+ setOpacity(percentage, IMAGE_PANE_BUFFER_ID);
+ } else {
+ setOpacity(100 - percentage, IMAGE_PANE_BUFFER_ID);
+ setOpacity(percentage, IMAGE_PANE_ID);
+
+ }
+ if (percentage < 100) {
+ percentage = percentage + 10;
+ setTimeout(function(){this.loadIntoBuffer = loadIntoBuffer;this.percentage = percentage;crossFade(percentage,loadIntoBuffer);}, 25);
+ }
+ }
+
+
+ // calling this function will result in the maximizing event being fired
+ // if the pane is maximized it will asume the event want to minimize
+ this.doMaximize = function() {
+ if (!maximizing && !minimizing && !maximized) {
+ infoPaneLoop = INFOPANE_DEFAULT_HEIGHT;
+ maximizing = true;
+ minimizing = false;
+ } else if (!maximizing && !minimizing) {
+ minimizing = true;
+ maximizing = false;
+ }
+ setTimeout(changeInfoPane, 0);
+ }
+
+ // will handle either minimizing or maximing but not both
+ // this method is called recursively until the maximinging
+ // or minimizing is done.
+ function changeInfoPane() {
+ if (maximizing) {
+ maxmizeInfoPane();
+ } else if (minimizing) {
+ minimizeInfoPane();
+ }
+ }
+
+ function maxmizeInfoPane() {
+ if (infoPaneLoop < INFOPANE_EXPAND_HEIGHT) {
+ infoPaneLoop = infoPaneLoop + INFOPANE_INCREMENT;
+ var clipMe = 'rect(' + '0px,' + VIEWPORT_WIDTH + 'px,'+ infoPaneLoop +'px,' + 0 + 'px)';
+ infoPane.style.clip = clipMe;
+ infoPane.style.height = infoPaneLoop;
+ infoPane.style.top = (tileY + (PADDING *2) + INFOPANE_DEFAULT_HEIGHT + IMAGEPANE_HEIGHT) - infoPaneLoop;
+ setTimeout(changeInfoPane, 5);
+ } else {
+ minimizeImage.src= MINIMIZE_IMG_URI;
+ minimizeLink.title = MINIMIZE_IMG_TOOLTIP;
+ maximized = true;
+ maximizing = false;
+ minimizing = false;
+ }
+ }
+
+ function minimizeInfoPane() {
+ if (infoPaneLoop > INFOPANE_DEFAULT_HEIGHT) {
+ infoPaneLoop = infoPaneLoop - INFOPANE_INCREMENT;
+ var clipMe = 'rect(' + '0px,' + VIEWPORT_WIDTH + 'px,'+ infoPaneLoop +'px,' + 0 + 'px)';
+ infoPane.style.clip = clipMe;
+ infoPane.style.height = infoPaneLoop;
+ infoPane.style.top = (tileY + (PADDING *2) + INFOPANE_DEFAULT_HEIGHT + IMAGEPANE_HEIGHT) - infoPaneLoop;
+ if (debug) {
+ status2Div.innerHTML = "minimize infoPaneLoop =" + infoPaneLoop + " infopane.top=" + infoPane.style.top;
+ }
+ setTimeout(changeInfoPane, 5);
+ } else {
+ minimizeImage.src= MAXIMIZE_IMG_URI;
+ minimizeLink.title = MAXIMIZE_IMG_TOOLTIP;
+ maximizing = false;
+ minimizing = false;
+ maximized = false;
+ }
+ }
+
+ function scrollRight() {
+ isScrollingRight = true;
+ if ( (index + 4) >= tiles.length) {
+ // hide the rightButton
+ rightButton.style.visibility="hidden";
+ return;
+ } else {
+ leftButton.style.visibility="visible";
+ }
+ offset = offset - SCROLL_INCREMENT;
+ drawTiles();
+ setTimeout(scroll, timeout);
+ }
+
+ function getNext() {
+ isScrollingRight = true;
+ setTimeout(scroll, timeout);
+ }
+
+
+ function getPrevious () {
+ isScrollingLeft = true;
+ setTimeout(scroll, timeout);
+ }
+
+ function scrollLeft() {
+ if (offset >= 0) {
+ leftButton.style.visibility="hidden";
+ return;
+ } else {
+ leftButton.style.visibility="visible";
+ }
+ offset = offset + SCROLL_INCREMENT;
+ drawTiles();
+ setTimeout(scroll, timeout);
+ }
+
+ function drawTiles() {
+ // draw the first one if its off the screen
+ // check if the far right image is out view
+ var overHang;
+ var temp = offset;
+ index = Math.floor((offset)/THUMB_WIDTH);
+ overHang = offset % THUMB_WIDTH;
+ if (overHang < 0) {
+ overHang = overHang * -1;
+ }
+ if (index < 0) {
+ index = index * -1;
+ }
+ // check for next set of images
+ prefetch();
+ var startIndex = index;
+ if (overHang > 0 && index >0) {
+ startIndex = index -1;
+ }
+ var stopIndex = index + Math.round(VIEWPORT_WIDTH / THUMB_WIDTH);
+ if (stopIndex > tiles.length) {
+ stopIndex = tiles.length;
+ }
+ var displayX = 0;
+ for (var tl=startIndex; tl < stopIndex; tl++) {
+ if (debug) {
+ statusDiv.innerHTML = "overhang=" + overHang + " startIndex=" + startIndex + " stopIndex=" + stopIndex + " offset=" + offset + " displayX=" + displayX;
+ }
+ if (overHang > 0 && tl == startIndex) {
+ rightButton.style.visibility="visible";
+ // clip: rect(top right bottom left) - borders of the clipped area
+ // clip the left
+ var clipMe = 'rect(' + '0px,' + THUMB_WIDTH + 'px,'+ THUMB_HEIGHT +'px,' + overHang + 'px)';
+ tiles[tl].style.clip = clipMe;
+ tiles[tl].style.left = (tileX - overHang) + "px";
+ displayX = displayX + (THUMB_WIDTH - overHang);
+ } else if (tl == stopIndex -1) {
+ var underHang = VIEWPORT_WIDTH - displayX ;
+ if (underHang > 0 && underHang) {
+ var clipMe = 'rect(' + '0px,' + (underHang) + "px," + THUMB_HEIGHT +'px,' + 0 + 'px)';
+ tiles[tl].style.clip = clipMe;
+ tiles[tl].style.left = tileX + (offset + (tl * THUMB_WIDTH)) + 'px';
+ tiles[tl].style.visibility = "visible";
+ // resize the previous one to its real length
+ } else if (underHang < 0 && tl > 0) {
+ var clipMe = 'rect(' + '0px,' + (THUMB_WIDTH + underHang) + "px," + THUMB_HEIGHT +'px,' + 0 + 'px)';
+ tiles[tl-1].style.clip = clipMe;
+ tiles[tl-1].style.visibility = "visible";
+ tiles[tl-1].style.left = tileX + (offset + ((tl -1) * THUMB_WIDTH)) + 'px';
+ } else {
+ tiles[tl].style.left = '0px';
+ tiles[tl].style.visibility = "hidden";
+ }
+ } else {
+ displayX = displayX + THUMB_WIDTH;
+ tiles[tl].style.left = tileX + (offset + (tl * THUMB_WIDTH)) + 'px';
+ tiles[tl].style.visibility = "visible";
+ }
+ }
+ if (stopIndex < tiles.length) {
+ tiles[stopIndex].style.visibility = "hidden";
+ tiles[stopIndex].style.left = "0px";
+ }
+ }
+
+
+ this.load = function () {
+ map = new Map();
+ dojo.event.connect(window, "onresize", layout);
+ var loadImage;
+
+ var targetRow = document.getElementById("targetRow");
+ injectionPoint = document.getElementById("injection_point");
+
+ // for status output
+ statusDiv = document.getElementById("status");
+ status2Div = document.getElementById("status_2");
+
+ initLayout();
+ initialized = true;
+ }
+
+ function initLayout() {
+ containerDiv = document.getElementById("CatalogBrowser");
+ rightButton = document.getElementById("right_button");
+ leftButton = document.getElementById("left_button");
+ layout();
+ leftButton.style.visibility="hidden";
+ if (typeof rightButton.attachEvent != 'undefined') {
+ rightButton.attachEvent('onmouseover',function(e){scrollDone();getNext();});
+ rightButton.attachEvent('onmouseout',function(e){scrollDone();});
+ leftButton.attachEvent('onmouseover',function(e){scrollDone();getPrevious();});
+ leftButton.attachEvent('onmouseout',function(e){scrollDone();});
+ } else if (typeof rightButton.addEventListener != 'undefined') {
+ rightButton.addEventListener('mouseover',function(e){scrollDone();getNext();}, false);
+ rightButton.addEventListener('mouseout',function(e){scrollDone();}, false);
+ leftButton.addEventListener('mouseover',function(e){scrollDone();getPrevious();}, false);
+ leftButton.addEventListener('mouseout',function(e){scrollDone();}, false);
+ }
+ createInfoPane();
+ }
+
+ function layout() {
+ var ua = navigator.userAgent.toLowerCase();
+
+ // this will need to be made generic depending on the thumb height
+ tileY = findY(containerDiv);
+ tileX = findX(containerDiv) + 4;
+ var rightX = tileX + VIEWPORT_WIDTH - 20;
+ rightButton.style.left = rightX + "px";
+ var buttonY = tileY + IMAGEPANE_HEIGHT + INFOPANE_DEFAULT_HEIGHT + 12;
+ rightButton.style.top = buttonY + "px";
+ leftButton.style.top = buttonY + "px";
+
+ if (ua.indexOf('ie') != -1) {
+ isIE = true;
+ } else if (ua.indexOf('safari') != -1) {
+ tileX = tileX + 8;
+ timeout = 20;
+ }
+ drawTiles();
+ if (infoPane) {
+ infoPane.style.left = tileX + "px";
+ if (maximized) {
+
+ infoPane.style.top = (tileY + IMAGEPANE_HEIGHT + (PADDING*2) - infoPane.style.height) + "px";
+ } else {
+ infoPane.style.top = (tileY + IMAGEPANE_HEIGHT + (PADDING*2)) + "px";
+ }
+ if (maximized) {
+ infoPaneLoop = infoPane.style.height;
+ } else {
+ infoPaneLoop = INFOPANE_DEFAULT_HEIGHT;
+ }
+ }
+ if (typeof imageLoadingPane != 'undefined') {
+ imageLoadingPane.style.left = tileX;
+ imageLoadingPane.style.top = tileY;
+ }
+ }
+
+ function createInfoPane() {
+ infoPane = document.getElementById("infopane");
+ infoPane.style.width = VIEWPORT_WIDTH + "px";
+ // give room for 4 pixels above and below
+ infoPane.style.height = (INFOPANE_DEFAULT_HEIGHT) + "px";
+ // give 3px padding for a border
+ infoPane.style.top = (tileY + IMAGEPANE_HEIGHT + (PADDING*2)) + "px";
+ infoPane.style.left = tileX + "px";
+ infoTableMinimize = document.getElementById("infopaneDetailsIcon");
+ indicatorCell = document.getElementById("infopaneIndicator");
+ indicatorCell.style.width = (10) + "px";
+ indicatorImage = document.createElement("img");
+ indicatorImage.className = "infopaneIndicator";
+ indicatorImage.src = INDICATOR_IMG_URI;
+ indicatorImage.style.visibility = "hidden";
+ indicatorCell.appendChild(indicatorImage);
+ minimizeLink = document.createElement("a");
+ minimizeLink.className = "infopaneLink";
+ minimizeLink.title = MAXIMIZE_IMG_TOOLTIP;
+ minimizeImage = document.createElement("img");
+ minimizeImage.src= MAXIMIZE_IMG_URI;
+ minimizeLink.appendChild(minimizeImage);
+ infoTableMinimize.appendChild(minimizeLink);
+
+ if (typeof minimizeLink.attachEvent != 'undefined') {
+ minimizeLink.attachEvent("onclick",function(e){_this.doMaximize();});
+ } else {
+ minimizeLink.addEventListener("click",function(e){_this.doMaximize();}, true);
+ }
+ var clipMe = 'rect(' + '0px,' + VIEWPORT_WIDTH + 'px,'+ INFOPANE_DEFAULT_HEIGHT +'px,' + 0 + 'px)';
+ infoPane.style.clip = clipMe;
+ }
+
+ function createTile(i) {
+ var div = document.createElement("div");
+ div.className = "tile";
+ div.id = i.id;
+ var link = document.createElement("a");
+ var img = document.createElement("img");
+ img.title = i.name;
+ img.src = i.thumbnail;
+ img.className = "tileImage";
+ link.appendChild(img);
+ link.setAttribute("id", i.id);
+ if (typeof div.attachEvent != 'undefined') {
+ div.attachEvent('onclick',function(e){this.id = div.id; _this.showImage(this.id, false);});
+ } else {
+ link.addEventListener('click',function(e){this.id = div.id; _this.showImage(this.id, false);}, true);
+ }
+ div.appendChild(link);
+ injectionPoint.appendChild(div);
+ div.style.top = tileY + INFOPANE_DEFAULT_HEIGHT + IMAGEPANE_HEIGHT + (PADDING * 3) + "px";
+ tiles.push(div);
+ }
+
+
+ function findY(element) {
+ var t = 0;
+ if (element.offsetParent) {
+ while (element.offsetParent) {
+ t += element.offsetTop
+ element = element.offsetParent;
+ }
+ } else if (element.y) {
+ t += element.y;
+ }
+ return t;
+ }
+
+ function findX(element) {
+ var l = 0;
+ if (element.offsetParent) {
+ while (element.offsetParent) {
+ l += element.offsetLeft
+ element = element.offsetParent;
+ }
+ } else if (element.x)
+ l += element.x;
+ return l;
+ }
+}
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/styles.css b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/styles.css
index 7762d70..24ffbf9 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/styles.css
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/styles.css
@@ -1,130 +1,130 @@
-
-.dojoHtmlFisheyeListBar {
- cursor:pointer;
- margin: 0;
- width: 300px;
- text-align: right;
-}
-
-.outerbar {
- background-color: white;
- text-align: left;
- width: 300px;
-}
-
-.editText {
- height:25;
- font-size:18px;
- font-weight: bold;
- font-family: Arial;
-}
-
-.plainText {
- height:25;
- font-size:20px;
- font-weight: bold;
- font-family: Arial
-}
-
-.plainTextSelect {
- height:25;
- font-size:20px;
- font-weight: bold;
- font-family: Arial;
- background: red
-}
-
-.smallText {
- height:15;
- font-size:13px;
- font-weight: bold;
- font-family: Arial
-}
-
-.banner {
- height:35;
- font-size:35;
- font-weight: bold;
- font-family: Arial
-}
-
-
-.menuItem {
- background: white;
- color: black;
- text-decoration: none;
- font-size: 1.4em;
-}
-
-.menuLink {
- cursor:pointer;
- color: black;
- text-decoration: none;
- font-size: 1.3em;
-}
-
-.menuLinkHover {
- cursor:pointer;
- color: black;
- font-size: 1.3em;
- text-decoration: underline;
-}
-
-.autocomplete {
- position:absolute;
-}
-
-.autocompleteTable {
- padding:0;
- visibility: hidden;
- border-spacing: 0;
- border-width:1px;
- border-style:solid;
- border-color:black;
-}
-
-.popupRowHover {
- color: #FFFAFA;
- cursor:pointer;
- padding-left:3;
- padding-right:3;
- border-spacing: 0;
- border-width:0px;
- background: #7A8AFF;
-}
-
-.popupRow {
- padding-left:3;
- padding-right:3;
- border-spacing: 0;
- border-width:0px;
- background: #FFFAFA;
-}
-
-.popupRowEven {
- padding-left:3;
- padding-right:3;
- border-spacing: 0;
- border-width:0px;
- background: #FFFADA;
-}
-
-.popupItem {
- background: #FFFAFA;
- color: #000000;
- text-decoration: none;
- font-size: 1.2em;
-}
-
-.shadow {
- top:0px;
- left:0px;
- position: absolute;
- visibility: hidden;
- width:0;
- height:0;
- z-index:0;
- background:gray;
- opacity: .5;
-}
-
+
+.dojoHtmlFisheyeListBar {
+ cursor:pointer;
+ margin: 0;
+ width: 300px;
+ text-align: right;
+}
+
+.outerbar {
+ background-color: white;
+ text-align: left;
+ width: 300px;
+}
+
+.editText {
+ height:25;
+ font-size:18px;
+ font-weight: bold;
+ font-family: Arial;
+}
+
+.plainText {
+ height:25;
+ font-size:20px;
+ font-weight: bold;
+ font-family: Arial
+}
+
+.plainTextSelect {
+ height:25;
+ font-size:20px;
+ font-weight: bold;
+ font-family: Arial;
+ background: red
+}
+
+.smallText {
+ height:15;
+ font-size:13px;
+ font-weight: bold;
+ font-family: Arial
+}
+
+.banner {
+ height:35;
+ font-size:35;
+ font-weight: bold;
+ font-family: Arial
+}
+
+
+.menuItem {
+ background: white;
+ color: black;
+ text-decoration: none;
+ font-size: 1.4em;
+}
+
+.menuLink {
+ cursor:pointer;
+ color: black;
+ text-decoration: none;
+ font-size: 1.3em;
+}
+
+.menuLinkHover {
+ cursor:pointer;
+ color: black;
+ font-size: 1.3em;
+ text-decoration: underline;
+}
+
+.autocomplete {
+ position:absolute;
+}
+
+.autocompleteTable {
+ padding:0;
+ visibility: hidden;
+ border-spacing: 0;
+ border-width:1px;
+ border-style:solid;
+ border-color:black;
+}
+
+.popupRowHover {
+ color: #FFFAFA;
+ cursor:pointer;
+ padding-left:3;
+ padding-right:3;
+ border-spacing: 0;
+ border-width:0px;
+ background: #7A8AFF;
+}
+
+.popupRow {
+ padding-left:3;
+ padding-right:3;
+ border-spacing: 0;
+ border-width:0px;
+ background: #FFFAFA;
+}
+
+.popupRowEven {
+ padding-left:3;
+ padding-right:3;
+ border-spacing: 0;
+ border-width:0px;
+ background: #FFFADA;
+}
+
+.popupItem {
+ background: #FFFAFA;
+ color: #000000;
+ text-decoration: none;
+ font-size: 1.2em;
+}
+
+.shadow {
+ top:0px;
+ left:0px;
+ position: absolute;
+ visibility: hidden;
+ width:0;
+ height:0;
+ z-index:0;
+ background:gray;
+ opacity: .5;
+}
+
diff --git a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/tag.css b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/tag.css
index f72529a..bfbab6e 100644
--- a/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/tag.css
+++ b/etc/modules/sample-bundle/src/main/petstore/server/default/deploy/petstore.ear/petstore.war/tag.css
@@ -1,47 +1,47 @@
- .itemTable {
- padding: 0.3cm;
- border-style: double;
- width: 800px;
- border-color: darkgreen;
- }
- .itemCell {
- border-style: solid;
- border-color: darkgreen;
- border-width: thin;
- padding: 5px
- }
- .tagCell {
- padding: 0.3cm;
- }
- .xxlarge
- {
- font-size: xx-large;
- color: red;
- cursor: pointer;
- text-decoration: underline;
- }
- .xlarge
- {
- font-size: x-large;
- color: blue;
- cursor: pointer;
- text-decoration: underline;
- }
- .large
- {
- font-size: large;
- color: green;
- cursor: pointer;
- text-decoration: underline;
- }
- .medium
- {
- font-size: medium;
- cursor: pointer;
- color: black;
- text-decoration: underline;
- }
- .items
- {
- visibility: hidden;
- }
+ .itemTable {
+ padding: 0.3cm;
+ border-style: double;
+ width: 800px;
+ border-color: darkgreen;
+ }
+ .itemCell {
+ border-style: solid;
+ border-color: darkgreen;
+ border-width: thin;
+ padding: 5px
+ }
+ .tagCell {
+ padding: 0.3cm;
+ }
+ .xxlarge
+ {
+ font-size: xx-large;
+ color: red;
+ cursor: pointer;
+ text-decoration: underline;
+ }
+ .xlarge
+ {
+ font-size: x-large;
+ color: blue;
+ cursor: pointer;
+ text-decoration: underline;
+ }
+ .large
+ {
+ font-size: large;
+ color: green;
+ cursor: pointer;
+ text-decoration: underline;
+ }
+ .medium
+ {
+ font-size: medium;
+ cursor: pointer;
+ color: black;
+ text-decoration: underline;
+ }
+ .items
+ {
+ visibility: hidden;
+ }
diff --git a/modules/common/ant-bundle/src/main/assembly/bin/antenv.cmd b/modules/common/ant-bundle/src/main/assembly/bin/antenv.cmd
index 0460266..170d89f 100644
--- a/modules/common/ant-bundle/src/main/assembly/bin/antenv.cmd
+++ b/modules/common/ant-bundle/src/main/assembly/bin/antenv.cmd
@@ -1,98 +1,98 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-'@echo off'
-call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
-call SysLoadFuncs
-
-/* Prepare the parameters for later use */
-parse arg argv
-mode = ''
-args = ''
-opts = ''
-cp = ''
-lcp = ''
-
-do i = 1 to words(argv)
- param = word(argv, i)
- select
- when param='-lcp' then mode = 'l'
- when param='-cp' | param='-classpath' then mode = 'c'
- when abbrev('-opts', param, 4) then mode = 'o'
- when abbrev('-args', param, 4) then mode = 'a'
- otherwise
- select
- when mode = 'a' then args = space(args param, 1)
- when mode = 'c' then cp = space(cp param, 1)
- when mode = 'l' then lcp = space(lcp param, 1)
- when mode = 'o' then opts = space(opts param, 1)
- otherwise
- say 'Option' param 'ignored'
- end
- end
-end
-
-env="OS2ENVIRONMENT"
-antconf = _getenv_('antconf' 'antconf.cmd')
-runrc = _getenv_('runrc')
-interpret 'call "' || runrc || '"' '"' || antconf || '"' 'ETC'
-ANT_HOME = value('ANT_HOME',,env)
-JAVA_HOME = value('JAVA_HOME',,env)
-classpath = value('CLASSPATH',,env)
-classes = stream(JAVA_HOME || "\lib\classes.zip", "C", "QUERY EXISTS")
-if classes \= '' then classpath = prepend(classpath classes)
-classes = stream(JAVA_HOME || "\lib\tools.jar", "C", "QUERY EXISTS")
-if classes \= '' then classpath = prepend(classpath classes)
-
-classpath = prepend(classpath ANT_HOME || '\lib\ant-launcher.jar')
-'SET CLASSPATH=' || classpath
-
-/* Setting classpathes, options and arguments */
-envset = _getenv_('envset')
-if cp\='' then interpret 'call "' || envset || '"' '"; CLASSPATH"' '"' || cp || '"'
-if lcp\='' then interpret 'call "' || envset || '"' '"; LOCALCLASSPATH"' '"' || lcp || '"'
-if opts\='' then interpret 'call "' || envset || '"' '"-D ANT_OPTS"' '"' || opts || '"'
-if args\='' then interpret 'call "' || envset || '"' '"ANT_ARGS"' '"' || args || '"'
-
-exit 0
-
-addpath: procedure
-parse arg path elem
-if elem = '' then do
- if path\='' & right(path, 1)\=';' then path = path || ';'
- return path
-end
-if substr(path, length(path)) = ';' then glue = ''
-else glue = ';'
-if pos(translate(elem), translate(path)) = 0 then path = path || glue || elem || ';'
-return path
-
-prepend: procedure
-parse arg path elem
-if elem = '' then do
- if path\='' & right(path, 1)\=';' then path = path || ';'
- return path
-end
-if pos(translate(elem), translate(path)) = 0 then path = elem || ';' || path
-return path
-
-_getenv_: procedure expose env
-parse arg envar default
-if default = '' then default = envar
-var = value(translate(envar),,env)
-if var = '' then var = default
-return var
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+'@echo off'
+call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
+call SysLoadFuncs
+
+/* Prepare the parameters for later use */
+parse arg argv
+mode = ''
+args = ''
+opts = ''
+cp = ''
+lcp = ''
+
+do i = 1 to words(argv)
+ param = word(argv, i)
+ select
+ when param='-lcp' then mode = 'l'
+ when param='-cp' | param='-classpath' then mode = 'c'
+ when abbrev('-opts', param, 4) then mode = 'o'
+ when abbrev('-args', param, 4) then mode = 'a'
+ otherwise
+ select
+ when mode = 'a' then args = space(args param, 1)
+ when mode = 'c' then cp = space(cp param, 1)
+ when mode = 'l' then lcp = space(lcp param, 1)
+ when mode = 'o' then opts = space(opts param, 1)
+ otherwise
+ say 'Option' param 'ignored'
+ end
+ end
+end
+
+env="OS2ENVIRONMENT"
+antconf = _getenv_('antconf' 'antconf.cmd')
+runrc = _getenv_('runrc')
+interpret 'call "' || runrc || '"' '"' || antconf || '"' 'ETC'
+ANT_HOME = value('ANT_HOME',,env)
+JAVA_HOME = value('JAVA_HOME',,env)
+classpath = value('CLASSPATH',,env)
+classes = stream(JAVA_HOME || "\lib\classes.zip", "C", "QUERY EXISTS")
+if classes \= '' then classpath = prepend(classpath classes)
+classes = stream(JAVA_HOME || "\lib\tools.jar", "C", "QUERY EXISTS")
+if classes \= '' then classpath = prepend(classpath classes)
+
+classpath = prepend(classpath ANT_HOME || '\lib\ant-launcher.jar')
+'SET CLASSPATH=' || classpath
+
+/* Setting classpathes, options and arguments */
+envset = _getenv_('envset')
+if cp\='' then interpret 'call "' || envset || '"' '"; CLASSPATH"' '"' || cp || '"'
+if lcp\='' then interpret 'call "' || envset || '"' '"; LOCALCLASSPATH"' '"' || lcp || '"'
+if opts\='' then interpret 'call "' || envset || '"' '"-D ANT_OPTS"' '"' || opts || '"'
+if args\='' then interpret 'call "' || envset || '"' '"ANT_ARGS"' '"' || args || '"'
+
+exit 0
+
+addpath: procedure
+parse arg path elem
+if elem = '' then do
+ if path\='' & right(path, 1)\=';' then path = path || ';'
+ return path
+end
+if substr(path, length(path)) = ';' then glue = ''
+else glue = ';'
+if pos(translate(elem), translate(path)) = 0 then path = path || glue || elem || ';'
+return path
+
+prepend: procedure
+parse arg path elem
+if elem = '' then do
+ if path\='' & right(path, 1)\=';' then path = path || ';'
+ return path
+end
+if pos(translate(elem), translate(path)) = 0 then path = elem || ';' || path
+return path
+
+_getenv_: procedure expose env
+parse arg envar default
+if default = '' then default = envar
+var = value(translate(envar),,env)
+if var = '' then var = default
+return var
diff --git a/modules/common/ant-bundle/src/main/assembly/bin/envset.cmd b/modules/common/ant-bundle/src/main/assembly/bin/envset.cmd
index 3149be4..3b07419 100644
--- a/modules/common/ant-bundle/src/main/assembly/bin/envset.cmd
+++ b/modules/common/ant-bundle/src/main/assembly/bin/envset.cmd
@@ -1,131 +1,131 @@
-/*
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-SET environment variables
-First optional parameter:
- ; parameters are considered parts of a path variable, semicolons are
- appended to each element if not already present
- -D parameters are properties for Java or Makefile etc., -D will be
- prepended and the parameters will be separated by a space
- =D the same as above but equal sign is not required
- , parameters should be comma separated in the environment variable
- - parameters should be separated by the next parameter
- Other values mean that the first parameter is missing and the environment
- variable will be set to the space separated parameters
-
-Second parameter: name of the environment variable
-
-Next parameters: values
-; implies that the equal sign is considered a part of the parameter and is
-not interpreted
-
--D requires parameters in the form name=value. If the equal sign is not found,
-the parameters are changed to name=expanded_name
-
-Other options have optional equal sign. If it is found, only the part after
-the equal sign will be oprionally expanded.
-
-If the parameter is the minus sign, the next parameter will not be expanded.
-If the parameter is a single dot, it will be replaced with the value of the
-environment variable as it existed before envset was invoked.
-
-For other parameters the batch looks for the environment variable with the
-same name (in uppercase). If it is found, it forms the expanded_name. If
-the environment variable with such a name does not exist, the expanded_name
-will hold the parameter name without case conversion.
-*/
-
-parse arg mode envar args
-
-equal = 0
-sep = ' '
-
-/* Parse command line parameters */
-select
- when mode='-' then do
- sep = envar
- parse var args envar args
- end
- when mode=';' then do
- sep = ''
- equal = -1
- end
- when mode='-D' then equal = 1
- when mode='=D' then mode = '-D'
- when mode=',' then sep = ','
-otherwise
- args = envar args
- envar = mode
- mode = ''
-end
-
-env = 'OS2ENVIRONMENT'
-envar = translate(envar)
-orig = value(envar,,env)
-newval = ''
-expand = 1
-
-/* for each parameter... */
-do i = 1 to words(args)
- if expand > 0 & word(args, i) = '-' then expand = 0
- else call addval word(args, i)
-end
-
-/* Optionally enclose path variable by quotes */
-if mode = ';' & pos(' ', newval) > 0 then newval = '"' || newval || '"'
-
-/* Set the new value, 'SET' cannot be used since it does not allow '=' */
-x = value(envar, newval, env)
-exit 0
-
-addval: procedure expose sep equal orig expand newval mode env
-parse arg var
-
-if var = '.' then expvar = orig
-else do
- if equal >= 0 then do
- parse var var name '=' val
- if val = '' then var = name
- else var = val
- end
- if expand = 0 then expvar = var
- else expvar = value(translate(var),,env)
- if expvar = '' then expvar = var
- if equal >= 0 then do
- if val = '' then do
- parse var expvar key '=' val
- if val <> '' then name = key
- else do
- if equal > 0 then val = key
- else name = key
- end
- end
- else val = expvar
- if pos(' ', val) > 0 | pos('=', val) > 0 then val = '"' || val || '"'
- if val = '' then expvar = name
- else expvar = name || '=' || val
- end
- if mode = '-D' then expvar = '-D' || expvar
- if mode = ';' then do
- if right(expvar, 1) <> ';' then expvar = expvar || ';'
- end
-end
-
-if newval = '' then newval = expvar
-else newval = newval || sep || expvar
-expand = 1
-return
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+SET environment variables
+First optional parameter:
+ ; parameters are considered parts of a path variable, semicolons are
+ appended to each element if not already present
+ -D parameters are properties for Java or Makefile etc., -D will be
+ prepended and the parameters will be separated by a space
+ =D the same as above but equal sign is not required
+ , parameters should be comma separated in the environment variable
+ - parameters should be separated by the next parameter
+ Other values mean that the first parameter is missing and the environment
+ variable will be set to the space separated parameters
+
+Second parameter: name of the environment variable
+
+Next parameters: values
+; implies that the equal sign is considered a part of the parameter and is
+not interpreted
+
+-D requires parameters in the form name=value. If the equal sign is not found,
+the parameters are changed to name=expanded_name
+
+Other options have optional equal sign. If it is found, only the part after
+the equal sign will be oprionally expanded.
+
+If the parameter is the minus sign, the next parameter will not be expanded.
+If the parameter is a single dot, it will be replaced with the value of the
+environment variable as it existed before envset was invoked.
+
+For other parameters the batch looks for the environment variable with the
+same name (in uppercase). If it is found, it forms the expanded_name. If
+the environment variable with such a name does not exist, the expanded_name
+will hold the parameter name without case conversion.
+*/
+
+parse arg mode envar args
+
+equal = 0
+sep = ' '
+
+/* Parse command line parameters */
+select
+ when mode='-' then do
+ sep = envar
+ parse var args envar args
+ end
+ when mode=';' then do
+ sep = ''
+ equal = -1
+ end
+ when mode='-D' then equal = 1
+ when mode='=D' then mode = '-D'
+ when mode=',' then sep = ','
+otherwise
+ args = envar args
+ envar = mode
+ mode = ''
+end
+
+env = 'OS2ENVIRONMENT'
+envar = translate(envar)
+orig = value(envar,,env)
+newval = ''
+expand = 1
+
+/* for each parameter... */
+do i = 1 to words(args)
+ if expand > 0 & word(args, i) = '-' then expand = 0
+ else call addval word(args, i)
+end
+
+/* Optionally enclose path variable by quotes */
+if mode = ';' & pos(' ', newval) > 0 then newval = '"' || newval || '"'
+
+/* Set the new value, 'SET' cannot be used since it does not allow '=' */
+x = value(envar, newval, env)
+exit 0
+
+addval: procedure expose sep equal orig expand newval mode env
+parse arg var
+
+if var = '.' then expvar = orig
+else do
+ if equal >= 0 then do
+ parse var var name '=' val
+ if val = '' then var = name
+ else var = val
+ end
+ if expand = 0 then expvar = var
+ else expvar = value(translate(var),,env)
+ if expvar = '' then expvar = var
+ if equal >= 0 then do
+ if val = '' then do
+ parse var expvar key '=' val
+ if val <> '' then name = key
+ else do
+ if equal > 0 then val = key
+ else name = key
+ end
+ end
+ else val = expvar
+ if pos(' ', val) > 0 | pos('=', val) > 0 then val = '"' || val || '"'
+ if val = '' then expvar = name
+ else expvar = name || '=' || val
+ end
+ if mode = '-D' then expvar = '-D' || expvar
+ if mode = ';' then do
+ if right(expvar, 1) <> ';' then expvar = expvar || ';'
+ end
+end
+
+if newval = '' then newval = expvar
+else newval = newval || sep || expvar
+expand = 1
+return
diff --git a/modules/common/ant-bundle/src/main/assembly/bin/lcp.bat b/modules/common/ant-bundle/src/main/assembly/bin/lcp.bat
index dc7e9bf..4bf2e7c 100644
--- a/modules/common/ant-bundle/src/main/assembly/bin/lcp.bat
+++ b/modules/common/ant-bundle/src/main/assembly/bin/lcp.bat
@@ -1,31 +1,31 @@
-REM
-REM Licensed to the Apache Software Foundation (ASF) under one or more
-REM contributor license agreements. See the NOTICE file distributed with
-REM this work for additional information regarding copyright ownership.
-REM The ASF licenses this file to You under the Apache License, Version 2.0
-REM (the "License"); you may not use this file except in compliance with
-REM the License. You may obtain a copy of the License at
-REM
-REM http://www.apache.org/licenses/LICENSE-2.0
-REM
-REM Unless required by applicable law or agreed to in writing, software
-REM distributed under the License is distributed on an "AS IS" BASIS,
-REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-REM See the License for the specific language governing permissions and
-REM limitations under the License.
-REM
-REM
-
-set _CLASSPATHCOMPONENT=%1
-if ""%1""=="""" goto gotAllArgs
-shift
-
-:argCheck
-if ""%1""=="""" goto gotAllArgs
-set _CLASSPATHCOMPONENT=%_CLASSPATHCOMPONENT% %1
-shift
-goto argCheck
-
-:gotAllArgs
-set LOCALCLASSPATH=%LOCALCLASSPATH%;%_CLASSPATHCOMPONENT%
-
+REM
+REM Licensed to the Apache Software Foundation (ASF) under one or more
+REM contributor license agreements. See the NOTICE file distributed with
+REM this work for additional information regarding copyright ownership.
+REM The ASF licenses this file to You under the Apache License, Version 2.0
+REM (the "License"); you may not use this file except in compliance with
+REM the License. You may obtain a copy of the License at
+REM
+REM http://www.apache.org/licenses/LICENSE-2.0
+REM
+REM Unless required by applicable law or agreed to in writing, software
+REM distributed under the License is distributed on an "AS IS" BASIS,
+REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+REM See the License for the specific language governing permissions and
+REM limitations under the License.
+REM
+REM
+
+set _CLASSPATHCOMPONENT=%1
+if ""%1""=="""" goto gotAllArgs
+shift
+
+:argCheck
+if ""%1""=="""" goto gotAllArgs
+set _CLASSPATHCOMPONENT=%_CLASSPATHCOMPONENT% %1
+shift
+goto argCheck
+
+:gotAllArgs
+set LOCALCLASSPATH=%LOCALCLASSPATH%;%_CLASSPATHCOMPONENT%
+
diff --git a/modules/common/ant-bundle/src/main/assembly/bin/rhq-ant.cmd b/modules/common/ant-bundle/src/main/assembly/bin/rhq-ant.cmd
index 70665c0..d221a40 100644
--- a/modules/common/ant-bundle/src/main/assembly/bin/rhq-ant.cmd
+++ b/modules/common/ant-bundle/src/main/assembly/bin/rhq-ant.cmd
@@ -1,93 +1,93 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- Run ant
-*/
-
-'@echo off'
-parse arg mode envarg '::' antarg
-
-if mode\='.' & mode\='..' & mode\='/' then do
- envarg = mode envarg
- mode = ''
-end
-
-if antarg = '' then do
- antarg = envarg
- envarg = ''
-end
-
-x = setlocal()
-
-env="OS2ENVIRONMENT"
-antenv = _getenv_('antenv')
-if _testenv_() = 0 then interpret 'call "' || antenv || '"' '"' || envarg || '"'
-
-if mode = '' then mode = _getenv_('ANT_MODE' '..')
-if mode \= '/' then do
- runrc = _getenv_('runrc')
- antrc = _getenv_('antrc' 'antrc.cmd')
- if mode = '..' then mode = '-r'
- else mode = ''
- interpret 'call "' || runrc || '"' antrc '"' || mode || '"'
-end
-
-if _testenv_() = 0 then do
- say 'Ant environment is not set properly'
- x = endlocal()
- exit 16
-end
-
-settings = '-Dant.home=' || ANT_HOME '-Djava.home=' || JAVA_HOME
-
-java = _getenv_('javacmd' 'java')
-opts = value('ANT_OPTS',,env)
-args = value('ANT_ARGS',,env)
-lcp = value('LOCALCLASSPATH',,env)
-cp = value('CLASSPATH',,env)
-if value('ANT_USE_CP',,env) \= '' then do
- if lcp \= '' & right(lcp, 1) \= ';' then lcp = lcp || ';'
- lcp = lcp || cp
- 'SET CLASSPATH='
-end
-if lcp\='' then lcp = '-classpath' lcp
-
-cmd = java opts lcp '-jar' ANT_HOME ||'\lib\ant-launcher.jar' settings args antarg
-launcher = stream(ANT_HOME ||'\lib\ant-launcher.jar', 'C', 'query exists')
-if launcher = '' then entry = 'org.apache.tools.ant.Main'
-else entry = 'org.apache.tools.ant.launch.Launcher'
-java opts lcp entry settings args antarg
-
-x = endlocal()
-
-return rc
-
-_testenv_: procedure expose env ANT_HOME JAVA_HOME
-ANT_HOME = value('ANT_HOME',,env)
-if ANT_HOME = '' then return 0
-JAVA_HOME = value('JAVA_HOME',,env)
-if JAVA_HOME = '' then return 0
-cp = translate(value('CLASSPATH',,env))
-if pos(translate(ANT_HOME), cp) = 0 then return 0
-if pos(translate(JAVA_HOME), cp) = 0 then return 0
-return 1
-
-_getenv_: procedure expose env
-parse arg envar default
-if default = '' then default = envar
-var = value(translate(envar),,env)
-if var = '' then var = default
-return var
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ Run ant
+*/
+
+'@echo off'
+parse arg mode envarg '::' antarg
+
+if mode\='.' & mode\='..' & mode\='/' then do
+ envarg = mode envarg
+ mode = ''
+end
+
+if antarg = '' then do
+ antarg = envarg
+ envarg = ''
+end
+
+x = setlocal()
+
+env="OS2ENVIRONMENT"
+antenv = _getenv_('antenv')
+if _testenv_() = 0 then interpret 'call "' || antenv || '"' '"' || envarg || '"'
+
+if mode = '' then mode = _getenv_('ANT_MODE' '..')
+if mode \= '/' then do
+ runrc = _getenv_('runrc')
+ antrc = _getenv_('antrc' 'antrc.cmd')
+ if mode = '..' then mode = '-r'
+ else mode = ''
+ interpret 'call "' || runrc || '"' antrc '"' || mode || '"'
+end
+
+if _testenv_() = 0 then do
+ say 'Ant environment is not set properly'
+ x = endlocal()
+ exit 16
+end
+
+settings = '-Dant.home=' || ANT_HOME '-Djava.home=' || JAVA_HOME
+
+java = _getenv_('javacmd' 'java')
+opts = value('ANT_OPTS',,env)
+args = value('ANT_ARGS',,env)
+lcp = value('LOCALCLASSPATH',,env)
+cp = value('CLASSPATH',,env)
+if value('ANT_USE_CP',,env) \= '' then do
+ if lcp \= '' & right(lcp, 1) \= ';' then lcp = lcp || ';'
+ lcp = lcp || cp
+ 'SET CLASSPATH='
+end
+if lcp\='' then lcp = '-classpath' lcp
+
+cmd = java opts lcp '-jar' ANT_HOME ||'\lib\ant-launcher.jar' settings args antarg
+launcher = stream(ANT_HOME ||'\lib\ant-launcher.jar', 'C', 'query exists')
+if launcher = '' then entry = 'org.apache.tools.ant.Main'
+else entry = 'org.apache.tools.ant.launch.Launcher'
+java opts lcp entry settings args antarg
+
+x = endlocal()
+
+return rc
+
+_testenv_: procedure expose env ANT_HOME JAVA_HOME
+ANT_HOME = value('ANT_HOME',,env)
+if ANT_HOME = '' then return 0
+JAVA_HOME = value('JAVA_HOME',,env)
+if JAVA_HOME = '' then return 0
+cp = translate(value('CLASSPATH',,env))
+if pos(translate(ANT_HOME), cp) = 0 then return 0
+if pos(translate(JAVA_HOME), cp) = 0 then return 0
+return 1
+
+_getenv_: procedure expose env
+parse arg envar default
+if default = '' then default = envar
+var = value(translate(envar),,env)
+if var = '' then var = default
+return var
diff --git a/modules/common/ant-bundle/src/main/assembly/bin/runrc.cmd b/modules/common/ant-bundle/src/main/assembly/bin/runrc.cmd
index 34b4f5d..c68f04d 100644
--- a/modules/common/ant-bundle/src/main/assembly/bin/runrc.cmd
+++ b/modules/common/ant-bundle/src/main/assembly/bin/runrc.cmd
@@ -1,60 +1,60 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- Run RC file, name is in the first arg, second arg is either PATH
- ENV or -r or nothing
-*/
-
-parse arg name path rest
-
-if name = '' then do
- say 'RC file name is missing'
- exit 1
-end
-
-if rest \= '' then do
- say 'Too many parameters'
- exit 1
-end
-
-call runit name path
-exit 0
-
-runit: procedure
-parse arg name path dir
-
-if path \= '' & path \= '-r' then do
- dir = value(translate(path),,'OS2ENVIRONMENT')
- if dir = '' then return
- dir = translate(dir, '\', '/') /* change UNIX-like path to OS/2 */
-end
-
-if dir = '' then dir = directory()
-
-if path = '-r' then do /* recursive call */
- subdir = filespec('path', dir)
- if subdir \= '\' then do
- subdir = left(subdir, length(subdir)-1)
- call runit name path filespec('drive', dir) || subdir
- end
-end
-
-/* Look for the file and run it */
-if right(dir, 1) \= '\' then dir = dir || '\'
-rcfile = stream(dir || name, 'c', 'query exists')
-if rcfile \= '' then interpret 'call "' || rcfile || '"'
-
-return
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ Run RC file, name is in the first arg, second arg is either PATH
+ ENV or -r or nothing
+*/
+
+parse arg name path rest
+
+if name = '' then do
+ say 'RC file name is missing'
+ exit 1
+end
+
+if rest \= '' then do
+ say 'Too many parameters'
+ exit 1
+end
+
+call runit name path
+exit 0
+
+runit: procedure
+parse arg name path dir
+
+if path \= '' & path \= '-r' then do
+ dir = value(translate(path),,'OS2ENVIRONMENT')
+ if dir = '' then return
+ dir = translate(dir, '\', '/') /* change UNIX-like path to OS/2 */
+end
+
+if dir = '' then dir = directory()
+
+if path = '-r' then do /* recursive call */
+ subdir = filespec('path', dir)
+ if subdir \= '\' then do
+ subdir = left(subdir, length(subdir)-1)
+ call runit name path filespec('drive', dir) || subdir
+ end
+end
+
+/* Look for the file and run it */
+if right(dir, 1) \= '\' then dir = dir || '\'
+rcfile = stream(dir || name, 'c', 'query exists')
+if rcfile \= '' then interpret 'call "' || rcfile || '"'
+
+return
commit e782aced9325fee8159672fb037eb96c3da74050
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 11:09:57 2010 -0400
Additional check for proper prop def merging
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
index 238c3c6..e4c608c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
@@ -445,13 +445,20 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
* @param newProperty the new prop that should replace the existing prop
*/
private void replaceListPropertyMemberDefinition(PropertyDefinitionList exList, PropertyDefinitionList newList) {
- PropertyDefinition doomedMember = exList.getMemberDefinition();
+ PropertyDefinition doomedMember = null;
+
+ // only remove the existing member if it is a different entity
+ if (exList.getMemberDefinition().getId() != newList.getMemberDefinition().getId()) {
+ doomedMember = exList.getMemberDefinition();
+ }
exList.setMemberDefinition(newList.getMemberDefinition());
exList.setMax(newList.getMax());
exList.setMin(newList.getMin());
- entityManager.remove(doomedMember);
+ if (null != doomedMember) {
+ entityManager.remove(doomedMember);
+ }
entityManager.merge(exList);
entityManager.flush();
}
commit 36b1e605cad08f003af34fb8d51733142637534e
Merge: 229a6c4... cc8f2db...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 10:34:00 2010 -0400
Merge branch 'master' into master-jay
commit 229a6c47e809481ea9011698dc46a58ca574875f
Merge: d3fa4b8... d3cc735...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 09:45:34 2010 -0400
Merge branch 'master' into master-jay
commit d3fa4b8aceb726dc8eda7c6164e4693cb415512c
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 09:43:59 2010 -0400
Test failure showed some bad behavior with respect to the handling
of PropDefEnumerations, their cleanup and their order indexing. To
resolve I've basically moved ordering logic from the PDE to the
PropDefSimple, which uses the enumerated values. In more detail:
- remove the PrePersist/PreUpdate orderIndex setting from PDE. this
didn't always work, and was the source of the test failure, it relied
on the encompassing PDS being fully formed, which it may not be.
- Add logic to PDS to assign sane orderIndexes at the time the enumerations
are set/added/removed.
- update the config metadata update logic analogously, and improve
cleanup of obsolete config defs.
- updated and reenabled the previously failing tests
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionEnumeration.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionEnumeration.java
index 3781d13..fbcabb4 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionEnumeration.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionEnumeration.java
@@ -31,8 +31,6 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
-import javax.persistence.PrePersist;
-import javax.persistence.PreUpdate;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
@@ -63,7 +61,7 @@ public class PropertyDefinitionEnumeration implements Serializable {
private String value;
@Column(name = "ORDER_INDEX", nullable = false)
- private int orderIndex;
+ private int orderIndex = -1;
@Column(name = "IS_DEFAULT")
private boolean isDefault;
@@ -87,11 +85,13 @@ public class PropertyDefinitionEnumeration implements Serializable {
this.isDefault = isDefault;
}
- @PrePersist
- @PreUpdate
- public void updateOrder() {
- this.orderIndex = this.propertyDefinitionSimple.getEnumeratedValues().indexOf(this);
- }
+ // @PrePersist
+ // @PreUpdate
+ // public void updateOrder() {
+ // if (this.orderIndex < 0) {
+ // this.orderIndex = this.propertyDefinitionSimple.getEnumeratedValues().indexOf(this);
+ // }
+ // }
public PropertyDefinitionSimple getPropertyDefinitionSimple() {
return propertyDefinitionSimple;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
index 3a7be2c..a27b677 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
@@ -157,12 +157,30 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
public void setEnumeratedValues(List<PropertyDefinitionEnumeration> enumeratedValues, boolean allowCustomEnumValue) {
this.enumeratedValues = enumeratedValues;
this.allowCustomEnumeratedValue = allowCustomEnumValue;
+ ensureOrdering();
}
public void addEnumeratedValues(PropertyDefinitionEnumeration... enumerations) {
for (PropertyDefinitionEnumeration enumeration : enumerations) {
- getEnumeratedValues().add(enumeration);
enumeration.setPropertyDefinitionSimple(this);
+ getEnumeratedValues().add(enumeration);
+ }
+ ensureOrdering();
+ }
+
+ public void removeEnumeratedValues(PropertyDefinitionEnumeration... enumerations) {
+ for (PropertyDefinitionEnumeration enumeration : enumerations) {
+ getEnumeratedValues().remove(enumeration);
+ }
+ ensureOrdering();
+ }
+
+ private void ensureOrdering() {
+ if (null == this.enumeratedValues) {
+ return;
+ }
+ for (int i = 0, size = getEnumeratedValues().size(); (i < size); ++i) {
+ getEnumeratedValues().get(i).setOrderIndex(i);
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
index 4abf76f..238c3c6 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
@@ -30,6 +30,7 @@ import javax.persistence.PersistenceContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -274,8 +275,7 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
* @param existingProperties list of existing properties to inspect for potential removal
*/
private void removeNoLongerUsedProperties(ConfigurationDefinition newConfigDef,
- ConfigurationDefinition existingConfigDef,
- List<PropertyDefinition> existingProperties) {
+ ConfigurationDefinition existingConfigDef, List<PropertyDefinition> existingProperties) {
List<PropertyDefinition> propDefsToDelete = new ArrayList<PropertyDefinition>();
for (PropertyDefinition existingPropDef : existingProperties) {
PropertyDefinition newPropDef = newConfigDef.get(existingPropDef.getName());
@@ -350,14 +350,8 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
PropertyDefinitionList exList = (PropertyDefinitionList) existingProperty;
if (newProperty instanceof PropertyDefinitionList) {
PropertyDefinitionList newList = (PropertyDefinitionList) newProperty;
- exList.setMemberDefinition(newList.getMemberDefinition());
- exList.setMax(newList.getMax());
- exList.setMin(newList.getMax());
- // what about parentPropertyListDefinition ?
-
- // TODO recursively update the member ?
- } else // simple property or map-property
- {
+ replaceListPropertyMemberDefinition(exList, newList);
+ } else { // simple property or map-property
replaceProperty(existingProperty, newProperty);
}
} else if (existingProperty instanceof PropertyDefinitionSimple) {
@@ -374,12 +368,11 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
List<PropertyDefinitionEnumeration> toDelete = missingInFirstList(newOptions, existingOptions);
List<PropertyDefinitionEnumeration> changed = intersection(existingOptions, newOptions);
- // TODO GH: This still doesn't properly reorder options, but at least it doesn't leave any nulls
- // and therefore doesn't blow up the renderer
- // delete old ones (first so we don't leave index holes later)
+ // sync the enumerated values and then merge the changes into the PDS, I think this
+ // solves previous issues with orderIndex values.
+ // First remove obsolete values
for (PropertyDefinitionEnumeration pde : toDelete) {
- existingOptions.remove(pde);
- entityManager.remove(pde);
+ existingPDS.removeEnumeratedValues(pde);
}
// save new ones
@@ -388,16 +381,16 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
entityManager.persist(pde);
}
+ // update others
for (PropertyDefinitionEnumeration pde : changed) {
for (PropertyDefinitionEnumeration nPde : newOptions) {
if (nPde.equals(pde)) {
pde.setDefault(nPde.isDefault());
- pde.setOrderIndex(nPde.getOrderIndex());
pde.setValue(nPde.getValue());
- entityManager.merge(pde);
}
}
}
+ entityManager.merge(existingPDS);
// handle <constraint> [0..*]
@@ -444,6 +437,26 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
}
/**
+ * This replaces the member property for the list. If it is a nested structure the whole thing
+ * is replaced from the top. The previous member property is removed. cascading should remove a nested
+ * structure.
+ *
+ * @param existingProperty the existing prop
+ * @param newProperty the new prop that should replace the existing prop
+ */
+ private void replaceListPropertyMemberDefinition(PropertyDefinitionList exList, PropertyDefinitionList newList) {
+ PropertyDefinition doomedMember = exList.getMemberDefinition();
+
+ exList.setMemberDefinition(newList.getMemberDefinition());
+ exList.setMax(newList.getMax());
+ exList.setMin(newList.getMin());
+
+ entityManager.remove(doomedMember);
+ entityManager.merge(exList);
+ entityManager.flush();
+ }
+
+ /**
* Return a list containing those element that are in reference, but not in first. Both input lists are not modified
*
* @param first
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java
index 0dc958a..4a07bb7 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java
@@ -581,187 +581,176 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
}
}
- // TODO (jshaughn) For some reason this test is creating a ConfigDef that Hibernate chokes on. Need
- // to come back and figure out why. Perhaps it's oracle specific... Also, if activated update
- // cleanup routine in TestBase to delete myPlatform6.
- @Test(enabled = false)
- public void testListProperty() throws Exception {
- // Note, plugins are registered in new transactions. for tests, this means
- // you can't do everything in a trans and roll back at the end. You must clean up
- // manually.
+ @Test(enabled = ENABLED)
+ public void testListOfLists() throws Exception {
try {
- { // extra block for variable scoping purposes
- registerPlugin("propertyList-v1.xml");
- ResourceType platform = getResourceType("myPlatform6");
- getTransactionManager().begin();
- EntityManager em = getEntityManager();
- platform = em.find(ResourceType.class, platform.getId());
-
- ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
- Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
- assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v1, but got " + propDefs.size();
- for (PropertyDefinition def : propDefs.values()) {
- assert def instanceof PropertyDefinitionList : "PropertyDefinition " + def.getName()
- + " is no list-property in v1";
- PropertyDefinitionList pdl = (PropertyDefinitionList) def;
- PropertyDefinition member = pdl.getMemberDefinition();
-
- if (pdl.getName().equals("myList1")) {
- assert pdl.getDescription().equals("Just a simple list");
- assert member instanceof PropertyDefinitionSimple : "Expected the member of myList1 to be a simple property in v1";
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
- assert pds.getName().equals("foo");
- } else if (pdl.getName().equals("myList2")) {
- assert member instanceof PropertyDefinitionList : "Expected the member of myList2 to be a list property in v1";
- } else if (pdl.getName().equals("myList3")) {
- assert member instanceof PropertyDefinitionSimple : "Expected the member of myList3 to be a simple property in v1";
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
- assert pds.getName().equals("baz");
- } else if (pdl.getName().equals("rec1")) {
- assert member instanceof PropertyDefinitionList : "Expected the member of rc1 to be a list property in v1";
- PropertyDefinitionList pdl2 = (PropertyDefinitionList) member;
-
- // TODO check min/max for the lists on the way. Commented out. See JBNADM-1595
- assert pdl2.getName().equals("rec2");
-
- // assert pdl2.getMin()==2 : "Expected rec2:min to be 2, but it was " + pdl2.getMin();
- // assert pdl2.getMax()==20;
- pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
- assert pdl2.getName().equals("rec3");
-
- // assert pdl2.getMin()==3;
- // assert pdl2.getMax()==30;
- pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
- assert pdl2.getName().equals("rec4");
-
- // assert pdl2.getMin()==4;
- // assert pdl2.getMax()==40;
- assert pdl2.getMemberDefinition() instanceof PropertyDefinitionSimple;
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pdl2.getMemberDefinition();
- assert pds.getName().equals("rec5");
- assert pds.getDescription().equals("Deeply nested");
- List<PropertyDefinitionEnumeration> options = pds.getEnumeratedValues();
- assert options.size() == 4;
- int found = 0;
- String[] optionVals = new String[] { "a", "b", "c", "d" };
- for (PropertyDefinitionEnumeration option : options) {
- if (containedIn(option.getValue(), optionVals)) {
- found++;
- }
+ // extra block for variable scoping purposes
+ registerPlugin("propertyList-v1.xml");
+ ResourceType platform = getResourceType("myPlatform6");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+ ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
+ Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
+ assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v1, but got " + propDefs.size();
+ for (PropertyDefinition def : propDefs.values()) {
+ assert def instanceof PropertyDefinitionList : "PropertyDefinition " + def.getName()
+ + " is no list-property in v1";
+ PropertyDefinitionList pdl = (PropertyDefinitionList) def;
+ PropertyDefinition member = pdl.getMemberDefinition();
+
+ if (pdl.getName().equals("myList1")) {
+ assert pdl.getDescription().equals("Just a simple list");
+ assert member instanceof PropertyDefinitionSimple : "Expected the member of myList1 to be a simple property in v1";
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
+ assert pds.getName().equals("foo");
+ } else if (pdl.getName().equals("myList2")) {
+ assert member instanceof PropertyDefinitionList : "Expected the member of myList2 to be a list property in v1";
+ } else if (pdl.getName().equals("myList3")) {
+ assert member instanceof PropertyDefinitionSimple : "Expected the member of myList3 to be a simple property in v1";
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
+ assert pds.getName().equals("baz");
+ } else if (pdl.getName().equals("rec1")) {
+ assert member instanceof PropertyDefinitionList : "Expected the member of rc1 to be a list property in v1";
+ PropertyDefinitionList pdl2 = (PropertyDefinitionList) member;
+
+ // TODO check min/max for the lists on the way. Commented out. See JBNADM-1595
+ assert pdl2.getName().equals("rec2");
+
+ // assert pdl2.getMin()==2 : "Expected rec2:min to be 2, but it was " + pdl2.getMin();
+ // assert pdl2.getMax()==20;
+ pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
+ assert pdl2.getName().equals("rec3");
+
+ // assert pdl2.getMin()==3;
+ // assert pdl2.getMax()==30;
+ pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
+ assert pdl2.getName().equals("rec4");
+
+ // assert pdl2.getMin()==4;
+ // assert pdl2.getMax()==40;
+ assert pdl2.getMemberDefinition() instanceof PropertyDefinitionSimple;
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pdl2.getMemberDefinition();
+ assert pds.getName().equals("rec5");
+ assert pds.getDescription().equals("Deeply nested");
+ List<PropertyDefinitionEnumeration> options = pds.getEnumeratedValues();
+ assert options.size() == 4;
+ int found = 0;
+ String[] optionVals = new String[] { "a", "b", "c", "d" };
+ for (PropertyDefinitionEnumeration option : options) {
+ if (containedIn(option.getValue(), optionVals)) {
+ found++;
}
-
- assert found == 4;
- Set<Constraint> constraints = pds.getConstraints();
- assert constraints.size() == 1;
- } else {
- assert true == false : "Unknown list-definition in v1: " + pdl.getName();
}
+
+ assert found == 4;
+ Set<Constraint> constraints = pds.getConstraints();
+ assert constraints.size() == 1;
+ } else {
+ assert true == false : "Unknown list-definition in v1: " + pdl.getName();
}
- getTransactionManager().rollback();
}
+ getTransactionManager().rollback();
/*
* Deploy v2 of the plugin
*/
- { // extra block for variable scoping purposes
- registerPlugin("propertyList-v2.xml");
- ResourceType platform = getResourceType("myPlatform6");
- getTransactionManager().begin();
- EntityManager em = getEntityManager();
- platform = em.find(ResourceType.class, platform.getId());
-
- ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
- Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
- assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v2, but got " + propDefs.size();
- for (PropertyDefinition def : propDefs.values()) {
- assert def instanceof PropertyDefinitionList : "PropertyDefinition " + def.getName()
- + " is no list-property in v2";
- PropertyDefinitionList pdl = (PropertyDefinitionList) def;
- PropertyDefinition member = pdl.getMemberDefinition();
-
- if (pdl.getName().equals("myList2")) {
- assert member instanceof PropertyDefinitionList : "Expected the member of myList2 to be a list property in v2";
- } else if (pdl.getName().equals("myList3")) {
- assert member instanceof PropertyDefinitionList : "Expected the member of myList3 to be a list property in v2";
- PropertyDefinitionList pds = (PropertyDefinitionList) member;
- assert pds.getName().equals("baz");
- assert pds.getDescription().equals("myList3:baz");
- assert pds.getMemberDefinition() instanceof PropertyDefinitionSimple : "Expected the member of list3:baz to be a simple property in v2";
- } else if (pdl.getName().equals("myList4")) {
- assert pdl.getDescription().equals("Just a simple list");
- assert member instanceof PropertyDefinitionSimple : "Expected the member of myList4 to be a simple property in v2";
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
- assert pds.getName().equals("foo");
- } else if (pdl.getName().equals("rec1")) {
- assert member instanceof PropertyDefinitionList : "Expected the member of rec1 to be a list property in v2";
- PropertyDefinitionList pdl2 = (PropertyDefinitionList) member;
- assert pdl2.getName().equals("rec2");
-
- /*
- * PropertyDefinitionList.getMin()/getMax() are commented out. See JBNADM1595
- */
+ registerPlugin("propertyList-v2.xml");
+ platform = getResourceType("myPlatform6");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
- // assert pdl2.getMin()==12 : "Expected rec2:min to be 12, but it was " + pdl2.getMin();
- // assert pdl2.getMax()==200;
- pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
- assert pdl2.getName().equals("rec3+");
-
- // assert pdl2.getMin()==13;
- // assert pdl2.getMax()==300;
- pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
- assert pdl2.getName().equals("rec4");
-
- // assert pdl2.getMin()==14;
- // assert pdl2.getMax()==400;
- assert pdl2.getMemberDefinition() instanceof PropertyDefinitionSimple;
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pdl2.getMemberDefinition();
- assert pds.getName().equals("rec5");
- assert pds.getDescription().equals("Nested deeply");
- List<PropertyDefinitionEnumeration> options = pds.getEnumeratedValues();
- assert options.size() == 5;
- int found = 0;
- String[] optionVals = new String[] { "b", "c", "d", "x", "z" };
- for (PropertyDefinitionEnumeration option : options) {
- if (containedIn(option.getValue(), optionVals)) {
- found++;
- }
+ cd = platform.getResourceConfigurationDefinition();
+ propDefs = cd.getPropertyDefinitions();
+ assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v2, but got " + propDefs.size();
+ for (PropertyDefinition def : propDefs.values()) {
+ assert def instanceof PropertyDefinitionList : "PropertyDefinition " + def.getName()
+ + " is no list-property in v2";
+ PropertyDefinitionList pdl = (PropertyDefinitionList) def;
+ PropertyDefinition member = pdl.getMemberDefinition();
+
+ if (pdl.getName().equals("myList2")) {
+ assert member instanceof PropertyDefinitionList : "Expected the member of myList2 to be a list property in v2";
+ } else if (pdl.getName().equals("myList3")) {
+ assert member instanceof PropertyDefinitionList : "Expected the member of myList3 to be a list property in v2";
+ PropertyDefinitionList pds = (PropertyDefinitionList) member;
+ assert pds.getName().equals("baz");
+ assert pds.getDescription().equals("myList3:baz");
+ assert pds.getMemberDefinition() instanceof PropertyDefinitionSimple : "Expected the member of list3:baz to be a simple property in v2";
+ } else if (pdl.getName().equals("myList4")) {
+ assert pdl.getDescription().equals("Just a simple list");
+ assert member instanceof PropertyDefinitionSimple : "Expected the member of myList4 to be a simple property in v2";
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
+ assert pds.getName().equals("foo");
+ } else if (pdl.getName().equals("rec1")) {
+ assert member instanceof PropertyDefinitionList : "Expected the member of rec1 to be a list property in v2";
+ PropertyDefinitionList pdl2 = (PropertyDefinitionList) member;
+ assert pdl2.getName().equals("rec2");
+
+ /*
+ * PropertyDefinitionList.getMin()/getMax() are commented out. See JBNADM1595
+ */
+
+ // assert pdl2.getMin()==12 : "Expected rec2:min to be 12, but it was " + pdl2.getMin();
+ // assert pdl2.getMax()==200;
+ pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
+ assert pdl2.getName().equals("rec3+");
+
+ // assert pdl2.getMin()==13;
+ // assert pdl2.getMax()==300;
+ pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
+ assert pdl2.getName().equals("rec4");
+
+ // assert pdl2.getMin()==14;
+ // assert pdl2.getMax()==400;
+ assert pdl2.getMemberDefinition() instanceof PropertyDefinitionSimple;
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pdl2.getMemberDefinition();
+ assert pds.getName().equals("rec5");
+ assert pds.getDescription().equals("Nested deeply");
+ List<PropertyDefinitionEnumeration> options = pds.getEnumeratedValues();
+ assert options.size() == 5;
+ int found = 0;
+ String[] optionVals = new String[] { "b", "c", "d", "x", "z" };
+ for (PropertyDefinitionEnumeration option : options) {
+ if (containedIn(option.getValue(), optionVals)) {
+ found++;
}
+ }
- assert found == optionVals.length;
- Set<Constraint> constraints = pds.getConstraints();
- assert constraints.size() == 2;
- for (Constraint constraint : constraints) {
- if (constraint instanceof IntegerRangeConstraint) {
- IntegerRangeConstraint irc = (IntegerRangeConstraint) constraint;
- assert irc != null : "Integer-constraint was null, but should not be";
- // See JBNADM-1596/97
- assert irc.getDetails().equals("-2#10");
- // TODO (ips, 3/31/10): The below is a workaround for IntegerRangeConstraint.onLoad() not being called by Hibernate.
- irc.setDetails(irc.getDetails());
- assert irc.getMaximum() == 10;
- assert irc.getMinimum() == -2;
- } else if (constraint instanceof FloatRangeConstraint) {
- FloatRangeConstraint frc = (FloatRangeConstraint) constraint;
- assert frc != null : "Float-constraint was null, but should not be";
- // See JBNADM-1596/97
- assert frc.getDetails().equals("10.0#5.0");
- // TODO (ips, 3/31/10): The below is a workaround for FloatRangeConstraint.onLoad() not being called by Hibernate.
- frc.setDetails(frc.getDetails());
- assert frc.getMinimum() == 10; // TODO change when JBNADM-1597 is being worked on
- assert frc.getMaximum() == 5;
-
- } else {
- assert true == false : "Unknown constraint type encountered";
- }
+ assert found == optionVals.length;
+ Set<Constraint> constraints = pds.getConstraints();
+ assert constraints.size() == 2;
+ for (Constraint constraint : constraints) {
+ if (constraint instanceof IntegerRangeConstraint) {
+ IntegerRangeConstraint irc = (IntegerRangeConstraint) constraint;
+ assert irc != null : "Integer-constraint was null, but should not be";
+ // See JBNADM-1596/97
+ assert irc.getDetails().equals("-2#10");
+ // TODO (ips, 3/31/10): The below is a workaround for IntegerRangeConstraint.onLoad() not being called by Hibernate.
+ irc.setDetails(irc.getDetails());
+ assert irc.getMaximum() == 10;
+ assert irc.getMinimum() == -2;
+ } else if (constraint instanceof FloatRangeConstraint) {
+ FloatRangeConstraint frc = (FloatRangeConstraint) constraint;
+ assert frc != null : "Float-constraint was null, but should not be";
+ // See JBNADM-1596/97
+ assert frc.getDetails().equals("10.0#5.0");
+ // TODO (ips, 3/31/10): The below is a workaround for FloatRangeConstraint.onLoad() not being called by Hibernate.
+ frc.setDetails(frc.getDetails());
+ assert frc.getMinimum() == 10; // TODO change when JBNADM-1597 is being worked on
+ assert frc.getMaximum() == 5;
+
+ } else {
+ assert true == false : "Unknown constraint type encountered";
}
- } else {
- assert true == false : "Unknown list-definition in v2: " + pdl.getName();
}
- getTransactionManager().rollback();
+ } else {
+ assert true == false : "Unknown list-definition in v2: " + pdl.getName();
}
-
- // done with v2
}
+ getTransactionManager().rollback();
+
} finally {
if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
getTransactionManager().rollback();
@@ -771,7 +760,7 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
try {
cleanupTest();
} catch (Exception e) {
- System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testListProperty");
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testListOfLists");
}
}
}
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 cb3f029..6b5c627 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
@@ -125,6 +125,7 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
ResourceTypeCriteria resourceTypeCriteria = new ResourceTypeCriteria();
+ resourceTypeCriteria.setStrict(true);
resourceTypeCriteria.addFilterName(typeName);
resourceTypeCriteria.addFilterPluginName(pluginName);
@@ -274,7 +275,7 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
cleanupResourceType("myPlatform3");
cleanupResourceType("myPlatform4");
cleanupResourceType("myPlatform5");
- //cleanupResourceType("myPlatform6");
+ cleanupResourceType("myPlatform6");
cleanupResourceType("myPlatform7");
cleanupResourceType("ops");
cleanupResourceType("testApp1");
@@ -323,6 +324,7 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
// delete any resources first
ResourceCriteria c = new ResourceCriteria();
+ c.setStrict(true);
c.addFilterResourceTypeId(rt.getId());
c.addFilterInventoryStatus(InventoryStatus.NEW);
List<Resource> doomedResources = resourceManager.findResourcesByCriteria(overlord, c);
14 years, 1 month
[rhq] 4 commits - modules/core modules/enterprise
by Jay Shaughnessy
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionEnumeration.java | 16
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java | 20
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java | 54 +
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java | 321 ++++------
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateSubsytemTestBase.java | 4
5 files changed, 222 insertions(+), 193 deletions(-)
New commits:
commit e782aced9325fee8159672fb037eb96c3da74050
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 11:09:57 2010 -0400
Additional check for proper prop def merging
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
index 238c3c6..e4c608c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
@@ -445,13 +445,20 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
* @param newProperty the new prop that should replace the existing prop
*/
private void replaceListPropertyMemberDefinition(PropertyDefinitionList exList, PropertyDefinitionList newList) {
- PropertyDefinition doomedMember = exList.getMemberDefinition();
+ PropertyDefinition doomedMember = null;
+
+ // only remove the existing member if it is a different entity
+ if (exList.getMemberDefinition().getId() != newList.getMemberDefinition().getId()) {
+ doomedMember = exList.getMemberDefinition();
+ }
exList.setMemberDefinition(newList.getMemberDefinition());
exList.setMax(newList.getMax());
exList.setMin(newList.getMin());
- entityManager.remove(doomedMember);
+ if (null != doomedMember) {
+ entityManager.remove(doomedMember);
+ }
entityManager.merge(exList);
entityManager.flush();
}
commit 36b1e605cad08f003af34fb8d51733142637534e
Merge: 229a6c4... cc8f2db...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 10:34:00 2010 -0400
Merge branch 'master' into master-jay
commit 229a6c47e809481ea9011698dc46a58ca574875f
Merge: d3fa4b8... d3cc735...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 09:45:34 2010 -0400
Merge branch 'master' into master-jay
commit d3fa4b8aceb726dc8eda7c6164e4693cb415512c
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 27 09:43:59 2010 -0400
Test failure showed some bad behavior with respect to the handling
of PropDefEnumerations, their cleanup and their order indexing. To
resolve I've basically moved ordering logic from the PDE to the
PropDefSimple, which uses the enumerated values. In more detail:
- remove the PrePersist/PreUpdate orderIndex setting from PDE. this
didn't always work, and was the source of the test failure, it relied
on the encompassing PDS being fully formed, which it may not be.
- Add logic to PDS to assign sane orderIndexes at the time the enumerations
are set/added/removed.
- update the config metadata update logic analogously, and improve
cleanup of obsolete config defs.
- updated and reenabled the previously failing tests
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionEnumeration.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionEnumeration.java
index 3781d13..fbcabb4 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionEnumeration.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionEnumeration.java
@@ -31,8 +31,6 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
-import javax.persistence.PrePersist;
-import javax.persistence.PreUpdate;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
@@ -63,7 +61,7 @@ public class PropertyDefinitionEnumeration implements Serializable {
private String value;
@Column(name = "ORDER_INDEX", nullable = false)
- private int orderIndex;
+ private int orderIndex = -1;
@Column(name = "IS_DEFAULT")
private boolean isDefault;
@@ -87,11 +85,13 @@ public class PropertyDefinitionEnumeration implements Serializable {
this.isDefault = isDefault;
}
- @PrePersist
- @PreUpdate
- public void updateOrder() {
- this.orderIndex = this.propertyDefinitionSimple.getEnumeratedValues().indexOf(this);
- }
+ // @PrePersist
+ // @PreUpdate
+ // public void updateOrder() {
+ // if (this.orderIndex < 0) {
+ // this.orderIndex = this.propertyDefinitionSimple.getEnumeratedValues().indexOf(this);
+ // }
+ // }
public PropertyDefinitionSimple getPropertyDefinitionSimple() {
return propertyDefinitionSimple;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
index 3a7be2c..a27b677 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
@@ -157,12 +157,30 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
public void setEnumeratedValues(List<PropertyDefinitionEnumeration> enumeratedValues, boolean allowCustomEnumValue) {
this.enumeratedValues = enumeratedValues;
this.allowCustomEnumeratedValue = allowCustomEnumValue;
+ ensureOrdering();
}
public void addEnumeratedValues(PropertyDefinitionEnumeration... enumerations) {
for (PropertyDefinitionEnumeration enumeration : enumerations) {
- getEnumeratedValues().add(enumeration);
enumeration.setPropertyDefinitionSimple(this);
+ getEnumeratedValues().add(enumeration);
+ }
+ ensureOrdering();
+ }
+
+ public void removeEnumeratedValues(PropertyDefinitionEnumeration... enumerations) {
+ for (PropertyDefinitionEnumeration enumeration : enumerations) {
+ getEnumeratedValues().remove(enumeration);
+ }
+ ensureOrdering();
+ }
+
+ private void ensureOrdering() {
+ if (null == this.enumeratedValues) {
+ return;
+ }
+ for (int i = 0, size = getEnumeratedValues().size(); (i < size); ++i) {
+ getEnumeratedValues().get(i).setOrderIndex(i);
}
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
index 4abf76f..238c3c6 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
@@ -30,6 +30,7 @@ import javax.persistence.PersistenceContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -274,8 +275,7 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
* @param existingProperties list of existing properties to inspect for potential removal
*/
private void removeNoLongerUsedProperties(ConfigurationDefinition newConfigDef,
- ConfigurationDefinition existingConfigDef,
- List<PropertyDefinition> existingProperties) {
+ ConfigurationDefinition existingConfigDef, List<PropertyDefinition> existingProperties) {
List<PropertyDefinition> propDefsToDelete = new ArrayList<PropertyDefinition>();
for (PropertyDefinition existingPropDef : existingProperties) {
PropertyDefinition newPropDef = newConfigDef.get(existingPropDef.getName());
@@ -350,14 +350,8 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
PropertyDefinitionList exList = (PropertyDefinitionList) existingProperty;
if (newProperty instanceof PropertyDefinitionList) {
PropertyDefinitionList newList = (PropertyDefinitionList) newProperty;
- exList.setMemberDefinition(newList.getMemberDefinition());
- exList.setMax(newList.getMax());
- exList.setMin(newList.getMax());
- // what about parentPropertyListDefinition ?
-
- // TODO recursively update the member ?
- } else // simple property or map-property
- {
+ replaceListPropertyMemberDefinition(exList, newList);
+ } else { // simple property or map-property
replaceProperty(existingProperty, newProperty);
}
} else if (existingProperty instanceof PropertyDefinitionSimple) {
@@ -374,12 +368,11 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
List<PropertyDefinitionEnumeration> toDelete = missingInFirstList(newOptions, existingOptions);
List<PropertyDefinitionEnumeration> changed = intersection(existingOptions, newOptions);
- // TODO GH: This still doesn't properly reorder options, but at least it doesn't leave any nulls
- // and therefore doesn't blow up the renderer
- // delete old ones (first so we don't leave index holes later)
+ // sync the enumerated values and then merge the changes into the PDS, I think this
+ // solves previous issues with orderIndex values.
+ // First remove obsolete values
for (PropertyDefinitionEnumeration pde : toDelete) {
- existingOptions.remove(pde);
- entityManager.remove(pde);
+ existingPDS.removeEnumeratedValues(pde);
}
// save new ones
@@ -388,16 +381,16 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
entityManager.persist(pde);
}
+ // update others
for (PropertyDefinitionEnumeration pde : changed) {
for (PropertyDefinitionEnumeration nPde : newOptions) {
if (nPde.equals(pde)) {
pde.setDefault(nPde.isDefault());
- pde.setOrderIndex(nPde.getOrderIndex());
pde.setValue(nPde.getValue());
- entityManager.merge(pde);
}
}
}
+ entityManager.merge(existingPDS);
// handle <constraint> [0..*]
@@ -444,6 +437,26 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
}
/**
+ * This replaces the member property for the list. If it is a nested structure the whole thing
+ * is replaced from the top. The previous member property is removed. cascading should remove a nested
+ * structure.
+ *
+ * @param existingProperty the existing prop
+ * @param newProperty the new prop that should replace the existing prop
+ */
+ private void replaceListPropertyMemberDefinition(PropertyDefinitionList exList, PropertyDefinitionList newList) {
+ PropertyDefinition doomedMember = exList.getMemberDefinition();
+
+ exList.setMemberDefinition(newList.getMemberDefinition());
+ exList.setMax(newList.getMax());
+ exList.setMin(newList.getMin());
+
+ entityManager.remove(doomedMember);
+ entityManager.merge(exList);
+ entityManager.flush();
+ }
+
+ /**
* Return a list containing those element that are in reference, but not in first. Both input lists are not modified
*
* @param first
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java
index 0dc958a..4a07bb7 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/resource/metadata/test/UpdateConfigurationSubsystemTest.java
@@ -581,187 +581,176 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
}
}
- // TODO (jshaughn) For some reason this test is creating a ConfigDef that Hibernate chokes on. Need
- // to come back and figure out why. Perhaps it's oracle specific... Also, if activated update
- // cleanup routine in TestBase to delete myPlatform6.
- @Test(enabled = false)
- public void testListProperty() throws Exception {
- // Note, plugins are registered in new transactions. for tests, this means
- // you can't do everything in a trans and roll back at the end. You must clean up
- // manually.
+ @Test(enabled = ENABLED)
+ public void testListOfLists() throws Exception {
try {
- { // extra block for variable scoping purposes
- registerPlugin("propertyList-v1.xml");
- ResourceType platform = getResourceType("myPlatform6");
- getTransactionManager().begin();
- EntityManager em = getEntityManager();
- platform = em.find(ResourceType.class, platform.getId());
-
- ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
- Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
- assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v1, but got " + propDefs.size();
- for (PropertyDefinition def : propDefs.values()) {
- assert def instanceof PropertyDefinitionList : "PropertyDefinition " + def.getName()
- + " is no list-property in v1";
- PropertyDefinitionList pdl = (PropertyDefinitionList) def;
- PropertyDefinition member = pdl.getMemberDefinition();
-
- if (pdl.getName().equals("myList1")) {
- assert pdl.getDescription().equals("Just a simple list");
- assert member instanceof PropertyDefinitionSimple : "Expected the member of myList1 to be a simple property in v1";
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
- assert pds.getName().equals("foo");
- } else if (pdl.getName().equals("myList2")) {
- assert member instanceof PropertyDefinitionList : "Expected the member of myList2 to be a list property in v1";
- } else if (pdl.getName().equals("myList3")) {
- assert member instanceof PropertyDefinitionSimple : "Expected the member of myList3 to be a simple property in v1";
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
- assert pds.getName().equals("baz");
- } else if (pdl.getName().equals("rec1")) {
- assert member instanceof PropertyDefinitionList : "Expected the member of rc1 to be a list property in v1";
- PropertyDefinitionList pdl2 = (PropertyDefinitionList) member;
-
- // TODO check min/max for the lists on the way. Commented out. See JBNADM-1595
- assert pdl2.getName().equals("rec2");
-
- // assert pdl2.getMin()==2 : "Expected rec2:min to be 2, but it was " + pdl2.getMin();
- // assert pdl2.getMax()==20;
- pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
- assert pdl2.getName().equals("rec3");
-
- // assert pdl2.getMin()==3;
- // assert pdl2.getMax()==30;
- pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
- assert pdl2.getName().equals("rec4");
-
- // assert pdl2.getMin()==4;
- // assert pdl2.getMax()==40;
- assert pdl2.getMemberDefinition() instanceof PropertyDefinitionSimple;
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pdl2.getMemberDefinition();
- assert pds.getName().equals("rec5");
- assert pds.getDescription().equals("Deeply nested");
- List<PropertyDefinitionEnumeration> options = pds.getEnumeratedValues();
- assert options.size() == 4;
- int found = 0;
- String[] optionVals = new String[] { "a", "b", "c", "d" };
- for (PropertyDefinitionEnumeration option : options) {
- if (containedIn(option.getValue(), optionVals)) {
- found++;
- }
+ // extra block for variable scoping purposes
+ registerPlugin("propertyList-v1.xml");
+ ResourceType platform = getResourceType("myPlatform6");
+ getTransactionManager().begin();
+ EntityManager em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
+ ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
+ Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
+ assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v1, but got " + propDefs.size();
+ for (PropertyDefinition def : propDefs.values()) {
+ assert def instanceof PropertyDefinitionList : "PropertyDefinition " + def.getName()
+ + " is no list-property in v1";
+ PropertyDefinitionList pdl = (PropertyDefinitionList) def;
+ PropertyDefinition member = pdl.getMemberDefinition();
+
+ if (pdl.getName().equals("myList1")) {
+ assert pdl.getDescription().equals("Just a simple list");
+ assert member instanceof PropertyDefinitionSimple : "Expected the member of myList1 to be a simple property in v1";
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
+ assert pds.getName().equals("foo");
+ } else if (pdl.getName().equals("myList2")) {
+ assert member instanceof PropertyDefinitionList : "Expected the member of myList2 to be a list property in v1";
+ } else if (pdl.getName().equals("myList3")) {
+ assert member instanceof PropertyDefinitionSimple : "Expected the member of myList3 to be a simple property in v1";
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
+ assert pds.getName().equals("baz");
+ } else if (pdl.getName().equals("rec1")) {
+ assert member instanceof PropertyDefinitionList : "Expected the member of rc1 to be a list property in v1";
+ PropertyDefinitionList pdl2 = (PropertyDefinitionList) member;
+
+ // TODO check min/max for the lists on the way. Commented out. See JBNADM-1595
+ assert pdl2.getName().equals("rec2");
+
+ // assert pdl2.getMin()==2 : "Expected rec2:min to be 2, but it was " + pdl2.getMin();
+ // assert pdl2.getMax()==20;
+ pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
+ assert pdl2.getName().equals("rec3");
+
+ // assert pdl2.getMin()==3;
+ // assert pdl2.getMax()==30;
+ pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
+ assert pdl2.getName().equals("rec4");
+
+ // assert pdl2.getMin()==4;
+ // assert pdl2.getMax()==40;
+ assert pdl2.getMemberDefinition() instanceof PropertyDefinitionSimple;
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pdl2.getMemberDefinition();
+ assert pds.getName().equals("rec5");
+ assert pds.getDescription().equals("Deeply nested");
+ List<PropertyDefinitionEnumeration> options = pds.getEnumeratedValues();
+ assert options.size() == 4;
+ int found = 0;
+ String[] optionVals = new String[] { "a", "b", "c", "d" };
+ for (PropertyDefinitionEnumeration option : options) {
+ if (containedIn(option.getValue(), optionVals)) {
+ found++;
}
-
- assert found == 4;
- Set<Constraint> constraints = pds.getConstraints();
- assert constraints.size() == 1;
- } else {
- assert true == false : "Unknown list-definition in v1: " + pdl.getName();
}
+
+ assert found == 4;
+ Set<Constraint> constraints = pds.getConstraints();
+ assert constraints.size() == 1;
+ } else {
+ assert true == false : "Unknown list-definition in v1: " + pdl.getName();
}
- getTransactionManager().rollback();
}
+ getTransactionManager().rollback();
/*
* Deploy v2 of the plugin
*/
- { // extra block for variable scoping purposes
- registerPlugin("propertyList-v2.xml");
- ResourceType platform = getResourceType("myPlatform6");
- getTransactionManager().begin();
- EntityManager em = getEntityManager();
- platform = em.find(ResourceType.class, platform.getId());
-
- ConfigurationDefinition cd = platform.getResourceConfigurationDefinition();
- Map<String, PropertyDefinition> propDefs = cd.getPropertyDefinitions();
- assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v2, but got " + propDefs.size();
- for (PropertyDefinition def : propDefs.values()) {
- assert def instanceof PropertyDefinitionList : "PropertyDefinition " + def.getName()
- + " is no list-property in v2";
- PropertyDefinitionList pdl = (PropertyDefinitionList) def;
- PropertyDefinition member = pdl.getMemberDefinition();
-
- if (pdl.getName().equals("myList2")) {
- assert member instanceof PropertyDefinitionList : "Expected the member of myList2 to be a list property in v2";
- } else if (pdl.getName().equals("myList3")) {
- assert member instanceof PropertyDefinitionList : "Expected the member of myList3 to be a list property in v2";
- PropertyDefinitionList pds = (PropertyDefinitionList) member;
- assert pds.getName().equals("baz");
- assert pds.getDescription().equals("myList3:baz");
- assert pds.getMemberDefinition() instanceof PropertyDefinitionSimple : "Expected the member of list3:baz to be a simple property in v2";
- } else if (pdl.getName().equals("myList4")) {
- assert pdl.getDescription().equals("Just a simple list");
- assert member instanceof PropertyDefinitionSimple : "Expected the member of myList4 to be a simple property in v2";
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
- assert pds.getName().equals("foo");
- } else if (pdl.getName().equals("rec1")) {
- assert member instanceof PropertyDefinitionList : "Expected the member of rec1 to be a list property in v2";
- PropertyDefinitionList pdl2 = (PropertyDefinitionList) member;
- assert pdl2.getName().equals("rec2");
-
- /*
- * PropertyDefinitionList.getMin()/getMax() are commented out. See JBNADM1595
- */
+ registerPlugin("propertyList-v2.xml");
+ platform = getResourceType("myPlatform6");
+ getTransactionManager().begin();
+ em = getEntityManager();
+ platform = em.find(ResourceType.class, platform.getId());
- // assert pdl2.getMin()==12 : "Expected rec2:min to be 12, but it was " + pdl2.getMin();
- // assert pdl2.getMax()==200;
- pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
- assert pdl2.getName().equals("rec3+");
-
- // assert pdl2.getMin()==13;
- // assert pdl2.getMax()==300;
- pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
- assert pdl2.getName().equals("rec4");
-
- // assert pdl2.getMin()==14;
- // assert pdl2.getMax()==400;
- assert pdl2.getMemberDefinition() instanceof PropertyDefinitionSimple;
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pdl2.getMemberDefinition();
- assert pds.getName().equals("rec5");
- assert pds.getDescription().equals("Nested deeply");
- List<PropertyDefinitionEnumeration> options = pds.getEnumeratedValues();
- assert options.size() == 5;
- int found = 0;
- String[] optionVals = new String[] { "b", "c", "d", "x", "z" };
- for (PropertyDefinitionEnumeration option : options) {
- if (containedIn(option.getValue(), optionVals)) {
- found++;
- }
+ cd = platform.getResourceConfigurationDefinition();
+ propDefs = cd.getPropertyDefinitions();
+ assert propDefs.size() == 4 : "Expected to see 4 <list-property>s in v2, but got " + propDefs.size();
+ for (PropertyDefinition def : propDefs.values()) {
+ assert def instanceof PropertyDefinitionList : "PropertyDefinition " + def.getName()
+ + " is no list-property in v2";
+ PropertyDefinitionList pdl = (PropertyDefinitionList) def;
+ PropertyDefinition member = pdl.getMemberDefinition();
+
+ if (pdl.getName().equals("myList2")) {
+ assert member instanceof PropertyDefinitionList : "Expected the member of myList2 to be a list property in v2";
+ } else if (pdl.getName().equals("myList3")) {
+ assert member instanceof PropertyDefinitionList : "Expected the member of myList3 to be a list property in v2";
+ PropertyDefinitionList pds = (PropertyDefinitionList) member;
+ assert pds.getName().equals("baz");
+ assert pds.getDescription().equals("myList3:baz");
+ assert pds.getMemberDefinition() instanceof PropertyDefinitionSimple : "Expected the member of list3:baz to be a simple property in v2";
+ } else if (pdl.getName().equals("myList4")) {
+ assert pdl.getDescription().equals("Just a simple list");
+ assert member instanceof PropertyDefinitionSimple : "Expected the member of myList4 to be a simple property in v2";
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) member;
+ assert pds.getName().equals("foo");
+ } else if (pdl.getName().equals("rec1")) {
+ assert member instanceof PropertyDefinitionList : "Expected the member of rec1 to be a list property in v2";
+ PropertyDefinitionList pdl2 = (PropertyDefinitionList) member;
+ assert pdl2.getName().equals("rec2");
+
+ /*
+ * PropertyDefinitionList.getMin()/getMax() are commented out. See JBNADM1595
+ */
+
+ // assert pdl2.getMin()==12 : "Expected rec2:min to be 12, but it was " + pdl2.getMin();
+ // assert pdl2.getMax()==200;
+ pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
+ assert pdl2.getName().equals("rec3+");
+
+ // assert pdl2.getMin()==13;
+ // assert pdl2.getMax()==300;
+ pdl2 = (PropertyDefinitionList) pdl2.getMemberDefinition();
+ assert pdl2.getName().equals("rec4");
+
+ // assert pdl2.getMin()==14;
+ // assert pdl2.getMax()==400;
+ assert pdl2.getMemberDefinition() instanceof PropertyDefinitionSimple;
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) pdl2.getMemberDefinition();
+ assert pds.getName().equals("rec5");
+ assert pds.getDescription().equals("Nested deeply");
+ List<PropertyDefinitionEnumeration> options = pds.getEnumeratedValues();
+ assert options.size() == 5;
+ int found = 0;
+ String[] optionVals = new String[] { "b", "c", "d", "x", "z" };
+ for (PropertyDefinitionEnumeration option : options) {
+ if (containedIn(option.getValue(), optionVals)) {
+ found++;
}
+ }
- assert found == optionVals.length;
- Set<Constraint> constraints = pds.getConstraints();
- assert constraints.size() == 2;
- for (Constraint constraint : constraints) {
- if (constraint instanceof IntegerRangeConstraint) {
- IntegerRangeConstraint irc = (IntegerRangeConstraint) constraint;
- assert irc != null : "Integer-constraint was null, but should not be";
- // See JBNADM-1596/97
- assert irc.getDetails().equals("-2#10");
- // TODO (ips, 3/31/10): The below is a workaround for IntegerRangeConstraint.onLoad() not being called by Hibernate.
- irc.setDetails(irc.getDetails());
- assert irc.getMaximum() == 10;
- assert irc.getMinimum() == -2;
- } else if (constraint instanceof FloatRangeConstraint) {
- FloatRangeConstraint frc = (FloatRangeConstraint) constraint;
- assert frc != null : "Float-constraint was null, but should not be";
- // See JBNADM-1596/97
- assert frc.getDetails().equals("10.0#5.0");
- // TODO (ips, 3/31/10): The below is a workaround for FloatRangeConstraint.onLoad() not being called by Hibernate.
- frc.setDetails(frc.getDetails());
- assert frc.getMinimum() == 10; // TODO change when JBNADM-1597 is being worked on
- assert frc.getMaximum() == 5;
-
- } else {
- assert true == false : "Unknown constraint type encountered";
- }
+ assert found == optionVals.length;
+ Set<Constraint> constraints = pds.getConstraints();
+ assert constraints.size() == 2;
+ for (Constraint constraint : constraints) {
+ if (constraint instanceof IntegerRangeConstraint) {
+ IntegerRangeConstraint irc = (IntegerRangeConstraint) constraint;
+ assert irc != null : "Integer-constraint was null, but should not be";
+ // See JBNADM-1596/97
+ assert irc.getDetails().equals("-2#10");
+ // TODO (ips, 3/31/10): The below is a workaround for IntegerRangeConstraint.onLoad() not being called by Hibernate.
+ irc.setDetails(irc.getDetails());
+ assert irc.getMaximum() == 10;
+ assert irc.getMinimum() == -2;
+ } else if (constraint instanceof FloatRangeConstraint) {
+ FloatRangeConstraint frc = (FloatRangeConstraint) constraint;
+ assert frc != null : "Float-constraint was null, but should not be";
+ // See JBNADM-1596/97
+ assert frc.getDetails().equals("10.0#5.0");
+ // TODO (ips, 3/31/10): The below is a workaround for FloatRangeConstraint.onLoad() not being called by Hibernate.
+ frc.setDetails(frc.getDetails());
+ assert frc.getMinimum() == 10; // TODO change when JBNADM-1597 is being worked on
+ assert frc.getMaximum() == 5;
+
+ } else {
+ assert true == false : "Unknown constraint type encountered";
}
- } else {
- assert true == false : "Unknown list-definition in v2: " + pdl.getName();
}
- getTransactionManager().rollback();
+ } else {
+ assert true == false : "Unknown list-definition in v2: " + pdl.getName();
}
-
- // done with v2
}
+ getTransactionManager().rollback();
+
} finally {
if (Status.STATUS_NO_TRANSACTION != getTransactionManager().getStatus()) {
getTransactionManager().rollback();
@@ -771,7 +760,7 @@ public class UpdateConfigurationSubsystemTest extends UpdateSubsytemTestBase {
try {
cleanupTest();
} catch (Exception e) {
- System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testListProperty");
+ System.out.println("CANNNOT CLEAN UP TEST: " + this.getClass().getSimpleName() + ".testListOfLists");
}
}
}
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 cb3f029..6b5c627 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
@@ -125,6 +125,7 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
ResourceTypeCriteria resourceTypeCriteria = new ResourceTypeCriteria();
+ resourceTypeCriteria.setStrict(true);
resourceTypeCriteria.addFilterName(typeName);
resourceTypeCriteria.addFilterPluginName(pluginName);
@@ -274,7 +275,7 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
cleanupResourceType("myPlatform3");
cleanupResourceType("myPlatform4");
cleanupResourceType("myPlatform5");
- //cleanupResourceType("myPlatform6");
+ cleanupResourceType("myPlatform6");
cleanupResourceType("myPlatform7");
cleanupResourceType("ops");
cleanupResourceType("testApp1");
@@ -323,6 +324,7 @@ public class UpdateSubsytemTestBase extends AbstractEJB3Test {
// delete any resources first
ResourceCriteria c = new ResourceCriteria();
+ c.setStrict(true);
c.addFilterResourceTypeId(rt.getId());
c.addFilterInventoryStatus(InventoryStatus.NEW);
List<Resource> doomedResources = resourceManager.findResourcesByCriteria(overlord, c);
14 years, 1 month
[rhq] Branch 'gwt' - 9 commits - modules/core modules/enterprise
by ips
modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java | 29 +-
modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml | 1
modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml | 8
modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml | 1
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 1
modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java | 52 +---
modules/core/domain/src/main/java/org/rhq/core/domain/plugin/AbstractPlugin.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java | 39 ++-
modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSubsystem.java | 14 +
modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSuggestion.java | 94 ++++++++
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationStoreUIBean.java | 72 ------
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationsUIBean.java | 26 --
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/UserPreferencesUIBean.java | 62 +++--
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseResourcesUIBean.java | 48 ++--
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/hub/ResourceHubPortalAction.java | 40 +--
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java | 11
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml | 24 --
modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml | 15 +
modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml | 34 ++
modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g | 1
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java | 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java | 98 ++++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/AbstractSearchAssistant.java | 12 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/ResourceSearchAssistant.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/SearchAssistant.java | 10
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java | 115 +++++++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchSuggestion.java | 52 ----
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchTranslationManager.java | 26 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/translation/SearchTranslatorFactory.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java | 2
modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt | 10
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java | 5
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java | 8
36 files changed, 573 insertions(+), 360 deletions(-)
New commits:
commit 91e1f5b3d76a7cbe48ecf46992ec74fbdd2ff5a1
Merge: 5250a8a... d362688...
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Tue Apr 27 11:01:40 2010 -0400
Merge branch 'master' into gwt
commit d36268863a5e64e6a14de4d89c129f2ed0e89a2e
Merge: 5f9cbe0... cc8f2db...
Author: Ian P. Springer <ips(a)jetengine.(none)>
Date: Tue Apr 27 09:52:39 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit cc8f2db67869ec32176c5160bc2adb195fdbb678
Author: Joseph Marques <joseph(a)redhat.com>
Date: Tue Apr 27 09:46:42 2010 -0400
small fix to dbsetup script data
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
index da98622..380ef0f 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-data.xml
@@ -5,18 +5,18 @@
<!-- overlord-created, global, default saved searches -->
<table name="RHQ_SAVED_SEARCH">
<data ID="1"
- CONTEXT="Resource"
+ CONTEXT="RESOURCE"
NAME="Downed Platforms"
DESCRIPTION="All downed machines across the entire enterprise"
- PATTERN="down platform"
+ PATTERN="availability=down category=platform"
LAST_COMPUTE_TIME="0"
SUBJECT_ID="1"
GLOBAL="TRUE" />
<data ID="2"
- CONTEXT="Resource"
+ CONTEXT="RESOURCE"
NAME="Downed Servers"
DESCRIPTION="All downed servers across the entire enterprise"
- PATTERN="down server"
+ PATTERN="availability=down category=server"
LAST_COMPUTE_TIME="0"
SUBJECT_ID="1"
GLOBAL="TRUE" />
commit d2ce45f0122e499162151ef8e927d9d5086dc5ed
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Apr 26 17:32:52 2010 -0400
remove name field from alert notifications
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
index 0fa4ee8..07c7590 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/upgrade/CustomAlertSenderUpgradeTask.java
@@ -75,9 +75,8 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
String propertyName = "subjectId";
String senderName = "System Users";
- String name = "User Notifications";
- persist(data, propertyName, senderName, name);
+ persist(data, propertyName, senderName);
}
private void upgradeRoleNotifications() throws SQLException {
@@ -91,9 +90,8 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
String propertyName = "roleId";
String senderName = "System Roles";
- String name = "Role Notifications";
- persist(data, propertyName, senderName, name);
+ persist(data, propertyName, senderName);
}
private void upgradeEmailNotifications() throws SQLException {
@@ -107,9 +105,8 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
String propertyName = "emailAddress";
String senderName = "Direct Emails";
- String name = "Email Notifications";
- persist(data, propertyName, senderName, name);
+ persist(data, propertyName, senderName);
}
private void upgradeSNMPNotifications() throws SQLException {
@@ -129,7 +126,7 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
// buffer will be 0 the very first time, since definitionId is initially -1
int configId = persistConfiguration("host", host, "port", port, "oid", oid);
- persistNotification(alertDefinitionId, configId, "SNMP Traps", "SNMP Notifications");
+ persistNotification(alertDefinitionId, configId, "SNMP Traps");
}
}
@@ -147,11 +144,11 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
// buffer will be 0 the very first time, since definitionId is initially -1
int configId = persistConfiguration("operation-definition-id", operationDefinitionId, "selection-mode",
"SELF");
- persistNotification(alertDefinitionId, configId, "Resource Operations", "Operation Invocation");
+ persistNotification(alertDefinitionId, configId, "Resource Operations");
}
}
- private void persist(List<Object[]> data, String propertyName, String sender, String name) throws SQLException {
+ private void persist(List<Object[]> data, String propertyName, String sender) throws SQLException {
int definitionId = -1;
StringBuilder buffer = new StringBuilder();
for (Object[] next : data) {
@@ -162,7 +159,7 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
if (buffer.length() != 0) {
// buffer will be 0 the very first time, since definitionId is initially -1
int configId = persistConfiguration(propertyName, buffer.toString());
- persistNotification(definitionId, configId, sender, name);
+ persistNotification(definitionId, configId, sender);
}
buffer = new StringBuilder(); // reset for the next definitionId
}
@@ -176,7 +173,7 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
if (buffer.length() != 0) {
int configId = persistConfiguration(propertyName, buffer.toString());
- persistNotification(definitionId, configId, sender, name);
+ persistNotification(definitionId, configId, sender);
}
}
@@ -197,9 +194,9 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
return configId;
}
- private void persistNotification(int definitionId, int configId, String sender, String name) throws SQLException {
+ private void persistNotification(int definitionId, int configId, String sender) throws SQLException {
int notificationId = databaseType.getNextSequenceValue(connection, "rhq_alert_notification", "id");
- String insertNotificationSQL = getInsertNotificationSQL(notificationId, definitionId, configId, sender, name);
+ String insertNotificationSQL = getInsertNotificationSQL(notificationId, definitionId, configId, sender);
databaseType.executeSql(connection, insertNotificationSQL);
}
@@ -214,9 +211,9 @@ public class CustomAlertSenderUpgradeTask implements DatabaseUpgradeTask {
+ " VALUES ( " + id + ", " + configId + ", '" + name + "', '" + value + "', 'property' ) ";
}
- private String getInsertNotificationSQL(int id, int definitionId, int configId, String sender, String name) {
- return "INSERT INTO rhq_alert_notification ( id, alert_definition_id, sender_config_id, sender_name, display_name )" //
- + " VALUES ( " + id + ", " + definitionId + ", " + configId + ", '" + sender + "', '" + name + "' ) ";
+ private String getInsertNotificationSQL(int id, int definitionId, int configId, String sender) {
+ return "INSERT INTO rhq_alert_notification ( id, alert_definition_id, sender_config_id, sender_name )" //
+ + " VALUES ( " + id + ", " + definitionId + ", " + configId + ", '" + sender + "' ) ";
}
}
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
index 9617057..b2db5f0 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/alert-schema.xml
@@ -137,7 +137,6 @@
<column name="TEMPLATE_ID" required="false" type="INTEGER" references="RHQ_ALERT_NOTIF_TEMPL(ID)"/>
<column name="SENDER_CONFIG_ID" required="false" type="INTEGER" references="RHQ_CONFIG(ID)"/>
<column name="SENDER_NAME" required="true" size="100" type="VARCHAR2" />
- <column name="DISPLAY_NAME" type="VARCHAR2" size="100" />
</table>
</dbsetup>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 6974780..d028a43 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2060,7 +2060,6 @@
<schema-addColumn table="RHQ_ALERT" column="ACK_TIME" columnType="LONG" />
<!-- TODO: this needs to change to ack_subject_name -->
<schema-addColumn table="RHQ_ALERT" column="ACK_SUBJECT" precision="100" columnType="VARCHAR2" />
- <schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="DISPLAY_NAME" precision="100" columnType="VARCHAR2" />
<schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_NAME" precision="100" columnType="VARCHAR2" />
<schema-addColumn table="RHQ_ALERT_NOTIFICATION" column="SENDER_CONFIG_ID" columnType="INTEGER" />
<schema-directSQL>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
index 1a7be46..b77d8b0 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
@@ -85,9 +85,6 @@ public class AlertNotification implements Serializable {
@Column(name = "SENDER_NAME")
private String senderName;
- @Column(name = "DISPLAY_NAME")
- private String displayName;
-
protected AlertNotification() {
} // JPA spec
@@ -115,7 +112,6 @@ public class AlertNotification implements Serializable {
} else {
this.configuration = source.configuration.deepCopy(false);
}
- this.displayName = source.displayName;
this.senderName = source.senderName;
}
@@ -129,8 +125,7 @@ public class AlertNotification implements Serializable {
this.alertNotificationId = alertNotificationId;
}
- public AlertNotification(String displayName, String sender) {
- this.displayName = displayName;
+ public AlertNotification(String sender) {
this.senderName = sender;
}
@@ -147,22 +142,6 @@ public class AlertNotification implements Serializable {
this.alertDefinition = alertDefinition;
}
- public AlertNotification copyWithAlertDefintion(AlertDefinition alertDefinition, boolean copyIds) {
- Configuration config;
- if (copyIds) {
- config = this.configuration;
- } else {
- config = this.configuration.deepCopy(false);
- }
- AlertNotification notification = new AlertNotification(alertDefinition, config);
- if (copyIds) {
- notification.id = this.id;
- }
- notification.setDisplayName(this.displayName);
- notification.setSenderName(this.senderName);
- return notification;
- }
-
public void prepareForOrphanDelete() {
this.alertDefinition = null;
}
@@ -183,14 +162,6 @@ public class AlertNotification implements Serializable {
this.configuration = configuration;
}
- public String getDisplayName() {
- return displayName;
- }
-
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
public AlertNotificationTemplate getAlertNotificationTemplate() {
return alertNotificationTemplate;
}
@@ -216,7 +187,6 @@ public class AlertNotification implements Serializable {
sb.append(", id=").append(id);
sb.append(", notificationTemplate=").append(alertNotificationTemplate);
sb.append(", senderName='").append(senderName).append('\'');
- sb.append(", displayName='").append(displayName).append('\'');
sb.append('}');
return sb.toString();
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationStoreUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationStoreUIBean.java
deleted file mode 100644
index 05e254e..0000000
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationStoreUIBean.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.alert.common;
-
-import java.util.List;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.web.RequestParameter;
-
-import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-(a)Scope(ScopeType.EVENT)
-@Name("alertNotificationStoreUIBean")
-public class AlertNotificationStoreUIBean {
-
- @RequestParameter("context")
- private String context;
-
- @RequestParameter("contextId")
- private Integer contextId;
-
- private AlertNotificationManagerLocal alertNotificationManager = LookupUtil.getAlertNotificationManager();
-
- public List<AlertNotification> lookupNotifications(Subject subject) {
- if (context.equals("template")) {
- return this.alertNotificationManager.getNotificationsForTemplate(subject, contextId);
- } else {
- return this.alertNotificationManager.getNotificationsForAlertDefinition(subject, contextId);
- }
- }
-
- public AlertNotification addNotification(Subject subject, String senderType, String notificationName,
- Configuration configuration) {
- if (context.equals("template")) {
- return alertNotificationManager.addAlertNotificationToTemplate(subject, contextId, senderType,
- notificationName, configuration);
- } else {
- return this.alertNotificationManager.addAlertNotification(subject, contextId, senderType, notificationName,
- configuration);
- }
- }
-
- public void removeNotifications(Subject subject, Integer[] notificationIds) {
- if (context.equals("template")) {
- this.alertNotificationManager.removeNotificationsFromTemplate(subject, contextId, notificationIds);
- } else {
- this.alertNotificationManager.removeNotifications(subject, contextId, notificationIds);
- }
- }
-}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationsUIBean.java
index f696c3c..80cc829 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/common/AlertNotificationsUIBean.java
@@ -49,14 +49,16 @@ public class AlertNotificationsUIBean extends EnterpriseFacesContextUIBean {
@RequestParameter("nid")
private Integer notificationId;
+ @RequestParameter("context")
+ private String context;
+ @RequestParameter("contextId")
+ private Integer contextId;
+
@In
private AlertNotificationManagerLocal alertNotificationManager;
- @In(create = true)
- private AlertNotificationStoreUIBean alertNotificationStoreUIBean;
private List<AlertNotification> alertNotifications;
private Set<AlertNotification> selectedNotifications;
- private String newAlertName;
private String selectedNewSender;
private AlertNotification activeNotification;
private ConfigurationDefinition activeConfigDefinition;
@@ -79,14 +81,6 @@ public class AlertNotificationsUIBean extends EnterpriseFacesContextUIBean {
this.selectedNotifications = selectedNotifications;
}
- public String getNewAlertName() {
- return newAlertName;
- }
-
- public void setNewAlertName(String newAlertName) {
- this.newAlertName = newAlertName;
- }
-
public String getSelectedNewSender() {
return selectedNewSender;
}
@@ -136,7 +130,8 @@ public class AlertNotificationsUIBean extends EnterpriseFacesContextUIBean {
}
public void reloadAlertNotifications() {
- this.alertNotifications = this.alertNotificationStoreUIBean.lookupNotifications(getSubject());
+ this.alertNotifications = this.alertNotificationManager.getNotificationsForAlertDefinition(getSubject(),
+ contextId);
}
// Sets the initial state of the bean given the requrest parameters, this allows
@@ -175,8 +170,9 @@ public class AlertNotificationsUIBean extends EnterpriseFacesContextUIBean {
newSenderConfig = new Configuration();
}
- AlertNotification newlyCreated = this.alertNotificationStoreUIBean.addNotification(getSubject(),
- this.selectedNewSender, this.newAlertName, newSenderConfig);
+ AlertNotification newlyCreated = this.alertNotificationManager.addAlertNotification(getSubject(),
+ this.contextId, this.selectedNewSender, newSenderConfig);
+
this.alertNotifications.add(newlyCreated); // only add if no errors
this.activeNotification = newlyCreated;
this.selectedNotifications.clear();
@@ -194,7 +190,7 @@ public class AlertNotificationsUIBean extends EnterpriseFacesContextUIBean {
}
public String removeSelected() {
- this.alertNotificationStoreUIBean.removeNotifications(getSubject(), getSelectedIds());
+ this.alertNotificationManager.removeNotifications(getSubject(), contextId, getSelectedIds());
this.alertNotifications.removeAll(this.selectedNotifications); // only remove if no errors
this.activeNotification = null;
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
index fd83f96..74b978e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
@@ -52,19 +52,13 @@
fastOrderControlsVisible="false"
orderControlsVisible="false"
id="sendersList">
- <rich:column width="20%">
- <f:facet name="header">
- <h:outputText value="Name" />
- </f:facet>
- <h:outputText value="#{alertNotification.displayName}" />
- </rich:column>
- <rich:column width="20%">
+ <rich:column width="25%">
<f:facet name="header">
<h:outputText value="Type" />
</f:facet>
<h:outputText value="#{alertNotification.senderName}" />
</rich:column>
- <rich:column width="60%">
+ <rich:column width="75%">
<f:facet name="header">
<h:outputText value="Configuration" />
</f:facet>
@@ -170,20 +164,6 @@
<input type="hidden" name="contextSubId" value="#{param.contextSubId}"/>
<div style="height: 100px;">
- <h:outputLabel for="alertNameInput" value="Alert Notification Name:" />
- <br />
- <h:inputText id="alertNameInput"
- value="#{alertNotificationsUIBean.newAlertName}"
- maxlength="100"
- required="true" />
-
- <h:message for="alertNameInput"
- infoClass="InfoBlock"
- warnClass="WarnBlock"
- errorClass="ErrorBlock"
- fatalClass="FatalBlock" />
- <br /><br />
-
<h:outputLabel for="senderList" value="Alert Sender Type:" />
<br />
<h:selectOneMenu id="senderList" value="#{alertNotificationsUIBean.selectedNewSender}">
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
index 0e7682a..0897dc7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
@@ -296,7 +296,7 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
* {@inheritDoc}
*/
public AlertNotification addAlertNotification(Subject user, int alertDefinitionId, String senderName,
- String alertName, Configuration configuration) {
+ Configuration configuration) {
AlertDefinition definition = alertDefinitionManager.getAlertDefinition(user, alertDefinitionId);
if (definition == null) {
@@ -307,7 +307,6 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
entityManager.persist(configuration);
AlertNotification notif = new AlertNotification(definition);
notif.setSenderName(senderName);
- notif.setDisplayName(alertName);
notif.setConfiguration(configuration);
entityManager.persist(notif);
definition.getAlertNotifications().add(notif);
@@ -485,7 +484,7 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
AlertNotificationTemplate template = entityManager.find(AlertNotificationTemplate.class, templateId);
entityManager.persist(notificationConfiguration);
- AlertNotification alertNotification = new AlertNotification(notificationName, sender);
+ AlertNotification alertNotification = new AlertNotification(sender);
alertNotification.setConfiguration(notificationConfiguration);
alertNotification.setAlertNotificationTemplate(template);
entityManager.persist(alertNotification);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
index 56f1c20..9db80cc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerLocal.java
@@ -65,10 +65,9 @@ public interface AlertNotificationManagerLocal {
* @param user subject of the caller
* @param alertDefinitionId Id of the alert definition
* @param senderName shortName of the {@link AlertSender}
- * @param alertName name of the new {@link AlertNotification}
* @param configuration Properties for this alert sender.
*/
- AlertNotification addAlertNotification(Subject user, int alertDefinitionId, String senderName, String alertName,
+ AlertNotification addAlertNotification(Subject user, int alertDefinitionId, String senderName,
Configuration configuration);
/**
commit d3cc735b22ba4548e5eef68b1dae73bf51335649
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Apr 26 17:00:14 2010 -0400
BZ-562816: fix for stack trace when trying to edit general properties or conditions for an alert definition
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
index afa5671..5a3aeba 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
@@ -448,8 +448,7 @@ public class AlertDefinition implements Serializable {
Set<AlertNotification> copiedNotifications = new HashSet<AlertNotification>();
for (AlertNotification oldNotification : new HashSet<AlertNotification>(alertDef.getAlertNotifications())) {
- AlertNotification newNotification = oldNotification.copy(copyIds);
- newNotification.setAlertDefinition(this);
+ AlertNotification newNotification = new AlertNotification(oldNotification, copyIds);
copiedNotifications.add(newNotification);
}
this.removeAllAlertNotifications();
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
index 1f14aad..1a7be46 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/notification/AlertNotification.java
@@ -79,7 +79,7 @@ public class AlertNotification implements Serializable {
private AlertNotificationTemplate alertNotificationTemplate;
@JoinColumn(name = "SENDER_CONFIG_ID", referencedColumnName = "ID")
- @OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
+ @OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
private Configuration configuration;
@Column(name = "SENDER_NAME")
@@ -108,6 +108,17 @@ public class AlertNotification implements Serializable {
this.configuration = config.deepCopy();
}
+ public AlertNotification(AlertNotification source, boolean copyIds) {
+ if (copyIds) {
+ this.id = source.id;
+ this.configuration = source.configuration;
+ } else {
+ this.configuration = source.configuration.deepCopy(false);
+ }
+ this.displayName = source.displayName;
+ this.senderName = source.senderName;
+ }
+
/**
* Constructor only for transient usage
* @param alertDefinitionId
@@ -136,31 +147,22 @@ public class AlertNotification implements Serializable {
this.alertDefinition = alertDefinition;
}
- public AlertNotification copy(boolean copyIds) {
- AlertNotification results = copy();
- if (copyIds) {
- results.id = this.id;
- }
- return results;
- }
-
- public AlertNotification copyWithAlertDefintion(AlertDefinition alertDefinition, boolean cloneConfiguration) {
+ public AlertNotification copyWithAlertDefintion(AlertDefinition alertDefinition, boolean copyIds) {
Configuration config;
- if (cloneConfiguration) {
- config = this.configuration.deepCopy(false);
- } else {
+ if (copyIds) {
config = this.configuration;
+ } else {
+ config = this.configuration.deepCopy(false);
}
AlertNotification notification = new AlertNotification(alertDefinition, config);
+ if (copyIds) {
+ notification.id = this.id;
+ }
notification.setDisplayName(this.displayName);
notification.setSenderName(this.senderName);
return notification;
}
- protected AlertNotification copy() {
- return new AlertNotification(this.alertDefinition, this.configuration);
- }
-
public void prepareForOrphanDelete() {
this.alertDefinition = null;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
index 8a4bb98..0e7682a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java
@@ -393,7 +393,8 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc
def.getAlertNotifications().clear();
for (AlertNotification notif : template.getNotifications()) {
- AlertNotification notification = notif.copyWithAlertDefintion(def, true);
+ AlertNotification notification = new AlertNotification(notif, true);
+ notification.setAlertDefinition(notif.getAlertDefinition());
entityManager.persist(notification.getConfiguration());
entityManager.persist(notification);
def.addAlertNotification(notification); // Attach a copy, as the ones in the template should not be shared
commit deef32fd46d29fa6bf9145ac360c9b1d59b2826a
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Apr 26 16:28:38 2010 -0400
only print statistics for saved search result count recalculation if updates were non-zero
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
index a1e53b3..0e015e3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
@@ -80,7 +80,10 @@ public class SavedSearchResultCountRecalculationJob extends AbstractStatefulJob
+ next.getPattern() + "']");
}
}
- LOG.info("Statistics: updated " + updated + " in " + totalMillis + " ms (" + errors + " errors)");
+ if (updated > 0) {
+ // only print non-zero stats
+ LOG.info("Statistics: updated " + updated + " in " + totalMillis + " ms (" + errors + " errors)");
+ }
}
private List<SavedSearch> getSavedSearchesNeedingRecomputation() {
commit 9937c0a8336afcf18245fe8614ad3fe413d178bc
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Apr 26 15:52:28 2010 -0400
fix failure unit tests for saved searches subsystem
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java
index 2cb808c..97f44dd 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java
@@ -31,7 +31,7 @@ public class SearchAssistManager {
private static List<String> booleanOperators = Arrays.asList("and", "or", "|");
private Subject subject;
- private AbstractSearchAssistant completor;
+ private SearchSubsystem searchSubsystem;
/*
* states:
@@ -278,10 +278,11 @@ public class SearchAssistManager {
public SearchAssistManager(Subject subject, SearchSubsystem searchSubsystem) {
this.subject = subject;
- this.completor = getAutoCompletor(searchSubsystem);
+ this.searchSubsystem = searchSubsystem;
+
}
- protected AbstractSearchAssistant getAutoCompletor(SearchSubsystem searchSubsystem) {
+ protected AbstractSearchAssistant getSearchAssistant() {
if (searchSubsystem == SearchSubsystem.RESOURCE) {
return new ResourceSearchAssistant();
} else {
@@ -290,8 +291,8 @@ public class SearchAssistManager {
}
public List<String> getAllContexts() {
- List<String> results = new ArrayList<String>(completor.getSimpleContexts());
- for (String parameterized : completor.getParameterizedContexts()) {
+ List<String> results = new ArrayList<String>(getSearchAssistant().getSimpleContexts());
+ for (String parameterized : getSearchAssistant().getParameterizedContexts()) {
results.add(parameterized + "[");
}
return results;
@@ -299,7 +300,7 @@ public class SearchAssistManager {
public List<SearchSuggestion> getSuggestions(String expression, int caretPos) {
//List<SearchSuggestion> simple = getSimpleSuggestions(expression, caretPos);
- List<SearchSuggestion> advanced = getAdvancedSuggestions(expression, caretPos, SearchSuggestion.Kind.Advanced);
+ List<SearchSuggestion> advanced = getAdvancedSuggestions(expression, caretPos);
List<SearchSuggestion> userSavedSearches = getUserSavedSearchSuggestions(expression);
List<SearchSuggestion> globalSavedSearches = getGlobalSavedSearchSuggestions(expression);
@@ -313,11 +314,12 @@ public class SearchAssistManager {
}
public List<SearchSuggestion> getSimpleSuggestions(String expression, int caretPos) {
+ AbstractSearchAssistant completor = getSearchAssistant();
+
List<SearchSuggestion> results = new ArrayList<SearchSuggestion>();
for (String nextContext : completor.getSimpleContexts()) {
String intermediateExpression = nextContext + "=" + expression;
- List<SearchSuggestion> suggestions = getAdvancedSuggestions(intermediateExpression, caretPos,
- SearchSuggestion.Kind.Simple);
+ List<SearchSuggestion> suggestions = getAdvancedSuggestions(intermediateExpression, caretPos);
results.addAll(suggestions);
}
Collections.sort(results);
@@ -328,8 +330,9 @@ public class SearchAssistManager {
}
}
- public List<SearchSuggestion> getAdvancedSuggestions(String expression, int caretPos,
- SearchSuggestion.Kind targetKind) {
+ public List<SearchSuggestion> getAdvancedSuggestions(String expression, int caretPos) {
+ AbstractSearchAssistant completor = getSearchAssistant();
+
debug("getAdvancedSuggestions: START");
long id = HibernatePerformanceMonitor.get().start();
SearchTermAssistant assistant = new SearchTermAssistant(expression, caretPos);
@@ -339,7 +342,7 @@ public class SearchAssistManager {
if (tokens.length == 0) {
debug("getAdvancedSuggestions: no terms");
- return convert(getAllContexts(), targetKind); // no terms yet defined
+ return convert(getAllContexts()); // no terms yet defined
}
String beforeCaret = assistant.getFragmentBeforeCaret();
@@ -352,26 +355,26 @@ public class SearchAssistManager {
if (parsed.context.equals("")) {
if (tokens.length == 1) {
debug("getAdvancedSuggestions: no terms yet, suggesting contexts");
- return convert(getAllContexts(), targetKind);
+ return convert(getAllContexts());
} else if (isBooleanTerm(assistant.getPreviousToken())) {
debug("getAdvancedSuggestions: previous term was boolean, suggesting contexts");
- return convert(getAllContexts(), targetKind);
+ return convert(getAllContexts());
} else {
debug("getAdvancedSuggestions: previous term was not boolean, suggesting boolean");
- return convert(booleanOperators, targetKind);
+ return convert(booleanOperators);
}
} else if (isBooleanTerm(parsed.context)) {
debug("getAdvancedSuggestions: beforeCaret is whole boolean operator");
- return convert(getAllContexts(), targetKind); // TODO: should we tell user to type a space first?
+ return convert(getAllContexts()); // TODO: should we tell user to type a space first?
} else {
// check if this context is complete or not
if (completor.getSimpleContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: search term is simple context, wants operator");
- return convert(pad(parsed.context, comparisonOperators, ""), targetKind);
+ return convert(pad(parsed.context, comparisonOperators, ""));
}
if (completor.getParameterizedContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: search term is parameterized context, wants open bracket");
- return convert(Arrays.asList(parsed.context + "["), targetKind);
+ return convert(Arrays.asList(parsed.context + "["));
}
debug("getAdvancedSuggestions: search term wants context completion");
@@ -386,12 +389,11 @@ public class SearchAssistManager {
startsWithContexts.add(context + "[");
}
}
- return convert(startsWithContexts, targetKind);
+ return convert(startsWithContexts);
}
case PARAM:
debug("getAdvancedSuggestions: param state");
- return convert(pad(parsed.context + "[", completor.getParameters(parsed.context, parsed.param), "]"),
- targetKind);
+ return convert(pad(parsed.context + "[", completor.getParameters(parsed.context, parsed.param), "]"));
case OPERATOR:
debug("getAdvancedSuggestions: operator state");
if (comparisonOperators.contains(parsed.operator)) {
@@ -399,11 +401,11 @@ public class SearchAssistManager {
List<String> valueSuggestions = pad("\"", completor.getValues(parsed.context, parsed.param, ""), "\"");
if (completor.getSimpleContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: suggesting value completions for a simple context");
- return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""), targetKind);
+ return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""));
} else {
debug("getAdvancedSuggestions: suggesting value completions for a parameterized context");
return convert(pad(parsed.context + "[" + parsed.param + "]" + parsed.operator, valueSuggestions,
- ""), targetKind);
+ ""));
}
}
@@ -416,9 +418,9 @@ public class SearchAssistManager {
debug("getAdvancedSuggestions: providing suggestions for comparison operators");
if (completor.getSimpleContexts().contains(parsed.context)) {
- return convert(pad(parsed.context, operatorSuggestions, ""), targetKind);
+ return convert(pad(parsed.context, operatorSuggestions, ""));
} else {
- return convert(pad(parsed.context + "[" + parsed.param + "]", operatorSuggestions, ""), targetKind);
+ return convert(pad(parsed.context + "[" + parsed.param + "]", operatorSuggestions, ""));
}
case VALUE:
debug("getAdvancedSuggestions: value state");
@@ -426,11 +428,10 @@ public class SearchAssistManager {
"\"");
if (completor.getSimpleContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: suggesting value completions for a simple context");
- return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""), targetKind);
+ return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""));
} else {
debug("getAdvancedSuggestions: suggesting value completions for a parameterized context");
- return convert(pad(parsed.context + "[" + parsed.param + "]" + parsed.operator, valueSuggestions, ""),
- targetKind);
+ return convert(pad(parsed.context + "[" + parsed.param + "]" + parsed.operator, valueSuggestions, ""));
}
default:
return Collections.emptyList();
@@ -440,6 +441,7 @@ public class SearchAssistManager {
public List<SearchSuggestion> getUserSavedSearchSuggestions(String expression) {
SavedSearchCriteria criteria = new SavedSearchCriteria();
criteria.addFilterSubjectId(subject.getId());
+ criteria.addFilterSearchContext(searchSubsystem);
if (expression != null && expression.trim().equals("")) {
criteria.addFilterName(expression);
}
@@ -494,10 +496,10 @@ public class SearchAssistManager {
return false;
}
- private List<SearchSuggestion> convert(List<String> suggestions, SearchSuggestion.Kind targetKind) {
+ private List<SearchSuggestion> convert(List<String> suggestions) {
List<SearchSuggestion> results = new ArrayList<SearchSuggestion>(suggestions.size());
for (String suggestion : suggestions) {
- results.add(new SearchSuggestion(targetKind, suggestion));
+ results.add(new SearchSuggestion(Kind.Advanced, suggestion));
}
return results;
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java
index 5d51d10..0a28dee 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java
@@ -36,7 +36,7 @@ public class GenericSearchAssistTest extends AbstractEJB3Test {
}
count++;
- List<SearchSuggestion> results = new TestAutoCompletionManager().getSuggestions(expression,
+ List<SearchSuggestion> results = new TestAutoCompletionManager().getAdvancedSuggestions(expression,
expression.length());
List<String> expectedResults = Arrays.asList(expected.split(" "));
@@ -51,7 +51,8 @@ public class GenericSearchAssistTest extends AbstractEJB3Test {
}
System.out.println("Tested " + count + " expressions for assist");
} catch (Exception e) {
- System.out.println("Error testing single line RHQL: " + e);
+ System.out.println("Error testing GenericSearchAssistTest: " + e);
+ e.printStackTrace(System.out);
throw e;
} finally {
if (reader != null) {
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java
index 28a11a7..704146b 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java
@@ -9,6 +9,7 @@ import java.util.Map;
import org.rhq.core.domain.search.SearchSubsystem;
import org.rhq.enterprise.server.search.assist.AbstractSearchAssistant;
import org.rhq.enterprise.server.search.execution.SearchAssistManager;
+import org.rhq.enterprise.server.util.LookupUtil;
public class TestAutoCompletionManager extends SearchAssistManager {
public static class TestAutoCompletor extends AbstractSearchAssistant {
@@ -61,10 +62,12 @@ public class TestAutoCompletionManager extends SearchAssistManager {
}
public TestAutoCompletionManager() {
- super(null, null);
+ super(LookupUtil.getSubjectManager().getOverlord(), null);
}
- protected AbstractSearchAssistant getAutoCompletor(SearchSubsystem searchContext) {
+ @Override
+ protected AbstractSearchAssistant getSearchAssistant() {
return new TestAutoCompletor();
+
}
}
commit 7064ea6ab73f1899567ed6bd6e48ee86aaf3f2cc
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Apr 26 13:04:08 2010 -0400
BZ-562816: fix regression in custom alert sender UI
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
index b8ae721..fd83f96 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/alert/notification/details.xhtml
@@ -56,7 +56,7 @@
<f:facet name="header">
<h:outputText value="Name" />
</f:facet>
- <h:outputText value="#{alertNotification.name}" />
+ <h:outputText value="#{alertNotification.displayName}" />
</rich:column>
<rich:column width="20%">
<f:facet name="header">
commit 8f4b79421c74e3d50abb3d8ab209168912e4c8fa
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Apr 26 13:03:16 2010 -0400
continuing development on search subsystem:
add support for simple search terms (as opposed to context=value advanced expressions)
fixed search portlet on the dashboard to point to the JSF-based inventory browser
added display of global and user-specific saved searches to the resources menu
support for loading saved searches from the menu bar, pre-populating the search textbox
support for loading saved searches from the search suggestion, pre-populating the search textbox
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
index 14634b6..7910f84 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/search-schema.xml
@@ -12,7 +12,6 @@
<column name="DESCRIPTION" type="VARCHAR2" size="500" required="false"/>
<column name="PATTERN" type="VARCHAR2" size="1000" required="true"/>
- <column name="JPQL_TRANSLATION" type="VARCHAR2" size="4000" required="false"/>
<column name="LAST_COMPUTE_TIME" type="LONG" required="true"/>
<column name="RESULT_COUNT" type="LONG" required="false"/>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/AbstractPlugin.java b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/AbstractPlugin.java
index d056fbb..e64c22b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/AbstractPlugin.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/plugin/AbstractPlugin.java
@@ -23,7 +23,6 @@
package org.rhq.core.domain.plugin;
-import java.io.ByteArrayInputStream;
import java.io.Serializable;
import javax.persistence.Column;
@@ -40,8 +39,6 @@ import javax.persistence.PrePersist;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
-import org.rhq.core.util.MessageDigestGenerator;
-
/**
* Base plugin implementation that agent and server plugin implementations extend.
*
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
index a9d4ff1..147942b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SavedSearch.java
@@ -22,13 +22,18 @@
*/
package org.rhq.core.domain.search;
+import java.io.Serializable;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
@@ -55,7 +60,9 @@ import org.rhq.core.domain.auth.Subject;
@Entity
@SequenceGenerator(name = "id", sequenceName = "RHQ_SAVED_SEARCH_ID_SEQ")
@Table(name = "RHQ_SAVED_SEARCH")
-public class SavedSearch {
+public class SavedSearch implements Serializable {
+
+ private static final long serialVersionUID = 1L;
@Id
@Column(name = "ID", nullable = false)
@@ -75,16 +82,14 @@ public class SavedSearch {
@Column(name = "PATTERN", nullable = false)
private String pattern;
- @Column(name = "JPQL_TRANSLATION")
- private String jpqlTranslation;
-
@Column(name = "LAST_COMPUTE_TIME", nullable = false)
private long lastComputeTime;
@Column(name = "RESULT_COUNT")
private Long resultCount;
- @Column(name = "SUBJECT_ID", nullable = false)
+ @JoinColumn(name = "SUBJECT_ID", nullable = false)
+ @ManyToOne(fetch = FetchType.LAZY)
private Subject subject;
@Column(name = "SUBJECT_ID", insertable = false, updatable = false)
@@ -105,7 +110,6 @@ public class SavedSearch {
setName(name); // name can be null, to allow for saving searches quickly
this.description = null;
- this.jpqlTranslation = null; // null value for pre-computed JPQL implies computation is needed
this.lastComputeTime = 0; // further imply that computation needs to occur
this.resultCount = null; // NULL resultCount implies either computation failed or hasn't begun yet
this.global = false; // user must promote saved search to be a global after creation
@@ -157,14 +161,6 @@ public class SavedSearch {
this.pattern = pattern;
}
- public String getJpqlTranslation() {
- return jpqlTranslation;
- }
-
- public void setJpqlTransation(String jpqlTranslation) {
- this.jpqlTranslation = jpqlTranslation;
- }
-
public long getLastComputeTime() {
return lastComputeTime;
}
@@ -250,4 +246,19 @@ public class SavedSearch {
return true;
}
+
+ @Override
+ public String toString() {
+ return "SavedSearch [" //
+ + "id=" + id //
+ + ", context=" + context //
+ + ", description=" + description //
+ + ", global=" + global //
+ + ", lastComputeTime=" + lastComputeTime //
+ + ", name=" + name //
+ + ", pattern=" + pattern //
+ + ", resultCount=" + resultCount //
+ + ", subjectId=" + subjectId + "]";
+ }
+
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSubsystem.java b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSubsystem.java
index a834833..cc489f8 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSubsystem.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSubsystem.java
@@ -25,6 +25,7 @@ package org.rhq.core.domain.search;
import java.util.HashMap;
import java.util.Map;
+import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.group.ResourceGroup;
/**
@@ -40,8 +41,8 @@ import org.rhq.core.domain.resource.group.ResourceGroup;
*/
public enum SearchSubsystem {
- Resource(org.rhq.core.domain.resource.Resource.class), //
- Group(ResourceGroup.class);
+ RESOURCE(Resource.class), //
+ GROUP(ResourceGroup.class);
private Class<?> entityClass;
private static Map<Class<?>, SearchSubsystem> subsystems;
@@ -63,4 +64,13 @@ public enum SearchSubsystem {
public static SearchSubsystem get(Class<?> entityClass) {
return SearchSubsystem.subsystems.get(entityClass);
}
+
+ /**
+ * A Java bean style getter to allow us to access the enum name from JSP or Facelets pages
+ *
+ * @return the enum name
+ */
+ public String getName() {
+ return name();
+ }
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSuggestion.java b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSuggestion.java
new file mode 100644
index 0000000..7e47275
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/search/SearchSuggestion.java
@@ -0,0 +1,94 @@
+package org.rhq.core.domain.search;
+
+import java.io.Serializable;
+
+public class SearchSuggestion implements Serializable, Comparable<SearchSuggestion> {
+
+ private static final long serialVersionUID = 1L;
+
+ public enum Kind {
+ Unknown(""), //
+ InstructionalTextComment(""), //
+ GlobalSavedSearch("GLOBAL"), //
+ UserSavedSearch("SAVED"), //
+ AdvancedOperator("SYNTAX"), //
+ Advanced("QUERY"), //
+ Simple("TEXT");
+
+ private String displayName;
+
+ private Kind(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public String getName() {
+ return name();
+ }
+ }
+
+ private final Kind kind;
+ private final String value;
+ private final String label;
+ private final int startIndex;
+ private final int endIndex;
+
+ public SearchSuggestion(Kind kind, String value) {
+ this(kind, value, 0, 0);
+ }
+
+ public SearchSuggestion(Kind kind, String value, int startIndex, int length) {
+ this.kind = kind;
+ this.label = value;
+ this.value = value;
+ this.startIndex = startIndex;
+ this.endIndex = startIndex + length;
+ }
+
+ public SearchSuggestion(Kind kind, String label, String value, int startIndex, int length) {
+ this.kind = kind;
+ this.label = label;
+ this.value = value;
+ this.startIndex = startIndex;
+ this.endIndex = startIndex + length;
+ }
+
+ public Kind getKind() {
+ return kind;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public int getStartIndex() {
+ return startIndex;
+ }
+
+ public int getEndIndex() {
+ return endIndex;
+ }
+
+ @Override
+ public int compareTo(SearchSuggestion other) {
+ int kindComparision = (this.kind.ordinal() - other.kind.ordinal());
+ if (kindComparision != 0) {
+ return kindComparision;
+ }
+ return label.compareTo(other.label);
+ }
+
+ public String toString() {
+ String before = label.substring(0, startIndex);
+ String highlight = label.substring(startIndex, endIndex);
+ String after = label.substring(endIndex);
+ return before + "(" + highlight + ")" + after + "->" + value;
+ }
+}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/UserPreferencesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/UserPreferencesUIBean.java
index 0b87f7f..8fa9e9f 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/UserPreferencesUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/UserPreferencesUIBean.java
@@ -19,15 +19,14 @@
package org.rhq.enterprise.gui.common.framework;
import java.util.List;
-import java.util.Enumeration;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.SavedSearchCriteria;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.search.SavedSearch;
import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageOrdering;
import org.rhq.core.gui.util.FacesContextUtility;
import org.rhq.enterprise.gui.legacy.ParamConstants;
import org.rhq.enterprise.gui.legacy.WebUser;
@@ -35,6 +34,7 @@ import org.rhq.enterprise.gui.legacy.WebUserPreferences;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
+import org.rhq.enterprise.server.search.SavedSearchManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -42,23 +42,40 @@ import org.rhq.enterprise.server.util.LookupUtil;
*/
public class UserPreferencesUIBean {
- private final Log log = LogFactory.getLog(UserPreferencesUIBean.class);
+ //private final Log log = LogFactory.getLog(UserPreferencesUIBean.class);
public static final String LEFT_RESOURCE_NAV_SHOWING = "ui.leftResourceNavShowing";
public static final String SUMMARY_PANEL_DISPLAY_STATE = "ui.summaryPanelDisplayState";
private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
private ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
+ private SavedSearchManagerLocal savedSearchManager = LookupUtil.getSavedSearchManager();
+
private List<Resource> resourceFavorites;
private List<ResourceGroup> groupFavorites;
+ private List<SavedSearch> savedSearches;
private String refreshPath;
+ private WebUser webUser;
+ private Subject subject;
+
public Subject getSubject() {
- return EnterpriseFacesContextUtility.getSubject();
+ if (subject == null) {
+ loadUserInfo();
+ }
+ return subject;
}
public WebUser getWebUser() {
- return EnterpriseFacesContextUtility.getWebUser();
+ if (webUser == null) {
+ loadUserInfo();
+ }
+ return webUser;
+ }
+
+ private void loadUserInfo() {
+ webUser = EnterpriseFacesContextUtility.getWebUser();
+ subject = webUser.getSubject();
}
public String getLeftResourceNavState() {
@@ -68,8 +85,7 @@ public class UserPreferencesUIBean {
}
public void setLeftResourceNavState(String state) {
- WebUser webUser = EnterpriseFacesContextUtility.getWebUser();
- WebUserPreferences preferences = webUser.getWebPreferences();
+ WebUserPreferences preferences = getWebUser().getWebPreferences();
preferences.setPreference(LEFT_RESOURCE_NAV_SHOWING, state);
}
@@ -95,17 +111,13 @@ public class UserPreferencesUIBean {
}
public void setPageRefresh(int refresh, String path) {
- WebUser webUser = EnterpriseFacesContextUtility.getWebUser();
- WebUserPreferences preferences = webUser.getWebPreferences();
+ WebUserPreferences preferences = getWebUser().getWebPreferences();
preferences.setPreference("PATH_REFRESH." + path, refresh);
}
-
-
public int getPageRefresh() {
- WebUser webUser = EnterpriseFacesContextUtility.getWebUser();
- WebUserPreferences preferences = webUser.getWebPreferences();
+ WebUserPreferences preferences = getWebUser().getWebPreferences();
String path = (String) FacesContextUtility.getRequest().getAttribute("javax.servlet.forward.request_uri");
if (path == null) {
@@ -124,13 +136,11 @@ public class UserPreferencesUIBean {
}
public String getSummaryPanelDisplayState() {
- return EnterpriseFacesContextUtility.getWebUser().getWebPreferences().getPreference(
- SUMMARY_PANEL_DISPLAY_STATE, "true");
+ return getWebUser().getWebPreferences().getPreference(SUMMARY_PANEL_DISPLAY_STATE, "true");
}
public void setSummaryPanelDisplayState(String state) {
- WebUser webUser = EnterpriseFacesContextUtility.getWebUser();
- WebUserPreferences preferences = webUser.getWebPreferences();
+ WebUserPreferences preferences = getWebUser().getWebPreferences();
preferences.setPreference(SUMMARY_PANEL_DISPLAY_STATE, state);
}
@@ -146,6 +156,20 @@ public class UserPreferencesUIBean {
return resourceFavorites;
}
+ public List<SavedSearch> getSavedSearches() {
+ if (savedSearches == null) {
+ SavedSearchCriteria criteria = new SavedSearchCriteria();
+ criteria.addFilterSubjectId(getSubject().getId());
+ criteria.addFilterGlobal(true);
+ criteria.setFiltersOptional(true); // get this user's searches as well as global ones
+ criteria.addSortGlobal(PageOrdering.DESC); // globals, then user-specified
+ criteria.addSortName(PageOrdering.ASC); // each sublist is alphabetical
+
+ savedSearches = savedSearchManager.findSavedSearchesByCriteria(getSubject(), criteria);
+ }
+ return savedSearches;
+ }
+
public List<ResourceGroup> getGroupFavorites() {
if (groupFavorites == null) {
WebUser user = EnterpriseFacesContextUtility.getWebUser();
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java
index 37941e7..aad85f1 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java
@@ -13,6 +13,7 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.core.domain.search.SearchSuggestion;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.gui.util.FacesContextUtility;
@@ -21,7 +22,6 @@ import org.rhq.enterprise.gui.common.framework.PagedDataTableUIBean;
import org.rhq.enterprise.gui.common.paging.PageControlView;
import org.rhq.enterprise.gui.common.paging.PagedListDataModel;
import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
-import org.rhq.enterprise.server.search.execution.SearchSuggestion;
import org.rhq.enterprise.server.util.LookupUtil;
public class BrowseGroupsUIBean extends PagedDataTableUIBean {
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseResourcesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseResourcesUIBean.java
index 074cd3a..e01a8f2 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseResourcesUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseResourcesUIBean.java
@@ -13,7 +13,9 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.search.SavedSearch;
import org.rhq.core.domain.search.SearchSubsystem;
+import org.rhq.core.domain.search.SearchSuggestion;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.gui.util.FacesContextUtility;
@@ -24,8 +26,8 @@ import org.rhq.enterprise.gui.common.paging.PageControlView;
import org.rhq.enterprise.gui.common.paging.ResourceNameDisambiguatingPagedListDataModel;
import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+import org.rhq.enterprise.server.search.SavedSearchManagerLocal;
import org.rhq.enterprise.server.search.execution.SearchAssistManager;
-import org.rhq.enterprise.server.search.execution.SearchSuggestion;
import org.rhq.enterprise.server.util.HibernatePerformanceMonitor;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -34,10 +36,13 @@ public class BrowseResourcesUIBean extends PagedDataTableUIBean {
public static final String MANAGED_BEAN_NAME = "BrowseResourcesUIBean";
- private String filter;
- private HtmlInputText filterInput;
+ private String search;
+ private HtmlInputText searchInput;
private ResourceCategory category;
+ private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
+ private SavedSearchManagerLocal savedSearchManager = LookupUtil.getSavedSearchManager();
+
private static final IntExtractor<ResourceComposite> RESOURCE_ID_EXTRATOR = new IntExtractor<ResourceComposite>() {
public int extract(ResourceComposite object) {
return object.getResource().getId();
@@ -54,15 +59,21 @@ public class BrowseResourcesUIBean extends PagedDataTableUIBean {
category = ResourceCategory.SERVICE;
}
- filter = FacesContextUtility.getOptionalRequestParameter("filter");
+ String searchId = FacesContextUtility.getOptionalRequestParameter("searchId");
+ if (searchId != null) {
+ SavedSearch savedSearch = savedSearchManager.getSavedSearchById(getSubject(), Integer.valueOf(searchId));
+ search = savedSearch.getPattern();
+ } else {
+ search = FacesContextUtility.getOptionalRequestParameter("search");
+ }
}
- public String getFilter() {
- return this.filter;
+ public String getSearch() {
+ return this.search;
}
- public void setFilter(String filter) {
- this.filter = filter;
+ public void setSearch(String search) {
+ this.search = search;
}
public ResourceCategory getCategory() {
@@ -77,8 +88,6 @@ public class BrowseResourcesUIBean extends PagedDataTableUIBean {
return dataModel;
}
- private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
-
private class ResultsDataModel extends ResourceNameDisambiguatingPagedListDataModel<ResourceComposite> {
public ResultsDataModel(PageControlView view, String beanName) {
@@ -86,14 +95,14 @@ public class BrowseResourcesUIBean extends PagedDataTableUIBean {
}
public PageList<ResourceComposite> fetchDataForPage(PageControl pc) {
- String filter = getFilter();
+ String search = getSearch();
ResourceCategory category = getCategory();
ResourceCriteria criteria = new ResourceCriteria();
criteria.setPageControl(pc);
criteria.addFilterResourceCategory(category);
- if (filter != null && !filter.trim().equals("")) {
- criteria.setSearchExpression(filter);
+ if (search != null && !search.trim().equals("")) {
+ criteria.setSearchExpression(search);
}
criteria.fetchParentResource(true);
@@ -127,25 +136,24 @@ public class BrowseResourcesUIBean extends PagedDataTableUIBean {
return FacesContextUtility.getRequest().getParameterValues("selectedItems");
}
- SearchAssistManager searchAssist = new SearchAssistManager(SearchSubsystem.Resource);
+ SearchAssistManager searchAssist = new SearchAssistManager(getSubject(), SearchSubsystem.RESOURCE);
public List<SearchSuggestion> autocomplete(Object suggest) {
String currentInputText = (String) suggest;
// assume caret at the end of the input
long id = HibernatePerformanceMonitor.get().start();
- List<SearchSuggestion> suggestions = searchAssist.getAdvancedSuggestions(currentInputText, currentInputText
- .length());
+ List<SearchSuggestion> suggestions = searchAssist.getSuggestions(currentInputText, currentInputText.length());
HibernatePerformanceMonitor.get().stop(id, "ResourceSuggestions");
return suggestions;
}
- public HtmlInputText getFilterInput() {
- return filterInput;
+ public HtmlInputText getSearchInput() {
+ return searchInput;
}
- public void setFilterInput(HtmlInputText filterInput) {
- this.filterInput = filterInput;
+ public void setSearchInput(HtmlInputText searchInput) {
+ this.searchInput = searchInput;
}
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/hub/ResourceHubPortalAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/hub/ResourceHubPortalAction.java
index f3d14be..1c775c8 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/hub/ResourceHubPortalAction.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/hub/ResourceHubPortalAction.java
@@ -36,6 +36,7 @@ import org.jetbrains.annotations.NotNull;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.plugin.Plugin;
+import org.rhq.core.domain.resource.InventorySummary;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.util.PageList;
@@ -48,7 +49,6 @@ import org.rhq.enterprise.gui.legacy.util.HubUtils;
import org.rhq.enterprise.gui.legacy.util.RequestUtils;
import org.rhq.enterprise.gui.legacy.util.SessionUtils;
import org.rhq.enterprise.gui.util.WebUtility;
-import org.rhq.core.domain.resource.InventorySummary;
import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -86,29 +86,23 @@ public class ResourceHubPortalAction extends BaseAction {
messages = getResources(request);
ResourceHubForm hubForm = (ResourceHubForm) form;
- /*
- * once search functionality is complete, this will redirect to the new inventory manager;
- * until then, keep it working against the old ResourceHub
- */
- if (false) {
- String filter = hubForm.getKeywords();
- if (filter.equals("Resource Name")) {
- filter = null; // user didn't type a filter, just selected a category and clicked 'GO'
- }
- String category = hubForm.getResourceCategory();
- String subtab = "all";
- try {
- ResourceCategory.valueOf(category.toUpperCase());
- subtab = category.toLowerCase();
- } catch (Exception e) {
- subtab = "hub";
- }
- String url = "/rhq/inventory/browseResources.xhtml?subtab=" + subtab;
- if (filter != null && !filter.trim().equals("")) {
- url += "&filter=" + filter;
- }
- response.sendRedirect(url);
+ String searchExpression = hubForm.getKeywords();
+ if (searchExpression.equals("Resource Name")) {
+ searchExpression = null; // user didn't type a filter, just selected a category and clicked 'GO'
+ }
+ String category = hubForm.getResourceCategory();
+ String subtab = "all";
+ try {
+ ResourceCategory.valueOf(category.toUpperCase());
+ subtab = category.toLowerCase();
+ } catch (Exception e) {
+ subtab = "hub";
+ }
+ String url = "/rhq/inventory/browseResources.xhtml?subtab=" + subtab;
+ if (searchExpression != null && !searchExpression.trim().equals("")) {
+ url += "&search=name=" + searchExpression;
}
+ response.sendRedirect(url);
org.rhq.core.domain.util.PageControl pageControl = WebUtility.getPageControl(request);
Subject subject = RequestUtils.getSubject(request);
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
index d6cb267..51107b2 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/startup/StartupServlet.java
@@ -59,6 +59,7 @@ import org.rhq.enterprise.server.plugin.pc.ServerPluginServiceManagement;
import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.scheduler.SchedulerLocal;
import org.rhq.enterprise.server.scheduler.jobs.AsyncResourceDeleteJob;
+import org.rhq.enterprise.server.scheduler.jobs.SavedSearchResultCountRecalculationJob;
import org.rhq.enterprise.server.scheduler.jobs.CheckForSuspectedAgentsJob;
import org.rhq.enterprise.server.scheduler.jobs.CheckForTimedOutConfigUpdatesJob;
import org.rhq.enterprise.server.scheduler.jobs.CheckForTimedOutContentRequestsJob;
@@ -325,6 +326,16 @@ public class StartupServlet extends HttpServlet {
LookupUtil.getSystemManager().scheduleConfigCacheReloader();
try {
+ // Do not check until we are up at least 1 min, and every minute thereafter.
+ final long initialDelay = 1000L * 60;
+ final long interval = 1000L * 60;
+ scheduler.scheduleSimpleRepeatingJob(SavedSearchResultCountRecalculationJob.class, true, false, initialDelay,
+ interval);
+ } catch (Exception e) {
+ log("Cannot schedule asynchronous resource deletion job: " + e.getMessage());
+ }
+
+ try {
// Do not check until we are up at least 1 min, and every 5 minutes thereafter.
final long initialDelay = 1000L * 60;
final long interval = 1000L * 60 * 5;
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml
index 232974b..8e016de 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/menu/menu.xhtml
@@ -124,6 +124,21 @@
</c:if>
</c:forEach>
</rich:menuGroup>
+
+ <ui:remove>***** Resources > SAVED SEARCHES *****</ui:remove>
+ <rich:menuGroup value="Saved Searches" icon="/images/bookmark.png">
+ <c:forEach var="savedSearch" items="#{UserPreferencesUIBean.savedSearches}">
+ <c:if test="#{savedSearch.context.name == 'RESOURCE'}">
+ <rich:menuItem submitMode="none"
+ icon="/images/icons/Flag_#{savedSearch.global ? 'yellow' : 'blue'}_16.png"
+ onclick="window.location = '/rhq/inventory/browseResources.xhtml?subtab=all&searchId=#{savedSearch.id}'">
+ <h:outputText value="#{savedSearch.name}" />
+ <h:outputText value=" (#{savedSearch.resultCount})"
+ rendered="#{not empty savedSearch.resultCount}" />
+ </rich:menuItem>
+ </c:if>
+ </c:forEach>
+ </rich:menuGroup>
<rich:menuSeparator/>
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml
index ac11225..90d45c0 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseResources.xhtml
@@ -31,17 +31,23 @@
<a4j:keepAlive beanName="BrowseResourcesUIBean"/>
<h:form id="browseResourcesForm">
- <input type="hidden" name="subtab" value="${param.subtab}"/>
+ <input type="hidden" name="subtab" value="${param.subtab}" />
<p/>
<h:panelGroup>
- <h:outputLabel for="filter" value="Search: " />
- <h:inputText id="filter"
- binding="#{BrowseResourcesUIBean.filterInput}"
- value="#{BrowseResourcesUIBean.filter}"
+ <h:outputLabel for="search" value="Search: " />
+ <h:inputText id="search"
+ binding="#{BrowseResourcesUIBean.searchInput}"
+ value="#{BrowseResourcesUIBean.search}"
onkeypress="return ignoreEnterKey(event);"
- style="width: 600px;" />
- <rich:suggestionbox id="suggest" for="filter"
+ style="width: 600px;">
+ <ui:remove>
+ <a4j:support event="onfocus" reRender="suggest"
+ disableDefault="true" status="commonStatus" limitToList="true"
+ ajaxSingle="true" oncomplete="#{rich:component('suggest')}.show(event, {})"/>
+ </ui:remove>
+ </h:inputText>
+ <rich:suggestionbox id="suggest" for="search"
width="600" height="400"
border="1" cellpadding="1" cellspacing="1"
minChars="0"
@@ -56,7 +62,19 @@
eventsQueue="resourceSearchSuggestions"
ignoreDupResponses="true"
rendered="true"> <!-- disable until auto-completer is added -->
- <h:column>
+ <h:column width="10%">
+ <h:outputText value="#{suggestItem.kind.displayName}" style="font-variant: small-caps; color: gray;"
+ rendered="#{suggestItem.kind.name eq 'Simple'}" />
+ <h:outputText value="#{suggestItem.kind.displayName}" style="font-variant: small-caps; "
+ rendered="#{suggestItem.kind.name eq 'Advanced'}" />
+ <h:outputText value="#{suggestItem.kind.displayName}" style="font-variant: small-caps; color: yellow"
+ rendered="#{suggestItem.kind.name eq 'AdvancedOperator'}" />
+ <h:outputText value="#{suggestItem.kind.displayName}" style="font-variant: small-caps; color: green;"
+ rendered="#{suggestItem.kind.name eq 'UserSavedSearch'}" />
+ <h:outputText value="#{suggestItem.kind.displayName}" style="font-variant: small-caps; color: orange;"
+ rendered="#{suggestItem.kind.name eq 'GlobalSavedSearch'}" />
+ </h:column>
+ <h:column width="90%">
<h:outputText value="#{suggestItem.label}" />
</h:column>
</rich:suggestionbox>
diff --git a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
index b8ff97e..4fa879e 100644
--- a/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
+++ b/modules/enterprise/server/jar/src/main/antlr3/org/rhq/enterprise/server/search/RHQL.g
@@ -95,6 +95,7 @@ conditionalPrimary
simpleConditionalExpression
: c=context WS* op=comparisonOperator WS* ident=identifier -> ^($op $c ^(VALUE $ident))
+ | ident=identifier
; // rewrite tree output so operator is always the root -- ignore captured WS
context
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
new file mode 100644
index 0000000..a1e53b3
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/SavedSearchResultCountRecalculationJob.java
@@ -0,0 +1,95 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.server.scheduler.jobs;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.criteria.SavedSearchCriteria;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.search.SavedSearch;
+import org.rhq.core.domain.search.SearchSubsystem;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+import org.rhq.enterprise.server.search.SavedSearchManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ *
+ *
+ * @author Joseph Marques
+ */
+public class SavedSearchResultCountRecalculationJob extends AbstractStatefulJob {
+
+ private final static Log LOG = LogFactory.getLog(SavedSearchResultCountRecalculationJob.class);
+
+ private SavedSearchManagerLocal savedSearchManager = LookupUtil.getSavedSearchManager();
+ private ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
+
+ private Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+
+ @Override
+ public void executeJobCode(JobExecutionContext context) throws JobExecutionException {
+ List<SavedSearch> staleSavedSearches = getSavedSearchesNeedingRecomputation();
+
+ int errors = 0;
+ int updated = 0;
+ long totalMillis = 0;
+ for (SavedSearch next : staleSavedSearches) {
+ try {
+ if (next.getContext() == SearchSubsystem.RESOURCE) {
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.setSearchExpression(next.getPattern());
+
+ totalMillis -= System.currentTimeMillis();
+ PageList<Resource> results = resourceManager.findResourcesByCriteria(overlord, criteria);
+ totalMillis += System.currentTimeMillis();
+
+ if (results.getTotalSize() != next.getResultCount()) {
+ next.setResultCount((long) results.getTotalSize());
+ savedSearchManager.updateSavedSearch(overlord, next);
+ updated++;
+ }
+ }
+ } catch (Throwable t) {
+ // TODO: mark this saved search as "broken" so that future computation is suppressed for it
+ errors++;
+ LOG.error("Could not calculate result count for SavedSearch[name=" + next.getName() + ", patter='"
+ + next.getPattern() + "']");
+ }
+ }
+ LOG.info("Statistics: updated " + updated + " in " + totalMillis + " ms (" + errors + " errors)");
+ }
+
+ private List<SavedSearch> getSavedSearchesNeedingRecomputation() {
+ long fiveMinutesAgo = System.currentTimeMillis() - (5 * 60 * 1000);
+
+ SavedSearchCriteria criteria = new SavedSearchCriteria();
+ criteria.addFilterLastComputeTimeMax(fiveMinutesAgo);
+
+ List<SavedSearch> results = savedSearchManager.findSavedSearchesByCriteria(overlord, criteria);
+ return results;
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/AbstractSearchAssistant.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/AbstractSearchAssistant.java
index 90c790f..05b39e1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/AbstractSearchAssistant.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/AbstractSearchAssistant.java
@@ -12,6 +12,16 @@ import org.rhq.enterprise.server.util.LookupUtil;
public abstract class AbstractSearchAssistant implements SearchAssistant {
+ private int maxResultCount = 20;
+
+ public int getMaxResultCount() {
+ return maxResultCount;
+ }
+
+ public void setMaxResultCount(int maxResultCount) {
+ this.maxResultCount = maxResultCount;
+ }
+
@Override
public List<String> getSimpleContexts() {
return Collections.emptyList();
@@ -46,7 +56,7 @@ public abstract class AbstractSearchAssistant implements SearchAssistant {
@SuppressWarnings("unchecked")
protected final List<String> execute(String jpql) {
Query query = LookupUtil.getEntityManager().createQuery(jpql);
- query.setMaxResults(20);
+ query.setMaxResults(maxResultCount);
List<String> results = query.getResultList();
return results;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/ResourceSearchAssistant.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/ResourceSearchAssistant.java
index 94dcb7f..0e2b3df 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/ResourceSearchAssistant.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/ResourceSearchAssistant.java
@@ -21,7 +21,7 @@ public class ResourceSearchAssistant extends AbstractSearchAssistant {
@Override
public SearchSubsystem getSearchSubsystem() {
- return SearchSubsystem.Resource;
+ return SearchSubsystem.RESOURCE;
}
@Override
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/SearchAssistant.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/SearchAssistant.java
index 804e0bb..4314e06 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/SearchAssistant.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/assist/SearchAssistant.java
@@ -6,14 +6,14 @@ import org.rhq.core.domain.search.SearchSubsystem;
public interface SearchAssistant {
- public SearchSubsystem getSearchSubsystem();
+ SearchSubsystem getSearchSubsystem();
- public List<String> getSimpleContexts();
+ List<String> getSimpleContexts();
- public List<String> getParameterizedContexts();
+ List<String> getParameterizedContexts();
- public List<String> getParameters(String context, String filter);
+ List<String> getParameters(String context, String filter);
- public List<String> getValues(String context, String param, String filter);
+ List<String> getValues(String context, String param, String filter);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java
index e500449..2cb808c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchAssistManager.java
@@ -9,19 +9,29 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.SavedSearchCriteria;
+import org.rhq.core.domain.search.SavedSearch;
import org.rhq.core.domain.search.SearchSubsystem;
+import org.rhq.core.domain.search.SearchSuggestion;
+import org.rhq.core.domain.search.SearchSuggestion.Kind;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.enterprise.server.search.SavedSearchManagerLocal;
+import org.rhq.enterprise.server.search.assist.AbstractSearchAssistant;
import org.rhq.enterprise.server.search.assist.ResourceSearchAssistant;
-import org.rhq.enterprise.server.search.assist.SearchAssistant;
import org.rhq.enterprise.server.util.HibernatePerformanceMonitor;
+import org.rhq.enterprise.server.util.LookupUtil;
public class SearchAssistManager {
private static final Log LOG = LogFactory.getLog(SearchAssistManager.class);
+ private SavedSearchManagerLocal savedSearchManager = LookupUtil.getSavedSearchManager();
private static List<String> comparisonOperators = Arrays.asList("!==", "!=", "==", "=");
- private static List<String> booleanOperators = Arrays.asList("and", "or");
+ private static List<String> booleanOperators = Arrays.asList("and", "or", "|");
- private SearchAssistant completor;
+ private Subject subject;
+ private AbstractSearchAssistant completor;
/*
* states:
@@ -266,12 +276,13 @@ public class SearchAssistManager {
}
}
- public SearchAssistManager(SearchSubsystem searchSubsystem) {
+ public SearchAssistManager(Subject subject, SearchSubsystem searchSubsystem) {
+ this.subject = subject;
this.completor = getAutoCompletor(searchSubsystem);
}
- protected SearchAssistant getAutoCompletor(SearchSubsystem searchSubsystem) {
- if (searchSubsystem == SearchSubsystem.Resource) {
+ protected AbstractSearchAssistant getAutoCompletor(SearchSubsystem searchSubsystem) {
+ if (searchSubsystem == SearchSubsystem.RESOURCE) {
return new ResourceSearchAssistant();
} else {
throw new IllegalArgumentException("No SearchAssistant found for SearchSubsystem[" + searchSubsystem + "]");
@@ -286,7 +297,39 @@ public class SearchAssistManager {
return results;
}
- public List<SearchSuggestion> getAdvancedSuggestions(String expression, int caretPos) {
+ public List<SearchSuggestion> getSuggestions(String expression, int caretPos) {
+ //List<SearchSuggestion> simple = getSimpleSuggestions(expression, caretPos);
+ List<SearchSuggestion> advanced = getAdvancedSuggestions(expression, caretPos, SearchSuggestion.Kind.Advanced);
+ List<SearchSuggestion> userSavedSearches = getUserSavedSearchSuggestions(expression);
+ List<SearchSuggestion> globalSavedSearches = getGlobalSavedSearchSuggestions(expression);
+
+ List<SearchSuggestion> results = new ArrayList<SearchSuggestion>();
+ //results.addAll(simple);
+ results.addAll(advanced);
+ results.addAll(userSavedSearches);
+ results.addAll(globalSavedSearches);
+ Collections.sort(results);
+ return results;
+ }
+
+ public List<SearchSuggestion> getSimpleSuggestions(String expression, int caretPos) {
+ List<SearchSuggestion> results = new ArrayList<SearchSuggestion>();
+ for (String nextContext : completor.getSimpleContexts()) {
+ String intermediateExpression = nextContext + "=" + expression;
+ List<SearchSuggestion> suggestions = getAdvancedSuggestions(intermediateExpression, caretPos,
+ SearchSuggestion.Kind.Simple);
+ results.addAll(suggestions);
+ }
+ Collections.sort(results);
+ if (results.size() > completor.getMaxResultCount()) {
+ return results.subList(0, completor.getMaxResultCount());
+ } else {
+ return results;
+ }
+ }
+
+ public List<SearchSuggestion> getAdvancedSuggestions(String expression, int caretPos,
+ SearchSuggestion.Kind targetKind) {
debug("getAdvancedSuggestions: START");
long id = HibernatePerformanceMonitor.get().start();
SearchTermAssistant assistant = new SearchTermAssistant(expression, caretPos);
@@ -296,7 +339,7 @@ public class SearchAssistManager {
if (tokens.length == 0) {
debug("getAdvancedSuggestions: no terms");
- return convert(getAllContexts()); // no terms yet defined
+ return convert(getAllContexts(), targetKind); // no terms yet defined
}
String beforeCaret = assistant.getFragmentBeforeCaret();
@@ -309,26 +352,26 @@ public class SearchAssistManager {
if (parsed.context.equals("")) {
if (tokens.length == 1) {
debug("getAdvancedSuggestions: no terms yet, suggesting contexts");
- return convert(getAllContexts());
+ return convert(getAllContexts(), targetKind);
} else if (isBooleanTerm(assistant.getPreviousToken())) {
debug("getAdvancedSuggestions: previous term was boolean, suggesting contexts");
- return convert(getAllContexts());
+ return convert(getAllContexts(), targetKind);
} else {
debug("getAdvancedSuggestions: previous term was not boolean, suggesting boolean");
- return convert(booleanOperators);
+ return convert(booleanOperators, targetKind);
}
} else if (isBooleanTerm(parsed.context)) {
debug("getAdvancedSuggestions: beforeCaret is whole boolean operator");
- return convert(getAllContexts()); // TODO: should we tell user to type a space first?
+ return convert(getAllContexts(), targetKind); // TODO: should we tell user to type a space first?
} else {
// check if this context is complete or not
if (completor.getSimpleContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: search term is simple context, wants operator");
- return convert(pad(parsed.context, comparisonOperators, ""));
+ return convert(pad(parsed.context, comparisonOperators, ""), targetKind);
}
if (completor.getParameterizedContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: search term is parameterized context, wants open bracket");
- return convert(Arrays.asList(parsed.context + "["));
+ return convert(Arrays.asList(parsed.context + "["), targetKind);
}
debug("getAdvancedSuggestions: search term wants context completion");
@@ -343,11 +386,12 @@ public class SearchAssistManager {
startsWithContexts.add(context + "[");
}
}
- return convert(startsWithContexts);
+ return convert(startsWithContexts, targetKind);
}
case PARAM:
debug("getAdvancedSuggestions: param state");
- return convert(pad(parsed.context + "[", completor.getParameters(parsed.context, parsed.param), "]"));
+ return convert(pad(parsed.context + "[", completor.getParameters(parsed.context, parsed.param), "]"),
+ targetKind);
case OPERATOR:
debug("getAdvancedSuggestions: operator state");
if (comparisonOperators.contains(parsed.operator)) {
@@ -355,11 +399,11 @@ public class SearchAssistManager {
List<String> valueSuggestions = pad("\"", completor.getValues(parsed.context, parsed.param, ""), "\"");
if (completor.getSimpleContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: suggesting value completions for a simple context");
- return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""));
+ return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""), targetKind);
} else {
debug("getAdvancedSuggestions: suggesting value completions for a parameterized context");
return convert(pad(parsed.context + "[" + parsed.param + "]" + parsed.operator, valueSuggestions,
- ""));
+ ""), targetKind);
}
}
@@ -372,9 +416,9 @@ public class SearchAssistManager {
debug("getAdvancedSuggestions: providing suggestions for comparison operators");
if (completor.getSimpleContexts().contains(parsed.context)) {
- return convert(pad(parsed.context, operatorSuggestions, ""));
+ return convert(pad(parsed.context, operatorSuggestions, ""), targetKind);
} else {
- return convert(pad(parsed.context + "[" + parsed.param + "]", operatorSuggestions, ""));
+ return convert(pad(parsed.context + "[" + parsed.param + "]", operatorSuggestions, ""), targetKind);
}
case VALUE:
debug("getAdvancedSuggestions: value state");
@@ -382,16 +426,65 @@ public class SearchAssistManager {
"\"");
if (completor.getSimpleContexts().contains(parsed.context)) {
debug("getAdvancedSuggestions: suggesting value completions for a simple context");
- return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""));
+ return convert(pad(parsed.context + parsed.operator, valueSuggestions, ""), targetKind);
} else {
debug("getAdvancedSuggestions: suggesting value completions for a parameterized context");
- return convert(pad(parsed.context + "[" + parsed.param + "]" + parsed.operator, valueSuggestions, ""));
+ return convert(pad(parsed.context + "[" + parsed.param + "]" + parsed.operator, valueSuggestions, ""),
+ targetKind);
}
default:
return Collections.emptyList();
}
}
+ public List<SearchSuggestion> getUserSavedSearchSuggestions(String expression) {
+ SavedSearchCriteria criteria = new SavedSearchCriteria();
+ criteria.addFilterSubjectId(subject.getId());
+ if (expression != null && expression.trim().equals("")) {
+ criteria.addFilterName(expression);
+ }
+
+ criteria.setCaseSensitive(false);
+ criteria.addSortName(PageOrdering.ASC);
+
+ List<SavedSearch> savedSearchResults = savedSearchManager.findSavedSearchesByCriteria(subject, criteria);
+
+ List<SearchSuggestion> results = new ArrayList<SearchSuggestion>();
+ for (SavedSearch next : savedSearchResults) {
+ String label = next.getName();
+ String value = next.getPattern();
+ int index = next.getName().toLowerCase().indexOf(expression);
+ SearchSuggestion suggestion = new SearchSuggestion(Kind.UserSavedSearch, label, value, index, expression
+ .length());
+ results.add(suggestion);
+ }
+ return results;
+ }
+
+ public List<SearchSuggestion> getGlobalSavedSearchSuggestions(String expression) {
+ SavedSearchCriteria criteria = new SavedSearchCriteria();
+ criteria.addFilterGlobal(true);
+ if (expression != null && expression.trim().equals("")) {
+ criteria.addFilterName(expression);
+ }
+
+ criteria.setCaseSensitive(false);
+ criteria.addSortName(PageOrdering.ASC);
+
+ List<SavedSearch> savedSearchResults = savedSearchManager.findSavedSearchesByCriteria(subject, criteria);
+
+ List<SearchSuggestion> results = new ArrayList<SearchSuggestion>();
+ for (SavedSearch next : savedSearchResults) {
+ String label = next.getName();
+ String value = next.getPattern();
+ int index = next.getName().toLowerCase().indexOf(expression);
+ SearchSuggestion suggestion = new SearchSuggestion(Kind.GlobalSavedSearch, label, value, index, expression
+ .length());
+ results.add(suggestion);
+ }
+ return results;
+ }
+
private boolean isBooleanTerm(String term) {
for (String op : booleanOperators) {
if (op.equals(term)) {
@@ -401,10 +494,10 @@ public class SearchAssistManager {
return false;
}
- private List<SearchSuggestion> convert(List<String> suggestions) {
+ private List<SearchSuggestion> convert(List<String> suggestions, SearchSuggestion.Kind targetKind) {
List<SearchSuggestion> results = new ArrayList<SearchSuggestion>(suggestions.size());
for (String suggestion : suggestions) {
- results.add(new SearchSuggestion(SearchSuggestion.SearchCategory.Advanced, suggestion));
+ results.add(new SearchSuggestion(targetKind, suggestion));
}
return results;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchSuggestion.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchSuggestion.java
deleted file mode 100644
index e69090d..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchSuggestion.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.rhq.enterprise.server.search.execution;
-
-public class SearchSuggestion {
- public enum SearchCategory {
- Simple, Advanced, SavedSearch, InstructionalTextComment, Unknown;
- }
-
- private final SearchCategory category;
- private final String value;
- private final String label;
- private final int startIndex;
- private final int endIndex;
-
- public SearchSuggestion(SearchCategory category, String value) {
- this(category, value, 0, 0);
- }
-
- public SearchSuggestion(SearchCategory category, String value, int startIndex, int length) {
- this.category = category;
- this.label = value;
- this.value = value;
- this.startIndex = startIndex;
- this.endIndex = startIndex + length;
- }
-
- public SearchCategory getCategory() {
- return category;
- }
-
- public String getLabel() {
- return label;
- }
-
- public String getValue() {
- return value;
- }
-
- public int getStartIndex() {
- return startIndex;
- }
-
- public int getEndIndex() {
- return endIndex;
- }
-
- public String toString() {
- String before = label.substring(0, startIndex);
- String highlight = label.substring(startIndex, endIndex);
- String after = label.substring(endIndex);
- return before + "(" + highlight + ")" + after + "->" + value;
- }
-}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchTranslationManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchTranslationManager.java
index 806987f..812bc57 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchTranslationManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/execution/SearchTranslationManager.java
@@ -57,19 +57,19 @@ public class SearchTranslationManager {
public String getJPQLSelectStatement() throws Exception {
String jpql = "SELECT " + alias + " FROM " + entity + " " + alias + " WHERE " + getJPQLWhereFragment();
- System.out.println("JPQL was:");
+ //System.out.println("JPQL was:");
PrintUtils.printJPQL(jpql.split(" "));
- System.out.println();
+ //System.out.println();
return jpql;
}
public String getJPQLWhereFragment() throws Exception {
RHQLParser.searchExpression_return searchAST = parser.searchExpression();
- System.out.println("Search was: " + expression);
+ //System.out.println("Search was: " + expression);
CommonTree searchExpressionTree = (CommonTree) searchAST.getTree();
- System.out.println("Errors found: " + adaptor.getErrorMessages());
- System.out.println("Tree was:");
+ //System.out.println("Errors found: " + adaptor.getErrorMessages());
+ //System.out.println("Tree was:");
PrintUtils.print(searchExpressionTree, "");
String fragment = generateJPQL(searchExpressionTree);
return fragment;
@@ -193,12 +193,12 @@ public class SearchTranslationManager {
}
if (lineBreakers.contains(next)) {
- System.out.println();
- System.out.print(indent);
+ //System.out.println();
+ //System.out.print(indent);
}
- System.out.print(next);
- System.out.print(" ");
+ //System.out.print(next);
+ //System.out.print(" ");
if (next.equals(")")) {
indent = indent.substring(3);
@@ -228,11 +228,11 @@ public class SearchTranslationManager {
return;
}
- System.out.print(indent + token.getText());
+ //System.out.print(indent + token.getText());
if (isStringNode(token)) {
- System.out.println(collapseStringChildren(tree));
+ //System.out.println(collapseStringChildren(tree));
} else {
- System.out.println();
+ //System.out.println();
for (int childIndex = 0; childIndex < tree.getChildCount(); childIndex++) {
CommonTree child = (CommonTree) tree.getChild(childIndex);
print(child, indent + " ");
@@ -261,7 +261,7 @@ public class SearchTranslationManager {
}
public static void main(String[] args) throws Exception {
- SearchTranslationManager manager = new SearchTranslationManager(SearchSubsystem.Resource);
+ SearchTranslationManager manager = new SearchTranslationManager(SearchSubsystem.RESOURCE);
manager.setExpression("(name = rhq and category = server) or plugin = jbossas");
String jpql = manager.getJPQLSelectStatement();
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/translation/SearchTranslatorFactory.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/translation/SearchTranslatorFactory.java
index fa8d626..ee8ecda 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/translation/SearchTranslatorFactory.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/search/translation/SearchTranslatorFactory.java
@@ -8,7 +8,7 @@ public class SearchTranslatorFactory {
}
public static SearchTranslator getTranslator(SearchSubsystem searchContext) {
- if (searchContext == SearchSubsystem.Resource) {
+ if (searchContext == SearchSubsystem.RESOURCE) {
return new ResourceSearchTranslator();
}
throw new IllegalArgumentException("No SearchTranslator found for SearchContext[" + searchContext + "]");
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
index 0e1a789..ff71760 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
@@ -398,7 +398,7 @@ public final class CriteriaQueryGenerator {
// translate first, if there was an error we won't add the dangling 'AND' to the where clause
String translatedJPQL = searchManager.getJPQLWhereFragment();
- LOG.info("Translated JPQL Fragment was: " + translatedJPQL);
+ LOG.debug("Translated JPQL Fragment was: " + translatedJPQL);
if (translatedJPQL != null) {
searchExpressionWhereClause = translatedJPQL;
}
diff --git a/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt b/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
index 8793fb1..265071b 100644
--- a/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
+++ b/modules/enterprise/server/jar/src/main/resources/single-line-rhql.txt
@@ -94,4 +94,12 @@ context = value1 | ((context = value2))
((context = value1)) context = value2
(context = value1) (context = value2)
(context = value1 (context = value2))
-context = value1 ((context = value2))
\ No newline at end of file
+context = value1 ((context = value2))
+
+# simple terms
+hello
+hello world
+"hello world" 'foo bar'
+'hello world' "foo bar"
+hello | world
+context=value | world
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java
index 867ee78..5d51d10 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/GenericSearchAssistTest.java
@@ -10,7 +10,7 @@ import java.util.List;
import org.testng.annotations.Test;
-import org.rhq.enterprise.server.search.execution.SearchSuggestion;
+import org.rhq.core.domain.search.SearchSuggestion;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
public class GenericSearchAssistTest extends AbstractEJB3Test {
@@ -36,7 +36,7 @@ public class GenericSearchAssistTest extends AbstractEJB3Test {
}
count++;
- List<SearchSuggestion> results = new TestAutoCompletionManager().getAdvancedSuggestions(expression,
+ List<SearchSuggestion> results = new TestAutoCompletionManager().getSuggestions(expression,
expression.length());
List<String> expectedResults = Arrays.asList(expected.split(" "));
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java
index 89cb5ff..28a11a7 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/search/TestAutoCompletionManager.java
@@ -8,7 +8,6 @@ import java.util.Map;
import org.rhq.core.domain.search.SearchSubsystem;
import org.rhq.enterprise.server.search.assist.AbstractSearchAssistant;
-import org.rhq.enterprise.server.search.assist.SearchAssistant;
import org.rhq.enterprise.server.search.execution.SearchAssistManager;
public class TestAutoCompletionManager extends SearchAssistManager {
@@ -62,10 +61,10 @@ public class TestAutoCompletionManager extends SearchAssistManager {
}
public TestAutoCompletionManager() {
- super(null);
+ super(null, null);
}
- protected SearchAssistant getAutoCompletor(SearchSubsystem searchContext) {
+ protected AbstractSearchAssistant getAutoCompletor(SearchSubsystem searchContext) {
return new TestAutoCompletor();
}
}
14 years, 1 month