Log loaded values in config
Add/remove / in REST interface.
This commit is contained in:
@ -84,7 +84,7 @@ There exist following fields:
|
|||||||
### Example
|
### Example
|
||||||
|
|
||||||
```
|
```
|
||||||
curl -H "Content-Type: application/json" -X GET -d '{"channels":["channel1","channel2"],"startPulseId":0,"endPulseId":4}' http://sf-nube-14.psi.ch:8080/channels
|
curl -H "Content-Type: application/json" -X POST -d '{"channels":["channel1","channel2"],"startPulseId":0,"endPulseId":4}' http://sf-nube-14.psi.ch:8080/query
|
||||||
```
|
```
|
||||||
|
|
||||||
### Response example
|
### Response example
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package ch.psi.daq.queryrest.config;
|
package ch.psi.daq.queryrest.config;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -131,6 +132,8 @@ public class QueryRestConfig extends WebMvcConfigurerAdapter {
|
|||||||
public Set<QueryField> defaultResponseFields() {
|
public Set<QueryField> defaultResponseFields() {
|
||||||
String[] responseFields =
|
String[] responseFields =
|
||||||
StringUtils.commaDelimitedListToStringArray(env.getProperty(QUERYREST_DEFAULT_RESPONSE_FIELDS));
|
StringUtils.commaDelimitedListToStringArray(env.getProperty(QUERYREST_DEFAULT_RESPONSE_FIELDS));
|
||||||
|
LOGGER.debug("Load '{}={}'", BEAN_NAME_DEFAULT_RESPONSE_FIELDS, Arrays.toString(responseFields));
|
||||||
|
|
||||||
// preserve order
|
// preserve order
|
||||||
LinkedHashSet<QueryField> defaultResponseFields = new LinkedHashSet<>(responseFields.length);
|
LinkedHashSet<QueryField> defaultResponseFields = new LinkedHashSet<>(responseFields.length);
|
||||||
for (String field : responseFields) {
|
for (String field : responseFields) {
|
||||||
@ -148,6 +151,8 @@ public class QueryRestConfig extends WebMvcConfigurerAdapter {
|
|||||||
public Set<Aggregation> defaultResponseAggregations() {
|
public Set<Aggregation> defaultResponseAggregations() {
|
||||||
String[] responseAggregations =
|
String[] responseAggregations =
|
||||||
StringUtils.commaDelimitedListToStringArray(env.getProperty(QUERYREST_DEFAULT_RESPONSE_AGGREGATIONS));
|
StringUtils.commaDelimitedListToStringArray(env.getProperty(QUERYREST_DEFAULT_RESPONSE_AGGREGATIONS));
|
||||||
|
LOGGER.debug("Load '{}={}'", BEAN_NAME_DEFAULT_RESPONSE_AGGREGATIONS, Arrays.toString(responseAggregations));
|
||||||
|
|
||||||
// preserve order
|
// preserve order
|
||||||
LinkedHashSet<Aggregation> defaultResponseAggregations = new LinkedHashSet<>(responseAggregations.length);
|
LinkedHashSet<Aggregation> defaultResponseAggregations = new LinkedHashSet<>(responseAggregations.length);
|
||||||
for (String aggregation : responseAggregations) {
|
for (String aggregation : responseAggregations) {
|
||||||
|
@ -70,11 +70,13 @@ public class QueryRestController {
|
|||||||
|
|
||||||
@InitBinder
|
@InitBinder
|
||||||
protected void initBinder(WebDataBinder binder) {
|
protected void initBinder(WebDataBinder binder) {
|
||||||
if (requestProviderValidator.supports(binder.getTarget().getClass())) {
|
if (binder.getTarget() != null) {
|
||||||
binder.addValidators(requestProviderValidator);
|
if (requestProviderValidator.supports(binder.getTarget().getClass())) {
|
||||||
}
|
binder.addValidators(requestProviderValidator);
|
||||||
if (queryValidator.supports(binder.getTarget().getClass())) {
|
}
|
||||||
binder.addValidators(queryValidator);
|
if (queryValidator.supports(binder.getTarget().getClass())) {
|
||||||
|
binder.addValidators(queryValidator);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +161,7 @@ public class QueryRestController {
|
|||||||
i -> 0,
|
i -> 0,
|
||||||
i -> new long[] {nrOfElements - i, nrOfElements - i, nrOfElements - i, nrOfElements - i},
|
i -> new long[] {nrOfElements - i, nrOfElements - i, nrOfElements - i, nrOfElements - i},
|
||||||
"TRFCA-channel2");
|
"TRFCA-channel2");
|
||||||
|
|
||||||
cassandraDataGen.writeData(3, 0, 4,
|
cassandraDataGen.writeData(3, 0, 4,
|
||||||
i -> i,
|
i -> i,
|
||||||
i -> 0,
|
i -> 0,
|
||||||
@ -168,7 +170,7 @@ public class QueryRestController {
|
|||||||
i -> 0,
|
i -> 0,
|
||||||
i -> i,
|
i -> i,
|
||||||
"TRFCB-channel3");
|
"TRFCB-channel3");
|
||||||
|
|
||||||
cassandraDataGen.writeData(3, 0, 4,
|
cassandraDataGen.writeData(3, 0, 4,
|
||||||
i -> i,
|
i -> i,
|
||||||
i -> 0,
|
i -> 0,
|
||||||
|
@ -53,7 +53,7 @@ public class DaqRestControllerTest extends AbstractDaqRestTest {
|
|||||||
|
|
||||||
this.mockMvc.perform(
|
this.mockMvc.perform(
|
||||||
MockMvcRequestBuilders
|
MockMvcRequestBuilders
|
||||||
.get("/" + QueryRestController.CHANNELS)
|
.get(QueryRestController.CHANNELS)
|
||||||
.contentType(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultHandlers.print())
|
.andDo(MockMvcResultHandlers.print())
|
||||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||||
@ -79,7 +79,7 @@ public class DaqRestControllerTest extends AbstractDaqRestTest {
|
|||||||
|
|
||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(MockMvcRequestBuilders
|
.perform(MockMvcRequestBuilders
|
||||||
.post("/" + QueryRestController.QUERY)
|
.post(QueryRestController.QUERY)
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.content(content))
|
.content(content))
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ public class DaqRestControllerTest extends AbstractDaqRestTest {
|
|||||||
String content = mapper.writeValueAsString(request);
|
String content = mapper.writeValueAsString(request);
|
||||||
|
|
||||||
this.mockMvc.perform(MockMvcRequestBuilders
|
this.mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/" + QueryRestController.QUERY)
|
.post(QueryRestController.QUERY)
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.content(content))
|
.content(content))
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ public class DaqRestControllerTest extends AbstractDaqRestTest {
|
|||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(
|
.perform(
|
||||||
MockMvcRequestBuilders
|
MockMvcRequestBuilders
|
||||||
.post("/" + QueryRestController.QUERY)
|
.post(QueryRestController.QUERY)
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.content(content)
|
.content(content)
|
||||||
)
|
)
|
||||||
@ -174,7 +174,7 @@ public class DaqRestControllerTest extends AbstractDaqRestTest {
|
|||||||
String content = mapper.writeValueAsString(request);
|
String content = mapper.writeValueAsString(request);
|
||||||
|
|
||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(MockMvcRequestBuilders.post("/" + QueryRestController.QUERY)
|
.perform(MockMvcRequestBuilders.post(QueryRestController.QUERY)
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.content(content))
|
.content(content))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user