In the project flow i am getting the data in form of json collection in apache camel exchange and to process it further i need to transform it in java object
try{
List<RespModel> records = (List<RespModel>) exchange.getIn().getBody(RespModel.class);
System.out.println(records.size());
}catch (Exception e){
System.out.println("NO LUCK "+e.getLocalizedMessage());
}
But i am getting records as null.
Could you please help me to transform this ?
exchange data is as below -
"identifier": {
"domain": "transport",
"id": "123",
"version": 1
},
"record": "NEW",
"payload": {
"pesonalDetails" : {
"name" : "bla bla bla"
"dob" :
},
"reason" :
}
},{
"identifier": {
"domain": "transport",
"id": "123",
"version": 1
},
"record": "NEW",
"payload": {
"pesonalDetails" : {
"name" : "bla bla bla"
"dob" :
},
"reason" :
}]```
I am getting null here, how can i achieve this ? pls reply if you know. Thanks
Got the answer finally -
String result = IOUtils.toString((InputStream) exchange.getIn().getBody(), StandardCharsets.UTF_8);
List<RespModel> = new ObjectMapper().readValue(result,
new TypeReference<List<RespModel>>() {
});
Hi I am trying to do aggregation on a field using MAX function inside my index, the issue is when I do aggregation with group by it fails whenever I don't have that value inside of a time frame
POST /_opendistro/_sql
{
"query": "SELECT date(timeStamp) time_unit, MAX(testField) test_field_alias FROM my_index where orgId = 'xyz' and timeStamp <= '2020-07-04T23:59:59' and timeStamp >= '2020-07-01T00:00' group by date(timeStamp) order by time_unit desc"
}
My index mapping is as given below
"mappings" : {
"properties" : {
"orgId" : {
"type" : "text"
},
"testField" : {
"type" : "long",
"null_value" : 0
},
"timeStamp": {
"type":"date"
}
}
When I try the above query I get
{
"error": {
"root_cause": [
{
"type": "j_s_o_n_exception",
"reason": "JSON does not allow non-finite numbers."
}
],
"type": "j_s_o_n_exception",
"reason": "JSON does not allow non-finite numbers."
},
"status": 500
}
I have understood this happens for time frames where I don't have the above-mentioned field in the documents in my index, SO I added "null_value":0 to my mapping but still of no use.
Thing is I want to do aggregation using MAX function grouped by time scales if there is another approach that works, that's enough for me it doesn't have to be in SQL format only.
I am trying to comparing Json response with my sql query result.
Json Response:
[
{
"id": "1023313",
"empno": "073130425890",
"empForma": "0",
"status": "success",
"message": ""
},
{
"id": "43781661",
"empno": "073130425890",
"empForma": "0",
"status": "success",
"message": ""
},
{
"id": "63535011",
"empno": "000004501951",
"empForma": "2",
"status": "success",
"message": ""
},
{
"id": "184570",
"status": "success",
"message": "No Data Available"
}
]
I have stored SQL Query Output in string:
queryResult:
[1023313 073130425890 0, 43781661 073130425890 0, 63535011 000004501951 2]
Comparing strings will be difficult and error prone.
Better parse both your json and query result to POJOs and use equals method to compare them.
This Doc Click here clearly tells me about the merchant authentication. However they only provide the content type : text/xml. Api end point for it is https://apitest.authorize.net/xml/v1/request.api ( sandbox account ).
How can I send a JSON request with name and transaction key as the keys? Also, what is the End Point to which I should send this request for mechant authentication?
Official DOC doesn't help. :'( Was hoping you could. DHC or HttpClientRequester doesn't help too. Getting error.
Authorize.net now works with JSON.
Following is a valid JSON string that you could send to Authorize using whatever platform you use and your own login and secret key.
I should note that even though JSON normally doesn't care which order the values are sent in, Authorize uses a kludgy method to internally convert JSON to XML, so order is in fact, important.
{
"createTransactionRequest": {
"merchantAuthentication": {
"name": "yourLoginKey",
"transactionKey": "yourSecretKey"
},
"refId": "12345",
"transactionRequest": {
"transactionType": "authCaptureTransaction",
"amount": "3.99",
"payment": {
"creditCard": {
"cardNumber": "4111111111111111",
"expirationDate": "0522",
"cardCode": "123"
}
},
"customer": {
"id": "John Doe"
},
"billTo": {
"firstName": "John",
"lastName": "Doe",
"address": "123 My Street",
"city": "Chicago",
"state": "IL",
"zip": "60007",
"country": "USA"
}
}
}
}
I want to get node details via Backend webscript but I have some issues. I've tried two webscripts:
alfresco/service/slingshot/doclib2/node/workspace/SpacesStore/a10a0777-40f4-42da-b236-8845eb26294e
alfresco/service/slingshot/doclib/node/workspace/SpacesStore/a10a0777-40f4-42da-b236-8845eb26294e.
The first one gave me this response :
{
"status" :
{
"code" : 410,
"name" : "Gone",
"description" : "Resource is no longer available at the server and no forwarding address is known."
},
"message" : "Location is 'null'. (No permission?)",
"exception" : "",
"callstack" :
[
],
"server" : "Enterprise v4.2.0 (r57217-b28) schema 6,034",
"time" : "Jun 10, 2014 10:28:15 AM"
}
and the second :
{
"status" :
{
"code" : 500,
"name" : "Internal Error",
"description" : "An error inside the HTTP server which prevented it from fulfilling the request."
},
"message" : "05100028 Wrapped Exception (with status template): 05100077 Failed to execute script 'classpath*:alfresco\/templates\/webscripts\/org\/alfresco\/slingshot\/documentlibrary\/node.get.js': 05100076 Site container UploadComponent.java does not refer to a folder.",
"exception" : "org.springframework.extensions.webscripts.WebScriptException - 05100028 Wrapped Exception (with status template): 05100077 Failed to execute script 'classpath*:alfresco\/templates\/webscripts\/org\/alfresco\/slingshot\/documentlibrary\/node.get.js': 05100076 Site container UploadComponent.java does not refer to a folder.",
"callstack" :
[
"" ,"org.alfresco.repo.site.SiteServiceException: 05100076 Site container UploadComponent.java does not refer to a folder."
,"
Updated :
You can notice that in the second webSript the error says that my file UploadComponent.java does not refer to a folder. Does this script take a cm:folder as an argument. If there is another web-script that returns the node details (properties: nodeRef, mimetype, size... ) from nodeRef please show it to me. thanks !
Pro tip - You can see all of the available web scripts at http://localhost:8080/alfresco/service/index/uri/
You're supposed to use the CMIS web scripts where possible, and this also makes for the simplest request.
http://<MyAlfresco>/alfresco/service/cmis/i/8826b8f4-9f61-41a4-9f21-14ad5b6395ab
This returns the full set of properties for the nodeRef workspace://SpacesStore/8826b8f4-9f61-41a4-9f21-14ad5b6395ab.
Some of the XML you will receive is:
<cmis:properties>
<cmis:propertyInteger propertyDefinitionId="cmis:contentStreamLength" displayName="Content Stream Length" queryName="cmis:contentStreamLength"><cmis:value>36864</cmis:value></cmis:propertyInteger>
<cmis:propertyId propertyDefinitionId="cmis:objectTypeId" displayName="Object Type Id" queryName="cmis:objectTypeId"><cmis:value>cmis:document</cmis:value></cmis:propertyId>
<cmis:propertyString propertyDefinitionId="cmis:versionSeriesCheckedOutBy" displayName="Version Series Checked Out By" queryName="cmis:versionSeriesCheckedOutBy"/>
<cmis:propertyBoolean propertyDefinitionId="cmis:isPrivateWorkingCopy" displayName="Is private working copy" queryName="cmis:isPrivateWorkingCopy"/>
<cmis:propertyId propertyDefinitionId="cmis:versionSeriesCheckedOutId" displayName="Version Series Checked Out Id" queryName="cmis:versionSeriesCheckedOutId"/>
<cmis:propertyId propertyDefinitionId="cmis:versionSeriesId" displayName="Version series id" queryName="cmis:versionSeriesId"><cmis:value>workspace://SpacesStore/8826b8f4-9f61-41a4-9f21-14ad5b6395ab</cmis:value></cmis:propertyId>
<cmis:propertyBoolean propertyDefinitionId="cmis:isLatestVersion" displayName="Is Latest Version" queryName="cmis:isLatestVersion"><cmis:value>true</cmis:value></cmis:propertyBoolean>
</cmis:properties>
I also checked and this should give you the properties for any node regardless of where it is situated in your Alfresco instance.
There are a few webscripts you can use, such as the CMIS ones, but I think the simplest is probably the Slingshot Document Library Node webscript, with ID org/alfresco/slingshot/documentlibrary/node.get. You can read about it at http://localhost:8080/alfresco/service/script/org/alfresco/slingshot/documentlibrary/node.get
For a node with noderef workspace://SpacesStore/357b6dad-d434-4a46-a7e0-731df50e5e90 the URL is http://localhost:8080/alfresco/service/slingshot/doclib/node/workspace/SpacesStore/357b6dad-d434-4a46-a7e0-731df50e5e90, and the JSON returned looks something like:
{
"metadata":
{
"parent":
{
"nodeRef": "workspace://SpacesStore/7f4e374c-7c7c-4356-bf8f-0ec6bfc5eac4",
"permissions":
{
"userAccess":
{
"permissions": true,
"edit": true,
"delete": true,
"cancel-checkout": false,
"create": true
}
}
},
"onlineEditing": true
},
"item":
{
"nodeRef": "workspace://SpacesStore/357b6dad-d434-4a46-a7e0-731df50e5e90",
"nodeType": "cm:content",
"type": "document",
"mimetype": "application\/vnd.ms-project",
"isFolder": false,
"isLink": false,
"fileName": "testPROJECT.mpx",
"displayName": "testPROJECT.mpx",
"status": "",
"title": "testPROJECT.mpx",
"description": "",
"author": "",
"createdOn": "2014-06-10T15:17:33.791+01:00",
"createdBy": "Administrator",
"createdByUser": "admin",
"modifiedOn": "2014-06-10T15:17:42.258+01:00",
"modifiedBy": "Administrator",
"modifiedByUser": "admin",
"lockedBy": "",
"lockedByUser": "",
"size": "3555",
"version": "1.0",
"contentUrl": "api/node/content/workspace/SpacesStore/357b6dad-d434-4a46-a7e0-731df50e5e90/testPROJECT.mpx",
"webdavUrl": "\/webdav\/User%20Homes\/administrator\/testPROJECT.mpx",
"actionSet": "document",
"tags": [],
"activeWorkflows": "",
"isFavourite": false,
"likes":
{
"isLiked": false,
"totalLikes": 0
},
"location":
{
"repositoryId": "8ff64edd-57d3-4198-ac3d-8386f47bf5bb",
"site": "",
"siteTitle": "",
"container": "",
"path": "\/User Homes\/administrator",
"file": "testPROJECT.mpx",
"parent":
{
"nodeRef": "workspace:\/\/SpacesStore\/7f4e374c-7c7c-4356-bf8f-0ec6bfc5eac4"
}
},
"permissions":
{
"inherited": true,
"roles":
[
"ALLOWED;administrator;All;INHERITED",
"ALLOWED;ROLE_OWNER;All;INHERITED"
],
"userAccess":
{
"permissions": true,
"edit": true,
"delete": true,
"cancel-checkout": false,
"create": true
}
},
"custom": {},
"actionLabels":
{
}
}
}
I believe that's all the metadata and properties you're after. It's a webscript used by Share, so ought to be well tested and used. As you can see from the location section, it's a webscript which works for both site-based and non-site nodes equally
(If you do hit problems with it, probably best to ensure you're running the latest service pack if on enterprise, or newest release for community)