Restructure Tenant Configuration View to make it more flexible for adaptations (#1043)

* Extract view creation for Configuration Components into Beans;
Split implementations of config Binders into corresponding view classes:
- add ProxySystemConfig classes respectively for ConfigurationViews;
- create Binder and config Bean in BaseConfigurationView via Generics;
- extend ConfigurationViews from BaseConfigurationView;
- populate Binders and config Bean in ConfigurationView;
- access binder getter/setter in ConfigurationItem through corresponding ProxySystemConfig;
- autowire Collection of Config Views in TenantConfigurationDashboardView;
- create components, call save and undo for each config view in Collection

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* Do not send the target token when anonymous download is enabled

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* Update amqp tests to cover enabled anonymous download config

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* Do not change TargetToken functionality for hawkbit;
Make createDownloadAndUpdateRequest protected;
Undo some of previous test changes;

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* Add license header to ProxySystemConfigDsType

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* Call save methods for filtered ConfigurationViews only, not the autowired.

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* Document public classes

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* Adopt Review Comments:
- Rename DefaultDistributionSetTypeLayout
- Remove unnecessary qualifier TenantConfigurationProperties

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* Refactoring: implement InitializingBean instead of using PostConstruct

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* Apply to remaining classes: implement InitializingBean instead of using PostConstruct

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* Removed unnecessary method notifyConfigurationChanged();
Documented Bean creation of configuration views

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* Rename TenantConfigurationAutoConfiguration to SystemConfigViewAutoConfiguration

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* Rename init method of DefaultDistributionSetTypeView

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>
This commit is contained in:
Natalia Kislicyn
2021-02-11 17:21:55 +01:00
committed by GitHub
parent 3deb325514
commit 3422781125
25 changed files with 1162 additions and 911 deletions

View File

@@ -105,8 +105,8 @@ public class AmqpConfiguration {
} }
/** /**
* @return {@link RabbitTemplate} with automatic retry, published confirms * @return {@link RabbitTemplate} with automatic retry, published confirms and
* and {@link Jackson2JsonMessageConverter}. * {@link Jackson2JsonMessageConverter}.
*/ */
@Bean @Bean
public RabbitTemplate rabbitTemplate() { public RabbitTemplate rabbitTemplate() {
@@ -140,8 +140,8 @@ public class AmqpConfiguration {
} }
/** /**
* Create the DMF API receiver queue for authentication requests called by * Create the DMF API receiver queue for authentication requests called by 3rd
* 3rd party artifact storages for download authorization by devices. * party artifact storages for download authorization by devices.
* *
* @return the receiver queue * @return the receiver queue
*/ */
@@ -183,8 +183,7 @@ public class AmqpConfiguration {
} }
/** /**
* Create the Binding * Create the Binding {@link AmqpConfiguration#authenticationReceiverQueue()} to
* {@link AmqpConfiguration#authenticationReceiverQueue()} to
* {@link AmqpConfiguration#authenticationExchange()}. * {@link AmqpConfiguration#authenticationExchange()}.
* *
* @return the binding and create the queue and exchange * @return the binding and create the queue and exchange

View File

@@ -139,18 +139,13 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
if (!shouldBeProcessed(assignedEvent)) { if (!shouldBeProcessed(assignedEvent)) {
return; return;
} }
LOG.debug("targetAssignDistributionSet retrieved. I will forward it to DMF broker."); LOG.debug("targetAssignDistributionSet retrieved. I will forward it to DMF broker.");
distributionSetManagement.get(assignedEvent.getDistributionSetId()).ifPresent(ds -> { distributionSetManagement.get(assignedEvent.getDistributionSetId()).ifPresent(ds -> {
final Map<SoftwareModule, List<SoftwareModuleMetadata>> softwareModules = getSoftwareModulesWithMetadata( final Map<SoftwareModule, List<SoftwareModuleMetadata>> softwareModules = getSoftwareModulesWithMetadata(
ds); ds);
targetManagement.getByControllerID(assignedEvent.getActions().keySet()).forEach( targetManagement.getByControllerID(assignedEvent.getActions().keySet()).forEach(
target -> sendUpdateMessageToTarget(assignedEvent.getActions().get(target.getControllerId()), target -> sendUpdateMessageToTarget(assignedEvent.getActions().get(target.getControllerId()),
target, softwareModules)); target, softwareModules));
}); });
} }
@@ -186,7 +181,6 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
action -> action.getDistributionSet().getModules().stream() action -> action.getDistributionSet().getModules().stream()
.collect(Collectors.toMap(m -> m, softwareModuleMetadata::get))); .collect(Collectors.toMap(m -> m, softwareModuleMetadata::get)));
} }
}); });
} }
@@ -194,8 +188,8 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
protected void sendMultiActionRequestToTarget(final String tenant, final Target target, final List<Action> actions, protected void sendMultiActionRequestToTarget(final String tenant, final Target target, final List<Action> actions,
final Function<Action, Map<SoftwareModule, List<SoftwareModuleMetadata>>> getSoftwareModuleMetaData) { final Function<Action, Map<SoftwareModule, List<SoftwareModuleMetadata>>> getSoftwareModuleMetaData) {
final URI targetAdress = target.getAddress(); final URI targetAddress = target.getAddress();
if (!IpUtil.isAmqpUri(targetAdress) || CollectionUtils.isEmpty(actions)) { if (!IpUtil.isAmqpUri(targetAddress) || CollectionUtils.isEmpty(actions)) {
return; return;
} }
@@ -209,8 +203,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
final Message message = getMessageConverter().toMessage(multiActionRequest, final Message message = getMessageConverter().toMessage(multiActionRequest,
createConnectorMessagePropertiesEvent(tenant, target.getControllerId(), EventTopic.MULTI_ACTION)); createConnectorMessagePropertiesEvent(tenant, target.getControllerId(), EventTopic.MULTI_ACTION));
amqpSenderService.sendMessage(message, targetAdress); amqpSenderService.sendMessage(message, targetAddress);
} }
private DmfActionRequest createDmfActionRequest(final Target target, final Action action, private DmfActionRequest createDmfActionRequest(final Target target, final Action action,
@@ -218,8 +211,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
if (action.isCancelingOrCanceled()) { if (action.isCancelingOrCanceled()) {
return createPlainActionRequest(action); return createPlainActionRequest(action);
} }
return createDownloadAndUpdateRequest(target, action, softwareModules); return createDownloadAndUpdateRequest(target, action.getId(), softwareModules);
} }
private static DmfActionRequest createPlainActionRequest(final Action action) { private static DmfActionRequest createPlainActionRequest(final Action action) {
@@ -228,11 +220,12 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
return actionRequest; return actionRequest;
} }
private DmfDownloadAndUpdateRequest createDownloadAndUpdateRequest(final Target target, final Action action, protected DmfDownloadAndUpdateRequest createDownloadAndUpdateRequest(final Target target, final Long actionId,
final Map<SoftwareModule, List<SoftwareModuleMetadata>> softwareModules) { final Map<SoftwareModule, List<SoftwareModuleMetadata>> softwareModules) {
final DmfDownloadAndUpdateRequest request = new DmfDownloadAndUpdateRequest(); final DmfDownloadAndUpdateRequest request = new DmfDownloadAndUpdateRequest();
request.setActionId(action.getId()); request.setActionId(actionId);
request.setTargetSecurityToken(systemSecurityContext.runAsSystem(target::getSecurityToken)); request.setTargetSecurityToken(systemSecurityContext.runAsSystem(target::getSecurityToken));
if (softwareModules != null) { if (softwareModules != null) {
softwareModules.entrySet() softwareModules.entrySet()
.forEach(entry -> request.addSoftwareModule(convertToAmqpSoftwareModule(target, entry))); .forEach(entry -> request.addSoftwareModule(convertToAmqpSoftwareModule(target, entry)));
@@ -325,26 +318,15 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
final String tenant = action.getTenant(); final String tenant = action.getTenant();
final URI targetAdress = target.getAddress(); final URI targetAddress = target.getAddress();
if (!IpUtil.isAmqpUri(targetAdress)) { if (!IpUtil.isAmqpUri(targetAddress)) {
return; return;
} }
final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = new DmfDownloadAndUpdateRequest(); final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = createDownloadAndUpdateRequest(target, action.getId(), modules);
downloadAndUpdateRequest.setActionId(action.getId());
final String targetSecurityToken = systemSecurityContext.runAsSystem(target::getSecurityToken);
downloadAndUpdateRequest.setTargetSecurityToken(targetSecurityToken);
modules.entrySet().forEach(entry -> {
final DmfSoftwareModule amqpSoftwareModule = convertToAmqpSoftwareModule(target, entry);
downloadAndUpdateRequest.addSoftwareModule(amqpSoftwareModule);
});
final Message message = getMessageConverter().toMessage(downloadAndUpdateRequest, final Message message = getMessageConverter().toMessage(downloadAndUpdateRequest,
createConnectorMessagePropertiesEvent(tenant, target.getControllerId(), getEventTypeForTarget(action))); createConnectorMessagePropertiesEvent(tenant, target.getControllerId(), getEventTypeForTarget(action)));
amqpSenderService.sendMessage(message, targetAdress); amqpSenderService.sendMessage(message, targetAddress);
} }
protected void sendPingReponseToDmfReceiver(final Message ping, final String tenant, final String virtualHost) { protected void sendPingReponseToDmfReceiver(final Message ping, final String tenant, final String virtualHost) {
@@ -359,7 +341,6 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
} }
private void sendDeleteMessage(final String tenant, final String controllerId, final String targetAddress) { private void sendDeleteMessage(final String tenant, final String controllerId, final String targetAddress) {
if (!hasValidAddress(targetAddress)) { if (!hasValidAddress(targetAddress)) {
return; return;
} }

View File

@@ -19,7 +19,7 @@ import static org.mockito.Mockito.when;
import java.io.File; import java.io.File;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
@@ -35,6 +35,7 @@ import org.eclipse.hawkbit.dmf.amqp.api.MessageType;
import org.eclipse.hawkbit.dmf.json.model.DmfActionRequest; import org.eclipse.hawkbit.dmf.json.model.DmfActionRequest;
import org.eclipse.hawkbit.dmf.json.model.DmfDownloadAndUpdateRequest; import org.eclipse.hawkbit.dmf.json.model.DmfDownloadAndUpdateRequest;
import org.eclipse.hawkbit.dmf.json.model.DmfMetadata; import org.eclipse.hawkbit.dmf.json.model.DmfMetadata;
import org.eclipse.hawkbit.dmf.json.model.DmfSoftwareModule;
import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent; import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent;
import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent; import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent;
@@ -101,7 +102,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
final ArtifactUrlHandler artifactUrlHandlerMock = Mockito.mock(ArtifactUrlHandler.class); final ArtifactUrlHandler artifactUrlHandlerMock = Mockito.mock(ArtifactUrlHandler.class);
when(artifactUrlHandlerMock.getUrls(any(), any())) when(artifactUrlHandlerMock.getUrls(any(), any()))
.thenReturn(Arrays.asList(new ArtifactUrl("http", "download", "http://mockurl"))); .thenReturn(Collections.singletonList(new ArtifactUrl("http", "download", "http://mockurl")));
systemManagement = Mockito.mock(SystemManagement.class); systemManagement = Mockito.mock(SystemManagement.class);
final TenantMetaData tenantMetaData = Mockito.mock(TenantMetaData.class); final TenantMetaData tenantMetaData = Mockito.mock(TenantMetaData.class);
@@ -116,11 +117,10 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
} }
private Message getCaptureAdressEvent(final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent) { private Message getCaptureAddressEvent(final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent) {
final Target target = targetManagement final Target target = targetManagement
.getByControllerID(targetAssignDistributionSetEvent.getActions().keySet().iterator().next()).get(); .getByControllerID(targetAssignDistributionSetEvent.getActions().keySet().iterator().next()).get();
final Message sendMessage = createArgumentCapture(target.getAddress()); return createArgumentCapture(target.getAddress());
return sendMessage;
} }
private Action createAction(final DistributionSet testDs) { private Action createAction(final DistributionSet testDs) {
@@ -128,8 +128,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
} }
@Test @Test
@Description("Verifies that download and install event with 3 software moduls and no artifacts works") @Description("Verifies that download and install event with 3 software modules and no artifacts works")
public void testSendDownloadRequesWithSoftwareModulesAndNoArtifacts() { public void testSendDownloadRequestWithSoftwareModulesAndNoArtifacts() {
final DistributionSet createDistributionSet = testdataFactory final DistributionSet createDistributionSet = testdataFactory
.createDistributionSet(UUID.randomUUID().toString()); .createDistributionSet(UUID.randomUUID().toString());
testdataFactory.addSoftwareModuleMetadata(createDistributionSet); testdataFactory.addSoftwareModuleMetadata(createDistributionSet);
@@ -139,7 +139,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = new TargetAssignDistributionSetEvent( final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = new TargetAssignDistributionSetEvent(
action, serviceMatcher.getServiceId()); action, serviceMatcher.getServiceId());
amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent); amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent);
final Message sendMessage = getCaptureAdressEvent(targetAssignDistributionSetEvent); final Message sendMessage = getCaptureAddressEvent(targetAssignDistributionSetEvent);
final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage, final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage,
action.getId()); action.getId());
assertThat(createDistributionSet.getModules()).hasSameSizeAs(downloadAndUpdateRequest.getSoftwareModules()); assertThat(createDistributionSet.getModules()).hasSameSizeAs(downloadAndUpdateRequest.getSoftwareModules());
@@ -152,7 +152,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
new DmfMetadata(TestdataFactory.VISIBLE_SM_MD_KEY, TestdataFactory.VISIBLE_SM_MD_VALUE)); new DmfMetadata(TestdataFactory.VISIBLE_SM_MD_KEY, TestdataFactory.VISIBLE_SM_MD_VALUE));
for (final SoftwareModule softwareModule2 : action.getDistributionSet().getModules()) { for (final SoftwareModule softwareModule2 : action.getDistributionSet().getModules()) {
assertNotNull("Sofware module ID should be set", softwareModule.getModuleId()); assertNotNull("Software module ID should be set", softwareModule.getModuleId());
if (!softwareModule.getModuleId().equals(softwareModule2.getId())) { if (!softwareModule.getModuleId().equals(softwareModule2.getId())) {
continue; continue;
} }
@@ -186,7 +186,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = new TargetAssignDistributionSetEvent( final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = new TargetAssignDistributionSetEvent(
action, serviceMatcher.getServiceId()); action, serviceMatcher.getServiceId());
amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent); amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent);
final Message sendMessage = getCaptureAdressEvent(targetAssignDistributionSetEvent); final Message sendMessage = getCaptureAddressEvent(targetAssignDistributionSetEvent);
final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage, final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage,
action.getId()); action.getId());
@@ -194,8 +194,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
downloadAndUpdateRequest.getSoftwareModules().size()); downloadAndUpdateRequest.getSoftwareModules().size());
assertThat(downloadAndUpdateRequest.getTargetSecurityToken()).isEqualTo(TEST_TOKEN); assertThat(downloadAndUpdateRequest.getTargetSecurityToken()).isEqualTo(TEST_TOKEN);
for (final org.eclipse.hawkbit.dmf.json.model.DmfSoftwareModule softwareModule : downloadAndUpdateRequest for (final DmfSoftwareModule softwareModule : downloadAndUpdateRequest.getSoftwareModules()) {
.getSoftwareModules()) {
if (!softwareModule.getModuleId().equals(module.getId())) { if (!softwareModule.getModuleId().equals(module.getId())) {
continue; continue;
} }
@@ -259,7 +258,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
@Test @Test
@Description("Verifies that a delete message is not send if the address is not an amqp address.") @Description("Verifies that a delete message is not send if the address is not an amqp address.")
public void sendDeleteRequestWithNoAmqpAdress() { public void sendDeleteRequestWithNoAmqpAddress() {
// setup // setup
final String noAmqpUri = "http://anyhost"; final String noAmqpUri = "http://anyhost";
@@ -274,8 +273,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
} }
@Test @Test
@Description("Verfies that a delete message is not send if the address is null.") @Description("Verifies that a delete message is not send if the address is null.")
public void sendDeleteRequestWithNullAdress() { public void sendDeleteRequestWithNullAddress() {
// setup // setup
final String noAmqpUri = null; final String noAmqpUri = null;
@@ -293,7 +292,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
assertEventMessage(sendMessage); assertEventMessage(sendMessage);
final DmfActionRequest actionId = convertMessage(sendMessage, DmfActionRequest.class); final DmfActionRequest actionId = convertMessage(sendMessage, DmfActionRequest.class);
assertEquals("Action ID should be 1", actionId.getActionId(), Long.valueOf(1)); assertEquals("Action ID should be 1", actionId.getActionId(), Long.valueOf(1));
assertEquals("The topc in the message should be a CANCEL_DOWNLOAD value", EventTopic.CANCEL_DOWNLOAD, assertEquals("The topic in the message should be a CANCEL_DOWNLOAD value", EventTopic.CANCEL_DOWNLOAD,
sendMessage.getMessageProperties().getHeaders().get(MessageHeaderKey.TOPIC)); sendMessage.getMessageProperties().getHeaders().get(MessageHeaderKey.TOPIC));
} }

View File

@@ -93,9 +93,7 @@ public abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpInt
} }
private <T> T waitUntilIsPresent(final Callable<Optional<T>> callable) { private <T> T waitUntilIsPresent(final Callable<Optional<T>> callable) {
createConditionFactory().until(() -> { createConditionFactory().until(() -> securityRule.runAsPrivileged(() -> callable.call().isPresent()));
return securityRule.runAsPrivileged(() -> callable.call().isPresent());
});
try { try {
return securityRule.runAsPrivileged(() -> callable.call().get()); return securityRule.runAsPrivileged(() -> callable.call().get());
@@ -105,10 +103,8 @@ public abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpInt
} }
protected void waitUntilEventMessagesAreDispatchedToTarget(final EventTopic... eventTopics) { protected void waitUntilEventMessagesAreDispatchedToTarget(final EventTopic... eventTopics) {
createConditionFactory().untilAsserted(() -> { createConditionFactory().untilAsserted(() -> assertThat(replyToListener.getLatestEventMessageTopics())
assertThat(replyToListener.getLatestEventMessageTopics()) .containsExactlyInAnyOrderElementsOf(Arrays.asList(eventTopics)));
.containsExactlyInAnyOrderElementsOf(Arrays.asList(eventTopics));
});
replyToListener.resetLatestEventMessageTopics(); replyToListener.resetLatestEventMessageTopics();
} }
@@ -194,10 +190,10 @@ public abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpInt
protected void assertDmfDownloadAndUpdateRequest(final DmfDownloadAndUpdateRequest request, protected void assertDmfDownloadAndUpdateRequest(final DmfDownloadAndUpdateRequest request,
final Set<SoftwareModule> softwareModules, final String controllerId) { final Set<SoftwareModule> softwareModules, final String controllerId) {
Assert.assertThat(softwareModules, SoftwareModuleJsonMatcher.containsExactly(request.getSoftwareModules())); Assert.assertThat(softwareModules, SoftwareModuleJsonMatcher.containsExactly(request.getSoftwareModules()));
request.getSoftwareModules() request.getSoftwareModules().forEach(dmfModule -> assertThat(dmfModule.getMetadata()).containsExactly(
.forEach(dmfModule -> assertThat(dmfModule.getMetadata()).containsExactly( new DmfMetadata(TestdataFactory.VISIBLE_SM_MD_KEY, TestdataFactory.VISIBLE_SM_MD_VALUE)));
new DmfMetadata(TestdataFactory.VISIBLE_SM_MD_KEY, TestdataFactory.VISIBLE_SM_MD_VALUE)));
final Target updatedTarget = waitUntilIsPresent(() -> targetManagement.getByControllerID(controllerId)); final Target updatedTarget = waitUntilIsPresent(() -> targetManagement.getByControllerID(controllerId));
assertThat(updatedTarget).isNotNull();
assertThat(updatedTarget.getSecurityToken()).isEqualTo(request.getTargetSecurityToken()); assertThat(updatedTarget.getSecurityToken()).isEqualTo(request.getTargetSecurityToken());
} }
@@ -223,9 +219,8 @@ public abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpInt
} }
protected void verifyReplyToListener() { protected void verifyReplyToListener() {
createConditionFactory().untilAsserted(() -> { createConditionFactory()
Mockito.verify(replyToListener, Mockito.atLeast(1)).handleMessage(Mockito.any()); .untilAsserted(() -> Mockito.verify(replyToListener, Mockito.atLeast(1)).handleMessage(Mockito.any()));
});
} }
protected Long cancelAction(final Long actionId, final String controllerId) { protected Long cancelAction(final Long actionId, final String controllerId) {
@@ -273,9 +268,10 @@ public abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpInt
final int existingTargetsAfterCreation, final TargetUpdateStatus expectedTargetStatus, final int existingTargetsAfterCreation, final TargetUpdateStatus expectedTargetStatus,
final String createdBy) { final String createdBy) {
createAndSendThingCreated(target, TENANT_EXIST); createAndSendThingCreated(target, TENANT_EXIST);
final Target registerdTarget = waitUntilIsPresent(() -> targetManagement.getByControllerID(target)); final Target registeredTarget = waitUntilIsPresent(() -> targetManagement.getByControllerID(target));
assertAllTargetsCount(existingTargetsAfterCreation); assertAllTargetsCount(existingTargetsAfterCreation);
assertTarget(registerdTarget, expectedTargetStatus, createdBy); assertThat(registeredTarget).isNotNull();
assertTarget(registeredTarget, expectedTargetStatus, createdBy);
} }
protected void registerSameTargetAndAssertBasedOnVersion(final String controllerId, protected void registerSameTargetAndAssertBasedOnVersion(final String controllerId,
@@ -284,6 +280,7 @@ public abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpInt
createAndSendThingCreated(controllerId, TENANT_EXIST); createAndSendThingCreated(controllerId, TENANT_EXIST);
final Target registeredTarget = waitUntilIsPresent(() -> findTargetBasedOnNewVersion(controllerId, version)); final Target registeredTarget = waitUntilIsPresent(() -> findTargetBasedOnNewVersion(controllerId, version));
assertAllTargetsCount(existingTargetsAfterCreation); assertAllTargetsCount(existingTargetsAfterCreation);
assertThat(registeredTarget).isNotNull();
assertThat(registeredTarget.getUpdateStatus()).isEqualTo(expectedTargetStatus); assertThat(registeredTarget.getUpdateStatus()).isEqualTo(expectedTargetStatus);
} }

View File

@@ -179,7 +179,7 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
final Long actionId1 = assignNewDsToTarget(controllerId, 450); final Long actionId1 = assignNewDsToTarget(controllerId, 450);
final Entry<Long, EventTopic> action1Install = new SimpleEntry<>(actionId1, EventTopic.DOWNLOAD_AND_INSTALL); final Entry<Long, EventTopic> action1Install = new SimpleEntry<>(actionId1, EventTopic.DOWNLOAD_AND_INSTALL);
waitUntilEventMessagesAreDispatchedToTarget(EventTopic.MULTI_ACTION); waitUntilEventMessagesAreDispatchedToTarget(EventTopic.MULTI_ACTION);
assertLatestMultiActionMessage(controllerId, Arrays.asList(action1Install)); assertLatestMultiActionMessage(controllerId, Collections.singletonList(action1Install));
final Long actionId2 = assignNewDsToTarget(controllerId, 111); final Long actionId2 = assignNewDsToTarget(controllerId, 111);
final Entry<Long, EventTopic> action2Install = new SimpleEntry<>(actionId2, EventTopic.DOWNLOAD_AND_INSTALL); final Entry<Long, EventTopic> action2Install = new SimpleEntry<>(actionId2, EventTopic.DOWNLOAD_AND_INSTALL);
@@ -273,7 +273,7 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
updateActionViaDmfClient(controllerId, actionId1, DmfActionStatus.CANCELED); updateActionViaDmfClient(controllerId, actionId1, DmfActionStatus.CANCELED);
waitUntilEventMessagesAreDispatchedToTarget(EventTopic.MULTI_ACTION); waitUntilEventMessagesAreDispatchedToTarget(EventTopic.MULTI_ACTION);
assertLatestMultiActionMessage(controllerId, Arrays.asList(action2Install)); assertLatestMultiActionMessage(controllerId, Collections.singletonList(action2Install));
} }
@Test @Test
@@ -300,7 +300,7 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
updateActionViaDmfClient(controllerId, actionId1, DmfActionStatus.FINISHED); updateActionViaDmfClient(controllerId, actionId1, DmfActionStatus.FINISHED);
waitUntilEventMessagesAreDispatchedToTarget(EventTopic.REQUEST_ATTRIBUTES_UPDATE, EventTopic.MULTI_ACTION); waitUntilEventMessagesAreDispatchedToTarget(EventTopic.REQUEST_ATTRIBUTES_UPDATE, EventTopic.MULTI_ACTION);
assertRequestAttributesUpdateMessage(controllerId); assertRequestAttributesUpdateMessage(controllerId);
assertLatestMultiActionMessage(controllerId, Arrays.asList(action2Install)); assertLatestMultiActionMessage(controllerId, Collections.singletonList(action2Install));
} }
@Test @Test
@@ -371,7 +371,7 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
createAndStartRollout(ds, filterQuery, 122); createAndStartRollout(ds, filterQuery, 122);
waitUntilEventMessagesAreDispatchedToTarget(EventTopic.MULTI_ACTION); waitUntilEventMessagesAreDispatchedToTarget(EventTopic.MULTI_ACTION);
assertLatestMultiActionMessageContainsInstallMessages(controllerId, Arrays.asList(smIds)); assertLatestMultiActionMessageContainsInstallMessages(controllerId, Collections.singletonList(smIds));
createAndStartRollout(ds, filterQuery, 43); createAndStartRollout(ds, filterQuery, 43);
waitUntilEventMessagesAreDispatchedToTarget(EventTopic.MULTI_ACTION); waitUntilEventMessagesAreDispatchedToTarget(EventTopic.MULTI_ACTION);
@@ -418,7 +418,7 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
updateActionViaDmfClient(controllerId, installActions.get(1), DmfActionStatus.FINISHED); updateActionViaDmfClient(controllerId, installActions.get(1), DmfActionStatus.FINISHED);
waitUntilEventMessagesAreDispatchedToTarget(EventTopic.REQUEST_ATTRIBUTES_UPDATE, EventTopic.MULTI_ACTION); waitUntilEventMessagesAreDispatchedToTarget(EventTopic.REQUEST_ATTRIBUTES_UPDATE, EventTopic.MULTI_ACTION);
assertLatestMultiActionMessageContainsInstallMessages(controllerId, Arrays.asList(smIds1)); assertLatestMultiActionMessageContainsInstallMessages(controllerId, Collections.singletonList(smIds1));
} }
private Set<Long> getSoftwareModuleIds(final DistributionSet ds) { private Set<Long> getSoftwareModuleIds(final DistributionSet ds) {

View File

@@ -82,12 +82,12 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Autowired @Autowired
private AmqpProperties amqpProperties; private AmqpProperties amqpProperties;
@Autowired @Autowired
private AmqpMessageHandlerService amqpMessageHandlerService; private AmqpMessageHandlerService amqpMessageHandlerService;
@Test @Test
@Description("Tests DMF PING request and expected reponse.") @Description("Tests DMF PING request and expected response.")
public void pingDmfInterface() { public void pingDmfInterface() {
final Message pingMessage = createPingMessage(CORRELATION_ID, TENANT_EXIST); final Message pingMessage = createPingMessage(CORRELATION_ID, TENANT_EXIST);
getDmfClient().send(pingMessage); getDmfClient().send(pingMessage);
@@ -99,8 +99,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests register target") @Description("Tests register target")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 2), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 3)}) @Expect(type = TargetPollEvent.class, count = 3) })
public void registerTargets() { public void registerTargets() {
final String controllerId = TARGET_PREFIX + "registerTargets"; final String controllerId = TARGET_PREFIX + "registerTargets";
registerAndAssertTargetWithExistingTenant(controllerId, 1); registerAndAssertTargetWithExistingTenant(controllerId, 1);
@@ -113,8 +113,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
} }
@Test @Test
@Description("Tests register invalid target withy empty controller id.") @Description("Tests register invalid target with empty controller id.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void registerEmptyTarget() { public void registerEmptyTarget() {
createAndSendThingCreated("", TENANT_EXIST); createAndSendThingCreated("", TENANT_EXIST);
assertAllTargetsCount(0); assertAllTargetsCount(0);
@@ -122,8 +122,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
} }
@Test @Test
@Description("Tests register invalid target with whitspace controller id.") @Description("Tests register invalid target with whitespace controller id.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void registerWhitespaceTarget() { public void registerWhitespaceTarget() {
createAndSendThingCreated("Invalid Invalid", TENANT_EXIST); createAndSendThingCreated("Invalid Invalid", TENANT_EXIST);
assertAllTargetsCount(0); assertAllTargetsCount(0);
@@ -132,7 +132,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests register invalid target with null controller id.") @Description("Tests register invalid target with null controller id.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void registerInvalidNullTarget() { public void registerInvalidNullTarget() {
createAndSendThingCreated(null, TENANT_EXIST); createAndSendThingCreated(null, TENANT_EXIST);
assertAllTargetsCount(0); assertAllTargetsCount(0);
@@ -141,7 +141,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests register invalid target with too long controller id") @Description("Tests register invalid target with too long controller id")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void registerInvalidTargetWithTooLongControllerId() { public void registerInvalidTargetWithTooLongControllerId() {
createAndSendThingCreated(RandomStringUtils.randomAlphabetic(Target.CONTROLLER_ID_MAX_SIZE + 1), TENANT_EXIST); createAndSendThingCreated(RandomStringUtils.randomAlphabetic(Target.CONTROLLER_ID_MAX_SIZE + 1), TENANT_EXIST);
assertAllTargetsCount(0); assertAllTargetsCount(0);
@@ -150,7 +150,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests null reply to property in message header. This message should forwarded to the deadletter queue") @Description("Tests null reply to property in message header. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void missingReplyToProperty() { public void missingReplyToProperty() {
final String controllerId = TARGET_PREFIX + "missingReplyToProperty"; final String controllerId = TARGET_PREFIX + "missingReplyToProperty";
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
@@ -163,7 +163,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests missing reply to property in message header. This message should forwarded to the deadletter queue") @Description("Tests missing reply to property in message header. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void emptyReplyToProperty() { public void emptyReplyToProperty() {
final String controllerId = TARGET_PREFIX + "emptyReplyToProperty"; final String controllerId = TARGET_PREFIX + "emptyReplyToProperty";
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
@@ -176,7 +176,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests missing thing id property in message. This message should forwarded to the deadletter queue") @Description("Tests missing thing id property in message. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void missingThingIdProperty() { public void missingThingIdProperty() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.THING_ID); createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.THING_ID);
@@ -188,7 +188,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests null thing id property in message. This message should forwarded to the deadletter queue") @Description("Tests null thing id property in message. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void nullThingIdProperty() { public void nullThingIdProperty() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
getDmfClient().send(createTargetMessage); getDmfClient().send(createTargetMessage);
@@ -199,7 +199,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests missing tenant message header. This message should forwarded to the deadletter queue") @Description("Tests missing tenant message header. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void missingTenantHeader() { public void missingTenantHeader() {
final String controllerId = TARGET_PREFIX + "missingTenantHeader"; final String controllerId = TARGET_PREFIX + "missingTenantHeader";
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
@@ -212,7 +212,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests null tenant message header. This message should forwarded to the deadletter queue") @Description("Tests null tenant message header. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void nullTenantHeader() { public void nullTenantHeader() {
final String controllerId = TARGET_PREFIX + "nullTenantHeader"; final String controllerId = TARGET_PREFIX + "nullTenantHeader";
final Message createTargetMessage = createTargetMessage(controllerId, null); final Message createTargetMessage = createTargetMessage(controllerId, null);
@@ -224,7 +224,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests empty tenant message header. This message should forwarded to the deadletter queue") @Description("Tests empty tenant message header. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void emptyTenantHeader() { public void emptyTenantHeader() {
final String controllerId = TARGET_PREFIX + "emptyTenantHeader"; final String controllerId = TARGET_PREFIX + "emptyTenantHeader";
final Message createTargetMessage = createTargetMessage(controllerId, ""); final Message createTargetMessage = createTargetMessage(controllerId, "");
@@ -236,7 +236,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests tenant not exist. This message should forwarded to the deadletter queue") @Description("Tests tenant not exist. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void tenantNotExist() { public void tenantNotExist() {
final String controllerId = TARGET_PREFIX + "tenantNotExist"; final String controllerId = TARGET_PREFIX + "tenantNotExist";
final Message createTargetMessage = createTargetMessage(controllerId, "TenantNotExist"); final Message createTargetMessage = createTargetMessage(controllerId, "TenantNotExist");
@@ -248,7 +248,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests missing type message header. This message should forwarded to the deadletter queue") @Description("Tests missing type message header. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void missingTypeHeader() { public void missingTypeHeader() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TYPE); createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TYPE);
@@ -260,7 +260,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests null type message header. This message should forwarded to the deadletter queue") @Description("Tests null type message header. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void nullTypeHeader() { public void nullTypeHeader() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TYPE, null); createTargetMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TYPE, null);
@@ -272,7 +272,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests empty type message header. This message should forwarded to the deadletter queue") @Description("Tests empty type message header. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void emptyTypeHeader() { public void emptyTypeHeader() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TYPE, ""); createTargetMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TYPE, "");
@@ -284,7 +284,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests invalid type message header. This message should forwarded to the deadletter queue") @Description("Tests invalid type message header. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void invalidTypeHeader() { public void invalidTypeHeader() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TYPE, "NotExist"); createTargetMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TYPE, "NotExist");
@@ -296,7 +296,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests null topic message header. This message should forwarded to the deadletter queue") @Description("Tests null topic message header. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void nullTopicHeader() { public void nullTopicHeader() {
final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, ""); final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, "");
eventMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TOPIC, null); eventMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TOPIC, null);
@@ -307,7 +307,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests null topic message header. This message should forwarded to the deadletter queue") @Description("Tests null topic message header. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void emptyTopicHeader() { public void emptyTopicHeader() {
final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, ""); final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, "");
eventMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TOPIC, ""); eventMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TOPIC, "");
@@ -318,7 +318,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests null topic message header. This message should forwarded to the deadletter queue") @Description("Tests null topic message header. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void invalidTopicHeader() { public void invalidTopicHeader() {
final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, ""); final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, "");
eventMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TOPIC, "NotExist"); eventMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TOPIC, "NotExist");
@@ -329,7 +329,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests missing topic message header. This message should forwarded to the deadletter queue") @Description("Tests missing topic message header. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void missingTopicHeader() { public void missingTopicHeader() {
final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, ""); final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, "");
eventMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TOPIC); eventMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TOPIC);
@@ -340,7 +340,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests invalid null message content. This message should forwarded to the deadletter queue") @Description("Tests invalid null message content. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void updateActionStatusWithNullContent() { public void updateActionStatusWithNullContent() {
final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, null); final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, null);
getDmfClient().send(eventMessage); getDmfClient().send(eventMessage);
@@ -349,7 +349,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests invalid empty message content. This message should forwarded to the deadletter queue") @Description("Tests invalid empty message content. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void updateActionStatusWithEmptyContent() { public void updateActionStatusWithEmptyContent() {
final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, ""); final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, "");
getDmfClient().send(eventMessage); getDmfClient().send(eventMessage);
@@ -358,7 +358,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests invalid json message content. This message should forwarded to the deadletter queue") @Description("Tests invalid json message content. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void updateActionStatusWithInvalidJsonContent() { public void updateActionStatusWithInvalidJsonContent() {
final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS,
"Invalid Content"); "Invalid Content");
@@ -368,7 +368,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests invalid topic message header. This message should forwarded to the deadletter queue") @Description("Tests invalid topic message header. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void updateActionStatusWithInvalidActionId() { public void updateActionStatusWithInvalidActionId() {
final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.RUNNING); final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.RUNNING);
final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS,
@@ -379,98 +379,98 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests register target and send finished message") @Description("Tests register target and send finished message")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetAttributesRequestedEvent.class, count = 1), @Expect(type = TargetAttributesRequestedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1)}) @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1) })
public void finishActionStatus() { public void finishActionStatus() {
final String controllerId = TARGET_PREFIX + "finishActionStatus"; final String controllerId = TARGET_PREFIX + "finishActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.FINISHED, Status.FINISHED, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.FINISHED, Status.FINISHED, controllerId);
} }
@Test @Test
@Description("Register a target and send a update action status (running). Verfiy if the updated action status is correct.") @Description("Register a target and send a update action status (running). Verify if the updated action status is correct.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 0), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 0), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1)}) @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) })
public void runningActionStatus() { public void runningActionStatus() {
final String controllerId = TARGET_PREFIX + "runningActionStatus"; final String controllerId = TARGET_PREFIX + "runningActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RUNNING, Status.RUNNING, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RUNNING, Status.RUNNING, controllerId);
} }
@Test @Test
@Description("Register a target and send an update action status (downloaded). Verfiy if the updated action status is correct.") @Description("Register a target and send an update action status (downloaded). Verify if the updated action status is correct.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 0), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 0), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1)}) @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) })
public void downloadedActionStatus() { public void downloadedActionStatus() {
final String controllerId = TARGET_PREFIX + "downloadedActionStatus"; final String controllerId = TARGET_PREFIX + "downloadedActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOADED, Status.DOWNLOADED, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOADED, Status.DOWNLOADED, controllerId);
} }
@Test @Test
@Description("Register a target and send a update action status (download). Verfiy if the updated action status is correct.") @Description("Register a target and send a update action status (download). Verify if the updated action status is correct.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1)}) @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) })
public void downloadActionStatus() { public void downloadActionStatus() {
final String controllerId = TARGET_PREFIX + "downloadActionStatus"; final String controllerId = TARGET_PREFIX + "downloadActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOAD, Status.DOWNLOAD, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOAD, Status.DOWNLOAD, controllerId);
} }
@Test @Test
@Description("Register a target and send a update action status (error). Verfiy if the updated action status is correct.") @Description("Register a target and send a update action status (error). Verify if the updated action status is correct.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1)}) @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1) })
public void errorActionStatus() { public void errorActionStatus() {
final String controllerId = TARGET_PREFIX + "errorActionStatus"; final String controllerId = TARGET_PREFIX + "errorActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.ERROR, Status.ERROR, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.ERROR, Status.ERROR, controllerId);
} }
@Test @Test
@Description("Register a target and send a update action status (warning). Verfiy if the updated action status is correct.") @Description("Register a target and send a update action status (warning). Verify if the updated action status is correct.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1)}) @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) })
public void warningActionStatus() { public void warningActionStatus() {
final String controllerId = TARGET_PREFIX + "warningActionStatus"; final String controllerId = TARGET_PREFIX + "warningActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.WARNING, Status.WARNING, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.WARNING, Status.WARNING, controllerId);
} }
@Test @Test
@Description("Register a target and send a update action status (retrieved). Verfiy if the updated action status is correct.") @Description("Register a target and send a update action status (retrieved). Verify if the updated action status is correct.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1)}) @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) })
public void retrievedActionStatus() { public void retrievedActionStatus() {
final String controllerId = TARGET_PREFIX + "retrievedActionStatus"; final String controllerId = TARGET_PREFIX + "retrievedActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RETRIEVED, Status.RETRIEVED, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RETRIEVED, Status.RETRIEVED, controllerId);
@@ -478,13 +478,13 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Register a target and send a invalid update action status (cancel). This message should forwarded to the deadletter queue") @Description("Register a target and send a invalid update action status (cancel). This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1)}) @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) })
public void cancelNotAllowActionStatus() { public void cancelNotAllowActionStatus() {
final String controllerId = TARGET_PREFIX + "cancelNotAllowActionStatus"; final String controllerId = TARGET_PREFIX + "cancelNotAllowActionStatus";
registerTargetAndSendActionStatus(DmfActionStatus.CANCELED, controllerId); registerTargetAndSendActionStatus(DmfActionStatus.CANCELED, controllerId);
@@ -492,14 +492,14 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
} }
@Test @Test
@Description("Verfiy receiving a download and install message if a deployment is done before the target has polled the first time.") @Description("Verify receiving a download and install message if a deployment is done before the target has polled the first time.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2)}) @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2) })
public void receiveDownLoadAndInstallMessageAfterAssignment() { public void receiveDownLoadAndInstallMessageAfterAssignment() {
final String controllerId = TARGET_PREFIX + "receiveDownLoadAndInstallMessageAfterAssignment"; final String controllerId = TARGET_PREFIX + "receiveDownLoadAndInstallMessageAfterAssignment";
@@ -518,14 +518,14 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
} }
@Test @Test
@Description("Verfiy receiving a download message if a deployment is done with window configured but before maintenance window start time.") @Description("Verify receiving a download message if a deployment is done with window configured but before maintenance window start time.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2)}) @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2) })
public void receiveDownloadMessageBeforeMaintenanceWindowStartTime() { public void receiveDownloadMessageBeforeMaintenanceWindowStartTime() {
final String controllerId = TARGET_PREFIX + "receiveDownLoadMessageBeforeMaintenanceWindowStartTime"; final String controllerId = TARGET_PREFIX + "receiveDownLoadMessageBeforeMaintenanceWindowStartTime";
@@ -546,13 +546,13 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Verify receiving a download_and_install message if a deployment is done with window configured and during maintenance window start time.") @Description("Verify receiving a download_and_install message if a deployment is done with window configured and during maintenance window start time.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2)}) @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2) })
public void receiveDownloadAndInstallMessageDuringMaintenanceWindow() { public void receiveDownloadAndInstallMessageDuringMaintenanceWindow() {
final String controllerId = TARGET_PREFIX + "receiveDownLoadAndInstallMessageDuringMaintenanceWindow"; final String controllerId = TARGET_PREFIX + "receiveDownLoadAndInstallMessageDuringMaintenanceWindow";
@@ -572,15 +572,15 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
} }
@Test @Test
@Description("Verfiy receiving a cancel update message if a deployment is canceled before the target has polled the first time.") @Description("Verify receiving a cancel update message if a deployment is canceled before the target has polled the first time.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2)}) @Expect(type = TargetPollEvent.class, count = 2) })
public void receiveCancelUpdateMessageAfterAssignmentWasCanceled() { public void receiveCancelUpdateMessageAfterAssignmentWasCanceled() {
final String controllerId = TARGET_PREFIX + "receiveCancelUpdateMessageAfterAssignmentWasCanceled"; final String controllerId = TARGET_PREFIX + "receiveCancelUpdateMessageAfterAssignmentWasCanceled";
@@ -601,14 +601,14 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Register a target and send a invalid update action status (canceled). The current status (pending) is not a canceling state. This message should forwarded to the deadletter queue") @Description("Register a target and send a invalid update action status (canceled). The current status (pending) is not a canceling state. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1)}) @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) })
public void actionNotExists() { public void actionNotExists() {
final String controllerId = TARGET_PREFIX + "actionNotExists"; final String controllerId = TARGET_PREFIX + "actionNotExists";
@@ -621,13 +621,13 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Register a target and send a invalid update action status (cancel_rejected). This message should forwarded to the deadletter queue") @Description("Register a target and send a invalid update action status (cancel_rejected). This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1)}) @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) })
public void canceledRejectedNotAllowActionStatus() { public void canceledRejectedNotAllowActionStatus() {
final String controllerId = TARGET_PREFIX + "canceledRejectedNotAllowActionStatus"; final String controllerId = TARGET_PREFIX + "canceledRejectedNotAllowActionStatus";
registerTargetAndSendActionStatus(DmfActionStatus.CANCEL_REJECTED, controllerId); registerTargetAndSendActionStatus(DmfActionStatus.CANCEL_REJECTED, controllerId);
@@ -635,15 +635,15 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
} }
@Test @Test
@Description("Register a target and send a valid update action status (cancel_rejected). Verfiy if the updated action status is correct.") @Description("Register a target and send a valid update action status (cancel_rejected). Verify if the updated action status is correct.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1)}) @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) })
public void canceledRejectedActionStatus() { public void canceledRejectedActionStatus() {
final String controllerId = TARGET_PREFIX + "canceledRejectedActionStatus"; final String controllerId = TARGET_PREFIX + "canceledRejectedActionStatus";
@@ -655,8 +655,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Verify that sending an update controller attribute message to an existing target works. Verify that different update modes (merge, replace, remove) can be used.") @Description("Verify that sending an update controller attribute message to an existing target works. Verify that different update modes (merge, replace, remove) can be used.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 4), @Expect(type = TargetPollEvent.class, count = 1)}) @Expect(type = TargetUpdatedEvent.class, count = 4), @Expect(type = TargetPollEvent.class, count = 1) })
public void updateAttributesWithDifferentUpdateModes() { public void updateAttributesWithDifferentUpdateModes() {
final String controllerId = TARGET_PREFIX + "updateAttributes"; final String controllerId = TARGET_PREFIX + "updateAttributes";
@@ -758,8 +758,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Verify that sending an update controller attribute message with no thingid header to an existing target does not work.") @Description("Verify that sending an update controller attribute message with no thingid header to an existing target does not work.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 0), @Expect(type = TargetPollEvent.class, count = 1)}) @Expect(type = TargetUpdatedEvent.class, count = 0), @Expect(type = TargetPollEvent.class, count = 1) })
public void updateAttributesWithNoThingId() { public void updateAttributesWithNoThingId() {
final String controllerId = TARGET_PREFIX + "updateAttributesWithNoThingId"; final String controllerId = TARGET_PREFIX + "updateAttributesWithNoThingId";
@@ -783,8 +783,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Verify that sending an update controller attribute message with invalid body to an existing target does not work.") @Description("Verify that sending an update controller attribute message with invalid body to an existing target does not work.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 0), @Expect(type = TargetPollEvent.class, count = 1)}) @Expect(type = TargetUpdatedEvent.class, count = 0), @Expect(type = TargetPollEvent.class, count = 1) })
public void updateAttributesWithWrongBody() { public void updateAttributesWithWrongBody() {
// setup // setup
@@ -825,14 +825,14 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests the download_only assignment: tests the handling of a target reporting DOWNLOADED") @Description("Tests the download_only assignment: tests the handling of a target reporting DOWNLOADED")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetAttributesRequestedEvent.class, count = 1), @Expect(type = TargetAttributesRequestedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1)}) @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1) })
public void downloadOnlyAssignmentFinishesActionWhenTargetReportsDownloaded() throws IOException { public void downloadOnlyAssignmentFinishesActionWhenTargetReportsDownloaded() throws IOException {
// create target // create target
final String controllerId = TARGET_PREFIX + "registerTargets_1"; final String controllerId = TARGET_PREFIX + "registerTargets_1";
@@ -855,14 +855,14 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Tests the download_only assignment: tests the handling of a target reporting FINISHED") @Description("Tests the download_only assignment: tests the handling of a target reporting FINISHED")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1), @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = TargetAttributesRequestedEvent.class, count = 2), @Expect(type = TargetAttributesRequestedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 3), @Expect(type = TargetPollEvent.class, count = 1)}) @Expect(type = TargetUpdatedEvent.class, count = 3), @Expect(type = TargetPollEvent.class, count = 1) })
public void downloadOnlyAssignmentAllowsActionStatusUpdatesWhenTargetReportsFinishedAndUpdatesInstalledDS() public void downloadOnlyAssignmentAllowsActionStatusUpdatesWhenTargetReportsFinishedAndUpdatesInstalledDS()
throws IOException { throws IOException {
@@ -894,7 +894,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test @Test
@Description("Messages that result into certain exceptions being raised should not be requeued. This message should forwarded to the deadletter queue") @Description("Messages that result into certain exceptions being raised should not be requeued. This message should forwarded to the deadletter queue")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)}) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void ignoredExceptionTypesShouldNotBeRequeued() { public void ignoredExceptionTypesShouldNotBeRequeued() {
final ControllerManagement mockedControllerManagement = Mockito.mock(ControllerManagement.class); final ControllerManagement mockedControllerManagement = Mockito.mock(ControllerManagement.class);
@@ -1010,8 +1010,9 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
} }
private int getAuthenticationMessageCount() { private int getAuthenticationMessageCount() {
return Integer.parseInt(getRabbitAdmin().getQueueProperties(amqpProperties.getReceiverQueue()) return Integer
.get(RabbitAdmin.QUEUE_MESSAGE_COUNT).toString()); .parseInt(Objects.requireNonNull(getRabbitAdmin().getQueueProperties(amqpProperties.getReceiverQueue()))
.get(RabbitAdmin.QUEUE_MESSAGE_COUNT).toString());
} }
private void assertEmptyReceiverQueueCount() { private void assertEmptyReceiverQueueCount() {

View File

@@ -0,0 +1,155 @@
/**
* Copyright (c) 2020 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.data.proxies;
/**
* Proxy for the Authentication view of system config window
*/
public class ProxySystemConfigAuthentication extends ProxySystemConfigWindow {
private static final long serialVersionUID = 1L;
private Long caRootAuthorityId;
private boolean certificateAuth;
private boolean targetSecToken;
private boolean gatewaySecToken;
private boolean downloadAnonymous;
private String caRootAuthority;
private String gatewaySecurityToken;
public Long getCaRootAuthorityId() {
return caRootAuthorityId;
}
public void setCaRootAuthorityId(final Long caRootAuthorityId) {
this.caRootAuthorityId = caRootAuthorityId;
}
/**
* Flag that indicates if the certificateAuth option is enabled.
*
* @return <code>true</code> if the certificateAuth is enabled, otherwise
* <code>false</code>
*/
public boolean isCertificateAuth() {
return certificateAuth;
}
/**
* Sets the flag that indicates if the certificateAuth option is enabled.
*
* @param certificateAuth
* <code>true</code> if the certificateAuth is enabled, otherwise
* <code>false</code>
*/
public void setCertificateAuth(final boolean certificateAuth) {
this.certificateAuth = certificateAuth;
}
/**
* Flag that indicates if the targetSecToken option is enabled.
*
* @return <code>true</code> if the targetSecToken is enabled, otherwise
* <code>false</code>
*/
public boolean isTargetSecToken() {
return targetSecToken;
}
/**
* Sets the flag that indicates if the targetSecToken option is enabled.
*
* @param targetSecToken
* <code>true</code> if the targetSecToken is enabled, otherwise
* <code>false</code>
*/
public void setTargetSecToken(final boolean targetSecToken) {
this.targetSecToken = targetSecToken;
}
/**
* Flag that indicates if the gatewaySecToken option is enabled.
*
* @return <code>true</code> if the gatewaySecToken is enabled, otherwise
* <code>false</code>
*/
public boolean isGatewaySecToken() {
return gatewaySecToken;
}
/**
* Sets the flag that indicates if the gatewaySecToken option is enabled.
*
* @param gatewaySecToken
* <code>true</code> if the gatewaySecToken is enabled, otherwise
* <code>false</code>
*/
public void setGatewaySecToken(final boolean gatewaySecToken) {
this.gatewaySecToken = gatewaySecToken;
}
/**
* Flag that indicates if the downloadAnonymous option is enabled.
*
* @return <code>true</code> if the downloadAnonymous is enabled, otherwise
* <code>false</code>
*/
public boolean isDownloadAnonymous() {
return downloadAnonymous;
}
/**
* Sets the flag that indicates if the downloadAnonymous option is enabled.
*
* @param downloadAnonymous
* <code>true</code> if the downloadAnonymous is enabled, otherwise
* <code>false</code>
*/
public void setDownloadAnonymous(final boolean downloadAnonymous) {
this.downloadAnonymous = downloadAnonymous;
}
/**
* Gets the caRootAuthority
*
* @return caRootAuthority
*/
public String getCaRootAuthority() {
return caRootAuthority;
}
/**
* Sets the caRootAuthority
*
* @param caRootAuthority
* System config window caRootAuthority
*/
public void setCaRootAuthority(final String caRootAuthority) {
this.caRootAuthority = caRootAuthority;
}
/**
* Gets the gatewaySecurityToken
*
* @return gatewaySecurityToken
*/
public String getGatewaySecurityToken() {
return gatewaySecurityToken;
}
/**
* Sets the gatewaySecurityToken
*
* @param gatewaySecurityToken
* System config window gatewaySecurityToken
*/
public void setGatewaySecurityToken(final String gatewaySecurityToken) {
this.gatewaySecurityToken = gatewaySecurityToken;
}
}

