DDI improvements and Maintenance Window states in UI (#658)

* Add DDI status and tests.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Add new downloaded status to UI.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Reduce message noise.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix sonar issue.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2018-03-14 15:17:08 +01:00
committed by GitHub
parent 1f43862618
commit a8cd650375
7 changed files with 60 additions and 26 deletions

View File

@@ -106,7 +106,12 @@ public class DdiStatus {
/** /**
* The action has been downloaded by the target. * The action has been downloaded by the target.
*/ */
DOWNLOADED("downloaded"); DOWNLOADED("downloaded"),
/**
* Target starts to download.
*/
DOWNLOAD("download");
private String name; private String name;

View File

@@ -67,6 +67,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.http.server.ServletServerHttpRequest; import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -363,49 +364,61 @@ public class DdiRootController implements DdiRootControllerRestApi {
final Long actionid) { final Long actionid) {
final List<String> messages = new ArrayList<>(); final List<String> messages = new ArrayList<>();
if (!CollectionUtils.isEmpty(feedback.getStatus().getDetails())) {
messages.addAll(feedback.getStatus().getDetails());
}
Status status; Status status;
switch (feedback.getStatus().getExecution()) { switch (feedback.getStatus().getExecution()) {
case CANCELED: case CANCELED:
LOG.debug("Controller confirmed cancel (actionid: {}, controllerId: {}) as we got {} report.", actionid, LOG.debug("Controller confirmed cancel (actionid: {}, controllerId: {}) as we got {} report.", actionid,
controllerId, feedback.getStatus().getExecution()); controllerId, feedback.getStatus().getExecution());
status = Status.CANCELED; status = Status.CANCELED;
messages.add(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target confirmed cancelation."); addMessageIfEmpty("Target confirmed cancelation.", messages);
break; break;
case REJECTED: case REJECTED:
LOG.info("Controller reported internal error (actionid: {}, controllerId: {}) as we got {} report.", LOG.info("Controller reported internal error (actionid: {}, controllerId: {}) as we got {} report.",
actionid, controllerId, feedback.getStatus().getExecution()); actionid, controllerId, feedback.getStatus().getExecution());
status = Status.WARNING; status = Status.WARNING;
messages.add(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target REJECTED update."); addMessageIfEmpty("Target REJECTED update", messages);
break; break;
case CLOSED: case CLOSED:
status = handleClosedCase(feedback, controllerId, actionid, messages); status = handleClosedCase(feedback, controllerId, actionid, messages);
break; break;
case DOWNLOAD:
LOG.debug("Controller confirmed status of download (actionId: {}, controllerId: {}) as we got {} report.",
actionid, controllerId, feedback.getStatus().getExecution());
status = Status.DOWNLOAD;
addMessageIfEmpty("Target confirmed download start", messages);
break;
case DOWNLOADED: case DOWNLOADED:
LOG.debug("Controller confirmed download (actionId: {}, controllerId: {}) as we got {} report.", actionid, LOG.debug("Controller confirmed download (actionId: {}, controllerId: {}) as we got {} report.", actionid,
controllerId, feedback.getStatus().getExecution()); controllerId, feedback.getStatus().getExecution());
status = Status.DOWNLOADED; status = Status.DOWNLOADED;
messages.add(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target confirmed download of distribution set."); addMessageIfEmpty("Target confirmed download finished", messages);
break; break;
default: default:
status = handleDefaultCase(feedback, controllerId, actionid, messages); status = handleDefaultCase(feedback, controllerId, actionid, messages);
break; break;
} }
if (feedback.getStatus().getDetails() != null) {
messages.addAll(feedback.getStatus().getDetails());
}
return entityFactory.actionStatus().create(actionid).status(status).messages(messages); return entityFactory.actionStatus().create(actionid).status(status).messages(messages);
} }
private static void addMessageIfEmpty(final String text, final List<String> messages) {
if (messages != null && messages.isEmpty()) {
messages.add(RepositoryConstants.SERVER_MESSAGE_PREFIX + text + ".");
}
}
private Status handleDefaultCase(final DdiActionFeedback feedback, final String controllerId, final Long actionid, private Status handleDefaultCase(final DdiActionFeedback feedback, final String controllerId, final Long actionid,
final List<String> messages) { final List<String> messages) {
Status status; Status status;
LOG.debug("Controller reported intermediate status (actionid: {}, controllerId: {}) as we got {} report.", LOG.debug("Controller reported intermediate status (actionid: {}, controllerId: {}) as we got {} report.",
actionid, controllerId, feedback.getStatus().getExecution()); actionid, controllerId, feedback.getStatus().getExecution());
status = Status.RUNNING; status = Status.RUNNING;
messages.add( addMessageIfEmpty("Target reported " + feedback.getStatus().getExecution(), messages);
RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target reported " + feedback.getStatus().getExecution());
return status; return status;
} }
@@ -416,10 +429,10 @@ public class DdiRootController implements DdiRootControllerRestApi {
controllerId, feedback.getStatus().getExecution()); controllerId, feedback.getStatus().getExecution());
if (feedback.getStatus().getResult().getFinished() == FinalResult.FAILURE) { if (feedback.getStatus().getResult().getFinished() == FinalResult.FAILURE) {
status = Status.ERROR; status = Status.ERROR;
messages.add(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target reported CLOSED with ERROR!"); addMessageIfEmpty("Target reported CLOSED with ERROR!", messages);
} else { } else {
status = Status.FINISHED; status = Status.FINISHED;
messages.add(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target reported CLOSED with OK!"); addMessageIfEmpty("Target reported CLOSED with OK!", messages);
} }
return status; return status;
} }
@@ -525,10 +538,10 @@ public class DdiRootController implements DdiRootControllerRestApi {
Status status; Status status;
if (feedback.getStatus().getResult().getFinished() == FinalResult.FAILURE) { if (feedback.getStatus().getResult().getFinished() == FinalResult.FAILURE) {
status = Status.ERROR; status = Status.ERROR;
messages.add(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target was not able to complete cancelation."); addMessageIfEmpty("Target was not able to complete cancelation", messages);
} else { } else {
status = Status.CANCELED; status = Status.CANCELED;
messages.add(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Cancelation confirmed."); addMessageIfEmpty("Cancelation confirmed", messages);
} }
return status; return status;
} }

View File

@@ -152,6 +152,7 @@ public class TotalTargetCountStatus {
case RUNNING: case RUNNING:
case WARNING: case WARNING:
case DOWNLOAD: case DOWNLOAD:
case DOWNLOADED:
case CANCELING: case CANCELING:
final Long runningItemsCount = statusTotalCountMap.get(Status.RUNNING) + item.getCount(); final Long runningItemsCount = statusTotalCountMap.get(Status.RUNNING) + item.getCount();
statusTotalCountMap.put(Status.RUNNING, runningItemsCount); statusTotalCountMap.put(Status.RUNNING, runningItemsCount);

View File

@@ -143,8 +143,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.IN_SYNC, assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.IN_SYNC,
Action.Status.FINISHED, Action.Status.FINISHED, false); Action.Status.FINISHED, Action.Status.FINISHED, false);
assertThat(actionStatusRepository.count()).isEqualTo(6); assertThat(actionStatusRepository.count()).isEqualTo(7);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(6); assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(7);
} }
@Test @Test
@@ -170,8 +170,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
.messages(Arrays.asList("this is valid.", INVALID_TEXT_HTML)))) .messages(Arrays.asList("this is valid.", INVALID_TEXT_HTML))))
.as("set invalid description text should not be created"); .as("set invalid description text should not be created");
assertThat(actionStatusRepository.count()).isEqualTo(5); assertThat(actionStatusRepository.count()).isEqualTo(6);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(5); assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(6);
} }
@Test @Test
@@ -246,8 +246,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.IN_SYNC, assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.IN_SYNC,
Action.Status.CANCELED, Action.Status.FINISHED, false); Action.Status.CANCELED, Action.Status.FINISHED, false);
assertThat(actionStatusRepository.count()).isEqualTo(7); assertThat(actionStatusRepository.count()).isEqualTo(8);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(7); assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(8);
} }
@Test @Test
@@ -273,8 +273,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.IN_SYNC, assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.IN_SYNC,
Action.Status.CANCELED, Action.Status.CANCELED, false); Action.Status.CANCELED, Action.Status.CANCELED, false);
assertThat(actionStatusRepository.count()).isEqualTo(7); assertThat(actionStatusRepository.count()).isEqualTo(8);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(7); assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(8);
} }
@Test @Test
@@ -301,8 +301,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.PENDING, assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.PENDING,
Action.Status.RUNNING, Action.Status.CANCEL_REJECTED, true); Action.Status.RUNNING, Action.Status.CANCEL_REJECTED, true);
assertThat(actionStatusRepository.count()).isEqualTo(7); assertThat(actionStatusRepository.count()).isEqualTo(8);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(7); assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(8);
} }
@Test @Test
@@ -329,8 +329,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.PENDING, assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.PENDING,
Action.Status.RUNNING, Action.Status.ERROR, true); Action.Status.RUNNING, Action.Status.ERROR, true);
assertThat(actionStatusRepository.count()).isEqualTo(7); assertThat(actionStatusRepository.count()).isEqualTo(8);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(7); assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(8);
} }
@Step @Step
@@ -357,6 +357,11 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.PENDING, assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.PENDING,
Action.Status.CANCELING, Action.Status.DOWNLOAD, true); Action.Status.CANCELING, Action.Status.DOWNLOAD, true);
controllerManagement
.addCancelActionStatus(entityFactory.actionStatus().create(actionId).status(Action.Status.DOWNLOADED));
assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.PENDING,
Action.Status.CANCELING, Action.Status.DOWNLOADED, true);
controllerManagement controllerManagement
.addCancelActionStatus(entityFactory.actionStatus().create(actionId).status(Action.Status.RETRIEVED)); .addCancelActionStatus(entityFactory.actionStatus().create(actionId).status(Action.Status.RETRIEVED));
assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.PENDING, assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.PENDING,
@@ -379,6 +384,10 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
.addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Action.Status.DOWNLOAD)); .addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Action.Status.DOWNLOAD));
assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.PENDING, assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.PENDING,
Action.Status.RUNNING, Action.Status.DOWNLOAD, true); Action.Status.RUNNING, Action.Status.DOWNLOAD, true);
controllerManagement
.addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Action.Status.DOWNLOADED));
assertActionStatus(actionId, TestdataFactory.DEFAULT_CONTROLLER_ID, TargetUpdateStatus.PENDING,
Action.Status.RUNNING, Action.Status.DOWNLOADED, true);
controllerManagement controllerManagement
.addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Action.Status.RETRIEVED)); .addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Action.Status.RETRIEVED));

