Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment type for Download-Only fixed on DDI-API #848

Merged
merged 4 commits into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ default boolean isForced() {
return ActionType.FORCED == getActionType();
}

/**
* @return true when action is downloadonly, false otherwise
*/
default boolean isDownloadOnly() {
laverman marked this conversation as resolved.
Show resolved Hide resolved
return ActionType.DOWNLOAD_ONLY == getActionType();
}

/**
* Action status as reported by the controller.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,15 @@ public ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction(
final DdiActionHistory actionHistory = actionHistoryMsgs.isEmpty() ? null
: new DdiActionHistory(action.getStatus().name(), actionHistoryMsgs);

final HandlingType downloadType = action.isForce() ? HandlingType.FORCED : HandlingType.ATTEMPT;
final HandlingType downloadType = calculateDownloadType(action);
final HandlingType updateType = calculateUpdateType(action, downloadType);

final DdiMaintenanceWindowStatus maintenanceWindow = calculateMaintenanceWindow(action);

final DdiDeploymentBase base = new DdiDeploymentBase(Long.toString(action.getId()),
new DdiDeployment(downloadType, updateType, chunks, maintenanceWindow), actionHistory);

LOG.debug("Found an active UpdateAction for target {}. returning deyploment: {}", controllerId, base);
LOG.debug("Found an active UpdateAction for target {}. returning deployment: {}", controllerId, base);

controllerManagement.registerRetrieved(action.getId(), RepositoryConstants.SERVER_MESSAGE_PREFIX
+ "Target retrieved update action and should start now the download.");
Expand All @@ -313,6 +313,13 @@ public ResponseEntity<DdiDeploymentBase> getControllerBasedeploymentAction(
return ResponseEntity.notFound().build();
}

private static HandlingType calculateDownloadType(final Action action) {
if (action.isDownloadOnly() || action.isForce()) {
return HandlingType.FORCED;
}
return HandlingType.ATTEMPT;
}

private static DdiMaintenanceWindowStatus calculateMaintenanceWindow(final Action action) {
if (action.hasMaintenanceSchedule()) {
return action.isMaintenanceWindowAvailable() ? DdiMaintenanceWindowStatus.AVAILABLE
Expand All @@ -322,7 +329,9 @@ private static DdiMaintenanceWindowStatus calculateMaintenanceWindow(final Actio
}

private static HandlingType calculateUpdateType(final Action action, final HandlingType downloadType) {
if (action.hasMaintenanceSchedule()) {
if (action.isDownloadOnly()) {
return HandlingType.SKIP;
} else if (action.hasMaintenanceSchedule()) {
return action.isMaintenanceWindowAvailable() ? downloadType : HandlingType.SKIP;
}
return downloadType;
Expand Down
Loading