View File

@@ -0,0 +1,27 @@
/**
* Copyright (c) 2020 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.data.proxies;
/**
* Proxy for the DistributionSetType view of system config window
*/
public class ProxySystemConfigDsType extends ProxySystemConfigWindow {
private static final long serialVersionUID = 1L;
private ProxyTypeInfo dsTypeInfo;
public ProxyTypeInfo getDsTypeInfo() {
return dsTypeInfo;
}
public void setDsTypeInfo(final ProxyTypeInfo dsTypeInfo) {
this.dsTypeInfo = dsTypeInfo;
}
}

View File

@@ -0,0 +1,104 @@
/**
* Copyright (c) 2020 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.data.proxies;
import java.time.Duration;
/**
* Proxy for the Authentication view of system config window
*/
public class ProxySystemConfigPolling extends ProxySystemConfigWindow {
private static final long serialVersionUID = 1L;
private boolean pollingOverdue;
private transient Duration pollingOverdueDuration;
private boolean pollingTime;
private transient Duration pollingTimeDuration;
/**
* Flag that indicates if the polling time option is enabled.
*
* @return <code>true</code> if the polling time is enabled, otherwise
* <code>false</code>
*/
public boolean isPollingTime() {
return pollingTime;
}
/**
* Sets the flag that indicates if the polling time option is enabled.
*
* @param pollingTime
* <code>true</code> if the polling time is enabled, otherwise
* <code>false</code>
*/
public void setPollingTime(final boolean pollingTime) {
this.pollingTime = pollingTime;
}
/**
* Gets the pollingTimeDuration
*
* @return pollingTimeDuration
*/
public Duration getPollingTimeDuration() {
return pollingTimeDuration;
}
/**
* Sets the pollingTimeDuration
*
* @param pollingTimeDuration
* System config window pollingTimeDuration
*/
public void setPollingTimeDuration(final Duration pollingTimeDuration) {
this.pollingTimeDuration = pollingTimeDuration;
}
/**
* Flag that indicates if the polling overdue time option is enabled.
*
* @return <code>true</code> if the polling overdue time is enabled, otherwise
* <code>false</code>
*/
public boolean isPollingOverdue() {
return pollingOverdue;
}
/**
* Sets the flag that indicates if the polling overdue time option is enabled.
*
* @param pollingOverdue
* <code>true</code> if the polling overdue time is enabled,
* otherwise <code>false</code>
*/
public void setPollingOverdue(final boolean pollingOverdue) {
this.pollingOverdue = pollingOverdue;
}
/**
* Gets the pollingOverdueDuration
*
* @return pollingOverdueDuration
*/
public Duration getPollingOverdueDuration() {
return pollingOverdueDuration;
}
/**
* Sets the pollingOverdueDuration
*
* @param pollingOverdueDuration
* System config window pollingOverdueDuration
*/
public void setPollingOverdueDuration(final Duration pollingOverdueDuration) {
this.pollingOverdueDuration = pollingOverdueDuration;
}
}

