On 01/21/2014 01:26 PM, Matej Kollar wrote:
> * "$Rev$" is legacy of our old versioning system (cvs) and has no use
>   now that we use git (and we would not like to see it in new code).

Just to have everyone informed: I used those tags because they were
required by checkstyle_eclipse.xml. Matej will fix that configuration
file, meanwhile I fixed the patch.

By the way I also fixed my review-pending branches with these commits:

e9ac621 -> master-pxe-default-image-no-powermanagement
9e04ed5 -> master-power-management-ssm

> * Preferred space indentation for `.jsp` files is 2 spaces.

As discussed, since there is no current standard in Spacewalk and the
Oracle code conventions for JSP is four spaces[1], we will stick with
four. Of course we can revert the decision later if a decision is taken.

> * Use of `property="dispatch"` for submit button isn't needed
>   when the only thing you actually check is `isSubmitted(form)`. [...]

Agreed, fixed.

> * Confirm button -- I would prefer "Reboot system" that was used on
>   `.pxt` page..

Fixed.

> * Using "sid": [...] one "sid" is enough.

Okay! :-)

Thanks for your review and thorough explanations.

Regards

[1]
http://www.oracle.com/technetwork/articles/javase/code-convention-138726.html
-- 
Silvio Moioli
SUSE LINUX Products GmbH
Maxfeldstraße 5, 90409 Nürnberg Germany
>From 51fc76e6de18e6e93f38652f389edf39976d5c38 Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Thu, 16 Jan 2014 14:08:11 +0100
Subject: [PATCH] port reboot_confirm.pxt from perl to java

---
 .../action/systems/sdc/SystemRebootAction.java     | 88 ++++++++++++++++++++++
 .../frontend/strings/jsp/StringResource_en_US.xml  | 24 ++++++
 java/code/webapp/WEB-INF/nav/system_detail.xml     |  2 +-
 .../webapp/WEB-INF/pages/systems/sdc/overview.jsp  |  4 +-
 .../WEB-INF/pages/systems/sdc/rebootsystem.jsp     | 52 +++++++++++++
 java/code/webapp/WEB-INF/struts-config.xml         | 13 ++++
 web/include/nav/system_detail.xml                  |  2 +-
 7 files changed, 181 insertions(+), 4 deletions(-)
 create mode 100644 java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemRebootAction.java
 create mode 100644 java/code/webapp/WEB-INF/pages/systems/sdc/rebootsystem.jsp

diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemRebootAction.java b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemRebootAction.java
new file mode 100644
index 0000000..5e4c998
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/frontend/action/systems/sdc/SystemRebootAction.java
@@ -0,0 +1,88 @@
+/**
+ * Copyright (c) 2014 SUSE
+ *
+ * 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.sdc;
+
+import com.redhat.rhn.common.util.DatePicker;
+import com.redhat.rhn.domain.action.Action;
+import com.redhat.rhn.domain.action.ActionFactory;
+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.RhnAction;
+import com.redhat.rhn.frontend.struts.RhnHelper;
+import com.redhat.rhn.manager.action.ActionManager;
+import com.redhat.rhn.manager.system.SystemManager;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.DynaActionForm;
+
+import java.util.Date;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * SystemRebootAction handles the interaction of the system reboot.
+ */
+public class SystemRebootAction extends RhnAction {
+    /** Success forward name. */
+    private static final String CONFIRM_FORWARD = "confirm";
+
+    /** {@inheritDoc} */
+    @Override
+    @SuppressWarnings("unchecked")
+    public ActionForward execute(ActionMapping mapping, ActionForm formIn,
+        HttpServletRequest request, HttpServletResponse response) {
+
+        DynaActionForm form = (DynaActionForm) formIn;
+        RequestContext context = new RequestContext(request);
+        User user = context.getLoggedInUser();
+        Map<String, Object> params = (Map<String, Object>) makeParamMap(request);
+        String forward = RhnHelper.DEFAULT_FORWARD;
+
+        Long sid = context.getRequiredParam(RequestContext.SID);
+        Server server = SystemManager.lookupByIdAndUser(sid, user);
+
+        if (isSubmitted(form)) {
+            Date earliest = getStrutsDelegate().readDatePicker((DynaActionForm) formIn,
+                "date", DatePicker.YEAR_RANGE_POSITIVE);
+            Action action = ActionManager.scheduleRebootAction(user, server, earliest);
+            ActionFactory.save(action);
+
+            String[] messageParams = new String[3];
+            messageParams[0] = server.getName();
+            messageParams[1] = earliest.toString();
+            messageParams[2] = action.getId().toString();
+            createMessage(request, "system.reboot.scheduled", messageParams);
+
+            // goes to sdc/overview.jsp
+            params.put(RequestContext.SID, sid);
+            forward = CONFIRM_FORWARD;
+        }
+
+        DatePicker picker = getStrutsDelegate().prepopulateDatePicker(request, form,
+            "date", DatePicker.YEAR_RANGE_POSITIVE);
+        request.setAttribute("date", picker);
+        request.setAttribute(RequestContext.SID, sid);
+        request.setAttribute("system", server);
+
+        SdcHelper.ssmCheck(request, server.getId(), user);
+
+        return getStrutsDelegate().forwardParams(mapping.findForward(forward), params);
+    }
+}
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 c4cdf75..62ec065 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
@@ -5130,6 +5130,30 @@ value for this entitlement, excluding the default organization's consumption.</s
           <context context-type="sourcefile">/rhn/systems/SystemGroupList</context>
         </context-group>
       </trans-unit>
