mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-09-11 23:00:06 +02:00
adding private methods
This commit is contained in:
parent
12ec295fe0
commit
5fe892abfd
@ -50,21 +50,12 @@ public class LabelController extends BaseController {
|
||||
restLabel.setTitle(title);
|
||||
}
|
||||
|
||||
final Label label = restLabel.getDelegated();
|
||||
|
||||
// Validate ...
|
||||
final BindingResult result = new BeanPropertyBindingResult(restLabel, "");
|
||||
new LabelValidator(labelService).validate(label, result);
|
||||
if (result.hasErrors()) {
|
||||
throw new ValidationException(result);
|
||||
}
|
||||
validate(restLabel);
|
||||
|
||||
// Add new label ...
|
||||
final User user = Utils.getUser();
|
||||
assert user != null;
|
||||
labelService.addLabel(label, user);
|
||||
final Label label = createLabel(restLabel);
|
||||
|
||||
// Return the new created map ...
|
||||
// Return the new created label ...
|
||||
response.setHeader("ResourceId", Integer.toString(label.getId()));
|
||||
}
|
||||
|
||||
@ -105,4 +96,21 @@ public class LabelController extends BaseController {
|
||||
assert user != null;
|
||||
labelService.removeLabel(label, user);
|
||||
}
|
||||
|
||||
@NotNull private Label createLabel(@NotNull final RestLabel restLabel) throws WiseMappingException {
|
||||
final Label label = restLabel.getDelegated();
|
||||
// Add new label ...
|
||||
final User user = Utils.getUser();
|
||||
assert user != null;
|
||||
labelService.addLabel(label, user);
|
||||
return label;
|
||||
}
|
||||
|
||||
private void validate(@NotNull final RestLabel restLabel) throws ValidationException {
|
||||
final BindingResult result = new BeanPropertyBindingResult(restLabel, "");
|
||||
new LabelValidator(labelService).validate(restLabel.getDelegated(), result);
|
||||
if (result.hasErrors()) {
|
||||
throw new ValidationException(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user