How to Rollback the webscript not using WebScriptException?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2007 07:57 AM
How do I make Alfresco rollback the transaction when my DeclarativeWebscript discovers an error?
All my REST-calls return an XML (with the Freemaker Template) that has a standard format containing a status-tag. So I am not interested in the error generated when the WebScriptException is thrown.
Can I call a specific function in java or should I override the WebScriptException?
All my REST-calls return an XML (with the Freemaker Template) that has a standard format containing a status-tag. So I am not interested in the error generated when the WebScriptException is thrown.
Can I call a specific function in java or should I override the WebScriptException?
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2007 04:36 PM
Are you aware of http://wiki.alfresco.com/wiki/Web_Scripts#Response_Status
I'm not sure exactly of your requirement, but if an exception is thrown, the transaction will roll-back. And all exceptions are caught by the Web Script runtime and rendered as a response (with a status).
The only possible issue is how to mark rollback within javascript. Is that your issue?
I'm not sure exactly of your requirement, but if an exception is thrown, the transaction will roll-back. And all exceptions are caught by the Web Script runtime and rendered as a response (with a status).
The only possible issue is how to mark rollback within javascript. Is that your issue?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2007 06:14 AM
I don't use javascript with Alfresco 🙂
I want to do the following handle an exception in a java class of type DeclarativeWebScript gracefull by doing the following
- catch exception
- rollback the transaction
- set a custom statuscode in the model that I return
- use the Freemaker-template for the method (no exception/error FreeMarker template)
- the FreeMaker-template returns its XML as normal with the statuscode.
Is this more clear concerning what I want to do?
I want to do the following handle an exception in a java class of type DeclarativeWebScript gracefull by doing the following
- catch exception
- rollback the transaction
- set a custom statuscode in the model that I return
- use the Freemaker-template for the method (no exception/error FreeMarker template)
- the FreeMaker-template returns its XML as normal with the statuscode.
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, WebScriptStatus status) {
Map<String, Object> model = new HashMap<String, Object>(7, 1.0f);
Integer statuscode = Status.STATUS_INTERNAL_ERROR;
try {
SuperObject so = null;
so.thisWillTriggerException();
statuscode = Status.SUCCESS;
}
catch (…) {
// Rollback transaction and use the same
// FreeMaker-template as it would if no
// exception was triggered.
statuscode = Status.THIS_TOTALLY_FAILED;
}
model.put("statuscode", statuscode);
return model;
}
Is this more clear concerning what I want to do?