+      <trans-unit id="reboot.jsp.header">
+        <source>System Reboot Confirmation</source>
+        <context-group name="ctx">
+          <context context-type="sourcefile">/rhn/systems/details/RebootSystem</context>
+        </context-group>
+      </trans-unit>
+      <trans-unit id="reboot.jsp.summary">
+        <source>This will schedule a reboot of this system.</source>
+        <context-group name="ctx">
+          <context context-type="sourcefile">/rhn/systems/details/RebootSystem</context>
+        </context-group>
+      </trans-unit>
+      <trans-unit id="reboot.jsp.widgetsummary">
+        <source>If you are &lt;strong&gt;certain&lt;/strong&gt; you wish to do this, you may schedule the reboot to take place after a specified time:</source>
+        <context-group name="ctx">
+          <context context-type="sourcefile">/rhn/systems/details/RebootSystem</context>
+        </context-group>
+      </trans-unit>
+      <trans-unit id="reboot.jsp.confirm">
+        <source>Reboot system</source>
+        <context-group name="ctx">
+          <context context-type="sourcefile">/rhn/systems/details/RebootSystem</context>
+        </context-group>
+      </trans-unit>
       <!--- System Duplicates pages -->
       <group>
         <context-group name="ctx">
diff --git a/java/code/webapp/WEB-INF/nav/system_detail.xml b/java/code/webapp/WEB-INF/nav/system_detail.xml
index 6c20453..5261dec 100644
--- a/java/code/webapp/WEB-INF/nav/system_detail.xml
+++ b/java/code/webapp/WEB-INF/nav/system_detail.xml
@@ -4,7 +4,7 @@
   <rhn-tab name="Details" url="/rhn/systems/details/Overview.do">
     <rhn-tab name="Overview">
 	  <rhn-tab-url>/rhn/systems/details/Overview.do</rhn-tab-url>
-	  <rhn-tab-url>/network/systems/details/reboot_confirm.pxt</rhn-tab-url>
+          <rhn-tab-url>/rhn/systems/details/RebootSystem.do</rhn-tab-url>
     </rhn-tab>
     <rhn-tab name="Properties" url="/rhn/systems/details/Edit.do" />
     <rhn-tab name="Remote Command" acl="system_feature(ftr_remote_command)">
diff --git a/java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp b/java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp
index ce473c4..0dc87b4 100644
--- a/java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/sdc/overview.jsp
@@ -54,7 +54,7 @@
         <div class="systeminfo">
           <div class="systeminfo-full">
             <rhn:icon type="system-reboot" /><bean:message key="sdc.details.overview.requires_reboot"/>
-            <bean:message key="sdc.details.overview.schedulereboot" arg0="/network/systems/details/reboot_confirm.pxt?sid=${system.id}"/>
+            <bean:message key="sdc.details.overview.schedulereboot" arg0="/rhn/systems/details/RebootSystem.do?sid=${system.id}"/>
           </div>
         </div>
       </c:if>
@@ -255,7 +255,7 @@
             <td><fmt:formatDate value="${system.lastBootAsDate}" type="both" dateStyle="short" timeStyle="long"/><br/>
                   <rhn:require acl="system_feature(ftr_reboot)"
                        mixins="com.redhat.rhn.common.security.acl.SystemAclHandler">
