comparison src/main/java/de/intevation/lada/rest/stamm/OrtService.java @ 1237:e49c006b9076

Handle errors in OrtFactory and pass them to the client.
author Tom Gottfried <tom@intevation.de>
date Tue, 13 Dec 2016 20:06:57 +0100
parents 32e27cb8cfef
children 75692dc7077f
comparison
equal deleted inserted replaced
1236:d67b10dc5d4b 1237:e49c006b9076
24 import javax.ws.rs.core.HttpHeaders; 24 import javax.ws.rs.core.HttpHeaders;
25 import javax.ws.rs.core.MediaType; 25 import javax.ws.rs.core.MediaType;
26 import javax.ws.rs.core.MultivaluedMap; 26 import javax.ws.rs.core.MultivaluedMap;
27 import javax.ws.rs.core.UriInfo; 27 import javax.ws.rs.core.UriInfo;
28 28
29 import de.intevation.lada.importer.ReportItem;
29 import de.intevation.lada.factory.OrtFactory; 30 import de.intevation.lada.factory.OrtFactory;
30 import de.intevation.lada.model.stammdaten.Filter; 31 import de.intevation.lada.model.stammdaten.Filter;
31 import de.intevation.lada.model.stammdaten.Ort; 32 import de.intevation.lada.model.stammdaten.Ort;
32 import de.intevation.lada.util.annotation.AuthorizationConfig; 33 import de.intevation.lada.util.annotation.AuthorizationConfig;
33 import de.intevation.lada.util.annotation.RepositoryConfig; 34 import de.intevation.lada.util.annotation.RepositoryConfig;
277 response.setWarnings(violation.getWarnings()); 278 response.setWarnings(violation.getWarnings());
278 return response; 279 return response;
279 } 280 }
280 281
281 ortFactory.transformCoordinates(ort); 282 ortFactory.transformCoordinates(ort);
283 if (ortFactory.hasErrors()) {
284 Violation factoryErrs = new Violation();
285 for (ReportItem err : ortFactory.getErrors()) {
286 factoryErrs.addError(err.getKey(), err.getCode());
287 }
288 Response response = new Response(false, 604, ort);
289 response.setErrors(factoryErrs.getErrors());
290 return response;
291 }
282 Response response = repository.create(ort, "stamm"); 292 Response response = repository.create(ort, "stamm");
283 if(violation.hasWarnings()) { 293 if(violation.hasWarnings()) {
284 response.setWarnings(violation.getWarnings()); 294 response.setWarnings(violation.getWarnings());
285 } 295 }
286 296
338 response.setWarnings(violation.getWarnings()); 348 response.setWarnings(violation.getWarnings());
339 return response; 349 return response;
340 } 350 }
341 351
342 ortFactory.transformCoordinates(ort); 352 ortFactory.transformCoordinates(ort);
353 if (ortFactory.hasErrors()) {
354 Violation factoryErrs = new Violation();
355 for (ReportItem err : ortFactory.getErrors()) {
356 factoryErrs.addError(err.getKey(), err.getCode());
357 }
358 Response response = new Response(false, 604, ort);
359 response.setErrors(factoryErrs.getErrors());
360 return response;
361 }
343 Response response = repository.update(ort, "stamm"); 362 Response response = repository.update(ort, "stamm");
344 if(violation.hasWarnings()) { 363 if(violation.hasWarnings()) {
345 response.setWarnings(violation.getWarnings()); 364 response.setWarnings(violation.getWarnings());
346 } 365 }
347 366
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)