View File

@@ -0,0 +1,126 @@
/**
* Copyright (c) 2020 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.data.proxies;
import org.eclipse.hawkbit.ui.tenantconfiguration.repository.ActionAutoCleanupConfigurationItem;
/**
* Proxy for the Repository view of system config window
*/
public class ProxySystemConfigRepository extends ProxySystemConfigWindow {
private static final long serialVersionUID = 1L;
private boolean actionAutoclose;
private boolean actionAutocleanup;
private boolean multiAssignments;
private ActionAutoCleanupConfigurationItem.ActionStatusOption actionCleanupStatus;
private String actionExpiryDays;
/**
* Flag that indicates if the actionAutocleanup option is enabled.
*
* @return <code>true</code> if the actionAutocleanup is enabled, otherwise
* <code>false</code>
*/
public boolean isActionAutocleanup() {
return actionAutocleanup;
}
/**
* Sets the flag that indicates if the actionAutocleanup option is enabled.
*
* @param actionAutocleanup
* <code>true</code> if the actionAutocleanup is enabled, otherwise
* <code>false</code>
*/
public void setActionAutocleanup(final boolean actionAutocleanup) {
this.actionAutocleanup = actionAutocleanup;
}
/**
* Flag that indicates if the multiAssignments option is enabled.
*
* @return <code>true</code> if the multiAssignments is enabled, otherwise
* <code>false</code>
*/
public boolean isMultiAssignments() {
return multiAssignments;
}
/**
* Sets the flag that indicates if the multiAssignments option is enabled.
*
* @param multiAssignments
* <code>true</code> if the multiAssignments is enabled, otherwise
* <code>false</code>
*/
public void setMultiAssignments(final boolean multiAssignments) {
this.multiAssignments = multiAssignments;
}
/**
* Flag that indicates if the actionAutoclose option is enabled.
*
* @return <code>true</code> if the actionAutoclose is enabled, otherwise
* <code>false</code>
*/
public boolean isActionAutoclose() {
return actionAutoclose;
}
/**
* Sets the flag that indicates if the actionAutoclose option is enabled.
*
* @param actionAutoclose
* <code>true</code> if the actionAutoclose is enabled, otherwise
* <code>false</code>
*/
public void setActionAutoclose(final boolean actionAutoclose) {
this.actionAutoclose = actionAutoclose;
}
/**
* Gets the actionExpiryDays
*
* @return actionExpiryDays
*/
public String getActionExpiryDays() {
return actionExpiryDays;
}
/**
* Sets the actionExpiryDays
*
* @param actionExpiryDays
* System config window actionExpiryDays
*/
public void setActionExpiryDays(final String actionExpiryDays) {
this.actionExpiryDays = actionExpiryDays;
}
/**
* Gets the actionCleanupStatus
*
* @return actionCleanupStatus
*/
public ActionAutoCleanupConfigurationItem.ActionStatusOption getActionCleanupStatus() {
return actionCleanupStatus;
}
/**
* Sets the actionCleanupStatus
*
* @param actionCleanupStatus
* System config window actionCleanupStatus
*/
public void setActionCleanupStatus(
final ActionAutoCleanupConfigurationItem.ActionStatusOption actionCleanupStatus) {
this.actionCleanupStatus = actionCleanupStatus;
}
}

