Commit 828f034e authored by Richard Bruskiewich's avatar Richard Bruskiewich Committed by Matija Obreza
Browse files

No HTML sanitation (Squashed by Matija)

parent 2fa6cde0
...@@ -30,6 +30,7 @@ import net.sf.oval.constraint.NotNull; ...@@ -30,6 +30,7 @@ import net.sf.oval.constraint.NotNull;
import org.genesys2.server.exception.AuthorizationException; import org.genesys2.server.exception.AuthorizationException;
import org.genesys2.server.model.genesys.Method; import org.genesys2.server.model.genesys.Method;
import org.genesys2.server.model.genesys.Parameter; import org.genesys2.server.model.genesys.Parameter;
import org.genesys2.server.model.impl.Crop;
import org.genesys2.server.service.CropService; import org.genesys2.server.service.CropService;
import org.genesys2.server.service.GenesysService; import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.TraitService; import org.genesys2.server.service.TraitService;
...@@ -108,7 +109,7 @@ public class TraitsController extends RestController { ...@@ -108,7 +109,7 @@ public class TraitsController extends RestController {
@RequestMapping(value = "/methods", method = { RequestMethod.PUT, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE }) @RequestMapping(value = "/methods", method = { RequestMethod.PUT, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody public @ResponseBody
Object createMethod(@RequestBody MethodJson methodJson) throws ValidationException { Object createMethod(@RequestBody MethodJson methodJson) throws ValidationException {
LOG.info("Creating method"); LOG.info("Creating method:");
Validator validator = new Validator(); Validator validator = new Validator();
List<ConstraintViolation> violations = validator.validate(methodJson); List<ConstraintViolation> violations = validator.validate(methodJson);
if (violations.size() > 0) { if (violations.size() > 0) {
...@@ -144,4 +145,44 @@ public class TraitsController extends RestController { ...@@ -144,4 +145,44 @@ public class TraitsController extends RestController {
@NotBlank @NotBlank
public String range; public String range;
} }
/**
* Add a crop
*
* @return
* @throws ValidationException
*/
@RequestMapping(value = "/{taxon}/property", method = { RequestMethod.PUT, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody
Object createProperty(
@PathVariable("taxon") String taxon,
@RequestBody PropertyJson propertyJson
) throws ValidationException {
LOG.info("Creating crop property:");
Validator validator = new Validator();
List<ConstraintViolation> violations = validator.validate(propertyJson);
if (violations.size() > 0) {
// TODO We could do better messages on validation error
throw new ModelValidationException("Validation problem", violations);
}
Crop crop = cropService.getCrop(taxon) ;
Parameter property = traitService.addParameter(crop, propertyJson.title);
return property;
}
public static class PropertyJson {
//@NotNull
//@NotBlank
//public String uri;
@NotNull
@NotBlank
public String title;
}
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment