mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01: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);
|
restLabel.setTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Label label = restLabel.getDelegated();
|
|
||||||
|
|
||||||
// Validate ...
|
// Validate ...
|
||||||
final BindingResult result = new BeanPropertyBindingResult(restLabel, "");
|
validate(restLabel);
|
||||||
new LabelValidator(labelService).validate(label, result);
|
|
||||||
if (result.hasErrors()) {
|
|
||||||
throw new ValidationException(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add new label ...
|
final Label label = createLabel(restLabel);
|
||||||
final User user = Utils.getUser();
|
|
||||||
assert user != null;
|
|
||||||
labelService.addLabel(label, user);
|
|
||||||
|
|
||||||
// Return the new created map ...
|
// Return the new created label ...
|
||||||
response.setHeader("ResourceId", Integer.toString(label.getId()));
|
response.setHeader("ResourceId", Integer.toString(label.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,4 +96,21 @@ public class LabelController extends BaseController {
|
|||||||
assert user != null;
|
assert user != null;
|
||||||
labelService.removeLabel(label, user);
|
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