Spring Cloud Config Server - Response Description - spring

Is there any documentation which provides description of all the elements in Spring Cloud Config Server's response
{
"name":"myapp",
"profiles":[
"default"
],
"label":null,
"version":null,
"state":null,
"propertySources":[
{
"name":"vault:myapp",
"source":{
"foo":"myappsbar"
}
},
{
"name":"vault:application",
"source":{
"baz":"bam",
"foo":"bar"
}
}
]
}

Based on source code it's:
Simple plain text serializable encapsulation of a list of property sources. Basically a DTO for {#link org.springframework.core.env.Environment}, but also applicable outside the domain of a Spring application.
See: https://github.com/spring-cloud/spring-cloud-config/blob/master/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/environment/Environment.java
and
https://github.com/spring-cloud/spring-cloud-config/blob/master/spring-cloud-config-client/src/main/java/org/springframework/cloud/config/environment/PropertySource.java

Please refer https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html#vault-backend It has a response object which is the same as your question and the documentation can help you understand each and every parameter in that object.

Related

Auditing in spring boot - How to custimise?

I followed this document for implementing Auditing in spring boot.
(https://www.baeldung.com/database-auditing-jpa)
Auditing is working fine but when the object is of type list means we are persisting as multiple entries in db.
I am passing this request object for rest API :-
`
[
{
"name": "reddy"
},
{
"name": "mani"
}
]
`
for each object we are getting one audit log in db.
Is there any way to achieve as single entry in database?

Google Form Api. Adding Response validation to textQuestion

Currently, AFAIK, when performing google form batchUpdate using the google forms API v1, we are only able to set the shuffle property of choiceQuestions, while for textQuestions there are no options to set the response validations, like if I want to use regex match as validation.
For Example, the request body looks like this:
{
"requests": [
{
"createItem": {
"item": {
"questionItem": {
"question": {
"choiceQuestion": {
"shuffle": false
},
"textQuestion": {
"paragraph": false
/*no other parameters to set*/
}
}
}
}
}
}
]
}
Am I missing something? Or is this feature not implemented yet?
You are correct, this has not been implemented yet. For now, these are the only options that can be used with ChoiceQuestion This is kind of expected taking into consideration FORMS API was launched just last month.
So you may want to submit a Feature Request for that missing feature.
In the meantime, you can also consider tackling this using Google Apps Script and its Forms Advanced Service which includes response validation.

how to tell rest post data is invalid in spring

I have a post data request as the following,
{
"doctorId":1,
"userId":29,
"sampleConditions":[
{
"conditionId":"14",
"conditionName":"Acne",
"conditionDate":"2017-01-31"
}
],
"labOrder":{
"testId" : [1,2,3]
}
}
what happens, if the client gives the incorrect key
"sampleConditionss":[
{
"conditionId":"14",
"conditionName":"Acne",
"conditionDate":"2017-01-31"
}
],
Instead of giving sampleConditions, the client have sent the request as sampleConditionss.
How can i handle the request,
When you are using springs the spring framework will return 400 and you need not do anything here

How to create custom DbRefs in Spring Data

I need to support a MongoDB database originally created by a parse.com installation.
I'm using Spring Boot and Spring Data. The problem is that parse.com and Spring Data have different implementations of DB references:
parse.com
_p_meal_ : { Meal$eh0662S2wn }
_p_FIELD_ : { <REF_CLASS>$<REF_ID> } // generically
Spring Data follows the recommendation
meal: { "$ref" : "meals", "$id" : ObjectId("5126bc054aed4daf9e2ab772"), "$db" : "maindb" }
FIELD: { "$ref": REF_CLASS, "$id": ID, "$db": DATABASE } // generically
I want to configure Spring Data so it knows how to read&write DB references the same way as parse.com.
I suspect it has to do with providing a custom DbRefResolver to MongoTemplate but I'm not sure.
Thanks

Exchanging Spring Hypermedia Resources with HAL+JSON CURIEs via RestTemplate

I am using Spring Framework 4.1.0 and Spring HATEOAS 0.16.0 to develop both a Spring web application and a Spring test client for that application.
The test client has a statement like:
ResponseEntity<Resource<Calculation>> response = restTemplate.exchange(
calculationsUri,
HttpMethod.POST,
new HttpEntity<Calculation>(calculation),
new ParameterizedTypeReference<Resource<Calculation>>()
);
...wherein Calculation is a POJO with Jackson annotations (for example, #JsonProperty).
Without CURIEs, that RestTemplate.exchange() invocation succeeds: response.getBody().getLinks() returns a non-null non-empty instance of List<Link>.
My web application has non-standard link relations, for example, "sub-calculations". I want to use CURIEs.
With CURIEs, that RestTemplate.exchange() invocation fails: The response-deserialization code throws org.springframework.http.converter.HttpMessageNotReadableException, caused by com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:
'Could not read JSON: Unrecognized field "name" (class org.springframework.hateoas.Link), not marked as ignorable (one known property "href"])'
In particular, Jackson fails to deserialize the CURIE(s) from the _links map in the response JSON to the List<Link>-typed field org.springframework.hateoas.ResourceSupport.links. The response JSON looks like:
{
"_links" : {
"self" : {
"href" : "..."
},
"myNamespace:sub-calculations" : [ {
"href" : "..."
}, {
"href" : "..."
} ],
"curies" : [ {
"href" : ".../{rel}",
"name" : "myNamespace",
"templated" : true
} ]
}
}
How may I use RestTemplate.exchange() to obtain a resource whose HAL+JSON ("application/hal+json") representation uses CURIEs?
looks like the library simply doesn't support the name field of HAL link object https://datatracker.ietf.org/doc/html/draft-kelly-json-hal-06#section-5.5 ...doesn't really have anything to do with CURIE's. You should open an issue with that library to support all the fields of HAL link objects.
As far as CURIE #CCCV in your example they key is AWALYS myNamespace:sub-calculations no matter if CURIE is present or not. CURIE just lets you dereference to a URL that SHOULD link to documentation. It's kinda weird, and i see implementations get it wrong all the time thinking the URI is what matters. see https://groups.google.com/d/msg/hal-discuss/lt0CnC3eev4/YinN1Us54KcJ i'm not saying i agree with it..but that's how it's supposed to be

Resources