-                <bean:message key="sdc.details.overview.schedulereboot" arg0="/network/systems/details/reboot_confirm.pxt?sid=${system.id}"/>
+                <bean:message key="sdc.details.overview.schedulereboot" arg0="/rhn/systems/details/RebootSystem.do?sid=${system.id}"/>
                   </rhn:require>
             </td>
           </tr>
diff --git a/java/code/webapp/WEB-INF/pages/systems/sdc/rebootsystem.jsp b/java/code/webapp/WEB-INF/pages/systems/sdc/rebootsystem.jsp
new file mode 100644
index 0000000..6e03b4a
--- /dev/null
+++ b/java/code/webapp/WEB-INF/pages/systems/sdc/rebootsystem.jsp
@@ -0,0 +1,52 @@
+<%--
+    Document   : rebootsystem
+    Created on : Jan 15, 2014, 2:35:54 PM
+    Author     : Michael Calmer <m...@suse.de>
+--%>
+
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+
+<%@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" %>
+
+<html>
+    <body>
+        <%@ include file="/WEB-INF/pages/common/fragments/systems/system-header.jspf" %>
+        <div class="panel panel-default">
+            <div class="panel-heading">
+                <h4><bean:message key="reboot.jsp.header" /></h4>
+            </div>
+            <div class="panel-body">
+                <bean:message key="reboot.jsp.summary" />
+                <br>
+                <bean:message key="reboot.jsp.widgetsummary"/>
+
+                <form action="/rhn/systems/details/RebootSystem.do?sid=${sid}" method="post" class="form-horizontal">
+                    <rhn:csrf />
+                    <rhn:submitted />
+
+                    <div class="form-group">
+                        <div class="col-lg-offset-3 col-lg-6">
+                            <jsp:include page="/WEB-INF/pages/common/fragments/date-picker.jsp">
+                                <jsp:param name="widget" value="date"/>
+                            </jsp:include>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <div class="col-lg-offset-3 col-lg-6">
+                            <html:submit styleClass="btn btn-danger">
+                                <bean:message key="reboot.jsp.confirm"/>
+                            </html:submit>
+                        </div>
+                    </div>
+
+                    <input type="hidden" name="use_date" value="true" />
+                </form>
+            </div>
+        </div>
+    </body>
+</html>
diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml
index 1e96b02..c96c141 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -3063,6 +3063,19 @@
                      path="/systems/ssm/ListSystems.do" redirect="true" />
     </action>
 
+    <action path="/systems/details/RebootSystem"
+            scope="request"
+            name="datePickerForm"
+            input="/WEB-INF/pages/systems/sdc/rebootsystem.jsp"
+            type="com.redhat.rhn.frontend.action.systems.sdc.SystemRebootAction"
+            className="com.redhat.rhn.frontend.struts.RhnActionMapping">
+        <set-property property="postRequiredIfSubmitted" value="true"/>
+        <forward name="confirm"
+                 path="/WEB-INF/pages/systems/sdc/overview.jsp" />
+        <forward name="default"
+                 path="/WEB-INF/pages/systems/sdc/rebootsystem.jsp" />
+    </action>
+
     <action path="/systems/details/audit/ListScap"
         scope="request"
         input="/WEB-INF/pages/systems/details/audit/listscap.jsp"
diff --git a/web/include/nav/system_detail.xml b/web/include/nav/system_detail.xml
index 3332573..b45ba4d 100644
--- a/web/include/nav/system_detail.xml
+++ b/web/include/nav/system_detail.xml
@@ -4,7 +4,7 @@
   <rhn-tab name="Details" url="/rhn/systems/details/Overview.do">
     <rhn-tab name="Overview">
 	  <rhn-tab-url>/rhn/systems/details/Overview.do</rhn-tab-url>
-	  <rhn-tab-url>/network/systems/details/reboot_confirm.pxt</rhn-tab-url>
+          <rhn-tab-url>/rhn/systems/details/RebootSystem.do</rhn-tab-url>
     </rhn-tab>
     <rhn-tab name="Properties" url="/rhn/systems/details/Edit.do" />
     <rhn-tab name="Remote Command" acl="system_feature(ftr_remote_command)">
-- 
1.8.1.4

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to