View File

@@ -724,6 +724,8 @@ public class ActionHistoryGrid extends AbstractGrid<LazyQueryContainer> {
i18n.getMessage("label.cancelled"), statusLabelId)); i18n.getMessage("label.cancelled"), statusLabelId));
stateMap.put(Action.Status.RETRIEVED, new StatusFontIcon(FontAwesome.CIRCLE_O, STATUS_ICON_PENDING, stateMap.put(Action.Status.RETRIEVED, new StatusFontIcon(FontAwesome.CIRCLE_O, STATUS_ICON_PENDING,
i18n.getMessage("label.retrieved"), statusLabelId)); i18n.getMessage("label.retrieved"), statusLabelId));
stateMap.put(Action.Status.DOWNLOADED, new StatusFontIcon(FontAwesome.CLOUD_DOWNLOAD, STATUS_ICON_GREEN,
i18n.getMessage("label.downloaded"), statusLabelId));
stateMap.put(Action.Status.DOWNLOAD, new StatusFontIcon(FontAwesome.CLOUD_DOWNLOAD, STATUS_ICON_PENDING, stateMap.put(Action.Status.DOWNLOAD, new StatusFontIcon(FontAwesome.CLOUD_DOWNLOAD, STATUS_ICON_PENDING,
i18n.getMessage("label.download"), statusLabelId)); i18n.getMessage("label.download"), statusLabelId));
stateMap.put(Action.Status.SCHEDULED, new StatusFontIcon(FontAwesome.HOURGLASS_1, STATUS_ICON_PENDING, stateMap.put(Action.Status.SCHEDULED, new StatusFontIcon(FontAwesome.HOURGLASS_1, STATUS_ICON_PENDING,

View File

@@ -46,6 +46,8 @@ public final class ActionStatusIconMapper {
SPUIStyleDefinitions.STATUS_ICON_PENDING, FontAwesome.CIRCLE_O)); SPUIStyleDefinitions.STATUS_ICON_PENDING, FontAwesome.CIRCLE_O));
MAPPINGS.put(Action.Status.DOWNLOAD, new ActionStatusIconMapper("label.download", MAPPINGS.put(Action.Status.DOWNLOAD, new ActionStatusIconMapper("label.download",
SPUIStyleDefinitions.STATUS_ICON_PENDING, FontAwesome.CLOUD_DOWNLOAD)); SPUIStyleDefinitions.STATUS_ICON_PENDING, FontAwesome.CLOUD_DOWNLOAD));
MAPPINGS.put(Action.Status.DOWNLOADED, new ActionStatusIconMapper("label.downloaded",
SPUIStyleDefinitions.STATUS_ICON_GREEN, FontAwesome.CLOUD_DOWNLOAD));
MAPPINGS.put(Action.Status.SCHEDULED, new ActionStatusIconMapper("label.scheduled", MAPPINGS.put(Action.Status.SCHEDULED, new ActionStatusIconMapper("label.scheduled",
SPUIStyleDefinitions.STATUS_ICON_PENDING, FontAwesome.HOURGLASS_1)); SPUIStyleDefinitions.STATUS_ICON_PENDING, FontAwesome.HOURGLASS_1));
} }

View File

@@ -60,6 +60,8 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid<LazyQueryContainer
new StatusFontIcon(FontAwesome.ADJUST, SPUIStyleDefinitions.STATUS_ICON_YELLOW)); new StatusFontIcon(FontAwesome.ADJUST, SPUIStyleDefinitions.STATUS_ICON_YELLOW));
statusIconMap.put(Status.DOWNLOAD, statusIconMap.put(Status.DOWNLOAD,
new StatusFontIcon(FontAwesome.ADJUST, SPUIStyleDefinitions.STATUS_ICON_YELLOW)); new StatusFontIcon(FontAwesome.ADJUST, SPUIStyleDefinitions.STATUS_ICON_YELLOW));
statusIconMap.put(Status.DOWNLOADED,
new StatusFontIcon(FontAwesome.ADJUST, SPUIStyleDefinitions.STATUS_ICON_YELLOW));
statusIconMap.put(Status.CANCELING, statusIconMap.put(Status.CANCELING,
new StatusFontIcon(FontAwesome.TIMES_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_PENDING)); new StatusFontIcon(FontAwesome.TIMES_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_PENDING));
statusIconMap.put(Status.CANCELED, statusIconMap.put(Status.CANCELED,