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

View File

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

View File

@@ -19,7 +19,7 @@ import static org.mockito.Mockito.when;
import java.io.File;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
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.DmfDownloadAndUpdateRequest;
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.event.remote.TargetAssignDistributionSetEvent;
import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent;
@@ -101,7 +102,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
final ArtifactUrlHandler artifactUrlHandlerMock = Mockito.mock(ArtifactUrlHandler.class);
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);
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
.getByControllerID(targetAssignDistributionSetEvent.getActions().keySet().iterator().next()).get();
final Message sendMessage = createArgumentCapture(target.getAddress());
return sendMessage;
return createArgumentCapture(target.getAddress());
}
private Action createAction(final DistributionSet testDs) {
@@ -128,8 +128,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
}
@Test
@Description("Verifies that download and install event with 3 software moduls and no artifacts works")
public void testSendDownloadRequesWithSoftwareModulesAndNoArtifacts() {
@Description("Verifies that download and install event with 3 software modules and no artifacts works")
public void testSendDownloadRequestWithSoftwareModulesAndNoArtifacts() {
final DistributionSet createDistributionSet = testdataFactory
.createDistributionSet(UUID.randomUUID().toString());
testdataFactory.addSoftwareModuleMetadata(createDistributionSet);
@@ -139,7 +139,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = new TargetAssignDistributionSetEvent(
action, serviceMatcher.getServiceId());
amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent);
final Message sendMessage = getCaptureAdressEvent(targetAssignDistributionSetEvent);
final Message sendMessage = getCaptureAddressEvent(targetAssignDistributionSetEvent);
final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage,
action.getId());
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));
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())) {
continue;
}
@@ -186,7 +186,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = new TargetAssignDistributionSetEvent(
action, serviceMatcher.getServiceId());
amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent);
final Message sendMessage = getCaptureAdressEvent(targetAssignDistributionSetEvent);
final Message sendMessage = getCaptureAddressEvent(targetAssignDistributionSetEvent);
final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage,
action.getId());
@@ -194,8 +194,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
downloadAndUpdateRequest.getSoftwareModules().size());
assertThat(downloadAndUpdateRequest.getTargetSecurityToken()).isEqualTo(TEST_TOKEN);
for (final org.eclipse.hawkbit.dmf.json.model.DmfSoftwareModule softwareModule : downloadAndUpdateRequest
.getSoftwareModules()) {
for (final DmfSoftwareModule softwareModule : downloadAndUpdateRequest.getSoftwareModules()) {
if (!softwareModule.getModuleId().equals(module.getId())) {
continue;
}
@@ -259,7 +258,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
@Test
@Description("Verifies that a delete message is not send if the address is not an amqp address.")
public void sendDeleteRequestWithNoAmqpAdress() {
public void sendDeleteRequestWithNoAmqpAddress() {
// setup
final String noAmqpUri = "http://anyhost";
@@ -274,8 +273,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
}
@Test
@Description("Verfies that a delete message is not send if the address is null.")
public void sendDeleteRequestWithNullAdress() {
@Description("Verifies that a delete message is not send if the address is null.")
public void sendDeleteRequestWithNullAddress() {
// setup
final String noAmqpUri = null;
@@ -293,7 +292,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
assertEventMessage(sendMessage);
final DmfActionRequest actionId = convertMessage(sendMessage, DmfActionRequest.class);
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));
}

View File

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

View File

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

View File

@@ -82,12 +82,12 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Autowired
private AmqpProperties amqpProperties;
@Autowired
private AmqpMessageHandlerService amqpMessageHandlerService;
@Test
@Description("Tests DMF PING request and expected reponse.")
@Description("Tests DMF PING request and expected response.")
public void pingDmfInterface() {
final Message pingMessage = createPingMessage(CORRELATION_ID, TENANT_EXIST);
getDmfClient().send(pingMessage);
@@ -99,8 +99,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@Description("Tests register target")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 3)})
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 3) })
public void registerTargets() {
final String controllerId = TARGET_PREFIX + "registerTargets";
registerAndAssertTargetWithExistingTenant(controllerId, 1);
@@ -113,8 +113,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
}
@Test
@Description("Tests register invalid target withy empty controller id.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)})
@Description("Tests register invalid target with empty controller id.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void registerEmptyTarget() {
createAndSendThingCreated("", TENANT_EXIST);
assertAllTargetsCount(0);
@@ -122,8 +122,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
}
@Test
@Description("Tests register invalid target with whitspace controller id.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 0)})
@Description("Tests register invalid target with whitespace controller id.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void registerWhitespaceTarget() {
createAndSendThingCreated("Invalid Invalid", TENANT_EXIST);
assertAllTargetsCount(0);
@@ -132,7 +132,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
createAndSendThingCreated(null, TENANT_EXIST);
assertAllTargetsCount(0);
@@ -141,7 +141,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
createAndSendThingCreated(RandomStringUtils.randomAlphabetic(Target.CONTROLLER_ID_MAX_SIZE + 1), TENANT_EXIST);
assertAllTargetsCount(0);
@@ -150,7 +150,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final String controllerId = TARGET_PREFIX + "missingReplyToProperty";
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
@@ -163,7 +163,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final String controllerId = TARGET_PREFIX + "emptyReplyToProperty";
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
@@ -176,7 +176,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.THING_ID);
@@ -188,7 +188,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
getDmfClient().send(createTargetMessage);
@@ -199,7 +199,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final String controllerId = TARGET_PREFIX + "missingTenantHeader";
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
@@ -212,7 +212,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final String controllerId = TARGET_PREFIX + "nullTenantHeader";
final Message createTargetMessage = createTargetMessage(controllerId, null);
@@ -224,7 +224,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final String controllerId = TARGET_PREFIX + "emptyTenantHeader";
final Message createTargetMessage = createTargetMessage(controllerId, "");
@@ -236,7 +236,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final String controllerId = TARGET_PREFIX + "tenantNotExist";
final Message createTargetMessage = createTargetMessage(controllerId, "TenantNotExist");
@@ -248,7 +248,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TYPE);
@@ -260,7 +260,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TYPE, null);
@@ -272,7 +272,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TYPE, "");
@@ -284,7 +284,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TYPE, "NotExist");
@@ -296,7 +296,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, "");
eventMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TOPIC, null);
@@ -307,7 +307,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, "");
eventMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TOPIC, "");
@@ -318,7 +318,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, "");
eventMessage.getMessageProperties().getHeaders().put(MessageHeaderKey.TOPIC, "NotExist");
@@ -329,7 +329,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, "");
eventMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TOPIC);
@@ -340,7 +340,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, null);
getDmfClient().send(eventMessage);
@@ -349,7 +349,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS, "");
getDmfClient().send(eventMessage);
@@ -358,7 +358,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS,
"Invalid Content");
@@ -368,7 +368,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.RUNNING);
final Message eventMessage = createEventMessage(TENANT_EXIST, EventTopic.UPDATE_ACTION_STATUS,
@@ -379,98 +379,98 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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 = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.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() {
final String controllerId = TARGET_PREFIX + "finishActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.FINISHED, Status.FINISHED, controllerId);
}
@Test
@Description("Register a target and send a update action status (running). Verfiy if the updated action status is correct.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1),
@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),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 0), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@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() {
final String controllerId = TARGET_PREFIX + "runningActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RUNNING, Status.RUNNING, controllerId);
}
@Test
@Description("Register a target and send an update action status (downloaded). Verfiy if the updated action status is correct.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1),
@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),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 0), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@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() {
final String controllerId = TARGET_PREFIX + "downloadedActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOADED, Status.DOWNLOADED, controllerId);
}
@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),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@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() {
final String controllerId = TARGET_PREFIX + "downloadActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOAD, Status.DOWNLOAD, controllerId);
}
@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),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@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() {
final String controllerId = TARGET_PREFIX + "errorActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.ERROR, Status.ERROR, controllerId);
}
@Test
@Description("Register a target and send a update action status (warning). Verfiy if the updated action status is correct.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1),
@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),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@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() {
final String controllerId = TARGET_PREFIX + "warningActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.WARNING, Status.WARNING, controllerId);
}
@Test
@Description("Register a target and send a update action status (retrieved). Verfiy if the updated action status is correct.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1),
@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),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@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() {
final String controllerId = TARGET_PREFIX + "retrievedActionStatus";
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RETRIEVED, Status.RETRIEVED, controllerId);
@@ -478,13 +478,13 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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 = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@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() {
final String controllerId = TARGET_PREFIX + "cancelNotAllowActionStatus";
registerTargetAndSendActionStatus(DmfActionStatus.CANCELED, controllerId);
@@ -492,14 +492,14 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
}
@Test
@Description("Verfiy 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),
@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),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@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() {
final String controllerId = TARGET_PREFIX + "receiveDownLoadAndInstallMessageAfterAssignment";
@@ -518,14 +518,14 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
}
@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),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@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() {
final String controllerId = TARGET_PREFIX + "receiveDownLoadMessageBeforeMaintenanceWindowStartTime";
@@ -546,13 +546,13 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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 = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@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() {
final String controllerId = TARGET_PREFIX + "receiveDownLoadAndInstallMessageDuringMaintenanceWindow";
@@ -572,15 +572,15 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
}
@Test
@Description("Verfiy 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),
@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),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = CancelTargetAssignmentEvent.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() {
final String controllerId = TARGET_PREFIX + "receiveCancelUpdateMessageAfterAssignmentWasCanceled";
@@ -601,14 +601,14 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@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")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1),
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = CancelTargetAssignmentEvent.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() {
final String controllerId = TARGET_PREFIX + "actionNotExists";
@@ -621,13 +621,13 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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 = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@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() {
final String controllerId = TARGET_PREFIX + "canceledRejectedNotAllowActionStatus";
registerTargetAndSendActionStatus(DmfActionStatus.CANCEL_REJECTED, controllerId);
@@ -635,15 +635,15 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
}
@Test
@Description("Register a target and send a valid update action status (cancel_rejected). Verfiy if the updated action status is correct.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1),
@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),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@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() {
final String controllerId = TARGET_PREFIX + "canceledRejectedActionStatus";
@@ -655,8 +655,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@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.")
@ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 4), @Expect(type = TargetPollEvent.class, count = 1)})
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 4), @Expect(type = TargetPollEvent.class, count = 1) })
public void updateAttributesWithDifferentUpdateModes() {
final String controllerId = TARGET_PREFIX + "updateAttributes";
@@ -758,8 +758,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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),
@Expect(type = TargetUpdatedEvent.class, count = 0), @Expect(type = TargetPollEvent.class, count = 1)})
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 0), @Expect(type = TargetPollEvent.class, count = 1) })
public void updateAttributesWithNoThingId() {
final String controllerId = TARGET_PREFIX + "updateAttributesWithNoThingId";
@@ -783,8 +783,8 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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),
@Expect(type = TargetUpdatedEvent.class, count = 0), @Expect(type = TargetPollEvent.class, count = 1)})
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 0), @Expect(type = TargetPollEvent.class, count = 1) })
public void updateAttributesWithWrongBody() {
// setup
@@ -825,14 +825,14 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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 = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.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 {
// create target
final String controllerId = TARGET_PREFIX + "registerTargets_1";
@@ -855,14 +855,14 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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 = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
@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()
throws IOException {
@@ -894,7 +894,7 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
@Test
@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() {
final ControllerManagement mockedControllerManagement = Mockito.mock(ControllerManagement.class);
@@ -1010,8 +1010,9 @@ public class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServic
}
private int getAuthenticationMessageCount() {
return Integer.parseInt(getRabbitAdmin().getQueueProperties(amqpProperties.getReceiverQueue())
.get(RabbitAdmin.QUEUE_MESSAGE_COUNT).toString());
return Integer
.parseInt(Objects.requireNonNull(getRabbitAdmin().getQueueProperties(amqpProperties.getReceiverQueue()))
.get(RabbitAdmin.QUEUE_MESSAGE_COUNT).toString());
}
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;
import java.io.Serializable;
import java.time.Duration;
import org.eclipse.hawkbit.ui.tenantconfiguration.repository.ActionAutoCleanupConfigurationItem.ActionStatusOption;
/**
* Proxy for system config window.
@@ -23,28 +20,7 @@ public class ProxySystemConfigWindow implements Serializable {
private Long id;
private String name;
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
@@ -84,125 +60,6 @@ public class ProxySystemConfigWindow implements Serializable {
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
*
@@ -222,257 +79,4 @@ public class ProxySystemConfigWindow implements Serializable {
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;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
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.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.tenantconfiguration.authentication.AnonymousDownloadAuthenticationConfigurationItem;
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.VaadinMessageSource;
import com.vaadin.data.Binder;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Link;
import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout;
import org.springframework.util.StringUtils;
/**
* 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";
@@ -41,28 +42,34 @@ public class AuthenticationConfigurationView extends CustomComponent {
private final VaadinMessageSource i18n;
private final CertificateAuthenticationConfigurationItem certificateAuthenticationConfigurationItem;
private final TargetSecurityTokenAuthenticationConfigurationItem targetSecurityTokenAuthenticationConfigurationItem;
private final GatewaySecurityTokenAuthenticationConfigurationItem gatewaySecurityTokenAuthenticationConfigurationItem;
private final AnonymousDownloadAuthenticationConfigurationItem anonymousDownloadAuthenticationConfigurationItem;
private final transient SecurityTokenGenerator securityTokenGenerator;
private CertificateAuthenticationConfigurationItem certificateAuthenticationConfigurationItem;
private TargetSecurityTokenAuthenticationConfigurationItem targetSecurityTokenAuthenticationConfigurationItem;
private GatewaySecurityTokenAuthenticationConfigurationItem gatewaySecurityTokenAuthenticationConfigurationItem;
private AnonymousDownloadAuthenticationConfigurationItem anonymousDownloadAuthenticationConfigurationItem;
private final UiProperties uiProperties;
private final Binder<ProxySystemConfigWindow> binder;
AuthenticationConfigurationView(final VaadinMessageSource i18n, final UiProperties uiProperties,
final SecurityTokenGenerator securityTokenGenerator, final Binder<ProxySystemConfigWindow> binder) {
public AuthenticationConfigurationView(final VaadinMessageSource i18n, final UiProperties uiProperties,
final TenantConfigurationManagement tenantConfigurationManagement,
final SecurityTokenGenerator securityTokenGenerator) {
super(tenantConfigurationManagement);
this.i18n = i18n;
this.uiProperties = uiProperties;
this.securityTokenGenerator = securityTokenGenerator;
}
@Override
public void afterPropertiesSet() {
super.afterPropertiesSet();
this.targetSecurityTokenAuthenticationConfigurationItem = new TargetSecurityTokenAuthenticationConfigurationItem(
i18n);
this.certificateAuthenticationConfigurationItem = new CertificateAuthenticationConfigurationItem(i18n, binder);
this.certificateAuthenticationConfigurationItem = new CertificateAuthenticationConfigurationItem(i18n,
getBinder());
this.gatewaySecurityTokenAuthenticationConfigurationItem = new GatewaySecurityTokenAuthenticationConfigurationItem(
i18n, securityTokenGenerator, binder);
i18n, securityTokenGenerator, getBinder());
this.anonymousDownloadAuthenticationConfigurationItem = new AnonymousDownloadAuthenticationConfigurationItem(
i18n);
this.uiProperties = uiProperties;
this.binder = binder;
init();
}
@@ -88,9 +95,21 @@ public class AuthenticationConfigurationView extends CustomComponent {
gridLayout.setSizeFull();
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(
UIComponentIdProvider.CERT_AUTH_ALLOWED_CHECKBOX, binder, ProxySystemConfigWindow::isCertificateAuth,
ProxySystemConfigWindow::setCertificateAuth);
UIComponentIdProvider.CERT_AUTH_ALLOWED_CHECKBOX, getBinder(),
ProxySystemConfigAuthentication::isCertificateAuth,
ProxySystemConfigAuthentication::setCertificateAuth);
certificateAuthCheckbox.setStyleName(DIST_CHECKBOX_STYLE);
certificateAuthCheckbox.addValueChangeListener(valueChangeEvent -> {
if (valueChangeEvent.getValue()) {
@@ -99,19 +118,24 @@ public class AuthenticationConfigurationView extends CustomComponent {
certificateAuthenticationConfigurationItem.hideDetails();
}
});
gridLayout.addComponent(certificateAuthCheckbox, 0, 0);
gridLayout.addComponent(certificateAuthenticationConfigurationItem, 1, 0);
gridLayout.addComponent(certificateAuthCheckbox, 0, row);
gridLayout.addComponent(certificateAuthenticationConfigurationItem, 1, row);
}
protected void initTargetTokenConfiguration(GridLayout gridLayout, int row) {
final CheckBox targetSecTokenCheckBox = FormComponentBuilder.getCheckBox(
UIComponentIdProvider.TARGET_SEC_TOKEN_ALLOWED_CHECKBOX, binder,
ProxySystemConfigWindow::isTargetSecToken, ProxySystemConfigWindow::setTargetSecToken);
UIComponentIdProvider.TARGET_SEC_TOKEN_ALLOWED_CHECKBOX, getBinder(),
ProxySystemConfigAuthentication::isTargetSecToken, ProxySystemConfigAuthentication::setTargetSecToken);
targetSecTokenCheckBox.setStyleName(DIST_CHECKBOX_STYLE);
gridLayout.addComponent(targetSecTokenCheckBox, 0, 1);
gridLayout.addComponent(targetSecurityTokenAuthenticationConfigurationItem, 1, 1);
gridLayout.addComponent(targetSecTokenCheckBox, 0, row);
gridLayout.addComponent(targetSecurityTokenAuthenticationConfigurationItem, 1, row);
}
protected void initGatewayTokenConfiguration(GridLayout gridLayout, int row) {
final CheckBox gatewaySecTokenCheckBox = FormComponentBuilder.getCheckBox(
UIComponentIdProvider.GATEWAY_SEC_TOKEN_ALLOWED_CHECKBOX, binder,
ProxySystemConfigWindow::isGatewaySecToken, ProxySystemConfigWindow::setGatewaySecToken);
UIComponentIdProvider.GATEWAY_SEC_TOKEN_ALLOWED_CHECKBOX, getBinder(),
ProxySystemConfigAuthentication::isGatewaySecToken,
ProxySystemConfigAuthentication::setGatewaySecToken);
gatewaySecTokenCheckBox.setStyleName(DIST_CHECKBOX_STYLE);
gatewaySecTokenCheckBox.addValueChangeListener(valueChangeEvent -> {
if (valueChangeEvent.getValue()) {
@@ -120,23 +144,73 @@ public class AuthenticationConfigurationView extends CustomComponent {
gatewaySecurityTokenAuthenticationConfigurationItem.hideDetails();
}
});
gridLayout.addComponent(gatewaySecTokenCheckBox, 0, 2);
gridLayout.addComponent(gatewaySecurityTokenAuthenticationConfigurationItem, 1, 2);
gridLayout.addComponent(gatewaySecTokenCheckBox, 0, row);
gridLayout.addComponent(gatewaySecurityTokenAuthenticationConfigurationItem, 1, row);
}
protected void initAnonymousDownloadConfiguration(GridLayout gridLayout, int row) {
final CheckBox downloadAnonymousCheckBox = FormComponentBuilder.getCheckBox(
UIComponentIdProvider.DOWNLOAD_ANONYMOUS_CHECKBOX, binder, ProxySystemConfigWindow::isDownloadAnonymous,
ProxySystemConfigWindow::setDownloadAnonymous);
UIComponentIdProvider.DOWNLOAD_ANONYMOUS_CHECKBOX, getBinder(),
ProxySystemConfigAuthentication::isDownloadAnonymous,
ProxySystemConfigAuthentication::setDownloadAnonymous);
downloadAnonymousCheckBox.setStyleName(DIST_CHECKBOX_STYLE);
gridLayout.addComponent(downloadAnonymousCheckBox, 0, 3);
gridLayout.addComponent(anonymousDownloadAuthenticationConfigurationItem, 1, 3);
gridLayout.addComponent(downloadAnonymousCheckBox, 0, row);
gridLayout.addComponent(anonymousDownloadAuthenticationConfigurationItem, 1, row);
final Link linkToSecurityHelp = SPUIComponentProvider.getHelpLink(i18n,
uiProperties.getLinks().getDocumentation().getSecurity());
gridLayout.addComponent(linkToSecurityHelp, 2, 3);
gridLayout.addComponent(linkToSecurityHelp, 2, row);
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;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import com.vaadin.data.Binder;
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
* 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 final List<ConfigurationItemChangeListener> configurationChangeListeners = new ArrayList<>();
private final transient TenantConfigurationManagement tenantConfigurationManagement;
private final Binder<B> binder;
protected void notifyConfigurationChanged() {
configurationChangeListeners.forEach(ConfigurationItemChangeListener::configurationHasChanged);
public BaseConfigurationView(final TenantConfigurationManagement tenantConfigurationManagement) {
this.tenantConfigurationManagement = tenantConfigurationManagement;
binder = new Binder<>();
}
@Override
public void afterPropertiesSet() {
binder.setBean(populateSystemConfig());
}
protected abstract B populateSystemConfig();
@Override
public void addChangeListener(final ConfigurationItemChangeListener listener) {
configurationChangeListeners.add(listener);
@@ -39,4 +56,33 @@ public abstract class BaseConfigurationView extends CustomComponent implements C
// different valid options.
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.SystemManagement;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.ui.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
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.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.tenantconfiguration.window.SystemConfigWindowDependencies;
import org.eclipse.hawkbit.ui.tenantconfiguration.window.SystemConfigWindowLayoutComponentBuilder;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import com.vaadin.data.Binder;
import com.vaadin.data.HasValue;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
@@ -34,7 +33,7 @@ import com.vaadin.ui.VerticalLayout;
/**
* Default DistributionSet Panel.
*/
public class DefaultDistributionSetTypeLayout extends CustomComponent {
public class DefaultDistributionSetTypeView extends BaseConfigurationView<ProxySystemConfigDsType> {
private static final long serialVersionUID = 1L;
@@ -43,26 +42,31 @@ public class DefaultDistributionSetTypeLayout extends CustomComponent {
private final SpPermissionChecker permissionChecker;
private Long currentDefaultDistSetTypeId;
private ComboBox<ProxyTypeInfo> dsSetTypeComboBox;
private final Binder<ProxySystemConfigWindow> binder;
private final transient SystemManagement systemManagement;
private final transient SystemConfigWindowLayoutComponentBuilder builder;
private Label changeIcon;
DefaultDistributionSetTypeLayout(final SystemManagement systemManagement, final VaadinMessageSource i18n,
final SpPermissionChecker permChecker, final DistributionSetTypeManagement dsTypeManagement,
final Binder<ProxySystemConfigWindow> binder) {
DefaultDistributionSetTypeView(final VaadinMessageSource i18n,
final TenantConfigurationManagement tenantConfigurationManagement, final SystemManagement systemManagement,
final SpPermissionChecker permissionChecker, final DistributionSetTypeManagement dsTypeManagement) {
super(tenantConfigurationManagement);
this.i18n = i18n;
this.permissionChecker = permChecker;
this.binder = binder;
this.permissionChecker = permissionChecker;
this.systemManagement = systemManagement;
final DistributionSetTypeDataProvider<ProxyTypeInfo> dataProvider = new DistributionSetTypeDataProvider<>(
dsTypeManagement, new TypeToTypeInfoMapper<DistributionSetType>());
dsTypeManagement, new TypeToTypeInfoMapper<>());
final SystemConfigWindowDependencies dependencies = new SystemConfigWindowDependencies(systemManagement, i18n,
permChecker, dsTypeManagement, dataProvider);
permissionChecker, dsTypeManagement, dataProvider);
this.builder = new SystemConfigWindowLayoutComponentBuilder(dependencies);
initDsSetTypeComponent();
}
private void initDsSetTypeComponent() {
@Override
public void afterPropertiesSet() {
super.afterPropertiesSet();
init();
}
private void init() {
if (!permissionChecker.hasReadRepositoryPermission()) {
return;
}
@@ -101,21 +105,34 @@ public class DefaultDistributionSetTypeLayout extends CustomComponent {
}
private void initDsSetTypeComboBox() {
dsSetTypeComboBox = builder.createDistributionSetTypeCombo(binder);
dsSetTypeComboBox = builder.createDistributionSetTypeCombo(getBinder());
dsSetTypeComboBox.addValueChangeListener(this::selectDistributionSetTypeValue);
}
private Long getCurrentDistributionSetTypeId() {
return binder.getBean().getDsTypeInfo().getId();
return getBinderBean().getDsTypeInfo().getId();
}
/**
* Method that is called when combobox event is performed.
*
* @param event
* ValueChangeEvent
*/
private void selectDistributionSetTypeValue(final HasValue.ValueChangeEvent<ProxyTypeInfo> event) {
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.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.tenancy.configuration.DurationHelper;
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.utils.UIComponentIdProvider;
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.Panel;
import com.vaadin.ui.VerticalLayout;
@@ -34,25 +33,37 @@ import com.vaadin.ui.VerticalLayout;
/**
* 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 ZoneId ZONEID_UTC = ZoneId.of("+0");
private final DurationConfigField fieldPollTime;
private final DurationConfigField fieldPollingOverdueTime;
private final VaadinMessageSource i18n;
private final ControllerPollProperties controllerPollProperties;
PollingConfigurationView(final VaadinMessageSource i18n, final ControllerPollProperties controllerPollProperties,
final TenantConfigurationManagement tenantConfigurationManagement,
final Binder<ProxySystemConfigWindow> binder) {
final TenantConfigurationManagement tenantConfigurationManagement) {
super(tenantConfigurationManagement);
this.controllerPollProperties = controllerPollProperties;
this.i18n = i18n;
}
@Override
public void afterPropertiesSet() {
super.afterPropertiesSet();
init();
}
private void init() {
final Duration minDuration = DurationHelper
.formattedStringToDuration(controllerPollProperties.getMinPollingTime());
final Duration maxDuration = DurationHelper
.formattedStringToDuration(controllerPollProperties.getMaxPollingTime());
final Duration globalPollTime = DurationHelper.formattedStringToDuration(tenantConfigurationManagement
final Duration globalPollTime = DurationHelper.formattedStringToDuration(getTenantConfigurationManagement()
.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));
final Panel rootPanel = new Panel();
@@ -67,33 +78,36 @@ public class PollingConfigurationView extends CustomComponent {
headerDisSetType.addStyleName("config-panel-header");
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"))
.checkBoxTooltip(i18n.getMessage("configuration.polling.custom.value")).range(minDuration, maxDuration)
.globalDuration(globalPollTime).build();
binder.forField(fieldPollTime.getCheckBox()).bind(ProxySystemConfigWindow::isPollingTime,
ProxySystemConfigWindow::setPollingTime);
getBinder().forField(fieldPollTime.getCheckBox()).bind(ProxySystemConfigPolling::isPollingTime,
ProxySystemConfigPolling::setPollingTime);
binder.forField(fieldPollTime.getDurationField())
getBinder().forField(fieldPollTime.getDurationField())
.withConverter(PollingConfigurationView::localDateTimeToDuration,
PollingConfigurationView::durationToLocalDateTime)
.bind(ProxySystemConfigWindow::getPollingTimeDuration, ProxySystemConfigWindow::setPollingTimeDuration);
.bind(ProxySystemConfigPolling::getPollingTimeDuration,
ProxySystemConfigPolling::setPollingTimeDuration);
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"))
.checkBoxTooltip(i18n.getMessage("configuration.polling.custom.value")).range(minDuration, maxDuration)
.globalDuration(globalOverdueTime).build();
binder.forField(fieldPollingOverdueTime.getCheckBox()).bind(ProxySystemConfigWindow::isPollingOverdue,
ProxySystemConfigWindow::setPollingOverdue);
getBinder().forField(fieldPollingOverdueTime.getCheckBox()).bind(ProxySystemConfigPolling::isPollingOverdue,
ProxySystemConfigPolling::setPollingOverdue);
binder.forField(fieldPollingOverdueTime.getDurationField())
getBinder().forField(fieldPollingOverdueTime.getDurationField())
.withConverter(PollingConfigurationView::localDateTimeToDuration,
PollingConfigurationView::durationToLocalDateTime)
.bind(ProxySystemConfigWindow::getPollingOverdueDuration,
ProxySystemConfigWindow::setPollingOverdueDuration);
.bind(ProxySystemConfigPolling::getPollingOverdueDuration,
ProxySystemConfigPolling::setPollingOverdueDuration);
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());
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;
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.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.tenantconfiguration.repository.ActionAutoCleanupConfigurationItem;
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.VaadinMessageSource;
import com.vaadin.data.Binder;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Link;
import com.vaadin.ui.Panel;
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.
*/
public class RepositoryConfigurationView extends CustomComponent {
public class RepositoryConfigurationView extends BaseConfigurationView<ProxySystemConfigRepository> {
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 final VaadinMessageSource i18n;
private final UiProperties uiProperties;
private final ActionAutoCloseConfigurationItem actionAutocloseConfigurationItem;
private final ActionAutoCleanupConfigurationItem actionAutocleanupConfigurationItem;
private final MultiAssignmentsConfigurationItem multiAssignmentsConfigurationItem;
private ActionAutoCloseConfigurationItem actionAutocloseConfigurationItem;
private ActionAutoCleanupConfigurationItem actionAutocleanupConfigurationItem;
private MultiAssignmentsConfigurationItem multiAssignmentsConfigurationItem;
private CheckBox multiAssignmentsCheckBox;
private final Binder<ProxySystemConfigWindow> binder;
RepositoryConfigurationView(final VaadinMessageSource i18n, final UiProperties uiProperties,
final Binder<ProxySystemConfigWindow> binder) {
final TenantConfigurationManagement tenantConfigurationManagement) {
super(tenantConfigurationManagement);
this.i18n = i18n;
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();
}
@@ -86,20 +99,20 @@ public class RepositoryConfigurationView extends CustomComponent {
gridLayout.setSizeFull();
final CheckBox actionAutoCloseCheckBox = FormComponentBuilder.getCheckBox(
UIComponentIdProvider.REPOSITORY_ACTIONS_AUTOCLOSE_CHECKBOX, binder,
ProxySystemConfigWindow::isActionAutoclose, ProxySystemConfigWindow::setActionAutoclose);
UIComponentIdProvider.REPOSITORY_ACTIONS_AUTOCLOSE_CHECKBOX, getBinder(),
ProxySystemConfigRepository::isActionAutoclose, ProxySystemConfigRepository::setActionAutoclose);
actionAutoCloseCheckBox.setStyleName(DIST_CHECKBOX_STYLE);
actionAutoCloseCheckBox.setEnabled(!binder.getBean().isMultiAssignments());
actionAutocloseConfigurationItem.setEnabled(!binder.getBean().isMultiAssignments());
actionAutoCloseCheckBox.setEnabled(!getBinderBean().isMultiAssignments());
actionAutocloseConfigurationItem.setEnabled(!getBinderBean().isMultiAssignments());
gridLayout.addComponent(actionAutoCloseCheckBox, 0, 0);
gridLayout.addComponent(actionAutocloseConfigurationItem, 1, 0);
multiAssignmentsCheckBox = FormComponentBuilder.getCheckBox(
UIComponentIdProvider.REPOSITORY_MULTI_ASSIGNMENTS_CHECKBOX, binder,
ProxySystemConfigWindow::isMultiAssignments, ProxySystemConfigWindow::setMultiAssignments);
UIComponentIdProvider.REPOSITORY_MULTI_ASSIGNMENTS_CHECKBOX, getBinder(),
ProxySystemConfigRepository::isMultiAssignments, ProxySystemConfigRepository::setMultiAssignments);
multiAssignmentsCheckBox.setStyleName(DIST_CHECKBOX_STYLE);
multiAssignmentsCheckBox.setEnabled(!binder.getBean().isMultiAssignments());
multiAssignmentsConfigurationItem.setEnabled(!binder.getBean().isMultiAssignments());
multiAssignmentsCheckBox.setEnabled(!getBinderBean().isMultiAssignments());
multiAssignmentsConfigurationItem.setEnabled(!getBinderBean().isMultiAssignments());
multiAssignmentsCheckBox.addValueChangeListener(event -> {
actionAutoCloseCheckBox.setEnabled(!event.getValue());
actionAutocloseConfigurationItem.setEnabled(!event.getValue());
@@ -113,8 +126,8 @@ public class RepositoryConfigurationView extends CustomComponent {
gridLayout.addComponent(multiAssignmentsConfigurationItem, 1, 1);
final CheckBox actionAutoCleanupCheckBox = FormComponentBuilder.getCheckBox(
UIComponentIdProvider.REPOSITORY_ACTIONS_AUTOCLEANUP_CHECKBOX, binder,
ProxySystemConfigWindow::isActionAutocleanup, ProxySystemConfigWindow::setActionAutocleanup);
UIComponentIdProvider.REPOSITORY_ACTIONS_AUTOCLEANUP_CHECKBOX, getBinder(),
ProxySystemConfigRepository::isActionAutocleanup, ProxySystemConfigRepository::setActionAutocleanup);
actionAutoCleanupCheckBox.setStyleName(DIST_CHECKBOX_STYLE);
actionAutoCleanupCheckBox.addValueChangeListener(event -> {
if (event.getValue()) {
@@ -144,4 +157,63 @@ public class RepositoryConfigurationView extends CustomComponent {
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;
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.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.tenantconfiguration.rollout.ApprovalConfigurationItem;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import com.vaadin.data.Binder;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Link;
@@ -30,23 +30,26 @@ import com.vaadin.ui.VerticalLayout;
* Provides configuration of the RolloutManagement including enabling/disabling
* of the approval workflow.
*/
public class RolloutConfigurationView extends CustomComponent {
public class RolloutConfigurationView extends BaseConfigurationView<ProxySystemConfigRollout> {
private static final long serialVersionUID = 1L;
private final VaadinMessageSource i18n;
private final UiProperties uiProperties;
private final Binder<ProxySystemConfigWindow> binder;
private final ApprovalConfigurationItem approvalConfigurationItem;
RolloutConfigurationView(final VaadinMessageSource i18n, final UiProperties uiProperties,
final Binder<ProxySystemConfigWindow> binder) {
final TenantConfigurationManagement tenantConfigurationManagement) {
super(tenantConfigurationManagement);
this.i18n = i18n;
this.approvalConfigurationItem = new ApprovalConfigurationItem(i18n);
this.uiProperties = uiProperties;
this.binder = binder;
this.init();
this.approvalConfigurationItem = new ApprovalConfigurationItem(i18n);
}
@Override
public void afterPropertiesSet() {
super.afterPropertiesSet();
init();
}
private void init() {
@@ -69,8 +72,8 @@ public class RolloutConfigurationView extends CustomComponent {
gridLayout.setSizeFull();
final CheckBox approvalCheckbox = FormComponentBuilder.getCheckBox(
UIComponentIdProvider.ROLLOUT_APPROVAL_ENABLED_CHECKBOX, binder,
ProxySystemConfigWindow::isRolloutApproval, ProxySystemConfigWindow::setRolloutApproval);
UIComponentIdProvider.ROLLOUT_APPROVAL_ENABLED_CHECKBOX, getBinder(),
ProxySystemConfigRollout::isRolloutApproval, ProxySystemConfigRollout::setRolloutApproval);
gridLayout.addComponent(approvalCheckbox, 0, 0);
gridLayout.addComponent(approvalConfigurationItem, 1, 0);
@@ -83,4 +86,17 @@ public class RolloutConfigurationView extends CustomComponent {
rootPanel.setContent(vLayout);
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;
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.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
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.SpPermissionChecker;
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.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleNoBorder;
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.UINotification;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import com.google.common.collect.Lists;
import com.vaadin.data.Binder;
@@ -74,58 +49,26 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
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 UiProperties uiProperties;
private final UINotification uINotification;
private final transient SystemManagement systemManagement;
private final transient TenantConfigurationManagement tenantConfigurationManagement;
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 final List<BaseConfigurationView<? extends ProxySystemConfigWindow>> autowiredConfigurationViews;
private List<BaseConfigurationView<? extends ProxySystemConfigWindow>> filteredConfigurationViews;
private Button saveConfigurationBtn;
private Button undoConfigurationBtn;
private final Binder<ProxySystemConfigWindow> binder;
private final List<Binder<? extends ProxySystemConfigWindow>> binders = Lists.newArrayList();
@Autowired
TenantConfigurationDashboardView(final VaadinMessageSource i18n, final UiProperties uiProperties,
final UINotification uINotification, final SystemManagement systemManagement,
final DistributionSetTypeManagement distributionSetTypeManagement,
final TenantConfigurationManagement tenantConfigurationManagement,
final SecurityTokenGenerator securityTokenGenerator,
final ControllerPollProperties controllerPollProperties, final SpPermissionChecker permChecker) {
final UINotification uINotification,
final List<BaseConfigurationView<? extends ProxySystemConfigWindow>> configurationViews) {
this.i18n = i18n;
this.uiProperties = uiProperties;
this.uINotification = uINotification;
this.systemManagement = systemManagement;
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);
this.autowiredConfigurationViews = configurationViews;
}
/**
@@ -133,17 +76,11 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
*/
@PostConstruct
public void init() {
if (defaultDistributionSetTypeLayout.getComponentCount() > 0) {
customComponents.add(defaultDistributionSetTypeLayout);
}
customComponents.add(repositoryConfigurationView);
customComponents.add(rolloutConfigurationView);
customComponents.add(authenticationConfigurationView);
customComponents.add(pollingConfigurationView);
if (customConfigurationViews != null) {
configurationViews.addAll(
customConfigurationViews.stream().filter(ConfigurationGroup::show).collect(Collectors.toList()));
}
// filter the autowired views
filteredConfigurationViews = autowiredConfigurationViews.stream().filter(c -> c.getComponentCount() > 0)
.filter(ConfigurationGroup::show).collect(Collectors.toList());
// get and add the binders
filteredConfigurationViews.forEach(entry -> binders.add(entry.getBinder()));
final Panel rootPanel = new Panel();
rootPanel.setStyleName("tenantconfig-root");
@@ -152,8 +89,7 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
rootLayout.setSizeFull();
rootLayout.setMargin(true);
rootLayout.setSpacing(true);
customComponents.forEach(rootLayout::addComponent);
configurationViews.forEach(rootLayout::addComponent);
filteredConfigurationViews.forEach(rootLayout::addComponent);
final HorizontalLayout buttonContent = saveConfigurationButtonsLayout();
rootLayout.addComponent(buttonContent);
@@ -161,83 +97,11 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
rootPanel.setContent(rootLayout);
setCompositionRoot(rootPanel);
configurationViews.forEach(view -> view.addChangeListener(this));
binder.addStatusChangeListener(event -> {
filteredConfigurationViews.forEach(view -> view.addChangeListener(this));
binders.forEach(binder -> binder.addStatusChangeListener(event -> {
saveConfigurationBtn.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() {
@@ -264,85 +128,17 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
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() {
final boolean isUserInputValid = configurationViews.stream().allMatch(ConfigurationGroup::isUserInputValid);
final boolean isUserInputValid = filteredConfigurationViews.stream()
.allMatch(ConfigurationGroup::isUserInputValid);
if (!isUserInputValid) {
uINotification.displayValidationError(i18n.getMessage("notification.configuration.save.notpossible"));
return;
}
saveSystemConfigBean();
configurationViews.forEach(ConfigurationGroup::save);
// Iterate through all View Beans and call their save implementation
filteredConfigurationViews.forEach(ConfigurationGroup::save);
// More methods
saveConfigurationBtn.setEnabled(false);
undoConfigurationBtn.setEnabled(false);
@@ -350,8 +146,7 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
}
private void undoConfiguration() {
binder.setBean(populateAndGetSystemConfig());
configurationViews.forEach(ConfigurationGroup::undo);
filteredConfigurationViews.forEach(ConfigurationGroup::undo);
// More methods
saveConfigurationBtn.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.ui.common.builder.LabelBuilder;
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.utils.VaadinMessageSource;
@@ -41,7 +41,7 @@ public class CertificateAuthenticationConfigurationItem extends VerticalLayout {
* System config window binder
*/
public CertificateAuthenticationConfigurationItem(final VaadinMessageSource i18n,
final Binder<ProxySystemConfigWindow> binder) {
final Binder<ProxySystemConfigAuthentication> binder) {
this.setSpacing(false);
this.setMargin(false);
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.setWidth("100%");
binder.bind(caRootAuthorityTextField, ProxySystemConfigWindow::getCaRootAuthority,
ProxySystemConfigWindow::setCaRootAuthority);
binder.bind(caRootAuthorityTextField, ProxySystemConfigAuthentication::getCaRootAuthority,
ProxySystemConfigAuthentication::setCaRootAuthority);
caRootAuthorityLayout.addComponent(caRootAuthorityLabel);
caRootAuthorityLayout.setExpandRatio(caRootAuthorityLabel, 0);
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.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.decorators.SPUIButtonStyleSmall;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
@@ -34,7 +34,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Vertica
private final transient SecurityTokenGenerator securityTokenGenerator;
private final VerticalLayout detailLayout;
private final Binder<ProxySystemConfigWindow> binder;
private final Binder<ProxySystemConfigAuthentication> binder;
/**
* Constructor for GatewaySecurityTokenAuthenticationConfigurationItem
@@ -47,7 +47,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Vertica
* System config window binder
*/
public GatewaySecurityTokenAuthenticationConfigurationItem(final VaadinMessageSource i18n,
final SecurityTokenGenerator securityTokenGenerator, final Binder<ProxySystemConfigWindow> binder) {
final SecurityTokenGenerator securityTokenGenerator, final Binder<ProxySystemConfigAuthentication> binder) {
this.securityTokenGenerator = securityTokenGenerator;
this.binder = binder;
this.setSpacing(false);
@@ -68,7 +68,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Vertica
final Label gatewayTokenLabel = new LabelBuilder().id("gatewaysecuritytokenkey").name("").buildLabel();
gatewayTokenLabel.addStyleName("gateway-token-label");
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();
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.TenantConfiguration;
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.utils.UIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.VaadinMessageSource;
@@ -68,7 +68,7 @@ public class ActionAutoCleanupConfigurationItem extends VerticalLayout {
* @param i18n
* VaadinMessageSource
*/
public ActionAutoCleanupConfigurationItem(final Binder<ProxySystemConfigWindow> binder,
public ActionAutoCleanupConfigurationItem(final Binder<ProxySystemConfigRepository> binder,
final VaadinMessageSource i18n) {
this.i18n = i18n;
this.setSpacing(false);
@@ -84,8 +84,8 @@ public class ActionAutoCleanupConfigurationItem extends VerticalLayout {
actionStatusCombobox.removeStyleName(ValoTheme.COMBOBOX_SMALL);
actionStatusCombobox.addStyleName(ValoTheme.COMBOBOX_TINY);
actionStatusCombobox.setWidth(200.0F, Unit.PIXELS);
binder.bind(actionStatusCombobox, ProxySystemConfigWindow::getActionCleanupStatus,
ProxySystemConfigWindow::setActionCleanupStatus);
binder.bind(actionStatusCombobox, ProxySystemConfigRepository::getActionCleanupStatus,
ProxySystemConfigRepository::setActionCleanupStatus);
actionExpiryInput = new TextFieldBuilder(TenantConfiguration.VALUE_MAX_SIZE).buildTextComponent();
actionExpiryInput.setId(UIComponentIdProvider.SYSTEM_CONFIGURATION_ACTION_CLEANUP_ACTION_EXPIRY);
actionExpiryInput.setWidth(55, Unit.PIXELS);
@@ -97,7 +97,7 @@ public class ActionAutoCleanupConfigurationItem extends VerticalLayout {
} catch (final NumberFormatException ex) {
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(actionStatusCombobox);

View File

@@ -8,7 +8,7 @@
*/
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.utils.VaadinMessageSource;
@@ -39,7 +39,7 @@ public class MultiAssignmentsConfigurationItem extends VerticalLayout {
* System config window binder
*/
public MultiAssignmentsConfigurationItem(final VaadinMessageSource i18n,
final Binder<ProxySystemConfigWindow> binder) {
final Binder<ProxySystemConfigRepository> binder) {
this.i18n = i18n;
this.setSpacing(false);
this.setMargin(false);

View File

@@ -8,7 +8,7 @@
*/
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.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
@@ -42,7 +42,7 @@ public class SystemConfigWindowLayoutComponentBuilder {
*
* @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(
UIComponentIdProvider.SYSTEM_CONFIGURATION_DEFAULTDIS_COMBOBOX, null,
dependencies.getI18n().getMessage("caption.type"), null, false, ProxyTypeInfo::getKeyAndName,
@@ -51,8 +51,8 @@ public class SystemConfigWindowLayoutComponentBuilder {
dsTypeCombo.addStyleName(ValoTheme.COMBOBOX_TINY);
dsTypeCombo.setWidth(330.0F, Unit.PIXELS);
binder.forField(dsTypeCombo).bind(ProxySystemConfigWindow::getDsTypeInfo,
ProxySystemConfigWindow::setDsTypeInfo);
binder.forField(dsTypeCombo).bind(ProxySystemConfigDsType::getDsTypeInfo,
ProxySystemConfigDsType::setDsTypeInfo);
return dsTypeCombo;
}