<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Automation REST Response: how to return a custom message? in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/automation-rest-response-how-to-return-a-custom-message/m-p/316669#M3670</link>
    <description>&lt;P&gt;Following &lt;STRONG&gt;&lt;A href="https://doc.nuxeo.com/display/NXDOC/Automation+REST+Response"&gt;Automation REST Response&lt;/A&gt;&lt;/STRONG&gt; documentation, we are able now to create a custom exception and return an appropiate http error code from our operations, as shown in the example below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;{
    "entity-type": "exception",
    "code": "org.nuxeo.ecm.automation.TraceException",
    "status": 600,
    "message": "Failed to invoke operation: Test.UpdateDocMetadata"
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In this example 600 is our custom error code.&lt;/P&gt;
&lt;P&gt;Now, we would like to be able to return a custom message in the exception. For example, instead of having &lt;EM&gt;"&lt;STRONG&gt;Failed to invoke operation:&lt;/STRONG&gt; Test.UpdateDocMetadata operation"&lt;/EM&gt;, we would like to have a custom message. Is this posible?&lt;/P&gt;
&lt;P&gt;We are using Nuxeo 7.2.&lt;/P&gt;
&lt;P&gt;Thanks in advance and best regards,&lt;/P&gt;</description>
    <pubDate>Tue, 27 Oct 2015 12:20:01 GMT</pubDate>
    <dc:creator>ioihanguren_</dc:creator>
    <dc:date>2015-10-27T12:20:01Z</dc:date>
    <item>
      <title>Automation REST Response: how to return a custom message?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/automation-rest-response-how-to-return-a-custom-message/m-p/316669#M3670</link>
      <description>&lt;P&gt;Following &lt;STRONG&gt;&lt;A href="https://doc.nuxeo.com/display/NXDOC/Automation+REST+Response"&gt;Automation REST Response&lt;/A&gt;&lt;/STRONG&gt; documentation, we are able now to create a custom exception and return an appropiate http error code from our operations, as shown in the example below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;{
    "entity-type": "exception",
    "code": "org.nuxeo.ecm.automation.TraceException",
    "status": 600,
    "message": "Failed to invoke operation: Test.UpdateDocMetadata"
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In this example 600 is our custom error code.&lt;/P&gt;
&lt;P&gt;Now, we would like to be able to return a custom message in the exception. For example, instead of having &lt;EM&gt;"&lt;STRONG&gt;Failed to invoke operation:&lt;/STRONG&gt; Test.UpdateDocMetadata operation"&lt;/EM&gt;, we would like to have a custom message. Is this posible?&lt;/P&gt;
&lt;P&gt;We are using Nuxeo 7.2.&lt;/P&gt;
&lt;P&gt;Thanks in advance and best regards,&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2015 12:20:01 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/automation-rest-response-how-to-return-a-custom-message/m-p/316669#M3670</guid>
      <dc:creator>ioihanguren_</dc:creator>
      <dc:date>2015-10-27T12:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: Automation REST Response: how to return a custom message?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/automation-rest-response-how-to-return-a-custom-message/m-p/316670#M3671</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;I can think about several possibilities, depending on what you have done. If I only look at the example &lt;A href="https://doc.nuxeo.com/display/NXDOC/Automation+REST+Response"&gt;you gave&lt;/A&gt;, you can:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;set your custom message in the ExceptionTest class;&lt;/LI&gt;
&lt;LI&gt;Create a complete custom Exception where you set up your custom message and you don't necessarily have to extend RestOperationException (but you may have to extend class org.nuxeo.ecm.automation.OperationException)&lt;/LI&gt;
&lt;LI&gt;In the HttpStatusOperationTest class (with ExceptionTest), set your custom message when constructing the ExceptionTest or with (ExceptionTest.)setMessage before throwing the Exception&lt;/LI&gt;
&lt;LI&gt;In the HttpStatusOperationTest class (when success in Automation Operation), root is a DocumentModel, which has metadata. From your very example, it has a metadata named "message", so you should be able to update it with setProperty or setPropertyValue before returning root.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I hope this helps.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 10:27:57 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/automation-rest-response-how-to-return-a-custom-message/m-p/316670#M3671</guid>
      <dc:creator>Greg_Drayon</dc:creator>
      <dc:date>2015-11-12T10:27:57Z</dc:date>
    </item>
  </channel>
</rss>

