Fix cancel action status (#429)
* Fixed handling of action cancellation status updates. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix broken DDI test. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Code readibility. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Reduce access to default. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Added test for finished on action that is in cancelling. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Update MariaDb driver Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Wrong branch Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Remove duplicate status definition. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Use updated picture in docs. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Leverage existing statics. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix picture upload. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Revert change Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -34,7 +34,6 @@ import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
import org.eclipse.hawkbit.repository.model.PollStatus;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.eclipse.hawkbit.rest.data.ResponseList;
|
||||
import org.eclipse.hawkbit.rest.data.SortDirection;
|
||||
import org.eclipse.hawkbit.util.IpUtil;
|
||||
@@ -112,7 +111,7 @@ public final class MgmtTargetMapper {
|
||||
targetRest.setControllerId(target.getControllerId());
|
||||
targetRest.setDescription(target.getDescription());
|
||||
targetRest.setName(target.getName());
|
||||
targetRest.setUpdateStatus(getUpdateStatusName(target.getTargetInfo().getUpdateStatus()));
|
||||
targetRest.setUpdateStatus(target.getTargetInfo().getUpdateStatus().name().toLowerCase());
|
||||
|
||||
final URI address = target.getTargetInfo().getAddress();
|
||||
if (address != null) {
|
||||
@@ -198,37 +197,6 @@ public final class MgmtTargetMapper {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static String getNameOfActionStatusType(final Action.Status type) {
|
||||
String result;
|
||||
|
||||
switch (type) {
|
||||
case CANCELED:
|
||||
result = MgmtActionStatus.AS_CANCELED;
|
||||
break;
|
||||
case ERROR:
|
||||
result = MgmtActionStatus.AS_ERROR;
|
||||
break;
|
||||
case FINISHED:
|
||||
result = MgmtActionStatus.AS_FINISHED;
|
||||
break;
|
||||
case RETRIEVED:
|
||||
result = MgmtActionStatus.AS_RETRIEVED;
|
||||
break;
|
||||
case RUNNING:
|
||||
result = MgmtActionStatus.AS_RUNNING;
|
||||
break;
|
||||
case WARNING:
|
||||
result = MgmtActionStatus.AS_WARNING;
|
||||
break;
|
||||
default:
|
||||
return type.name().toLowerCase();
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private static String getType(final Action action) {
|
||||
if (!action.isCancelingOrCanceled()) {
|
||||
return MgmtAction.ACTION_UPDATE;
|
||||
@@ -239,39 +207,13 @@ public final class MgmtTargetMapper {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String getUpdateStatusName(final TargetUpdateStatus updatestatus) {
|
||||
String result;
|
||||
|
||||
switch (updatestatus) {
|
||||
case ERROR:
|
||||
result = "error";
|
||||
break;
|
||||
case IN_SYNC:
|
||||
result = "in_sync";
|
||||
break;
|
||||
case PENDING:
|
||||
result = "pending";
|
||||
break;
|
||||
case REGISTERED:
|
||||
result = "registered";
|
||||
break;
|
||||
case UNKNOWN:
|
||||
result = "unknown";
|
||||
break;
|
||||
default:
|
||||
return updatestatus.name().toLowerCase();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static MgmtActionStatus toResponse(final ActionStatus actionStatus) {
|
||||
final MgmtActionStatus result = new MgmtActionStatus();
|
||||
|
||||
result.setMessages(actionStatus.getMessages());
|
||||
result.setReportedAt(actionStatus.getCreatedAt());
|
||||
result.setStatusId(actionStatus.getId());
|
||||
result.setType(getNameOfActionStatusType(actionStatus.getStatus()));
|
||||
result.setType(actionStatus.getStatus().name().toLowerCase());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user