View File

@@ -0,0 +1,39 @@
/**
* Copyright (c) 2020 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.data.proxies;
/**
* Proxy for the Rollout view of system config window
*/
public class ProxySystemConfigRollout extends ProxySystemConfigWindow {
private static final long serialVersionUID = 1L;
private boolean rolloutApproval;
/**
* Flag that indicates if the rolloutApproval option is enabled.
*
* @return <code>true</code> if the rolloutApproval is enabled, otherwise
* <code>false</code>
*/
public boolean isRolloutApproval() {
return rolloutApproval;
}
/**
* Sets the flag that indicates if the rolloutApproval option is enabled.
*
* @param rolloutApproval
* <code>true</code> if the rolloutApproval is enabled, otherwise
* <code>false</code>
*/
public void setRolloutApproval(final boolean rolloutApproval) {
this.rolloutApproval = rolloutApproval;
}
}

View File

@@ -9,9 +9,6 @@
package org.eclipse.hawkbit.ui.common.data.proxies; package org.eclipse.hawkbit.ui.common.data.proxies;
import java.io.Serializable; import java.io.Serializable;
import java.time.Duration;
import org.eclipse.hawkbit.ui.tenantconfiguration.repository.ActionAutoCleanupConfigurationItem.ActionStatusOption;
/** /**
* Proxy for system config window. * Proxy for system config window.
@@ -23,28 +20,7 @@ public class ProxySystemConfigWindow implements Serializable {
private Long id; private Long id;
private String name; private String name;
private String description; private String description;
private ProxyTypeInfo dsTypeInfo;
private Long repositoryConfigId;
private Long rolloutConfigId;
private Long caRootAuthorityId;
private String caRootAuthority;
private String gatewaySecurityToken;
private ActionStatusOption actionCleanupStatus;
private boolean pollingOverdue;
private transient Duration pollingOverdueDuration;
private boolean pollingTime;
private transient Duration pollingTimeDuration;
private String actionExpiryDays;
private boolean rolloutApproval;
private boolean actionAutoclose;
private boolean actionAutocleanup;
private boolean multiAssignments;
private boolean certificateAuth;
private boolean targetSecToken;
private boolean gatewaySecToken;
private boolean downloadAnonymous;
private Long authConfigId;
private Long pollingConfigId;
/** /**
* Gets the id * Gets the id
@@ -84,125 +60,6 @@ public class ProxySystemConfigWindow implements Serializable {
this.name = name; this.name = name;
} }
/**
* Gets the caRootAuthority
*
* @return caRootAuthority
*/
public String getCaRootAuthority() {
return caRootAuthority;
}
/**
* Sets the caRootAuthority
*
* @param caRootAuthority
* System config window caRootAuthority
*/
public void setCaRootAuthority(final String caRootAuthority) {
this.caRootAuthority = caRootAuthority;
}
/**
* Gets the gatewaySecurityToken
*
* @return gatewaySecurityToken
*/
public String getGatewaySecurityToken() {
return gatewaySecurityToken;
}
/**
* Sets the gatewaySecurityToken
*
* @param gatewaySecurityToken
* System config window gatewaySecurityToken
*/
public void setGatewaySecurityToken(final String gatewaySecurityToken) {
this.gatewaySecurityToken = gatewaySecurityToken;
}
/**
* Flag that indicates if the polling time option is enabled.
*
* @return <code>true</code> if the polling time is enabled, otherwise
* <code>false</code>
*/
public boolean isPollingTime() {
return pollingTime;
}
/**
* Sets the flag that indicates if the polling time option is enabled.
*
* @param pollingTime
* <code>true</code> if the polling time is enabled, otherwise
* <code>false</code>
*/
public void setPollingTime(final boolean pollingTime) {
this.pollingTime = pollingTime;
}
/**
* Gets the pollingTimeDuration
*
* @return pollingTimeDuration
*/
public Duration getPollingTimeDuration() {
return pollingTimeDuration;
}
/**
* Sets the pollingTimeDuration
*
* @param pollingTimeDuration
* System config window pollingTimeDuration
*/
public void setPollingTimeDuration(final Duration pollingTimeDuration) {
this.pollingTimeDuration = pollingTimeDuration;
}
/**
* Flag that indicates if the polling overdue time option is enabled.
*
* @return <code>true</code> if the polling overdue time is enabled,
* otherwise <code>false</code>
*/
public boolean isPollingOverdue() {
return pollingOverdue;
}
/**
* Sets the flag that indicates if the polling overdue time option is
* enabled.
*
* @param pollingOverdue
* <code>true</code> if the polling overdue time is enabled,
* otherwise <code>false</code>
*/
public void setPollingOverdue(final boolean pollingOverdue) {
this.pollingOverdue = pollingOverdue;
}
/**
* Gets the pollingOverdueDuration
*
* @return pollingOverdueDuration
*/
public Duration getPollingOverdueDuration() {
return pollingOverdueDuration;
}
/**
* Sets the pollingOverdueDuration
*
* @param pollingOverdueDuration
* System config window pollingOverdueDuration
*/
public void setPollingOverdueDuration(final Duration pollingOverdueDuration) {
this.pollingOverdueDuration = pollingOverdueDuration;
}
/** /**
* Gets the description * Gets the description
* *
@@ -222,257 +79,4 @@ public class ProxySystemConfigWindow implements Serializable {
this.description = description; this.description = description;
} }
public ProxyTypeInfo getDsTypeInfo() {
return dsTypeInfo;
}
public void setDsTypeInfo(final ProxyTypeInfo dsTypeInfo) {
this.dsTypeInfo = dsTypeInfo;
}
/**
* Gets the actionExpiryDays
*
* @return actionExpiryDays
*/
public String getActionExpiryDays() {
return actionExpiryDays;
}
/**
* Sets the actionExpiryDays
*
* @param actionExpiryDays
* System config window actionExpiryDays
*/
public void setActionExpiryDays(final String actionExpiryDays) {
this.actionExpiryDays = actionExpiryDays;
}
/**
* Gets the actionCleanupStatus
*
* @return actionCleanupStatus
*/
public ActionStatusOption getActionCleanupStatus() {
return actionCleanupStatus;
}
/**
* Sets the actionCleanupStatus
*
* @param actionCleanupStatus
* System config window actionCleanupStatus
*/
public void setActionCleanupStatus(final ActionStatusOption actionCleanupStatus) {
this.actionCleanupStatus = actionCleanupStatus;
}
public Long getCaRootAuthorityId() {
return caRootAuthorityId;
}
public void setCaRootAuthorityId(final Long caRootAuthorityId) {
this.caRootAuthorityId = caRootAuthorityId;
}
/**
* Flag that indicates if the certificateAuth option is enabled.
*
* @return <code>true</code> if the certificateAuth is enabled, otherwise
* <code>false</code>
*/
public boolean isCertificateAuth() {
return certificateAuth;
}
/**
* Sets the flag that indicates if the certificateAuth option is enabled.
*
* @param certificateAuth
* <code>true</code> if the certificateAuth is enabled, otherwise
* <code>false</code>
*/
public void setCertificateAuth(final boolean certificateAuth) {
this.certificateAuth = certificateAuth;
}
/**
* Flag that indicates if the targetSecToken option is enabled.
*
* @return <code>true</code> if the targetSecToken is enabled, otherwise
* <code>false</code>
*/
public boolean isTargetSecToken() {
return targetSecToken;
}
/**
* Sets the flag that indicates if the targetSecToken option is enabled.
*
* @param targetSecToken
* <code>true</code> if the targetSecToken is enabled, otherwise
* <code>false</code>
*/
public void setTargetSecToken(final boolean targetSecToken) {
this.targetSecToken = targetSecToken;
}
/**
* Flag that indicates if the gatewaySecToken option is enabled.
*
* @return <code>true</code> if the gatewaySecToken is enabled, otherwise
* <code>false</code>
*/
public boolean isGatewaySecToken() {
return gatewaySecToken;
}
/**
* Sets the flag that indicates if the gatewaySecToken option is enabled.
*
* @param gatewaySecToken
* <code>true</code> if the gatewaySecToken is enabled, otherwise
* <code>false</code>
*/
public void setGatewaySecToken(final boolean gatewaySecToken) {
this.gatewaySecToken = gatewaySecToken;
}
/**
* Flag that indicates if the downloadAnonymous option is enabled.
*
* @return <code>true</code> if the downloadAnonymous is enabled, otherwise
* <code>false</code>
*/
public boolean isDownloadAnonymous() {
return downloadAnonymous;
}
/**
* Sets the flag that indicates if the downloadAnonymous option is enabled.
*
* @param downloadAnonymous
* <code>true</code> if the downloadAnonymous is enabled,
* otherwise <code>false</code>
*/
public void setDownloadAnonymous(final boolean downloadAnonymous) {
this.downloadAnonymous = downloadAnonymous;
}
/**
* Flag that indicates if the actionAutocleanup option is enabled.
*
* @return <code>true</code> if the actionAutocleanup is enabled, otherwise
* <code>false</code>
*/
public boolean isActionAutocleanup() {
return actionAutocleanup;
}
/**
* Sets the flag that indicates if the actionAutocleanup option is enabled.
*
* @param actionAutocleanup
* <code>true</code> if the actionAutocleanup is enabled,
* otherwise <code>false</code>
*/
public void setActionAutocleanup(final boolean actionAutocleanup) {
this.actionAutocleanup = actionAutocleanup;
}
/**
* Flag that indicates if the multiAssignments option is enabled.
*
* @return <code>true</code> if the multiAssignments is enabled, otherwise
* <code>false</code>
*/
public boolean isMultiAssignments() {
return multiAssignments;
}
/**
* Sets the flag that indicates if the multiAssignments option is enabled.
*
* @param multiAssignments
* <code>true</code> if the multiAssignments is enabled,
* otherwise <code>false</code>
*/
public void setMultiAssignments(final boolean multiAssignments) {
this.multiAssignments = multiAssignments;
}
/**
* Flag that indicates if the actionAutoclose option is enabled.
*
* @return <code>true</code> if the actionAutoclose is enabled, otherwise
* <code>false</code>
*/
public boolean isActionAutoclose() {
return actionAutoclose;
}
/**
* Sets the flag that indicates if the actionAutoclose option is enabled.
*
* @param actionAutoclose
* <code>true</code> if the actionAutoclose is enabled, otherwise
* <code>false</code>
*/
public void setActionAutoclose(final boolean actionAutoclose) {
this.actionAutoclose = actionAutoclose;
}
/**
* Flag that indicates if the rolloutApproval option is enabled.
*
* @return <code>true</code> if the rolloutApproval is enabled, otherwise
* <code>false</code>
*/
public boolean isRolloutApproval() {
return rolloutApproval;
}
/**
* Sets the flag that indicates if the rolloutApproval option is enabled.
*
* @param rolloutApproval
* <code>true</code> if the rolloutApproval is enabled, otherwise
* <code>false</code>
*/
public void setRolloutApproval(final boolean rolloutApproval) {
this.rolloutApproval = rolloutApproval;
}
public Long getRepositoryConfigId() {
return repositoryConfigId;
}
public void setRepositoryConfigId(final Long repositoryConfigId) {
this.repositoryConfigId = repositoryConfigId;
}
public Long getRolloutConfigId() {
return rolloutConfigId;
}
public void setRolloutConfigId(final Long rolloutConfigId) {
this.rolloutConfigId = rolloutConfigId;
}
public Long getAuthConfigId() {
return authConfigId;
}
public void setAuthConfigId(final Long authConfigId) {
this.authConfigId = authConfigId;
}
public Long getPollingConfigId() {
return pollingConfigId;
}
public void setPollingConfigId(final Long pollingConfigId) {
this.pollingConfigId = pollingConfigId;
}
} }

View File

