Clean Code Refactoring

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-02-09 13:36:58 +01:00
parent a4e1ae7ac8
commit b21f8f5c71
2 changed files with 25 additions and 15 deletions

View File

@@ -298,20 +298,7 @@ public class AmqpMessageHandlerService {
*/
private void updateActionStatus(final Message message) {
final ActionUpdateStatus actionUpdateStatus = convertMessage(message, ActionUpdateStatus.class);
final Long actionId = actionUpdateStatus.getActionId();
LOG.debug("Target notifies intermediate about action {} with status {}.", actionId, actionUpdateStatus
.getActionStatus().name());
if (actionId == null) {
logAndThrowMessageError(message, "Invalid message no action id");
}
final Action action = controllerManagement.findActionWithDetails(actionId);
if (action == null) {
logAndThrowMessageError(message, "Got intermediate notification about action " + actionId
+ " but action does not exist");
}
final Action action = checkActionExist(message, actionUpdateStatus);
final ActionStatus actionStatus = new ActionStatus();
final List<String> messageText = actionUpdateStatus.getMessage();
@@ -362,6 +349,29 @@ public class AmqpMessageHandlerService {
}
}
/**
* @param message
* @param actionUpdateStatus
* @return
*/
private Action checkActionExist(final Message message, final ActionUpdateStatus actionUpdateStatus) {
final Long actionId = actionUpdateStatus.getActionId();
LOG.debug("Target notifies intermediate about action {} with status {}.", actionId, actionUpdateStatus
.getActionStatus().name());
if (actionId == null) {
logAndThrowMessageError(message, "Invalid message no action id");
}
final Action action = controllerManagement.findActionWithDetails(actionId);
if (action == null) {
logAndThrowMessageError(message, "Got intermediate notification about action " + actionId
+ " but action does not exist");
}
return action;
}
private void handleCancelRejected(final Message message, final Action action, final ActionStatus actionStatus) {
if (action.isCancelingOrCanceled()) {

View File

@@ -161,7 +161,7 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
@Override
protected Map<String, Object> getVendorProperties() {
final Map<String, Object> properties = new HashMap<String, Object>();
final Map<String, Object> properties = new HashMap<>();
// Turn off dynamic weaving to disable LTW lookup in static weaving mode
properties.put("eclipselink.weaving", "false");
// needed for reports