Sonar issue fixed
Signed-off-by: Dominic Schabel <dominic.schabel@bosch-si.com>
This commit is contained in:
@@ -39,7 +39,7 @@ public enum ActionFields implements FieldNameProvider, FieldValueConverter<Actio
|
||||
|
||||
@Override
|
||||
public Object convertValue(final ActionFields e, final String value) {
|
||||
if (STATUS.equals(e)) {
|
||||
if (STATUS == e) {
|
||||
return convertStatusValue(value);
|
||||
}
|
||||
return value;
|
||||
@@ -58,7 +58,7 @@ public enum ActionFields implements FieldNameProvider, FieldValueConverter<Actio
|
||||
|
||||
@Override
|
||||
public String[] possibleValues(final ActionFields e) {
|
||||
if (STATUS.equals(e)) {
|
||||
if (STATUS == e) {
|
||||
return new String[] { ACTIVE, INACTIVE };
|
||||
}
|
||||
return new String[0];
|
||||
|
||||
@@ -256,8 +256,9 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
||||
* @return {@link EventTopic} to use for message.
|
||||
*/
|
||||
private static EventTopic getEventTypeForTarget(final ActionProperties action) {
|
||||
return (Action.ActionType.DOWNLOAD_ONLY.equals(action.getActionType())
|
||||
|| !action.isMaintenanceWindowAvailable()) ? EventTopic.DOWNLOAD : EventTopic.DOWNLOAD_AND_INSTALL;
|
||||
return (Action.ActionType.DOWNLOAD_ONLY == action.getActionType() || !action.isMaintenanceWindowAvailable())
|
||||
? EventTopic.DOWNLOAD
|
||||
: EventTopic.DOWNLOAD_AND_INSTALL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -313,7 +313,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
|
||||
final ActionStatusCreate actionStatus = entityFactory.actionStatus().create(action.getId()).status(status)
|
||||
.messages(messages);
|
||||
|
||||
final Action updatedAction = Status.CANCELED.equals(status)
|
||||
final Action updatedAction = (Status.CANCELED == status)
|
||||
? controllerManagement.addCancelActionStatus(actionStatus)
|
||||
: controllerManagement.addUpdateActionStatus(actionStatus);
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public interface Action extends TenantAwareBaseEntity {
|
||||
* otherwise
|
||||
*/
|
||||
default boolean isCancelingOrCanceled() {
|
||||
return Status.CANCELING.equals(getStatus()) || Status.CANCELED.equals(getStatus());
|
||||
return Status.CANCELING == getStatus() || Status.CANCELED == getStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +112,7 @@ public interface Action extends TenantAwareBaseEntity {
|
||||
* {@code false}
|
||||
*/
|
||||
default boolean isHitAutoForceTime(final long hitTimeMillis) {
|
||||
if (ActionType.TIMEFORCED.equals(getActionType())) {
|
||||
if (ActionType.TIMEFORCED == getActionType()) {
|
||||
return hitTimeMillis >= getForcedTime();
|
||||
}
|
||||
return false;
|
||||
@@ -139,7 +139,7 @@ public interface Action extends TenantAwareBaseEntity {
|
||||
* @return true when action is forced, false otherwise
|
||||
*/
|
||||
default boolean isForced() {
|
||||
return ActionType.FORCED.equals(getActionType());
|
||||
return ActionType.FORCED == getActionType();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -147,7 +147,7 @@ public class TotalTargetCountStatus {
|
||||
// Exception squid:MethodCyclomaticComplexity - simple state conversion, not
|
||||
// really complex.
|
||||
@SuppressWarnings("squid:MethodCyclomaticComplexity")
|
||||
private Status convertStatus(final Action.Status status){
|
||||
private Status convertStatus(final Action.Status status) {
|
||||
switch (status) {
|
||||
case SCHEDULED:
|
||||
return Status.SCHEDULED;
|
||||
@@ -164,10 +164,9 @@ public class TotalTargetCountStatus {
|
||||
case CANCELING:
|
||||
return Status.RUNNING;
|
||||
case DOWNLOADED:
|
||||
return Action.ActionType.DOWNLOAD_ONLY.equals(rolloutType) ? Status.FINISHED : Status.RUNNING;
|
||||
return Action.ActionType.DOWNLOAD_ONLY == rolloutType ? Status.FINISHED : Status.RUNNING;
|
||||
default:
|
||||
throw new IllegalArgumentException("State " + status + "is not valid");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public final class RolloutHelper {
|
||||
* the Status
|
||||
*/
|
||||
public static void verifyRolloutInStatus(final Rollout rollout, final Rollout.RolloutStatus status) {
|
||||
if (!rollout.getStatus().equals(status)) {
|
||||
if (rollout.getStatus() != status) {
|
||||
throw new RolloutIllegalStateException("Rollout is not in status " + status.toString());
|
||||
}
|
||||
}
|
||||
@@ -143,8 +143,6 @@ public final class RolloutHelper {
|
||||
* Filters the groups of a Rollout to match a specific status and adds a
|
||||
* group to the result.
|
||||
*
|
||||
* @param rollout
|
||||
* the rollout
|
||||
* @param status
|
||||
* the required status for the groups
|
||||
* @param group
|
||||
@@ -153,7 +151,7 @@ public final class RolloutHelper {
|
||||
*/
|
||||
public static List<Long> getGroupsByStatusIncludingGroup(final List<RolloutGroup> groups,
|
||||
final RolloutGroup.RolloutGroupStatus status, final RolloutGroup group) {
|
||||
return groups.stream().filter(innerGroup -> innerGroup.getStatus().equals(status) || innerGroup.equals(group))
|
||||
return groups.stream().filter(innerGroup -> innerGroup.getStatus() == status || innerGroup.equals(group))
|
||||
.map(RolloutGroup::getId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -200,15 +198,13 @@ public final class RolloutHelper {
|
||||
if (!StringUtils.isEmpty(previousGroupFilters)) {
|
||||
if (!StringUtils.isEmpty(groupFilter)) {
|
||||
return concatAndTargetFilters(baseFilter, groupFilter, previousGroupFilters);
|
||||
} else {
|
||||
return concatAndTargetFilters(baseFilter, previousGroupFilters);
|
||||
}
|
||||
return concatAndTargetFilters(baseFilter, previousGroupFilters);
|
||||
}
|
||||
if (!StringUtils.isEmpty(groupFilter)) {
|
||||
return concatAndTargetFilters(baseFilter, groupFilter);
|
||||
} else {
|
||||
return baseFilter;
|
||||
}
|
||||
return baseFilter;
|
||||
}
|
||||
|
||||
private static boolean isTargetFilterInGroups(final String groupFilter, final List<RolloutGroup> groups) {
|
||||
@@ -231,9 +227,8 @@ public final class RolloutHelper {
|
||||
static String getGroupTargetFilter(final String baseFilter, final RolloutGroup group) {
|
||||
if (StringUtils.isEmpty(group.getTargetFilterQuery())) {
|
||||
return baseFilter;
|
||||
} else {
|
||||
return concatAndTargetFilters(baseFilter, group.getTargetFilterQuery());
|
||||
}
|
||||
return concatAndTargetFilters(baseFilter, group.getTargetFilterQuery());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,10 +247,9 @@ public final class RolloutHelper {
|
||||
}
|
||||
|
||||
public static void checkIfRolloutCanStarted(final Rollout rollout, final Rollout mergedRollout) {
|
||||
if (!(Rollout.RolloutStatus.READY.equals(mergedRollout.getStatus()))) {
|
||||
if (Rollout.RolloutStatus.READY != mergedRollout.getStatus()) {
|
||||
throw new RolloutIllegalStateException("Rollout can only be started in state ready but current state is "
|
||||
+ rollout.getStatus().name().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -374,8 +374,7 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
|
||||
@Override
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
@Retryable(include = ConcurrencyFailureException.class, exclude = EntityAlreadyExistsException.class,
|
||||
maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
@Retryable(include = ConcurrencyFailureException.class, exclude = EntityAlreadyExistsException.class, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||
public Target findOrRegisterTargetIfItDoesNotExist(final String controllerId, final URI address) {
|
||||
final Specification<JpaTarget> spec = (targetRoot, query, cb) -> cb
|
||||
.equal(targetRoot.get(JpaTarget_.controllerId), controllerId);
|
||||
@@ -394,9 +393,11 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
afterCommit.afterCommit(() -> eventPublisher.publishEvent(new TargetPollEvent(result, bus.getId())));
|
||||
|
||||
return result;
|
||||
} catch (final EntityAlreadyExistsException e){
|
||||
LOG.warn("Caught an EntityAlreadyExistsException while creating non existing target " +
|
||||
"[controllerId:{}, address:{}, tenant: {}]", controllerId, address, tenantAware.getCurrentTenant());
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
LOG.warn(
|
||||
"Caught an EntityAlreadyExistsException while creating non existing target "
|
||||
+ "[controllerId:{}, address:{}, tenant: {}]",
|
||||
controllerId, address, tenantAware.getCurrentTenant());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -491,7 +492,7 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
private Target updateTargetStatus(final JpaTarget toUpdate, final URI address) {
|
||||
boolean storeEager = isStoreEager(toUpdate, address);
|
||||
|
||||
if (TargetUpdateStatus.UNKNOWN.equals(toUpdate.getUpdateStatus())) {
|
||||
if (TargetUpdateStatus.UNKNOWN == toUpdate.getUpdateStatus()) {
|
||||
toUpdate.setUpdateStatus(TargetUpdateStatus.REGISTERED);
|
||||
storeEager = true;
|
||||
}
|
||||
@@ -589,15 +590,15 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
|
||||
/**
|
||||
* ActionStatus updates are allowed mainly if the action is active. If the
|
||||
* action is not active we accept further status updates if permitted so
|
||||
* by repository configuration. In this case, only the values: Status.ERROR
|
||||
* and Status.FINISHED are allowed. In the case of a DOWNLOAD_ONLY action,
|
||||
* we accept status updates only once.
|
||||
* action is not active we accept further status updates if permitted so by
|
||||
* repository configuration. In this case, only the values: Status.ERROR and
|
||||
* Status.FINISHED are allowed. In the case of a DOWNLOAD_ONLY action, we
|
||||
* accept status updates only once.
|
||||
*/
|
||||
private boolean isUpdatingActionStatusAllowed(final JpaAction action, final JpaActionStatus actionStatus) {
|
||||
|
||||
final boolean isIntermediateFeedback = !FINISHED.equals(actionStatus.getStatus())
|
||||
&& !Status.ERROR.equals(actionStatus.getStatus());
|
||||
final boolean isIntermediateFeedback = (FINISHED != actionStatus.getStatus())
|
||||
&& (Status.ERROR != actionStatus.getStatus());
|
||||
|
||||
final boolean isAllowedByRepositoryConfiguration = !repositoryProperties.isRejectActionStatusForClosedAction()
|
||||
&& isIntermediateFeedback;
|
||||
@@ -608,7 +609,7 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
}
|
||||
|
||||
private static boolean isDownloadOnly(final JpaAction action) {
|
||||
return DOWNLOAD_ONLY.equals(action.getActionType());
|
||||
return DOWNLOAD_ONLY == action.getActionType();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -651,7 +652,7 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
}
|
||||
|
||||
private String handleDownloadedActionStatus(final JpaAction action) {
|
||||
if(!isDownloadOnly(action)){
|
||||
if (!isDownloadOnly(action)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -697,9 +698,11 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
target.setInstalledDistributionSet(ds);
|
||||
target.setInstallationDate(System.currentTimeMillis());
|
||||
|
||||
// Target reported an installation of a DOWNLOAD_ONLY assignment, the assigned DS has to be adapted
|
||||
// because the currently assigned DS can be unequal to the currently installed DS (the downloadOnly DS)
|
||||
if(isDownloadOnly(action)){
|
||||
// Target reported an installation of a DOWNLOAD_ONLY assignment, the
|
||||
// assigned DS has to be adapted
|
||||
// because the currently assigned DS can be unequal to the currently
|
||||
// installed DS (the downloadOnly DS)
|
||||
if (isDownloadOnly(action)) {
|
||||
target.setAssignedDistributionSet(action.getDistributionSet());
|
||||
}
|
||||
|
||||
@@ -838,7 +841,7 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
// retrieves after the other we don't want to store to protect to
|
||||
// overflood action status in
|
||||
// case controller retrieves a action multiple times.
|
||||
if (resultList.isEmpty() || !Status.RETRIEVED.equals(resultList.get(0)[1])) {
|
||||
if (resultList.isEmpty() || (Status.RETRIEVED != resultList.get(0)[1])) {
|
||||
// document that the status has been retrieved
|
||||
actionStatusRepository
|
||||
.save(new JpaActionStatus(action, Status.RETRIEVED, System.currentTimeMillis(), message));
|
||||
|
||||
@@ -238,7 +238,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
}
|
||||
|
||||
private static boolean isRolloutStatusReady(final RolloutGroup rolloutGroup) {
|
||||
return rolloutGroup != null && RolloutStatus.READY.equals(rolloutGroup.getRollout().getStatus());
|
||||
return rolloutGroup != null && (RolloutStatus.READY == rolloutGroup.getRollout().getStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import static org.eclipse.hawkbit.repository.jpa.builder.JpaRolloutGroupCreate.addSuccessAndErrorConditionsAndActions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -105,8 +107,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import static org.eclipse.hawkbit.repository.jpa.builder.JpaRolloutGroupCreate.addSuccessAndErrorConditionsAndActions;
|
||||
|
||||
/**
|
||||
* JPA implementation of {@link RolloutManagement}.
|
||||
*/
|
||||
@@ -336,14 +336,14 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
||||
int readyGroups = 0;
|
||||
int totalTargets = 0;
|
||||
for (final RolloutGroup group : rolloutGroups) {
|
||||
if (RolloutGroupStatus.READY.equals(group.getStatus())) {
|
||||
if (RolloutGroupStatus.READY == group.getStatus()) {
|
||||
readyGroups++;
|
||||
totalTargets += group.getTotalTargets();
|
||||
continue;
|
||||
}
|
||||
|
||||
final RolloutGroup filledGroup = fillRolloutGroupWithTargets(rollout, group);
|
||||
if (RolloutGroupStatus.READY.equals(filledGroup.getStatus())) {
|
||||
if (RolloutGroupStatus.READY == filledGroup.getStatus()) {
|
||||
readyGroups++;
|
||||
totalTargets += filledGroup.getTotalTargets();
|
||||
}
|
||||
|
||||
@@ -38,8 +38,9 @@ public class ThresholdRolloutGroupSuccessCondition implements RolloutGroupCondit
|
||||
return true;
|
||||
}
|
||||
|
||||
Action.Status completeActionStatus = Action.ActionType.DOWNLOAD_ONLY.equals(rollout.getActionType()) ?
|
||||
Action.Status.DOWNLOADED : Action.Status.FINISHED;
|
||||
final Action.Status completeActionStatus = (Action.ActionType.DOWNLOAD_ONLY == rollout.getActionType())
|
||||
? Action.Status.DOWNLOADED
|
||||
: Action.Status.FINISHED;
|
||||
final long finished = this.actionRepository.countByRolloutIdAndRolloutGroupIdAndStatus(rollout.getId(),
|
||||
rolloutGroup.getId(), completeActionStatus);
|
||||
try {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class MgmtDownloadResource implements MgmtDownloadRestApi {
|
||||
|
||||
AbstractDbArtifact artifact = null;
|
||||
|
||||
if (DownloadType.BY_SHA1.equals(artifactCache.getDownloadType())) {
|
||||
if (DownloadType.BY_SHA1 == artifactCache.getDownloadType()) {
|
||||
artifact = artifactRepository.getArtifactBySha1(tenant, artifactCache.getId());
|
||||
} else {
|
||||
LOGGER.warn("Download Type {} not supported", artifactCache.getDownloadType());
|
||||
|
||||
@@ -191,56 +191,56 @@ final class MgmtRolloutMapper {
|
||||
}
|
||||
|
||||
private static RolloutGroupErrorCondition mapErrorCondition(final Condition condition) {
|
||||
if (Condition.THRESHOLD.equals(condition)) {
|
||||
if (Condition.THRESHOLD == condition) {
|
||||
return RolloutGroupErrorCondition.THRESHOLD;
|
||||
}
|
||||
throw new IllegalArgumentException(createIllegalArgumentLiteral(condition));
|
||||
}
|
||||
|
||||
private static RolloutGroupSuccessCondition mapFinishCondition(final Condition condition) {
|
||||
if (Condition.THRESHOLD.equals(condition)) {
|
||||
if (Condition.THRESHOLD == condition) {
|
||||
return RolloutGroupSuccessCondition.THRESHOLD;
|
||||
}
|
||||
throw new IllegalArgumentException(createIllegalArgumentLiteral(condition));
|
||||
}
|
||||
|
||||
private static Condition map(final RolloutGroupSuccessCondition rolloutCondition) {
|
||||
if (RolloutGroupSuccessCondition.THRESHOLD.equals(rolloutCondition)) {
|
||||
if (RolloutGroupSuccessCondition.THRESHOLD == rolloutCondition) {
|
||||
return Condition.THRESHOLD;
|
||||
}
|
||||
throw new IllegalArgumentException("Rollout group condition " + rolloutCondition + NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
private static Condition map(final RolloutGroupErrorCondition rolloutCondition) {
|
||||
if (RolloutGroupErrorCondition.THRESHOLD.equals(rolloutCondition)) {
|
||||
if (RolloutGroupErrorCondition.THRESHOLD == rolloutCondition) {
|
||||
return Condition.THRESHOLD;
|
||||
}
|
||||
throw new IllegalArgumentException("Rollout group condition " + rolloutCondition + NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
private static RolloutGroupErrorAction map(final ErrorAction action) {
|
||||
if (ErrorAction.PAUSE.equals(action)) {
|
||||
if (ErrorAction.PAUSE == action) {
|
||||
return RolloutGroupErrorAction.PAUSE;
|
||||
}
|
||||
throw new IllegalArgumentException("Error Action " + action + NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
private static RolloutGroupSuccessAction map(final SuccessAction action) {
|
||||
if (SuccessAction.NEXTGROUP.equals(action)) {
|
||||
if (SuccessAction.NEXTGROUP == action) {
|
||||
return RolloutGroupSuccessAction.NEXTGROUP;
|
||||
}
|
||||
throw new IllegalArgumentException("Success Action " + action + NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
private static SuccessAction map(final RolloutGroupSuccessAction successAction) {
|
||||
if (RolloutGroupSuccessAction.NEXTGROUP.equals(successAction)) {
|
||||
if (RolloutGroupSuccessAction.NEXTGROUP == successAction) {
|
||||
return SuccessAction.NEXTGROUP;
|
||||
}
|
||||
throw new IllegalArgumentException("Rollout group success action " + successAction + NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
private static ErrorAction map(final RolloutGroupErrorAction errorAction) {
|
||||
if (RolloutGroupErrorAction.PAUSE.equals(errorAction)) {
|
||||
if (RolloutGroupErrorAction.PAUSE == errorAction) {
|
||||
return ErrorAction.PAUSE;
|
||||
}
|
||||
throw new IllegalArgumentException("Rollout group error action " + errorAction + NOT_SUPPORTED);
|
||||
|
||||
@@ -190,10 +190,11 @@ public final class MgmtTargetMapper {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return actionStatus.stream().map(status -> toResponse(status,
|
||||
deploymentManagement.findMessagesByActionStatusId(
|
||||
PageRequest.of(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT), status.getId())
|
||||
.getContent()))
|
||||
return actionStatus.stream()
|
||||
.map(status -> toResponse(status,
|
||||
deploymentManagement.findMessagesByActionStatusId(
|
||||
PageRequest.of(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT), status.getId())
|
||||
.getContent()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -202,7 +203,7 @@ public final class MgmtTargetMapper {
|
||||
|
||||
result.setActionId(action.getId());
|
||||
result.setType(getType(action));
|
||||
if (ActionType.TIMEFORCED.equals(action.getActionType())) {
|
||||
if (ActionType.TIMEFORCED == action.getActionType()) {
|
||||
result.setForceTime(action.getForcedTime());
|
||||
}
|
||||
result.setActionType(MgmtRestModelMapper.convertActionType(action.getActionType()));
|
||||
|
||||
@@ -346,7 +346,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
if (!MgmtActionType.FORCED.equals(actionUpdate.getActionType())) {
|
||||
if (MgmtActionType.FORCED != actionUpdate.getActionType()) {
|
||||
throw new ValidationException("Resource supports only switch to FORCED.");
|
||||
}
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ public class TargetFilterTable extends Table {
|
||||
i18n.getMessage(UIMessageIdProvider.BUTTON_AUTO_ASSIGNMENT_DESCRIPTION), null, false, null,
|
||||
SPUIButtonStyleNoBorder.class);
|
||||
} else {
|
||||
updateIcon = actionType.equals(ActionType.FORCED)
|
||||
updateIcon = actionType == ActionType.FORCED
|
||||
? SPUIComponentProvider.getButton(buttonId, distSet.getNameVersion(),
|
||||
i18n.getMessage(UIMessageIdProvider.BUTTON_AUTO_ASSIGNMENT_DESCRIPTION), null, false,
|
||||
FontAwesome.BOLT, SPUIButtonStyleNoBorderWithIcon.class)
|
||||
|
||||
@@ -250,7 +250,10 @@ public final class TargetAssignmentOperations {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
// Vaadin is returning object so "==" might not work
|
||||
@SuppressWarnings("squid:S4551")
|
||||
public void valueChange(final Property.ValueChangeEvent event) {
|
||||
|
||||
if (event.getProperty().getValue()
|
||||
.equals(AbstractActionTypeOptionGroupLayout.ActionTypeOption.DOWNLOAD_ONLY)) {
|
||||
enableMaintenanceWindowControl.setValue(false);
|
||||
|
||||
@@ -261,17 +261,17 @@ public class ActionHistoryGrid extends AbstractGrid<LazyQueryContainer> {
|
||||
}
|
||||
|
||||
private StatusFontIcon createTypeLabelMetadata(final Action action) {
|
||||
if (ActionType.FORCED.equals(action.getActionType()) || ActionType.TIMEFORCED.equals(action.getActionType())) {
|
||||
if (ActionType.FORCED == action.getActionType() || ActionType.TIMEFORCED == action.getActionType()) {
|
||||
return new StatusFontIcon(FontAwesome.BOLT, STATUS_ICON_FORCED,
|
||||
i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_FORCED),
|
||||
UIComponentIdProvider.ACTION_HISTORY_TABLE_TYPE_LABEL_ID);
|
||||
}
|
||||
if (ActionType.SOFT.equals(action.getActionType())) {
|
||||
if (ActionType.SOFT == action.getActionType()) {
|
||||
return new StatusFontIcon(FontAwesome.STEP_FORWARD, STATUS_ICON_SOFT,
|
||||
i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_SOFT),
|
||||
UIComponentIdProvider.ACTION_HISTORY_TABLE_TYPE_LABEL_ID);
|
||||
}
|
||||
if (ActionType.DOWNLOAD_ONLY.equals(action.getActionType())) {
|
||||
if (ActionType.DOWNLOAD_ONLY == action.getActionType()) {
|
||||
return new StatusFontIcon(FontAwesome.DOWNLOAD, STATUS_ICON_DOWNLOAD_ONLY,
|
||||
i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_DOWNLOAD_ONLY),
|
||||
UIComponentIdProvider.ACTION_HISTORY_TABLE_TYPE_LABEL_ID);
|
||||
@@ -282,7 +282,7 @@ public class ActionHistoryGrid extends AbstractGrid<LazyQueryContainer> {
|
||||
private StatusFontIcon createTimeForcedLabelMetadata(final Action action) {
|
||||
StatusFontIcon result = null;
|
||||
|
||||
if (ActionType.TIMEFORCED.equals(action.getActionType())) {
|
||||
if (ActionType.TIMEFORCED == action.getActionType()) {
|
||||
final long currentTimeMillis = System.currentTimeMillis();
|
||||
String style;
|
||||
String title;
|
||||
@@ -616,8 +616,8 @@ public class ActionHistoryGrid extends AbstractGrid<LazyQueryContainer> {
|
||||
setColumnsSize(107.0, 500.0, ProxyAction.PXY_ACTION_DS_NAME_VERSION);
|
||||
setColumnsSize(100.0, 150.0, ProxyAction.PXY_ACTION_LAST_MODIFIED_AT);
|
||||
setColumnsSize(53.0, 55.0, ProxyAction.PXY_ACTION_STATUS);
|
||||
setColumnsSize(FIXED_PIX_MIN, FIXED_PIX_MAX, VIRT_PROP_TYPE, VIRT_PROP_TIMEFORCED,
|
||||
VIRT_PROP_ACTION_CANCEL, VIRT_PROP_ACTION_FORCE, VIRT_PROP_ACTION_FORCE_QUIT);
|
||||
setColumnsSize(FIXED_PIX_MIN, FIXED_PIX_MAX, VIRT_PROP_TYPE, VIRT_PROP_TIMEFORCED, VIRT_PROP_ACTION_CANCEL,
|
||||
VIRT_PROP_ACTION_FORCE, VIRT_PROP_ACTION_FORCE_QUIT);
|
||||
setColumnsSize(FIXED_PIX_MIN, 500.0, ProxyAction.PXY_ACTION_ROLLOUT_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +109,8 @@ public abstract class AbstractActionTypeOptionGroupLayout extends HorizontalLayo
|
||||
*
|
||||
*/
|
||||
public enum ActionTypeOption {
|
||||
FORCED(ActionType.FORCED), SOFT(ActionType.SOFT), AUTO_FORCED(ActionType.TIMEFORCED),
|
||||
DOWNLOAD_ONLY(ActionType.DOWNLOAD_ONLY);
|
||||
FORCED(ActionType.FORCED), SOFT(ActionType.SOFT), AUTO_FORCED(ActionType.TIMEFORCED), DOWNLOAD_ONLY(
|
||||
ActionType.DOWNLOAD_ONLY);
|
||||
|
||||
private final ActionType actionType;
|
||||
|
||||
@@ -130,7 +130,7 @@ public abstract class AbstractActionTypeOptionGroupLayout extends HorizontalLayo
|
||||
* @return action type option if matches, otherwise empty Optional
|
||||
*/
|
||||
public static Optional<ActionTypeOption> getOptionForActionType(final ActionType actionType) {
|
||||
return Arrays.stream(ActionTypeOption.values()).filter(option -> option.getActionType().equals(actionType))
|
||||
return Arrays.stream(ActionTypeOption.values()).filter(option -> option.getActionType() == actionType)
|
||||
.findFirst();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ public class ActionTypeOptionGroupAssignmentLayout extends AbstractActionTypeOpt
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
// Vaadin is returning object so "==" might not work
|
||||
@SuppressWarnings("squid:S4551")
|
||||
public void valueChange(final ValueChangeEvent event) {
|
||||
if (event.getProperty().getValue().equals(ActionTypeOption.AUTO_FORCED)) {
|
||||
forcedTimeDateField.setEnabled(true);
|
||||
@@ -79,8 +81,6 @@ public class ActionTypeOptionGroupAssignmentLayout extends AbstractActionTypeOpt
|
||||
addDownloadOnlyItemWithLabel();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void addAutoForceItemWithLabelAndDateField() {
|
||||
final FlexibleOptionGroupItemComponent autoForceItem = actionTypeOptionGroup
|
||||
.getItemComponent(ActionTypeOption.AUTO_FORCED);
|
||||
|
||||
@@ -227,7 +227,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
||||
|
||||
if (editRolloutEnabled) {
|
||||
editRollout();
|
||||
if (rollout.getStatus().equals(Rollout.RolloutStatus.WAITING_FOR_APPROVAL)) {
|
||||
if (rollout.getStatus() == Rollout.RolloutStatus.WAITING_FOR_APPROVAL) {
|
||||
rolloutManagement.approveOrDeny(rollout.getId(),
|
||||
(Rollout.ApprovalDecision) approveButtonsGroup.getValue(), approvalRemarkField.getValue());
|
||||
eventBus.publish(this, RolloutEvent.UPDATE_ROLLOUT);
|
||||
@@ -274,10 +274,10 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
||||
.name(rolloutName.getValue()).description(description.getValue()).set(distributionSetId)
|
||||
.actionType(getActionType()).forcedTime(getForcedTimeStamp());
|
||||
|
||||
if (AutoStartOptionGroupLayout.AutoStartOption.AUTO_START.equals(getAutoStartOption())) {
|
||||
if (AutoStartOptionGroupLayout.AutoStartOption.AUTO_START == getAutoStartOption()) {
|
||||
rolloutUpdate.startAt(System.currentTimeMillis());
|
||||
}
|
||||
if (AutoStartOptionGroupLayout.AutoStartOption.SCHEDULED.equals(getAutoStartOption())) {
|
||||
if (AutoStartOptionGroupLayout.AutoStartOption.SCHEDULED == getAutoStartOption()) {
|
||||
rolloutUpdate.startAt(getScheduledStartTime());
|
||||
}
|
||||
|
||||
@@ -330,10 +330,10 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
||||
.description(description.getValue()).set(distributionId).targetFilterQuery(getTargetFilterQuery())
|
||||
.actionType(getActionType()).forcedTime(getForcedTimeStamp());
|
||||
|
||||
if (AutoStartOptionGroupLayout.AutoStartOption.AUTO_START.equals(getAutoStartOption())) {
|
||||
if (AutoStartOptionGroupLayout.AutoStartOption.AUTO_START == getAutoStartOption()) {
|
||||
rolloutCreate.startAt(System.currentTimeMillis());
|
||||
}
|
||||
if (AutoStartOptionGroupLayout.AutoStartOption.SCHEDULED.equals(getAutoStartOption())) {
|
||||
if (AutoStartOptionGroupLayout.AutoStartOption.SCHEDULED == getAutoStartOption()) {
|
||||
rolloutCreate.startAt(getScheduledStartTime());
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
||||
}
|
||||
|
||||
private Long getScheduledStartTime() {
|
||||
return AutoStartOptionGroupLayout.AutoStartOption.SCHEDULED.equals(getAutoStartOption())
|
||||
return AutoStartOptionGroupLayout.AutoStartOption.SCHEDULED == getAutoStartOption()
|
||||
? autoStartOptionGroupLayout.getStartAtDateField().getValue().getTime()
|
||||
: null;
|
||||
}
|
||||
@@ -392,8 +392,8 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
|
||||
private CommonDialogWindow createWindow() {
|
||||
return new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
|
||||
.caption(i18n.getMessage("caption.create.new", i18n.getMessage("caption.rollout"))).content(this)
|
||||
.id(UIComponentIdProvider.ROLLOUT_POPUP_ID)
|
||||
.layout(this).i18n(i18n).helpLink(uiProperties.getLinks().getDocumentation().getRolloutView())
|
||||
.id(UIComponentIdProvider.ROLLOUT_POPUP_ID).layout(this).i18n(i18n)
|
||||
.helpLink(uiProperties.getLinks().getDocumentation().getRolloutView())
|
||||
.saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow();
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,8 @@ public class AutoStartOptionGroupLayout extends HorizontalLayout {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
// Vaadin is returning object, so "==" might not work
|
||||
@SuppressWarnings("squid:S4551")
|
||||
public void valueChange(final ValueChangeEvent event) {
|
||||
if (event.getProperty().getValue().equals(AutoStartOption.SCHEDULED)) {
|
||||
startAtDateField.setEnabled(true);
|
||||
|
||||
@@ -545,7 +545,7 @@ public class RolloutListGrid extends AbstractGrid<LazyQueryContainer> {
|
||||
final RolloutStatus rolloutStatus = (RolloutStatus) row.getItemProperty(SPUILabelDefinitions.VAR_STATUS)
|
||||
.getValue();
|
||||
|
||||
if (!RolloutStatus.RUNNING.equals(rolloutStatus)) {
|
||||
if (RolloutStatus.RUNNING != rolloutStatus) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -562,13 +562,13 @@ public class RolloutListGrid extends AbstractGrid<LazyQueryContainer> {
|
||||
.getValue();
|
||||
final String rolloutName = (String) row.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
|
||||
|
||||
if (RolloutStatus.READY.equals(rolloutStatus)) {
|
||||
if (RolloutStatus.READY == rolloutStatus) {
|
||||
rolloutManagement.start(rolloutId);
|
||||
uiNotification.displaySuccess(i18n.getMessage("message.rollout.started", rolloutName));
|
||||
return;
|
||||
}
|
||||
|
||||
if (RolloutStatus.PAUSED.equals(rolloutStatus)) {
|
||||
if (RolloutStatus.PAUSED == rolloutStatus) {
|
||||
rolloutManagement.resumeRollout(rolloutId);
|
||||
uiNotification.displaySuccess(i18n.getMessage("message.rollout.resumed", rolloutName));
|
||||
}
|
||||
@@ -758,22 +758,22 @@ public class RolloutListGrid extends AbstractGrid<LazyQueryContainer> {
|
||||
}
|
||||
|
||||
private StatusFontIcon createTypeLabelAdapter(final ActionType actionType) {
|
||||
if (ActionType.FORCED.equals(actionType)) {
|
||||
if (ActionType.FORCED == actionType) {
|
||||
return new StatusFontIcon(FontAwesome.BOLT, STATUS_ICON_FORCED,
|
||||
i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_FORCED),
|
||||
UIComponentIdProvider.ACTION_HISTORY_TABLE_TYPE_LABEL_ID);
|
||||
}
|
||||
if (ActionType.TIMEFORCED.equals(actionType)) {
|
||||
if (ActionType.TIMEFORCED == actionType) {
|
||||
return new StatusFontIcon(FontAwesome.HISTORY, STATUS_ICON_FORCED,
|
||||
i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_TIME_FORCED),
|
||||
UIComponentIdProvider.ACTION_HISTORY_TABLE_TYPE_LABEL_ID);
|
||||
}
|
||||
if (ActionType.SOFT.equals(actionType)) {
|
||||
if (ActionType.SOFT == actionType) {
|
||||
return new StatusFontIcon(FontAwesome.STEP_FORWARD, STATUS_ICON_SOFT,
|
||||
i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_SOFT),
|
||||
UIComponentIdProvider.ACTION_HISTORY_TABLE_TYPE_LABEL_ID);
|
||||
}
|
||||
if (ActionType.DOWNLOAD_ONLY.equals(actionType)) {
|
||||
if (ActionType.DOWNLOAD_ONLY == actionType) {
|
||||
return new StatusFontIcon(FontAwesome.DOWNLOAD, STATUS_ICON_DOWNLOAD_ONLY,
|
||||
i18n.getMessage(UIMessageIdProvider.CAPTION_ACTION_DOWNLOAD_ONLY),
|
||||
UIComponentIdProvider.ACTION_HISTORY_TABLE_TYPE_LABEL_ID);
|
||||
|
||||
@@ -245,10 +245,9 @@ public class RolloutGroupTargetsListGrid extends AbstractGrid<LazyQueryContainer
|
||||
}
|
||||
|
||||
private StatusFontIcon mapActionStatusToPresentation(final Status status) {
|
||||
final boolean isFinishedDownloadOnlyAssignment = Status.DOWNLOADED.equals(status)
|
||||
&& rolloutUIState.getRolloutGroup()
|
||||
.map(group -> Action.ActionType.DOWNLOAD_ONLY.equals(group.getRollout().getActionType()))
|
||||
.orElse(false);
|
||||
final boolean isFinishedDownloadOnlyAssignment = Status.DOWNLOADED == status && rolloutUIState
|
||||
.getRolloutGroup()
|
||||
.map(group -> Action.ActionType.DOWNLOAD_ONLY == group.getRollout().getActionType()).orElse(false);
|
||||
|
||||
return isFinishedDownloadOnlyAssignment ? statusIconMap.get(Status.FINISHED) : statusIconMap.get(status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user