Merge branch 'master' into
fix_dialog_window_must_not_close_after_save_if_duplicate_exists Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>
This commit is contained in:
@@ -243,12 +243,16 @@ public class AmqpConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create amqp handler service bean.
|
* Create amqp handler service bean.
|
||||||
|
*
|
||||||
|
* @param amqpMessageDispatcherService
|
||||||
|
* to sending events to DMF client
|
||||||
*
|
*
|
||||||
* @return handler service bean
|
* @return handler service bean
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public AmqpMessageHandlerService amqpMessageHandlerService() {
|
public AmqpMessageHandlerService amqpMessageHandlerService(
|
||||||
return new AmqpMessageHandlerService(rabbitTemplate());
|
final AmqpMessageDispatcherService amqpMessageDispatcherService) {
|
||||||
|
return new AmqpMessageHandlerService(rabbitTemplate(), amqpMessageDispatcherService);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -74,8 +74,6 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
|||||||
import org.springframework.security.core.context.SecurityContextImpl;
|
import org.springframework.security.core.context.SecurityContextImpl;
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
import com.google.common.eventbus.EventBus;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* {@link AmqpMessageHandlerService} handles all incoming AMQP messages for the
|
* {@link AmqpMessageHandlerService} handles all incoming AMQP messages for the
|
||||||
@@ -86,6 +84,8 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
|
|||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(AmqpMessageHandlerService.class);
|
private static final Logger LOG = LoggerFactory.getLogger(AmqpMessageHandlerService.class);
|
||||||
|
|
||||||
|
private final AmqpMessageDispatcherService amqpMessageDispatcherService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ControllerManagement controllerManagement;
|
private ControllerManagement controllerManagement;
|
||||||
|
|
||||||
@@ -95,9 +95,6 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ArtifactManagement artifactManagement;
|
private ArtifactManagement artifactManagement;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EventBus eventBus;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier(CacheConstants.DOWNLOAD_ID_CACHE)
|
@Qualifier(CacheConstants.DOWNLOAD_ID_CACHE)
|
||||||
private Cache cache;
|
private Cache cache;
|
||||||
@@ -116,9 +113,13 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
|
|||||||
*
|
*
|
||||||
* @param defaultTemplate
|
* @param defaultTemplate
|
||||||
* the configured amqp template.
|
* the configured amqp template.
|
||||||
|
* @param amqpMessageDispatcherService
|
||||||
|
* to sending events to DMF client
|
||||||
*/
|
*/
|
||||||
public AmqpMessageHandlerService(final RabbitTemplate defaultTemplate) {
|
public AmqpMessageHandlerService(final RabbitTemplate defaultTemplate,
|
||||||
|
final AmqpMessageDispatcherService amqpMessageDispatcherService) {
|
||||||
super(defaultTemplate);
|
super(defaultTemplate);
|
||||||
|
this.amqpMessageDispatcherService = amqpMessageDispatcherService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -353,9 +354,9 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
|
|||||||
final List<SoftwareModule> softwareModuleList = controllerManagement
|
final List<SoftwareModule> softwareModuleList = controllerManagement
|
||||||
.findSoftwareModulesByDistributionSet(distributionSet);
|
.findSoftwareModulesByDistributionSet(distributionSet);
|
||||||
final String targetSecurityToken = systemSecurityContext.runAsSystem(() -> target.getSecurityToken());
|
final String targetSecurityToken = systemSecurityContext.runAsSystem(() -> target.getSecurityToken());
|
||||||
eventBus.post(new TargetAssignDistributionSetEvent(target.getOptLockRevision(), target.getTenant(),
|
amqpMessageDispatcherService.targetAssignDistributionSet(new TargetAssignDistributionSetEvent(
|
||||||
target.getControllerId(), action.getId(), softwareModuleList, target.getTargetInfo().getAddress(),
|
target.getOptLockRevision(), target.getTenant(), target.getControllerId(), action.getId(),
|
||||||
targetSecurityToken));
|
softwareModuleList, target.getTargetInfo().getAddress(), targetSecurityToken));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,6 +387,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
|
|||||||
final Action action = checkActionExist(message, actionUpdateStatus);
|
final Action action = checkActionExist(message, actionUpdateStatus);
|
||||||
|
|
||||||
final ActionStatus actionStatus = createActionStatus(message, actionUpdateStatus, action);
|
final ActionStatus actionStatus = createActionStatus(message, actionUpdateStatus, action);
|
||||||
|
updateLastPollTime(action.getTarget());
|
||||||
|
|
||||||
switch (actionUpdateStatus.getActionStatus()) {
|
switch (actionUpdateStatus.getActionStatus()) {
|
||||||
case DOWNLOAD:
|
case DOWNLOAD:
|
||||||
@@ -423,6 +425,10 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateLastPollTime(final Target target) {
|
||||||
|
controllerManagement.updateTargetStatus(target.getTargetInfo(), null, System.currentTimeMillis(), null);
|
||||||
|
}
|
||||||
|
|
||||||
private ActionStatus createActionStatus(final Message message, final ActionUpdateStatus actionUpdateStatus,
|
private ActionStatus createActionStatus(final Message message, final ActionUpdateStatus actionUpdateStatus,
|
||||||
final Action action) {
|
final Action action) {
|
||||||
final ActionStatus actionStatus = entityFactory.generateActionStatus();
|
final ActionStatus actionStatus = entityFactory.generateActionStatus();
|
||||||
@@ -509,10 +515,6 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
|
|||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setEventBus(final EventBus eventBus) {
|
|
||||||
this.eventBus = eventBus;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setEntityFactory(final EntityFactory entityFactory) {
|
void setEntityFactory(final EntityFactory entityFactory) {
|
||||||
this.entityFactory = entityFactory;
|
this.entityFactory = entityFactory;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,8 @@ public class AmqpControllerAuthenticationTest {
|
|||||||
messageConverter = new Jackson2JsonMessageConverter();
|
messageConverter = new Jackson2JsonMessageConverter();
|
||||||
final RabbitTemplate rabbitTemplate = mock(RabbitTemplate.class);
|
final RabbitTemplate rabbitTemplate = mock(RabbitTemplate.class);
|
||||||
when(rabbitTemplate.getMessageConverter()).thenReturn(messageConverter);
|
when(rabbitTemplate.getMessageConverter()).thenReturn(messageConverter);
|
||||||
amqpMessageHandlerService = new AmqpMessageHandlerService(rabbitTemplate);
|
amqpMessageHandlerService = new AmqpMessageHandlerService(rabbitTemplate,
|
||||||
|
mock(AmqpMessageDispatcherService.class));
|
||||||
|
|
||||||
authenticationManager = new AmqpControllerAuthentfication();
|
authenticationManager = new AmqpControllerAuthentfication();
|
||||||
authenticationManager.setControllerManagement(mock(ControllerManagement.class));
|
authenticationManager.setControllerManagement(mock(ControllerManagement.class));
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ import org.eclipse.hawkbit.repository.model.Action.Status;
|
|||||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||||
|
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||||
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
|
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
|
||||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -69,8 +70,6 @@ import org.springframework.amqp.support.converter.MessageConverter;
|
|||||||
import org.springframework.cache.Cache;
|
import org.springframework.cache.Cache;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
import com.google.common.eventbus.EventBus;
|
|
||||||
|
|
||||||
import ru.yandex.qatools.allure.annotations.Description;
|
import ru.yandex.qatools.allure.annotations.Description;
|
||||||
import ru.yandex.qatools.allure.annotations.Features;
|
import ru.yandex.qatools.allure.annotations.Features;
|
||||||
import ru.yandex.qatools.allure.annotations.Stories;
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
@@ -86,6 +85,9 @@ public class AmqpMessageHandlerServiceTest {
|
|||||||
|
|
||||||
private MessageConverter messageConverter;
|
private MessageConverter messageConverter;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private AmqpMessageDispatcherService amqpMessageDispatcherServiceMock;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private ControllerManagement controllerManagementMock;
|
private ControllerManagement controllerManagementMock;
|
||||||
|
|
||||||
@@ -107,9 +109,6 @@ public class AmqpMessageHandlerServiceTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private HostnameResolver hostnameResolverMock;
|
private HostnameResolver hostnameResolverMock;
|
||||||
|
|
||||||
@Mock
|
|
||||||
private EventBus eventBus;
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private RabbitTemplate rabbitTemplate;
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
@@ -120,13 +119,12 @@ public class AmqpMessageHandlerServiceTest {
|
|||||||
public void before() throws Exception {
|
public void before() throws Exception {
|
||||||
messageConverter = new Jackson2JsonMessageConverter();
|
messageConverter = new Jackson2JsonMessageConverter();
|
||||||
when(rabbitTemplate.getMessageConverter()).thenReturn(messageConverter);
|
when(rabbitTemplate.getMessageConverter()).thenReturn(messageConverter);
|
||||||
amqpMessageHandlerService = new AmqpMessageHandlerService(rabbitTemplate);
|
amqpMessageHandlerService = new AmqpMessageHandlerService(rabbitTemplate, amqpMessageDispatcherServiceMock);
|
||||||
amqpMessageHandlerService.setControllerManagement(controllerManagementMock);
|
amqpMessageHandlerService.setControllerManagement(controllerManagementMock);
|
||||||
amqpMessageHandlerService.setAuthenticationManager(authenticationManagerMock);
|
amqpMessageHandlerService.setAuthenticationManager(authenticationManagerMock);
|
||||||
amqpMessageHandlerService.setArtifactManagement(artifactManagementMock);
|
amqpMessageHandlerService.setArtifactManagement(artifactManagementMock);
|
||||||
amqpMessageHandlerService.setCache(cacheMock);
|
amqpMessageHandlerService.setCache(cacheMock);
|
||||||
amqpMessageHandlerService.setHostnameResolver(hostnameResolverMock);
|
amqpMessageHandlerService.setHostnameResolver(hostnameResolverMock);
|
||||||
amqpMessageHandlerService.setEventBus(eventBus);
|
|
||||||
amqpMessageHandlerService.setEntityFactory(entityFactoryMock);
|
amqpMessageHandlerService.setEntityFactory(entityFactoryMock);
|
||||||
amqpMessageHandlerService.setSystemSecurityContext(systemSecurityContextMock);
|
amqpMessageHandlerService.setSystemSecurityContext(systemSecurityContextMock);
|
||||||
|
|
||||||
@@ -134,7 +132,7 @@ public class AmqpMessageHandlerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests not allowed content-type in message")
|
@Description("Tests not allowed content-type in message")
|
||||||
public void testWrongContentType() {
|
public void wrongContentType() {
|
||||||
final MessageProperties messageProperties = new MessageProperties();
|
final MessageProperties messageProperties = new MessageProperties();
|
||||||
messageProperties.setContentType("xml");
|
messageProperties.setContentType("xml");
|
||||||
final Message message = new Message(new byte[0], messageProperties);
|
final Message message = new Message(new byte[0], messageProperties);
|
||||||
@@ -147,7 +145,7 @@ public class AmqpMessageHandlerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests the creation of a target/thing by calling the same method that incoming RabbitMQ messages would access.")
|
@Description("Tests the creation of a target/thing by calling the same method that incoming RabbitMQ messages would access.")
|
||||||
public void testCreateThing() {
|
public void createThing() {
|
||||||
final String knownThingId = "1";
|
final String knownThingId = "1";
|
||||||
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED);
|
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED);
|
||||||
messageProperties.setHeader(MessageHeaderKey.THING_ID, "1");
|
messageProperties.setHeader(MessageHeaderKey.THING_ID, "1");
|
||||||
@@ -168,7 +166,7 @@ public class AmqpMessageHandlerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests the creation of a thing without a 'reply to' header in message.")
|
@Description("Tests the creation of a thing without a 'reply to' header in message.")
|
||||||
public void testCreateThingWitoutReplyTo() {
|
public void createThingWitoutReplyTo() {
|
||||||
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED, null);
|
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED, null);
|
||||||
messageProperties.setHeader(MessageHeaderKey.THING_ID, "1");
|
messageProperties.setHeader(MessageHeaderKey.THING_ID, "1");
|
||||||
final Message message = messageConverter.toMessage("", messageProperties);
|
final Message message = messageConverter.toMessage("", messageProperties);
|
||||||
@@ -184,7 +182,7 @@ public class AmqpMessageHandlerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests the creation of a target/thing without a thingID by calling the same method that incoming RabbitMQ messages would access.")
|
@Description("Tests the creation of a target/thing without a thingID by calling the same method that incoming RabbitMQ messages would access.")
|
||||||
public void testCreateThingWithoutID() {
|
public void createThingWithoutID() {
|
||||||
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED);
|
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED);
|
||||||
final Message message = messageConverter.toMessage(new byte[0], messageProperties);
|
final Message message = messageConverter.toMessage(new byte[0], messageProperties);
|
||||||
try {
|
try {
|
||||||
@@ -197,7 +195,7 @@ public class AmqpMessageHandlerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests the call of the same method that incoming RabbitMQ messages would access with an unknown message type.")
|
@Description("Tests the call of the same method that incoming RabbitMQ messages would access with an unknown message type.")
|
||||||
public void testUnknownMessageType() {
|
public void unknownMessageType() {
|
||||||
final String type = "bumlux";
|
final String type = "bumlux";
|
||||||
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED);
|
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED);
|
||||||
messageProperties.setHeader(MessageHeaderKey.THING_ID, "");
|
messageProperties.setHeader(MessageHeaderKey.THING_ID, "");
|
||||||
@@ -213,7 +211,7 @@ public class AmqpMessageHandlerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests a invalid message without event topic")
|
@Description("Tests a invalid message without event topic")
|
||||||
public void testInvalidEventTopic() {
|
public void invalidEventTopic() {
|
||||||
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
|
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
|
||||||
final Message message = new Message(new byte[0], messageProperties);
|
final Message message = new Message(new byte[0], messageProperties);
|
||||||
try {
|
try {
|
||||||
@@ -241,7 +239,7 @@ public class AmqpMessageHandlerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests the update of an action of a target without a exist action id")
|
@Description("Tests the update of an action of a target without a exist action id")
|
||||||
public void testUpdateActionStatusWithoutActionId() {
|
public void updateActionStatusWithoutActionId() {
|
||||||
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
|
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
|
||||||
messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
|
messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
|
||||||
final ActionUpdateStatus actionUpdateStatus = new ActionUpdateStatus();
|
final ActionUpdateStatus actionUpdateStatus = new ActionUpdateStatus();
|
||||||
@@ -259,7 +257,7 @@ public class AmqpMessageHandlerServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests the update of an action of a target without a exist action id")
|
@Description("Tests the update of an action of a target without a exist action id")
|
||||||
public void testUpdateActionStatusWithoutExistActionId() {
|
public void updateActionStatusWithoutExistActionId() {
|
||||||
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
|
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
|
||||||
messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
|
messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
|
||||||
final ActionUpdateStatus actionUpdateStatus = createActionUpdateStatus(ActionStatus.DOWNLOAD);
|
final ActionUpdateStatus actionUpdateStatus = createActionUpdateStatus(ActionStatus.DOWNLOAD);
|
||||||
@@ -384,9 +382,13 @@ public class AmqpMessageHandlerServiceTest {
|
|||||||
amqpMessageHandlerService.onMessage(message, MessageType.EVENT.name(), TENANT, "vHost");
|
amqpMessageHandlerService.onMessage(message, MessageType.EVENT.name(), TENANT, "vHost");
|
||||||
|
|
||||||
// verify
|
// verify
|
||||||
|
verify(controllerManagementMock).updateTargetStatus(Matchers.any(TargetInfo.class),
|
||||||
|
Matchers.isNull(TargetUpdateStatus.class), Matchers.isNotNull(Long.class), Matchers.isNull(URI.class));
|
||||||
|
|
||||||
final ArgumentCaptor<TargetAssignDistributionSetEvent> captorTargetAssignDistributionSetEvent = ArgumentCaptor
|
final ArgumentCaptor<TargetAssignDistributionSetEvent> captorTargetAssignDistributionSetEvent = ArgumentCaptor
|
||||||
.forClass(TargetAssignDistributionSetEvent.class);
|
.forClass(TargetAssignDistributionSetEvent.class);
|
||||||
verify(eventBus, times(1)).post(captorTargetAssignDistributionSetEvent.capture());
|
verify(amqpMessageDispatcherServiceMock, times(1))
|
||||||
|
.targetAssignDistributionSet(captorTargetAssignDistributionSetEvent.capture());
|
||||||
final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = captorTargetAssignDistributionSetEvent
|
final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = captorTargetAssignDistributionSetEvent
|
||||||
.getValue();
|
.getValue();
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.eclipse.hawkbit.repository.model.AssignmentResult;
|
import org.eclipse.hawkbit.repository.model.AssignmentResult;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A bean which holds a complex result of an service operation to combine the
|
* A bean which holds a complex result of an service operation to combine the
|
||||||
@@ -61,6 +62,10 @@ public class DistributionSetAssignmentResult extends AssignmentResult<Target> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Target> getAssignedEntity() {
|
public List<Target> getAssignedEntity() {
|
||||||
|
if (CollectionUtils.isEmpty(assignedTargets)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
return targetManagement.findTargetByControllerID(assignedTargets);
|
return targetManagement.findTargetByControllerID(assignedTargets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -299,8 +299,6 @@ public class JpaControllerManagement implements ControllerManagement {
|
|||||||
case CANCELED:
|
case CANCELED:
|
||||||
case WARNING:
|
case WARNING:
|
||||||
case RUNNING:
|
case RUNNING:
|
||||||
handleIntermediateFeedback(mergedAction, mergedTarget);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -312,16 +310,6 @@ public class JpaControllerManagement implements ControllerManagement {
|
|||||||
return actionRepository.save(mergedAction);
|
return actionRepository.save(mergedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleIntermediateFeedback(final JpaAction mergedAction, final JpaTarget mergedTarget) {
|
|
||||||
// we change the target state only if the action is still running
|
|
||||||
// otherwise this is considered as late feedback that does not have
|
|
||||||
// an impact on the state anymore.
|
|
||||||
if (mergedAction.isActive()) {
|
|
||||||
DeploymentHelper.updateTargetInfo(mergedTarget, TargetUpdateStatus.PENDING, false, targetInfoRepository,
|
|
||||||
entityManager);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleErrorOnAction(final JpaAction mergedAction, final JpaTarget mergedTarget) {
|
private void handleErrorOnAction(final JpaAction mergedAction, final JpaTarget mergedTarget) {
|
||||||
mergedAction.setActive(false);
|
mergedAction.setActive(false);
|
||||||
mergedAction.setStatus(Status.ERROR);
|
mergedAction.setStatus(Status.ERROR);
|
||||||
@@ -349,15 +337,17 @@ public class JpaControllerManagement implements ControllerManagement {
|
|||||||
action.setStatus(Status.FINISHED);
|
action.setStatus(Status.FINISHED);
|
||||||
final JpaTargetInfo targetInfo = (JpaTargetInfo) target.getTargetInfo();
|
final JpaTargetInfo targetInfo = (JpaTargetInfo) target.getTargetInfo();
|
||||||
final JpaDistributionSet ds = (JpaDistributionSet) entityManager.merge(action.getDistributionSet());
|
final JpaDistributionSet ds = (JpaDistributionSet) entityManager.merge(action.getDistributionSet());
|
||||||
|
|
||||||
targetInfo.setInstalledDistributionSet(ds);
|
targetInfo.setInstalledDistributionSet(ds);
|
||||||
if (target.getAssignedDistributionSet() != null && targetInfo.getInstalledDistributionSet() != null && target
|
targetInfo.setInstallationDate(System.currentTimeMillis());
|
||||||
.getAssignedDistributionSet().getId().equals(targetInfo.getInstalledDistributionSet().getId())) {
|
|
||||||
|
// check if the assigned set is equal to the installed set (not
|
||||||
|
// necessarily the case as another update might be pending already).
|
||||||
|
if (target.getAssignedDistributionSet() != null && target.getAssignedDistributionSet().getId()
|
||||||
|
.equals(targetInfo.getInstalledDistributionSet().getId())) {
|
||||||
targetInfo.setUpdateStatus(TargetUpdateStatus.IN_SYNC);
|
targetInfo.setUpdateStatus(TargetUpdateStatus.IN_SYNC);
|
||||||
targetInfo.setInstallationDate(System.currentTimeMillis());
|
|
||||||
} else {
|
|
||||||
targetInfo.setUpdateStatus(TargetUpdateStatus.PENDING);
|
|
||||||
targetInfo.setInstallationDate(System.currentTimeMillis());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
targetInfoRepository.save(targetInfo);
|
targetInfoRepository.save(targetInfo);
|
||||||
entityManager.detach(ds);
|
entityManager.detach(ds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||||
import org.eclipse.hawkbit.repository.exception.DistributionSetTypeUndefinedException;
|
import org.eclipse.hawkbit.repository.exception.DistributionSetTypeUndefinedException;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||||
@@ -197,7 +198,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verfies that a DS is of default type if not specified explicitly at creation time.")
|
@Description("Verifies that a DS is of default type if not specified explicitly at creation time.")
|
||||||
public void createDistributionSetWithImplicitType() {
|
public void createDistributionSetWithImplicitType() {
|
||||||
final DistributionSet set = distributionSetManagement
|
final DistributionSet set = distributionSetManagement
|
||||||
.createDistributionSet(new JpaDistributionSet("newtypesoft", "1", "", null, null));
|
.createDistributionSet(new JpaDistributionSet("newtypesoft", "1", "", null, null));
|
||||||
@@ -208,7 +209,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verfies that multiple DS are of default type if not specified explicitly at creation time.")
|
@Description("Verifies that multiple DS are of default type if not specified explicitly at creation time.")
|
||||||
public void createMultipleDistributionSetsWithImplicitType() {
|
public void createMultipleDistributionSetsWithImplicitType() {
|
||||||
|
|
||||||
List<DistributionSet> sets = new ArrayList<>();
|
List<DistributionSet> sets = new ArrayList<>();
|
||||||
@@ -228,7 +229,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verfies that a DS entity cannot be used for creation.")
|
@Description("Verifies that a DS entity cannot be used for creation.")
|
||||||
public void createDistributionSetFailsOnExistingEntity() {
|
public void createDistributionSetFailsOnExistingEntity() {
|
||||||
final DistributionSet set = distributionSetManagement
|
final DistributionSet set = distributionSetManagement
|
||||||
.createDistributionSet(new JpaDistributionSet("newtypesoft", "1", "", null, null));
|
.createDistributionSet(new JpaDistributionSet("newtypesoft", "1", "", null, null));
|
||||||
@@ -818,6 +819,27 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
.isEqualTo(2);
|
.isEqualTo(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Description("Verify that the DistributionSetAssignmentResult not contains already assigned targets.")
|
||||||
|
public void verifyDistributionSetAssignmentResultNotContainsAlreadyAssignedTargets() {
|
||||||
|
DistributionSet dsToTargetAssigned = testdataFactory.createDistributionSet("ds-3");
|
||||||
|
|
||||||
|
// create assigned DS
|
||||||
|
dsToTargetAssigned = distributionSetManagement.findDistributionSetByNameAndVersion(dsToTargetAssigned.getName(),
|
||||||
|
dsToTargetAssigned.getVersion());
|
||||||
|
final Target target = new JpaTarget("4712");
|
||||||
|
final Target savedTarget = targetManagement.createTarget(target);
|
||||||
|
final List<Target> toAssign = Lists.newArrayList(savedTarget);
|
||||||
|
DistributionSetAssignmentResult assignmentResult = deploymentManagement
|
||||||
|
.assignDistributionSet(dsToTargetAssigned, toAssign);
|
||||||
|
assertThat(assignmentResult.getAssignedEntity()).hasSize(1);
|
||||||
|
|
||||||
|
assignmentResult = deploymentManagement.assignDistributionSet(dsToTargetAssigned, toAssign);
|
||||||
|
assertThat(assignmentResult.getAssignedEntity()).hasSize(0);
|
||||||
|
|
||||||
|
assertThat(distributionSetRepository.findAll()).hasSize(1);
|
||||||
|
}
|
||||||
|
|
||||||
private Rollout createRolloutByVariables(final String rolloutName, final String rolloutDescription,
|
private Rollout createRolloutByVariables(final String rolloutName, final String rolloutDescription,
|
||||||
final int groupSize, final String filterQuery, final DistributionSet distributionSet,
|
final int groupSize, final String filterQuery, final DistributionSet distributionSet,
|
||||||
final String successCondition, final String errorCondition) {
|
final String successCondition, final String errorCondition) {
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
|||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.event.dd.DragAndDropEvent;
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
import com.vaadin.event.dd.DropHandler;
|
|
||||||
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
@@ -215,21 +214,13 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DropHandler getTableDropHandler() {
|
protected AcceptCriterion getDropAcceptCriterion() {
|
||||||
return new DropHandler() {
|
return uploadViewAcceptCriteria;
|
||||||
|
}
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
@Override
|
||||||
|
protected boolean isDropValid(final DragAndDropEvent dragEvent) {
|
||||||
@Override
|
return false;
|
||||||
public AcceptCriterion getAcceptCriterion() {
|
|
||||||
return uploadViewAcceptCriteria;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drop(final DragAndDropEvent event) {
|
|
||||||
/* Not required */
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
|||||||
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
||||||
|
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
|
import com.vaadin.ui.DragAndDropWrapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract table to handling {@link NamedVersionedEntity}
|
* Abstract table to handling {@link NamedVersionedEntity}
|
||||||
@@ -54,4 +56,30 @@ public abstract class AbstractNamedVersionTable<E extends NamedVersionedEntity,
|
|||||||
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(baseEntity.getVersion());
|
item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(baseEntity.getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDropEventFromTable(final DragAndDropEvent event) {
|
||||||
|
// subclass can implement
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDropEventFromWrapper(final DragAndDropEvent event) {
|
||||||
|
// subclass can implement
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean hasDropPermission() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getDropTableId() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean validateDragAndDropWrapper(final DragAndDropWrapper wrapperSource) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,13 +26,20 @@ import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
|
|||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
||||||
|
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.vaadin.spring.events.EventBus;
|
import org.vaadin.spring.events.EventBus;
|
||||||
|
|
||||||
import com.google.gwt.thirdparty.guava.common.collect.Iterables;
|
import com.google.gwt.thirdparty.guava.common.collect.Iterables;
|
||||||
|
import com.google.gwt.thirdparty.guava.common.collect.Sets;
|
||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
|
import com.vaadin.event.Transferable;
|
||||||
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
import com.vaadin.event.dd.DropHandler;
|
import com.vaadin.event.dd.DropHandler;
|
||||||
|
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
||||||
|
import com.vaadin.ui.Component;
|
||||||
|
import com.vaadin.ui.DragAndDropWrapper;
|
||||||
import com.vaadin.ui.Table;
|
import com.vaadin.ui.Table;
|
||||||
import com.vaadin.ui.UI;
|
import com.vaadin.ui.UI;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
@@ -51,12 +58,17 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 4856562746502217630L;
|
private static final long serialVersionUID = 4856562746502217630L;
|
||||||
|
|
||||||
|
protected static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected transient EventBus.SessionEventBus eventBus;
|
protected transient EventBus.SessionEventBus eventBus;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected I18N i18n;
|
protected I18N i18n;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected UINotification notification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the components.
|
* Initialize the components.
|
||||||
*/
|
*/
|
||||||
@@ -359,12 +371,100 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
|
|||||||
return DEFAULT_COLUMN_NAME_MIN_SIZE;
|
return DEFAULT_COLUMN_NAME_MIN_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private DropHandler getTableDropHandler() {
|
||||||
* Get drop handler for the table.
|
return new DropHandler() {
|
||||||
*
|
private static final long serialVersionUID = 1L;
|
||||||
* @return reference of {@link DropHandler}
|
|
||||||
*/
|
@Override
|
||||||
protected abstract DropHandler getTableDropHandler();
|
public AcceptCriterion getAcceptCriterion() {
|
||||||
|
return getDropAcceptCriterion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drop(final DragAndDropEvent event) {
|
||||||
|
if (!isDropValid(event)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.getTransferable().getSourceComponent() instanceof Table) {
|
||||||
|
onDropEventFromTable(event);
|
||||||
|
} else if (event.getTransferable().getSourceComponent() instanceof DragAndDropWrapper) {
|
||||||
|
onDropEventFromWrapper(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Set<I> getDraggedTargetList(final DragAndDropEvent event) {
|
||||||
|
final com.vaadin.event.dd.TargetDetails targetDet = event.getTargetDetails();
|
||||||
|
final Table targetTable = (Table) targetDet.getTarget();
|
||||||
|
final Set<I> targetSelected = getTableValue(targetTable);
|
||||||
|
|
||||||
|
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
|
||||||
|
final Object targetItemId = dropData.getItemIdOver();
|
||||||
|
|
||||||
|
if (!targetSelected.contains(targetItemId)) {
|
||||||
|
return Sets.newHashSet((I) targetItemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return targetSelected;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<Object> getDraggedTargetList(final TableTransferable transferable, final Table source) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
final AbstractTable<NamedEntity, Object> table = (AbstractTable<NamedEntity, Object>) source;
|
||||||
|
return table.getDeletedEntityByTransferable(transferable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean validateDropList(final Set<?> droplist) {
|
||||||
|
if (droplist.isEmpty()) {
|
||||||
|
final String actionDidNotWork = i18n.get("message.action.did.not.work", new Object[] {});
|
||||||
|
notification.displayValidationError(actionDidNotWork);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isDropValid(final DragAndDropEvent dragEvent) {
|
||||||
|
final Transferable transferable = dragEvent.getTransferable();
|
||||||
|
final Component compsource = transferable.getSourceComponent();
|
||||||
|
|
||||||
|
if (!hasDropPermission()) {
|
||||||
|
notification.displayValidationError(i18n.get("message.permission.insufficient"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compsource instanceof Table) {
|
||||||
|
return validateTable((Table) compsource)
|
||||||
|
&& validateDropList(getDraggedTargetList((TableTransferable) transferable, (Table) compsource));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compsource instanceof DragAndDropWrapper) {
|
||||||
|
return validateDragAndDropWrapper((DragAndDropWrapper) compsource)
|
||||||
|
&& validateDropList(getDraggedTargetList(dragEvent));
|
||||||
|
}
|
||||||
|
notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean validateTable(final Table compsource) {
|
||||||
|
if (!compsource.getId().equals(getDropTableId())) {
|
||||||
|
notification.displayValidationError(ACTION_NOT_ALLOWED_MSG);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract boolean hasDropPermission();
|
||||||
|
|
||||||
|
protected abstract boolean validateDragAndDropWrapper(final DragAndDropWrapper wrapperSource);
|
||||||
|
|
||||||
|
protected abstract void onDropEventFromWrapper(DragAndDropEvent event);
|
||||||
|
|
||||||
|
protected abstract void onDropEventFromTable(DragAndDropEvent event);
|
||||||
|
|
||||||
|
protected abstract String getDropTableId();
|
||||||
|
|
||||||
|
protected abstract AcceptCriterion getDropAcceptCriterion();
|
||||||
|
|
||||||
protected abstract void setDataAvailable(boolean available);
|
protected abstract void setDataAvailable(boolean available);
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
|||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
||||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -61,7 +60,6 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
|||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.event.dd.DragAndDropEvent;
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
import com.vaadin.event.dd.DropHandler;
|
|
||||||
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
@@ -100,9 +98,6 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
|
private DistributionsViewAcceptCriteria distributionsViewAcceptCriteria;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UINotification notification;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private transient TargetManagement targetManagement;
|
private transient TargetManagement targetManagement;
|
||||||
|
|
||||||
@@ -231,25 +226,12 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DropHandler getTableDropHandler() {
|
public AcceptCriterion getDropAcceptCriterion() {
|
||||||
return new DropHandler() {
|
return distributionsViewAcceptCriteria;
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AcceptCriterion getAcceptCriterion() {
|
|
||||||
return distributionsViewAcceptCriteria;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drop(final DragAndDropEvent event) {
|
|
||||||
if (doValidation(event)) {
|
|
||||||
onDrop(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onDrop(final DragAndDropEvent event) {
|
@Override
|
||||||
|
protected void onDropEventFromTable(final DragAndDropEvent event) {
|
||||||
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final AbstractTable<?, Long> source = (AbstractTable<SoftwareModule, Long>) transferable.getSourceComponent();
|
final AbstractTable<?, Long> source = (AbstractTable<SoftwareModule, Long>) transferable.getSourceComponent();
|
||||||
@@ -262,6 +244,22 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
|||||||
if (item != null && item.getItemProperty("id") != null && item.getItemProperty("name") != null) {
|
if (item != null && item.getItemProperty("id") != null && item.getItemProperty("name") != null) {
|
||||||
handleDropEvent(source, softwareModulesIdList, item);
|
handleDropEvent(source, softwareModulesIdList, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDropEventFromWrapper(final DragAndDropEvent event) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isDropValid(final DragAndDropEvent dragEvent) {
|
||||||
|
final Component compsource = dragEvent.getTransferable().getSourceComponent();
|
||||||
|
if (!(compsource instanceof Table)) {
|
||||||
|
notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return super.isDropValid(dragEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleDropEvent(final Table source, final Set<Long> softwareModulesIdList, final Item item) {
|
private void handleDropEvent(final Table source, final Set<Long> softwareModulesIdList, final Item item) {
|
||||||
@@ -364,7 +362,8 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (distributionSetManagement.isDistributionSetInUse(ds)) {
|
if (distributionSetManagement.isDistributionSetInUse(ds)) {
|
||||||
notification.displayValidationError(i18n.get("message.error.notification.ds.target.assigned", ds.getName(), ds.getVersion()));
|
notification.displayValidationError(
|
||||||
|
i18n.get("message.error.notification.ds.target.assigned", ds.getName(), ds.getVersion()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -415,31 +414,14 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Validate event.
|
protected String getDropTableId() {
|
||||||
*
|
return SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE;
|
||||||
* @param dragEvent
|
}
|
||||||
* as event
|
|
||||||
* @return boolean as flag
|
@Override
|
||||||
*/
|
protected boolean hasDropPermission() {
|
||||||
private Boolean doValidation(final DragAndDropEvent dragEvent) {
|
return permissionChecker.hasUpdateDistributionPermission();
|
||||||
if (!permissionChecker.hasUpdateDistributionPermission()) {
|
|
||||||
notification.displayValidationError(i18n.get("message.permission.insufficient"));
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
final Component compsource = dragEvent.getTransferable().getSourceComponent();
|
|
||||||
final Table source = (Table) compsource;
|
|
||||||
if (compsource instanceof Table) {
|
|
||||||
if (!source.getId().equals(SPUIComponentIdProvider.UPLOAD_SOFTWARE_MODULE_TABLE)) {
|
|
||||||
notification.displayValidationError(i18n.get("message.action.not.allowed"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
notification.displayValidationError(i18n.get("message.action.not.allowed"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTableStyleGenerator() {
|
private void addTableStyleGenerator() {
|
||||||
@@ -550,7 +532,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
|||||||
|
|
||||||
private void showMetadataDetails(final Long itemId) {
|
private void showMetadataDetails(final Long itemId) {
|
||||||
final DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(itemId);
|
final DistributionSet ds = distributionSetManagement.findDistributionSetByIdWithDetails(itemId);
|
||||||
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds,null));
|
UI.getCurrent().addWindow(dsMetadataPopupLayout.getWindow(ds, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNameAndVerion(final Object itemId) {
|
private String getNameAndVerion(final Object itemId) {
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
|||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.event.dd.DragAndDropEvent;
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
import com.vaadin.event.dd.DropHandler;
|
|
||||||
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.server.Page;
|
import com.vaadin.server.Page;
|
||||||
@@ -78,7 +77,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ArtifactDetailsLayout artifactDetailsLayout;
|
private ArtifactDetailsLayout artifactDetailsLayout;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SwMetadataPopupLayout swMetadataPopupLayout;
|
private SwMetadataPopupLayout swMetadataPopupLayout;
|
||||||
|
|
||||||
@@ -180,9 +179,10 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
|
|||||||
|
|
||||||
addGeneratedColumn(SPUILabelDefinitions.ARTIFACT_ICON, new ColumnGenerator() {
|
addGeneratedColumn(SPUILabelDefinitions.ARTIFACT_ICON, new ColumnGenerator() {
|
||||||
private static final long serialVersionUID = -5982361782989980277L;
|
private static final long serialVersionUID = -5982361782989980277L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
|
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
|
||||||
HorizontalLayout iconLayout = new HorizontalLayout();
|
final HorizontalLayout iconLayout = new HorizontalLayout();
|
||||||
// add artifactory details popup
|
// add artifactory details popup
|
||||||
final String nameVersionStr = getNameAndVerion(itemId);
|
final String nameVersionStr = getNameAndVerion(itemId);
|
||||||
final Button showArtifactDtlsBtn = createShowArtifactDtlsButton(nameVersionStr);
|
final Button showArtifactDtlsBtn = createShowArtifactDtlsButton(nameVersionStr);
|
||||||
@@ -214,7 +214,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
|
|||||||
@Override
|
@Override
|
||||||
protected void publishEntityAfterValueChange(final SoftwareModule selectedLastEntity) {
|
protected void publishEntityAfterValueChange(final SoftwareModule selectedLastEntity) {
|
||||||
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.SELECTED_ENTITY, selectedLastEntity));
|
eventBus.publish(this, new SoftwareModuleEvent(BaseEntityEventType.SELECTED_ENTITY, selectedLastEntity));
|
||||||
if(selectedLastEntity!=null){
|
if (selectedLastEntity != null) {
|
||||||
manageDistUIState.setSelectedBaseSwModuleId(selectedLastEntity.getId());
|
manageDistUIState.setSelectedBaseSwModuleId(selectedLastEntity.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,21 +252,13 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DropHandler getTableDropHandler() {
|
protected AcceptCriterion getDropAcceptCriterion() {
|
||||||
return new DropHandler() {
|
return distributionsViewAcceptCriteria;
|
||||||
|
}
|
||||||
|
|
||||||
private static final long serialVersionUID = -6175865860867652573L;
|
@Override
|
||||||
|
protected boolean isDropValid(final DragAndDropEvent dragEvent) {
|
||||||
@Override
|
return false;
|
||||||
public AcceptCriterion getAcceptCriterion() {
|
|
||||||
return distributionsViewAcceptCriteria;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drop(final DragAndDropEvent event) {
|
|
||||||
/* sw module dont accept drops */
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* All Private Methods */
|
/* All Private Methods */
|
||||||
@@ -326,7 +318,7 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
|
|||||||
return showArtifactDtlsBtn;
|
return showArtifactDtlsBtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Button createManageMetadataButton(String nameVersionStr) {
|
private Button createManageMetadataButton(final String nameVersionStr) {
|
||||||
final Button manageMetadataBtn = SPUIComponentProvider.getButton(
|
final Button manageMetadataBtn = SPUIComponentProvider.getButton(
|
||||||
SPUIComponentIdProvider.SW_TABLE_MANAGE_METADATA_ID + "." + nameVersionStr, "", "", null, false,
|
SPUIComponentIdProvider.SW_TABLE_MANAGE_METADATA_ID + "." + nameVersionStr, "", "", null, false,
|
||||||
FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class);
|
FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class);
|
||||||
@@ -407,9 +399,9 @@ public class SwModuleTable extends AbstractNamedVersionTable<SoftwareModule, Lon
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showMetadataDetails(Long itemId) {
|
private void showMetadataDetails(final Long itemId) {
|
||||||
SoftwareModule swmodule = softwareManagement.findSoftwareModuleWithDetails(itemId);
|
final SoftwareModule swmodule = softwareManagement.findSoftwareModuleWithDetails(itemId);
|
||||||
UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule,null));
|
UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,14 +60,12 @@ import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
|||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.event.dd.DragAndDropEvent;
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
import com.vaadin.event.dd.DropHandler;
|
|
||||||
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
import com.vaadin.spring.annotation.ViewScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
import com.vaadin.ui.Button.ClickEvent;
|
import com.vaadin.ui.Button.ClickEvent;
|
||||||
import com.vaadin.ui.Component;
|
|
||||||
import com.vaadin.ui.DragAndDropWrapper;
|
import com.vaadin.ui.DragAndDropWrapper;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
import com.vaadin.ui.Table;
|
import com.vaadin.ui.Table;
|
||||||
@@ -356,36 +354,23 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DropHandler getTableDropHandler() {
|
public AcceptCriterion getDropAcceptCriterion() {
|
||||||
return new DropHandler() {
|
return managementViewAcceptCriteria;
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AcceptCriterion getAcceptCriterion() {
|
|
||||||
return managementViewAcceptCriteria;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drop(final DragAndDropEvent event) {
|
|
||||||
if (doValidation(event)) {
|
|
||||||
if (event.getTransferable().getSourceComponent() instanceof Table) {
|
|
||||||
assignTargetToDs(event);
|
|
||||||
} else if (event.getTransferable().getSourceComponent() instanceof DragAndDropWrapper) {
|
|
||||||
processWrapperDrop(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processWrapperDrop(final DragAndDropEvent event) {
|
@Override
|
||||||
|
protected void onDropEventFromTable(final DragAndDropEvent event) {
|
||||||
|
assignTargetToDs(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDropEventFromWrapper(final DragAndDropEvent event) {
|
||||||
if (event.getTransferable().getSourceComponent().getId()
|
if (event.getTransferable().getSourceComponent().getId()
|
||||||
.startsWith(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS)) {
|
.startsWith(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS)) {
|
||||||
assignDsTag(event);
|
assignDsTag(event);
|
||||||
} else {
|
} else {
|
||||||
assignTargetTag(event);
|
assignTargetTag(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assignDsTag(final DragAndDropEvent event) {
|
private void assignDsTag(final DragAndDropEvent event) {
|
||||||
@@ -458,42 +443,26 @@ public class DistributionTable extends AbstractNamedVersionTable<DistributionSet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean doValidation(final DragAndDropEvent dragEvent) {
|
@Override
|
||||||
final Component compsource = dragEvent.getTransferable().getSourceComponent();
|
protected boolean hasDropPermission() {
|
||||||
if (compsource instanceof Table) {
|
return permissionChecker.hasUpdateTargetPermission();
|
||||||
return validateTable(compsource);
|
|
||||||
} else if (compsource instanceof DragAndDropWrapper) {
|
|
||||||
return validateDragAndDropWrapper(compsource);
|
|
||||||
} else {
|
|
||||||
notification.displayValidationError(notAllowedMsg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean validateTable(final Component compsource) {
|
@Override
|
||||||
if (!permissionChecker.hasUpdateTargetPermission()) {
|
protected String getDropTableId() {
|
||||||
notification.displayValidationError(i18n.get("message.permission.insufficient"));
|
return SPUIComponentIdProvider.TARGET_TABLE_ID;
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (compsource instanceof Table && !compsource.getId().equals(SPUIComponentIdProvider.TARGET_TABLE_ID)) {
|
|
||||||
notification.displayValidationError(notAllowedMsg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean validateDragAndDropWrapper(final Component compsource) {
|
@Override
|
||||||
final DragAndDropWrapper wrapperSource = (DragAndDropWrapper) compsource;
|
protected boolean validateDragAndDropWrapper(final DragAndDropWrapper wrapperSource) {
|
||||||
final String tagData = wrapperSource.getData().toString();
|
final String tagData = wrapperSource.getData().toString();
|
||||||
if (wrapperSource.getId().startsWith(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS)) {
|
if (wrapperSource.getId().startsWith(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS)) {
|
||||||
return !isNoTagButton(tagData, SPUIDefinitions.DISTRIBUTION_TAG_BUTTON);
|
return !isNoTagButton(tagData, SPUIDefinitions.DISTRIBUTION_TAG_BUTTON);
|
||||||
} else if (wrapperSource.getId().startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS)) {
|
} else if (wrapperSource.getId().startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS)) {
|
||||||
return !isNoTagButton(tagData, SPUIDefinitions.TARGET_TAG_BUTTON);
|
return !isNoTagButton(tagData, SPUIDefinitions.TARGET_TAG_BUTTON);
|
||||||
} else {
|
|
||||||
notification.displayValidationError(notAllowedMsg);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
notification.displayValidationError(notAllowedMsg);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean isNoTagButton(final String tagData, final String targetNoTagData) {
|
private Boolean isNoTagButton(final String tagData, final String targetNoTagData) {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import org.eclipse.hawkbit.repository.eventbus.event.TargetCreatedEvent;
|
|||||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetDeletedEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.TargetDeletedEvent;
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetUpdatedEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.TargetUpdatedEvent;
|
||||||
|
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetIdName;
|
import org.eclipse.hawkbit.repository.model.TargetIdName;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||||
@@ -67,7 +68,6 @@ import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
|||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
import org.eclipse.hawkbit.ui.utils.TableColumn;
|
||||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -81,7 +81,6 @@ import com.google.common.base.Strings;
|
|||||||
import com.vaadin.data.Container;
|
import com.vaadin.data.Container;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.event.dd.DragAndDropEvent;
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
import com.vaadin.event.dd.DropHandler;
|
|
||||||
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.shared.ui.label.ContentMode;
|
import com.vaadin.shared.ui.label.ContentMode;
|
||||||
@@ -89,7 +88,6 @@ import com.vaadin.spring.annotation.SpringComponent;
|
|||||||
import com.vaadin.spring.annotation.ViewScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
import com.vaadin.ui.Button.ClickEvent;
|
import com.vaadin.ui.Button.ClickEvent;
|
||||||
import com.vaadin.ui.Component;
|
|
||||||
import com.vaadin.ui.DragAndDropWrapper;
|
import com.vaadin.ui.DragAndDropWrapper;
|
||||||
import com.vaadin.ui.Label;
|
import com.vaadin.ui.Label;
|
||||||
import com.vaadin.ui.Table;
|
import com.vaadin.ui.Table;
|
||||||
@@ -107,7 +105,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
private static final String TARGET_PINNED = "targetPinned";
|
private static final String TARGET_PINNED = "targetPinned";
|
||||||
private static final long serialVersionUID = -2300392868806614568L;
|
private static final long serialVersionUID = -2300392868806614568L;
|
||||||
private static final int PROPERTY_DEPT = 3;
|
private static final int PROPERTY_DEPT = 3;
|
||||||
private static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed";
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private transient TargetManagement targetManagement;
|
private transient TargetManagement targetManagement;
|
||||||
@@ -118,9 +115,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SpPermissionChecker permChecker;
|
private SpPermissionChecker permChecker;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UINotification notification;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ManagementViewAcceptCriteria managementViewAcceptCriteria;
|
private ManagementViewAcceptCriteria managementViewAcceptCriteria;
|
||||||
|
|
||||||
@@ -303,22 +297,8 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DropHandler getTableDropHandler() {
|
public AcceptCriterion getDropAcceptCriterion() {
|
||||||
return new DropHandler() {
|
return managementViewAcceptCriteria;
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AcceptCriterion getAcceptCriterion() {
|
|
||||||
return managementViewAcceptCriteria;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drop(final DragAndDropEvent event) {
|
|
||||||
if (doValidations(event)) {
|
|
||||||
doAssignments(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onTargetDeletedEvent(final List<TargetDeletedEvent> events) {
|
private void onTargetDeletedEvent(final List<TargetDeletedEvent> events) {
|
||||||
@@ -509,11 +489,14 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
setCellStyleGenerator((source, itemId, propertyId) -> null);
|
setCellStyleGenerator((source, itemId, propertyId) -> null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doAssignments(final DragAndDropEvent event) {
|
@Override
|
||||||
if (event.getTransferable().getSourceComponent() instanceof Table) {
|
protected void onDropEventFromTable(final DragAndDropEvent event) {
|
||||||
dsToTargetAssignment(event);
|
dsToTargetAssignment(event);
|
||||||
} else if (event.getTransferable().getSourceComponent() instanceof DragAndDropWrapper
|
}
|
||||||
&& isNoTagAssigned(event)) {
|
|
||||||
|
@Override
|
||||||
|
protected void onDropEventFromWrapper(final DragAndDropEvent event) {
|
||||||
|
if (isNoTagAssigned(event)) {
|
||||||
tagAssignment(event);
|
tagAssignment(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -530,19 +513,17 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void tagAssignment(final DragAndDropEvent event) {
|
private void tagAssignment(final DragAndDropEvent event) {
|
||||||
final com.vaadin.event.dd.TargetDetails taregtDet = event.getTargetDetails();
|
final List<String> targetList = getDraggedTargetList(event).stream()
|
||||||
final Table targetTable = (Table) taregtDet.getTarget();
|
.map(targetIdName -> targetIdName.getControllerId()).collect(Collectors.toList());
|
||||||
final Set<TargetIdName> targetSelected = getTableValue(targetTable);
|
|
||||||
final Set<String> targetList = new HashSet<>();
|
|
||||||
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
|
|
||||||
final Object targetItemId = dropData.getItemIdOver();
|
|
||||||
if (!targetSelected.contains(targetItemId)) {
|
|
||||||
targetList.add(((TargetIdName) targetItemId).getControllerId());
|
|
||||||
} else {
|
|
||||||
targetList.addAll(targetSelected.stream().map(t -> t.getControllerId()).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
final String targTagName = HawkbitCommonUtil.removePrefix(event.getTransferable().getSourceComponent().getId(),
|
final String targTagName = HawkbitCommonUtil.removePrefix(event.getTransferable().getSourceComponent().getId(),
|
||||||
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
|
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
|
||||||
|
if (targetList.isEmpty()) {
|
||||||
|
final String actionDidNotWork = i18n.get("message.action.did.not.work");
|
||||||
|
notification.displayValidationError(actionDidNotWork);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(targetList, targTagName);
|
final TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(targetList, targTagName);
|
||||||
|
|
||||||
final List<String> tagsClickedList = managementUIState.getTargetTableFilters().getClickedTargetTags();
|
final List<String> tagsClickedList = managementUIState.getTargetTableFilters().getClickedTargetTags();
|
||||||
@@ -552,52 +533,9 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Check Validation on Drop.
|
protected boolean validateDragAndDropWrapper(final DragAndDropWrapper wrapperSource) {
|
||||||
*
|
final String tagName = HawkbitCommonUtil.removePrefix(wrapperSource.getId(),
|
||||||
* @param dragEvent
|
|
||||||
* as drop event
|
|
||||||
* @return Boolean as flag
|
|
||||||
*/
|
|
||||||
private Boolean doValidations(final DragAndDropEvent dragEvent) {
|
|
||||||
final Component compsource = dragEvent.getTransferable().getSourceComponent();
|
|
||||||
if (compsource instanceof Table) {
|
|
||||||
return validateTable(compsource, (TableTransferable) dragEvent.getTransferable());
|
|
||||||
} else if (compsource instanceof DragAndDropWrapper) {
|
|
||||||
validateDragAndDropWrapper(compsource);
|
|
||||||
} else {
|
|
||||||
notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean validateTable(final Component compsource, final TableTransferable transferable) {
|
|
||||||
final Table source = (Table) compsource;
|
|
||||||
if (!(source.getId().equals(SPUIComponentIdProvider.DIST_TABLE_ID)
|
|
||||||
|| source.getId().startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS))) {
|
|
||||||
notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG));
|
|
||||||
return false;
|
|
||||||
} else if (!permChecker.hasUpdateTargetPermission()) {
|
|
||||||
notification.displayValidationError(i18n.get("message.permission.insufficient"));
|
|
||||||
return false;
|
|
||||||
} else if (getDraggedDistributionSet(transferable, source).size() > 1) {
|
|
||||||
notification.displayValidationError(i18n.get("message.onlyone.distribution.assigned"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Set<DistributionSetIdName> getDraggedDistributionSet(final TableTransferable transferable,
|
|
||||||
final Table source) {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
final AbstractTable<?, DistributionSetIdName> distTable = (AbstractTable<?, DistributionSetIdName>) source;
|
|
||||||
return distTable.getDeletedEntityByTransferable(transferable);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean validateDragAndDropWrapper(final Component compsource) {
|
|
||||||
final DragAndDropWrapper wrapperSource = (DragAndDropWrapper) compsource;
|
|
||||||
final String tagName = HawkbitCommonUtil.removePrefix(compsource.getId(),
|
|
||||||
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
|
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
|
||||||
if (wrapperSource.getId().startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS)) {
|
if (wrapperSource.getId().startsWith(SPUIDefinitions.TARGET_TAG_ID_PREFIXS)) {
|
||||||
if ("NO TAG".equals(tagName)) {
|
if ("NO TAG".equals(tagName)) {
|
||||||
@@ -608,19 +546,32 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
|
|||||||
notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG));
|
notification.displayValidationError(i18n.get(ACTION_NOT_ALLOWED_MSG));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getDropTableId() {
|
||||||
|
return SPUIComponentIdProvider.DIST_TABLE_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean hasDropPermission() {
|
||||||
|
return permChecker.hasUpdateTargetPermission();
|
||||||
|
}
|
||||||
|
|
||||||
private void dsToTargetAssignment(final DragAndDropEvent event) {
|
private void dsToTargetAssignment(final DragAndDropEvent event) {
|
||||||
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
||||||
final Table source = transferable.getSourceComponent();
|
final AbstractTable<NamedEntity, DistributionSetIdName> source = (AbstractTable<NamedEntity, DistributionSetIdName>) transferable
|
||||||
|
.getSourceComponent();
|
||||||
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
|
final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails();
|
||||||
final Object targetItemId = dropData.getItemIdOver();
|
final Object targetItemId = dropData.getItemIdOver();
|
||||||
LOG.debug("Adding a log to check if targetItemId is null : {} ", targetItemId);
|
LOG.debug("Adding a log to check if targetItemId is null : {} ", targetItemId);
|
||||||
if (targetItemId != null) {
|
if (targetItemId != null) {
|
||||||
final TargetIdName targetId = (TargetIdName) targetItemId;
|
final TargetIdName targetId = (TargetIdName) targetItemId;
|
||||||
String message = null;
|
String message = null;
|
||||||
for (final DistributionSetIdName distributionNameId : getDraggedDistributionSet(transferable, source)) {
|
|
||||||
|
for (final DistributionSetIdName distributionNameId : source.getDeletedEntityByTransferable(transferable)) {
|
||||||
if (null != distributionNameId) {
|
if (null != distributionNameId) {
|
||||||
if (managementUIState.getAssignedList().keySet().contains(targetId)
|
if (managementUIState.getAssignedList().keySet().contains(targetId)
|
||||||
&& managementUIState.getAssignedList().get(targetId).equals(distributionNameId)) {
|
&& managementUIState.getAssignedList().get(targetId).equals(distributionNameId)) {
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import org.vaadin.spring.events.EventScope;
|
|||||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||||
|
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
|
import com.vaadin.event.Transferable;
|
||||||
import com.vaadin.event.dd.DragAndDropEvent;
|
import com.vaadin.event.dd.DragAndDropEvent;
|
||||||
import com.vaadin.event.dd.DropHandler;
|
import com.vaadin.event.dd.DropHandler;
|
||||||
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
|
||||||
@@ -158,7 +159,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
|
|||||||
final TableTransferable tbl = (TableTransferable) event.getTransferable();
|
final TableTransferable tbl = (TableTransferable) event.getTransferable();
|
||||||
final Table source = tbl.getSourceComponent();
|
final Table source = tbl.getSourceComponent();
|
||||||
if (source.getId().equals(SPUIComponentIdProvider.TARGET_TABLE_ID)) {
|
if (source.getId().equals(SPUIComponentIdProvider.TARGET_TABLE_ID)) {
|
||||||
processTargetDrop(event);
|
UI.getCurrent().access(() -> processTargetDrop(event));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,18 +184,28 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
|
|||||||
* @return Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
private Boolean validate(final DragAndDropEvent event) {
|
private Boolean validate(final DragAndDropEvent event) {
|
||||||
final Component compsource = event.getTransferable().getSourceComponent();
|
final Transferable transferable = event.getTransferable();
|
||||||
if (!(compsource instanceof Table)) {
|
final Component compsource = transferable.getSourceComponent();
|
||||||
|
if (!(compsource instanceof AbstractTable)) {
|
||||||
notification.displayValidationError(i18n.get(SPUILabelDefinitions.ACTION_NOT_ALLOWED));
|
notification.displayValidationError(i18n.get(SPUILabelDefinitions.ACTION_NOT_ALLOWED));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
final Table source = ((TableTransferable) event.getTransferable()).getSourceComponent();
|
|
||||||
|
|
||||||
if (!validateIfSourceisTargetTable(source) && !checkForTargetUpdatePermission()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final TableTransferable tabletransferable = (TableTransferable) transferable;
|
||||||
|
|
||||||
|
final AbstractTable<?, ?> source = (AbstractTable<?, ?>) tabletransferable.getSourceComponent();
|
||||||
|
|
||||||
|
if (!validateIfSourceisTargetTable(source) && !checkForTargetUpdatePermission()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Set<?> deletedEntityByTransferable = source.getDeletedEntityByTransferable(tabletransferable);
|
||||||
|
if (deletedEntityByTransferable.isEmpty()) {
|
||||||
|
final String actionDidNotWork = i18n.get("message.action.did.not.work", new Object[] {});
|
||||||
|
notification.displayValidationError(actionDidNotWork);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,11 +227,13 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
|
|||||||
private void processTargetDrop(final DragAndDropEvent event) {
|
private void processTargetDrop(final DragAndDropEvent event) {
|
||||||
final com.vaadin.event.dd.TargetDetails targetDetails = event.getTargetDetails();
|
final com.vaadin.event.dd.TargetDetails targetDetails = event.getTargetDetails();
|
||||||
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
final TableTransferable transferable = (TableTransferable) event.getTransferable();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final AbstractTable<?, TargetIdName> targetTable = (AbstractTable<?, TargetIdName>) transferable
|
final AbstractTable<?, TargetIdName> targetTable = (AbstractTable<?, TargetIdName>) transferable
|
||||||
.getSourceComponent();
|
.getSourceComponent();
|
||||||
|
|
||||||
final Set<TargetIdName> targetSelected = targetTable.getDeletedEntityByTransferable(transferable);
|
final Set<TargetIdName> targetSelected = targetTable.getDeletedEntityByTransferable(transferable);
|
||||||
|
|
||||||
final Set<String> targetList = targetSelected.stream().map(t -> t.getControllerId())
|
final Set<String> targetList = targetSelected.stream().map(t -> t.getControllerId())
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,25 @@ public class I18N implements Serializable {
|
|||||||
* @see #getLocale()
|
* @see #getLocale()
|
||||||
*/
|
*/
|
||||||
public String get(final String code, final Object... args) {
|
public String get(final String code, final Object... args) {
|
||||||
|
return getMessage(code, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to resolve the message.
|
||||||
|
*
|
||||||
|
* @param code
|
||||||
|
* the code to lookup up.
|
||||||
|
*
|
||||||
|
* @return the resolved message, or the message code if the lookup fails.
|
||||||
|
*
|
||||||
|
* @see MessageSource#getMessage(String, Object[], Locale)
|
||||||
|
* @see #getLocale()
|
||||||
|
*/
|
||||||
|
public String get(final String code) {
|
||||||
|
return getMessage(code, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getMessage(final String code, final Object[] args) {
|
||||||
try {
|
try {
|
||||||
return source.getMessage(code, args, getLocale());
|
return source.getMessage(code, args, getLocale());
|
||||||
} catch (final NoSuchMessageException ex) {
|
} catch (final NoSuchMessageException ex) {
|
||||||
|
|||||||
@@ -287,6 +287,7 @@ message.forcequit.action.failed = Force Quitting the action is not possible !
|
|||||||
message.forcequit.action.confirm = Attention!\nForce quit should only be used when the assignment action is not working properly.\nForce quitting an action has no effect on the connected target. It is just resetting \nthe data stored on the SP update server. \nAre you absolutely sure that you want to force quit this action?
|
message.forcequit.action.confirm = Attention!\nForce quit should only be used when the assignment action is not working properly.\nForce quitting an action has no effect on the connected target. It is just resetting \nthe data stored on the SP update server. \nAre you absolutely sure that you want to force quit this action?
|
||||||
message.distribution.no.update = distribution {0} set is already assigned to targets and cannot be changed
|
message.distribution.no.update = distribution {0} set is already assigned to targets and cannot be changed
|
||||||
message.action.not.allowed = Action not allowed
|
message.action.not.allowed = Action not allowed
|
||||||
|
message.action.did.not.work = Action did not work. Please try again.
|
||||||
message.onlyone.distribution.assigned = Only one distribution set can be assigned
|
message.onlyone.distribution.assigned = Only one distribution set can be assigned
|
||||||
message.onlyone.distribution.dropallowed = Only one distribution set can be dropped
|
message.onlyone.distribution.dropallowed = Only one distribution set can be dropped
|
||||||
message.error.missing.typename = Missing Type Name
|
message.error.missing.typename = Missing Type Name
|
||||||
|
|||||||
@@ -284,6 +284,7 @@ message.force.action.confirm = Are you sure that you want to force this action?
|
|||||||
message.force.action.success = Action forced successfully !
|
message.force.action.success = Action forced successfully !
|
||||||
message.distribution.no.update = distribution {0} set is already assigned to targets and cannot be changed
|
message.distribution.no.update = distribution {0} set is already assigned to targets and cannot be changed
|
||||||
message.action.not.allowed = Action not allowed
|
message.action.not.allowed = Action not allowed
|
||||||
|
message.action.did.not.work = Action did not work. Please try again.
|
||||||
message.onlyone.distribution.assigned = Only one distribution set can be assigned
|
message.onlyone.distribution.assigned = Only one distribution set can be assigned
|
||||||
message.onlyone.distribution.dropallowed = Only one distribution set can be dropped
|
message.onlyone.distribution.dropallowed = Only one distribution set can be dropped
|
||||||
message.error.missing.typename = Missing Type Name
|
message.error.missing.typename = Missing Type Name
|
||||||
|
|||||||
@@ -282,6 +282,7 @@ message.force.action.confirm = Are you sure that you want to force this action?
|
|||||||
message.force.action.success = Action forced successfully !
|
message.force.action.success = Action forced successfully !
|
||||||
message.distribution.no.update = distribution {0} set is already assigned to targets and cannot be changed
|
message.distribution.no.update = distribution {0} set is already assigned to targets and cannot be changed
|
||||||
message.action.not.allowed = Action not allowed
|
message.action.not.allowed = Action not allowed
|
||||||
|
message.action.did.not.work = Action did not work. Please try again.
|
||||||
message.onlyone.distribution.assigned = Only one distribution set can be assigned
|
message.onlyone.distribution.assigned = Only one distribution set can be assigned
|
||||||
message.onlyone.distribution.dropallowed = Only one distribution set can be dropped
|
message.onlyone.distribution.dropallowed = Only one distribution set can be dropped
|
||||||
message.error.missing.typename = Missing Type Name
|
message.error.missing.typename = Missing Type Name
|
||||||
|
|||||||
Reference in New Issue
Block a user