use of org.eclipse.winery.model.tosca.TBoolean in project winery by eclipse.
the class ParametersResource method createParamter.
/**
* TODO: This method possibly is never called from the Angular UI
*/
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.TEXT_PLAIN)
public // @formatter:off
Response createParamter(@FormParam("name") String name, @FormParam("type") String type, // @ApiParam(value = "type tYesNo, not Boolean. For convenience, on/off is also supported. In case this parameter is not provided, 'off' is assumed. This is in contrast to the specification, but it eases implementing the UI")
@FormParam("required") String required) {
// @formatter:on
if (StringUtils.isEmpty(name)) {
return Response.status(Status.BAD_REQUEST).entity("name must not be null").build();
}
if (StringUtils.isEmpty(type)) {
return Response.status(Status.BAD_REQUEST).entity("type must not be null").build();
}
TParameter param = new TParameter();
param.setName(name);
param.setType(type);
TBoolean tb;
if (required == null) {
// The specification states that the default value is "yes"
// We assume "no", because Chrome does not send the checkbox data if a checkbox is not checked
tb = TBoolean.NO;
} else {
if (required.equalsIgnoreCase("on")) {
tb = TBoolean.YES;
} else if (required.equalsIgnoreCase("off")) {
tb = TBoolean.NO;
} else {
try {
tb = TBoolean.valueOf(required);
} catch (java.lang.IllegalArgumentException e) {
return Response.status(Status.BAD_REQUEST).entity("Wrong format of required").build();
}
}
}
param.setRequired(tb);
this.list.add(param);
return RestUtils.persist(this.res);
}
use of org.eclipse.winery.model.tosca.TBoolean in project winery by eclipse.
the class ParameterResource method putRequired.
@PUT
@Path("required")
public Response putRequired(@FormParam(value = "required") String required) {
TBoolean tb = TBoolean.valueOf(required);
this.o.setRequired(tb);
return RestUtils.persist(this.res);
}
Aggregations