branding/css/rhn-special-styles.css | 4 java/code/src/com/redhat/rhn/common/db/datasource/xml/Set_queries.xml | 16 + java/code/src/com/redhat/rhn/common/db/datasource/xml/scap_queries.xml | 19 + java/code/src/com/redhat/rhn/domain/action/ActionFactory.java | 15 + java/code/src/com/redhat/rhn/domain/action/server/ServerAction.hbm.xml | 6 java/code/src/com/redhat/rhn/domain/audit/ScapFactory.java | 9 java/code/src/com/redhat/rhn/domain/audit/XccdfTestResult.hbm.xml | 2 java/code/src/com/redhat/rhn/domain/audit/XccdfTestResult.java | 26 ++ java/code/src/com/redhat/rhn/domain/org/OrgConfig.hbm.xml | 1 java/code/src/com/redhat/rhn/domain/org/OrgConfig.java | 18 + java/code/src/com/redhat/rhn/domain/rhnset/RhnSetFactory.java | 10 java/code/src/com/redhat/rhn/domain/rhnset/SetCleanup.java | 2 java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgConfigAction.java | 19 + java/code/src/com/redhat/rhn/frontend/action/systems/audit/ListScapAction.java | 55 +++-- java/code/src/com/redhat/rhn/frontend/action/systems/audit/ScapDownloadAction.java | 20 - java/code/src/com/redhat/rhn/frontend/action/systems/audit/XccdfDeleteConfirmAction.java | 110 ++++++++++ java/code/src/com/redhat/rhn/frontend/dto/XccdfTestResultDto.java | 14 + java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml | 38 +++ java/code/src/com/redhat/rhn/frontend/struts/BaseSetHelper.java | 2 java/code/src/com/redhat/rhn/manager/audit/ScapManager.java | 48 ++++ java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapFileManager.java | 27 ++ java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapResultFile.java | 16 + java/code/src/com/redhat/rhn/manager/rhnset/RhnSetDecl.java | 2 java/code/webapp/WEB-INF/nav/system_detail.xml | 1 java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp | 39 +++ java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list-columns.jspf | 34 +++ java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list.jspf | 52 +--- java/code/webapp/WEB-INF/pages/systems/details/audit/xccdfdeleteconfirm.jsp | 47 ++++ java/code/webapp/WEB-INF/pages/systems/details/audit/xccdfdetails.jsp | 10 java/code/webapp/WEB-INF/struts-config.xml | 15 + schema/spacewalk/common/tables/rhnOrgConfiguration.sql | 4 schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/011-rhnOrgConfiguration-scapret.sql | 4 32 files changed, 601 insertions(+), 84 deletions(-)
New commits: commit ac7293ff55358ce0279d49058780223a52972427 Author: Simon Lukasik slukasik@redhat.com Date: Wed Jul 31 14:37:12 2013 +0200
Refactor common columns to a fragment file.
diff --git a/java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list-columns.jspf b/java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list-columns.jspf new file mode 100644 index 0000000..68e478d --- /dev/null +++ b/java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list-columns.jspf @@ -0,0 +1,34 @@ +<rl:column headerkey="system.audit.listscap.jsp.testresult"> + <c:choose> + <c:when test="${not empty current.comparableId}"> + <a href="/rhn/audit/scap/DiffSubmit.do?first=${current.comparableId}&second=${current.xid}&view=changed"> + <img src="/img/rhn-listicon-${current.diffIcon}.gif" + alt="<bean:message key="scapdiff.jsp.i.${current.diffIcon}"/>" + title="<bean:message key="scapdiff.jsp.i.${current.diffIcon}"/>"/></a> + </c:when> + <c:otherwise> + <img src="/img/icon_checkin.gif" + alt="<bean:message key="system.audit.xccdfdetails.jsp.nodiff"/>" + title="<bean:message key="system.audit.xccdfdetails.jsp.nodiff"/>"/> + </c:otherwise> + </c:choose> + + <a href="/rhn/systems/details/audit/XccdfDetails.do?sid=${param.sid}&xid=${current.xid}"> + ${current.testResult} + </a> +</rl:column> +<rl:column headerkey="system.audit.listscap.jsp.completed"> + ${current.completed} +</rl:column> +<rl:column headerkey="system.audit.listscap.jsp.percentage"> + <c:choose> + <c:when test="${current.sum - current.notselected - current.informational == 0}"> + <bean:message key="system.audit.listscap.jsp.na"/> + </c:when> + <c:otherwise> + <fmt:formatNumber maxFractionDigits="0" + value="${current.pass * 100 / (current.sum - current.notselected - current.informational)}"/> + % + </c:otherwise> + </c:choose> +</rl:column> diff --git a/java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list.jspf b/java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list.jspf index 8c6861b..e38e9bd 100644 --- a/java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list.jspf +++ b/java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list.jspf @@ -7,40 +7,8 @@ <rl:decorator name="SelectableDecorator"/> <rl:selectablecolumn value="${current.xid}" selected="${current.selected}" disabled="${not current.selectable}"/>
- <rl:column headerkey="system.audit.listscap.jsp.testresult"> - <c:choose> - <c:when test="${not empty current.comparableId}"> - <a href="/rhn/audit/scap/DiffSubmit.do?first=${current.comparableId}&second=${current.xid}&view=changed"> - <img src="/img/rhn-listicon-${current.diffIcon}.gif" - alt="<bean:message key="scapdiff.jsp.i.${current.diffIcon}"/>" - title="<bean:message key="scapdiff.jsp.i.${current.diffIcon}"/>"/></a> - </c:when> - <c:otherwise> - <img src="/img/icon_checkin.gif" - alt="<bean:message key="system.audit.xccdfdetails.jsp.nodiff"/>" - title="<bean:message key="system.audit.xccdfdetails.jsp.nodiff"/>"/> - </c:otherwise> - </c:choose> + <%@ include file="/WEB-INF/pages/common/fragments/audit/scap-list-columns.jspf" %>
- <a href="/rhn/systems/details/audit/XccdfDetails.do?sid=${param.sid}&xid=${current.xid}"> - ${current.testResult} - </a> - </rl:column> - <rl:column headerkey="system.audit.listscap.jsp.completed"> - ${current.completed} - </rl:column> - <rl:column headerkey="system.audit.listscap.jsp.percentage"> - <c:choose> - <c:when test="${current.sum - current.notselected - current.informational == 0}"> - <bean:message key="system.audit.listscap.jsp.na"/> - </c:when> - <c:otherwise> - <fmt:formatNumber maxFractionDigits="0" - value="${current.pass * 100 / (current.sum - current.notselected - current.informational)}"/> - % - </c:otherwise> - </c:choose> - </rl:column> <rl:column headerkey="system.audit.listscap.jsp.pass.abb"> ${current.pass} </rl:column> diff --git a/java/code/webapp/WEB-INF/pages/systems/details/audit/xccdfdeleteconfirm.jsp b/java/code/webapp/WEB-INF/pages/systems/details/audit/xccdfdeleteconfirm.jsp index d02d0f8..d5b9c40 100644 --- a/java/code/webapp/WEB-INF/pages/systems/details/audit/xccdfdeleteconfirm.jsp +++ b/java/code/webapp/WEB-INF/pages/systems/details/audit/xccdfdeleteconfirm.jsp @@ -21,41 +21,8 @@ <rl:list dataset="pageList" name="xccdfScans"> <rl:decorator name="ElaborationDecorator"/>
- <rl:column headerkey="system.audit.listscap.jsp.testresult"> - <c:choose> - <c:when test="${not empty current.comparableId}"> - <a href="/rhn/audit/scap/DiffSubmit.do?first=${current.comparableId}&second=${current.xid}&view=changed"> - <img src="/img/rhn-listicon-${current.diffIcon}.gif" - alt="<bean:message key="scapdiff.jsp.i.${current.diffIcon}"/>" - title="<bean:message key="scapdiff.jsp.i.${current.diffIcon}"/>"/></a> - </c:when> - <c:otherwise> - <img src="/img/icon_checkin.gif" - alt="<bean:message key="system.audit.xccdfdetails.jsp.nodiff"/>" - title="<bean:message key="system.audit.xccdfdetails.jsp.nodiff"/>"/> - </c:otherwise> - </c:choose> + <%@ include file="/WEB-INF/pages/common/fragments/audit/scap-list-columns.jspf" %>
- <a href="/rhn/systems/details/audit/XccdfDetails.do?sid=${param.sid}&xid=${current.xid}"> - ${current.testResult} - </a> - </rl:column> - <rl:column headerkey="system.audit.listscap.jsp.completed"> - ${current.completed} - </rl:column> - <rl:column headerkey="system.audit.listscap.jsp.percentage"> - <c:choose> - <c:when test="${current.sum - current.notselected - current.informational == 0}"> - <bean:message key="system.audit.listscap.jsp.na"/> - </c:when> - <c:otherwise> - <fmt:formatNumber maxFractionDigits="0" - value="${current.pass * 100 / - (current.sum - current.notselected - current.informational)}"/> - % - </c:otherwise> - </c:choose> - </rl:column> <rl:column headerkey="system.audit.xccdfdeleteconfirm.jsp.deletable"> <c:choose> <c:when test="${current.deletable}">
commit 84db0b36d6819055d7d7b504b136cb2c49ce67aa Author: Simon Lukasik slukasik@redhat.com Date: Wed Jul 31 11:23:25 2013 +0200
Handle non-existent files properly.
Addressing: 2013-07-30 07:38:07,927 [TP-Processor3] WARN org.apache.struts.action.RequestProcessor - Unhandled Exception thrown: class java.io.FileNotFoundException 2013-07-30 07:38:07,927 [TP-Processor3] ERROR com.redhat.rhn.frontend.servlets.SessionFilter - Error during transaction. Rolling back java.io.FileNotFoundException: /var/satellite/systems/1/1000010000/actions/158/xccdf-report.html (Permission denied) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:137) at java.io.FileInputStream.<init>(FileInputStream.java:96) at com.redhat.rhn.manager.audit.scap.file.ScapResultFile.getInputStream(ScapResultFile.java:81) at org.apache.struts.actions.DownloadAction.execute(DownloadAction.java:106) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228) ...
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml index b864f3f..9106660 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml @@ -275,6 +275,9 @@ <trans-unit id="lookup.xccdfscan.title"> <source>We're sorry, but the XCCDF scan could not be found.</source> </trans-unit> + <trans-unit id="lookup.scapfile.title"> + <source>We're sorry, but the requested SCAP results file could not be found.</source> + </trans-unit> <trans-unit id="missing_capabilities.jsp.header"> <source>Missing Capabilities</source> </trans-unit> diff --git a/java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapResultFile.java b/java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapResultFile.java index d70f925..12ec5d2 100644 --- a/java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapResultFile.java +++ b/java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapResultFile.java @@ -20,6 +20,8 @@ import java.io.InputStream;
import org.apache.struts.actions.DownloadAction.StreamInfo;
+import com.redhat.rhn.common.hibernate.LookupException; +import com.redhat.rhn.common.localization.LocalizationService; import com.redhat.rhn.domain.audit.XccdfTestResult;
/** @@ -77,8 +79,18 @@ public class ScapResultFile implements StreamInfo { /** * {@inheritDoc} */ - public InputStream getInputStream() throws IOException { - return new FileInputStream(getAbsolutePath()); + public InputStream getInputStream() { + try { + return new FileInputStream(getAbsolutePath()); + } + catch (IOException e) { + e.printStackTrace(); + LocalizationService ls = LocalizationService.getInstance(); + LookupException le = new LookupException("Could not server file '" + + filename + "' for XCCDF Scan " + testResult.getId()); + le.setLocalizedTitle(ls.getMessage("lookup.scapfile.title")); + throw le; + } }
/**
commit 3145e60c29fcb89f233cd4427c14aa144f3e4ed0 Author: Simon Lukasik slukasik@redhat.com Date: Tue Jul 30 17:54:18 2013 +0200
Remove commented-out code, commited by accident.
diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/audit/ScapDownloadAction.java b/java/code/src/com/redhat/rhn/frontend/action/systems/audit/ScapDownloadAction.java index 56d68fe..5d4f854 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/systems/audit/ScapDownloadAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/systems/audit/ScapDownloadAction.java @@ -34,26 +34,6 @@ import com.redhat.rhn.manager.system.SystemManager; * ScapDownloadAction */ public class ScapDownloadAction extends DownloadAction { -/* - public ActionForward execute(ActionMapping mapping, ActionForm formIn, - HttpServletRequest request, - HttpServletResponse response) { - - response.setHeader("Content- - - try { - OutputStream - - request.setAttribute("testResult", testResult); - request.setAttribute("system", server); - - request.setAttribute(ListTagHelper.PARENT_URL, - request.getRequestURI() + "?sid=" + sid + "&xid=" + xid); - SdcHelper.ssmCheck(request, sid, user); - - return mapping.findForward(RhnHelper.DEFAULT_FORWARD); - } -*/ @Override protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
commit 6b4ccd79947802919d3922815045c2b6672b7dd6 Author: Simon Lukasik slukasik@redhat.com Date: Tue Jul 30 17:32:11 2013 +0200
Do not delete content of the directory which you cannot list
Addressing: 2013-07-30 11:29:25,250 [TP-Processor1] ERROR com.redhat.rhn.frontend.servlets.SessionFilter - Error during transaction. Rolling back javax.servlet.ServletException: java.lang.NullPointerException at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:520) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:427) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228) at com.redhat.rhn.frontend.struts.RhnRequestProcessor.process(RhnRequestProcessor.java:102) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) ... Caused by: java.lang.NullPointerException at com.redhat.rhn.manager.audit.scap.file.ScapFileManager.deleteFilesForTestResult(ScapFileManager.java:64) at com.redhat.rhn.manager.audit.ScapManager.deleteScan(ScapManager.java:310) at com.redhat.rhn.manager.audit.ScapManager.deleteScansInSet(ScapManager.java:295) at com.redhat.rhn.frontend.action.systems.audit.XccdfDeleteConfirmAction.execute(XccdfDeleteConfirmAction.java:86) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425) ... 40 more
diff --git a/java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapFileManager.java b/java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapFileManager.java index d7eec9d..806fac6 100644 --- a/java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapFileManager.java +++ b/java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapFileManager.java @@ -61,8 +61,11 @@ public class ScapFileManager { public static void deleteFilesForTestResult(XccdfTestResult tr) { File folder = new File(getStoragePath(tr)); if (folder.exists() && folder.isDirectory()) { - for (File file : folder.listFiles()) { - file.delete(); + File[] files = folder.listFiles(); + if (files != null) { + for (File file : files) { + file.delete(); + } } folder.delete(); }
commit 6bbe628e65d2189d9e3bf01f51871891af292d36 Author: Simon Lukasik slukasik@redhat.com Date: Tue Jul 30 17:24:12 2013 +0200
Make sure to not iterate through null.
The previous checks for existence and isDirectory() are not enough, because the directory might not be accessible (think of permission).
Addressing: 2013-07-30 11:18:12,993 [TP-Processor8] ERROR com.redhat.rhn.frontend.servlets.SessionFilter - Error during transaction. Rolling back javax.el.ELException: Error reading 'files' on type com.redhat.rhn.domain.audit.XccdfTestResult at javax.el.BeanELResolver.getValue(BeanELResolver.java:66) at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54) at org.apache.el.parser.AstValue.getValue(AstValue.java:118) at org.apache.el.parser.AstEmpty.getValue(AstEmpty.java:45) at org.apache.el.parser.AstNot.getValue(AstNot.java:42) ... Caused by: java.lang.NullPointerException at com.redhat.rhn.manager.audit.scap.file.ScapFileManager.lookupFilesForTestResult(ScapFileManager.java:47) at com.redhat.rhn.domain.audit.XccdfTestResult.getFiles(XccdfTestResult.java:231) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:616) at javax.el.BeanELResolver.getValue(BeanELResolver.java:62) ... 58 more
diff --git a/java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapFileManager.java b/java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapFileManager.java index 3354c8b..d7eec9d 100644 --- a/java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapFileManager.java +++ b/java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapFileManager.java @@ -43,10 +43,12 @@ public class ScapFileManager { if (!folder.exists() || !folder.isDirectory()) { return result; } - - for (File file : folder.listFiles()) { - if (file.isFile()) { - result.add(new ScapResultFile(testResult, file.getName())); + File[] files = folder.listFiles(); + if (files != null) { + for (File file : files) { + if (file.isFile()) { + result.add(new ScapResultFile(testResult, file.getName())); + } } } return result;
commit d4fccbc495c501bb12a01f8fd90d43bb06d39b9f Author: Simon Lukasik slukasik@redhat.com Date: Tue Jul 30 14:39:27 2013 +0200
Reconcile the set of scans with existing scans after deletion
The delete operation might have removed some of the scans from database. These removed scans should be also removed from the set. The rest of the set is kept untouched to allow user to continue working with it.
diff --git a/java/code/src/com/redhat/rhn/domain/rhnset/RhnSetFactory.java b/java/code/src/com/redhat/rhn/domain/rhnset/RhnSetFactory.java index 2f5937b..0364400 100644 --- a/java/code/src/com/redhat/rhn/domain/rhnset/RhnSetFactory.java +++ b/java/code/src/com/redhat/rhn/domain/rhnset/RhnSetFactory.java @@ -150,6 +150,16 @@ public class RhnSetFactory extends HibernateFactory { simpl.sync(); }
+ /** + * Cleanup the set. That is useful, when some of the items included in the set were + * removed from database. That might have invalidated part of the set. + * @param set RhnSet to cleanup. + */ + public static void cleanup(RhnSet set) { + RhnSetImpl simpl = (RhnSetImpl) set; + simpl.getCleanup().cleanup(simpl); // Even palindrom can save the day. + } + private static WriteMode writeMode(String modeName) { return ModeFactory.getWriteMode(CATALOG, modeName); } diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/audit/XccdfDeleteConfirmAction.java b/java/code/src/com/redhat/rhn/frontend/action/systems/audit/XccdfDeleteConfirmAction.java index 1f514fd..0e7e970 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/systems/audit/XccdfDeleteConfirmAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/systems/audit/XccdfDeleteConfirmAction.java @@ -81,7 +81,13 @@ public class XccdfDeleteConfirmAction extends RhnAction { request.setAttribute(RequestContext.PAGE_LIST, result);
if (context.wasDispatched(CONFIRM_BUT)) { - Long removedCount = ScapManager.deleteScansInSet(result); + Long removedCount = null; + try { + removedCount = ScapManager.deleteScansInSet(result); + } + finally { + RhnSetFactory.cleanup(set); + } Long retainedCount = result.size() - removedCount; ActionMessages msg = (removedCount == 0) ? new ActionErrors() : new ActionMessages();
commit f6422571e3f22991e6ce9970eca182283263633c Author: Simon Lukasik slukasik@redhat.com Date: Tue Jul 16 15:42:23 2013 +0200
Allow deletion of a single scan from its details page
diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/audit/XccdfDeleteConfirmAction.java b/java/code/src/com/redhat/rhn/frontend/action/systems/audit/XccdfDeleteConfirmAction.java index ea547aa..1f514fd 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/systems/audit/XccdfDeleteConfirmAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/systems/audit/XccdfDeleteConfirmAction.java @@ -29,6 +29,7 @@ import org.apache.struts.action.ActionMessages;
import com.redhat.rhn.common.db.datasource.DataResult; import com.redhat.rhn.domain.rhnset.RhnSet; +import com.redhat.rhn.domain.rhnset.RhnSetFactory; import com.redhat.rhn.domain.server.Server; import com.redhat.rhn.domain.user.User; import com.redhat.rhn.frontend.dto.XccdfTestResultDto; @@ -59,6 +60,16 @@ public class XccdfDeleteConfirmAction extends RhnAction { User user = context.getCurrentUser();
RhnSet set = getSetDecl(sid).get(user); + if (request.getParameter("xid") != null) { + Long xid = Long.parseLong(request.getParameter("xid")); + if (xid != null && xid > 0) { + // Being redirected from XccdfDetails.do, asked to delete a single scan + set.clear(); + set.addElement(xid); + RhnSetFactory.save(set); + } + } + DataResult<XccdfTestResultDto> result = ScapManager.scansInSet(user, set.getLabel());
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml index e02be82..b864f3f 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml @@ -11145,6 +11145,9 @@ the <strong>Red Hat Enterprise Linux System Administration Guide.</stro <trans-unit id="system.audit.xccdfdetails.jsp.reschedule"> <source>reschedule</source> </trans-unit> + <trans-unit id="system.audit.xccdfdelete"> + <source>delete scan</source> + </trans-unit> </group> <group> <context-group name="ctx"> diff --git a/java/code/webapp/WEB-INF/pages/systems/details/audit/xccdfdetails.jsp b/java/code/webapp/WEB-INF/pages/systems/details/audit/xccdfdetails.jsp index f22ddb1..771c10d 100644 --- a/java/code/webapp/WEB-INF/pages/systems/details/audit/xccdfdetails.jsp +++ b/java/code/webapp/WEB-INF/pages/systems/details/audit/xccdfdetails.jsp @@ -28,6 +28,16 @@ </c:choose> |
+ <c:if test="${testResult.deletable}"> + <a href="/rhn/systems/details/audit/XccdfDeleteConfirm.do?sid=${param.sid}&xid=${testResult.id}"> + <img src="/img/action-del.gif" + alt="<bean:message key="system.audit.xccdfdelete"/>" + title="<bean:message key="system.audit.xccdfdelete"/>"/> + <bean:message key="system.audit.xccdfdelete"/> + </a> + | + </c:if> + <a href="/rhn/systems/details/audit/ScheduleXccdf.do?sid=${param.sid}&path=${testResult.scapActionDetails.path}¶ms=${testResult.scapActionDetails.parametersContents}"> <img src="/img/restart.png" alt="<bean:message key="system.audit.xccdfdetails.jsp.reschedule"/>"/> <bean:message key="system.audit.xccdfdetails.jsp.reschedule"/>
commit a8eb5185e2917d1d3d9c4a786116caa6c259c205 Author: Simon Lukasik <slukasik@redhat.com> Date: Tue Jul 30 11:38:28 2013 +0200
Use the red tint if none has been deleted.
diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/audit/XccdfDeleteConfirmAction.java b/java/code/src/com/redhat/rhn/frontend/action/systems/audit/XccdfDeleteConfirmAction.java index bd2073d..ea547aa 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/systems/audit/XccdfDeleteConfirmAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/systems/audit/XccdfDeleteConfirmAction.java @@ -20,6 +20,7 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;
+import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; @@ -71,7 +72,8 @@ public class XccdfDeleteConfirmAction extends RhnAction { if (context.wasDispatched(CONFIRM_BUT)) { Long removedCount = ScapManager.deleteScansInSet(result); Long retainedCount = result.size() - removedCount; - ActionMessages msg = new ActionMessages(); + ActionMessages msg = (removedCount == 0) ? + new ActionErrors() : new ActionMessages(); String[] messageParams = {removedCount.toString(), retainedCount.toString()}; msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( "system.audit.xccdfdeleteconfirm.jsp.message", messageParams));
commit bb6ee805c0a5bec13a582d0c113398cde5e68957 Author: Simon Lukasik <slukasik@redhat.com> Date: Tue Jul 30 11:07:16 2013 +0200
Allow XccdfTestResult objects to be deleted.
Addressing: [TP-Processor9] ERROR org.hibernate.cache.ReadOnlyCache - Application attempted to edit read only item: com.redhat.rhn.domain.audit.XccdfTestResult#73 [TP-Processor9] WARN org.apache.struts.action.RequestProcessor - Unhandled Exception thrown: class java.lang.UnsupportedOperationException [TP-Processor9] ERROR com.redhat.rhn.frontend.servlets.SessionFilter - Error during transaction. Rolling back javax.servlet.ServletException: java.lang.UnsupportedOperationException: Can't write to a readonly object at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:520) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:427) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228) at com.redhat.rhn.frontend.struts.RhnRequestProcessor.process(RhnRequestProcessor.java:102) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
diff --git a/java/code/src/com/redhat/rhn/domain/audit/XccdfTestResult.hbm.xml b/java/code/src/com/redhat/rhn/domain/audit/XccdfTestResult.hbm.xml index 0e88a2f..b456078 100644 --- a/java/code/src/com/redhat/rhn/domain/audit/XccdfTestResult.hbm.xml +++ b/java/code/src/com/redhat/rhn/domain/audit/XccdfTestResult.hbm.xml @@ -6,7 +6,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" <class name="com.redhat.rhn.domain.audit.XccdfTestResult" table="rhnXccdfTestresult" mutable="false"> - <cache usage="read-only"/> + <cache usage="read-write"/> <id name="id" type="long" column="id"> <meta attribute="scope-set">protected</meta> <generator class="assigned"/> diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml index b719cd9..e02be82 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml @@ -11084,7 +11084,7 @@ the <strong>Red Hat Enterprise Linux System Administration Guide.</stro <source>Only those SCAP Scans can be deleted which have passed their retention period. Retention period can be set in the Organization Configuration dialog.</source> </trans-unit> <trans-unit id="system.audit.xccdfdeleteconfirm.jsp.message"> - <source>{0} SCAP Scan(s) successfully removed. {1} SCAP Scan(s) retained</source> + <source>{0} SCAP Scan(s) deleted. {1} SCAP Scan(s) retained</source> </trans-unit> </group> <group>
commit 8eaaafa017e5ca438b480df960a87cb48befa2b4 Author: Simon Lukasik <slukasik@redhat.com> Date: Mon Jul 22 16:26:55 2013 +0200
Deletion of multiple XCCDF Scans.
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/scap_queries.xml b/java/code/src/com/redhat/rhn/common/db/datasource/xml/scap_queries.xml index b8916f1..1fab607 100644 --- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/scap_queries.xml +++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/scap_queries.xml @@ -12,6 +12,25 @@ </query> </mode>
+<mode name="scans_in_set" class="com.redhat.rhn.frontend.dto.XccdfTestResultDto"> + <elaborator name="testresult_counts"/> + <query params="user_id, set_label"> + SELECT tr.id as xid, + tr.identifier as test_result, + sa.completion_time as completed + FROM rhnXccdfTestresult tr, + rhnActionScap ras, + rhnServerAction sa, + rhnSet st + WHERE tr.id = st.element + AND st.user_id = :user_id + AND st.label = :set_label + AND tr.action_Scap_id = ras.id + AND sa.server_id = tr.server_id + AND sa.action_id = ras.action_id + ORDER BY tr.id DESC + </query> +</mode> <mode name="show_system_scans" class="com.redhat.rhn.frontend.dto.XccdfTestResultDto"> <elaborator name="testresult_counts"/> <query params="sid"> diff --git a/java/code/src/com/redhat/rhn/domain/audit/ScapFactory.java b/java/code/src/com/redhat/rhn/domain/audit/ScapFactory.java index ae8e2eb..fd4e763 100644 --- a/java/code/src/com/redhat/rhn/domain/audit/ScapFactory.java +++ b/java/code/src/com/redhat/rhn/domain/audit/ScapFactory.java @@ -63,6 +63,15 @@ public class ScapFactory extends HibernateFactory { } return result; } + + /** + * Delete XCCDF TestResult + * @param tr XCCDF TestResult to delete + */ + public static void delete(XccdfTestResult tr) { + singleton.removeObject(tr); + } + /** * Get the Logger for the derived class so log messages * show up on the correct class. diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/audit/ListScapAction.java b/java/code/src/com/redhat/rhn/frontend/action/systems/audit/ListScapAction.java index 30c04c8..8335883 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/systems/audit/ListScapAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/systems/audit/ListScapAction.java @@ -14,6 +14,9 @@ */ package com.redhat.rhn.frontend.action.systems.audit;
+import java.util.HashMap; +import java.util.Map; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;
@@ -24,6 +27,7 @@ import org.apache.struts.action.ActionMapping; import com.redhat.rhn.common.db.datasource.DataResult; import com.redhat.rhn.domain.rhnset.RhnSet; import com.redhat.rhn.domain.server.Server; +import com.redhat.rhn.domain.user.User; import com.redhat.rhn.frontend.struts.RequestContext; import com.redhat.rhn.frontend.struts.RhnHelper; import com.redhat.rhn.frontend.struts.RhnListSetHelper; @@ -40,6 +44,7 @@ import com.redhat.rhn.manager.rhnset.RhnSetManager;
public class ListScapAction extends ScapSetupAction { private static final String LIST_NAME = "xccdfScans"; + private static final String DELET_BUT = "system.audit.listscap.jsp.removebut";
/** * {@inheritDoc} @@ -77,6 +82,12 @@ public class ListScapAction extends ScapSetupAction { request.getRequestURI() + "?sid=" + sid); request.setAttribute(RequestContext.PAGE_LIST, result);
+ if (context.wasDispatched(DELET_BUT) && getSetDecl(sid).get(user).size() > 0) { + Map<String, Long> params = new HashMap<String, Long>(); + params.put("sid", sid); + return getStrutsDelegate().forwardParams(mapping.findForward("submitDelete"), + params); + } return mapping.findForward(RhnHelper.DEFAULT_FORWARD); }
diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/audit/XccdfDeleteConfirmAction.java b/java/code/src/com/redhat/rhn/frontend/action/systems/audit/XccdfDeleteConfirmAction.java new file mode 100644 index 0000000..bd2073d --- /dev/null +++ b/java/code/src/com/redhat/rhn/frontend/action/systems/audit/XccdfDeleteConfirmAction.java @@ -0,0 +1,91 @@ +/** + * 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.action.systems.audit; + +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; + +import com.redhat.rhn.common.db.datasource.DataResult; +import com.redhat.rhn.domain.rhnset.RhnSet; +import com.redhat.rhn.domain.server.Server; +import com.redhat.rhn.domain.user.User; +import com.redhat.rhn.frontend.dto.XccdfTestResultDto; +import com.redhat.rhn.frontend.struts.RequestContext; +import com.redhat.rhn.frontend.struts.RhnAction; +import com.redhat.rhn.frontend.struts.RhnHelper; +import com.redhat.rhn.frontend.taglibs.list.ListTagHelper; +import com.redhat.rhn.frontend.taglibs.list.TagHelper; +import com.redhat.rhn.manager.audit.ScapManager; +import com.redhat.rhn.manager.rhnset.RhnSetDecl; + +/** + * XccdfDeleteConfirmAction + */ +public class XccdfDeleteConfirmAction extends RhnAction { + private static final String CONFIRM_BUT = "confirm.jsp.confirm"; + private static final String LIST_NAME = "xccdfScans"; + + /** + * {@inheritDoc} + */ + public ActionForward execute(ActionMapping mapping, ActionForm formIn, + HttpServletRequest request, + HttpServletResponse response) { + RequestContext context = new RequestContext(request); + Long sid = context.getRequiredParam(RequestContext.SID); + Server server = context.lookupAndBindServer(); + User user = context.getCurrentUser(); + + RhnSet set = getSetDecl(sid).get(user); + DataResult<XccdfTestResultDto> result = ScapManager.scansInSet(user, + set.getLabel()); + + TagHelper.bindElaboratorTo(LIST_NAME, result.getElaborator(), request); + + request.setAttribute(RequestContext.SID, sid); + request.setAttribute(ListTagHelper.PARENT_URL, + request.getRequestURI() + "?" + RequestContext.SID + "=" + sid); + request.setAttribute(RequestContext.PAGE_LIST, result); + + if (context.wasDispatched(CONFIRM_BUT)) { + Long removedCount = ScapManager.deleteScansInSet(result); + Long retainedCount = result.size() - removedCount; + ActionMessages msg = new ActionMessages(); + String[] messageParams = {removedCount.toString(), retainedCount.toString()}; + msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( + "system.audit.xccdfdeleteconfirm.jsp.message", messageParams)); + getStrutsDelegate().saveMessages(request, msg); + Map<String, Long> params = new HashMap<String, Long>(); + params.put(RequestContext.SID, sid); + return getStrutsDelegate().forwardParams(mapping.findForward("submit"), + params); + } + + return mapping.findForward(RhnHelper.DEFAULT_FORWARD); + } + + protected RhnSetDecl getSetDecl(Long sid) { + return RhnSetDecl.XCCDF_TESTRESULTS.createCustom(sid); + } +} diff --git a/java/code/src/com/redhat/rhn/frontend/dto/XccdfTestResultDto.java b/java/code/src/com/redhat/rhn/frontend/dto/XccdfTestResultDto.java index 11f87b8..b58f3cd 100644 --- a/java/code/src/com/redhat/rhn/frontend/dto/XccdfTestResultDto.java +++ b/java/code/src/com/redhat/rhn/frontend/dto/XccdfTestResultDto.java @@ -16,11 +16,13 @@ package com.redhat.rhn.frontend.dto;
import java.util.Date;
+import com.redhat.rhn.domain.audit.ScapFactory; +import com.redhat.rhn.domain.audit.XccdfTestResult; import com.redhat.rhn.manager.audit.ScapManager; import com.redhat.rhn.manager.audit.scap.RuleResultDiffer;
/** - * Simple DTO for transfering data from the DB to the UI through datasource. + * Simple DTO for transferring data from the DB to the UI through datasource. * @version $Rev$ */ public class XccdfTestResultDto extends XccdfTestResultCounts { @@ -180,4 +182,14 @@ public class XccdfTestResultDto extends XccdfTestResultCounts { } return diffIcon; } + + /** + * Return true if this TestResult can be deleted (based on the organization's + * SCAP retention policy. + * @return the result + */ + public Boolean getDeletable() { + XccdfTestResult tr = ScapFactory.lookupTestResultById(xid); + return tr.getDeletable(); + } } diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml index 861baa7..b719cd9 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml @@ -11066,6 +11066,26 @@ the <strong>Red Hat Enterprise Linux System Administration Guide.</stro <trans-unit id="system.audit.listscap.jsp.na"> <source>N/A</source> </trans-unit> + <trans-unit id="system.audit.listscap.jsp.removebut"> + <source>Remove Selected Scans</source> + </trans-unit> + </group> + <group> + <context-group name="ctx"> + <context context-type="sourcefile">Confirmation dialog for deletion of SCAP scans for given system</context> + </context-group> + <trans-unit id="system.audit.xccdfdeleteconfirm.jsp.overview"> + <source>Confirm Deletion of OpenSCAP Scans</source> + </trans-unit> + <trans-unit id="system.audit.xccdfdeleteconfirm.jsp.deletable"> + <source>Deletable</source> + </trans-unit> + <trans-unit id="system.audit.xccdfdeleteconfirm.jsp.tip"> + <source>Only those SCAP Scans can be deleted which have passed their retention period. Retention period can be set in the Organization Configuration dialog.</source> + </trans-unit> + <trans-unit id="system.audit.xccdfdeleteconfirm.jsp.message"> + <source>{0} SCAP Scan(s) successfully removed. {1} SCAP Scan(s) retained</source> + </trans-unit> </group> <group> <context-group name="ctx"> diff --git a/java/code/src/com/redhat/rhn/manager/audit/ScapManager.java b/java/code/src/com/redhat/rhn/manager/audit/ScapManager.java index 8f2800f..2238de7 100644 --- a/java/code/src/com/redhat/rhn/manager/audit/ScapManager.java +++ b/java/code/src/com/redhat/rhn/manager/audit/ScapManager.java @@ -26,6 +26,8 @@ import com.redhat.rhn.common.db.datasource.ModeFactory; import com.redhat.rhn.common.db.datasource.SelectMode; import com.redhat.rhn.common.hibernate.LookupException; import com.redhat.rhn.domain.action.scap.ScapAction; +import com.redhat.rhn.domain.audit.ScapFactory; +import com.redhat.rhn.domain.audit.XccdfTestResult; import com.redhat.rhn.domain.server.Server; import com.redhat.rhn.domain.user.User; import com.redhat.rhn.frontend.dto.XccdfIdentDto; @@ -33,6 +35,7 @@ import com.redhat.rhn.frontend.dto.XccdfRuleResultDto; import com.redhat.rhn.frontend.dto.XccdfTestResultDto; import com.redhat.rhn.manager.BaseManager; import com.redhat.rhn.manager.action.ActionManager; +import com.redhat.rhn.manager.audit.scap.file.ScapFileManager; import com.redhat.rhn.manager.rhnset.RhnSetDecl;
/** @@ -105,6 +108,21 @@ public class ScapManager extends BaseManager { }
/** + * Show brief results of scans in given set + * @param user The user owning the set + * @param setLabel The label of the set + * @return The list of scan results in brief + */ + public static DataResult<XccdfTestResultDto> scansInSet(User user, String setLabel) { + SelectMode m = ModeFactory.getMode("scap_queries", + "scans_in_set"); + HashMap<String, Object> params = new HashMap<String, Object>(); + params.put("user_id", user.getId()); + params.put("set_label", setLabel); + return makeDataResult(params, new HashMap<String, Object>(), null, m); + } + + /** * Show xccdf:rule-result results for given test * @param testResultId of XccdfTestResult of the test for which to search * @return the list of rule-results @@ -266,6 +284,36 @@ public class ScapManager extends BaseManager { return m.execute(params).size() >= 1; }
+ /** + * Delete XccdfTestResults specified by set. + * @param set Set of TestResults to delete + * @return a number of successfully removed testResult + */ + public static Long deleteScansInSet(Iterable<XccdfTestResultDto> set) { + Long deleted = new Long(0); + for (XccdfTestResultDto dto : set) { + if (deleteScan(dto.getXid())) { + deleted++; + } + } + return deleted; + } + + /** + * Delete given XccdfTestResult together with stored files + * @param xid ID of TestResult to delete + * @return true if the deletion was successfull + */ + public static Boolean deleteScan(Long xid) { + XccdfTestResult tr = ScapFactory.lookupTestResultById(xid); + if (tr.getDeletable()) { + ScapFileManager.deleteFilesForTestResult(tr); + ScapFactory.delete(tr); + return true; + } + return false; + } + private static HashSet<Long> idsInDataResultToSet(DataResult dataIn) { HashSet<Long> result = new HashSet<Long>(); for (Map<String, Long> map : (List<Map<String, Long>>) dataIn) { diff --git a/java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapFileManager.java b/java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapFileManager.java index ef0583d..3354c8b 100644 --- a/java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapFileManager.java +++ b/java/code/src/com/redhat/rhn/manager/audit/scap/file/ScapFileManager.java @@ -53,6 +53,20 @@ public class ScapFileManager { }
/** + * Remove any files assigned with the given testResult + * @param tr XccdfTestResult + */ + public static void deleteFilesForTestResult(XccdfTestResult tr) { + File folder = new File(getStoragePath(tr)); + if (folder.exists() && folder.isDirectory()) { + for (File file : folder.listFiles()) { + file.delete(); + } + folder.delete(); + } + } + + /** * Get file path to the storage directory assigned with a given testResult * @param tr TestResult * @return the path diff --git a/java/code/webapp/WEB-INF/nav/system_detail.xml b/java/code/webapp/WEB-INF/nav/system_detail.xml index 4afb74f..5d2cdf9 100644 --- a/java/code/webapp/WEB-INF/nav/system_detail.xml +++ b/java/code/webapp/WEB-INF/nav/system_detail.xml @@ -200,6 +200,7 @@ <rhn-tab-url>/rhn/systems/details/audit/ListScap.do</rhn-tab-url> <rhn-tab-url>/rhn/systems/details/audit/XccdfDetails.do</rhn-tab-url> <rhn-tab-url>/rhn/systems/details/audit/RuleDetails.do</rhn-tab-url> + <rhn-tab-url>/rhn/systems/details/audit/XccdfDeleteConfirm.do</rhn-tab-url> </rhn-tab> <rhn-tab name="nav.system.audit.schedule" acl="system_has_management_entitlement()"> <rhn-tab-url>/rhn/systems/details/audit/ScheduleXccdf.do</rhn-tab-url> diff --git a/java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list.jspf b/java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list.jspf index 3b247af..8c6861b 100644 --- a/java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list.jspf +++ b/java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list.jspf @@ -75,6 +75,14 @@ <rl:csv name="xccdfScans" dataset="pageList" exportColumns="xid,testResult,completed,pass,fail,error,unknown,notapplicable,notchecked,notselected,informational,fixed,sum"/>
+<p align="right"> + <input type="submit" name="dispatch" value="<bean:message key="system.audit.listscap.jsp.removebut"/>" + <c:choose> + <c:when test="${empty pageList}">disabled</c:when> + </c:choose> + > +</p> + </rl:listset>
<rhn:tooltip><bean:message key="system.audit.listscap.jsp.tooltip"/></rhn:tooltip> diff --git a/java/code/webapp/WEB-INF/pages/systems/details/audit/xccdfdeleteconfirm.jsp b/java/code/webapp/WEB-INF/pages/systems/details/audit/xccdfdeleteconfirm.jsp new file mode 100644 index 0000000..d02d0f8 --- /dev/null +++ b/java/code/webapp/WEB-INF/pages/systems/details/audit/xccdfdeleteconfirm.jsp @@ -0,0 +1,80 @@ +<%@ taglib uri="http://rhn.redhat.com/rhn" prefix="rhn" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> +<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> +<%@ taglib uri="http://rhn.redhat.com/tags/list" prefix="rl" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> + +<html:xhtml/> +<html> + +<body> + +<%@ include file="/WEB-INF/pages/common/fragments/systems/system-header.jspf" %> + +<h2><bean:message key="system.audit.xccdfdeleteconfirm.jsp.overview"/></h2> + +<rl:listset name="xccdfScans"> + <rhn:csrf/> + <input type="hidden" name="sid" value="${param.sid}"> + + <rl:list dataset="pageList" name="xccdfScans"> + <rl:decorator name="ElaborationDecorator"/> + + <rl:column headerkey="system.audit.listscap.jsp.testresult"> + <c:choose> + <c:when test="${not empty current.comparableId}"> + <a href="/rhn/audit/scap/DiffSubmit.do?first=${current.comparableId}&second=${current.xid}&view=changed"> + <img src="/img/rhn-listicon-${current.diffIcon}.gif" + alt="<bean:message key="scapdiff.jsp.i.${current.diffIcon}"/>" + title="<bean:message key="scapdiff.jsp.i.${current.diffIcon}"/>"/></a> + </c:when> + <c:otherwise> + <img src="/img/icon_checkin.gif" + alt="<bean:message key="system.audit.xccdfdetails.jsp.nodiff"/>" + title="<bean:message key="system.audit.xccdfdetails.jsp.nodiff"/>"/> + </c:otherwise> + </c:choose> + + <a href="/rhn/systems/details/audit/XccdfDetails.do?sid=${param.sid}&xid=${current.xid}"> + ${current.testResult} + </a> + </rl:column> + <rl:column headerkey="system.audit.listscap.jsp.completed"> + ${current.completed} + </rl:column> + <rl:column headerkey="system.audit.listscap.jsp.percentage"> + <c:choose> + <c:when test="${current.sum - current.notselected - current.informational == 0}"> + <bean:message key="system.audit.listscap.jsp.na"/> + </c:when> + <c:otherwise> + <fmt:formatNumber maxFractionDigits="0" + value="${current.pass * 100 / + (current.sum - current.notselected - current.informational)}"/> + % + </c:otherwise> + </c:choose> + </rl:column> + <rl:column headerkey="system.audit.xccdfdeleteconfirm.jsp.deletable"> + <c:choose> + <c:when test="${current.deletable}"> + <img src="/img/rhn-listicon-checked_immutable.gif"> + </c:when> + <c:otherwise> + <img src="/img/rhn-listicon-unchecked_immutable.gif"> + </c:otherwise> + </c:choose> + </rl:column> + </rl:list> + + <p align="right"> + <input type="submit" name="dispatch" value="<bean:message key="confirm.jsp.confirm"/>"> + </p> +</rl:listset> + +<span class="small-text"> + <bean:message key="system.audit.xccdfdeleteconfirm.jsp.tip"/> +</span> +</body> +</html> diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index d5b62ed..e6059c6 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -3000,6 +3000,20 @@ <set-property property="postRequiredIfSubmitted" value="true"/> <forward name="default" path="/WEB-INF/pages/systems/details/audit/listscap.jsp"/> + <forward name="submitDelete" + path="/systems/details/audit/XccdfDeleteConfirm.do" redirect="true"/> + </action> + + <action path="/systems/details/audit/XccdfDeleteConfirm" + scope="request" + input="/WEB-INF/pages/systems/details/audit/xccdfdeleteconfirm.jsp" + type="com.redhat.rhn.frontend.action.systems.audit.XccdfDeleteConfirmAction" + className="com.redhat.rhn.frontend.struts.RhnActionMapping"> + <set-property property="postRequiredIfSubmitted" value="true"/> + <forward name="default" + path="/WEB-INF/pages/systems/details/audit/xccdfdeleteconfirm.jsp"/> + <forward name="submit" + path="/systems/details/audit/ListScap.do" redirect="true"/> </action>
<action path="/systems/details/audit/ScheduleXccdf"
commit 02ffde3756b516aabfb5ae5f6aaa1e97a86cbaa5 Author: Simon Lukasik slukasik@redhat.com Date: Wed Jul 17 17:15:06 2013 +0200
Allow for scans at the System's scans listing page to be selected
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Set_queries.xml b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Set_queries.xml index b61f5a4..ec4aba6 100644 --- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Set_queries.xml +++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Set_queries.xml @@ -395,4 +395,20 @@ DELETE </query> </write-mode>
+<write-mode name="remove_inaccessible_xccdf_results"> + <query params="user_id, label"> + DELETE FROM rhnSet st + WHERE st.user_id = :user_id + AND st.label = :label + AND NOT EXISTS (SELECT 1 FROM rhnUserServerPerms usp, + rhnServerAction sa, + rhnActionScap ras, + rhnXccdfTestresult tr + WHERE usp.user_id = st.user_id + AND usp.server_id = sa.server_id + AND sa.action_id = ras.action_id + AND ras.id = tr.action_scap_id + AND tr.id = st.element) + </query> +</write-mode> </datasource_modes> diff --git a/java/code/src/com/redhat/rhn/domain/rhnset/SetCleanup.java b/java/code/src/com/redhat/rhn/domain/rhnset/SetCleanup.java index 47e0241..b9006ab 100644 --- a/java/code/src/com/redhat/rhn/domain/rhnset/SetCleanup.java +++ b/java/code/src/com/redhat/rhn/domain/rhnset/SetCleanup.java @@ -80,6 +80,8 @@ public class SetCleanup { new SetCleanup("remove_inaccessible_config_files"); public static final SetCleanup INACCESSIBLE_CONFIG_CHANNELS = new SetCleanup("remove_inaccessible_config_channels"); + public static final SetCleanup INACCESSIBLE_XCCDF_RESULTS = + new SetCleanup("remove_inaccessible_xccdf_results");
private String catalogName; private String modeName; diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/audit/ListScapAction.java b/java/code/src/com/redhat/rhn/frontend/action/systems/audit/ListScapAction.java index 25ea384..30c04c8 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/systems/audit/ListScapAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/systems/audit/ListScapAction.java @@ -14,8 +14,6 @@ */ package com.redhat.rhn.frontend.action.systems.audit;
-import java.util.List; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;
@@ -24,21 +22,24 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping;
import com.redhat.rhn.common.db.datasource.DataResult; +import com.redhat.rhn.domain.rhnset.RhnSet; import com.redhat.rhn.domain.server.Server; import com.redhat.rhn.frontend.struts.RequestContext; import com.redhat.rhn.frontend.struts.RhnHelper; +import com.redhat.rhn.frontend.struts.RhnListSetHelper; import com.redhat.rhn.frontend.taglibs.list.ListTagHelper; import com.redhat.rhn.frontend.taglibs.list.TagHelper; -import com.redhat.rhn.frontend.taglibs.list.helper.ListHelper; -import com.redhat.rhn.frontend.taglibs.list.helper.Listable; import com.redhat.rhn.manager.audit.ScapManager; +import com.redhat.rhn.manager.rhnset.RhnSetDecl; +import com.redhat.rhn.manager.rhnset.RhnSetManager;
/** * ListScapAction * @version $Rev$ */
-public class ListScapAction extends ScapSetupAction implements Listable { +public class ListScapAction extends ScapSetupAction { + private static final String LIST_NAME = "xccdfScans";
/** * {@inheritDoc} @@ -48,25 +49,38 @@ public class ListScapAction extends ScapSetupAction implements Listable { HttpServletResponse response) { RequestContext context = new RequestContext(request); Long sid = context.getRequiredParam("sid"); + Server server = context.lookupAndBindServer(); + User user = context.getCurrentUser(); setupScapEnablementInfo(context);
- ListHelper helper = new ListHelper(this, request); - helper.execute(); + DataResult result = ScapManager.allScans(server); + RhnListSetHelper helper = new RhnListSetHelper(request); + + RhnSet set = getSetDecl(sid).get(user); + if (!context.isSubmitted()) { + RhnSetManager.store(set); + } + if (ListTagHelper.getListAction(LIST_NAME, request) != null) { + helper.execute(set, LIST_NAME, result); + } + + if (!set.isEmpty()) { + helper.syncSelections(set, result); + ListTagHelper.setSelectedAmount(LIST_NAME, set.size(), request); + } + + ListTagHelper.bindSetDeclTo(LIST_NAME, getSetDecl(sid), request); + TagHelper.bindElaboratorTo(LIST_NAME, result.getElaborator(), request);
+ request.setAttribute("sid", sid); request.setAttribute(ListTagHelper.PARENT_URL, request.getRequestURI() + "?sid=" + sid); + request.setAttribute(RequestContext.PAGE_LIST, result);
return mapping.findForward(RhnHelper.DEFAULT_FORWARD); }
- /** - * {@inheritDoc} - */ - public List getResult(RequestContext context) { - Server server = context.lookupAndBindServer(); - DataResult results = ScapManager.allScans(server); - TagHelper.bindElaboratorTo("groupSet", results.getElaborator(), - context.getRequest()); - return results; + protected RhnSetDecl getSetDecl(Long sid) { + return RhnSetDecl.XCCDF_TESTRESULTS.createCustom(sid); } } diff --git a/java/code/src/com/redhat/rhn/manager/rhnset/RhnSetDecl.java b/java/code/src/com/redhat/rhn/manager/rhnset/RhnSetDecl.java index 9c5df7c..d62ec41 100644 --- a/java/code/src/com/redhat/rhn/manager/rhnset/RhnSetDecl.java +++ b/java/code/src/com/redhat/rhn/manager/rhnset/RhnSetDecl.java @@ -393,6 +393,8 @@ public class RhnSetDecl {
public static final RhnSetDecl ISS_LOCAL_ORGS = make( "iss_local_orgs", SetCleanup.NOOP); + public static final RhnSetDecl XCCDF_TESTRESULTS = make( + "xccdf_testresults", SetCleanup.INACCESSIBLE_XCCDF_RESULTS);
private SetCleanup cleanup; private String label; diff --git a/java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list.jspf b/java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list.jspf index 22d0f89..3b247af 100644 --- a/java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list.jspf +++ b/java/code/webapp/WEB-INF/pages/common/fragments/audit/scap-list.jspf @@ -1,8 +1,11 @@ -<rl:listset name="groupSet" legend="xccdf"> +<rl:listset name="xccdfScans" legend="xccdf"> <rhn:csrf /> + <input type="hidden" name="sid" value="${param.sid}">
- <rl:list emptykey="system.audit.listscap.jsp.noscans"> + <rl:list emptykey="system.audit.listscap.jsp.noscans" dataset="pageList" name="xccdfScans"> <rl:decorator name="ElaborationDecorator"/> + <rl:decorator name="SelectableDecorator"/> + <rl:selectablecolumn value="${current.xid}" selected="${current.selected}" disabled="${not current.selectable}"/>
<rl:column headerkey="system.audit.listscap.jsp.testresult"> <c:choose> @@ -69,8 +72,9 @@ ${current.sum} </rl:column> </rl:list> - <rl:csv name="groupSet" + <rl:csv name="xccdfScans" dataset="pageList" exportColumns="xid,testResult,completed,pass,fail,error,unknown,notapplicable,notchecked,notselected,informational,fixed,sum"/> + </rl:listset>
rhn:tooltip<bean:message key="system.audit.listscap.jsp.tooltip"/></rhn:tooltip> diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index 2df85f0..d5b62ed 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -2997,6 +2997,7 @@ input="/WEB-INF/pages/systems/details/audit/listscap.jsp" type="com.redhat.rhn.frontend.action.systems.audit.ListScapAction" className="com.redhat.rhn.frontend.struts.RhnActionMapping"> + <set-property property="postRequiredIfSubmitted" value="true"/> <forward name="default" path="/WEB-INF/pages/systems/details/audit/listscap.jsp"/> </action>
commit 3a1d19143fb52ddda879aa893a73f07dbfd802b4 Author: Simon Lukasik slukasik@redhat.com Date: Mon Jul 15 19:02:23 2013 +0200
Prepare model for deletion of a SCAP Result
diff --git a/java/code/src/com/redhat/rhn/domain/action/ActionFactory.java b/java/code/src/com/redhat/rhn/domain/action/ActionFactory.java index a70fb07..b634453 100644 --- a/java/code/src/com/redhat/rhn/domain/action/ActionFactory.java +++ b/java/code/src/com/redhat/rhn/domain/action/ActionFactory.java @@ -655,6 +655,21 @@ public class ActionFactory extends HibernateFactory { }
/** + * Lookup ServerAction object for given Server/Action pair. + * @param serverIn the server who's ServerAction you are searching for + * @param actionIn the action who's ServerAction you are searching for + * @return matching ServerAction object + */ + public static ServerAction getServerActionForServerAndAction(Server serverIn, + Action actionIn) { + Map params = new HashMap(); + params.put("server", serverIn); + params.put("action", actionIn); + return (ServerAction) singleton.lookupObjectByNamedQuery( + "ServerAction.findByServerAndAction", params); + } + + /** * Reschedule All Failed Server Actions associated with an action * @param action the action who's server actions you are rescheduling * @param tries the number of tries to set (should be set to 5) diff --git a/java/code/src/com/redhat/rhn/domain/action/server/ServerAction.hbm.xml b/java/code/src/com/redhat/rhn/domain/action/server/ServerAction.hbm.xml index a4347e1..f7d0f36 100644 --- a/java/code/src/com/redhat/rhn/domain/action/server/ServerAction.hbm.xml +++ b/java/code/src/com/redhat/rhn/domain/action/server/ServerAction.hbm.xml @@ -43,6 +43,12 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" ]]> </query>
+ <query name="ServerAction.findByServerAndAction"> + <![CDATA[from com.redhat.rhn.domain.action.server.ServerAction as sa + where sa.server = :server + and sa.parentAction = :action]]> + </query> + <query name="ServerAction.deleteByParentActions"><![CDATA[ delete ServerAction sa where sa.parentAction in (:actions) ]]></query> diff --git a/java/code/src/com/redhat/rhn/domain/audit/XccdfTestResult.java b/java/code/src/com/redhat/rhn/domain/audit/XccdfTestResult.java index 70e4668..dc1b97f 100644 --- a/java/code/src/com/redhat/rhn/domain/audit/XccdfTestResult.java +++ b/java/code/src/com/redhat/rhn/domain/audit/XccdfTestResult.java @@ -14,12 +14,16 @@ */ package com.redhat.rhn.domain.audit;
+import java.util.Calendar; import java.util.Date; import java.util.List;
import com.redhat.rhn.common.hibernate.HibernateFactory; +import com.redhat.rhn.domain.action.ActionFactory; import com.redhat.rhn.domain.action.scap.ScapActionDetails; +import com.redhat.rhn.domain.action.server.ServerAction; import com.redhat.rhn.domain.server.Server; +import com.redhat.rhn.domain.org.OrgConfig; import com.redhat.rhn.manager.audit.ScapManager; import com.redhat.rhn.manager.audit.scap.RuleResultDiffer; import com.redhat.rhn.manager.audit.scap.file.ScapFileManager; @@ -226,4 +230,26 @@ public class XccdfTestResult { public List<ScapResultFile> getFiles() { return ScapFileManager.lookupFilesForTestResult(this); } + + /** + * Return true if this XccdfTestResult can be deleted (based on the organization's + * SCAP retention policy. + * @return the result + */ + public Boolean getDeletable() { + OrgConfig cfg = getServer().getOrg().getOrgConfig(); + Long retentionDays = cfg.getScapRetentionPeriodDays(); + if (retentionDays == null) { + return false; + } + ServerAction serverAction = ActionFactory.getServerActionForServerAndAction( + getServer(), getScapActionDetails().getParentAction()); + Date completionTime = serverAction.getCompletionTime(); + + Calendar periodStart = Calendar.getInstance(); + periodStart.setTime(new Date()); + periodStart.add(Calendar.DATE, -1 * retentionDays.intValue()); + + return completionTime.before(periodStart.getTime()); + } }
commit 1dc63ff28ca4de79dd44a0b01a3ab6179540f01f Author: Simon Lukasik slukasik@redhat.com Date: Mon Jul 15 17:01:14 2013 +0200
Indent organization configuration dialog to clarify semantics of checkboxes.
diff --git a/branding/css/rhn-special-styles.css b/branding/css/rhn-special-styles.css index cf11ffc..8c1981f 100644 --- a/branding/css/rhn-special-styles.css +++ b/branding/css/rhn-special-styles.css @@ -93,6 +93,10 @@ td.comparison { padding: 10px; }
+th.hidden { + visibility: hidden; +} + /** ssm **/
.ssm-overview th { diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp b/java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp index 5017b7e..5804299 100644 --- a/java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp +++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp @@ -55,7 +55,9 @@ function modifyUploadCheckbox(checkbox) { <p/> <table class="details" align="center"> <tr> - <th><label for="staging_content_enabled"><bean:message key="org-config.staging-content.jsp"/></th> + <th colspan="2"> + <label for="staging_content_enabled"><bean:message key="org-config.staging-content.jsp"/> + </th> <td><input type="checkbox" name="staging_content_enabled" value="enabled" id="staging_content_enabled" <c:if test = "${org.orgConfig.stagingContentEnabled}"> @@ -65,7 +67,7 @@ function modifyUploadCheckbox(checkbox) { </td> </tr> <tr> - <th> + <th colspan="2"> <label for="crash_reporting_enabled"> <bean:message key="org-config.crash-reporting.jsp"/> </th> @@ -82,6 +84,7 @@ function modifyUploadCheckbox(checkbox) { </td> </tr> <tr> + <th class="hidden"> </th> <th> <label for="crashfile_upload_enabled"> <bean:message key="org-config.crashfile-upload.jsp"/> @@ -101,6 +104,7 @@ function modifyUploadCheckbox(checkbox) { </td> </tr> <tr> + <th class="hidden"> </th> <th> <bean:message key="org-config.crashfile-sizelimit.jsp"/> </th> @@ -112,7 +116,7 @@ function modifyUploadCheckbox(checkbox) { <td> </tr> <tr> - <th> + <th colspan="2"> <label for="scapfile_upload_enabled"> <bean:message key="org-config.scapfile-upload.jsp"/> </th> @@ -128,6 +132,7 @@ function modifyUploadCheckbox(checkbox) { </td> </tr> <tr> + <th class="hidden"> </th> <th> <bean:message key="org-config.scapfile-sizelimit.jsp"/> </th> @@ -139,7 +144,7 @@ function modifyUploadCheckbox(checkbox) { </td> </tr> <tr> - <th> + <th colspan="2"> <bean:message key="org-config.scap-retention"/> </th> <td> @@ -155,6 +160,7 @@ function modifyUploadCheckbox(checkbox) { </td> </tr> <tr id="tr_scap_retention"> + <th class="hidden"> </th> <th> <bean:message key="org-config.scap-retention-period"/> </th>
commit d7e77e04fa32312ccc0adfffd2d1c36e9a690fdb Author: Simon Lukasik slukasik@redhat.com Date: Thu Jul 11 14:42:27 2013 +0200
Allow for scap_retention_period to be set through webui.
diff --git a/java/code/src/com/redhat/rhn/domain/org/OrgConfig.hbm.xml b/java/code/src/com/redhat/rhn/domain/org/OrgConfig.hbm.xml index 84c7ab1..31a23c4 100644 --- a/java/code/src/com/redhat/rhn/domain/org/OrgConfig.hbm.xml +++ b/java/code/src/com/redhat/rhn/domain/org/OrgConfig.hbm.xml @@ -16,6 +16,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" <property name="crashFileSizelimit" column="crash_file_sizelimit" type="long" not-null="true"/> <property name="scapfileUploadEnabled" column="scapfile_upload_enabled" type="yes_no" not-null="true"/> <property name="scapFileSizelimit" column="scap_file_sizelimit" type="long" not-null="true"/> + <property name="scapRetentionPeriodDays" column="scap_retention_period_days" type="long" not-null="false"/> </class> </hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/org/OrgConfig.java b/java/code/src/com/redhat/rhn/domain/org/OrgConfig.java index e63181c..fe02dc6 100644 --- a/java/code/src/com/redhat/rhn/domain/org/OrgConfig.java +++ b/java/code/src/com/redhat/rhn/domain/org/OrgConfig.java @@ -34,6 +34,7 @@ public class OrgConfig extends BaseDomainHelper { private Long crashFileSizelimit; private boolean scapfileUploadEnabled; private Long scapFileSizelimit; + private Long scapRetentionPeriodDays;
/** * Gets the current value of org_id @@ -138,4 +139,21 @@ public class OrgConfig extends BaseDomainHelper { public void setScapFileSizelimit(Long sizeLimitIn) { scapFileSizelimit = sizeLimitIn; } + + /** + * Get the org-wide period (in days) after which it is possible to remove SCAP scan. + * @return Returns the org-wide SCAP retention period. + */ + public Long getScapRetentionPeriodDays() { + return scapRetentionPeriodDays; + } + + /** + * Set the org-wide SCAP period (in days) after which it is possible to remove SCAP + * scan. + * @param scapRetentionPeriodDaysIn The org-wide SCAP retention period. + */ + public void setScapRetentionPeriodDays(Long scapRetentionPeriodDaysIn) { + scapRetentionPeriodDays = scapRetentionPeriodDaysIn; + } } diff --git a/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgConfigAction.java b/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgConfigAction.java index cfe7455..9b1d969 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgConfigAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgConfigAction.java @@ -38,6 +38,9 @@ import javax.servlet.http.HttpServletResponse; * @version $Rev: 1 $ */ public class OrgConfigAction extends RhnAction { + private static final String SCAP_RETENTION_PERIOD = "scap_retention_period"; + private static final String SCAP_RETENTION_SET = "scap_retention_set"; +
/** {@inheritDoc} */ @Override @@ -65,14 +68,17 @@ public class OrgConfigAction extends RhnAction {
Long newCrashLimit = null; Long newScapLimit = null; + Long newScapRetentionPeriod = null; try { newCrashLimit = Long.parseLong( request.getParameter("crashfile_sizelimit").trim());
newScapLimit = Long.parseLong( request.getParameter("scapfile_sizelimit").trim()); + newScapRetentionPeriod = Long.parseLong( + request.getParameter(SCAP_RETENTION_PERIOD).trim());
- if (newCrashLimit < 0 || newScapLimit < 0) { + if (newCrashLimit < 0 || newScapLimit < 0 || newScapRetentionPeriod < 0) { throw new IllegalArgumentException(); } } @@ -90,6 +96,12 @@ public class OrgConfigAction extends RhnAction { if (StringUtils.isNotEmpty(request.getParameter("scapfile_sizelimit"))) { org.getOrgConfig().setScapFileSizelimit(newScapLimit); } + if (StringUtils.isNotEmpty(request.getParameter(SCAP_RETENTION_PERIOD))) { + org.getOrgConfig().setScapRetentionPeriodDays(newScapRetentionPeriod); + } + if (!getOptionScapRetentionPeriodSet(request)) { + org.getOrgConfig().setScapRetentionPeriodDays(null); + }
ActionMessages msg = new ActionMessages(); msg.add(ActionMessages.GLOBAL_MESSAGE, @@ -101,4 +113,9 @@ public class OrgConfigAction extends RhnAction { } return mapping.findForward(RhnHelper.DEFAULT_FORWARD); } + + private Boolean getOptionScapRetentionPeriodSet(HttpServletRequest request) { + String strRetentionSet = request.getParameter(SCAP_RETENTION_SET); + return "on".equals(strRetentionSet); + } } diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml index f28f202..861baa7 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml @@ -3375,6 +3375,18 @@ button below, and <b>will be unable to log back in</b>.</source> <context context-type="sourcefile">/rhn/admin/multiorg/OrgConfigDetails.do</context> </context-group> </trans-unit> + <trans-unit id="org-config.scap-retention"> + <source>Allow Deletion of SCAP Results</source> + <context-group name="ctx"> + <context context-type="sourcefile">/rhn/admin/multiorg/OrgConfigDetails.do</context> + </context-group> + </trans-unit> + <trans-unit id="org-config.scap-retention-period"> + <source>Allow Deletion After (period in days)</source> + <context-group name="ctx"> + <context context-type="sourcefile">/rhn/admin/multiorg/OrgConfigDetails.do</context> + </context-group> + </trans-unit> <trans-unit id="org.id.jsp"> <source>Organization ID</source> <context-group name="ctx"> diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp b/java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp index 8bc48d5..5017b7e 100644 --- a/java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp +++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp @@ -138,6 +138,33 @@ function modifyUploadCheckbox(checkbox) { id="scapfile_sizelimit" /> </td> </tr> + <tr> + <th> + <bean:message key="org-config.scap-retention"/> + </th> + <td> + <input type="checkbox" + name="scap_retention_set" + value="on" + id="scap_retention_set" + onChange="modifyTrVisibility('tr_scap_retention')" + <c:if test = "${org.orgConfig.scapRetentionPeriodDays != null}"> + checked="checked" + </c:if> + /> + </td> + </tr> + <tr id="tr_scap_retention"> + <th> + <bean:message key="org-config.scap-retention-period"/> + </th> + <td> + <input type="number" + name="scap_retention_period" + value="${org.orgConfig.scapRetentionPeriodDays == null ? 90 : org.orgConfig.scapRetentionPeriodDays}" + id="scap_retention_period" /> + </td> + </tr> </table>
<div align="right">
commit 196dab4c4977a1c5dd30b9f7e9505089ed24f54f Author: Simon Lukasik slukasik@redhat.com Date: Thu Jul 11 12:48:01 2013 +0200
Close table cell more properly.
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp b/java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp index 8ea22aa..8bc48d5 100644 --- a/java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp +++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/configuration.jsp @@ -136,7 +136,7 @@ function modifyUploadCheckbox(checkbox) { name="scapfile_sizelimit" value="${org.orgConfig.scapFileSizelimit}" id="scapfile_sizelimit" /> - <td> + </td> </tr> </table>
commit 1fae4629322076f58043245a140f290673ae5306 Author: Simon Lukasik slukasik@redhat.com Date: Thu Jul 11 09:40:58 2013 +0200
New OrgConfig attribute: period during which it is not possible to delete scan
diff --git a/schema/spacewalk/common/tables/rhnOrgConfiguration.sql b/schema/spacewalk/common/tables/rhnOrgConfiguration.sql index 9aeb1c3..9ff1606 100644 --- a/schema/spacewalk/common/tables/rhnOrgConfiguration.sql +++ b/schema/spacewalk/common/tables/rhnOrgConfiguration.sql @@ -43,6 +43,10 @@ create table rhnOrgConfiguration default(2097152) not null constraint rhn_org_conf_scap_szlmt_chk check (scap_file_sizelimit >= 0), + scap_retention_period_days number + default(90) + constraint rhn_org_conf_scap_reten_chk + check (scap_retention_period_days >= 0), created timestamp with local time zone default (current_timestamp) not null, modified timestamp with local time zone diff --git a/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/011-rhnOrgConfiguration-scapret.sql b/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/011-rhnOrgConfiguration-scapret.sql new file mode 100644 index 0000000..b213404 --- /dev/null +++ b/schema/spacewalk/upgrade/spacewalk-schema-2.0-to-spacewalk-schema-2.1/011-rhnOrgConfiguration-scapret.sql @@ -0,0 +1,4 @@ +alter table rhnOrgConfiguration + add scap_retention_period_days + number default (90) + constraint rhn_org_conf_scap_reten_chk check (scap_retention_period_days >= 0);
commit 056a48555ed3ac2715daf1fa27aac6402cf60776 Author: Simon Lukasik slukasik@redhat.com Date: Thu Jul 25 18:10:36 2013 +0200
Correct typo in documentation.
diff --git a/java/code/src/com/redhat/rhn/frontend/struts/BaseSetHelper.java b/java/code/src/com/redhat/rhn/frontend/struts/BaseSetHelper.java index 69172d1..a76391c 100644 --- a/java/code/src/com/redhat/rhn/frontend/struts/BaseSetHelper.java +++ b/java/code/src/com/redhat/rhn/frontend/struts/BaseSetHelper.java @@ -51,7 +51,7 @@ public class BaseSetHelper {
/** * Default struts action one might want to execute - * when selectAll, unselectAll, udate set actions are clicked + * when selectAll, unselectAll, update set actions are clicked * on a table with an Set. * @param set the set to update * @param listName the name of the list to grab the data from
spacewalk-commits@lists.fedorahosted.org