Revision 50238
Added by Claudio Atzori over 6 years ago
DatasourcesApiController.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.openaire.exporter.datasource; |
2 | 2 |
|
3 | 3 |
import java.util.List; |
4 |
import javax.validation.Valid; |
|
4 | 5 |
|
5 | 6 |
import eu.dnetlib.common.rmi.DNetRestDocumentation; |
6 | 7 |
import eu.dnetlib.enabling.datasources.common.DsmException; |
... | ... | |
142 | 143 |
tags = { DS, W }) |
143 | 144 |
@ApiResponses(value = { |
144 | 145 |
@ApiResponse(code = 200, message = "OK"), |
145 |
@ApiResponse(code = 500, message = "unexpected error", response = ErrorMessage.class) }) |
|
146 |
public void saveDs(@RequestBody final DatasourceDetails datasource) throws DsmException { |
|
146 |
@ApiResponse(code = 400, message = "Malformed request", response = ErrorMessage[].class), |
|
147 |
@ApiResponse(code = 500, message = "Unexpected error", response = ErrorMessage.class) }) |
|
148 |
public void saveDs(@Valid @RequestBody final DatasourceDetails datasource) throws DsmException { |
|
147 | 149 |
|
148 | 150 |
if (dsmCore.exist(datasource)) { // TODO further check that the DS doesn't have any API |
149 |
throw new DsmException(HttpStatus.SC_CONFLICT, String.format("cannot already defined '%s'", datasource.getId())); |
|
151 |
throw new DsmException(HttpStatus.SC_CONFLICT, String.format("cannot register, datasource already defined '%s'", datasource.getId()));
|
|
150 | 152 |
} |
151 | 153 |
dsmCore.save(datasource); |
152 | 154 |
} |
Also available in: Unified diff
added initial test for DSM controller, added Datasource validation annotation, fixed conversion from API model to db model