Prevent camel-jackson from removing quotation marks - jackson

I am working on a camel route for a REST service. My task is to add a POST in which I need to take a token out of the json that is sent. I am doing the following:
.unmarshal().json(JsonLibrary.Jackson, Token.class)
I added the "camel-jackson" dependency to my pom file and it works fine.
Problem: Now all the json coming is has the double quotation marks stripped off. So the following json:
{"name": "John Doe", "job": "farmer"}
Ends up as:
{name:John Doe,job:farmer}
For some of my code I need the double quotes. I have tried to do a bit of configuring my rest route with no luck. Any one have an idea of a fix?

You mention in the comment that you have
restConfiguration()
.component("jetty")
.scheme("https")
.bindingMode(RestBindingMode.auto)
.dataFormatProperty("prettyPrint", "true")
.port(8443);
You don't mention what your route is. However, if you're using bindingMode it will expect a type() on the get()/post() which will be used to unmarshal json into. It sounds like you only want to do this for the new POST you are adding, so why not have the binding on the post() rather than globally on the restConfiguration()?
e.g.
restConfiguration()
.component("jetty")
.scheme("https")
.dataFormatProperty("prettyPrint", "true")
.port(8443);
rest("/words")
.post("/new/post/url")
.bindingMode(RestBindingMode.auto)
.type(YourPojo.class)
...
.get("existing/stuff")
...

Related

How to add comment and spent time in one call to Gitlab API?

I have two separate calls
addSpentTime(projectId, issueIid, duration, date) {
const endpoint = this.apiUrl(
`/projects/${projectId}/issues/${issueIid}/notes?body=/spend ${duration} ${date}`
);
return this.ajaxRequest("POST", endpoint);
}
addComment(projectId, issueIid, comment) {
const endpoint = this.apiUrl(
`/projects/${projectId}/issues/${issueIid}/notes?body=${comment}`
);
return this.ajaxRequest("POST", endpoint);
}
The first one is for sending how much time has been spent on an issue and the latter is for adding a comment to the issue.
I'd like to do both of these actions in one call like this
addSpentTimeAndComment(projectId, issueIid, duration, date, comment) {
const endpoint = this.apiUrl(
`/projects/${projectId}/issues/${issueIid}/notes?body=${comment}/spend ${duration} ${date}`
);
return this.ajaxRequest("POST", endpoint);
}
but the suffix /spend ${duration} ${date} makes it into the comment as well. It seems that the API takes literally everything that comes after body= as a part of the comment. I tried to add \n, \\n, spaces, backslashes to signify the end of the comment so that the /spend part gets evaluated as well and I also tried changing the order so that the /spend is before the comment body but nothing seemed to work. The GitLab API docs don't mention any standard way of ending the comment or maybe they do but I can't find it anywhere. Furthermore, I don't even know what it's called - delimiter, escaping symbol...?
Is there a way of signifying the ending of the comment, giving a way of appending other commands?
As part of the comment (project note) call, append the time as a Quick Action using the /spend <time> call.
By posting that to the API with the comment, GitLab will add the time at the same time it adds the comment.

ORDS: Removing escaping char from json in ORDS OUT param