@@ -8,10 +8,12 @@
*/ */
package org.eclipse.hawkbit.ui.tenantconfiguration; package org.eclipse.hawkbit.ui.tenantconfiguration;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.security.SecurityTokenGenerator; import org.eclipse.hawkbit.security.SecurityTokenGenerator;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.common.builder.FormComponentBuilder; import org.eclipse.hawkbit.ui.common.builder.FormComponentBuilder;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigWindow; import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigAuthentication;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.AnonymousDownloadAuthenticationConfigurationItem; import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.AnonymousDownloadAuthenticationConfigurationItem;
import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.CertificateAuthenticationConfigurationItem; import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.CertificateAuthenticationConfigurationItem;
@@ -20,20 +22,19 @@ import org.eclipse.hawkbit.ui.tenantconfiguration.authentication.TargetSecurityT
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import com.vaadin.data.Binder;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
import com.vaadin.ui.CheckBox; import com.vaadin.ui.CheckBox;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.GridLayout; import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label; import com.vaadin.ui.Label;
import com.vaadin.ui.Link; import com.vaadin.ui.Link;
import com.vaadin.ui.Panel; import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.VerticalLayout;
import org.springframework.util.StringUtils;
/** /**
* View to configure the authentication mode. * View to configure the authentication mode.
*/ */
public class AuthenticationConfigurationView extends CustomComponent { public class AuthenticationConfigurationView extends BaseConfigurationView<ProxySystemConfigAuthentication> {
private static final String DIST_CHECKBOX_STYLE = "dist-checkbox-style"; private static final String DIST_CHECKBOX_STYLE = "dist-checkbox-style";
@@ -41,28 +42,34 @@ public class AuthenticationConfigurationView extends CustomComponent {
private final VaadinMessageSource i18n; private final VaadinMessageSource i18n;
private final CertificateAuthenticationConfigurationItem certificateAuthenticationConfigurationItem; private final transient SecurityTokenGenerator securityTokenGenerator;
private final TargetSecurityTokenAuthenticationConfigurationItem targetSecurityTokenAuthenticationConfigurationItem; private CertificateAuthenticationConfigurationItem certificateAuthenticationConfigurationItem;
private final GatewaySecurityTokenAuthenticationConfigurationItem gatewaySecurityTokenAuthenticationConfigurationItem; private TargetSecurityTokenAuthenticationConfigurationItem targetSecurityTokenAuthenticationConfigurationItem;
private final AnonymousDownloadAuthenticationConfigurationItem anonymousDownloadAuthenticationConfigurationItem; private GatewaySecurityTokenAuthenticationConfigurationItem gatewaySecurityTokenAuthenticationConfigurationItem;
private AnonymousDownloadAuthenticationConfigurationItem anonymousDownloadAuthenticationConfigurationItem;
private final UiProperties uiProperties; private final UiProperties uiProperties;
private final Binder<ProxySystemConfigWindow> binder; public AuthenticationConfigurationView(final VaadinMessageSource i18n, final UiProperties uiProperties,
final TenantConfigurationManagement tenantConfigurationManagement,
AuthenticationConfigurationView(final VaadinMessageSource i18n, final UiProperties uiProperties, final SecurityTokenGenerator securityTokenGenerator) {
final SecurityTokenGenerator securityTokenGenerator, final Binder<ProxySystemConfigWindow> binder) { super(tenantConfigurationManagement);
this.i18n = i18n; this.i18n = i18n;
this.uiProperties = uiProperties;
this.securityTokenGenerator = securityTokenGenerator;
}
@Override
public void afterPropertiesSet() {
super.afterPropertiesSet();
this.targetSecurityTokenAuthenticationConfigurationItem = new TargetSecurityTokenAuthenticationConfigurationItem( this.targetSecurityTokenAuthenticationConfigurationItem = new TargetSecurityTokenAuthenticationConfigurationItem(
i18n); i18n);
this.certificateAuthenticationConfigurationItem = new CertificateAuthenticationConfigurationItem(i18n, binder); this.certificateAuthenticationConfigurationItem = new CertificateAuthenticationConfigurationItem(i18n,
getBinder());
this.gatewaySecurityTokenAuthenticationConfigurationItem = new GatewaySecurityTokenAuthenticationConfigurationItem( this.gatewaySecurityTokenAuthenticationConfigurationItem = new GatewaySecurityTokenAuthenticationConfigurationItem(
i18n, securityTokenGenerator, binder); i18n, securityTokenGenerator, getBinder());
this.anonymousDownloadAuthenticationConfigurationItem = new AnonymousDownloadAuthenticationConfigurationItem( this.anonymousDownloadAuthenticationConfigurationItem = new AnonymousDownloadAuthenticationConfigurationItem(
i18n); i18n);
this.uiProperties = uiProperties;
this.binder = binder;
init(); init();
} }
@@ -88,9 +95,21 @@ public class AuthenticationConfigurationView extends CustomComponent {
gridLayout.setSizeFull(); gridLayout.setSizeFull();
gridLayout.setColumnExpandRatio(1, 1.0F); gridLayout.setColumnExpandRatio(1, 1.0F);
initCertificateAuthConfiguration(gridLayout, 0);
initTargetTokenConfiguration(gridLayout, 1);
initGatewayTokenConfiguration(gridLayout, 2);
initAnonymousDownloadConfiguration(gridLayout, 3);
vLayout.addComponent(gridLayout);
rootPanel.setContent(vLayout);
setCompositionRoot(rootPanel);
}
protected void initCertificateAuthConfiguration(GridLayout gridLayout, int row) {
final CheckBox certificateAuthCheckbox = FormComponentBuilder.getCheckBox( final CheckBox certificateAuthCheckbox = FormComponentBuilder.getCheckBox(
UIComponentIdProvider.CERT_AUTH_ALLOWED_CHECKBOX, binder, ProxySystemConfigWindow::isCertificateAuth, UIComponentIdProvider.CERT_AUTH_ALLOWED_CHECKBOX, getBinder(),
ProxySystemConfigWindow::setCertificateAuth); ProxySystemConfigAuthentication::isCertificateAuth,
ProxySystemConfigAuthentication::setCertificateAuth);
certificateAuthCheckbox.setStyleName(DIST_CHECKBOX_STYLE); certificateAuthCheckbox.setStyleName(DIST_CHECKBOX_STYLE);
certificateAuthCheckbox.addValueChangeListener(valueChangeEvent -> { certificateAuthCheckbox.addValueChangeListener(valueChangeEvent -> {
if (valueChangeEvent.getValue()) { if (valueChangeEvent.getValue()) {
@@ -99,19 +118,24 @@ public class AuthenticationConfigurationView extends CustomComponent {
certificateAuthenticationConfigurationItem.hideDetails(); certificateAuthenticationConfigurationItem.hideDetails();
} }
}); });
gridLayout.addComponent(certificateAuthCheckbox, 0, 0); gridLayout.addComponent(certificateAuthCheckbox, 0, row);
gridLayout.addComponent(certificateAuthenticationConfigurationItem, 1, 0); gridLayout.addComponent(certificateAuthenticationConfigurationItem, 1, row);
}
protected void initTargetTokenConfiguration(GridLayout gridLayout, int row) {
final CheckBox targetSecTokenCheckBox = FormComponentBuilder.getCheckBox( final CheckBox targetSecTokenCheckBox = FormComponentBuilder.getCheckBox(
UIComponentIdProvider.TARGET_SEC_TOKEN_ALLOWED_CHECKBOX, binder, UIComponentIdProvider.TARGET_SEC_TOKEN_ALLOWED_CHECKBOX, getBinder(),
ProxySystemConfigWindow::isTargetSecToken, ProxySystemConfigWindow::setTargetSecToken); ProxySystemConfigAuthentication::isTargetSecToken, ProxySystemConfigAuthentication::setTargetSecToken);
targetSecTokenCheckBox.setStyleName(DIST_CHECKBOX_STYLE); targetSecTokenCheckBox.setStyleName(DIST_CHECKBOX_STYLE);
gridLayout.addComponent(targetSecTokenCheckBox, 0, 1); gridLayout.addComponent(targetSecTokenCheckBox, 0, row);
gridLayout.addComponent(targetSecurityTokenAuthenticationConfigurationItem, 1, 1); gridLayout.addComponent(targetSecurityTokenAuthenticationConfigurationItem, 1, row);
}
protected void initGatewayTokenConfiguration(GridLayout gridLayout, int row) {
final CheckBox gatewaySecTokenCheckBox = FormComponentBuilder.getCheckBox( final CheckBox gatewaySecTokenCheckBox = FormComponentBuilder.getCheckBox(
UIComponentIdProvider.GATEWAY_SEC_TOKEN_ALLOWED_CHECKBOX, binder, UIComponentIdProvider.GATEWAY_SEC_TOKEN_ALLOWED_CHECKBOX, getBinder(),
ProxySystemConfigWindow::isGatewaySecToken, ProxySystemConfigWindow::setGatewaySecToken); ProxySystemConfigAuthentication::isGatewaySecToken,
ProxySystemConfigAuthentication::setGatewaySecToken);
gatewaySecTokenCheckBox.setStyleName(DIST_CHECKBOX_STYLE); gatewaySecTokenCheckBox.setStyleName(DIST_CHECKBOX_STYLE);
gatewaySecTokenCheckBox.addValueChangeListener(valueChangeEvent -> { gatewaySecTokenCheckBox.addValueChangeListener(valueChangeEvent -> {
if (valueChangeEvent.getValue()) { if (valueChangeEvent.getValue()) {
@@ -120,23 +144,73 @@ public class AuthenticationConfigurationView extends CustomComponent {
gatewaySecurityTokenAuthenticationConfigurationItem.hideDetails(); gatewaySecurityTokenAuthenticationConfigurationItem.hideDetails();
} }
}); });
gridLayout.addComponent(gatewaySecTokenCheckBox, 0, 2); gridLayout.addComponent(gatewaySecTokenCheckBox, 0, row);
gridLayout.addComponent(gatewaySecurityTokenAuthenticationConfigurationItem, 1, 2); gridLayout.addComponent(gatewaySecurityTokenAuthenticationConfigurationItem, 1, row);
}
protected void initAnonymousDownloadConfiguration(GridLayout gridLayout, int row) {
final CheckBox downloadAnonymousCheckBox = FormComponentBuilder.getCheckBox( final CheckBox downloadAnonymousCheckBox = FormComponentBuilder.getCheckBox(
UIComponentIdProvider.DOWNLOAD_ANONYMOUS_CHECKBOX, binder, ProxySystemConfigWindow::isDownloadAnonymous, UIComponentIdProvider.DOWNLOAD_ANONYMOUS_CHECKBOX, getBinder(),
ProxySystemConfigWindow::setDownloadAnonymous); ProxySystemConfigAuthentication::isDownloadAnonymous,
ProxySystemConfigAuthentication::setDownloadAnonymous);
downloadAnonymousCheckBox.setStyleName(DIST_CHECKBOX_STYLE); downloadAnonymousCheckBox.setStyleName(DIST_CHECKBOX_STYLE);
gridLayout.addComponent(downloadAnonymousCheckBox, 0, 3); gridLayout.addComponent(downloadAnonymousCheckBox, 0, row);
gridLayout.addComponent(anonymousDownloadAuthenticationConfigurationItem, 1, 3); gridLayout.addComponent(anonymousDownloadAuthenticationConfigurationItem, 1, row);
final Link linkToSecurityHelp = SPUIComponentProvider.getHelpLink(i18n, final Link linkToSecurityHelp = SPUIComponentProvider.getHelpLink(i18n,
uiProperties.getLinks().getDocumentation().getSecurity()); uiProperties.getLinks().getDocumentation().getSecurity());
gridLayout.addComponent(linkToSecurityHelp, 2, 3); gridLayout.addComponent(linkToSecurityHelp, 2, row);
gridLayout.setComponentAlignment(linkToSecurityHelp, Alignment.BOTTOM_RIGHT); gridLayout.setComponentAlignment(linkToSecurityHelp, Alignment.BOTTOM_RIGHT);
vLayout.addComponent(gridLayout);
rootPanel.setContent(vLayout);
setCompositionRoot(rootPanel);
} }
@Override
public void save() {
writeConfigOption(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED,
getBinderBean().isTargetSecToken());
writeConfigOption(TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED,
getBinderBean().isGatewaySecToken());
writeConfigOption(TenantConfigurationKey.ANONYMOUS_DOWNLOAD_MODE_ENABLED,
getBinderBean().isDownloadAnonymous());
if (getBinderBean().isGatewaySecToken()) {
writeConfigOption(TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY,
getBinderBean().getGatewaySecurityToken());
}
writeConfigOption(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED,
getBinderBean().isCertificateAuth());
if (getBinderBean().isCertificateAuth()) {
final String value = getBinderBean().getCaRootAuthority() != null ? getBinderBean().getCaRootAuthority()
: "";
writeConfigOption(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, value);
}
}
@Override
protected ProxySystemConfigAuthentication populateSystemConfig() {
final ProxySystemConfigAuthentication configBean = new ProxySystemConfigAuthentication();
configBean.setCertificateAuth(readConfigOption(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED));
configBean.setTargetSecToken(
readConfigOption(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED));
configBean.setGatewaySecToken(
readConfigOption(TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED));
configBean.setDownloadAnonymous(readConfigOption(TenantConfigurationKey.ANONYMOUS_DOWNLOAD_MODE_ENABLED));
String securityToken = getTenantConfigurationManagement().getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, String.class).getValue();
if (StringUtils.isEmpty(securityToken)) {
securityToken = securityTokenGenerator.generateToken();
}
configBean.setGatewaySecurityToken(securityToken);
configBean.setCaRootAuthority(getCaRootAuthorityValue());
return configBean;
}
private String getCaRootAuthorityValue() {
return getTenantConfigurationManagement()
.getConfigurationValue(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class)
.getValue();
}
} }

View File

@@ -8,26 +8,43 @@
*/ */
package org.eclipse.hawkbit.ui.tenantconfiguration; package org.eclipse.hawkbit.ui.tenantconfiguration;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.vaadin.data.Binder;
import com.vaadin.ui.CustomComponent; import com.vaadin.ui.CustomComponent;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigWindow;
import org.springframework.beans.factory.InitializingBean;
/** /**
* Base class for all configuration views. This class implements the logic for * Base class for all configuration views. This class implements the logic for
* the handling of the configurations in a consistent way. * the handling of the configurations in a consistent way.
* *
*/ */
public abstract class BaseConfigurationView extends CustomComponent implements ConfigurationGroup { public abstract class BaseConfigurationView<B extends ProxySystemConfigWindow> extends CustomComponent
implements ConfigurationGroup, InitializingBean {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final List<ConfigurationItemChangeListener> configurationChangeListeners = new ArrayList<>(); private final List<ConfigurationItemChangeListener> configurationChangeListeners = new ArrayList<>();
private final transient TenantConfigurationManagement tenantConfigurationManagement;
private final Binder<B> binder;
protected void notifyConfigurationChanged() { public BaseConfigurationView(final TenantConfigurationManagement tenantConfigurationManagement) {
configurationChangeListeners.forEach(ConfigurationItemChangeListener::configurationHasChanged); this.tenantConfigurationManagement = tenantConfigurationManagement;
binder = new Binder<>();
} }
@Override
public void afterPropertiesSet() {
binder.setBean(populateSystemConfig());
}
protected abstract B populateSystemConfig();
@Override @Override
public void addChangeListener(final ConfigurationItemChangeListener listener) { public void addChangeListener(final ConfigurationItemChangeListener listener) {
configurationChangeListeners.add(listener); configurationChangeListeners.add(listener);
@@ -39,4 +56,33 @@ public abstract class BaseConfigurationView extends CustomComponent implements C
// different valid options. // different valid options.
return true; return true;
} }
@Override
public void undo() {
binder.setBean(populateSystemConfig());
}
protected boolean readConfigOption(final String configurationKey) {
final TenantConfigurationValue<Boolean> enabled = tenantConfigurationManagement
.getConfigurationValue(configurationKey, Boolean.class);
return enabled.getValue() && !enabled.isGlobal();
}
protected <T extends Serializable> void writeConfigOption(final String key, final T value) {
tenantConfigurationManagement.addOrUpdateConfiguration(key, value);
}
protected TenantConfigurationManagement getTenantConfigurationManagement() {
return tenantConfigurationManagement;
}
protected Binder<B> getBinder() {
return binder;
}
protected B getBinderBean() {
return getBinder().getBean();
}
} }

View File

@@ -10,22 +10,21 @@ package org.eclipse.hawkbit.ui.tenantconfiguration;
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement; import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.data.mappers.TypeToTypeInfoMapper; import org.eclipse.hawkbit.ui.common.data.mappers.TypeToTypeInfoMapper;
import org.eclipse.hawkbit.ui.common.data.providers.DistributionSetTypeDataProvider; import org.eclipse.hawkbit.ui.common.data.providers.DistributionSetTypeDataProvider;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigWindow; import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigDsType;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTypeInfo; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTypeInfo;
import org.eclipse.hawkbit.ui.tenantconfiguration.window.SystemConfigWindowDependencies; import org.eclipse.hawkbit.ui.tenantconfiguration.window.SystemConfigWindowDependencies;
import org.eclipse.hawkbit.ui.tenantconfiguration.window.SystemConfigWindowLayoutComponentBuilder; import org.eclipse.hawkbit.ui.tenantconfiguration.window.SystemConfigWindowLayoutComponentBuilder;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import com.vaadin.data.Binder;
import com.vaadin.data.HasValue; import com.vaadin.data.HasValue;
import com.vaadin.icons.VaadinIcons; import com.vaadin.icons.VaadinIcons;
import com.vaadin.ui.ComboBox; import com.vaadin.ui.ComboBox;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label; import com.vaadin.ui.Label;
import com.vaadin.ui.Panel; import com.vaadin.ui.Panel;
@@ -34,7 +33,7 @@ import com.vaadin.ui.VerticalLayout;
/** /**
* Default DistributionSet Panel. * Default DistributionSet Panel.
*/ */
public class DefaultDistributionSetTypeLayout extends CustomComponent { public class DefaultDistributionSetTypeView extends BaseConfigurationView<ProxySystemConfigDsType> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -43,26 +42,31 @@ public class DefaultDistributionSetTypeLayout extends CustomComponent {
private final SpPermissionChecker permissionChecker; private final SpPermissionChecker permissionChecker;
private Long currentDefaultDistSetTypeId; private Long currentDefaultDistSetTypeId;
private ComboBox<ProxyTypeInfo> dsSetTypeComboBox; private ComboBox<ProxyTypeInfo> dsSetTypeComboBox;
private final Binder<ProxySystemConfigWindow> binder; private final transient SystemManagement systemManagement;
private final transient SystemConfigWindowLayoutComponentBuilder builder; private final transient SystemConfigWindowLayoutComponentBuilder builder;
private Label changeIcon; private Label changeIcon;
DefaultDistributionSetTypeLayout(final SystemManagement systemManagement, final VaadinMessageSource i18n, DefaultDistributionSetTypeView(final VaadinMessageSource i18n,
final SpPermissionChecker permChecker, final DistributionSetTypeManagement dsTypeManagement, final TenantConfigurationManagement tenantConfigurationManagement, final SystemManagement systemManagement,
final Binder<ProxySystemConfigWindow> binder) { final SpPermissionChecker permissionChecker, final DistributionSetTypeManagement dsTypeManagement) {
super(tenantConfigurationManagement);
this.i18n = i18n; this.i18n = i18n;
this.permissionChecker = permChecker; this.permissionChecker = permissionChecker;
this.binder = binder; this.systemManagement = systemManagement;
final DistributionSetTypeDataProvider<ProxyTypeInfo> dataProvider = new DistributionSetTypeDataProvider<>( final DistributionSetTypeDataProvider<ProxyTypeInfo> dataProvider = new DistributionSetTypeDataProvider<>(
dsTypeManagement, new TypeToTypeInfoMapper<DistributionSetType>()); dsTypeManagement, new TypeToTypeInfoMapper<>());
final SystemConfigWindowDependencies dependencies = new SystemConfigWindowDependencies(systemManagement, i18n, final SystemConfigWindowDependencies dependencies = new SystemConfigWindowDependencies(systemManagement, i18n,
permChecker, dsTypeManagement, dataProvider); permissionChecker, dsTypeManagement, dataProvider);
this.builder = new SystemConfigWindowLayoutComponentBuilder(dependencies); this.builder = new SystemConfigWindowLayoutComponentBuilder(dependencies);
initDsSetTypeComponent();
} }
private void initDsSetTypeComponent() { @Override
public void afterPropertiesSet() {
super.afterPropertiesSet();
init();
}
private void init() {
if (!permissionChecker.hasReadRepositoryPermission()) { if (!permissionChecker.hasReadRepositoryPermission()) {
return; return;
} }
@@ -101,21 +105,34 @@ public class DefaultDistributionSetTypeLayout extends CustomComponent {
} }
private void initDsSetTypeComboBox() { private void initDsSetTypeComboBox() {
dsSetTypeComboBox = builder.createDistributionSetTypeCombo(binder); dsSetTypeComboBox = builder.createDistributionSetTypeCombo(getBinder());
dsSetTypeComboBox.addValueChangeListener(this::selectDistributionSetTypeValue); dsSetTypeComboBox.addValueChangeListener(this::selectDistributionSetTypeValue);
} }
private Long getCurrentDistributionSetTypeId() { private Long getCurrentDistributionSetTypeId() {
return binder.getBean().getDsTypeInfo().getId(); return getBinderBean().getDsTypeInfo().getId();
} }
/** /**
* Method that is called when combobox event is performed. * Method that is called when combobox event is performed.
* *
* @param event * @param event
* ValueChangeEvent
*/ */
private void selectDistributionSetTypeValue(final HasValue.ValueChangeEvent<ProxyTypeInfo> event) { private void selectDistributionSetTypeValue(final HasValue.ValueChangeEvent<ProxyTypeInfo> event) {
changeIcon.setVisible(!event.getValue().getId().equals(currentDefaultDistSetTypeId)); changeIcon.setVisible(!event.getValue().getId().equals(currentDefaultDistSetTypeId));
} }
@Override
protected ProxySystemConfigDsType populateSystemConfig() {
final ProxySystemConfigDsType configBean = new ProxySystemConfigDsType();
configBean.setDsTypeInfo(new TypeToTypeInfoMapper<DistributionSetType>()
.map(systemManagement.getTenantMetadata().getDefaultDsType()));
return configBean;
}
@Override
public void save() {
systemManagement.updateTenantMetadata(getBinderBean().getDsTypeInfo().getId());
}
} }

View File

@@ -18,15 +18,14 @@ import java.util.Date;
import org.eclipse.hawkbit.ControllerPollProperties; import org.eclipse.hawkbit.ControllerPollProperties;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.tenancy.configuration.DurationHelper; import org.eclipse.hawkbit.tenancy.configuration.DurationHelper;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigWindow; import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigPolling;
import org.eclipse.hawkbit.ui.tenantconfiguration.polling.DurationConfigField; import org.eclipse.hawkbit.ui.tenantconfiguration.polling.DurationConfigField;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import com.vaadin.data.Binder;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Label; import com.vaadin.ui.Label;
import com.vaadin.ui.Panel; import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.VerticalLayout;
@@ -34,25 +33,37 @@ import com.vaadin.ui.VerticalLayout;
/** /**
* View to configure the polling interval and the overdue time. * View to configure the polling interval and the overdue time.
*/ */
public class PollingConfigurationView extends CustomComponent { public class PollingConfigurationView extends BaseConfigurationView<ProxySystemConfigPolling> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final ZoneId ZONEID_UTC = ZoneId.of("+0"); private static final ZoneId ZONEID_UTC = ZoneId.of("+0");
private final DurationConfigField fieldPollTime; private final VaadinMessageSource i18n;
private final DurationConfigField fieldPollingOverdueTime; private final ControllerPollProperties controllerPollProperties;
PollingConfigurationView(final VaadinMessageSource i18n, final ControllerPollProperties controllerPollProperties, PollingConfigurationView(final VaadinMessageSource i18n, final ControllerPollProperties controllerPollProperties,
final TenantConfigurationManagement tenantConfigurationManagement, final TenantConfigurationManagement tenantConfigurationManagement) {
final Binder<ProxySystemConfigWindow> binder) { super(tenantConfigurationManagement);
this.controllerPollProperties = controllerPollProperties;
this.i18n = i18n;
}
@Override
public void afterPropertiesSet() {
super.afterPropertiesSet();
init();
}
private void init() {
final Duration minDuration = DurationHelper final Duration minDuration = DurationHelper
.formattedStringToDuration(controllerPollProperties.getMinPollingTime()); .formattedStringToDuration(controllerPollProperties.getMinPollingTime());
final Duration maxDuration = DurationHelper final Duration maxDuration = DurationHelper
.formattedStringToDuration(controllerPollProperties.getMaxPollingTime()); .formattedStringToDuration(controllerPollProperties.getMaxPollingTime());
final Duration globalPollTime = DurationHelper.formattedStringToDuration(tenantConfigurationManagement final Duration globalPollTime = DurationHelper.formattedStringToDuration(getTenantConfigurationManagement()
.getGlobalConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, String.class)); .getGlobalConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, String.class));
final Duration globalOverdueTime = DurationHelper.formattedStringToDuration(tenantConfigurationManagement final Duration globalOverdueTime = DurationHelper.formattedStringToDuration(getTenantConfigurationManagement()
.getGlobalConfigurationValue(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL, String.class)); .getGlobalConfigurationValue(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL, String.class));
final Panel rootPanel = new Panel(); final Panel rootPanel = new Panel();
@@ -67,33 +78,36 @@ public class PollingConfigurationView extends CustomComponent {
headerDisSetType.addStyleName("config-panel-header"); headerDisSetType.addStyleName("config-panel-header");
vLayout.addComponent(headerDisSetType); vLayout.addComponent(headerDisSetType);
fieldPollTime = DurationConfigField.builder(UIComponentIdProvider.SYSTEM_CONFIGURATION_POLLING, i18n) DurationConfigField fieldPollTime = DurationConfigField
.builder(UIComponentIdProvider.SYSTEM_CONFIGURATION_POLLING, i18n)
.caption(i18n.getMessage("configuration.polling.time")) .caption(i18n.getMessage("configuration.polling.time"))
.checkBoxTooltip(i18n.getMessage("configuration.polling.custom.value")).range(minDuration, maxDuration) .checkBoxTooltip(i18n.getMessage("configuration.polling.custom.value")).range(minDuration, maxDuration)
.globalDuration(globalPollTime).build(); .globalDuration(globalPollTime).build();
binder.forField(fieldPollTime.getCheckBox()).bind(ProxySystemConfigWindow::isPollingTime, getBinder().forField(fieldPollTime.getCheckBox()).bind(ProxySystemConfigPolling::isPollingTime,
ProxySystemConfigWindow::setPollingTime); ProxySystemConfigPolling::setPollingTime);
binder.forField(fieldPollTime.getDurationField()) getBinder().forField(fieldPollTime.getDurationField())
.withConverter(PollingConfigurationView::localDateTimeToDuration, .withConverter(PollingConfigurationView::localDateTimeToDuration,
PollingConfigurationView::durationToLocalDateTime) PollingConfigurationView::durationToLocalDateTime)
.bind(ProxySystemConfigWindow::getPollingTimeDuration, ProxySystemConfigWindow::setPollingTimeDuration); .bind(ProxySystemConfigPolling::getPollingTimeDuration,
ProxySystemConfigPolling::setPollingTimeDuration);
vLayout.addComponent(fieldPollTime); vLayout.addComponent(fieldPollTime);
fieldPollingOverdueTime = DurationConfigField.builder(UIComponentIdProvider.SYSTEM_CONFIGURATION_OVERDUE, i18n) DurationConfigField fieldPollingOverdueTime = DurationConfigField
.builder(UIComponentIdProvider.SYSTEM_CONFIGURATION_OVERDUE, i18n)
.caption(i18n.getMessage("configuration.polling.overduetime")) .caption(i18n.getMessage("configuration.polling.overduetime"))
.checkBoxTooltip(i18n.getMessage("configuration.polling.custom.value")).range(minDuration, maxDuration) .checkBoxTooltip(i18n.getMessage("configuration.polling.custom.value")).range(minDuration, maxDuration)
.globalDuration(globalOverdueTime).build(); .globalDuration(globalOverdueTime).build();
binder.forField(fieldPollingOverdueTime.getCheckBox()).bind(ProxySystemConfigWindow::isPollingOverdue, getBinder().forField(fieldPollingOverdueTime.getCheckBox()).bind(ProxySystemConfigPolling::isPollingOverdue,
ProxySystemConfigWindow::setPollingOverdue); ProxySystemConfigPolling::setPollingOverdue);
binder.forField(fieldPollingOverdueTime.getDurationField()) getBinder().forField(fieldPollingOverdueTime.getDurationField())
.withConverter(PollingConfigurationView::localDateTimeToDuration, .withConverter(PollingConfigurationView::localDateTimeToDuration,
PollingConfigurationView::durationToLocalDateTime) PollingConfigurationView::durationToLocalDateTime)
.bind(ProxySystemConfigWindow::getPollingOverdueDuration, .bind(ProxySystemConfigPolling::getPollingOverdueDuration,
ProxySystemConfigWindow::setPollingOverdueDuration); ProxySystemConfigPolling::setPollingOverdueDuration);
vLayout.addComponent(fieldPollingOverdueTime); vLayout.addComponent(fieldPollingOverdueTime);
@@ -112,4 +126,39 @@ public class PollingConfigurationView extends CustomComponent {
final Date date = Date.from(lt.atDate(LocalDate.now(ZONEID_UTC)).atZone(ZONEID_UTC).toInstant()); final Date date = Date.from(lt.atDate(LocalDate.now(ZONEID_UTC)).atZone(ZONEID_UTC).toInstant());
return LocalDateTime.ofInstant(date.toInstant(), ZONEID_UTC); return LocalDateTime.ofInstant(date.toInstant(), ZONEID_UTC);
} }
@Override
protected ProxySystemConfigPolling populateSystemConfig() {
ProxySystemConfigPolling configBean = new ProxySystemConfigPolling();
final TenantConfigurationValue<String> pollingTimeConfValue = getTenantConfigurationManagement()
.getConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, String.class);
configBean.setPollingTime(!pollingTimeConfValue.isGlobal());
configBean.setPollingTimeDuration(DurationHelper.formattedStringToDuration(pollingTimeConfValue.getValue()));
final TenantConfigurationValue<String> overdueTimeConfValue = getTenantConfigurationManagement()
.getConfigurationValue(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL, String.class);
configBean.setPollingOverdue(!overdueTimeConfValue.isGlobal());
configBean.setPollingOverdueDuration(DurationHelper.formattedStringToDuration(overdueTimeConfValue.getValue()));
return configBean;
}
@Override
public void save() {
if (getBinderBean().isPollingTime()) {
getTenantConfigurationManagement().addOrUpdateConfiguration(TenantConfigurationKey.POLLING_TIME_INTERVAL,
DurationHelper.durationToFormattedString(getBinderBean().getPollingTimeDuration()));
} else {
getTenantConfigurationManagement().deleteConfiguration(TenantConfigurationKey.POLLING_TIME_INTERVAL);
}
if (getBinderBean().isPollingOverdue()) {
getTenantConfigurationManagement().addOrUpdateConfiguration(
TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL,
DurationHelper.durationToFormattedString(getBinderBean().getPollingOverdueDuration()));
} else {
getTenantConfigurationManagement()
.deleteConfiguration(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL);
}
}
} }

