java/code/src/com/redhat/rhn/domain/server/Crash.hbm.xml | 36 +
java/code/src/com/redhat/rhn/domain/server/Crash.java | 358
++++++++++
java/code/src/com/redhat/rhn/domain/server/CrashCount.java | 1
java/code/src/com/redhat/rhn/domain/server/CrashFile.hbm.xml | 21
java/code/src/com/redhat/rhn/domain/server/CrashFile.java | 154 ++++
java/code/src/com/redhat/rhn/domain/server/Server.java | 15
java/code/src/com/redhat/rhn/domain/server/Server_legacyUser.hbm.xml | 5
java/code/src/com/redhat/rhn/frontend/xmlrpc/system/crash/CrashHandler.java | 65 +
8 files changed, 655 insertions(+)
New commits:
commit 38c33be490472d98f429fca790d1f04a80905ee3
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Fri Feb 22 17:34:15 2013 +0100
abrt: listSystemCrashes api call
diff --git a/java/code/src/com/redhat/rhn/domain/server/Crash.hbm.xml
b/java/code/src/com/redhat/rhn/domain/server/Crash.hbm.xml
new file mode 100644
index 0000000..6c7c48a
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/domain/server/Crash.hbm.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping
+PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+ <class name="com.redhat.rhn.domain.server.Crash"
table="rhnServerCrash">
+ <id name="id" column="id">
+ <generator class="sequence">
+ <param
name="sequence">rhn_server_crash_id_seq</param>
+ </generator>
+ </id>
+ <many-to-one name="server"
+ column="server_id"
+ class="com.redhat.rhn.domain.server.Server" />
+ <set name="crashFiles" cascade="all-delete-orphan"
lazy="true" inverse="true">
+ <key column="crash_id"/>
+ <one-to-many
class="com.redhat.rhn.domain.server.CrashFile"/>
+ </set>
+ <property name="crash" column="crash"
type="string"/>
+ <property name="path" column="path"
type="string"/>
+ <property name="count" column="count"
type="long"/>
+ <property name="analyzer" column="analyzer"
type="string"/>
+ <property name="architecture" column="architecture"
type="string"/>
+ <property name="cmdline" column="cmdline"
type="string"/>
+ <property name="component" column="component"
type="string"/>
+ <property name="executable" column="executable"
type="string"/>
+ <property name="kernel" column="kernel"
type="string"/>
+ <property name="reason" column="reason"
type="string"/>
+ <property name="username" column="username"
type="string"/>
+ <property name="packageNameId" column="package_name_id"
type="long"/>
+ <property name="packageEvrId" column="package_evr_id"
type="long"/>
+ <property name="packageArchId" column="package_arch_id"
type="long"/>
+ <property name="created" type="timestamp"
column="created" />
+ <property name="modified" type="timestamp"
column="modified" />
+ </class>
+</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/server/Crash.java
b/java/code/src/com/redhat/rhn/domain/server/Crash.java
new file mode 100644
index 0000000..0fb4f78
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/domain/server/Crash.java
@@ -0,0 +1,358 @@
+/**
+ * Copyright (c) 2013 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+
+package com.redhat.rhn.domain.server;
+
+import com.redhat.rhn.domain.BaseDomainHelper;
+
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * Represents a particular crash.
+ * @version $Rev$
+ */
+public class Crash extends BaseDomainHelper {
+
+ private Long id;
+ private Server server;
+ private String crash;
+ private String path;
+ private long count;
+ private String analyzer;
+ private String architecture;
+ private String cmdline;
+ private String component;
+ private String executable;
+ private String kernel;
+ private String reason;
+ private String username;
+ private long packageNameId;
+ private long packageEvrId;
+ private long packageArchId;
+ private Date created;
+ private Date modified;
+ private Set<CrashFile> crashFiles;
+
+ /**
+ * Represents application crash information.
+ */
+ public Crash() {
+ super();
+ }
+
+ /**
+ * Returns the database id of the crash.
+ * @return Returns the id.
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * Sets the database id of the crash.
+ * @param idIn The id to set.
+ */
+ public void setId(Long idIn) {
+ id = idIn;
+ }
+
+ /**
+ * The parent server.
+ * @return Returns the server.
+ */
+ public Server getServer() {
+ return server;
+ }
+
+ /**
+ * Sets the parent server.
+ * @param serverIn The server to set.
+ */
+ public void setServer(Server serverIn) {
+ server = serverIn;
+ }
+
+ /**
+ * Get the crash string.
+ * @return Returns the crash string.
+ */
+ public String getCrash() {
+ return crash;
+ }
+
+ /**
+ * Sets the crash string.
+ * @param crashIn The crash string to set.
+ */
+ public void setCrash(String crashIn) {
+ crash = crashIn;
+ }
+
+ /**
+ * Get the crash path.
+ * @return Returns the crash path.
+ */
+ public String getPath() {
+ return path;
+ }
+
+ /**
+ * Set the crash path.
+ * @param pathIn The crash path to set.
+ */
+ public void setPath(String pathIn) {
+ path = pathIn;
+ }
+
+ /**
+ * Get the crash count.
+ * @return Returns the crash count.
+ */
+ public long getCount() {
+ return count;
+ }
+
+ /**
+ * Set the crash count.
+ * @param countIn The crash count to set.
+ */
+ public void setCount(long countIn) {
+ count = countIn;
+ }
+
+ /**
+ * Get the crash analyzer.
+ * @return Returns the crash analyzer.
+ */
+ public String getAnalyzer() {
+ return analyzer;
+ }
+
+ /**
+ * Set the crash analyzer.
+ * @param analyzerIn The crash analyzer to set.
+ */
+ public void setAnalyzer(String analyzerIn) {
+ analyzer = analyzerIn;
+ }
+
+ /**
+ * Get the crash architecture.
+ * @return Returns the crash architecture.
+ */
+ public String getArchitecture() {
+ return architecture;
+ }
+
+ /**
+ * Set the crash architecture.
+ * @param architectureIn The crash architecture to set.
+ */
+ public void setArchitecture(String architectureIn) {
+ architecture = architectureIn;
+ }
+
+ /**
+ * Get the crash cmdline.
+ * @return Returns the crash cmdline.
+ */
+ public String getCmdline() {
+ return cmdline;
+ }
+
+ /**
+ * Set the crash cmdline.
+ * @param cmdlineIn The cmdline to set.
+ */
+ public void setCmdline(String cmdlineIn) {
+ cmdline = cmdlineIn;
+ }
+
+ /**
+ * Get the crash component.
+ * @return Returns the crash component.
+ */
+ public String getComponent() {
+ return component;
+ }
+
+ /**
+ * Set the crash component.
+ * @param componentIn The crash component to set.
+ */
+ public void setComponent(String componentIn) {
+ component = componentIn;
+ }
+
+ /**
+ * Get the crash executable.
+ * @return Returns the crash executable.
+ */
+ public String getExecutable() {
+ return executable;
+ }
+
+ /**
+ * Set the crash executable.
+ * @param executableIn The executable to set.
+ */
+ public void setExecutable(String executableIn) {
+ executable = executableIn;
+ }
+
+ /**
+ * Get the crash kernel.
+ * @return Returns the crash kernel.
+ */
+ public String getKernel() {
+ return kernel;
+ }
+
+ /**
+ * Set the crash kernel.
+ * @param kernelIn The crash kernel to set.
+ */
+ public void setKernel(String kernelIn) {
+ kernel = kernelIn;
+ }
+
+ /**
+ * Get the crash reason.
+ * @return Returns the crash reason.
+ */
+ public String getReason() {
+ return reason;
+ }
+
+ /**
+ * Set the crash reason.
+ * @param reasonIn The crash reason to set.
+ */
+ public void setReason(String reasonIn) {
+ reason = reasonIn;
+ }
+
+ /**
+ * Get the crash username.
+ * @return Returns the crash username.
+ */
+ public String getUsername() {
+ return username;
+ }
+
+ /**
+ * Set the crash username.
+ * @param usernameIn The username to set.
+ */
+ public void setUsername(String usernameIn) {
+ username = usernameIn;
+ }
+
+ /**
+ * Get the crash package name id.
+ * @return Returns the crash package name id.
+ */
+ public long getPackageNameId() {
+ return packageNameId;
+ }
+
+ /**
+ * Set the crash package name id.
+ * @param packageNameIdIn The crash package name id to set.
+ */
+ public void setPackageNameId(long packageNameIdIn) {
+ packageNameId = packageNameIdIn;
+ }
+
+ /**
+ * Get the crash package EVR id.
+ * @return Returns the crash package EVR id.
+ */
+ public long getPackageEvrId() {
+ return packageEvrId;
+ }
+
+ /**
+ * Set the crash package EVR id.
+ * @param packageEvrIdIn The crash package EVR id to set.
+ */
+ public void setPackageEvrId(long packageEvrIdIn) {
+ packageEvrId = packageEvrIdIn;
+ }
+
+ /**
+ * Get the crash package arch id.
+ * @return Returns the crash package arch id.
+ */
+ public long getPackageArchId() {
+ return packageArchId;
+ }
+
+ /**
+ * Set the crash package arch id.
+ * @param packageArchIdIn The package arch id to set.
+ */
+ public void setPackageArchId(long packageArchIdIn) {
+ packageArchId = packageArchIdIn;
+ }
+
+ /**
+ * Returns the created date.
+ * @return the created date.
+ */
+ public Date getCreated() {
+ return created;
+ }
+
+ /**
+ * Sets the created date.
+ * @param createdIn The create date to set.
+ */
+ public void setCreated(Date createdIn) {
+ created = createdIn;
+ }
+
+ /**
+ * Returns the modified date.
+ * @return the modified date.
+ */
+ public Date getModified() {
+ return modified;
+ }
+
+ /**
+ * Sets the modified date.
+ * @param modifiedIn The modified date to set.
+ */
+ public void setModified(Date modifiedIn) {
+ modified = modifiedIn;
+ }
+
+ /**
+ * @return Returns the crash files.
+ */
+ public Set<CrashFile> getCrashFiles() {
+ return crashFiles;
+ }
+
+ /**
+ * @param cf The crash files to set.
+ */
+ public void setCrashFiles(Set<CrashFile> cf) {
+ this.crashFiles = cf;
+ }
+
+}
diff --git a/java/code/src/com/redhat/rhn/domain/server/CrashCount.java
b/java/code/src/com/redhat/rhn/domain/server/CrashCount.java
index 6dac90e..086df03 100644
--- a/java/code/src/com/redhat/rhn/domain/server/CrashCount.java
+++ b/java/code/src/com/redhat/rhn/domain/server/CrashCount.java
@@ -12,6 +12,7 @@
* granted to use or replicate Red Hat trademarks that are incorporated
* in this software or its documentation.
*/
+
package com.redhat.rhn.domain.server;
import com.redhat.rhn.domain.BaseDomainHelper;
diff --git a/java/code/src/com/redhat/rhn/domain/server/CrashFile.hbm.xml
b/java/code/src/com/redhat/rhn/domain/server/CrashFile.hbm.xml
new file mode 100644
index 0000000..57e8068
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/domain/server/CrashFile.hbm.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping
+PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+ <class name="com.redhat.rhn.domain.server.CrashFile"
table="rhnServerCrashFile">
+ <id name="id" column="id">
+ <generator class="sequence">
+ <param
name="sequence">rhn_server_crash_file_id_seq</param>
+ </generator>
+ </id>
+ <many-to-one name="crash"
+ column="crash_id"
+ class="com.redhat.rhn.domain.server.Crash" />
+ <property name="filename" column="filename"
type="string"/>
+ <property name="path" column="path"
type="string"/>
+ <property name="filesize" column="filesize"
type="long"/>
+ <property name="created" type="timestamp"
column="created" />
+ <property name="modified" type="timestamp"
column="modified" />
+ </class>
+</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/server/CrashFile.java
b/java/code/src/com/redhat/rhn/domain/server/CrashFile.java
new file mode 100644
index 0000000..85849f4
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/domain/server/CrashFile.java
@@ -0,0 +1,154 @@
+/**
+ * Copyright (c) 2013 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+
+package com.redhat.rhn.domain.server;
+
+import com.redhat.rhn.domain.BaseDomainHelper;
+
+import java.util.Date;
+
+/**
+ * Represents the particulart file associated with a crash.
+ * @version $Rev$
+ */
+public class CrashFile extends BaseDomainHelper {
+
+ private Long id;
+ private Crash crash;
+ private String filename;
+ private String path;
+ private long filesize;
+ private Date created;
+ private Date modified;
+
+ /**
+ * Represents application crash information.
+ */
+ public CrashFile() {
+ super();
+ }
+
+ /**
+ * Returns the database id of the crash.
+ * @return Returns the id.
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * Sets the database id of the crash.
+ * @param idIn The id to set.
+ */
+ public void setId(Long idIn) {
+ id = idIn;
+ }
+
+ /**
+ * The parent Crash.
+ * @return Returns the parent crash.
+ */
+ public Crash getCrash() {
+ return crash;
+ }
+
+ /**
+ * Sets the parent crash.
+ * @param crashIn The parent crash to set.
+ */
+ public void setCrash(Crash crashIn) {
+ crash = crashIn;
+ }
+
+ /**
+ * Get the filename.
+ * @return Returns the crash filename.
+ */
+ public String getFilename() {
+ return filename;
+ }
+
+ /**
+ * Sets the filename.
+ * @param filenameIn The filename to set.
+ */
+ public void setFilename(String filenameIn) {
+ filename = filenameIn;
+ }
+
+ /**
+ * Get the file path.
+ * @return Returns the file path.
+ */
+ public String getPath() {
+ return path;
+ }
+
+ /**
+ * Set the file path.
+ * @param pathIn The file path to set.
+ */
+ public void setPath(String pathIn) {
+ path = pathIn;
+ }
+
+ /**
+ * Get the file size.
+ * @return Returns the file size.
+ */
+ public long getFilesize() {
+ return filesize;
+ }
+
+ /**
+ * Set the file size.
+ * @param filesizeIn The file size to set.
+ */
+ public void setFilesize(long filesizeIn) {
+ filesize = filesizeIn;
+ }
+
+ /**
+ * Returns the created date.
+ * @return the created date.
+ */
+ public Date getCreated() {
+ return created;
+ }
+
+ /**
+ * Sets the created date.
+ * @param createdIn The create date to set.
+ */
+ public void setCreated(Date createdIn) {
+ created = createdIn;
+ }
+
+ /**
+ * Returns the modified date.
+ * @return the modified date.
+ */
+ public Date getModified() {
+ return modified;
+ }
+
+ /**
+ * Sets the modified date.
+ * @param modifiedIn The modified date to set.
+ */
+ public void setModified(Date modifiedIn) {
+ modified = modifiedIn;
+ }
+}
diff --git a/java/code/src/com/redhat/rhn/domain/server/Server.java
b/java/code/src/com/redhat/rhn/domain/server/Server.java
index 6e00f8f..418b9ff 100644
--- a/java/code/src/com/redhat/rhn/domain/server/Server.java
+++ b/java/code/src/com/redhat/rhn/domain/server/Server.java
@@ -115,6 +115,7 @@ public class Server extends BaseDomainHelper implements Identifiable
{
private Set<? extends ServerGroup> groups;
private Set<Capability> capabilities;
private CrashCount crashCount;
+ private Set<Crash> crashes;
public static final String VALID_CNAMES = "valid_cnames_";
@@ -1959,4 +1960,18 @@ public class Server extends BaseDomainHelper implements
Identifiable {
}
return active;
}
+
+ /**
+ * @return Returns the crashes.
+ */
+ public Set<Crash> getCrashes() {
+ return crashes;
+ }
+
+ /**
+ * @param c The crashes to set.
+ */
+ public void setCrashes(Set<Crash> c) {
+ this.crashes = c;
+ }
}
diff --git a/java/code/src/com/redhat/rhn/domain/server/Server_legacyUser.hbm.xml
b/java/code/src/com/redhat/rhn/domain/server/Server_legacyUser.hbm.xml
index 5ad8431..bdad289 100644
--- a/java/code/src/com/redhat/rhn/domain/server/Server_legacyUser.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/server/Server_legacyUser.hbm.xml
@@ -121,6 +121,11 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<one-to-one name="crashCount"
class="com.redhat.rhn.domain.server.CrashCount"
cascade="all" lazy="proxy"/>
+ <set name="crashes" cascade="all-delete-orphan"
lazy="true" inverse="true">
+ <key column="server_id"/>
+ <one-to-many class="com.redhat.rhn.domain.server.Crash"/>
+ </set>
+
<one-to-one name="lock"
class="com.redhat.rhn.domain.server.ServerLock"
cascade="all" lazy="proxy"/>
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/crash/CrashHandler.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/crash/CrashHandler.java
index 1776979..0073b18 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/crash/CrashHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/crash/CrashHandler.java
@@ -18,13 +18,18 @@ package com.redhat.rhn.frontend.xmlrpc.system.crash;
import com.redhat.rhn.frontend.xmlrpc.BaseHandler;
import com.redhat.rhn.frontend.xmlrpc.NoCrashesFoundException;
import com.redhat.rhn.frontend.xmlrpc.system.XmlRpcSystemHelper;
+import com.redhat.rhn.domain.server.Crash;
import com.redhat.rhn.domain.server.CrashCount;
import com.redhat.rhn.domain.server.Server;
import com.redhat.rhn.domain.user.User;
import org.apache.log4j.Logger;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* CrashHandler
@@ -104,4 +109,64 @@ public class CrashHandler extends BaseHandler {
CrashCount crashCount = getCrashCount(server);
return crashCount.getTotalCrashCount();
}
+
+ /**
+ * Returns list of software crashes for a system.
+ * @param sessionKey Session key
+ * @param serverId Server ID
+ * @return Returns list of software crashes for given system id.
+ *
+ * @xmlrpc.doc Return list of software crashes for a system.
+ * @xmlrpc.param @param("string", "sessionKey")
+ * @xmlrpc.param #param("int", "serverId")
+ * @xmlrpc.returntype
+ * #array()
+ * #struct("crash")
+ * #prop("int", "id")
+ * #prop("string", "crash")
+ * #prop("string", "path")
+ * #prop("int", "count")
+ * #prop("string", "analyzer")
+ * #prop("string", "architecture")
+ * #prop("string", "cmdline")
+ * #prop("string", "component")
+ * #prop("string", "executable")
+ * #prop("string", "kernel")
+ * #prop("string", "reason")
+ * #prop("string", "username")
+ * #prop("date", "created")
+ * #prop("date", "modified")
+ * #struct_end()
+ * #array_end()
+ */
+ public List listSystemCrashes(String sessionKey, Integer serverId) {
+ User loggedInUser = getLoggedInUser(sessionKey);
+ XmlRpcSystemHelper sysHelper = XmlRpcSystemHelper.getInstance();
+ Server server = sysHelper.lookupServer(loggedInUser, serverId);
+
+ List returnList = new ArrayList();
+
+ for (Crash crash : server.getCrashes()) {
+ Map crashMap = new HashMap();
+ crashMap.put("id", crash.getId());
+ crashMap.put("crash", crash.getCrash());
+ crashMap.put("path", crash.getPath());
+ crashMap.put("count", crash.getCount());
+ crashMap.put("analyzer", crash.getAnalyzer());
+ crashMap.put("architecture", crash.getArchitecture());
+ crashMap.put("cmdline", crash.getCmdline());
+ crashMap.put("component", crash.getComponent());
+ crashMap.put("executable", crash.getExecutable());
+ crashMap.put("kernel", crash.getKernel());
+ crashMap.put("reason", crash.getReason());
+ crashMap.put("username", crash.getUsername());
+ // FIXME: package info
+ crashMap.put("created", crash.getCreated());
+ crashMap.put("modified", crash.getModified());
+
+ returnList.add(crashMap);
+ }
+
+ return returnList;
+ }
}