You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2012/06/26 11:53:08 UTC
svn commit: r1353905 - in /ofbiz/trunk/framework/service:
entitydef/entitymodel.xml src/org/ofbiz/service/job/GenericServiceJob.java
src/org/ofbiz/service/job/PersistedServiceJob.java
Author: jacopoc
Date: Tue Jun 26 09:53:07 2012
New Revision: 1353905
URL: http://svn.apache.org/viewvc?rev=1353905&view=rev
Log:
Enhancement for JobSandbox: the job execution result message (success/error/exception messages) is now stored in the new field JobSandbox.jobResult
Modified:
ofbiz/trunk/framework/service/entitydef/entitymodel.xml
ofbiz/trunk/framework/service/src/org/ofbiz/service/job/GenericServiceJob.java
ofbiz/trunk/framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java
Modified: ofbiz/trunk/framework/service/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/entitydef/entitymodel.xml?rev=1353905&r1=1353904&r2=1353905&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/framework/service/entitydef/entitymodel.xml Tue Jun 26 09:53:07 2012
@@ -62,6 +62,7 @@ under the License.
<field name="startDateTime" type="date-time"></field>
<field name="finishDateTime" type="date-time"></field>
<field name="cancelDateTime" type="date-time"></field>
+ <field name="jobResult" type="value"></field>
<prim-key field="jobId"/>
<relation type="one" fk-name="JOB_SNDBX_RECINFO" rel-entity-name="RecurrenceInfo">
<key-map field-name="recurrenceInfoId"/>
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/job/GenericServiceJob.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/job/GenericServiceJob.java?rev=1353905&r1=1353904&r2=1353905&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/job/GenericServiceJob.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/job/GenericServiceJob.java Tue Jun 26 09:53:07 2012
@@ -24,7 +24,7 @@ import org.ofbiz.base.util.Debug;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.GenericRequester;
import org.ofbiz.service.LocalDispatcher;
-import org.ofbiz.service.ModelService;
+import org.ofbiz.service.ServiceUtil;
/**
* Generic Service Job - A generic async-service Job.
@@ -64,17 +64,16 @@ public class GenericServiceJob extends A
public void exec() throws InvalidJobException {
init();
+ Map<String, Object> result = null;
// no transaction is necessary since runSync handles this
try {
// get the dispatcher and invoke the service via runSync -- will run all ECAs
LocalDispatcher dispatcher = dctx.getDispatcher();
- Map<String, Object> result = dispatcher.runSync(getServiceName(), getContext());
+ result = dispatcher.runSync(getServiceName(), getContext());
// check for a failure
- boolean isError = ModelService.RESPOND_ERROR.equals(result.get(ModelService.RESPONSE_MESSAGE));
- if (isError) {
- String errorMessage = (String) result.get(ModelService.ERROR_MESSAGE);
- this.failed(new Exception(errorMessage));
+ if (ServiceUtil.isError(result)) {
+ this.failed(new Exception(ServiceUtil.getErrorMessage(result)));
}
if (requester != null) {
@@ -92,7 +91,7 @@ public class GenericServiceJob extends A
}
// call the finish method
- this.finish();
+ this.finish(result);
}
/**
@@ -105,7 +104,7 @@ public class GenericServiceJob extends A
/**
* Method is called after the service has finished.
*/
- protected void finish() throws InvalidJobException {
+ protected void finish(Map<String, Object> result) throws InvalidJobException {
if (Debug.verboseOn()) Debug.logVerbose("Async-Service finished.", module);
runtime = 0;
}
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java?rev=1353905&r1=1353904&r2=1353905&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java Tue Jun 26 09:53:07 2012
@@ -49,6 +49,8 @@ import org.ofbiz.service.calendar.Recurr
import org.ofbiz.service.config.ServiceConfigUtil;
import org.xml.sax.SAXException;
+import org.apache.commons.lang.StringUtils;
+
/**
* Entity Service Job - Store => Schedule => Run
*/
@@ -206,8 +208,8 @@ public class PersistedServiceJob extends
* @see org.ofbiz.service.job.GenericServiceJob#finish()
*/
@Override
- protected void finish() throws InvalidJobException {
- super.finish();
+ protected void finish(Map<String, Object> result) throws InvalidJobException {
+ super.finish(result);
// set the finish date
GenericValue job = getJob();
@@ -216,6 +218,15 @@ public class PersistedServiceJob extends
job.set("statusId", "SERVICE_FINISHED");
}
job.set("finishDateTime", UtilDateTime.nowTimestamp());
+ String jobResult = null;
+ if (ServiceUtil.isError(result)) {
+ jobResult = StringUtils.substring(ServiceUtil.getErrorMessage(result), 0, 255);
+ } else {
+ jobResult = StringUtils.substring(ServiceUtil.makeSuccessMessage(result, "", "", "", ""), 0, 255);
+ }
+ if (UtilValidate.isNotEmpty(jobResult)) {
+ job.set("jobResult", jobResult);
+ }
try {
job.store();
} catch (GenericEntityException e) {
@@ -252,6 +263,7 @@ public class PersistedServiceJob extends
// set the failed status
job.set("statusId", "SERVICE_FAILED");
job.set("finishDateTime", UtilDateTime.nowTimestamp());
+ job.set("jobResult", StringUtils.substring(t.getMessage(), 0, 255));
try {
job.store();
} catch (GenericEntityException e) {