java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml | 3
java/code/src/com/redhat/rhn/frontend/xmlrpc/NoCrashesFoundException.java | 35 +++
java/code/src/com/redhat/rhn/frontend/xmlrpc/handler-manifest.xml | 2
java/code/src/com/redhat/rhn/frontend/xmlrpc/system/crash/CrashHandler.java | 107
++++++++++
4 files changed, 147 insertions(+)
New commits:
commit 5c3b1a712038880e3b32253ec47cb50d6708b229
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Wed Feb 20 16:48:18 2013 +0100
abrt: xml-rpc api for crash count information
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
index c56e5c6..f9ef85a 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
@@ -6889,6 +6889,9 @@ Follow this url to see the full list of inactive systems:
<trans-unit id="api.systemgroup.serverNotInGroup">
<source>The specified server is not a member of the specified
group</source>
</trans-unit>
+ <trans-unit id="api.system.crash.nocrashesfound">
+ <source>No crashes recorded for the specified system.</source>
+ </trans-unit>
<trans-unit id="api.errata.invalidadvisorytype">
<source>Invalid errata type, "{0}". Please use one of the
following: "Security Advisory", "Product Enhancement Advisory", or
"Bug Fix Advisory".</source>
</trans-unit>
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/NoCrashesFoundException.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/NoCrashesFoundException.java
new file mode 100644
index 0000000..d935eed
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/NoCrashesFoundException.java
@@ -0,0 +1,35 @@
+/**
+ * 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.frontend.xmlrpc;
+
+import com.redhat.rhn.FaultException;
+import com.redhat.rhn.common.localization.LocalizationService;
+
+/**
+ * No Crashes Exception
+ *
+ * @version $Rev$
+ */
+public class NoCrashesFoundException extends FaultException {
+
+ /**
+ * NoCrashesFoundException
+ */
+ public NoCrashesFoundException() {
+ super(1071, "No Crashes Found" , LocalizationService.getInstance().
+ getMessage("api.system.crash.nocrashesfound", new Object []
{}));
+ }
+}
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/handler-manifest.xml
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/handler-manifest.xml
index d14aebb..9174ab7 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/handler-manifest.xml
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/handler-manifest.xml
@@ -8,6 +8,8 @@
<template name="packages.provider"
classname="com.redhat.rhn.frontend.xmlrpc.packages.provider.PackagesProviderHandler"
/>
<template name="system"
classname="com.redhat.rhn.frontend.xmlrpc.system.SystemHandler" />
<template name="system.config"
classname="com.redhat.rhn.frontend.xmlrpc.system.config.ServerConfigHandler"/>
+ <template name="system.config"
classname="com.redhat.rhn.frontend.xmlrpc.system.config.ServerConfigHandler"/>
+ <template name="system.crash"
classname="com.redhat.rhn.frontend.xmlrpc.system.crash.CrashHandler"/>
<template name="system.custominfo"
classname="com.redhat.rhn.frontend.xmlrpc.system.custominfo.CustomInfoHandler"/>
<template name="system.provisioning.snapshot"
classname="com.redhat.rhn.frontend.xmlrpc.system.provisioning.snapshot.SnapshotHandler"/>
<template name="system.scap"
classname="com.redhat.rhn.frontend.xmlrpc.system.scap.SystemScapHandler"/>
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
new file mode 100644
index 0000000..1776979
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/crash/CrashHandler.java
@@ -0,0 +1,107 @@
+/**
+ * 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.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.CrashCount;
+import com.redhat.rhn.domain.server.Server;
+import com.redhat.rhn.domain.user.User;
+
+import org.apache.log4j.Logger;
+
+import java.util.Date;
+
+/**
+ * CrashHandler
+ * @version $Rev$
+ * @xmlrpc.namespace system.crash
+ * @xmlrpc.doc Provides methods to access and modify software crash information.
+ */
+public class CrashHandler extends BaseHandler {
+
+ private static Logger log = Logger.getLogger(SystemCrashHandler.class);
+
+ private CrashCount getCrashCount(Server serverIn) {
+ CrashCount crashCount = serverIn.getCrashCount();
+ if (crashCount == null) {
+ throw new NoCrashesFoundException();
+ }
+ return crashCount;
+ }
+
+ /**
+ * Return date of last software crashes report for given system.
+ * @param sessionKey Session key
+ * @param serverId Server ID
+ * @return Date of the last software crash report.
+ *
+ * @xmlrpc.doc Return date of last software crashes report for given system
+ * @xmlrpc.param @param("string", "sessionKey")
+ * @xmlrpc.param #param("int", "serverId")
+ * @xmlrpc.returntype dateTime.iso8601 - Date of the last software crash report.
+ */
+ public Date getLastReportDate(String sessionKey, Integer serverId) {
+ User loggedInUser = getLoggedInUser(sessionKey);
+ XmlRpcSystemHelper sysHelper = XmlRpcSystemHelper.getInstance();
+ Server server = sysHelper.lookupServer(loggedInUser, serverId);
+
+ CrashCount crashCount = getCrashCount(server);
+ return crashCount.getLastReport();
+ }
+
+
+ /**
+ * Return number of unique software crashes for given system.
+ * @param sessionKey Session key
+ * @param serverId Server ID
+ * @return Number of unique software crashes.
+ *
+ * @xmlrpc.doc Return number of unique software recorded crashes for given system
+ * @xmlrpc.param @param("string", "sessionKey")
+ * @xmlrpc.param #param("int", "serverId")
+ * @xmlrpc.returntype int - Number of unique software crashes
+ */
+ public long getUniqueCrashCount(String sessionKey, Integer serverId) {
+ User loggedInUser = getLoggedInUser(sessionKey);
+ XmlRpcSystemHelper sysHelper = XmlRpcSystemHelper.getInstance();
+ Server server = sysHelper.lookupServer(loggedInUser, serverId);
+
+ CrashCount crashCount = getCrashCount(server);
+ return crashCount.getUniqueCrashCount();
+ }
+
+ /**
+ * Return total number of software recorded crashes for given system.
+ * @param sessionKey Session key
+ * @param serverId Server ID
+ * @return Total number of recorded software crashes.
+ *
+ * @xmlrpc.doc Return total number of software recorded crashes for given system
+ * @xmlrpc.param @param("string", "sessionKey")
+ * @xmlrpc.param #param("int", "serverId")
+ * @xmlrpc.returntype int - Total number of recorded software crashes
+ */
+ public long getTotalCrashCount(String sessionKey, Integer serverId) {
+ User loggedInUser = getLoggedInUser(sessionKey);
+ XmlRpcSystemHelper sysHelper = XmlRpcSystemHelper.getInstance();
+ Server server = sysHelper.lookupServer(loggedInUser, serverId);
+
+ CrashCount crashCount = getCrashCount(server);
+ return crashCount.getTotalCrashCount();
+ }
+}