formatting changes on file.

This commit is contained in:
Keith Woodlock
2013-02-05 20:40:09 +00:00
parent 27bb852e3a
commit f73dc7e742
@@ -53,19 +53,18 @@ public class RoleWritePlatformServiceJpaRepositoryImpl implements RoleWritePlatf
try { try {
context.authenticatedUser(); context.authenticatedUser();
this.roleCommandFromApiJsonDeserializer.validateForCreate(command this.roleCommandFromApiJsonDeserializer.validateForCreate(command.json());
.json());
final Role entity = Role.fromJson(command); final Role entity = Role.fromJson(command);
this.roleRepository.save(entity); this.roleRepository.save(entity);
return new CommandProcessingResultBuilder() return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(entity.getId()).build();
.withCommandId(command.commandId())
.withEntityId(entity.getId()).build();
} catch (DataIntegrityViolationException dve) { } catch (DataIntegrityViolationException dve) {
handleDataIntegrityIssues(command, dve); handleDataIntegrityIssues(command, dve);
return CommandProcessingResult.empty(); return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
.build();
} }
} }
@@ -79,8 +78,8 @@ public class RoleWritePlatformServiceJpaRepositoryImpl implements RoleWritePlatf
if (realCause.getMessage().contains("unq_name")) { if (realCause.getMessage().contains("unq_name")) {
final String name = command.stringValueOfParameterNamed("name"); final String name = command.stringValueOfParameterNamed("name");
throw new PlatformDataIntegrityException("error.msg.role.duplicate.name", "Role with name `" + name throw new PlatformDataIntegrityException("error.msg.role.duplicate.name", "Role with name `" + name + "` already exists",
+ "` already exists", "name", name); "name", name);
} }
logAsErrorUnexpectedDataIntegrityException(dve); logAsErrorUnexpectedDataIntegrityException(dve);
@@ -98,13 +97,10 @@ public class RoleWritePlatformServiceJpaRepositoryImpl implements RoleWritePlatf
try { try {
context.authenticatedUser(); context.authenticatedUser();
this.roleCommandFromApiJsonDeserializer.validateForUpdate(command this.roleCommandFromApiJsonDeserializer.validateForUpdate(command.json());
.json());
final Role role = this.roleRepository.findOne(roleId); final Role role = this.roleRepository.findOne(roleId);
if (role == null) { if (role == null) { throw new RoleNotFoundException(roleId); }
throw new RoleNotFoundException(roleId);
}
final Map<String, Object> changes = role.update(command); final Map<String, Object> changes = role.update(command);
if (!changes.isEmpty()) { if (!changes.isEmpty()) {
@@ -113,11 +109,14 @@ public class RoleWritePlatformServiceJpaRepositoryImpl implements RoleWritePlatf
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withEntityId(roleId).with(changes) // .withEntityId(roleId) //
.with(changes) //
.build(); .build();
} catch (DataIntegrityViolationException dve) { } catch (DataIntegrityViolationException dve) {
handleDataIntegrityIssues(command, dve); handleDataIntegrityIssues(command, dve);
return new CommandProcessingResult(Long.valueOf(-1)); return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
.build();
} }
} }