I am using the OUT parameter in the ORDS parameters to send a response which is already in JSON and this stored as CLOB in the DB. When I send this out in the response from the ORDS, ORDS is actually adding lot of back spaces to the response.
Can someone help me to understand how I can remove the escaping chars here(all the backslashes). I had tried a different approach explained by Jeff in another thread to try to use an alias for the JSON key, but it did not work for me.
Over here I have mentioned the response as OUT parameter in my code.
eg payload:
{
"response": "{\n\"Order\":{\n\"OriginalShipmentID\":1\n,\"orderNumber\":1\n,\"orgID\":1\n,\"orderShipmentNumber\":1\n,\"oracleShipSet\":\"1\"\n,\"OeHeaderId\":1\n,\"GsHeaderId\":1\n,\"CustomerPoNumber\":\"1\"\n,\"PaymentTerms\":1\n,\"FreightTerms\":\"PAID\"\n,\"CurrencyCode\":\"USD\"\n,\"BillToSiteUseID\":1\n,\"ShipToSiteUseID\":1\n,\"SalesChannel\":\"DIRECT\"\n,\"HeaderKeyCode\":\"1 1\"\n,\"OrigSysDocumentRef\":\"1\"\n,\"OrderTypeCode\":\"XYZ yXYZ\"\n,\"OrderTypeID\":1\n,\"SalesRepID\":-3\n,\"IsAtgOrder\":\"N\"\n,\"OrderSource\":\"MCP\"\n,\"OdiDocSet\":\"PO\"\n,\"CsServiceSymbol\":\"XYZ\"\n,\"CsServiceFriendlyName\":\"XYZ\"\n,\"CsShipper\":\"NDC_MX\"\n,\"GsShipToAddressID\":1\n,\"GsBillFrtAddressID\":-1\n,\"BillingMethod\":\"DoNotBillFreight\"\n,\"ReasonForNoInvoice\":\"NA\"\n,\"ShippedBy\":\"NA\"\n,\"ManifestID\":1771748\n,\"IsVoided\":\"N\"\n,\"CustomerNumber\":\"1\"\n,\"OrderLines\":[\n]\n,\"HeaderShortNotes\":{\n}\n}\n}\n"
}
Some more details:
SELECT get_json ( :ordernumber,
:warehouseid,
:shipset,
:ordershipmentno,
:gsshipmentid,
:countrycode,
:shipperid,
:fromcurrency,
:tocurrency,
:groupid,
:optionvalues,
:linehaul,
:servicename,
:sigid,
:lineid,
:customerid) "{}Order"
INTO l_response_clob
FROM DUAL;
This function returns a CLOB with a JSON format data and l_response_clob is defined as STRING output parameter on the ORDS.
Essentially, I want to stop ORDS from again converting JSON to JSON.
Been banging head over this from some time but can't seem to make it work.
Thanks for the help I can get here.

Multi param values are not replaced properly in the path

I have multiple parameters in the REST call as shown below
/integration/live/rest/accessProfile?page=0&pageSize=10&sortBy=name&fieldList=name,id,date_created,date_modified,created_id,modified_id&filter=id%20not%20equal%20to%20%27200%27%20AND%20id%20not%20equal%20to%20%27100%27%20AND%20id%20not%20equal%20to%20%27101%27%20AND%20id%20not%20equal%20to%20%27102%27%20AND%20id%20not%20equal%20to%20%27103%27%20&getTotalRecordCo
My code is
* params { page: '0', pageSize: '10',sortBy: 'name', fieldList: ['name','id', 'date_created', 'date_modified', 'created_id', 'modified_id'],filter: 'id%20not%20equal%20to%20%27200%27%20AND%20id%20not%20equal%20to%20%27100%27%20AND%20id%20not%20equal%20to%20%27101%27%20AND%20id%20not%20equal%20to%20%27102%27%20AND%20id%20not%20equal%20to%20%27103%27%20',getTotalRecordCount:true }
And path '/integration/live/rest/accessProfile'
When I am running the test cases the path is not properly replaced in the REST call
After running the actual call sent to the server is
https://vm-trunk-wmic-01.eur.ad.sag/integration/live/rest/accessProfile?page=0&pageSize=10&sortBy=name&fieldList=name&fieldList=id&fieldList=date_created&fieldList=date_modified&fieldList=created_id&fieldList=modified_id&filter=id%2520not%2520equal%2520to%2520%2527200%2527%2520AND%2520id%2520not%2520equal%2520to%2520%2527100%2527%2520AND%2520id%2520not%2520equal%2520to%2520%2527101%2527%2520AND%2520id%2520not%2520equal%2520to%2520%2527102%2527%2520AND%2520id%2520not%2520equal%2520to%2520%2527103%2527%2520&getTotalRecordCount=true
All the params are replaced properly except for 'fieldList' parameter in the path.
I am looking for correct syntax to pass my below REST call
/integration/live/rest/accessProfile?page=0&pageSize=10&sortBy=name&fieldList=name,id,date_created,date_modified,created_id,modified_id&filter=id%20not%20equal%20to%20%27200%27%20AND%20id%20not%20equal%20to%20%27100%27%20AND%20id%20not%20equal%20to%20%27101%27%20AND%20id%20not%20equal%20to%20%27102%27%20AND%20id%20not%20equal%20to%20%27103%27%20&getTotalRecordCount=true
Try:
* params { fieldList: 'name,id,date_created,date_modified,created_id,modified_id' }
EDIT: please note that commas will be URL-encoded as per the HTML spec. If you really want to "see" the commas, build the url yourself.
For an example of the 2 ways to do this, see this commit: https://github.com/intuit/karate/commit/14c6321606bb6bcb626614248f85cc8ea50c61b6

