Hello.
I`m trying to make a webscript which will be able to:
1. receive json request;
2. get and transform argument from json request to java format;
3. find node in a specific folder using json argument as a search request;
4. get properties from found node;
5. transform found properties back to json string;
6. send answer in json;
Example of json request that I want to process
$postData = array(
'didNumber' => '0443334000',
'srcNumber' => '0670219424',
'companyID' => '3041',
'requestType' => 'gettingCallSettings'
);
I`ve created next files after reading about json processing in Alfresco:
.get.desc.xml
<webscript>
<shortname>negotiate</shortname>
<description>negotiate JSON</description>
<url>/negotiate</url>
<authentication>guest</authentication>
<negotiate accept="application/json">json</negotiate>
</webscript>
.get.json.ftl
{"response": "myObjAsString"}.get.js
var tel = json.get("srcNumber");
var node = search.luceneSearch("@cm\\:name:\"" + nodeName+ "\" AND PARENT:\"workspace://SpacesStore/61d28f13-24e0-434a-8b90-5ea54d2fafa2\"");
var name = node.properties["zkz:Name"];
var myObj = {'name':'name'};
var myObjAsString = jsonUtils.toJSONString(myObj);
model.myObjAsString = myObjAsString;But every time I try to execute my srcipt I receive something like this:
{
"status" :
{
"code" : 500,
"name" : "Internal Error",
"description" : "An error inside the HTTP server which prevented it from fulfilling the request."
},
"message" : "09220628 Cannot locate template processor for template org\/alfresco\/negotiate.get.json",
"exception" : "org.springframework.extensions.webscripts.WebScriptException - 09220628 Cannot locate template processor for template org\/alfresco\/negotiate.get.json",or if I clean all data from .get.js I receive text from .ftl file.
In the end I need to send back something like this:
die(json_encode(array(
'customerData' => array(
'name' => '1111111',
'description' => '11111111111',
)
)));
Please, can someone help me with js file? Can it be on Java or it must be in Json format?