diff --git a/3rd-dependencies/listDeps.sh b/3rd-dependencies/listDeps.sh
old mode 100755
new mode 100644
diff --git a/README.md b/README.md
index ff93c9285..e61e5e9d1 100644
--- a/README.md
+++ b/README.md
@@ -52,7 +52,7 @@ $ java -jar ./examples/hawkbit-mgmt-api-client/target/hawkbit-mgmt-api-client-#v
* The master branch contains future development towards 0.2. We are currently focusing on:
* Rollout Management for large scale rollouts.
* Clustering capabilities for the update server.
- * Upgrade of Spring Boot and Vaadin depedencies.
+ * Upgrade of Spring Boot and Vaadin dependencies.
* And of course tons of usability improvements and bug fixes.
@@ -64,7 +64,7 @@ $ java -jar ./examples/hawkbit-mgmt-api-client/target/hawkbit-mgmt-api-client-#v
`hawkbit-autoconfigure` : spring-boot auto-configuration.
`hawkbit-dmf-api` : API for the Device Management Integration.
`hawkbit-dmf-amqp` : AMQP endpoint implementation for the DMF API.
-`hawkbit-repository` : repository implemenation based on SQL for all meta-data.
+`hawkbit-repository` : repository implementation based on SQL for all meta-data.
`hawkbit-http-security` : implementation for security filters for HTTP.
`hawkbit-rest-api` : API classes for the REST Management API.
`hawkbit-rest-resource` : HTTP REST endpoints for the Management and the Direct Device API.
diff --git a/examples/hawkbit-device-simulator/pom.xml b/examples/hawkbit-device-simulator/pom.xml
index a23051124..c74eace3e 100644
--- a/examples/hawkbit-device-simulator/pom.xml
+++ b/examples/hawkbit-device-simulator/pom.xml
@@ -139,7 +139,7 @@
com.vaadinvaadin-bom
- 7.6.3
+ ${vaadin.version}pomimport
diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulatorStartup.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulatorStartup.java
index b772bae1f..19367a9d4 100644
--- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulatorStartup.java
+++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulatorStartup.java
@@ -16,6 +16,7 @@ import org.eclipse.hawkbit.simulator.amqp.SpSenderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
@@ -25,6 +26,7 @@ import org.springframework.stereotype.Component;
*
*/
@Component
+@ConditionalOnProperty(prefix = "hawkbit.device.simulator", name = "autostart", matchIfMissing = true)
public class SimulatorStartup implements ApplicationListener {
private static final Logger LOGGER = LoggerFactory.getLogger(SimulatorStartup.class);
diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java
index f58355980..8fba3ac5b 100644
--- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java
+++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java
@@ -39,6 +39,12 @@ public class AmqpProperties {
*/
private String deadLetterExchange = "simulator.deadletter";
+ /**
+ * Message time to live (ttl) for the deadletter queue. Default ttl is 1
+ * hour.
+ */
+ private int deadLetterTtl = 60_000;
+
public String getReceiverConnectorQueueFromSp() {
return receiverConnectorQueueFromSp;
}
@@ -70,4 +76,12 @@ public class AmqpProperties {
public void setSenderForSpExchange(final String senderForSpExchange) {
this.senderForSpExchange = senderForSpExchange;
}
+
+ public int getDeadLetterTtl() {
+ return deadLetterTtl;
+ }
+
+ public void setDeadLetterTtl(final int deadLetterTtl) {
+ this.deadLetterTtl = deadLetterTtl;
+ }
}
diff --git a/examples/hawkbit-example-app/README.md b/examples/hawkbit-example-app/README.md
index ecbec93c3..068acdd15 100644
--- a/examples/hawkbit-example-app/README.md
+++ b/examples/hawkbit-example-app/README.md
@@ -4,16 +4,20 @@ The hawkBit example application is a standalone spring-boot application with an
We have have described several options for you to get access to the example.
## Try out the example application in our hawkBit sandbox on Bluemix
-- try out Management UI https://hawkbit.eu-gb.mybluemix.net/UI
-- try out Management API https://hawkbit.eu-gb.mybluemix.net/rest/v1/targets (don't forget basic auth header)
-- try out DDI API https://hawkbit.eu-gb.mybluemix.net/DEFAULT/controller/v1/MYTESTDEVICE
+- try out Management UI https://hawkbit.eu-gb.mybluemix.net/UI (username: admin, passwd: admin)
+- try out Management API https://hawkbit.eu-gb.mybluemix.net/rest/v1/targets (don't forget basic auth header; username: admin, passwd: admin)
+- try out DDI API https://hawkbit.eu-gb.mybluemix.net/DEFAULT/controller/v1/MYTESTDEVICE (authentication disabled)
## On your own workstation
### Run
```
java -jar examples/hawkbit-example-app/target/hawkbit-example-app-*-SNAPSHOT.jar
```
+
+_(Note: you have to add the JDBC driver also to your class path if you intend to use another database than H2.)_
+
Or:
+
```
run org eclipse.hawkbit.app.Start
```
diff --git a/examples/hawkbit-example-app/src/main/resources/application.properties b/examples/hawkbit-example-app/src/main/resources/application.properties
index 7864087c8..64661d2ec 100644
--- a/examples/hawkbit-example-app/src/main/resources/application.properties
+++ b/examples/hawkbit-example-app/src/main/resources/application.properties
@@ -21,7 +21,7 @@ spring.rabbitmq.password=guest
spring.rabbitmq.virtualHost=/
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
-hawkbit.dmf.rabbitmq.deadLetterQueue=dmf_connector_deadletter
+hawkbit.dmf.rabbitmq.deadLetterQueue=dmf_connector_deadletter_ttl
hawkbit.dmf.rabbitmq.deadLetterExchange=dmf.connector.deadletter
hawkbit.dmf.rabbitmq.receiverQueue=dmf_receiver
diff --git a/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties b/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties
index 198fce255..488777b8d 100644
--- a/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties
+++ b/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties
@@ -42,6 +42,6 @@ hawkbit.controller.minPollingTime=00:00:30
# Configuration for RabbitMQ integration
-hawkbit.dmf.rabbitmq.deadLetterQueue=dmf_connector_deadletter
+hawkbit.dmf.rabbitmq.deadLetterQueue=dmf_connector_deadletter_ttl
hawkbit.dmf.rabbitmq.deadLetterExchange=dmf.connector.deadletter
hawkbit.dmf.rabbitmq.receiverQueue=dmf_receiver
\ No newline at end of file
diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java
index acbcb453b..20a11713f 100644
--- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java
+++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java
@@ -8,9 +8,6 @@
*/
package org.eclipse.hawkbit.amqp;
-import java.util.HashMap;
-import java.util.Map;
-
import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
@@ -18,6 +15,7 @@ import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
+import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
@@ -31,15 +29,31 @@ import org.springframework.context.annotation.Bean;
* {@code amqp} to use a AMQP for communication with SP enabled devices.
*
*/
-@EnableConfigurationProperties(AmqpProperties.class)
+@EnableConfigurationProperties({ AmqpProperties.class, AmqpDeadletterProperties.class })
public class AmqpConfiguration {
@Autowired
protected AmqpProperties amqpProperties;
+ @Autowired
+ protected AmqpDeadletterProperties amqpDeadletterProperties;
+
@Autowired
private ConnectionFactory connectionFactory;
+ /**
+ * Create a {@link RabbitAdmin} and ignore declaration exceptions.
+ * {@link RabbitAdmin#setIgnoreDeclarationExceptions(boolean)}
+ *
+ * @return the bean
+ */
+ @Bean
+ public RabbitAdmin rabbitAdmin() {
+ final RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
+ rabbitAdmin.setIgnoreDeclarationExceptions(true);
+ return rabbitAdmin;
+ }
+
/**
* Method to set the Jackson2JsonMessageConverter.
*
@@ -59,7 +73,8 @@ public class AmqpConfiguration {
*/
@Bean
public Queue receiverQueue() {
- return new Queue(amqpProperties.getReceiverQueue(), true, false, false, getDeadLetterExchangeArgs());
+ return new Queue(amqpProperties.getReceiverQueue(), true, false, false,
+ amqpDeadletterProperties.getDeadLetterExchangeArgs(amqpProperties.getDeadLetterExchange()));
}
/**
@@ -79,7 +94,7 @@ public class AmqpConfiguration {
*/
@Bean
public Queue deadLetterQueue() {
- return new Queue(amqpProperties.getDeadLetterQueue());
+ return amqpDeadletterProperties.createDeadletterQueue(amqpProperties.getDeadLetterQueue());
}
/**
@@ -149,10 +164,4 @@ public class AmqpConfiguration {
return containerFactory;
}
- private Map getDeadLetterExchangeArgs() {
- final Map args = new HashMap<>();
- args.put("x-dead-letter-exchange", amqpProperties.getDeadLetterExchange());
- return args;
- }
-
}
diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java
new file mode 100644
index 000000000..7ed5e90c1
--- /dev/null
+++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpDeadletterProperties.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2015 Bosch Software Innovations 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.amqp;
+
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.amqp.core.Queue;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+/**
+ * Bean which holds the necessary properties for configuring the AMQP deadletter
+ * queue.
+ */
+@ConfigurationProperties("hawkbit.dmf.rabbitmq.deadLetter")
+public class AmqpDeadletterProperties {
+
+ /**
+ * Message time to live (ttl) for the deadletter queue. Default ttl is 3
+ * weeks.
+ */
+ private long ttl = Duration.ofDays(21).toMillis();
+
+ /**
+ * Return the deadletter arguments.
+ *
+ * @param exchange
+ * the deadletter exchange
+ * @return map which holds the properties
+ */
+ public Map getDeadLetterExchangeArgs(final String exchange) {
+ final Map args = new HashMap<>();
+ args.put("x-dead-letter-exchange", exchange);
+ return args;
+ }
+
+ /**
+ * Create a deadletter queue with ttl for messages
+ *
+ * @param queueName
+ * the deadlette queue name
+ * @return the deadletter queue
+ */
+ public Queue createDeadletterQueue(final String queueName) {
+ return new Queue(queueName, true, false, false, getTTLArgs());
+ }
+
+ private Map getTTLArgs() {
+ final Map args = new HashMap<>();
+ args.put("x-message-ttl", getTtl());
+ return args;
+ }
+
+ public long getTtl() {
+ return ttl;
+ }
+
+ public void setTtl(final long ttl) {
+ this.ttl = ttl;
+ }
+
+}
diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpProperties.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpProperties.java
index 38c6d34b3..ce6068ce8 100644
--- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpProperties.java
+++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpProperties.java
@@ -21,7 +21,7 @@ public class AmqpProperties {
/**
* DMF API dead letter queue.
*/
- private String deadLetterQueue = "dmf_connector_deadletter";
+ private String deadLetterQueue = "dmf_connector_deadletter_ttl";
/**
* DMF API dead letter exchange.
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java
index 7b97f5037..b3821e5f3 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java
@@ -11,9 +11,6 @@ package org.eclipse.hawkbit;
import javax.persistence.EntityManager;
import javax.transaction.Transaction;
-import org.eclipse.hawkbit.repository.RolloutManagement;
-import org.eclipse.hawkbit.repository.SystemManagement;
-import org.eclipse.hawkbit.repository.exception.TenantNotExistException;
import org.eclipse.hawkbit.tenancy.TenantAware;
import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.springframework.beans.factory.annotation.Autowired;
@@ -38,38 +35,12 @@ public class MultiTenantJpaTransactionManager extends JpaTransactionManager {
protected void doBegin(final Object transaction, final TransactionDefinition definition) {
super.doBegin(transaction, definition);
- final EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager
- .getResource(getEntityManagerFactory());
- final EntityManager em = emHolder.getEntityManager();
-
- if (notTenantManagement(definition) && notCurrentTenantKeyGenerator(definition)
- && notRolloutScheduler(definition) && notGetOrCreateTenantMetadata(definition)) {
-
- final String currentTenant = tenantAware.getCurrentTenant();
- if (currentTenant == null) {
- throw new TenantNotExistException("Tenant Unknown. Canceling transaction.");
- }
-
+ final String currentTenant = tenantAware.getCurrentTenant();
+ if (currentTenant != null) {
+ final EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager
+ .getResource(getEntityManagerFactory());
+ final EntityManager em = emHolder.getEntityManager();
em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase());
}
}
-
- private boolean notGetOrCreateTenantMetadata(final TransactionDefinition definition) {
- return !definition.getName()
- .startsWith(SystemManagement.class.getCanonicalName() + ".getOrCreateTenantMetadata");
- }
-
- private boolean notRolloutScheduler(final TransactionDefinition definition) {
- return !definition.getName().startsWith(RolloutManagement.class.getCanonicalName() + ".rolloutScheduler");
- }
-
- private boolean notCurrentTenantKeyGenerator(final TransactionDefinition definition) {
- return !definition.getName()
- .startsWith(SystemManagement.class.getCanonicalName() + ".currentTenantKeyGenerator");
- }
-
- private boolean notTenantManagement(final TransactionDefinition definition) {
- return !definition.getName().startsWith(SystemManagement.class.getCanonicalName() + ".deleteTenant")
- && !definition.getName().startsWith(SystemManagement.class.getCanonicalName() + ".findTenants");
- }
}
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java
index efead853e..13e37abed 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java
@@ -59,6 +59,10 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.annotation.Isolation;
+<<<<<<< HEAD
+=======
+import org.springframework.transaction.annotation.Propagation;
+>>>>>>> eclipse/master
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springframework.transaction.support.TransactionTemplate;
@@ -135,7 +139,7 @@ public class RolloutManagement {
/**
* Retrieves all rollouts.
- *
+ *
* @param page
* the page request to sort and limit the result
* @return a page of found rollouts
@@ -147,7 +151,7 @@ public class RolloutManagement {
/**
* Retrieves all rollouts found by the given specification.
- *
+ *
* @param specification
* the specification to filter rollouts
* @param page
@@ -164,7 +168,7 @@ public class RolloutManagement {
/**
* Retrieves a specific rollout by its ID.
- *
+ *
* @param rolloutId
* the ID of the rollout to retrieve
* @return the founded rollout or {@code null} if rollout with given ID does
@@ -181,13 +185,13 @@ public class RolloutManagement {
* which are effected by this rollout to create. The targets will then be
* split up into groups. The size of the groups can be defined in the
* {@code groupSize} parameter.
- *
+ *
* The rollout is not started. Only the preparation of the rollout is done,
* persisting and creating all the necessary groups. The Rollout and the
* groups are persisted in {@link RolloutStatus#READY} and
* {@link RolloutGroupStatus#READY} so they can be started
* {@link #startRollout(Rollout)}.
- *
+ *
* @param rollout
* the rollout entity to create
* @param amountGroup
@@ -196,7 +200,7 @@ public class RolloutManagement {
* the rolloutgroup conditions and actions which should be
* applied for each {@link RolloutGroup}
* @return the persisted rollout.
- *
+ *
* @throws IllegalArgumentException
* in case the given groupSize is zero or lower.
*/
@@ -216,22 +220,22 @@ public class RolloutManagement {
* will be done synchronously and will be returned. The targets will then be
* split up into groups. The size of the groups can be defined in the
* {@code groupSize} parameter.
- *
+ *
* The creation of the rollout groups is executed asynchronously due it
* might take some time to split up the targets into groups. The creation of
* the {@link RolloutGroup} is published as event
* {@link RolloutGroupCreatedEvent}.
- *
+ *
* The rollout is in status {@link RolloutStatus#CREATING} until all rollout
* groups has been created and the targets are split up, then the rollout
* will change the status to {@link RolloutStatus#READY}.
- *
+ *
* The rollout is not started. Only the preparation of the rollout is done,
* persisting and creating all the necessary groups. The Rollout and the
* groups are persisted in {@link RolloutStatus#READY} and
* {@link RolloutGroupStatus#READY} so they can be started
* {@link #startRollout(Rollout)}.
- *
+ *
* @param rollout
* the rollout to be created
* @param amountGroup
@@ -260,13 +264,7 @@ public class RolloutManagement {
entityManager.flush();
executor.execute(() -> {
try {
- final DefaultTransactionDefinition def = new DefaultTransactionDefinition();
- def.setName("creatingRollout");
- def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
- new TransactionTemplate(txManager, def).execute(status -> {
- createRolloutGroups(amountGroup, conditions, savedRollout);
- return null;
- });
+ createRolloutGroupsInNewTransaction(amountGroup, conditions, savedRollout);
} finally {
creatingRollouts.remove(savedRollout.getName());
}
@@ -289,13 +287,22 @@ public class RolloutManagement {
}
}
+ private Rollout createRolloutGroupsInNewTransaction(final int amountOfGroups, final RolloutGroupConditions conditions,
+ final Rollout savedRollout) {
+ final DefaultTransactionDefinition def = new DefaultTransactionDefinition();
+ def.setName("creatingRollout");
+ def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
+ return new TransactionTemplate(txManager, def)
+ .execute(status -> createRolloutGroups(amountOfGroups, conditions, savedRollout));
+ }
+
/**
* Method for creating rollout groups and calculating group sizes. Group
* sizes are calculated by dividing the total count of targets through the
* amount of given groups. In same cases this will lead to less rollout
* groups than given by client.
- *
- * @param amountGroup
+ *
+ * @param amountOfGroups
* the amount of groups
* @param conditions
* the rollout group conditions
@@ -303,17 +310,17 @@ public class RolloutManagement {
* the rollout
* @return the rollout with created groups
*/
- private Rollout createRolloutGroups(final int amountGroup, final RolloutGroupConditions conditions,
+ private Rollout createRolloutGroups(final int amountOfGroups, final RolloutGroupConditions conditions,
final Rollout savedRollout) {
int pageIndex = 0;
int groupIndex = 0;
final Long totalCount = savedRollout.getTotalTargets();
- final int groupSize = (int) Math.ceil((double) totalCount / (double) amountGroup);
+ final int groupSize = (int) Math.ceil((double) totalCount / (double) amountOfGroups);
// validate if the amount of groups that will be created are the amount
// of groups that the client what's to have created.
- int amountGroupValidated = amountGroup;
+ int amountGroupValidated = amountOfGroups;
final int amountGroupCreation = (int) (Math.ceil((double) totalCount / (double) groupSize));
- if (amountGroupCreation == (amountGroup - 1)) {
+ if (amountGroupCreation == (amountOfGroups - 1)) {
amountGroupValidated--;
}
RolloutGroup lastSavedGroup = null;
@@ -357,14 +364,14 @@ public class RolloutManagement {
* for each affected target in the rollout. The actions of the first group
* will be started immediately {@link RolloutGroupStatus#RUNNING} as the
* other groups will be {@link RolloutGroupStatus#SCHEDULED} state.
- *
+ *
* The rollout itself will be then also in {@link RolloutStatus#RUNNING}.
- *
+ *
* @param rollout
* the rollout to be started
- *
+ *
* @return started rollout
- *
+ *
* @throws RolloutIllegalStateException
* if given rollout is not in {@link RolloutStatus#READY}. Only
* ready rollouts can be started.
@@ -386,14 +393,14 @@ public class RolloutManagement {
* actions of the first group will be started immediately
* {@link RolloutGroupStatus#RUNNING} as the other groups will be
* {@link RolloutGroupStatus#SCHEDULED} state.
- *
+ *
* The rollout itself will be then also in {@link RolloutStatus#RUNNING}.
- *
+ *
* @param rollout
* the rollout to be started
- *
+ *
* @return the started rollout
- *
+ *
* @throws RolloutIllegalStateException
* if given rollout is not in {@link RolloutStatus#READY}. Only
* ready rollouts can be started.
@@ -461,14 +468,14 @@ public class RolloutManagement {
* {@link RolloutGroupStatus#SCHEDULED} will not be started and keep in
* {@link RolloutGroupStatus#SCHEDULED} state until the rollout is
* {@link RolloutManagement#resumeRollout(Rollout)}.
- *
+ *
* Switching the rollout status to {@link RolloutStatus#PAUSED} is
* sufficient due the {@link #checkRunningRollouts(long)} will not check
* this rollout anymore.
- *
+ *
* @param rollout
* the rollout to be paused.
- *
+ *
* @throws RolloutIllegalStateException
* if given rollout is not in {@link RolloutStatus#RUNNING}.
* Only running rollouts can be paused.
@@ -496,7 +503,7 @@ public class RolloutManagement {
* Resumes a paused rollout. The rollout switches back to
* {@link RolloutStatus#RUNNING} state which is then picked up again by the
* {@link #checkRunningRollouts(long)}.
- *
+ *
* @param rollout
* the rollout to be resumed
* @throws RolloutIllegalStateException
@@ -521,7 +528,7 @@ public class RolloutManagement {
* Checking running rollouts. Rollouts which are checked updating the
* {@link Rollout#setLastCheck(long)} to indicate that the current instance
* is handling the specific rollout. This code should run as system-code.
- *
+ *
*
* {@code
* SystemSecurityContext.runAsSystem(new Callable() {
@@ -531,21 +538,21 @@ public class RolloutManagement {
* });
* }
*
- *
+ *
* This method is attend to be called by a scheduler.
* {@link RolloutScheduler}. And must be running in an transaction so it's
* splitted from the scheduler.
- *
+ *
* Rollouts which are currently running are investigated, by means the
* error- and finish condition of running groups in this rollout are
* evaluated.
- *
+ *
* @param delayBetweenChecks
* the time in milliseconds of the delay between the further and
* this check. This check is only applied if the last check is
* less than (lastcheck-delay).
*/
- @Transactional(isolation = Isolation.READ_UNCOMMITTED)
+ @Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_UNCOMMITTED)
@Modifying
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_SYSTEM_CODE)
@@ -728,7 +735,7 @@ public class RolloutManagement {
/**
* Count rollouts by specified filter text.
- *
+ *
* @param searchText
* name or description
* @return total count rollouts for specified filter text.
@@ -750,7 +757,7 @@ public class RolloutManagement {
/**
* * Retrieves a specific rollout by its ID.
- *
+ *
* @param pageable
* the page request to sort and limit the result
* @param searchText
@@ -768,7 +775,7 @@ public class RolloutManagement {
/**
* Retrieves a specific rollout by its name.
- *
+ *
* @param rolloutName
* the name of the rollout to retrieve
* @return the founded rollout or {@code null} if rollout with given name
@@ -781,10 +788,10 @@ public class RolloutManagement {
/**
* Update rollout details.
- *
+ *
* @param rollout
* rollout to be updated
- *
+ *
* @return Rollout updated rollout
*/
@NotNull
@@ -798,7 +805,7 @@ public class RolloutManagement {
/**
* Get count of targets in different status in rollout.
- *
+ *
* @param page
* the page request to sort and limit the result
* @return a list of rollouts with details of targets count for different
@@ -860,7 +867,7 @@ public class RolloutManagement {
/***
* Get finished percentage details for a specified group which is in running
* state.
- *
+ *
* @param rolloutId
* the ID of the {@link Rollout}
* @param rolloutGroup
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java
index 2492930f2..787d5e8dc 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java
@@ -165,6 +165,7 @@ public class SystemManagement {
* @return the {@link CurrentTenantKeyGenerator}
*/
@Bean
+ @Transactional(propagation = Propagation.SUPPORTS)
public CurrentTenantKeyGenerator currentTenantKeyGenerator() {
return new CurrentTenantKeyGenerator();
}
@@ -207,7 +208,6 @@ public class SystemManagement {
@NotNull
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_SYSTEM_CODE)
- // tenant independent
public List findTenants() {
return tenantMetaDataRepository.findAll().stream().map(md -> md.getTenant()).collect(Collectors.toList());
}
@@ -222,7 +222,6 @@ public class SystemManagement {
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
@Modifying
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
- // tenant independent
public void deleteTenant(@NotNull final String tenant) {
cacheManager.evictCaches(tenant);
cacheManager.getCache("currentTenant").evict(currentTenantKeyGenerator().generate(null, null));
diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroup.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroup.java
index f1d4fe718..7a46b15b1 100644
--- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroup.java
+++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/RolloutTargetGroup.java
@@ -24,13 +24,18 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
+import org.eclipse.persistence.annotations.ExistenceChecking;
+import org.eclipse.persistence.annotations.ExistenceType;
+
/**
- * @author Michael Hirsch
- *
+ * Entity with JPA annotation to store the information which {@link Target} is
+ * in a specific {@link RolloutGroup}.
+ *
*/
@IdClass(RolloutTargetGroupId.class)
@Entity
@Table(name = "sp_rollouttargetgroup")
+@ExistenceChecking(ExistenceType.ASSUME_NON_EXISTENCE)
public class RolloutTargetGroup implements Serializable {
private static final long serialVersionUID = 1L;
diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java
index 1dd4c9823..67b9b5a26 100644
--- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java
+++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java
@@ -78,6 +78,22 @@ public class MultiTenancyEntityTest extends AbstractIntegrationTest {
assertThat(findTargetsForTenant).hasSize(1);
}
+ @Test
+ @Description(value = "Ensures that tenant with proper permissions can read and delete other tenants.")
+ @WithUser(tenantId = "mytenant", allSpPermissions = true)
+ public void deleteAnotherTenantPossible() throws Exception {
+ // create target for another tenant
+ final String anotherTenant = "anotherTenant";
+ final String controllerAnotherTenant = "anotherController";
+ createTargetForTenant(controllerAnotherTenant, anotherTenant);
+
+ assertThat(systemManagement.findTenants()).as("Expected number if tenants before deletion is").hasSize(3);
+
+ systemManagement.deleteTenant(anotherTenant);
+
+ assertThat(systemManagement.findTenants()).as("Expected number if tenants after deletion is").hasSize(2);
+ }
+
@Test
@Description(value = "Ensures that tenant metadata is retrieved for the current tenant.")
@WithUser(tenantId = "mytenant", autoCreateTenant = false, allSpPermissions = true)
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java
index bb48c515a..29bea30eb 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java
@@ -16,6 +16,7 @@ import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
+import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -101,8 +102,8 @@ public class BaseSwModuleBeanQuery extends AbstractBeanQuery
+ */
+ public static String loadAndFormatUsername(final String username) {
+ return loadAndFormatUsername(username, 100);
+ }
+
+ /**
+ * Load user details by {@link BaseEntity#getCreatedBy()} and format the
+ * user name. Use {@link UserDetailsFormatter#loadAndFormatUsername(String)}
+ *
+ * @param baseEntity
+ * the entity
+ * @return the formatted 'created at user name' (max 100 characters) cannot
+ * be
+ */
+ public static String loadAndFormatCreatedBy(final BaseEntity baseEntity) {
+ if (baseEntity == null || baseEntity.getCreatedBy() == null) {
+ return StringUtils.EMPTY;
+ }
+
+ return loadAndFormatUsername(baseEntity.getCreatedBy());
+ }
+
+ /**
+ * Load user details by {@link BaseEntity#getLastModifiedBy()} and format
+ * the user name. Use
+ * {@link UserDetailsFormatter#loadAndFormatUsername(String)}
+ *
+ * @param baseEntity
+ * the entity
+ * @return the formatted 'last modefied by user name' (max 100 characters)
+ * cannot be
+ */
+ public static String loadAndFormatLastModifiedBy(final BaseEntity baseEntity) {
+ if (baseEntity == null || baseEntity.getLastModifiedBy() == null) {
+ return StringUtils.EMPTY;
+ }
+
+ return loadAndFormatUsername(baseEntity.getLastModifiedBy());
+ }
+
+ /**
+ * Load user details by the current session information and format the user
+ * name to max 12 characters. @see
+ * {@link UserDetailsFormatter#loadAndFormatUsername(String, int)}
+ *
+ * @return the formatted user name (max 12 characters) cannot be
+ */
+ public static String formatCurrentUsername() {
+ return loadAndFormatUsername(getCurrentUser().getUsername(), 5);
+ }
+
+ /**
+ * Load user details by the user name and format the user name. If the
+ * loaded {@link UserDetails} is not an instance of a {@link UserPrincipal},
+ * then just the {@link UserDetails#getUsername()} will return.
+ *
+ * If first and last name available, they will combined. Otherwise the
+ * {@link UserPrincipal#getLoginname()} will formatted. The formatted name
+ * is reduced to 100 characters.
+ *
+ * @param username
+ * the user name
+ * @param expectedNameLength
+ * the name size of each name part
+ * @return the formatted user name (max expectedNameLength characters)
+ * cannot be
+ */
+ public static String loadAndFormatUsername(final String username, final int expectedNameLength) {
+ final UserDetails userDetails = loadUserByUsername(username);
+ return formatUserName(expectedNameLength, userDetails);
+ }
+
+ private static String formatUserName(final int expectedNameLength, final UserDetails userDetails) {
+ if (!(userDetails instanceof UserPrincipal)) {
+ return userDetails.getUsername();
+ }
+
+ final UserPrincipal userPrincipal = (UserPrincipal) userDetails;
+
+ String firstname = StringUtils.defaultIfEmpty(userPrincipal.getFirstname(), StringUtils.EMPTY);
+
+ if (!StringUtils.isEmpty(firstname)) {
+ firstname += DETAIL_SEPERATOR;
+ }
+
+ final String firstAndLastname = firstname
+ + StringUtils.defaultIfEmpty(userPrincipal.getLastname(), StringUtils.EMPTY);
+
+ final String trimmedUsername = trimAndFormatDetail(firstAndLastname, expectedNameLength);
+
+ if (StringUtils.isEmpty(trimmedUsername)) {
+ return trimAndFormatDetail(userPrincipal.getLoginname(), expectedNameLength);
+ }
+ return trimmedUsername;
+ }
+
+ /**
+ * Format the current tenant. The information is loaded by the current
+ * session information.
+ *
+ * @return the formatted user name (max 8 characters) can be
+ */
+ public static String formatCurrentTenant() {
+ final UserDetails userDetails = getCurrentUser();
+ if (!(userDetails instanceof UserPrincipal)) {
+ return null;
+ }
+
+ final UserPrincipal userPrincipal = (UserPrincipal) userDetails;
+ return trimAndFormatDetail(userPrincipal.getTenant(), 8);
+ }
+
+ private static UserDetails getCurrentUser() {
+ final SecurityContext context = (SecurityContext) VaadinService.getCurrentRequest().getWrappedSession()
+ .getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
+ return (UserDetails) context.getAuthentication().getPrincipal();
+ }
+
+ private static String trimAndFormatDetail(final String formatString, final int expectedDetailLength) {
+ final String detail = StringUtils.defaultIfEmpty(formatString, StringUtils.EMPTY);
+ final String trimmedDetail = StringUtils.substring(detail, 0, expectedDetailLength);
+ if (StringUtils.length(detail) > expectedDetailLength) {
+ return trimmedDetail + TRIM_APPENDIX;
+ }
+ return trimmedDetail;
+ }
+
+ private static UserDetails loadUserByUsername(final String username) {
+ final UserDetailsService userDetailsService = SpringContextHelper.getBean(UserDetailsService.class);
+ try {
+ final UserDetails loadUserByUsername = userDetailsService.loadUserByUsername(username);
+ if (loadUserByUsername == null) {
+ throw new UsernameNotFoundException("User not found " + username);
+ }
+ return loadUserByUsername;
+ } catch (final UsernameNotFoundException e) {
+ return new User(username, "", Collections.emptyList());
+ }
+ }
+}
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java
index 969436904..360a9f925 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java
@@ -171,9 +171,7 @@ public abstract class AbstractTableDetailsLayout extends
}
private Label createHeaderCaption() {
- final Label captionLabel = SPUIComponentProvider.getLabel(getDefaultCaption(),
- SPUILabelDefinitions.SP_WIDGET_CAPTION);
- return captionLabel;
+ return SPUIComponentProvider.getLabel(getDefaultCaption(), SPUILabelDefinitions.SP_WIDGET_CAPTION);
}
protected VerticalLayout getTabLayout() {
@@ -213,22 +211,22 @@ public abstract class AbstractTableDetailsLayout extends
populateDetailsWidget();
}
- protected void updateLogLayout(final VerticalLayout changeLogLayout, final Long lastModifiedAt,
- final String lastModifiedBy, final Long createdAt, final String createdBy, final I18N i18n) {
- changeLogLayout.removeAllComponents();
- changeLogLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.created.at"),
- createdAt == null ? "" : SPDateTimeUtil.getFormattedDate(createdAt)));
+ protected void populateLog() {
+ logLayout.removeAllComponents();
- changeLogLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.created.by"),
- createdBy == null ? "" : HawkbitCommonUtil.getIMUser(createdBy)));
+ logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.created.at"),
+ SPDateTimeUtil.formatCreatedAt(selectedBaseEntity)));
- if (null != lastModifiedAt) {
- changeLogLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.modified.date"),
- SPDateTimeUtil.getFormattedDate(lastModifiedAt)));
+ logLayout.addComponent(SPUIComponentProvider.createCreatedByLabel(i18n, selectedBaseEntity));
- changeLogLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.modified.by"),
- lastModifiedBy == null ? "" : HawkbitCommonUtil.getIMUser(lastModifiedBy)));
+ if (selectedBaseEntity == null || selectedBaseEntity.getLastModifiedAt() == null) {
+ return;
}
+
+ logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.modified.date"),
+ SPDateTimeUtil.formatLastModifiedAt(selectedBaseEntity)));
+
+ logLayout.addComponent(SPUIComponentProvider.createLastModifiedByLabel(i18n, selectedBaseEntity));
}
protected void updateDescriptionLayout(final String descriptionLabel, final String description) {
@@ -320,19 +318,6 @@ public abstract class AbstractTableDetailsLayout extends
return detailsLayout;
}
- public VerticalLayout getLogLayout() {
- return logLayout;
- }
-
- private void populateLog() {
- if (selectedBaseEntity == null) {
- updateLogLayout(getLogLayout(), null, StringUtils.EMPTY, null, null, i18n);
- return;
- }
- updateLogLayout(getLogLayout(), selectedBaseEntity.getLastModifiedAt(), selectedBaseEntity.getLastModifiedBy(),
- selectedBaseEntity.getCreatedAt(), selectedBaseEntity.getCreatedBy(), i18n);
- }
-
private void populateDescription() {
if (selectedBaseEntity != null) {
updateDescriptionLayout(i18n.get("label.description"), selectedBaseEntity.getDescription());
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java
index 0737f42c8..1808cf070 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java
@@ -20,7 +20,7 @@ import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
-import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
+import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -212,9 +212,9 @@ public abstract class AbstractTable extends Table {
item.getItemProperty(SPUILabelDefinitions.VAR_ID).setValue(baseEntity.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(baseEntity.getDescription());
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY)
- .setValue(HawkbitCommonUtil.getIMUser(baseEntity.getCreatedBy()));
+ .setValue(UserDetailsFormatter.loadAndFormatCreatedBy(baseEntity));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY)
- .setValue(HawkbitCommonUtil.getIMUser(baseEntity.getLastModifiedBy()));
+ .setValue(UserDetailsFormatter.loadAndFormatLastModifiedBy(baseEntity));
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(baseEntity.getCreatedAt()));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE)
@@ -329,6 +329,17 @@ public abstract class AbstractTable extends Table {
columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2F));
+ setItemDescriptionGenerator((source, itemId, propertyId) -> {
+
+ if (SPUILabelDefinitions.VAR_CREATED_BY.equals(propertyId)) {
+ return getItem(itemId).getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).getValue().toString();
+ }
+ if (SPUILabelDefinitions.VAR_LAST_MODIFIED_BY.equals(propertyId)) {
+ return getItem(itemId).getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).getValue().toString();
+ }
+ return null;
+ });
+
return columnList;
}
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java
index d85b2bc71..9ac39616d 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java
@@ -36,6 +36,8 @@ public class ProxyTarget extends Target {
private DistributionSet installedDistributionSet;
+ private DistributionSet assignedDistributionSet;
+
private TargetIdName targetIdName;
private String assignedDistNameVersion;
@@ -249,6 +251,21 @@ public class ProxyTarget extends Target {
this.installedDistributionSet = installedDistributionSet;
}
+ /**
+ * @return the assignedDistributionSet
+ */
+ public DistributionSet getAssignedDistributionSet() {
+ return assignedDistributionSet;
+ }
+
+ /**
+ * @param assignedDistributionSet
+ * the assignedDistributionSet to set
+ */
+ public void setAssignedDistributionSet(DistributionSet assignedDistributionSet) {
+ this.assignedDistributionSet = assignedDistributionSet;
+ }
+
/**
* @return the targetIdName
*/
@@ -297,4 +314,5 @@ public class ProxyTarget extends Target {
public void setStatus(final Status status) {
this.status = status;
}
+
}
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java
index f5008eb31..d8e5e31d1 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java
@@ -12,7 +12,9 @@ import java.util.Arrays;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
+import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.DistributionSet;
+import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUIComboBoxDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUIHeaderLayoutDecorator;
@@ -20,6 +22,7 @@ import org.eclipse.hawkbit.ui.decorators.SPUILabelDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUITextAreaDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUITextFieldDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
+import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -328,6 +331,50 @@ public final class SPUIComponentProvider {
return nameValueLabel;
}
+ private static Label createUsernameLabel(final String label, final String username) {
+ String loadAndFormatUsername = StringUtils.EMPTY;
+ if (!StringUtils.isEmpty(username)) {
+ loadAndFormatUsername = UserDetailsFormatter.loadAndFormatUsername(username);
+ }
+
+ final Label nameValueLabel = new Label(getBoldHTMLText(label) + loadAndFormatUsername, ContentMode.HTML);
+ nameValueLabel.setSizeFull();
+ nameValueLabel.addStyleName(SPUIDefinitions.TEXT_STYLE);
+ nameValueLabel.addStyleName("label-style");
+ nameValueLabel.setDescription(loadAndFormatUsername);
+ return nameValueLabel;
+ }
+
+ /**
+ * Create label which represents the {@link BaseEntity#getCreatedBy()} by
+ * user name
+ *
+ * @param i18n
+ * the i18n
+ * @param baseEntity
+ * the entity
+ * @return the label
+ */
+ public static Label createCreatedByLabel(final I18N i18n, final BaseEntity baseEntity) {
+ return createUsernameLabel(i18n.get("label.created.by"),
+ baseEntity == null ? StringUtils.EMPTY : baseEntity.getCreatedBy());
+ }
+
+ /**
+ * Create label which represents the
+ * {@link BaseEntity#getLastModifiedBy()()} by user name
+ *
+ * @param i18n
+ * the i18n
+ * @param baseEntity
+ * the entity
+ * @return the label
+ */
+ public static Label createLastModifiedByLabel(final I18N i18n, final BaseEntity baseEntity) {
+ return createUsernameLabel(i18n.get("label.modified.by"),
+ baseEntity == null ? StringUtils.EMPTY : baseEntity.getLastModifiedBy());
+ }
+
/**
* Get Bold Text.
*
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java
index 8d609f628..64a06bd38 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java
@@ -284,7 +284,7 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
mainLayout.addComponent(fieldLayout);
mainLayout.addComponent(twinTableLayout);
-
+
colorLayout = new HorizontalLayout();
sliderLayout = new VerticalLayout();
final HorizontalLayout chooseColorLayout = new HorizontalLayout();
@@ -299,6 +299,7 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
mainWindowLayout.addComponent(colorLayout);
mainWindowLayout.addComponent(buttonLayout);
setCompositionRoot(mainWindowLayout);
+ typeName.focus();
}
private HorizontalLayout createTwinColumnLayout() {
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java
index 60b547285..78410f29c 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java
@@ -20,6 +20,7 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
+import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.components.ProxyDistribution;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -113,8 +114,8 @@ public class ManageDistBeanQuery extends AbstractBeanQuery {
proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt()));
proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt()));
proxyDistribution.setDescription(distributionSet.getDescription());
- proxyDistribution.setCreatedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy()));
- proxyDistribution.setModifiedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy()));
+ proxyDistribution.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(distributionSet));
+ proxyDistribution.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(distributionSet));
proxyDistribution.setIsComplete(distributionSet.isComplete());
proxyDistributions.add(proxyDistribution);
}
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java
index 5419cc1bf..21ce01347 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java
@@ -17,6 +17,7 @@ import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.CustomSoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
+import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -99,8 +100,8 @@ public class SwModuleBeanQuery extends AbstractBeanQuery
proxyItem.setVersion(bean.getVersion());
proxyItem.setVendor(bean.getVendor());
proxyItem.setDescription(bean.getDescription());
- proxyItem.setCreatedByUser(HawkbitCommonUtil.getIMUser(bean.getCreatedBy()));
- proxyItem.setModifiedByUser(HawkbitCommonUtil.getIMUser(bean.getLastModifiedBy()));
+ proxyItem.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(bean));
+ proxyItem.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(bean));
proxyItem.setAssigned(customSoftwareModule.isAssigned());
proxyItem.setColour(bean.getType().getColour());
proxyItem.setTypeId(bean.getType().getId());
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java
index ebeb95957..6e4933d69 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java
@@ -8,6 +8,7 @@
*/
package org.eclipse.hawkbit.ui.filtermanagement;
+
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@@ -17,10 +18,12 @@ import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
+import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
+import org.eclipse.hawkbit.ui.utils.AssignInstalledDSTooltipGenerator;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -69,6 +72,10 @@ public class CreateOrUpdateFilterTable extends Table {
private static final int PROPERTY_DEPT = 3;
+ private static final String ASSIGN_DIST_SET = "assignedDistributionSet";
+
+ private static final String INSTALL_DIST_SET = "installedDistributionSet";
+
/**
* Initialize the Action History Table.
*/
@@ -87,6 +94,7 @@ public class CreateOrUpdateFilterTable extends Table {
setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID);
setSelectable(false);
eventBus.subscribe(this);
+ setItemDescriptionGenerator(new AssignInstalledDSTooltipGenerator());
}
@PreDestroy
@@ -160,6 +168,9 @@ public class CreateOrUpdateFilterTable extends Table {
private void setCollapsibleColumns() {
setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, true);
setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, true);
+
+ setColumnCollapsed(ASSIGN_DIST_SET, true);
+ setColumnCollapsed(INSTALL_DIST_SET, true);
}
/**
@@ -172,10 +183,13 @@ public class CreateOrUpdateFilterTable extends Table {
container.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, Date.class, null);
container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, true);
container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, true);
- container.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, "");
- container.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class, null);
container.addContainerProperty(SPUILabelDefinitions.VAR_TARGET_STATUS, TargetUpdateStatus.class, null);
container.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true);
+
+ container.addContainerProperty(ASSIGN_DIST_SET, DistributionSet.class, null, false, true);
+ container.addContainerProperty(INSTALL_DIST_SET, DistributionSet.class, null, false, true);
+ container.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, "");
+ container.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class, null);
}
private List getVisbleColumns() {
@@ -186,12 +200,12 @@ public class CreateOrUpdateFilterTable extends Table {
columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1F));
columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F));
+ columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F));
+ columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F));
columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER,
i18n.get("header.assigned.ds"), 0.125F));
columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER,
i18n.get("header.installed.ds"), 0.125F));
- columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.1F));
- columnList.add(new TableColumn(SPUILabelDefinitions.STATUS_ICON, i18n.get("header.status"), 0.1F));
return columnList;
}
@@ -244,4 +258,5 @@ public class CreateOrUpdateFilterTable extends Table {
populateTableData();
eventBus.publish(this, CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON);
}
+
}
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java
index bf5fdbe54..2cc572245 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java
@@ -15,6 +15,7 @@ import java.util.Map;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target;
+import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.components.ProxyTarget;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -118,8 +119,8 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery {
prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt()));
prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt()));
prxyTarget.setCreatedAt(targ.getCreatedAt());
- prxyTarget.setCreatedByUser(HawkbitCommonUtil.getIMUser(targ.getCreatedBy()));
- prxyTarget.setModifiedByUser(HawkbitCommonUtil.getIMUser(targ.getLastModifiedBy()));
+ prxyTarget.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(targ));
+ prxyTarget.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(targ));
final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId());
final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet();
prxyTarget.setInstalledDistributionSet(installedDistributionSet);
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java
index 9c50640cd..4a2d6da6c 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java
@@ -14,6 +14,7 @@ import java.util.Map;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
+import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.components.ProxyTargetFilter;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -93,9 +94,9 @@ public class TargetFilterBeanQuery extends AbstractBeanQuery
proxyTarFilter.setName(tarFilterQuery.getName());
proxyTarFilter.setId(tarFilterQuery.getId());
proxyTarFilter.setCreatedDate(SPDateTimeUtil.getFormattedDate(tarFilterQuery.getCreatedAt()));
- proxyTarFilter.setCreatedBy(HawkbitCommonUtil.getIMUser(tarFilterQuery.getCreatedBy()));
+ proxyTarFilter.setCreatedBy(UserDetailsFormatter.loadAndFormatCreatedBy(tarFilterQuery));
proxyTarFilter.setModifiedDate(SPDateTimeUtil.getFormattedDate(tarFilterQuery.getLastModifiedAt()));
- proxyTarFilter.setLastModifiedBy(HawkbitCommonUtil.getIMUser(tarFilterQuery.getLastModifiedBy()));
+ proxyTarFilter.setLastModifiedBy(UserDetailsFormatter.loadAndFormatLastModifiedBy(tarFilterQuery));
proxyTarFilter.setQuery(tarFilterQuery.getQuery());
proxyTargetFilter.add(proxyTarFilter);
}
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java
index 80c1b5700..5d9304191 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java
@@ -145,11 +145,12 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
setSizeUndefined();
addComponents(madatoryLabel, distsetTypeNameComboBox, distNameTextField, distVersionTextField, descTextArea,
reqMigStepCheckbox);
-
+
addComponent(buttonsLayout);
setComponentAlignment(madatoryLabel, Alignment.MIDDLE_LEFT);
-
- }
+ distNameTextField.focus();
+
+ }
/**
* Create required UI components.
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java
index 7b49ddcb2..7909a3850 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java
@@ -18,6 +18,7 @@ import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilte
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.model.DistributionSet;
+import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.components.ProxyDistribution;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -129,8 +130,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery
proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt()));
proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt()));
proxyDistribution.setDescription(distributionSet.getDescription());
- proxyDistribution.setCreatedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy()));
- proxyDistribution.setModifiedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy()));
+ proxyDistribution.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(distributionSet));
+ proxyDistribution.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(distributionSet));
proxyDistribution.setNameVersion(
HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion()));
proxyDistributions.add(proxyDistribution);
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java
index b78db6b4f..6bed7dd4f 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java
@@ -171,7 +171,7 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
tagName = SPUIComponentProvider.getTextField("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME,
true, "", i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
tagName.setId(SPUIDefinitions.NEW_TARGET_TAG_NAME);
-
+
tagDesc = SPUIComponentProvider.getTextArea("", ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_DESC,
false, "", i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
@@ -237,7 +237,8 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
fieldLayout.addComponent(madatoryLabel);
fieldLayout.addComponent(tagName);
fieldLayout.addComponent(tagDesc);
-
+
+
final HorizontalLayout colorLabelLayout = new HorizontalLayout();
colorLabelLayout.addComponents(colorLabel, tagColorPreviewBtn);
fieldLayout.addComponent(colorLabelLayout);
@@ -257,8 +258,8 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
mainLayout = new HorizontalLayout();
mainLayout.addComponent(fieldButtonLayout);
-
setCompositionRoot(mainLayout);
+ tagName.focus();
}
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java
index 973d61857..e54911d86 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java
@@ -152,7 +152,7 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
madatoryLabel.setVisible(Boolean.FALSE);
}
mainLayout.addComponents(madatoryLabel, controllerIDTextField, nameTextField, descTextArea, buttonsLayout);
-
+ nameTextField.focus();
}
private void addListeners() {
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java
index dac50ab0d..e48004d7a 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java
@@ -19,6 +19,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
+import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.components.ProxyTarget;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -130,20 +131,24 @@ public class TargetBeanQuery extends AbstractBeanQuery {
prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt()));
prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt()));
prxyTarget.setCreatedAt(targ.getCreatedAt());
- prxyTarget.setCreatedByUser(HawkbitCommonUtil.getIMUser(targ.getCreatedBy()));
- prxyTarget.setModifiedByUser(HawkbitCommonUtil.getIMUser(targ.getLastModifiedBy()));
+ prxyTarget.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(targ));
+ prxyTarget.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(targ));
- if (pinnedDistId == null) {
- prxyTarget.setInstalledDistributionSet(null);
- prxyTarget.setAssignedDistributionSet(null);
- } else {
- final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId());
- final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet();
- prxyTarget.setInstalledDistributionSet(installedDistributionSet);
- final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet();
- prxyTarget.setAssignedDistributionSet(assignedDistributionSet);
+ final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId());
+ final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet();
+ final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet();
+
+ prxyTarget.setInstalledDistributionSet(installedDistributionSet);
+ prxyTarget.setAssignedDistributionSet(assignedDistributionSet);
+
+ if (installedDistributionSet != null) {
+ prxyTarget.setInstalledDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion(
+ installedDistributionSet.getName(), installedDistributionSet.getVersion()));
+ }
+ if (assignedDistributionSet != null) {
+ prxyTarget.setAssignedDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion(
+ assignedDistributionSet.getName(), assignedDistributionSet.getVersion()));
}
-
prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus());
prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery());
prxyTarget.setTargetInfo(targ.getTargetInfo());
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java
index 3b9c18952..6232ebcf8 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java
@@ -24,7 +24,9 @@ import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TargetManagement;
+import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetIdName;
+import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TargetIdName;
@@ -32,6 +34,7 @@ import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState;
+import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.common.table.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.filter.FilterExpression;
@@ -51,6 +54,7 @@ import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.management.state.TargetTableFilters;
+import org.eclipse.hawkbit.ui.utils.AssignInstalledDSTooltipGenerator;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
@@ -109,6 +113,7 @@ public class TargetTable extends AbstractTable implements
private static final int PROPERTY_DEPT = 3;
private static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed";
+
@Autowired
private transient TargetManagement targetManagement;
@@ -136,6 +141,7 @@ public class TargetTable extends AbstractTable implements
addActionHandler(this);
actionSelectAll = new ShortcutAction(i18n.get("action.target.table.selectall"));
actionUnSelectAll = new ShortcutAction(i18n.get("action.target.table.clear"));
+ setItemDescriptionGenerator(new AssignInstalledDSTooltipGenerator());
}
/**
@@ -329,6 +335,11 @@ public class TargetTable extends AbstractTable implements
if (!isMaximized()) {
columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_POLL_TIME, "", 0.0F));
columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_PIN_TOGGLE_ICON, "", 0.0F));
+ }else{
+ columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER,
+ i18n.get("header.assigned.ds"), 0.1F));
+ columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER,
+ i18n.get("header.installed.ds"), 0.1F));
}
return columnList;
@@ -739,7 +750,7 @@ public class TargetTable extends AbstractTable implements
.setValue(updatedTarget.getTargetInfo().getLastTargetQuery());
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY)
- .setValue(HawkbitCommonUtil.getIMUser(updatedTarget.getLastModifiedBy()));
+ .setValue(UserDetailsFormatter.loadAndFormatLastModifiedBy(updatedTarget));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(updatedTarget.getLastModifiedAt()));
item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(updatedTarget.getDescription());
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java
index bbbba8cec..5a822ff86 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java
@@ -18,23 +18,20 @@ import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
+import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.HawkbitServerProperties;
import org.eclipse.hawkbit.im.authentication.PermissionService;
-import org.eclipse.hawkbit.im.authentication.UserPrincipal;
import org.eclipse.hawkbit.ui.UiProperties;
+import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.menu.DashboardEvent.PostViewChangeEvent;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.core.context.SecurityContext;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
import com.vaadin.server.FontAwesome;
import com.vaadin.server.Page;
import com.vaadin.server.ThemeResource;
-import com.vaadin.server.VaadinService;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.UIScope;
@@ -189,63 +186,27 @@ public final class DashboardMenu extends CustomComponent {
return links;
}
- private UserDetails getCurrentUser() {
- final SecurityContext context = (SecurityContext) VaadinService.getCurrentRequest().getWrappedSession()
- .getAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
- return (UserDetails) context.getAuthentication().getPrincipal();
- }
-
private Component buildUserMenu() {
final MenuBar settings = new MenuBar();
settings.addStyleName("user-menu");
- final UserDetails user = getCurrentUser();
+ settings.setHtmlContentAllowed(true);
final MenuItem settingsItem = settings.addItem("", new ThemeResource("images/profile-pic-57px.jpg"), null);
- if (user instanceof UserPrincipal
- && (((UserPrincipal) user).getFirstname() != null || ((UserPrincipal) user).getLastname() != null)) {
- settingsItem.setText(trimTanent(((UserPrincipal) user).getTenant()) + "\n"
- + concateFNameLName(((UserPrincipal) user).getFirstname(), ((UserPrincipal) user).getLastname()));
- settingsItem.setDescription(
- ((UserPrincipal) user).getFirstname() + " / " + ((UserPrincipal) user).getLastname());
- } else if (user instanceof UserPrincipal) {
- if (((UserPrincipal) user).getLoginname().length() > 10) {
- settingsItem.setText(trimTanent(((UserPrincipal) user).getTenant()) + "\n"
- + ((UserPrincipal) user).getLoginname().substring(0, 10) + "..");
- } else {
- settingsItem.setText(
- trimTanent(((UserPrincipal) user).getTenant()) + "\n" + ((UserPrincipal) user).getLoginname());
- }
- settingsItem.setDescription(((UserPrincipal) user).getLoginname());
- } else if (user != null) {
- settingsItem.setText(user.getUsername());
- settingsItem.setDescription(user.getUsername());
+
+ final String formattedTenant = UserDetailsFormatter.formatCurrentTenant();
+ final String formattedUsername = UserDetailsFormatter.formatCurrentUsername();
+ String tenantAndUsernameHtml = "";
+ if (!StringUtils.isEmpty(formattedTenant)) {
+ tenantAndUsernameHtml += formattedTenant + " ";
}
+ tenantAndUsernameHtml += formattedUsername;
+ settingsItem.setText(tenantAndUsernameHtml);
+ settingsItem.setDescription(formattedUsername);
+ settingsItem.setStyleName("user-menuitem");
settingsItem.addItem("Sign Out", selectedItem -> Page.getCurrent().setLocation("/UI/logout"));
return settings;
}
- private String concateFNameLName(final String fName, final String lName) {
- final StringBuilder userName = new StringBuilder();
- if (fName != null && fName.length() > 6) {
- userName.append(fName.substring(0, 6) + ".." + ", ");
- } else {
- userName.append(fName).append(", ");
- }
- if (lName != null && lName.length() > 6) {
- userName.append(lName.substring(0, 6) + "..");
- } else {
- userName.append(lName);
- }
- return userName.toString();
- }
-
- private String trimTanent(final String tanent) {
- if (tanent != null && tanent.length() > 8) {
- return tanent.substring(0, 8) + "..";
- }
- return tanent;
- }
-
private Component buildToggleButton() {
final Button valoMenuToggleButton = new Button("Menu", (ClickListener) event -> {
if (getCompositionRoot().getStyleName().contains(STYLE_VISIBLE)) {
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java
index e5e86c520..7e8d45e1b 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java
@@ -209,6 +209,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
actionTypeOptionGroupLayout, linkToHelp, getSaveDiscardButtonLayout());
mainLayout.setComponentAlignment(linkToHelp, Alignment.BOTTOM_RIGHT);
setCompositionRoot(mainLayout);
+ rolloutName.focus();
}
private HorizontalLayout getGroupDetailsLayout() {
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/DistributionBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/DistributionBeanQuery.java
index 74daf89d8..75d2741af 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/DistributionBeanQuery.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/DistributionBeanQuery.java
@@ -18,6 +18,7 @@ import org.eclipse.hawkbit.repository.DistributionSetFilter;
import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
+import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.components.ProxyDistribution;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -62,7 +63,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]);
// Add sort
for (int distId = 1; distId < sortPropertyIds.length; distId++) {
- sort.and(new Sort(sortStates[distId] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[distId]));
+ sort.and(new Sort(sortStates[distId] ? Direction.ASC : Direction.DESC,
+ (String) sortPropertyIds[distId]));
}
}
}
@@ -103,8 +105,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery
final List proxyDistributions = new ArrayList<>();
for (final DistributionSet distributionSet : distBeans) {
final ProxyDistribution proxyDistribution = new ProxyDistribution();
- proxyDistribution.setName(HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(),
- distributionSet.getVersion()));
+ proxyDistribution.setName(
+ HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion()));
proxyDistribution.setDescription(distributionSet.getDescription());
proxyDistribution.setDistId(distributionSet.getId());
proxyDistribution.setId(distributionSet.getId());
@@ -112,8 +114,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery
proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt()));
proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt()));
proxyDistribution.setDescription(distributionSet.getDescription());
- proxyDistribution.setCreatedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy()));
- proxyDistribution.setModifiedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy()));
+ proxyDistribution.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(distributionSet));
+ proxyDistribution.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(distributionSet));
proxyDistribution.setIsComplete(distributionSet.isComplete());
proxyDistributions.add(proxyDistribution);
}
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/ProxyRollout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/ProxyRollout.java
index 6514ba2df..04c6659a5 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/ProxyRollout.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/ProxyRollout.java
@@ -8,7 +8,10 @@
*/
package org.eclipse.hawkbit.ui.rollout.rollout;
+import java.util.Set;
+
import org.eclipse.hawkbit.repository.model.Rollout;
+import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
import com.vaadin.server.FontAwesome;
@@ -19,123 +22,196 @@ import com.vaadin.server.FontAwesome;
*/
public class ProxyRollout extends Rollout {
- private static final long serialVersionUID = 4539849939617681918L;
+ private static final long serialVersionUID = 4539849939617681918L;
- private String distributionSetNameVersion;
+ private String distributionSetNameVersion;
- private String createdDate;
+ private String createdDate;
- private String modifiedDate;
+ private String modifiedDate;
- private Long numberOfGroups;
+ private Long numberOfGroups;
- private Boolean isActionRecieved = Boolean.FALSE;
+ private Boolean isActionRecieved = Boolean.FALSE;
- private String totalTargetsCount;
+ private Boolean isRequiredMigrationStep = Boolean.FALSE;
- private RolloutRendererData rolloutRendererData;
+ private String totalTargetsCount;
+ private RolloutRendererData rolloutRendererData;
- public RolloutRendererData getRolloutRendererData() {
- return rolloutRendererData;
- }
+ private String discription;
- public void setRolloutRendererData(RolloutRendererData rendererData) {
- this.rolloutRendererData = rendererData;
- }
+ private String type;
- /**
- * @return the distributionSetNameVersion
- */
- public String getDistributionSetNameVersion() {
- return distributionSetNameVersion;
- }
+ private Set swModules;
- /**
- * @param distributionSetNameVersion
- * the distributionSetNameVersion to set
- */
- public void setDistributionSetNameVersion(final String distributionSetNameVersion) {
- this.distributionSetNameVersion = distributionSetNameVersion;
- }
+ /**
+ * @return the isRequiredMigrationStep
+ */
- /**
- * @return the numberOfGroups
- */
- public Long getNumberOfGroups() {
- return numberOfGroups;
- }
+ public Boolean getIsRequiredMigrationStep() {
+ return isRequiredMigrationStep;
+ }
- /**
- * @param numberOfGroups
- * the numberOfGroups to set
- */
- public void setNumberOfGroups(final Long numberOfGroups) {
- this.numberOfGroups = numberOfGroups;
- }
+ /**
+ * @param isRequiredMigrationStep
+ * the isRequiredMigrationStep to set
+ */
- /**
- * @return the createdDate
- */
- public String getCreatedDate() {
- return createdDate;
- }
+ public void setIsRequiredMigrationStep(Boolean isRequiredMigrationStep) {
+ this.isRequiredMigrationStep = isRequiredMigrationStep;
+ }
- /**
- * @param createdDate
- * the createdDate to set
- */
- public void setCreatedDate(final String createdDate) {
- this.createdDate = createdDate;
- }
+ /**
+ * @return the discription
+ */
- /**
- * @return the modifiedDate
- */
- public String getModifiedDate() {
- return modifiedDate;
- }
+ public String getDiscription() {
+ return discription;
+ }
- /**
- * @param modifiedDate
- * the modifiedDate to set
- */
- public void setModifiedDate(final String modifiedDate) {
- this.modifiedDate = modifiedDate;
- }
+ /**
+ * @param discription
+ * the discription to set
+ */
- /**
- * @return the isActionRecieved
- */
- public Boolean getIsActionRecieved() {
- return isActionRecieved;
- }
+ public void setDiscription(String discription) {
+ this.discription = discription;
+ }
- /**
- * @param isActionRecieved
- * the isActionRecieved to set
- */
- public void setIsActionRecieved(final Boolean isActionRecieved) {
- this.isActionRecieved = isActionRecieved;
- }
+ /**
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
- /**
- * @return the totalTargetsCount
- */
- public String getTotalTargetsCount() {
- return totalTargetsCount;
- }
+ /**
+ * @param type
+ * the type to set
+ */
- /**
- * @param totalTargetsCount
- * the totalTargetsCount to set
- */
- public void setTotalTargetsCount(final String totalTargetsCount) {
- this.totalTargetsCount = totalTargetsCount;
- }
+ public void setType(String type) {
+ this.type = type;
+ }
- public String getAction() {
- return FontAwesome.CIRCLE_O.getHtml();
- }
+ /**
+ *
+ * @return the Set of Software modules
+ */
+ public Set getSwModules() {
+ return swModules;
+ }
+
+ /**
+ * @param swModules
+ * Set to set
+ */
+ public void setSwModules(Set swModules) {
+ this.swModules = swModules;
+ }
+
+ public RolloutRendererData getRolloutRendererData() {
+ return rolloutRendererData;
+ }
+
+ public void setRolloutRendererData(RolloutRendererData rendererData) {
+ this.rolloutRendererData = rendererData;
+ }
+
+ /**
+ * @return the distributionSetNameVersion
+ */
+ public String getDistributionSetNameVersion() {
+ return distributionSetNameVersion;
+ }
+
+ /**
+ * @param distributionSetNameVersion
+ * the distributionSetNameVersion to set
+ */
+ public void setDistributionSetNameVersion(final String distributionSetNameVersion) {
+ this.distributionSetNameVersion = distributionSetNameVersion;
+ }
+
+ /**
+ * @return the numberOfGroups
+ */
+ public Long getNumberOfGroups() {
+ return numberOfGroups;
+ }
+
+ /**
+ * @param numberOfGroups
+ * the numberOfGroups to set
+ */
+ public void setNumberOfGroups(final Long numberOfGroups) {
+ this.numberOfGroups = numberOfGroups;
+ }
+
+ /**
+ * @return the createdDate
+ */
+ public String getCreatedDate() {
+ return createdDate;
+ }
+
+ /**
+ * @param createdDate
+ * the createdDate to set
+ */
+ public void setCreatedDate(final String createdDate) {
+ this.createdDate = createdDate;
+ }
+
+ /**
+ * @return the modifiedDate
+ */
+ public String getModifiedDate() {
+ return modifiedDate;
+ }
+
+ /**
+ * @param modifiedDate
+ * the modifiedDate to set
+ */
+ public void setModifiedDate(final String modifiedDate) {
+ this.modifiedDate = modifiedDate;
+ }
+
+ /**
+ * @return the isActionRecieved
+ */
+ public Boolean getIsActionRecieved() {
+ return isActionRecieved;
+ }
+
+ /**
+ * @param isActionRecieved
+ * the isActionRecieved to set
+ */
+ public void setIsActionRecieved(final Boolean isActionRecieved) {
+ this.isActionRecieved = isActionRecieved;
+ }
+
+ /**
+ * @return the totalTargetsCount
+ */
+ public String getTotalTargetsCount() {
+ return totalTargetsCount;
+ }
+
+ /**
+ * @param totalTargetsCount
+ * the totalTargetsCount to set
+ */
+ public void setTotalTargetsCount(final String totalTargetsCount) {
+ this.totalTargetsCount = totalTargetsCount;
+ }
+
+ public String getAction() {
+ return FontAwesome.CIRCLE_O.getHtml();
+ }
}
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java
index 34ae323da..8a9675564 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutBeanQuery.java
@@ -17,6 +17,7 @@ import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
+import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -40,165 +41,171 @@ import com.google.common.base.Strings;
*/
public class RolloutBeanQuery extends AbstractBeanQuery {
- private static final long serialVersionUID = 4027879794344836185L;
+ private static final long serialVersionUID = 4027879794344836185L;
- private final String searchText;
+ private final String searchText;
- private Sort sort = new Sort(Direction.ASC, "createdAt");
+ private Sort sort = new Sort(Direction.ASC, "createdAt");
- private transient RolloutManagement rolloutManagement;
+ private transient RolloutManagement rolloutManagement;
- private transient TargetFilterQueryManagement filterQueryManagement;
+ private transient TargetFilterQueryManagement filterQueryManagement;
- private transient RolloutUIState rolloutUIState;
+ private transient RolloutUIState rolloutUIState;
- /**
- * Parametric Constructor.
- *
- * @param definition
- * as QueryDefinition
- * @param queryConfig
- * as Config
- * @param sortIds
- * as sort
- * @param sortStates
- * as Sort status
- */
- public RolloutBeanQuery(final QueryDefinition definition, final Map queryConfig,
- final Object[] sortIds, final boolean[] sortStates) {
- super(definition, queryConfig, sortIds, sortStates);
+ /**
+ * Parametric Constructor.
+ *
+ * @param definition
+ * as QueryDefinition
+ * @param queryConfig
+ * as Config
+ * @param sortIds
+ * as sort
+ * @param sortStates
+ * as Sort status
+ */
+ public RolloutBeanQuery(final QueryDefinition definition, final Map queryConfig,
+ final Object[] sortIds, final boolean[] sortStates) {
+ super(definition, queryConfig, sortIds, sortStates);
- searchText = getSearchText();
+ searchText = getSearchText();
- if (HawkbitCommonUtil.checkBolArray(sortStates)) {
- // Initalize Sor
- sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
- // Add sort.
- for (int targetId = 1; targetId < sortIds.length; targetId++) {
- sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId]));
- }
- }
- }
+ if (HawkbitCommonUtil.checkBolArray(sortStates)) {
+ // Initalize Sor
+ sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
+ // Add sort.
+ for (int targetId = 1; targetId < sortIds.length; targetId++) {
+ sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId]));
+ }
+ }
+ }
- private String getSearchText() {
- if (getRolloutUIState().getSearchText().isPresent()) {
- return String.format("%%%s%%", getRolloutUIState().getSearchText().get());
- }
- return null;
- }
+ private String getSearchText() {
+ if (getRolloutUIState().getSearchText().isPresent()) {
+ return String.format("%%%s%%", getRolloutUIState().getSearchText().get());
+ }
+ return null;
+ }
- @Override
- protected ProxyRollout constructBean() {
- return new ProxyRollout();
- }
+ @Override
+ protected ProxyRollout constructBean() {
+ return new ProxyRollout();
+ }
- /*
- * (non-Javadoc)
- *
- * @see
- * org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#loadBeans(int,
- * int)
- */
- @Override
- protected List loadBeans(final int startIndex, final int count) {
- final Slice rolloutBeans;
- if (Strings.isNullOrEmpty(searchText)) {
- rolloutBeans = getRolloutManagement().findAllRolloutsWithDetailedStatus(
- new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort));
- } else {
- rolloutBeans = getRolloutManagement().findRolloutByFilters(
- new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort),
- searchText);
- }
- return getProxyRolloutList(rolloutBeans);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#loadBeans(int,
+ * int)
+ */
+ @Override
+ protected List loadBeans(final int startIndex, final int count) {
+ final Slice rolloutBeans;
+ if (Strings.isNullOrEmpty(searchText)) {
+ rolloutBeans = getRolloutManagement().findAllRolloutsWithDetailedStatus(
+ new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort));
+ } else {
+ rolloutBeans = getRolloutManagement().findRolloutByFilters(
+ new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort),
+ searchText);
+ }
+ return getProxyRolloutList(rolloutBeans);
+ }
- private List getProxyRolloutList(final Slice rolloutBeans) {
- final List proxyRolloutList = new ArrayList<>();
- for (final Rollout rollout : rolloutBeans) {
- final ProxyRollout proxyRollout = new ProxyRollout();
- proxyRollout.setName(rollout.getName());
- proxyRollout.setDescription(rollout.getDescription());
- final DistributionSet distributionSet = rollout.getDistributionSet();
- proxyRollout.setDistributionSetNameVersion(
- HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion()));
- proxyRollout.setDistributionSet(distributionSet);
- proxyRollout.setNumberOfGroups(Long.valueOf(rollout.getRolloutGroups().size()));
- proxyRollout.setCreatedDate(SPDateTimeUtil.getFormattedDate(rollout.getCreatedAt()));
- proxyRollout.setModifiedDate(SPDateTimeUtil.getFormattedDate(rollout.getLastModifiedAt()));
- proxyRollout.setCreatedBy(HawkbitCommonUtil.getIMUser(rollout.getCreatedBy()));
- proxyRollout.setLastModifiedBy(HawkbitCommonUtil.getIMUser(rollout.getLastModifiedBy()));
- proxyRollout.setForcedTime(rollout.getForcedTime());
- proxyRollout.setId(rollout.getId());
- proxyRollout.setStatus(rollout.getStatus());
- proxyRollout.setRolloutRendererData(new RolloutRendererData(rollout.getName(), rollout.getStatus().toString()));
+ private List getProxyRolloutList(final Slice rolloutBeans) {
+ final List proxyRolloutList = new ArrayList<>();
+ for (final Rollout rollout : rolloutBeans) {
+ final ProxyRollout proxyRollout = new ProxyRollout();
+ proxyRollout.setName(rollout.getName());
+ proxyRollout.setDescription(rollout.getDescription());
+ final DistributionSet distributionSet = rollout.getDistributionSet();
+ proxyRollout.setDistributionSetNameVersion(
+ HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion()));
+ proxyRollout.setDistributionSet(distributionSet);
+ proxyRollout.setNumberOfGroups(Long.valueOf(rollout.getRolloutGroups().size()));
+ proxyRollout.setCreatedDate(SPDateTimeUtil.getFormattedDate(rollout.getCreatedAt()));
+ proxyRollout.setModifiedDate(SPDateTimeUtil.getFormattedDate(rollout.getLastModifiedAt()));
+ proxyRollout.setCreatedBy(UserDetailsFormatter.loadAndFormatCreatedBy(rollout));
+ proxyRollout.setLastModifiedBy(UserDetailsFormatter.loadAndFormatLastModifiedBy(rollout));
+ proxyRollout.setForcedTime(rollout.getForcedTime());
+ proxyRollout.setId(rollout.getId());
+ proxyRollout.setStatus(rollout.getStatus());
+ proxyRollout
+ .setRolloutRendererData(new RolloutRendererData(rollout.getName(), rollout.getStatus().toString()));
- final TotalTargetCountStatus totalTargetCountActionStatus = rollout.getTotalTargetCountStatus();
- proxyRollout.setTotalTargetCountStatus(totalTargetCountActionStatus);
- proxyRollout.setTotalTargetsCount(String.valueOf(rollout.getTotalTargets()));
+ final TotalTargetCountStatus totalTargetCountActionStatus = rollout.getTotalTargetCountStatus();
+ proxyRollout.setTotalTargetCountStatus(totalTargetCountActionStatus);
+ proxyRollout.setTotalTargetsCount(String.valueOf(rollout.getTotalTargets()));
- proxyRolloutList.add(proxyRollout);
- }
- return proxyRolloutList;
- }
+ proxyRollout.setDescription(distributionSet.getDescription());
+ proxyRollout.setType(distributionSet.getType().getName());
+ proxyRollout.setIsRequiredMigrationStep(distributionSet.isRequiredMigrationStep());
+ proxyRollout.setSwModules(distributionSet.getModules());
- /*
- * (non-Javadoc)
- *
- * @see
- * org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#saveBeans(java
- * .util.List, java.util.List, java.util.List)
- */
- @Override
- protected void saveBeans(final List arg0, final List arg1,
- final List arg2) {
- /**
- * CRUD operations on Target will be done through repository methods
- */
- }
+ proxyRolloutList.add(proxyRollout);
+ }
+ return proxyRolloutList;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#size()
- */
- @Override
- public int size() {
- int size = getRolloutManagement().countRolloutsAll().intValue();
- if (!Strings.isNullOrEmpty(searchText)) {
- size = getRolloutManagement().countRolloutsAllByFilters(searchText).intValue();
- }
- return size;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#saveBeans(java
+ * .util.List, java.util.List, java.util.List)
+ */
+ @Override
+ protected void saveBeans(final List arg0, final List arg1,
+ final List arg2) {
+ /**
+ * CRUD operations on Target will be done through repository methods
+ */
+ }
- /**
- * @return the rolloutManagement
- */
- public RolloutManagement getRolloutManagement() {
- if (null == rolloutManagement) {
- rolloutManagement = SpringContextHelper.getBean(RolloutManagement.class);
- }
- return rolloutManagement;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#size()
+ */
+ @Override
+ public int size() {
+ int size = getRolloutManagement().countRolloutsAll().intValue();
+ if (!Strings.isNullOrEmpty(searchText)) {
+ size = getRolloutManagement().countRolloutsAllByFilters(searchText).intValue();
+ }
+ return size;
+ }
- /**
- * @return the filterQueryManagement
- */
- public TargetFilterQueryManagement getFilterQueryManagement() {
- if (null == filterQueryManagement) {
- filterQueryManagement = SpringContextHelper.getBean(TargetFilterQueryManagement.class);
- }
- return filterQueryManagement;
- }
+ /**
+ * @return the rolloutManagement
+ */
+ public RolloutManagement getRolloutManagement() {
+ if (null == rolloutManagement) {
+ rolloutManagement = SpringContextHelper.getBean(RolloutManagement.class);
+ }
+ return rolloutManagement;
+ }
- /**
- * @return the rolloutUIState
- */
- public RolloutUIState getRolloutUIState() {
- if (null == rolloutUIState) {
- rolloutUIState = SpringContextHelper.getBean(RolloutUIState.class);
- }
- return rolloutUIState;
- }
+ /**
+ * @return the filterQueryManagement
+ */
+ public TargetFilterQueryManagement getFilterQueryManagement() {
+ if (null == filterQueryManagement) {
+ filterQueryManagement = SpringContextHelper.getBean(TargetFilterQueryManagement.class);
+ }
+ return filterQueryManagement;
+ }
+
+ /**
+ * @return the rolloutUIState
+ */
+ public RolloutUIState getRolloutUIState() {
+ if (null == rolloutUIState) {
+ rolloutUIState = SpringContextHelper.getBean(RolloutUIState.class);
+ }
+ return rolloutUIState;
+ }
}
diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java
index 1bb0fd831..7f3877a9a 100644
--- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java
+++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/RolloutListGrid.java
@@ -8,18 +8,25 @@
*/
package org.eclipse.hawkbit.ui.rollout.rollout;
+import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_CLOSE_TAG;
+import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_OPEN_TAG;
+import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_CLOSE_TAG;
+import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
import org.eclipse.hawkbit.eventbus.event.RolloutChangeEvent;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
+import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.ui.common.grid.AbstractGrid;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
@@ -78,6 +85,12 @@ public class RolloutListGrid extends AbstractGrid {
private static final String START_OPTION = "Start";
+ private static final String DS_TYPE = "type";
+
+ private static final String SW_MODULES = "swModules";
+
+ private static final String IS_REQUIRED_MIGRATION_STEP = "isRequiredMigrationStep";
+
private static final String ROLLOUT_RENDERER_DATA = "rolloutRendererData";
@Autowired
@@ -160,8 +173,11 @@ public class RolloutListGrid extends AbstractGrid {
protected void addContainerProperties() {
final LazyQueryContainer rolloutGridContainer = (LazyQueryContainer) getContainerDataSource();
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, false);
+ rolloutGridContainer.addContainerProperty(DS_TYPE, String.class, null, false, false);
+ rolloutGridContainer.addContainerProperty(SW_MODULES, Set.class, null, false, false);
rolloutGridContainer.addContainerProperty(ROLLOUT_RENDERER_DATA, RolloutRendererData.class, null, false, false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, null, false, false);
+ rolloutGridContainer.addContainerProperty(IS_REQUIRED_MIGRATION_STEP, boolean.class, null, false, false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, RolloutStatus.class, null, false,
false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION, String.class, null, false,
@@ -216,6 +232,9 @@ public class RolloutListGrid extends AbstractGrid {
@Override
protected void setColumnHeaderNames() {
getColumn(ROLLOUT_RENDERER_DATA).setHeaderCaption(i18n.get("header.name"));
+ getColumn(DS_TYPE).setHeaderCaption("Type");
+ getColumn(SW_MODULES).setHeaderCaption("swModules");
+ getColumn(IS_REQUIRED_MIGRATION_STEP).setHeaderCaption("IsRequiredMigrationStep");
getColumn(SPUILabelDefinitions.VAR_DIST_NAME_VERSION).setHeaderCaption(i18n.get("header.distributionset"));
getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setHeaderCaption(i18n.get("header.numberofgroups"));
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setHeaderCaption(i18n.get("header.total.targets"));
@@ -240,6 +259,9 @@ public class RolloutListGrid extends AbstractGrid {
final List