m.request: use URL which contains colons

I have a m.request call like this:
mCmdName = "cn:cmd:list:deselectAll";
m.request({
method : "POST",
url : "/testing/cmd/" + mCmdName,
data: data
});
Now m.request calls
xhrOptions.url = parameterizeUrl(xhrOptions.url, xhrOptions.data);
and tries to replace all ':[name]' parts with data[name] which results in 'undefined' as data doesn't contain any of the keys. Data is just the data object of the XHR request.
Is there a way to prohibit this default behavior?
Thanks, Stefan
PS: I'm asking here and not in mithril mailing list because I can't post there for incomprehensible reasons. Maybe somebody can give me a hint on this.
Have you tried
encodeURIComponent("cn:cmd:list:deselectAll")
which gives you
cn%3Acmd%3Alist%3AdeselectAll
If necessary you can decode on the server.

How can I call a WCF service from code, in the .net framework 3

I'm working in VB.Net and I'm trying to make a piece of code more generic.
In fact, there's a big Select Case statement that build a ProxyServer based on a value passed in parameter (a string).
Select Case _strNteraHL7
Case Constantes.NomPRPMIN306010
strUrl = ObtenirUrl("ProviderDetailsQuery", _strVersion, _strEnvir, True, _blnSimulCAIS, _blnSimulPDS, _blnSimulPDSSIIR, _blnSimulPDSInteg)
objWsHL7 = New wsProviderDetailsQuery.ProviderDetailsQueryClient(objBinding, New EndpointAddress(strUrl))
Case Constantes.NomPRPMIN301010
strUrl = ObtenirUrl("AddProvider", _strVersion, _strEnvir, True, _blnSimulCAIS, _blnSimulPDS, _blnSimulPDSSIIR, _blnSimulPDSInteg)
objWsHL7 = New wsAddProvider.AddProviderClient(objBinding, New EndpointAddress(strUrl))
The objects like "wsAddProvider" and "wsProviderDetailsQuery" in the previous example are service references that have been added through the GUI of Visual Studio...
What I want to know, is basically, if I can call this constructor from a certain pool containing service references, similar as when I want to call a control in a controls container...
for example:
objWsHL7 = new wcfServicesContainer("serviceNameHere", paramArray())
or something similar, so I can remove all those big switch cases, that repeat the same thing 30 times.
objWsHL7 being an object or type "object" at compiling.
Sorry if I didn't mention enough detail, feel free to let me know if you need more, I don't really know what information I have to provide for this.
Edit: I've spotted another piece of code here that uses similar calls, maybe it'll help understanding...
Again, in another switch case statement,
objMsgHL7Out = _objWsHL7.ProviderDetailsQuery(_objMsgIn)
objMsgHL7Out is a System.ServiceModel.Channels.Message
_objMsgIn is a System.ServiceModel.Channels.Message
_objWsHL7 is an Object
Try this:
Create a hashmap of HashMap<string, string>
Add Constantes.NomPRPMIN306010, ... as key and "AddProvider", ... as value.
call ObtenirUrl(hashmap[_strNteraHL7], ...