View File

@@ -8,9 +8,13 @@
*/ */
package org.eclipse.hawkbit.ui.tenantconfiguration; package org.eclipse.hawkbit.ui.tenantconfiguration;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.common.builder.FormComponentBuilder; import org.eclipse.hawkbit.ui.common.builder.FormComponentBuilder;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigWindow; import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigRepository;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.tenantconfiguration.repository.ActionAutoCleanupConfigurationItem; import org.eclipse.hawkbit.ui.tenantconfiguration.repository.ActionAutoCleanupConfigurationItem;
import org.eclipse.hawkbit.ui.tenantconfiguration.repository.ActionAutoCloseConfigurationItem; import org.eclipse.hawkbit.ui.tenantconfiguration.repository.ActionAutoCloseConfigurationItem;
@@ -18,48 +22,57 @@ import org.eclipse.hawkbit.ui.tenantconfiguration.repository.MultiAssignmentsCon
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import com.vaadin.data.Binder;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
import com.vaadin.ui.CheckBox; import com.vaadin.ui.CheckBox;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.GridLayout; import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label; import com.vaadin.ui.Label;
import com.vaadin.ui.Link; import com.vaadin.ui.Link;
import com.vaadin.ui.Panel; import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.VerticalLayout;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey.ACTION_CLEANUP_ACTION_EXPIRY;
import static org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey.ACTION_CLEANUP_ACTION_STATUS;
/** /**
* View to configure the authentication mode. * View to configure the authentication mode.
*/ */
public class RepositoryConfigurationView extends CustomComponent { public class RepositoryConfigurationView extends BaseConfigurationView<ProxySystemConfigRepository> {
private static final String DIST_CHECKBOX_STYLE = "dist-checkbox-style"; private static final String DIST_CHECKBOX_STYLE = "dist-checkbox-style";
private static final Set<Action.Status> EMPTY_STATUS_SET = EnumSet.noneOf(Action.Status.class);
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final VaadinMessageSource i18n; private final VaadinMessageSource i18n;
private final UiProperties uiProperties; private final UiProperties uiProperties;
private final ActionAutoCloseConfigurationItem actionAutocloseConfigurationItem; private ActionAutoCloseConfigurationItem actionAutocloseConfigurationItem;
private ActionAutoCleanupConfigurationItem actionAutocleanupConfigurationItem;
private final ActionAutoCleanupConfigurationItem actionAutocleanupConfigurationItem; private MultiAssignmentsConfigurationItem multiAssignmentsConfigurationItem;
private final MultiAssignmentsConfigurationItem multiAssignmentsConfigurationItem;
private CheckBox multiAssignmentsCheckBox; private CheckBox multiAssignmentsCheckBox;
private final Binder<ProxySystemConfigWindow> binder;
RepositoryConfigurationView(final VaadinMessageSource i18n, final UiProperties uiProperties, RepositoryConfigurationView(final VaadinMessageSource i18n, final UiProperties uiProperties,
final Binder<ProxySystemConfigWindow> binder) { final TenantConfigurationManagement tenantConfigurationManagement) {
super(tenantConfigurationManagement);
this.i18n = i18n; this.i18n = i18n;
this.uiProperties = uiProperties; this.uiProperties = uiProperties;
this.actionAutocloseConfigurationItem = new ActionAutoCloseConfigurationItem(i18n); }
this.actionAutocleanupConfigurationItem = new ActionAutoCleanupConfigurationItem(binder, i18n);
this.multiAssignmentsConfigurationItem = new MultiAssignmentsConfigurationItem(i18n, binder);
this.binder = binder;
@Override
public void afterPropertiesSet() {
super.afterPropertiesSet();
this.actionAutocloseConfigurationItem = new ActionAutoCloseConfigurationItem(i18n);
this.actionAutocleanupConfigurationItem = new ActionAutoCleanupConfigurationItem(getBinder(), i18n);
this.multiAssignmentsConfigurationItem = new MultiAssignmentsConfigurationItem(i18n, getBinder());
init(); init();
} }
@@ -86,20 +99,20 @@ public class RepositoryConfigurationView extends CustomComponent {
gridLayout.setSizeFull(); gridLayout.setSizeFull();
final CheckBox actionAutoCloseCheckBox = FormComponentBuilder.getCheckBox( final CheckBox actionAutoCloseCheckBox = FormComponentBuilder.getCheckBox(
UIComponentIdProvider.REPOSITORY_ACTIONS_AUTOCLOSE_CHECKBOX, binder, UIComponentIdProvider.REPOSITORY_ACTIONS_AUTOCLOSE_CHECKBOX, getBinder(),
ProxySystemConfigWindow::isActionAutoclose, ProxySystemConfigWindow::setActionAutoclose); ProxySystemConfigRepository::isActionAutoclose, ProxySystemConfigRepository::setActionAutoclose);
actionAutoCloseCheckBox.setStyleName(DIST_CHECKBOX_STYLE); actionAutoCloseCheckBox.setStyleName(DIST_CHECKBOX_STYLE);
actionAutoCloseCheckBox.setEnabled(!binder.getBean().isMultiAssignments()); actionAutoCloseCheckBox.setEnabled(!getBinderBean().isMultiAssignments());
actionAutocloseConfigurationItem.setEnabled(!binder.getBean().isMultiAssignments()); actionAutocloseConfigurationItem.setEnabled(!getBinderBean().isMultiAssignments());
gridLayout.addComponent(actionAutoCloseCheckBox, 0, 0); gridLayout.addComponent(actionAutoCloseCheckBox, 0, 0);
gridLayout.addComponent(actionAutocloseConfigurationItem, 1, 0); gridLayout.addComponent(actionAutocloseConfigurationItem, 1, 0);
multiAssignmentsCheckBox = FormComponentBuilder.getCheckBox( multiAssignmentsCheckBox = FormComponentBuilder.getCheckBox(
UIComponentIdProvider.REPOSITORY_MULTI_ASSIGNMENTS_CHECKBOX, binder, UIComponentIdProvider.REPOSITORY_MULTI_ASSIGNMENTS_CHECKBOX, getBinder(),
ProxySystemConfigWindow::isMultiAssignments, ProxySystemConfigWindow::setMultiAssignments); ProxySystemConfigRepository::isMultiAssignments, ProxySystemConfigRepository::setMultiAssignments);
multiAssignmentsCheckBox.setStyleName(DIST_CHECKBOX_STYLE); multiAssignmentsCheckBox.setStyleName(DIST_CHECKBOX_STYLE);
multiAssignmentsCheckBox.setEnabled(!binder.getBean().isMultiAssignments()); multiAssignmentsCheckBox.setEnabled(!getBinderBean().isMultiAssignments());
multiAssignmentsConfigurationItem.setEnabled(!binder.getBean().isMultiAssignments()); multiAssignmentsConfigurationItem.setEnabled(!getBinderBean().isMultiAssignments());
multiAssignmentsCheckBox.addValueChangeListener(event -> { multiAssignmentsCheckBox.addValueChangeListener(event -> {
actionAutoCloseCheckBox.setEnabled(!event.getValue()); actionAutoCloseCheckBox.setEnabled(!event.getValue());
actionAutocloseConfigurationItem.setEnabled(!event.getValue()); actionAutocloseConfigurationItem.setEnabled(!event.getValue());
@@ -113,8 +126,8 @@ public class RepositoryConfigurationView extends CustomComponent {
gridLayout.addComponent(multiAssignmentsConfigurationItem, 1, 1); gridLayout.addComponent(multiAssignmentsConfigurationItem, 1, 1);
final CheckBox actionAutoCleanupCheckBox = FormComponentBuilder.getCheckBox( final CheckBox actionAutoCleanupCheckBox = FormComponentBuilder.getCheckBox(
UIComponentIdProvider.REPOSITORY_ACTIONS_AUTOCLEANUP_CHECKBOX, binder, UIComponentIdProvider.REPOSITORY_ACTIONS_AUTOCLEANUP_CHECKBOX, getBinder(),
ProxySystemConfigWindow::isActionAutocleanup, ProxySystemConfigWindow::setActionAutocleanup); ProxySystemConfigRepository::isActionAutocleanup, ProxySystemConfigRepository::setActionAutocleanup);
actionAutoCleanupCheckBox.setStyleName(DIST_CHECKBOX_STYLE); actionAutoCleanupCheckBox.setStyleName(DIST_CHECKBOX_STYLE);
actionAutoCleanupCheckBox.addValueChangeListener(event -> { actionAutoCleanupCheckBox.addValueChangeListener(event -> {
if (event.getValue()) { if (event.getValue()) {
@@ -144,4 +157,63 @@ public class RepositoryConfigurationView extends CustomComponent {
multiAssignmentsConfigurationItem.setEnabled(false); multiAssignmentsConfigurationItem.setEnabled(false);
} }
@Override
public void save() {
writeConfigOption(TenantConfigurationKey.ACTION_CLEANUP_ENABLED, getBinderBean().isActionAutocleanup());
if (getBinderBean().isActionAutocleanup()) {
writeConfigOption(ACTION_CLEANUP_ACTION_STATUS, getBinderBean().getActionCleanupStatus().getStatus()
.stream().map(Action.Status::name).collect(Collectors.joining(",")));
writeConfigOption(TenantConfigurationKey.ACTION_CLEANUP_ACTION_EXPIRY,
TimeUnit.DAYS.toMillis(Long.parseLong(getBinderBean().getActionExpiryDays())));
}
if (!readConfigOption(TenantConfigurationKey.MULTI_ASSIGNMENTS_ENABLED)) {
writeConfigOption(TenantConfigurationKey.REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED,
getBinderBean().isActionAutoclose());
}
if (getBinderBean().isMultiAssignments()
&& !readConfigOption(TenantConfigurationKey.MULTI_ASSIGNMENTS_ENABLED)) {
writeConfigOption(TenantConfigurationKey.MULTI_ASSIGNMENTS_ENABLED, getBinderBean().isMultiAssignments());
this.disableMultipleAssignmentOption();
}
}
@Override
protected ProxySystemConfigRepository populateSystemConfig() {
final ProxySystemConfigRepository configBean = new ProxySystemConfigRepository();
configBean.setActionAutoclose(readConfigOption(TenantConfigurationKey.REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED));
configBean.setMultiAssignments(readConfigOption(TenantConfigurationKey.MULTI_ASSIGNMENTS_ENABLED));
configBean.setActionAutocleanup(readConfigOption(TenantConfigurationKey.ACTION_CLEANUP_ENABLED));
configBean.setActionCleanupStatus(getActionStatusOption());
configBean.setActionExpiryDays(String.valueOf(getActionExpiry()));
return configBean;
}
private long getActionExpiry() {
return TimeUnit.MILLISECONDS.toDays(readConfigValue(ACTION_CLEANUP_ACTION_EXPIRY, Long.class).getValue());
}
private ActionAutoCleanupConfigurationItem.ActionStatusOption getActionStatusOption() {
final Set<Action.Status> actionStatus = getActionStatus();
final Collection<ActionAutoCleanupConfigurationItem.ActionStatusOption> actionStatusOptions = ActionAutoCleanupConfigurationItem
.getActionStatusOptions();
return actionStatusOptions.stream().filter(option -> actionStatus.equals(option.getStatus())).findFirst()
.orElse(actionStatusOptions.iterator().next());
}
private <T extends Serializable> TenantConfigurationValue<T> readConfigValue(final String key,
final Class<T> valueType) {
return getTenantConfigurationManagement().getConfigurationValue(key, valueType);
}
private Set<Action.Status> getActionStatus() {
final TenantConfigurationValue<String> statusStr = readConfigValue(ACTION_CLEANUP_ACTION_STATUS, String.class);
if (statusStr != null) {
return Arrays.stream(statusStr.getValue().split("[;,]")).map(Action.Status::valueOf)
.collect(Collectors.toSet());
}
return EMPTY_STATUS_SET;
}
} }

View File

@@ -8,18 +8,18 @@
*/ */
package org.eclipse.hawkbit.ui.tenantconfiguration; package org.eclipse.hawkbit.ui.tenantconfiguration;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.common.builder.FormComponentBuilder; import org.eclipse.hawkbit.ui.common.builder.FormComponentBuilder;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigWindow; import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigRollout;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.tenantconfiguration.rollout.ApprovalConfigurationItem; import org.eclipse.hawkbit.ui.tenantconfiguration.rollout.ApprovalConfigurationItem;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import com.vaadin.data.Binder;
import com.vaadin.ui.Alignment; import com.vaadin.ui.Alignment;
import com.vaadin.ui.CheckBox; import com.vaadin.ui.CheckBox;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.GridLayout; import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label; import com.vaadin.ui.Label;
import com.vaadin.ui.Link; import com.vaadin.ui.Link;
@@ -30,23 +30,26 @@ import com.vaadin.ui.VerticalLayout;
* Provides configuration of the RolloutManagement including enabling/disabling * Provides configuration of the RolloutManagement including enabling/disabling
* of the approval workflow. * of the approval workflow.
*/ */
public class RolloutConfigurationView extends CustomComponent { public class RolloutConfigurationView extends BaseConfigurationView<ProxySystemConfigRollout> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final VaadinMessageSource i18n; private final VaadinMessageSource i18n;
private final UiProperties uiProperties; private final UiProperties uiProperties;
private final Binder<ProxySystemConfigWindow> binder;
private final ApprovalConfigurationItem approvalConfigurationItem; private final ApprovalConfigurationItem approvalConfigurationItem;
RolloutConfigurationView(final VaadinMessageSource i18n, final UiProperties uiProperties, RolloutConfigurationView(final VaadinMessageSource i18n, final UiProperties uiProperties,
final Binder<ProxySystemConfigWindow> binder) { final TenantConfigurationManagement tenantConfigurationManagement) {
super(tenantConfigurationManagement);
this.i18n = i18n; this.i18n = i18n;
this.approvalConfigurationItem = new ApprovalConfigurationItem(i18n);
this.uiProperties = uiProperties; this.uiProperties = uiProperties;
this.binder = binder; this.approvalConfigurationItem = new ApprovalConfigurationItem(i18n);
this.init(); }
@Override
public void afterPropertiesSet() {
super.afterPropertiesSet();
init();
} }
private void init() { private void init() {
@@ -69,8 +72,8 @@ public class RolloutConfigurationView extends CustomComponent {
gridLayout.setSizeFull(); gridLayout.setSizeFull();
final CheckBox approvalCheckbox = FormComponentBuilder.getCheckBox( final CheckBox approvalCheckbox = FormComponentBuilder.getCheckBox(
UIComponentIdProvider.ROLLOUT_APPROVAL_ENABLED_CHECKBOX, binder, UIComponentIdProvider.ROLLOUT_APPROVAL_ENABLED_CHECKBOX, getBinder(),
ProxySystemConfigWindow::isRolloutApproval, ProxySystemConfigWindow::setRolloutApproval); ProxySystemConfigRollout::isRolloutApproval, ProxySystemConfigRollout::setRolloutApproval);
gridLayout.addComponent(approvalCheckbox, 0, 0); gridLayout.addComponent(approvalCheckbox, 0, 0);
gridLayout.addComponent(approvalConfigurationItem, 1, 0); gridLayout.addComponent(approvalConfigurationItem, 1, 0);
@@ -83,4 +86,17 @@ public class RolloutConfigurationView extends CustomComponent {
rootPanel.setContent(vLayout); rootPanel.setContent(vLayout);
setCompositionRoot(rootPanel); setCompositionRoot(rootPanel);
} }
@Override
protected ProxySystemConfigRollout populateSystemConfig() {
ProxySystemConfigRollout configBean = new ProxySystemConfigRollout();
configBean.setRolloutApproval(readConfigOption(TenantConfigurationKey.ROLLOUT_APPROVAL_ENABLED));
return configBean;
}
@Override
public void save() {
writeConfigOption(TenantConfigurationKey.ROLLOUT_APPROVAL_ENABLED, getBinderBean().isRolloutApproval());
}
} }

View File

@@ -0,0 +1,150 @@
/**
* Copyright (c) 2020 Bosch.IO GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.tenantconfiguration;
import com.vaadin.spring.annotation.ViewScope;
import org.eclipse.hawkbit.ControllerPollProperties;
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
import org.eclipse.hawkbit.ui.MgmtUiConfiguration;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
/**
* Enables UI components for the Tenant Configuration view
*/
@Configuration
@ConditionalOnClass(MgmtUiConfiguration.class)
public class SystemConfigViewAutoConfiguration {
/**
* Bean of configuration view to set the default distributionSet type.
*
* @param i18n
* VaadinMessageSource
* @param tenantConfigurationManagement
* TenantConfigurationManagement
* @param systemManagement
* SystemManagement
* @param permissionCheckerChecker
* SpPermissionChecker
* @param distributionSetTypeManagement
* DistributionSetTypeManagement
* @return DefaultDistributionSetTypeView to be shown in the Tenant
* Configuration Page
*/
@Bean
@ViewScope
@Order(value = 1)
DefaultDistributionSetTypeView defaultDistributionSetTypeLayout(final VaadinMessageSource i18n,
final TenantConfigurationManagement tenantConfigurationManagement, final SystemManagement systemManagement,
final SpPermissionChecker permissionCheckerChecker,
final DistributionSetTypeManagement distributionSetTypeManagement) {
return new DefaultDistributionSetTypeView(i18n, tenantConfigurationManagement, systemManagement,
permissionCheckerChecker, distributionSetTypeManagement);
}
/**
* Default Bean of configuration view to set the Repository specific
* configurations
*
* @param i18n
* VaadinMessageSource
* @param uiProperties
* UiProperties
* @param tenantConfigurationManagement
* TenantConfigurationManagement
* @return RepositoryConfigurationView to be shown in the Tenant Configuration
* Page
*/
@Bean
@ConditionalOnMissingBean
@ViewScope
@Order(value = 2)
RepositoryConfigurationView repositoryConfigurationView(final VaadinMessageSource i18n,
final UiProperties uiProperties, final TenantConfigurationManagement tenantConfigurationManagement) {
return new RepositoryConfigurationView(i18n, uiProperties, tenantConfigurationManagement);
}
/**
* Default Bean of configuration view to set the Rollout specific configurations
*
* @param i18n
* VaadinMessageSource
* @param uiProperties
* UiProperties
* @param tenantConfigurationManagement
* TenantConfigurationManagement
* @return RolloutConfigurationView to be shown in the Tenant Configuration Page
*/
@Bean
@ConditionalOnMissingBean
@ViewScope
@Order(value = 3)
RolloutConfigurationView rolloutConfigurationView(final VaadinMessageSource i18n, final UiProperties uiProperties,
final TenantConfigurationManagement tenantConfigurationManagement) {
return new RolloutConfigurationView(i18n, uiProperties, tenantConfigurationManagement);
}
/**
* Default Bean of configuration view to set the Authentication specific
* configurations
*
* @param i18n
* VaadinMessageSource
* @param uiProperties
* UiProperties
* @param tenantConfigurationManagement
* TenantConfigurationManagement
* @param securityTokenGenerator
* SecurityTokenGenerator
* @return AuthenticationConfigurationView to be shown in the Tenant
* Configuration Page
*/
@Bean
@ConditionalOnMissingBean
@ViewScope
@Order(value = 4)
AuthenticationConfigurationView authConfigurationView(final VaadinMessageSource i18n,
final UiProperties uiProperties, final TenantConfigurationManagement tenantConfigurationManagement,
final SecurityTokenGenerator securityTokenGenerator) {
return new AuthenticationConfigurationView(i18n, uiProperties, tenantConfigurationManagement,
securityTokenGenerator);
}
/**
* Default Bean of configuration view to set the Polling specific configurations
*
* @param i18n
* VaadinMessageSource
* @param uiProperties
* UiProperties
* @param tenantConfigurationManagement
* TenantConfigurationManagement
* @return PollingConfigurationView to be shown in the Tenant Configuration Page
*/
@Bean
@ConditionalOnMissingBean
@ViewScope
@Order(value = 5)
PollingConfigurationView pollingConfigurationView(final VaadinMessageSource i18n,
final ControllerPollProperties uiProperties,
final TenantConfigurationManagement tenantConfigurationManagement) {
return new PollingConfigurationView(i18n, uiProperties, tenantConfigurationManagement);
}
}

View File

@@ -8,46 +8,21 @@
*/ */
package org.eclipse.hawkbit.ui.tenantconfiguration; package org.eclipse.hawkbit.ui.tenantconfiguration;
import static org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey.ACTION_CLEANUP_ACTION_EXPIRY;
import static org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey.ACTION_CLEANUP_ACTION_STATUS;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.ControllerPollProperties;
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
import org.eclipse.hawkbit.tenancy.configuration.DurationHelper;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.AbstractHawkbitUI; import org.eclipse.hawkbit.ui.AbstractHawkbitUI;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.UiProperties; import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.common.data.mappers.TypeToTypeInfoMapper;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigWindow; import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigWindow;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleNoBorder; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleNoBorder;
import org.eclipse.hawkbit.ui.tenantconfiguration.ConfigurationItem.ConfigurationItemChangeListener; import org.eclipse.hawkbit.ui.tenantconfiguration.ConfigurationItem.ConfigurationItemChangeListener;
import org.eclipse.hawkbit.ui.tenantconfiguration.repository.ActionAutoCleanupConfigurationItem;
import org.eclipse.hawkbit.ui.tenantconfiguration.repository.ActionAutoCleanupConfigurationItem.ActionStatusOption;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.vaadin.data.Binder; import com.vaadin.data.Binder;
@@ -74,58 +49,26 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
public static final String VIEW_NAME = "spSystemConfig"; public static final String VIEW_NAME = "spSystemConfig";
private static final Set<Status> EMPTY_STATUS_SET = EnumSet.noneOf(Status.class);
private final VaadinMessageSource i18n; private final VaadinMessageSource i18n;
private final UiProperties uiProperties; private final UiProperties uiProperties;
private final UINotification uINotification; private final UINotification uINotification;
private final transient SystemManagement systemManagement; private final List<BaseConfigurationView<? extends ProxySystemConfigWindow>> autowiredConfigurationViews;
private final transient TenantConfigurationManagement tenantConfigurationManagement; private List<BaseConfigurationView<? extends ProxySystemConfigWindow>> filteredConfigurationViews;
private final transient SecurityTokenGenerator securityTokenGenerator;
private final DefaultDistributionSetTypeLayout defaultDistributionSetTypeLayout;
private final RepositoryConfigurationView repositoryConfigurationView;
private final AuthenticationConfigurationView authenticationConfigurationView;
private final PollingConfigurationView pollingConfigurationView;
private final RolloutConfigurationView rolloutConfigurationView;
@Autowired(required = false)
private Collection<ConfigurationGroup> customConfigurationViews;
private final List<ConfigurationGroup> configurationViews = Lists.newArrayList();
private final List<CustomComponent> customComponents = Lists.newArrayListWithExpectedSize(5);
private Button saveConfigurationBtn; private Button saveConfigurationBtn;
private Button undoConfigurationBtn; private Button undoConfigurationBtn;
private final Binder<ProxySystemConfigWindow> binder; private final List<Binder<? extends ProxySystemConfigWindow>> binders = Lists.newArrayList();
@Autowired @Autowired
TenantConfigurationDashboardView(final VaadinMessageSource i18n, final UiProperties uiProperties, TenantConfigurationDashboardView(final VaadinMessageSource i18n, final UiProperties uiProperties,
final UINotification uINotification, final SystemManagement systemManagement, final UINotification uINotification,
final DistributionSetTypeManagement distributionSetTypeManagement, final List<BaseConfigurationView<? extends ProxySystemConfigWindow>> configurationViews) {
final TenantConfigurationManagement tenantConfigurationManagement,
final SecurityTokenGenerator securityTokenGenerator,
final ControllerPollProperties controllerPollProperties, final SpPermissionChecker permChecker) {
this.i18n = i18n; this.i18n = i18n;
this.uiProperties = uiProperties; this.uiProperties = uiProperties;
this.uINotification = uINotification; this.uINotification = uINotification;
this.systemManagement = systemManagement; this.autowiredConfigurationViews = configurationViews;
this.tenantConfigurationManagement = tenantConfigurationManagement;
this.securityTokenGenerator = securityTokenGenerator;
this.binder = new Binder<>();
binder.setBean(populateAndGetSystemConfig());
this.defaultDistributionSetTypeLayout = new DefaultDistributionSetTypeLayout(systemManagement, i18n,
permChecker, distributionSetTypeManagement, binder);
this.authenticationConfigurationView = new AuthenticationConfigurationView(i18n, uiProperties,
securityTokenGenerator, binder);
this.pollingConfigurationView = new PollingConfigurationView(i18n, controllerPollProperties,
tenantConfigurationManagement, binder);
this.repositoryConfigurationView = new RepositoryConfigurationView(i18n, uiProperties, binder);
this.rolloutConfigurationView = new RolloutConfigurationView(i18n, uiProperties, binder);
} }
/** /**
@@ -133,17 +76,11 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
*/ */
@PostConstruct @PostConstruct
public void init() { public void init() {
if (defaultDistributionSetTypeLayout.getComponentCount() > 0) { // filter the autowired views
customComponents.add(defaultDistributionSetTypeLayout); filteredConfigurationViews = autowiredConfigurationViews.stream().filter(c -> c.getComponentCount() > 0)
} .filter(ConfigurationGroup::show).collect(Collectors.toList());
customComponents.add(repositoryConfigurationView); // get and add the binders
customComponents.add(rolloutConfigurationView); filteredConfigurationViews.forEach(entry -> binders.add(entry.getBinder()));
customComponents.add(authenticationConfigurationView);
customComponents.add(pollingConfigurationView);
if (customConfigurationViews != null) {
configurationViews.addAll(
customConfigurationViews.stream().filter(ConfigurationGroup::show).collect(Collectors.toList()));
}
final Panel rootPanel = new Panel(); final Panel rootPanel = new Panel();
rootPanel.setStyleName("tenantconfig-root"); rootPanel.setStyleName("tenantconfig-root");
@@ -152,8 +89,7 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
rootLayout.setSizeFull(); rootLayout.setSizeFull();
rootLayout.setMargin(true); rootLayout.setMargin(true);
rootLayout.setSpacing(true); rootLayout.setSpacing(true);
customComponents.forEach(rootLayout::addComponent); filteredConfigurationViews.forEach(rootLayout::addComponent);
configurationViews.forEach(rootLayout::addComponent);
final HorizontalLayout buttonContent = saveConfigurationButtonsLayout(); final HorizontalLayout buttonContent = saveConfigurationButtonsLayout();
rootLayout.addComponent(buttonContent); rootLayout.addComponent(buttonContent);
@@ -161,83 +97,11 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
rootPanel.setContent(rootLayout); rootPanel.setContent(rootLayout);
setCompositionRoot(rootPanel); setCompositionRoot(rootPanel);
configurationViews.forEach(view -> view.addChangeListener(this)); filteredConfigurationViews.forEach(view -> view.addChangeListener(this));
binder.addStatusChangeListener(event -> { binders.forEach(binder -> binder.addStatusChangeListener(event -> {
saveConfigurationBtn.setEnabled(event.getBinder().isValid()); saveConfigurationBtn.setEnabled(event.getBinder().isValid());
undoConfigurationBtn.setEnabled(event.getBinder().isValid()); undoConfigurationBtn.setEnabled(event.getBinder().isValid());
}); }));
}
private ProxySystemConfigWindow populateAndGetSystemConfig() {
final ProxySystemConfigWindow configBean = new ProxySystemConfigWindow();
configBean.setDsTypeInfo(new TypeToTypeInfoMapper<DistributionSetType>()
.map(systemManagement.getTenantMetadata().getDefaultDsType()));
configBean.setRolloutApproval(readConfigOption(TenantConfigurationKey.ROLLOUT_APPROVAL_ENABLED));
configBean.setActionAutoclose(readConfigOption(TenantConfigurationKey.REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED));
configBean.setMultiAssignments(readConfigOption(TenantConfigurationKey.MULTI_ASSIGNMENTS_ENABLED));
configBean.setActionAutocleanup(readConfigOption(TenantConfigurationKey.ACTION_CLEANUP_ENABLED));
configBean.setCertificateAuth(readConfigOption(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED));
configBean.setTargetSecToken(
readConfigOption(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED));
configBean.setGatewaySecToken(
readConfigOption(TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED));
configBean.setDownloadAnonymous(readConfigOption(TenantConfigurationKey.ANONYMOUS_DOWNLOAD_MODE_ENABLED));
String securityToken = tenantConfigurationManagement.getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, String.class).getValue();
if (StringUtils.isEmpty(securityToken)) {
securityToken = this.securityTokenGenerator.generateToken();
}
configBean.setGatewaySecurityToken(securityToken);
configBean.setCaRootAuthority(getCaRootAuthorityValue());
configBean.setActionCleanupStatus(getActionStatusOption());
configBean.setActionExpiryDays(String.valueOf(getActionExpiry()));
final TenantConfigurationValue<String> pollingTimeConfValue = tenantConfigurationManagement
.getConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, String.class);
configBean.setPollingTime(!pollingTimeConfValue.isGlobal());
configBean.setPollingTimeDuration(DurationHelper.formattedStringToDuration(pollingTimeConfValue.getValue()));
final TenantConfigurationValue<String> overdueTimeConfValue = tenantConfigurationManagement
.getConfigurationValue(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL, String.class);
configBean.setPollingOverdue(!overdueTimeConfValue.isGlobal());
configBean.setPollingOverdueDuration(DurationHelper.formattedStringToDuration(overdueTimeConfValue.getValue()));
return configBean;
}
private String getCaRootAuthorityValue() {
return tenantConfigurationManagement
.getConfigurationValue(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class)
.getValue();
}
private long getActionExpiry() {
return TimeUnit.MILLISECONDS.toDays(readConfigValue(ACTION_CLEANUP_ACTION_EXPIRY, Long.class).getValue());
}
private ActionStatusOption getActionStatusOption() {
final Set<Action.Status> actionStatus = getActionStatus();
final Collection<ActionStatusOption> actionStatusOptions = ActionAutoCleanupConfigurationItem
.getActionStatusOptions();
return actionStatusOptions.stream().filter(option -> actionStatus.equals(option.getStatus())).findFirst()
.orElse(actionStatusOptions.iterator().next());
}
private Set<Action.Status> getActionStatus() {
final TenantConfigurationValue<String> statusStr = readConfigValue(ACTION_CLEANUP_ACTION_STATUS, String.class);
if (statusStr != null) {
return Arrays.stream(statusStr.getValue().split("[;,]")).map(Action.Status::valueOf)
.collect(Collectors.toSet());
}
return EMPTY_STATUS_SET;
}
private <T extends Serializable> TenantConfigurationValue<T> readConfigValue(final String key,
final Class<T> valueType) {
return tenantConfigurationManagement.getConfigurationValue(key, valueType);
} }
private HorizontalLayout saveConfigurationButtonsLayout() { private HorizontalLayout saveConfigurationButtonsLayout() {
@@ -264,85 +128,17 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
return hlayout; return hlayout;
} }
private void saveSystemConfigBean() {
final ProxySystemConfigWindow configWindowBean = binder.getBean();
systemManagement.updateTenantMetadata(configWindowBean.getDsTypeInfo().getId());
writeConfigOption(TenantConfigurationKey.ROLLOUT_APPROVAL_ENABLED, configWindowBean.isRolloutApproval());
writeConfigOption(TenantConfigurationKey.ACTION_CLEANUP_ENABLED, configWindowBean.isActionAutocleanup());
writeConfigOption(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED,
configWindowBean.isTargetSecToken());
writeConfigOption(TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED,
configWindowBean.isGatewaySecToken());
writeConfigOption(TenantConfigurationKey.ANONYMOUS_DOWNLOAD_MODE_ENABLED,
configWindowBean.isDownloadAnonymous());
if (configWindowBean.isGatewaySecToken()) {
writeConfigOption(TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY,
configWindowBean.getGatewaySecurityToken());
}
if (configWindowBean.isActionAutocleanup()) {
writeConfigOption(ACTION_CLEANUP_ACTION_STATUS, configWindowBean.getActionCleanupStatus().getStatus()
.stream().map(Action.Status::name).collect(Collectors.joining(",")));
writeConfigOption(TenantConfigurationKey.ACTION_CLEANUP_ACTION_EXPIRY,
TimeUnit.DAYS.toMillis(Long.parseLong(configWindowBean.getActionExpiryDays())));
}
if (!readConfigOption(TenantConfigurationKey.MULTI_ASSIGNMENTS_ENABLED)) {
writeConfigOption(TenantConfigurationKey.REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED,
configWindowBean.isActionAutoclose());
}
if (configWindowBean.isMultiAssignments()
&& !readConfigOption(TenantConfigurationKey.MULTI_ASSIGNMENTS_ENABLED)) {
writeConfigOption(TenantConfigurationKey.MULTI_ASSIGNMENTS_ENABLED, configWindowBean.isMultiAssignments());
repositoryConfigurationView.disableMultipleAssignmentOption();
}
writeConfigOption(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED,
configWindowBean.isCertificateAuth());
if (configWindowBean.isCertificateAuth()) {
final String value = configWindowBean.getCaRootAuthority() != null ? configWindowBean.getCaRootAuthority()
: "";
writeConfigOption(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, value);
}
if (configWindowBean.isPollingTime()) {
tenantConfigurationManagement.addOrUpdateConfiguration(TenantConfigurationKey.POLLING_TIME_INTERVAL,
DurationHelper.durationToFormattedString(configWindowBean.getPollingTimeDuration()));
} else {
tenantConfigurationManagement.deleteConfiguration(TenantConfigurationKey.POLLING_TIME_INTERVAL);
}
if (configWindowBean.isPollingOverdue()) {
tenantConfigurationManagement.addOrUpdateConfiguration(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL,
DurationHelper.durationToFormattedString(configWindowBean.getPollingOverdueDuration()));
} else {
tenantConfigurationManagement.deleteConfiguration(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL);
}
populateAndGetSystemConfig();
}
private boolean readConfigOption(final String configurationKey) {
final TenantConfigurationValue<Boolean> enabled = tenantConfigurationManagement
.getConfigurationValue(configurationKey, Boolean.class);
return enabled.getValue() && !enabled.isGlobal();
}
private <T extends Serializable> void writeConfigOption(final String key, final T value) {
tenantConfigurationManagement.addOrUpdateConfiguration(key, value);
}
private void saveConfiguration() { private void saveConfiguration() {
final boolean isUserInputValid = configurationViews.stream().allMatch(ConfigurationGroup::isUserInputValid); final boolean isUserInputValid = filteredConfigurationViews.stream()
.allMatch(ConfigurationGroup::isUserInputValid);
if (!isUserInputValid) { if (!isUserInputValid) {
uINotification.displayValidationError(i18n.getMessage("notification.configuration.save.notpossible")); uINotification.displayValidationError(i18n.getMessage("notification.configuration.save.notpossible"));
return; return;
} }
saveSystemConfigBean(); // Iterate through all View Beans and call their save implementation
configurationViews.forEach(ConfigurationGroup::save); filteredConfigurationViews.forEach(ConfigurationGroup::save);
// More methods // More methods
saveConfigurationBtn.setEnabled(false); saveConfigurationBtn.setEnabled(false);
undoConfigurationBtn.setEnabled(false); undoConfigurationBtn.setEnabled(false);
@@ -350,8 +146,7 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
} }
private void undoConfiguration() { private void undoConfiguration() {
binder.setBean(populateAndGetSystemConfig()); filteredConfigurationViews.forEach(ConfigurationGroup::undo);
configurationViews.forEach(ConfigurationGroup::undo);
// More methods // More methods
saveConfigurationBtn.setEnabled(false); saveConfigurationBtn.setEnabled(false);
undoConfigurationBtn.setEnabled(false); undoConfigurationBtn.setEnabled(false);

View File

@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.ui.tenantconfiguration.authentication;
import org.eclipse.hawkbit.repository.model.TenantConfiguration; import org.eclipse.hawkbit.repository.model.TenantConfiguration;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder; import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigWindow; import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigAuthentication;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
@@ -41,7 +41,7 @@ public class CertificateAuthenticationConfigurationItem extends VerticalLayout {
* System config window binder * System config window binder
*/ */
public CertificateAuthenticationConfigurationItem(final VaadinMessageSource i18n, public CertificateAuthenticationConfigurationItem(final VaadinMessageSource i18n,
final Binder<ProxySystemConfigWindow> binder) { final Binder<ProxySystemConfigAuthentication> binder) {
this.setSpacing(false); this.setSpacing(false);
this.setMargin(false); this.setMargin(false);
addComponent(SPUIComponentProvider.generateLabel(i18n, "label.configuration.auth.header")); addComponent(SPUIComponentProvider.generateLabel(i18n, "label.configuration.auth.header"));
@@ -59,8 +59,8 @@ public class CertificateAuthenticationConfigurationItem extends VerticalLayout {
caRootAuthorityTextField = new TextFieldBuilder(TenantConfiguration.VALUE_MAX_SIZE).buildTextComponent(); caRootAuthorityTextField = new TextFieldBuilder(TenantConfiguration.VALUE_MAX_SIZE).buildTextComponent();
caRootAuthorityTextField.setWidth("100%"); caRootAuthorityTextField.setWidth("100%");
binder.bind(caRootAuthorityTextField, ProxySystemConfigWindow::getCaRootAuthority, binder.bind(caRootAuthorityTextField, ProxySystemConfigAuthentication::getCaRootAuthority,
ProxySystemConfigWindow::setCaRootAuthority); ProxySystemConfigAuthentication::setCaRootAuthority);
caRootAuthorityLayout.addComponent(caRootAuthorityLabel); caRootAuthorityLayout.addComponent(caRootAuthorityLabel);
caRootAuthorityLayout.setExpandRatio(caRootAuthorityLabel, 0); caRootAuthorityLayout.setExpandRatio(caRootAuthorityLabel, 0);
caRootAuthorityLayout.addComponent(caRootAuthorityTextField); caRootAuthorityLayout.addComponent(caRootAuthorityTextField);

View File

@@ -10,7 +10,7 @@ package org.eclipse.hawkbit.ui.tenantconfiguration.authentication;
import org.eclipse.hawkbit.security.SecurityTokenGenerator; import org.eclipse.hawkbit.security.SecurityTokenGenerator;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder; import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigWindow; import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigAuthentication;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
@@ -34,7 +34,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Vertica
private final transient SecurityTokenGenerator securityTokenGenerator; private final transient SecurityTokenGenerator securityTokenGenerator;
private final VerticalLayout detailLayout; private final VerticalLayout detailLayout;
private final Binder<ProxySystemConfigWindow> binder; private final Binder<ProxySystemConfigAuthentication> binder;
/** /**
* Constructor for GatewaySecurityTokenAuthenticationConfigurationItem * Constructor for GatewaySecurityTokenAuthenticationConfigurationItem
@@ -47,7 +47,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Vertica
* System config window binder * System config window binder
*/ */
public GatewaySecurityTokenAuthenticationConfigurationItem(final VaadinMessageSource i18n, public GatewaySecurityTokenAuthenticationConfigurationItem(final VaadinMessageSource i18n,
final SecurityTokenGenerator securityTokenGenerator, final Binder<ProxySystemConfigWindow> binder) { final SecurityTokenGenerator securityTokenGenerator, final Binder<ProxySystemConfigAuthentication> binder) {
this.securityTokenGenerator = securityTokenGenerator; this.securityTokenGenerator = securityTokenGenerator;
this.binder = binder; this.binder = binder;
this.setSpacing(false); this.setSpacing(false);
@@ -68,7 +68,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Vertica
final Label gatewayTokenLabel = new LabelBuilder().id("gatewaysecuritytokenkey").name("").buildLabel(); final Label gatewayTokenLabel = new LabelBuilder().id("gatewaysecuritytokenkey").name("").buildLabel();
gatewayTokenLabel.addStyleName("gateway-token-label"); gatewayTokenLabel.addStyleName("gateway-token-label");
final ReadOnlyHasValue<String> gatewayTokenFieldBindable = new ReadOnlyHasValue<>(gatewayTokenLabel::setValue); final ReadOnlyHasValue<String> gatewayTokenFieldBindable = new ReadOnlyHasValue<>(gatewayTokenLabel::setValue);
binder.bind(gatewayTokenFieldBindable, ProxySystemConfigWindow::getGatewaySecurityToken, null); binder.bind(gatewayTokenFieldBindable, ProxySystemConfigAuthentication::getGatewaySecurityToken, null);
final HorizontalLayout keyGenerationLayout = new HorizontalLayout(); final HorizontalLayout keyGenerationLayout = new HorizontalLayout();
keyGenerationLayout.setSpacing(true); keyGenerationLayout.setSpacing(true);

View File

@@ -18,7 +18,7 @@ import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.TenantConfiguration; import org.eclipse.hawkbit.repository.model.TenantConfiguration;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder; import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigWindow; import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigRepository;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
@@ -68,7 +68,7 @@ public class ActionAutoCleanupConfigurationItem extends VerticalLayout {
* @param i18n * @param i18n
* VaadinMessageSource * VaadinMessageSource
*/ */
public ActionAutoCleanupConfigurationItem(final Binder<ProxySystemConfigWindow> binder, public ActionAutoCleanupConfigurationItem(final Binder<ProxySystemConfigRepository> binder,
final VaadinMessageSource i18n) { final VaadinMessageSource i18n) {
this.i18n = i18n; this.i18n = i18n;
this.setSpacing(false); this.setSpacing(false);
@@ -84,8 +84,8 @@ public class ActionAutoCleanupConfigurationItem extends VerticalLayout {
actionStatusCombobox.removeStyleName(ValoTheme.COMBOBOX_SMALL); actionStatusCombobox.removeStyleName(ValoTheme.COMBOBOX_SMALL);
actionStatusCombobox.addStyleName(ValoTheme.COMBOBOX_TINY); actionStatusCombobox.addStyleName(ValoTheme.COMBOBOX_TINY);
actionStatusCombobox.setWidth(200.0F, Unit.PIXELS); actionStatusCombobox.setWidth(200.0F, Unit.PIXELS);
binder.bind(actionStatusCombobox, ProxySystemConfigWindow::getActionCleanupStatus, binder.bind(actionStatusCombobox, ProxySystemConfigRepository::getActionCleanupStatus,
ProxySystemConfigWindow::setActionCleanupStatus); ProxySystemConfigRepository::setActionCleanupStatus);
actionExpiryInput = new TextFieldBuilder(TenantConfiguration.VALUE_MAX_SIZE).buildTextComponent(); actionExpiryInput = new TextFieldBuilder(TenantConfiguration.VALUE_MAX_SIZE).buildTextComponent();
actionExpiryInput.setId(UIComponentIdProvider.SYSTEM_CONFIGURATION_ACTION_CLEANUP_ACTION_EXPIRY); actionExpiryInput.setId(UIComponentIdProvider.SYSTEM_CONFIGURATION_ACTION_CLEANUP_ACTION_EXPIRY);
actionExpiryInput.setWidth(55, Unit.PIXELS); actionExpiryInput.setWidth(55, Unit.PIXELS);
@@ -97,7 +97,7 @@ public class ActionAutoCleanupConfigurationItem extends VerticalLayout {
} catch (final NumberFormatException ex) { } catch (final NumberFormatException ex) {
return ValidationResult.error(i18n.getMessage(MSG_KEY_INVALID_EXPIRY)); return ValidationResult.error(i18n.getMessage(MSG_KEY_INVALID_EXPIRY));
} }
}).bind(ProxySystemConfigWindow::getActionExpiryDays, ProxySystemConfigWindow::setActionExpiryDays); }).bind(ProxySystemConfigRepository::getActionExpiryDays, ProxySystemConfigRepository::setActionExpiryDays);
row1.addComponent(newLabel(MSG_KEY_PREFIX)); row1.addComponent(newLabel(MSG_KEY_PREFIX));
row1.addComponent(actionStatusCombobox); row1.addComponent(actionStatusCombobox);

View File

@@ -8,7 +8,7 @@
*/ */
package org.eclipse.hawkbit.ui.tenantconfiguration.repository; package org.eclipse.hawkbit.ui.tenantconfiguration.repository;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigWindow; import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigRepository;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
@@ -39,7 +39,7 @@ public class MultiAssignmentsConfigurationItem extends VerticalLayout {
* System config window binder * System config window binder
*/ */
public MultiAssignmentsConfigurationItem(final VaadinMessageSource i18n, public MultiAssignmentsConfigurationItem(final VaadinMessageSource i18n,
final Binder<ProxySystemConfigWindow> binder) { final Binder<ProxySystemConfigRepository> binder) {
this.i18n = i18n; this.i18n = i18n;
this.setSpacing(false); this.setSpacing(false);
this.setMargin(false); this.setMargin(false);

View File

@@ -8,7 +8,7 @@
*/ */
package org.eclipse.hawkbit.ui.tenantconfiguration.window; package org.eclipse.hawkbit.ui.tenantconfiguration.window;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigWindow; import org.eclipse.hawkbit.ui.common.data.proxies.ProxySystemConfigDsType;
import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTypeInfo; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyTypeInfo;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider; import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
@@ -42,7 +42,7 @@ public class SystemConfigWindowLayoutComponentBuilder {
* *
* @return Distribution set type combo box * @return Distribution set type combo box
*/ */
public ComboBox<ProxyTypeInfo> createDistributionSetTypeCombo(final Binder<ProxySystemConfigWindow> binder) { public ComboBox<ProxyTypeInfo> createDistributionSetTypeCombo(final Binder<ProxySystemConfigDsType> binder) {
final ComboBox<ProxyTypeInfo> dsTypeCombo = SPUIComponentProvider.getComboBox( final ComboBox<ProxyTypeInfo> dsTypeCombo = SPUIComponentProvider.getComboBox(
UIComponentIdProvider.SYSTEM_CONFIGURATION_DEFAULTDIS_COMBOBOX, null, UIComponentIdProvider.SYSTEM_CONFIGURATION_DEFAULTDIS_COMBOBOX, null,
dependencies.getI18n().getMessage("caption.type"), null, false, ProxyTypeInfo::getKeyAndName, dependencies.getI18n().getMessage("caption.type"), null, false, ProxyTypeInfo::getKeyAndName,
@@ -51,8 +51,8 @@ public class SystemConfigWindowLayoutComponentBuilder {
dsTypeCombo.addStyleName(ValoTheme.COMBOBOX_TINY); dsTypeCombo.addStyleName(ValoTheme.COMBOBOX_TINY);
dsTypeCombo.setWidth(330.0F, Unit.PIXELS); dsTypeCombo.setWidth(330.0F, Unit.PIXELS);
binder.forField(dsTypeCombo).bind(ProxySystemConfigWindow::getDsTypeInfo, binder.forField(dsTypeCombo).bind(ProxySystemConfigDsType::getDsTypeInfo,
ProxySystemConfigWindow::setDsTypeInfo); ProxySystemConfigDsType::setDsTypeInfo);
return dsTypeCombo; return dsTypeCombo;
} }