incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1053371 - in /sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl: servlets/JobStateChangeServlet.java storage/NodeJobStatusFactoryImpl.java
Date Tue, 28 Dec 2010 15:39:48 GMT
Author: bdelacretaz
Date: Tue Dec 28 15:39:47 2010
New Revision: 1053371

URL: http://svn.apache.org/viewvc?rev=1053371&view=rev
Log:
SLING-1903 - return 200 response with additional JSON info if job state cannot be changed

Modified:
    sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/servlets/JobStateChangeServlet.java
    sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/storage/NodeJobStatusFactoryImpl.java

Modified: sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/servlets/JobStateChangeServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/servlets/JobStateChangeServlet.java?rev=1053371&r1=1053370&r2=1053371&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/servlets/JobStateChangeServlet.java
(original)
+++ sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/servlets/JobStateChangeServlet.java
Tue Dec 28 15:39:47 2010
@@ -76,7 +76,9 @@ public class JobStateChangeServlet exten
             return;
         }
         final JobStatus j = jobConsole.getJobStatus(session, request.getResource().getPath());
+        final JobStatus.State oldState = j.getState();
         j.requestStateChange(desiredState);
+        final JobStatus.State newState = j.getState();
         
         response.setContentType("application/json");
         response.setCharacterEncoding("UTF-8");
@@ -86,7 +88,8 @@ public class JobStateChangeServlet exten
             w.key("info").value("Requested state change");
             w.key(PARAM_STATE).value(desiredState.toString());
             w.key("path").value(j.getPath());
-            w.key("currentState").value(j.getState());
+            w.key("currentState").value(newState);
+            w.key("stateChanged").value(newState != oldState);
             w.endObject();
         } catch(JSONException je) {
             throw new ServletException("JSONException in doPost", je);

Modified: sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/storage/NodeJobStatusFactoryImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/storage/NodeJobStatusFactoryImpl.java?rev=1053371&r1=1053370&r2=1053371&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/storage/NodeJobStatusFactoryImpl.java
(original)
+++ sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/storage/NodeJobStatusFactoryImpl.java
Tue Dec 28 15:39:47 2010
@@ -86,9 +86,10 @@ public class NodeJobStatusFactoryImpl im
         public void requestStateChange(State s) {
             final JobStatus j = getActiveJob();
             if(j == null) {
-                throw new JobStorageException("Job is not active, cannot change state, path="
+ path);
+                log.debug("Job {} is not active, cannot change state", path);
+            } else {
+                j.requestStateChange(s);
             }
-            j.requestStateChange(s);
         }
         
         private JobStatus getActiveJob() {



Mime
View raw message