modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java | 12
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleFile.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeployment.java | 4
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeploymentHistory.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/cloud/FailoverList.java | 356 +++++-----
modules/core/domain/src/main/java/org/rhq/core/domain/cloud/FailoverListDetails.java | 338 ++++-----
modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceSyncResults.java | 2
modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoSyncResults.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/FileUploadServlet.java | 15
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml | 6
modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html | 1
11 files changed, 382 insertions(+), 364 deletions(-)
New commits:
commit dc67f7b6b6750537b253aaf21acbebcc6b72fc0d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon May 9 17:11:45 2011 -0400
[BZ 697751 - ResourcePackageDetails.getFileName() returns "c:\fakepath\xa.rar" when uploading file in Chrome and IE]
IE and Chrome provide an absolute filename for the uploaded item,
which needs to be trimmed down to what FF provides, just the name portion.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/FileUploadServlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/FileUploadServlet.java
index 2c8e514..e8265a6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/FileUploadServlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/FileUploadServlet.java
@@ -179,7 +179,20 @@ public class FileUploadServlet extends HttpServlet {
protected File forceToFile(FileItem fileItem) throws IOException, ServletException {
if (fileItem.isInMemory()) {
- File tmpFile = File.createTempFile("" + fileItem.getName(), null);
+ String name = fileItem.getName();
+
+ if (null == name) {
+ throw new IllegalArgumentException("FileItem has null name");
+ }
+
+ // some browsers (IE, Chrome) pass an absolute filename, we just want the name of the file, no paths
+ name = name.replace('\\', '/');
+ if (name.length() > 2 && name.charAt(1) == ':') {
+ name = name.substring(2);
+ }
+ name = new File(name).getName();
+
+ File tmpFile = File.createTempFile(name, null);
try {
fileItem.write(tmpFile);
return tmpFile;
commit aa5e5ba286997779ba1e735e5680f73c3854fd6d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon May 9 17:06:07 2011 -0400
[BZ 703252 - IE (IE7, IE8) unable to load CoreGUI]
- Add DOCTYPE to CoreGUI.html. This directs IE to use standards mode as
opposed to quirks mode.
- Comment out the gwt standard.css from CoreGUI.gwt.xml. This should not
be here as suggested by smartgwt, seems to not help us, and seemed link
to failed app loads in IE.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
index c2ba874..4c2ee34 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/CoreGUI.gwt.xml
@@ -10,7 +10,11 @@
<inherits name='com.smartgwt.SmartGwt' />
<inherits name="com.smartgwt.tools.SmartGwtTools"/>
- <!--<inherits name='com.google.gwt.user.theme.standard.Standard'/>-->
+ <!-- removing this, we can add it back if we find something that looks odd. But,
+ 1) it seemed like a trouble spot during initial load for certain IE configurations
+ 2) we probably don't want to be defaulting to GWT standards as opposed to SmartGWT.
+ <inherits name='com.google.gwt.user.theme.standard.Standard'/>
+ -->
<!--
<inherits name="com.smartclient.theme.graphite.Graphite"/>
-->
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html
index 5432ecb..1b96d09 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html
+++ b/modules/enterprise/gui/coregui/src/main/webapp/CoreGUI.html
@@ -1,3 +1,4 @@
+<!doctype html>
<html>
<head>
<title>RHQ Core Application</title>
commit 76bd674107fefba2344279cabe256c02344be5ea
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon May 9 17:03:40 2011 -0400
Related to [BZ 702390 - Large number of BundleDeployments for a single Bundle causes fetch serialization issues]
Ensure (optional=false) set for LAZY load required (i.e. nullable = false) associations.
This should ensure lazy load.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java
index e288428..bc9d927 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/Alert.java
@@ -50,7 +50,7 @@ import org.rhq.core.domain.alert.notification.AlertNotificationLog;
* @author Joseph Marques
*/
@Entity
-@NamedQueries({
+@NamedQueries( {
@NamedQuery(name = Alert.QUERY_FIND_BY_MEASUREMENT_DEFINITION_ID, query = "SELECT a " + " FROM Alert AS a "
+ " JOIN a.alertDefinition definition " + " JOIN definition.conditions condition "
+ " WHERE condition.measurementDefinition.id = :measurementDefinitionId "
@@ -123,10 +123,8 @@ import org.rhq.core.domain.alert.notification.AlertNotificationLog;
+ " FROM AlertDefinition ad " //
+ " JOIN ad.alerts innerA " //
+ " WHERE ad.resource.id IN ( :resourceIds ) )"),
- @NamedQuery(name = Alert.QUERY_DELETE_BY_RESOURCE_TEMPLATE, query =
- "DELETE FROM Alert alert "
- + "WHERE alert.id IN (SELECT innerAlerts.id "
- + " FROM AlertDefinition alertDef "
+ @NamedQuery(name = Alert.QUERY_DELETE_BY_RESOURCE_TEMPLATE, query = "DELETE FROM Alert alert "
+ + "WHERE alert.id IN (SELECT innerAlerts.id " + " FROM AlertDefinition alertDef "
+ " JOIN alertDef.alerts innerAlerts "
+ " WHERE alertDef.resourceType.id = :resourceTypeId)"),
@NamedQuery(name = Alert.QUERY_DELETE_BY_RESOURCE_GROUPS, query = "" //
@@ -272,8 +270,8 @@ public class Alert implements Serializable {
@Column(name = "RECOVERY_ID")
private Integer recoveryId;
- @JoinColumn(name = "RECOVERY_ID", referencedColumnName = "ID", insertable = false, updatable = false)
- @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "RECOVERY_ID", referencedColumnName = "ID", insertable = false, updatable = false, nullable = false)
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
private AlertDefinition recoveryAlertDefinition;
@Column(name = "WILL_RECOVER", nullable = false)
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleFile.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleFile.java
index f6b5c29..dfba7d4 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleFile.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleFile.java
@@ -67,7 +67,7 @@ public class BundleFile implements Serializable {
private int id;
@JoinColumn(name = "BUNDLE_VERSION_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne(fetch = FetchType.LAZY)
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
private BundleVersion bundleVersion;
// Note, currently we cascade remove the PackageVersion because BundleVersions do not share
@@ -75,7 +75,7 @@ public class BundleFile implements Serializable {
// the future (e.e reuse of PVs if the sha256 is not different) then this will will have to change
// to reflect the fact that multiple BundleFiles could reference the same PackageVersion.
@JoinColumn(name = "PACKAGE_VERSION_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
+ @ManyToOne(fetch = FetchType.LAZY, optional = false, cascade = CascadeType.REMOVE)
private PackageVersion packageVersion;
public BundleFile() {
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeployment.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeployment.java
index 7cd7b50..fec79da 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeployment.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeployment.java
@@ -78,11 +78,11 @@ public class BundleResourceDeployment implements Serializable {
private int id;
@JoinColumn(name = "BUNDLE_DEPLOYMENT_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne(fetch = FetchType.LAZY)
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
private BundleDeployment bundleDeployment;
@JoinColumn(name = "RESOURCE_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne(fetch = FetchType.LAZY)
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
private Resource resource;
@Column(name = "STATUS", nullable = false)
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeploymentHistory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeploymentHistory.java
index b04e257..6337c4e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeploymentHistory.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeploymentHistory.java
@@ -68,7 +68,7 @@ public class BundleResourceDeploymentHistory implements Serializable {
private int id;
@JoinColumn(name = "BUNDLE_RES_DEPLOY_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne(fetch = FetchType.LAZY)
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
private BundleResourceDeployment resourceDeployment;
@Column(name = "SUBJECT_NAME", nullable = true)
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/FailoverList.java b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/FailoverList.java
index 40dd426..000284d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/FailoverList.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/FailoverList.java
@@ -1,178 +1,178 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.rhq.core.domain.cloud;
-
-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.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.OrderBy;
-import javax.persistence.PrePersist;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.Table;
-
-import org.rhq.core.domain.resource.Agent;
-
-/**
- * An object to capture a snapshot of the order in which particular agents
- * will fail over to particular servers. The {@link FailoverListDetails}
- * will contain the ordered references back to other {@link Server}s.
- *
- * @author jmarques
- *
- */
-@Entity(name = "FailoverList")
-@NamedQueries( //
-{
- @NamedQuery(name = FailoverList.QUERY_DELETE_VIA_AGENT, query = "DELETE FROM FailoverList fl WHERE fl.agent = :agent"),
- @NamedQuery(name = FailoverList.QUERY_DELETE_VIA_PARTITION_EVENT, query = "DELETE FROM FailoverList fl WHERE fl.partitionEvent = :partitionEvent"),
- @NamedQuery(name = FailoverList.QUERY_GET_VIA_AGENT, query = "SELECT fl FROM FailoverList fl WHERE fl.agent = :agent"),
- @NamedQuery(name = FailoverList.QUERY_TRUNCATE, query = "DELETE FROM FailoverList") })
-@SequenceGenerator(name = "id", sequenceName = "RHQ_FAILOVER_LIST_ID_SEQ")
-@Table(name = "RHQ_FAILOVER_LIST")
-public class FailoverList implements Serializable {
-
- public static final long serialVersionUID = 1L;
-
- public static final String QUERY_DELETE_VIA_AGENT = "FailoverList.deletViaAgent";
- public static final String QUERY_DELETE_VIA_PARTITION_EVENT = "FailoverList.deletViaPartitionEvent";
- public static final String QUERY_GET_VIA_AGENT = "FailoverList.getViaAgent";
- public static final String QUERY_TRUNCATE = "FailoverList.truncate";
-
- @Column(name = "ID", nullable = false)
- @GeneratedValue(strategy = GenerationType.AUTO, generator = "id")
- @Id
- private int id;
-
- @JoinColumn(name = "PARTITION_EVENT_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne
- protected PartitionEvent partitionEvent;
-
- @JoinColumn(name = "AGENT_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne(fetch = FetchType.LAZY)
- protected Agent agent;
-
- @Column(name = "AGENT_ID", insertable = false, updatable = false)
- private int agentId;
-
- @Column(name = "CTIME", nullable = false)
- private long ctime;
-
- @OneToMany(mappedBy = "failoverList", cascade = CascadeType.ALL)
- @OrderBy("ordinal ASC")
- private List<FailoverListDetails> serverList = new ArrayList<FailoverListDetails>();
-
- // required for JPA
- protected FailoverList() {
- }
-
- public FailoverList(PartitionEvent event, Agent agent) {
- this.partitionEvent = event;
- this.agent = agent;
- }
-
- public PartitionEvent getPartitionEvent() {
- return partitionEvent;
- }
-
- public void setPartitionEvent(PartitionEvent partitionEvent) {
- this.partitionEvent = partitionEvent;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public Agent getAgent() {
- return agent;
- }
-
- public void setAgent(Agent agent) {
- this.agent = agent;
- }
-
- public long getCtime() {
- return ctime;
- }
-
- public List<FailoverListDetails> getServerList() {
- return serverList;
- }
-
- public void setServerList(List<FailoverListDetails> serverList) {
- this.serverList = serverList;
- }
-
- @PrePersist
- void onPersist() {
- this.ctime = System.currentTimeMillis();
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + agentId;
- result = prime * result + (int) (ctime ^ (ctime >>> 32));
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj == null || !(obj instanceof FailoverList)) {
- return false;
- }
-
- final FailoverList other = (FailoverList) obj;
-
- if (agentId != other.agentId) {
- return false;
- }
-
- if (ctime != other.ctime) {
- return false;
- }
-
- return true;
- }
-}
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.cloud;
+
+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.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderBy;
+import javax.persistence.PrePersist;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+
+import org.rhq.core.domain.resource.Agent;
+
+/**
+ * An object to capture a snapshot of the order in which particular agents
+ * will fail over to particular servers. The {@link FailoverListDetails}
+ * will contain the ordered references back to other {@link Server}s.
+ *
+ * @author jmarques
+ *
+ */
+@Entity(name = "FailoverList")
+@NamedQueries( //
+{
+ @NamedQuery(name = FailoverList.QUERY_DELETE_VIA_AGENT, query = "DELETE FROM FailoverList fl WHERE fl.agent = :agent"),
+ @NamedQuery(name = FailoverList.QUERY_DELETE_VIA_PARTITION_EVENT, query = "DELETE FROM FailoverList fl WHERE fl.partitionEvent = :partitionEvent"),
+ @NamedQuery(name = FailoverList.QUERY_GET_VIA_AGENT, query = "SELECT fl FROM FailoverList fl WHERE fl.agent = :agent"),
+ @NamedQuery(name = FailoverList.QUERY_TRUNCATE, query = "DELETE FROM FailoverList") })
+@SequenceGenerator(name = "id", sequenceName = "RHQ_FAILOVER_LIST_ID_SEQ")
+@Table(name = "RHQ_FAILOVER_LIST")
+public class FailoverList implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+
+ public static final String QUERY_DELETE_VIA_AGENT = "FailoverList.deletViaAgent";
+ public static final String QUERY_DELETE_VIA_PARTITION_EVENT = "FailoverList.deletViaPartitionEvent";
+ public static final String QUERY_GET_VIA_AGENT = "FailoverList.getViaAgent";
+ public static final String QUERY_TRUNCATE = "FailoverList.truncate";
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "id")
+ @Id
+ private int id;
+
+ @JoinColumn(name = "PARTITION_EVENT_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne(optional = false)
+ protected PartitionEvent partitionEvent;
+
+ @JoinColumn(name = "AGENT_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
+ protected Agent agent;
+
+ @Column(name = "AGENT_ID", insertable = false, updatable = false)
+ private int agentId;
+
+ @Column(name = "CTIME", nullable = false)
+ private long ctime;
+
+ @OneToMany(mappedBy = "failoverList", cascade = CascadeType.ALL)
+ @OrderBy("ordinal ASC")
+ private List<FailoverListDetails> serverList = new ArrayList<FailoverListDetails>();
+
+ // required for JPA
+ protected FailoverList() {
+ }
+
+ public FailoverList(PartitionEvent event, Agent agent) {
+ this.partitionEvent = event;
+ this.agent = agent;
+ }
+
+ public PartitionEvent getPartitionEvent() {
+ return partitionEvent;
+ }
+
+ public void setPartitionEvent(PartitionEvent partitionEvent) {
+ this.partitionEvent = partitionEvent;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public Agent getAgent() {
+ return agent;
+ }
+
+ public void setAgent(Agent agent) {
+ this.agent = agent;
+ }
+
+ public long getCtime() {
+ return ctime;
+ }
+
+ public List<FailoverListDetails> getServerList() {
+ return serverList;
+ }
+
+ public void setServerList(List<FailoverListDetails> serverList) {
+ this.serverList = serverList;
+ }
+
+ @PrePersist
+ void onPersist() {
+ this.ctime = System.currentTimeMillis();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + agentId;
+ result = prime * result + (int) (ctime ^ (ctime >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null || !(obj instanceof FailoverList)) {
+ return false;
+ }
+
+ final FailoverList other = (FailoverList) obj;
+
+ if (agentId != other.agentId) {
+ return false;
+ }
+
+ if (ctime != other.ctime) {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/FailoverListDetails.java b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/FailoverListDetails.java
index 51ae161..53b98b0 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/FailoverListDetails.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/FailoverListDetails.java
@@ -1,169 +1,169 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.rhq.core.domain.cloud;
-
-import java.io.Serializable;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.Table;
-
-/**
- * An object to capture a snapshot of the order in which particular agents
- * will fail over to particular servers. The {@link FailoverListDetails}
- * will contain the ordered references back to other {@link Server}s.
- *
- * @author jmarques
- * @author jshaughnessy
- *
- */
-@Entity(name = "FailoverListDetails")
-@NamedQueries( //
-{
- @NamedQuery(name = FailoverListDetails.QUERY_GET_VIA_AGENT_ID, query = "SELECT fld FROM FailoverListDetails fld WHERE fld.failoverList IN ( SELECT fl FROM FailoverList fl WHERE fl.agent.id = :agentId )"),
- @NamedQuery(name = FailoverListDetails.QUERY_GET_VIA_AGENT_ID_WITH_SERVERS, query = "SELECT fld FROM FailoverListDetails fld JOIN FETCH fld.server WHERE fld.failoverList IN ( SELECT fl FROM FailoverList fl WHERE fl.agent.id = :agentId )"),
- @NamedQuery(name = FailoverListDetails.QUERY_DELETE_VIA_AGENT, query = "DELETE FROM FailoverListDetails fld WHERE fld.failoverList IN ( SELECT fl FROM FailoverList fl WHERE fl.agent = :agent )"),
- @NamedQuery(name = FailoverListDetails.QUERY_DELETE_VIA_SERVER, query = "DELETE FROM FailoverListDetails fld WHERE fld.server.id = :serverId"),
- @NamedQuery(name = FailoverListDetails.QUERY_GET_ASSIGNED_LOADS, query = "SELECT new org.rhq.core.domain.cloud.composite.FailoverListDetailsComposite(fld.ordinal, fld.serverId, COUNT(fld.serverId)) FROM FailoverListDetails fld GROUP BY fld.ordinal, fld.serverId ORDER BY fld.ordinal ASC"),
- @NamedQuery(name = FailoverListDetails.QUERY_TRUNCATE, query = "DELETE FROM FailoverListDetails") })
-@SequenceGenerator(name = "id", sequenceName = "RHQ_FAILOVER_DETAILS_ID_SEQ")
-@Table(name = "RHQ_FAILOVER_DETAILS")
-public class FailoverListDetails implements Serializable {
-
- public static final long serialVersionUID = 1L;
-
- public static final String QUERY_GET_VIA_AGENT_ID = "FailoverListDetails.getViaAgentId";
- public static final String QUERY_GET_VIA_AGENT_ID_WITH_SERVERS = "FailoverListDetails.getViaAgentIdWithServers";
- public static final String QUERY_DELETE_VIA_AGENT = "FailoverListDetails.deleteViaAgent";
- public static final String QUERY_DELETE_VIA_SERVER = "FailoverListDetails.deleteViaServer";
- public static final String QUERY_GET_ASSIGNED_LOADS = "FailoverListDetails.getAssignedLoads";
- public static final String QUERY_TRUNCATE = "FailoverListDetails.truncate";
-
- @Column(name = "ID", nullable = false)
- @GeneratedValue(strategy = GenerationType.AUTO, generator = "id")
- @Id
- private int id;
-
- @JoinColumn(name = "FAILOVER_LIST_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne
- protected FailoverList failoverList;
-
- @Column(name = "ORDINAL", nullable = false)
- private int ordinal;
-
- @JoinColumn(name = "SERVER_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne(fetch = FetchType.LAZY)
- protected Server server;
-
- @Column(name = "SERVER_ID", insertable = false, updatable = false)
- private int serverId;
-
- // required for JPA
- protected FailoverListDetails() {
- }
-
- public FailoverListDetails(FailoverList failoverList, int ordinal, Server server) {
- super();
- this.failoverList = failoverList;
- this.ordinal = ordinal;
- this.server = server;
- this.serverId = server.getId();
- }
-
- public FailoverList getFailoverList() {
- return failoverList;
- }
-
- public void setFailoverList(FailoverList failoverList) {
- this.failoverList = failoverList;
- }
-
- public int getOrdinal() {
- return ordinal;
- }
-
- public void setOrdinal(int ordinal) {
- this.ordinal = ordinal;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public Server getServer() {
- return server;
- }
-
- public void setServer(Server agent) {
- this.server = agent;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + serverId;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj == null || !(obj instanceof FailoverListDetails)) {
- return false;
- }
-
- final FailoverListDetails other = (FailoverListDetails) obj;
-
- if (failoverList == null) {
- if (other.failoverList != null) {
- return false;
- }
- } else if (!failoverList.equals(other.failoverList)) {
- return false;
- }
-
- if (ordinal != other.ordinal) {
- return false;
- }
-
- return true;
- }
-
-}
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.domain.cloud;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+
+/**
+ * An object to capture a snapshot of the order in which particular agents
+ * will fail over to particular servers. The {@link FailoverListDetails}
+ * will contain the ordered references back to other {@link Server}s.
+ *
+ * @author jmarques
+ * @author jshaughnessy
+ *
+ */
+@Entity(name = "FailoverListDetails")
+@NamedQueries( //
+{
+ @NamedQuery(name = FailoverListDetails.QUERY_GET_VIA_AGENT_ID, query = "SELECT fld FROM FailoverListDetails fld WHERE fld.failoverList IN ( SELECT fl FROM FailoverList fl WHERE fl.agent.id = :agentId )"),
+ @NamedQuery(name = FailoverListDetails.QUERY_GET_VIA_AGENT_ID_WITH_SERVERS, query = "SELECT fld FROM FailoverListDetails fld JOIN FETCH fld.server WHERE fld.failoverList IN ( SELECT fl FROM FailoverList fl WHERE fl.agent.id = :agentId )"),
+ @NamedQuery(name = FailoverListDetails.QUERY_DELETE_VIA_AGENT, query = "DELETE FROM FailoverListDetails fld WHERE fld.failoverList IN ( SELECT fl FROM FailoverList fl WHERE fl.agent = :agent )"),
+ @NamedQuery(name = FailoverListDetails.QUERY_DELETE_VIA_SERVER, query = "DELETE FROM FailoverListDetails fld WHERE fld.server.id = :serverId"),
+ @NamedQuery(name = FailoverListDetails.QUERY_GET_ASSIGNED_LOADS, query = "SELECT new org.rhq.core.domain.cloud.composite.FailoverListDetailsComposite(fld.ordinal, fld.serverId, COUNT(fld.serverId)) FROM FailoverListDetails fld GROUP BY fld.ordinal, fld.serverId ORDER BY fld.ordinal ASC"),
+ @NamedQuery(name = FailoverListDetails.QUERY_TRUNCATE, query = "DELETE FROM FailoverListDetails") })
+@SequenceGenerator(name = "id", sequenceName = "RHQ_FAILOVER_DETAILS_ID_SEQ")
+@Table(name = "RHQ_FAILOVER_DETAILS")
+public class FailoverListDetails implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+
+ public static final String QUERY_GET_VIA_AGENT_ID = "FailoverListDetails.getViaAgentId";
+ public static final String QUERY_GET_VIA_AGENT_ID_WITH_SERVERS = "FailoverListDetails.getViaAgentIdWithServers";
+ public static final String QUERY_DELETE_VIA_AGENT = "FailoverListDetails.deleteViaAgent";
+ public static final String QUERY_DELETE_VIA_SERVER = "FailoverListDetails.deleteViaServer";
+ public static final String QUERY_GET_ASSIGNED_LOADS = "FailoverListDetails.getAssignedLoads";
+ public static final String QUERY_TRUNCATE = "FailoverListDetails.truncate";
+
+ @Column(name = "ID", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "id")
+ @Id
+ private int id;
+
+ @JoinColumn(name = "FAILOVER_LIST_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne(optional = false)
+ protected FailoverList failoverList;
+
+ @Column(name = "ORDINAL", nullable = false)
+ private int ordinal;
+
+ @JoinColumn(name = "SERVER_ID", referencedColumnName = "ID", nullable = false)
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
+ protected Server server;
+
+ @Column(name = "SERVER_ID", insertable = false, updatable = false)
+ private int serverId;
+
+ // required for JPA
+ protected FailoverListDetails() {
+ }
+
+ public FailoverListDetails(FailoverList failoverList, int ordinal, Server server) {
+ super();
+ this.failoverList = failoverList;
+ this.ordinal = ordinal;
+ this.server = server;
+ this.serverId = server.getId();
+ }
+
+ public FailoverList getFailoverList() {
+ return failoverList;
+ }
+
+ public void setFailoverList(FailoverList failoverList) {
+ this.failoverList = failoverList;
+ }
+
+ public int getOrdinal() {
+ return ordinal;
+ }
+
+ public void setOrdinal(int ordinal) {
+ this.ordinal = ordinal;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public Server getServer() {
+ return server;
+ }
+
+ public void setServer(Server agent) {
+ this.server = agent;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + serverId;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null || !(obj instanceof FailoverListDetails)) {
+ return false;
+ }
+
+ final FailoverListDetails other = (FailoverListDetails) obj;
+
+ if (failoverList == null) {
+ if (other.failoverList != null) {
+ return false;
+ }
+ } else if (!failoverList.equals(other.failoverList)) {
+ return false;
+ }
+
+ if (ordinal != other.ordinal) {
+ return false;
+ }
+
+ return true;
+ }
+
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceSyncResults.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceSyncResults.java
index b72c52a..86521d4 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceSyncResults.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/ContentSourceSyncResults.java
@@ -67,7 +67,7 @@ public class ContentSourceSyncResults implements ContentSyncResults, Serializabl
private int id;
@JoinColumn(name = "CONTENT_SRC_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne(fetch = FetchType.LAZY)
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
private ContentSource contentSource;
@Column(name = "STATUS", nullable = false)
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoSyncResults.java b/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoSyncResults.java
index e37de93..d88ab97 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoSyncResults.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/content/RepoSyncResults.java
@@ -66,7 +66,7 @@ public class RepoSyncResults implements Serializable, ContentSyncResults {
private int id;
@JoinColumn(name = "REPO_ID", referencedColumnName = "ID", nullable = false)
- @ManyToOne(fetch = FetchType.LAZY)
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
private Repo repo;
@Column(name = "STATUS", nullable = false)
@@ -168,7 +168,9 @@ public class RepoSyncResults implements Serializable, ContentSyncResults {
@Override
public String toString() {
- StringBuilder str = new StringBuilder(this.getClass().getName().substring(this.getClass().getName().lastIndexOf(".")+1) + ": ");
+ StringBuilder str = new StringBuilder(this.getClass().getName().substring(
+ this.getClass().getName().lastIndexOf(".") + 1)
+ + ": ");
str.append("start-time=[" + new Date(startTime));
str.append("], end-time=[" + ((endTime != null) ? new Date(endTime) : "---"));
str.append("], percentComplete=[" + status);