fix issue with updating root office details.

This commit is contained in:
Keith Woodlock
2012-12-15 22:15:39 +00:00
parent e52b66d562
commit 08a8b8cff0
2 changed files with 7 additions and 2 deletions
@@ -133,7 +133,7 @@ public final class JsonCommand {
return differenceExists;
}
private boolean parameterExists(final String parameterName) {
public boolean parameterExists(final String parameterName) {
return this.fromApiJsonHelper.parameterExists(parameterName, parsedCommand);
}
@@ -101,7 +101,12 @@ public class Office extends AbstractAuditableCustom<AppUser, Long> {
final String localeAsInput = command.locale();
final String parentIdParamName = "parentId";
if (command.isChangeInLongParameterNamed(parentIdParamName, this.parent.getId())) {
if (command.parameterExists(parentIdParamName) && this.parent == null) {
throw new RootOfficeParentCannotBeUpdated();
}
if (this.parent != null && command.isChangeInLongParameterNamed(parentIdParamName, this.parent.getId())) {
final Long newValue = command.longValueOfParameterNamed(parentIdParamName);
actualChanges.put(parentIdParamName, newValue);
}