Merge remote-tracking branch 'eclipse/master' into

fix-set-db-read-uncommited

Fixed small typo


Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2016-05-02 18:10:21 +02:00
50 changed files with 1241 additions and 662 deletions

0
3rd-dependencies/listDeps.sh Executable file → Normal file
View File

View File

@@ -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: * The master branch contains future development towards 0.2. We are currently focusing on:
* Rollout Management for large scale rollouts. * Rollout Management for large scale rollouts.
* Clustering capabilities for the update server. * 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. * 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-autoconfigure` : spring-boot auto-configuration.
`hawkbit-dmf-api` : API for the Device Management Integration. `hawkbit-dmf-api` : API for the Device Management Integration.
`hawkbit-dmf-amqp` : AMQP endpoint implementation for the DMF API. `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-http-security` : implementation for security filters for HTTP.
`hawkbit-rest-api` : API classes for the REST Management API. `hawkbit-rest-api` : API classes for the REST Management API.
`hawkbit-rest-resource` : HTTP REST endpoints for the Management and the Direct Device API. `hawkbit-rest-resource` : HTTP REST endpoints for the Management and the Direct Device API.

View File

@@ -139,7 +139,7 @@
<dependency> <dependency>
<groupId>com.vaadin</groupId> <groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId> <artifactId>vaadin-bom</artifactId>
<version>7.6.3</version> <version>${vaadin.version}</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>

View File

@@ -16,6 +16,7 @@ import org.eclipse.hawkbit.simulator.amqp.SpSenderService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -25,6 +26,7 @@ import org.springframework.stereotype.Component;
* *
*/ */
@Component @Component
@ConditionalOnProperty(prefix = "hawkbit.device.simulator", name = "autostart", matchIfMissing = true)
public class SimulatorStartup implements ApplicationListener<ContextRefreshedEvent> { public class SimulatorStartup implements ApplicationListener<ContextRefreshedEvent> {
private static final Logger LOGGER = LoggerFactory.getLogger(SimulatorStartup.class); private static final Logger LOGGER = LoggerFactory.getLogger(SimulatorStartup.class);

View File

@@ -39,6 +39,12 @@ public class AmqpProperties {
*/ */
private String deadLetterExchange = "simulator.deadletter"; 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() { public String getReceiverConnectorQueueFromSp() {
return receiverConnectorQueueFromSp; return receiverConnectorQueueFromSp;
} }
@@ -70,4 +76,12 @@ public class AmqpProperties {
public void setSenderForSpExchange(final String senderForSpExchange) { public void setSenderForSpExchange(final String senderForSpExchange) {
this.senderForSpExchange = senderForSpExchange; this.senderForSpExchange = senderForSpExchange;
} }
public int getDeadLetterTtl() {
return deadLetterTtl;
}
public void setDeadLetterTtl(final int deadLetterTtl) {
this.deadLetterTtl = deadLetterTtl;
}
} }

View File

@@ -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. 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 the example application in our hawkBit sandbox on Bluemix
- try out Management UI https://hawkbit.eu-gb.mybluemix.net/UI - 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) - 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 - try out DDI API https://hawkbit.eu-gb.mybluemix.net/DEFAULT/controller/v1/MYTESTDEVICE (authentication disabled)
## On your own workstation ## On your own workstation
### Run ### Run
``` ```
java -jar examples/hawkbit-example-app/target/hawkbit-example-app-*-SNAPSHOT.jar 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: Or:
``` ```
run org eclipse.hawkbit.app.Start run org eclipse.hawkbit.app.Start
``` ```

View File

@@ -21,7 +21,7 @@ spring.rabbitmq.password=guest
spring.rabbitmq.virtualHost=/ spring.rabbitmq.virtualHost=/
spring.rabbitmq.host=localhost spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672 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.deadLetterExchange=dmf.connector.deadletter
hawkbit.dmf.rabbitmq.receiverQueue=dmf_receiver hawkbit.dmf.rabbitmq.receiverQueue=dmf_receiver

View File

@@ -42,6 +42,6 @@ hawkbit.controller.minPollingTime=00:00:30
# Configuration for RabbitMQ integration # 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.deadLetterExchange=dmf.connector.deadletter
hawkbit.dmf.rabbitmq.receiverQueue=dmf_receiver hawkbit.dmf.rabbitmq.receiverQueue=dmf_receiver

View File

@@ -8,9 +8,6 @@
*/ */
package org.eclipse.hawkbit.amqp; package org.eclipse.hawkbit.amqp;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings; import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings;
import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder; 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.core.Queue;
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory; 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.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; 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. * {@code amqp} to use a AMQP for communication with SP enabled devices.
* *
*/ */
@EnableConfigurationProperties(AmqpProperties.class) @EnableConfigurationProperties({ AmqpProperties.class, AmqpDeadletterProperties.class })
public class AmqpConfiguration { public class AmqpConfiguration {
@Autowired @Autowired
protected AmqpProperties amqpProperties; protected AmqpProperties amqpProperties;
@Autowired
protected AmqpDeadletterProperties amqpDeadletterProperties;
@Autowired @Autowired
private ConnectionFactory connectionFactory; 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. * Method to set the Jackson2JsonMessageConverter.
* *
@@ -59,7 +73,8 @@ public class AmqpConfiguration {
*/ */
@Bean @Bean
public Queue receiverQueue() { 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 @Bean
public Queue deadLetterQueue() { public Queue deadLetterQueue() {
return new Queue(amqpProperties.getDeadLetterQueue()); return amqpDeadletterProperties.createDeadletterQueue(amqpProperties.getDeadLetterQueue());
} }
/** /**
@@ -149,10 +164,4 @@ public class AmqpConfiguration {
return containerFactory; return containerFactory;
} }
private Map<String, Object> getDeadLetterExchangeArgs() {
final Map<String, Object> args = new HashMap<>();
args.put("x-dead-letter-exchange", amqpProperties.getDeadLetterExchange());
return args;
}
} }

View File

@@ -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<String, Object> getDeadLetterExchangeArgs(final String exchange) {
final Map<String, Object> 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<String, Object> getTTLArgs() {
final Map<String, Object> 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;
}
}

View File

@@ -21,7 +21,7 @@ public class AmqpProperties {
/** /**
* DMF API dead letter queue. * DMF API dead letter queue.
*/ */
private String deadLetterQueue = "dmf_connector_deadletter"; private String deadLetterQueue = "dmf_connector_deadletter_ttl";
/** /**
* DMF API dead letter exchange. * DMF API dead letter exchange.

View File

@@ -11,9 +11,6 @@ package org.eclipse.hawkbit;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.transaction.Transaction; 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.hawkbit.tenancy.TenantAware;
import org.eclipse.persistence.config.PersistenceUnitProperties; import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.springframework.beans.factory.annotation.Autowired; 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) { protected void doBegin(final Object transaction, final TransactionDefinition definition) {
super.doBegin(transaction, definition); super.doBegin(transaction, definition);
final EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager final String currentTenant = tenantAware.getCurrentTenant();
.getResource(getEntityManagerFactory()); if (currentTenant != null) {
final EntityManager em = emHolder.getEntityManager(); final EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager
.getResource(getEntityManagerFactory());
if (notTenantManagement(definition) && notCurrentTenantKeyGenerator(definition) final EntityManager em = emHolder.getEntityManager();
&& notRolloutScheduler(definition) && notGetOrCreateTenantMetadata(definition)) {
final String currentTenant = tenantAware.getCurrentTenant();
if (currentTenant == null) {
throw new TenantNotExistException("Tenant Unknown. Canceling transaction.");
}
em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase()); 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");
}
} }

View File

@@ -59,6 +59,10 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.annotation.Isolation; 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.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition; import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springframework.transaction.support.TransactionTemplate; import org.springframework.transaction.support.TransactionTemplate;
@@ -260,13 +264,7 @@ public class RolloutManagement {
entityManager.flush(); entityManager.flush();
executor.execute(() -> { executor.execute(() -> {
try { try {
final DefaultTransactionDefinition def = new DefaultTransactionDefinition(); createRolloutGroupsInNewTransaction(amountGroup, conditions, savedRollout);
def.setName("creatingRollout");
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
new TransactionTemplate(txManager, def).execute(status -> {
createRolloutGroups(amountGroup, conditions, savedRollout);
return null;
});
} finally { } finally {
creatingRollouts.remove(savedRollout.getName()); 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 * Method for creating rollout groups and calculating group sizes. Group
* sizes are calculated by dividing the total count of targets through the * 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 * amount of given groups. In same cases this will lead to less rollout
* groups than given by client. * groups than given by client.
* *
* @param amountGroup * @param amountOfGroups
* the amount of groups * the amount of groups
* @param conditions * @param conditions
* the rollout group conditions * the rollout group conditions
@@ -303,17 +310,17 @@ public class RolloutManagement {
* the rollout * the rollout
* @return the rollout with created groups * @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) { final Rollout savedRollout) {
int pageIndex = 0; int pageIndex = 0;
int groupIndex = 0; int groupIndex = 0;
final Long totalCount = savedRollout.getTotalTargets(); 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 // validate if the amount of groups that will be created are the amount
// of groups that the client what's to have created. // 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)); final int amountGroupCreation = (int) (Math.ceil((double) totalCount / (double) groupSize));
if (amountGroupCreation == (amountGroup - 1)) { if (amountGroupCreation == (amountOfGroups - 1)) {
amountGroupValidated--; amountGroupValidated--;
} }
RolloutGroup lastSavedGroup = null; RolloutGroup lastSavedGroup = null;
@@ -545,7 +552,7 @@ public class RolloutManagement {
* this check. This check is only applied if the last check is * this check. This check is only applied if the last check is
* less than (lastcheck-delay). * less than (lastcheck-delay).
*/ */
@Transactional(isolation = Isolation.READ_UNCOMMITTED) @Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_UNCOMMITTED)
@Modifying @Modifying
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_SYSTEM_CODE) + SpringEvalExpressions.IS_SYSTEM_CODE)

View File

@@ -165,6 +165,7 @@ public class SystemManagement {
* @return the {@link CurrentTenantKeyGenerator} * @return the {@link CurrentTenantKeyGenerator}
*/ */
@Bean @Bean
@Transactional(propagation = Propagation.SUPPORTS)
public CurrentTenantKeyGenerator currentTenantKeyGenerator() { public CurrentTenantKeyGenerator currentTenantKeyGenerator() {
return new CurrentTenantKeyGenerator(); return new CurrentTenantKeyGenerator();
} }
@@ -207,7 +208,6 @@ public class SystemManagement {
@NotNull @NotNull
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN + SpringEvalExpressions.HAS_AUTH_OR @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_SYSTEM_CODE) + SpringEvalExpressions.IS_SYSTEM_CODE)
// tenant independent
public List<String> findTenants() { public List<String> findTenants() {
return tenantMetaDataRepository.findAll().stream().map(md -> md.getTenant()).collect(Collectors.toList()); return tenantMetaDataRepository.findAll().stream().map(md -> md.getTenant()).collect(Collectors.toList());
} }
@@ -222,7 +222,6 @@ public class SystemManagement {
@Transactional(isolation = Isolation.READ_UNCOMMITTED) @Transactional(isolation = Isolation.READ_UNCOMMITTED)
@Modifying @Modifying
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
// tenant independent
public void deleteTenant(@NotNull final String tenant) { public void deleteTenant(@NotNull final String tenant) {
cacheManager.evictCaches(tenant); cacheManager.evictCaches(tenant);
cacheManager.getCache("currentTenant").evict(currentTenantKeyGenerator().generate(null, null)); cacheManager.getCache("currentTenant").evict(currentTenantKeyGenerator().generate(null, null));

View File

@@ -24,13 +24,18 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; 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) @IdClass(RolloutTargetGroupId.class)
@Entity @Entity
@Table(name = "sp_rollouttargetgroup") @Table(name = "sp_rollouttargetgroup")
@ExistenceChecking(ExistenceType.ASSUME_NON_EXISTENCE)
public class RolloutTargetGroup implements Serializable { public class RolloutTargetGroup implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@@ -78,6 +78,22 @@ public class MultiTenancyEntityTest extends AbstractIntegrationTest {
assertThat(findTargetsForTenant).hasSize(1); 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 @Test
@Description(value = "Ensures that tenant metadata is retrieved for the current tenant.") @Description(value = "Ensures that tenant metadata is retrieved for the current tenant.")
@WithUser(tenantId = "mytenant", autoCreateTenant = false, allSpPermissions = true) @WithUser(tenantId = "mytenant", autoCreateTenant = false, allSpPermissions = true)

View File

@@ -16,6 +16,7 @@ import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; 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.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -101,8 +102,8 @@ public class BaseSwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSoftwareMo
proxy.setVersion(bean.getVersion()); proxy.setVersion(bean.getVersion());
proxy.setVendor(bean.getVendor()); proxy.setVendor(bean.getVendor());
proxy.setDescription(bean.getDescription()); proxy.setDescription(bean.getDescription());
proxy.setCreatedByUser(HawkbitCommonUtil.getIMUser(bean.getCreatedBy())); proxy.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(bean));
proxy.setModifiedByUser(HawkbitCommonUtil.getIMUser(bean.getLastModifiedBy())); proxy.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(bean));
return proxy; return proxy;
} }

View File

@@ -240,6 +240,7 @@ public class SoftwareModuleAddUpdateWindow implements Serializable {
SPUIDefinitions.CREATE_UPDATE_WINDOW); SPUIDefinitions.CREATE_UPDATE_WINDOW);
window.setContent(mainLayout); window.setContent(mainLayout);
window.setModal(true); window.setModal(true);
nameTextField.focus();
} }
private void addDescriptionTextChangeListener() { private void addDescriptionTextChangeListener() {

View File

@@ -257,6 +257,7 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
mainLayout = new HorizontalLayout(); mainLayout = new HorizontalLayout();
mainLayout.addComponent(fieldButtonLayout); mainLayout.addComponent(fieldButtonLayout);
setCompositionRoot(mainLayout); setCompositionRoot(mainLayout);
typeName.focus();
} }
private void addListeners() { private void addListeners() {

View File

@@ -0,0 +1,185 @@
/**
* 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.ui.common;
import java.util.Collections;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.im.authentication.UserPrincipal;
import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
import com.vaadin.server.VaadinService;
/**
* A Utility class to user details e.g. username
*/
public final class UserDetailsFormatter {
private static final String TRIM_APPENDIX = "...";
private static final String DETAIL_SEPERATOR = ", ";
private UserDetailsFormatter() {
}
/**
* Load user details by the user name and format the user name to max 100
* characters.
*
* @see {@link UserDetailsFormatter#loadAndFormatUsername(String, int)}
*
* @param username
* the user name
* @return the formatted user name (max 100 characters) cannot be <null>
*/
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 <null>
*/
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 <null>
*/
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 <null>
*/
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 <null>
*/
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 <null>
*/
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());
}
}
}

View File

@@ -171,9 +171,7 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
} }
private Label createHeaderCaption() { private Label createHeaderCaption() {
final Label captionLabel = SPUIComponentProvider.getLabel(getDefaultCaption(), return SPUIComponentProvider.getLabel(getDefaultCaption(), SPUILabelDefinitions.SP_WIDGET_CAPTION);
SPUILabelDefinitions.SP_WIDGET_CAPTION);
return captionLabel;
} }
protected VerticalLayout getTabLayout() { protected VerticalLayout getTabLayout() {
@@ -213,22 +211,22 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
populateDetailsWidget(); populateDetailsWidget();
} }
protected void updateLogLayout(final VerticalLayout changeLogLayout, final Long lastModifiedAt, protected void populateLog() {
final String lastModifiedBy, final Long createdAt, final String createdBy, final I18N i18n) { logLayout.removeAllComponents();
changeLogLayout.removeAllComponents();
changeLogLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.created.at"),
createdAt == null ? "" : SPDateTimeUtil.getFormattedDate(createdAt)));
changeLogLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.created.by"), logLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.created.at"),
createdBy == null ? "" : HawkbitCommonUtil.getIMUser(createdBy))); SPDateTimeUtil.formatCreatedAt(selectedBaseEntity)));
if (null != lastModifiedAt) { logLayout.addComponent(SPUIComponentProvider.createCreatedByLabel(i18n, selectedBaseEntity));
changeLogLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.modified.date"),
SPDateTimeUtil.getFormattedDate(lastModifiedAt)));
changeLogLayout.addComponent(SPUIComponentProvider.createNameValueLabel(i18n.get("label.modified.by"), if (selectedBaseEntity == null || selectedBaseEntity.getLastModifiedAt() == null) {
lastModifiedBy == null ? "" : HawkbitCommonUtil.getIMUser(lastModifiedBy))); 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) { protected void updateDescriptionLayout(final String descriptionLabel, final String description) {
@@ -320,19 +318,6 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
return detailsLayout; 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() { private void populateDescription() {
if (selectedBaseEntity != null) { if (selectedBaseEntity != null) {
updateDescriptionLayout(i18n.get("label.description"), selectedBaseEntity.getDescription()); updateDescriptionLayout(i18n.get("label.description"), selectedBaseEntity.getDescription());

View File

@@ -20,7 +20,7 @@ import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent; import org.eclipse.hawkbit.ui.artifacts.event.UploadArtifactUIEvent;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState; 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.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -212,9 +212,9 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
item.getItemProperty(SPUILabelDefinitions.VAR_ID).setValue(baseEntity.getId()); item.getItemProperty(SPUILabelDefinitions.VAR_ID).setValue(baseEntity.getId());
item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(baseEntity.getDescription()); item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(baseEntity.getDescription());
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY) item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY)
.setValue(HawkbitCommonUtil.getIMUser(baseEntity.getCreatedBy())); .setValue(UserDetailsFormatter.loadAndFormatCreatedBy(baseEntity));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY) item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY)
.setValue(HawkbitCommonUtil.getIMUser(baseEntity.getLastModifiedBy())); .setValue(UserDetailsFormatter.loadAndFormatLastModifiedBy(baseEntity));
item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE) item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(baseEntity.getCreatedAt())); .setValue(SPDateTimeUtil.getFormattedDate(baseEntity.getCreatedAt()));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE) item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE)
@@ -329,6 +329,17 @@ public abstract class AbstractTable<E extends NamedEntity, I> extends Table {
columnList.add( columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F)); 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)); 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; return columnList;
} }

View File

@@ -36,6 +36,8 @@ public class ProxyTarget extends Target {
private DistributionSet installedDistributionSet; private DistributionSet installedDistributionSet;
private DistributionSet assignedDistributionSet;
private TargetIdName targetIdName; private TargetIdName targetIdName;
private String assignedDistNameVersion; private String assignedDistNameVersion;
@@ -249,6 +251,21 @@ public class ProxyTarget extends Target {
this.installedDistributionSet = installedDistributionSet; 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 * @return the targetIdName
*/ */
@@ -297,4 +314,5 @@ public class ProxyTarget extends Target {
public void setStatus(final Status status) { public void setStatus(final Status status) {
this.status = status; this.status = status;
} }
} }

View File

@@ -12,7 +12,9 @@ import java.util.Arrays;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.DistributionSet; 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.SPUIButtonDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUIComboBoxDecorator; import org.eclipse.hawkbit.ui.decorators.SPUIComboBoxDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUIHeaderLayoutDecorator; 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.SPUITextAreaDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUITextFieldDecorator; import org.eclipse.hawkbit.ui.decorators.SPUITextFieldDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator; import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -328,6 +331,50 @@ public final class SPUIComponentProvider {
return nameValueLabel; 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. * Get Bold Text.
* *

View File

@@ -299,6 +299,7 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
mainWindowLayout.addComponent(colorLayout); mainWindowLayout.addComponent(colorLayout);
mainWindowLayout.addComponent(buttonLayout); mainWindowLayout.addComponent(buttonLayout);
setCompositionRoot(mainWindowLayout); setCompositionRoot(mainWindowLayout);
typeName.focus();
} }
private HorizontalLayout createTwinColumnLayout() { private HorizontalLayout createTwinColumnLayout() {

View File

@@ -20,6 +20,7 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType; 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.components.ProxyDistribution;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -113,8 +114,8 @@ public class ManageDistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt())); proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt()));
proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt())); proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt()));
proxyDistribution.setDescription(distributionSet.getDescription()); proxyDistribution.setDescription(distributionSet.getDescription());
proxyDistribution.setCreatedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy())); proxyDistribution.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(distributionSet));
proxyDistribution.setModifiedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy())); proxyDistribution.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(distributionSet));
proxyDistribution.setIsComplete(distributionSet.isComplete()); proxyDistribution.setIsComplete(distributionSet.isComplete());
proxyDistributions.add(proxyDistribution); proxyDistributions.add(proxyDistribution);
} }

View File

@@ -17,6 +17,7 @@ import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.CustomSoftwareModule; import org.eclipse.hawkbit.repository.model.CustomSoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; 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.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -99,8 +100,8 @@ public class SwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSwModuleItem>
proxyItem.setVersion(bean.getVersion()); proxyItem.setVersion(bean.getVersion());
proxyItem.setVendor(bean.getVendor()); proxyItem.setVendor(bean.getVendor());
proxyItem.setDescription(bean.getDescription()); proxyItem.setDescription(bean.getDescription());
proxyItem.setCreatedByUser(HawkbitCommonUtil.getIMUser(bean.getCreatedBy())); proxyItem.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(bean));
proxyItem.setModifiedByUser(HawkbitCommonUtil.getIMUser(bean.getLastModifiedBy())); proxyItem.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(bean));
proxyItem.setAssigned(customSoftwareModule.isAssigned()); proxyItem.setAssigned(customSoftwareModule.isAssigned());
proxyItem.setColour(bean.getType().getColour()); proxyItem.setColour(bean.getType().getColour());
proxyItem.setTypeId(bean.getType().getId()); proxyItem.setTypeId(bean.getType().getId());

View File

@@ -8,6 +8,7 @@
*/ */
package org.eclipse.hawkbit.ui.filtermanagement; package org.eclipse.hawkbit.ui.filtermanagement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@@ -17,10 +18,12 @@ import java.util.Map;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent; import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState; 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.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider; import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; 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 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. * Initialize the Action History Table.
*/ */
@@ -87,6 +94,7 @@ public class CreateOrUpdateFilterTable extends Table {
setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID); setId(SPUIComponetIdProvider.CUSTOM_FILTER_TARGET_TABLE_ID);
setSelectable(false); setSelectable(false);
eventBus.subscribe(this); eventBus.subscribe(this);
setItemDescriptionGenerator(new AssignInstalledDSTooltipGenerator());
} }
@PreDestroy @PreDestroy
@@ -160,6 +168,9 @@ public class CreateOrUpdateFilterTable extends Table {
private void setCollapsibleColumns() { private void setCollapsibleColumns() {
setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, true); setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, true);
setColumnCollapsed(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, 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_CREATED_DATE, Date.class, null);
container.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, true); 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.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_TARGET_STATUS, TargetUpdateStatus.class, null);
container.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true); 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<TableColumn> getVisbleColumns() { private List<TableColumn> 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_BY, i18n.get("header.modifiedBy"), 0.1F));
columnList.add( columnList.add(
new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), 0.1F)); 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, columnList.add(new TableColumn(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER,
i18n.get("header.assigned.ds"), 0.125F)); i18n.get("header.assigned.ds"), 0.125F));
columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, columnList.add(new TableColumn(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER,
i18n.get("header.installed.ds"), 0.125F)); 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; return columnList;
} }
@@ -244,4 +258,5 @@ public class CreateOrUpdateFilterTable extends Table {
populateTableData(); populateTableData();
eventBus.publish(this, CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON); eventBus.publish(this, CustomFilterUIEvent.UPDATE_TARGET_FILTER_SEARCH_ICON);
} }
} }

View File

@@ -15,6 +15,7 @@ import java.util.Map;
import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target; 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.components.ProxyTarget;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState; import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -118,8 +119,8 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt())); prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt()));
prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt())); prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt()));
prxyTarget.setCreatedAt(targ.getCreatedAt()); prxyTarget.setCreatedAt(targ.getCreatedAt());
prxyTarget.setCreatedByUser(HawkbitCommonUtil.getIMUser(targ.getCreatedBy())); prxyTarget.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(targ));
prxyTarget.setModifiedByUser(HawkbitCommonUtil.getIMUser(targ.getLastModifiedBy())); prxyTarget.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(targ));
final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId()); final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId());
final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet(); final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet();
prxyTarget.setInstalledDistributionSet(installedDistributionSet); prxyTarget.setInstalledDistributionSet(installedDistributionSet);

View File

@@ -14,6 +14,7 @@ import java.util.Map;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement; import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery; 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.components.ProxyTargetFilter;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -93,9 +94,9 @@ public class TargetFilterBeanQuery extends AbstractBeanQuery<ProxyTargetFilter>
proxyTarFilter.setName(tarFilterQuery.getName()); proxyTarFilter.setName(tarFilterQuery.getName());
proxyTarFilter.setId(tarFilterQuery.getId()); proxyTarFilter.setId(tarFilterQuery.getId());
proxyTarFilter.setCreatedDate(SPDateTimeUtil.getFormattedDate(tarFilterQuery.getCreatedAt())); proxyTarFilter.setCreatedDate(SPDateTimeUtil.getFormattedDate(tarFilterQuery.getCreatedAt()));
proxyTarFilter.setCreatedBy(HawkbitCommonUtil.getIMUser(tarFilterQuery.getCreatedBy())); proxyTarFilter.setCreatedBy(UserDetailsFormatter.loadAndFormatCreatedBy(tarFilterQuery));
proxyTarFilter.setModifiedDate(SPDateTimeUtil.getFormattedDate(tarFilterQuery.getLastModifiedAt())); proxyTarFilter.setModifiedDate(SPDateTimeUtil.getFormattedDate(tarFilterQuery.getLastModifiedAt()));
proxyTarFilter.setLastModifiedBy(HawkbitCommonUtil.getIMUser(tarFilterQuery.getLastModifiedBy())); proxyTarFilter.setLastModifiedBy(UserDetailsFormatter.loadAndFormatLastModifiedBy(tarFilterQuery));
proxyTarFilter.setQuery(tarFilterQuery.getQuery()); proxyTarFilter.setQuery(tarFilterQuery.getQuery());
proxyTargetFilter.add(proxyTarFilter); proxyTargetFilter.add(proxyTarFilter);
} }

View File

@@ -148,8 +148,9 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
addComponent(buttonsLayout); addComponent(buttonsLayout);
setComponentAlignment(madatoryLabel, Alignment.MIDDLE_LEFT); setComponentAlignment(madatoryLabel, Alignment.MIDDLE_LEFT);
distNameTextField.focus();
} }
/** /**
* Create required UI components. * Create required UI components.

View File

@@ -18,6 +18,7 @@ import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilte
import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.model.DistributionSet; 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.components.ProxyDistribution;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -129,8 +130,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt())); proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt()));
proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt())); proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt()));
proxyDistribution.setDescription(distributionSet.getDescription()); proxyDistribution.setDescription(distributionSet.getDescription());
proxyDistribution.setCreatedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy())); proxyDistribution.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(distributionSet));
proxyDistribution.setModifiedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy())); proxyDistribution.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(distributionSet));
proxyDistribution.setNameVersion( proxyDistribution.setNameVersion(
HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion())); HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion()));
proxyDistributions.add(proxyDistribution); proxyDistributions.add(proxyDistribution);

View File

@@ -238,6 +238,7 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
fieldLayout.addComponent(tagName); fieldLayout.addComponent(tagName);
fieldLayout.addComponent(tagDesc); fieldLayout.addComponent(tagDesc);
final HorizontalLayout colorLabelLayout = new HorizontalLayout(); final HorizontalLayout colorLabelLayout = new HorizontalLayout();
colorLabelLayout.addComponents(colorLabel, tagColorPreviewBtn); colorLabelLayout.addComponents(colorLabel, tagColorPreviewBtn);
fieldLayout.addComponent(colorLabelLayout); fieldLayout.addComponent(colorLabelLayout);
@@ -257,8 +258,8 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
mainLayout = new HorizontalLayout(); mainLayout = new HorizontalLayout();
mainLayout.addComponent(fieldButtonLayout); mainLayout.addComponent(fieldButtonLayout);
setCompositionRoot(mainLayout); setCompositionRoot(mainLayout);
tagName.focus();
} }

View File

@@ -152,7 +152,7 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
madatoryLabel.setVisible(Boolean.FALSE); madatoryLabel.setVisible(Boolean.FALSE);
} }
mainLayout.addComponents(madatoryLabel, controllerIDTextField, nameTextField, descTextArea, buttonsLayout); mainLayout.addComponents(madatoryLabel, controllerIDTextField, nameTextField, descTextArea, buttonsLayout);
nameTextField.focus();
} }
private void addListeners() { private void addListeners() {

View File

@@ -19,6 +19,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; 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.components.ProxyTarget;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -130,20 +131,24 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt())); prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt()));
prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt())); prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt()));
prxyTarget.setCreatedAt(targ.getCreatedAt()); prxyTarget.setCreatedAt(targ.getCreatedAt());
prxyTarget.setCreatedByUser(HawkbitCommonUtil.getIMUser(targ.getCreatedBy())); prxyTarget.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(targ));
prxyTarget.setModifiedByUser(HawkbitCommonUtil.getIMUser(targ.getLastModifiedBy())); prxyTarget.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(targ));
if (pinnedDistId == null) { final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId());
prxyTarget.setInstalledDistributionSet(null); final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet();
prxyTarget.setAssignedDistributionSet(null); final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet();
} else {
final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId()); prxyTarget.setInstalledDistributionSet(installedDistributionSet);
final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet(); prxyTarget.setAssignedDistributionSet(assignedDistributionSet);
prxyTarget.setInstalledDistributionSet(installedDistributionSet);
final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet(); if (installedDistributionSet != null) {
prxyTarget.setAssignedDistributionSet(assignedDistributionSet); 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.setUpdateStatus(targ.getTargetInfo().getUpdateStatus());
prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery()); prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery());
prxyTarget.setTargetInfo(targ.getTargetInfo()); prxyTarget.setTargetInfo(targ.getTargetInfo());

View File

@@ -24,7 +24,9 @@ import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TargetManagement; 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.DistributionSetIdName;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TargetIdName; 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.TargetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.common.ManagmentEntityState; 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.AbstractTable;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType; import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.filter.FilterExpression; 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.event.TargetTableEvent.TargetComponentEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.management.state.TargetTableFilters; 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.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider; import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
@@ -109,6 +113,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> implements
private static final int PROPERTY_DEPT = 3; private static final int PROPERTY_DEPT = 3;
private static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed"; private static final String ACTION_NOT_ALLOWED_MSG = "message.action.not.allowed";
@Autowired @Autowired
private transient TargetManagement targetManagement; private transient TargetManagement targetManagement;
@@ -136,6 +141,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> implements
addActionHandler(this); addActionHandler(this);
actionSelectAll = new ShortcutAction(i18n.get("action.target.table.selectall")); actionSelectAll = new ShortcutAction(i18n.get("action.target.table.selectall"));
actionUnSelectAll = new ShortcutAction(i18n.get("action.target.table.clear")); actionUnSelectAll = new ShortcutAction(i18n.get("action.target.table.clear"));
setItemDescriptionGenerator(new AssignInstalledDSTooltipGenerator());
} }
/** /**
@@ -329,6 +335,11 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> implements
if (!isMaximized()) { if (!isMaximized()) {
columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_POLL_TIME, "", 0.0F)); columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_POLL_TIME, "", 0.0F));
columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_PIN_TOGGLE_ICON, "", 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; return columnList;
@@ -739,7 +750,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> implements
.setValue(updatedTarget.getTargetInfo().getLastTargetQuery()); .setValue(updatedTarget.getTargetInfo().getLastTargetQuery());
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY) item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY)
.setValue(HawkbitCommonUtil.getIMUser(updatedTarget.getLastModifiedBy())); .setValue(UserDetailsFormatter.loadAndFormatLastModifiedBy(updatedTarget));
item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE) item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE)
.setValue(SPDateTimeUtil.getFormattedDate(updatedTarget.getLastModifiedAt())); .setValue(SPDateTimeUtil.getFormattedDate(updatedTarget.getLastModifiedAt()));
item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(updatedTarget.getDescription()); item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(updatedTarget.getDescription());

View File

@@ -18,23 +18,20 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.HawkbitServerProperties; import org.eclipse.hawkbit.HawkbitServerProperties;
import org.eclipse.hawkbit.im.authentication.PermissionService; 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.UiProperties;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.menu.DashboardEvent.PostViewChangeEvent; import org.eclipse.hawkbit.ui.menu.DashboardEvent.PostViewChangeEvent;
import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider; import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
import org.springframework.beans.factory.annotation.Autowired; 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.FontAwesome;
import com.vaadin.server.Page; import com.vaadin.server.Page;
import com.vaadin.server.ThemeResource; import com.vaadin.server.ThemeResource;
import com.vaadin.server.VaadinService;
import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.UIScope; import com.vaadin.spring.annotation.UIScope;
@@ -189,63 +186,27 @@ public final class DashboardMenu extends CustomComponent {
return links; 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() { private Component buildUserMenu() {
final MenuBar settings = new MenuBar(); final MenuBar settings = new MenuBar();
settings.addStyleName("user-menu"); settings.addStyleName("user-menu");
final UserDetails user = getCurrentUser(); settings.setHtmlContentAllowed(true);
final MenuItem settingsItem = settings.addItem("", new ThemeResource("images/profile-pic-57px.jpg"), null); 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)) { final String formattedTenant = UserDetailsFormatter.formatCurrentTenant();
settingsItem.setText(trimTanent(((UserPrincipal) user).getTenant()) + "\n" final String formattedUsername = UserDetailsFormatter.formatCurrentUsername();
+ concateFNameLName(((UserPrincipal) user).getFirstname(), ((UserPrincipal) user).getLastname())); String tenantAndUsernameHtml = "";
settingsItem.setDescription( if (!StringUtils.isEmpty(formattedTenant)) {
((UserPrincipal) user).getFirstname() + " / " + ((UserPrincipal) user).getLastname()); tenantAndUsernameHtml += formattedTenant + "<br>";
} 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());
} }
tenantAndUsernameHtml += formattedUsername;
settingsItem.setText(tenantAndUsernameHtml);
settingsItem.setDescription(formattedUsername);
settingsItem.setStyleName("user-menuitem");
settingsItem.addItem("Sign Out", selectedItem -> Page.getCurrent().setLocation("/UI/logout")); settingsItem.addItem("Sign Out", selectedItem -> Page.getCurrent().setLocation("/UI/logout"));
return settings; 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() { private Component buildToggleButton() {
final Button valoMenuToggleButton = new Button("Menu", (ClickListener) event -> { final Button valoMenuToggleButton = new Button("Menu", (ClickListener) event -> {
if (getCompositionRoot().getStyleName().contains(STYLE_VISIBLE)) { if (getCompositionRoot().getStyleName().contains(STYLE_VISIBLE)) {

View File

@@ -209,6 +209,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
actionTypeOptionGroupLayout, linkToHelp, getSaveDiscardButtonLayout()); actionTypeOptionGroupLayout, linkToHelp, getSaveDiscardButtonLayout());
mainLayout.setComponentAlignment(linkToHelp, Alignment.BOTTOM_RIGHT); mainLayout.setComponentAlignment(linkToHelp, Alignment.BOTTOM_RIGHT);
setCompositionRoot(mainLayout); setCompositionRoot(mainLayout);
rolloutName.focus();
} }
private HorizontalLayout getGroupDetailsLayout() { private HorizontalLayout getGroupDetailsLayout() {

View File

@@ -18,6 +18,7 @@ import org.eclipse.hawkbit.repository.DistributionSetFilter;
import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder; import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder;
import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet; 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.components.ProxyDistribution;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil; import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
@@ -62,7 +63,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]); sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]);
// Add sort // Add sort
for (int distId = 1; distId < sortPropertyIds.length; distId++) { 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<ProxyDistribution>
final List<ProxyDistribution> proxyDistributions = new ArrayList<>(); final List<ProxyDistribution> proxyDistributions = new ArrayList<>();
for (final DistributionSet distributionSet : distBeans) { for (final DistributionSet distributionSet : distBeans) {
final ProxyDistribution proxyDistribution = new ProxyDistribution(); final ProxyDistribution proxyDistribution = new ProxyDistribution();
proxyDistribution.setName(HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), proxyDistribution.setName(
distributionSet.getVersion())); HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion()));
proxyDistribution.setDescription(distributionSet.getDescription()); proxyDistribution.setDescription(distributionSet.getDescription());
proxyDistribution.setDistId(distributionSet.getId()); proxyDistribution.setDistId(distributionSet.getId());
proxyDistribution.setId(distributionSet.getId()); proxyDistribution.setId(distributionSet.getId());
@@ -112,8 +114,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt())); proxyDistribution.setCreatedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt()));
proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt())); proxyDistribution.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt()));
proxyDistribution.setDescription(distributionSet.getDescription()); proxyDistribution.setDescription(distributionSet.getDescription());
proxyDistribution.setCreatedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy())); proxyDistribution.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(distributionSet));
proxyDistribution.setModifiedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy())); proxyDistribution.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(distributionSet));
proxyDistribution.setIsComplete(distributionSet.isComplete()); proxyDistribution.setIsComplete(distributionSet.isComplete());
proxyDistributions.add(proxyDistribution); proxyDistributions.add(proxyDistribution);
} }

View File

@@ -8,7 +8,10 @@
*/ */
package org.eclipse.hawkbit.ui.rollout.rollout; package org.eclipse.hawkbit.ui.rollout.rollout;
import java.util.Set;
import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData; import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
import com.vaadin.server.FontAwesome; import com.vaadin.server.FontAwesome;
@@ -19,123 +22,196 @@ import com.vaadin.server.FontAwesome;
*/ */
public class ProxyRollout extends Rollout { 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() { private String discription;
return rolloutRendererData;
}
public void setRolloutRendererData(RolloutRendererData rendererData) { private String type;
this.rolloutRendererData = rendererData;
}
/** private Set<SoftwareModule> swModules;
* @return the distributionSetNameVersion
*/
public String getDistributionSetNameVersion() {
return distributionSetNameVersion;
}
/** /**
* @param distributionSetNameVersion * @return the isRequiredMigrationStep
* the distributionSetNameVersion to set */
*/
public void setDistributionSetNameVersion(final String distributionSetNameVersion) {
this.distributionSetNameVersion = distributionSetNameVersion;
}
/** public Boolean getIsRequiredMigrationStep() {
* @return the numberOfGroups return isRequiredMigrationStep;
*/ }
public Long getNumberOfGroups() {
return numberOfGroups;
}
/** /**
* @param numberOfGroups * @param isRequiredMigrationStep
* the numberOfGroups to set * the isRequiredMigrationStep to set
*/ */
public void setNumberOfGroups(final Long numberOfGroups) {
this.numberOfGroups = numberOfGroups;
}
/** public void setIsRequiredMigrationStep(Boolean isRequiredMigrationStep) {
* @return the createdDate this.isRequiredMigrationStep = isRequiredMigrationStep;
*/ }
public String getCreatedDate() {
return createdDate;
}
/** /**
* @param createdDate * @return the discription
* the createdDate to set */
*/
public void setCreatedDate(final String createdDate) {
this.createdDate = createdDate;
}
/** public String getDiscription() {
* @return the modifiedDate return discription;
*/ }
public String getModifiedDate() {
return modifiedDate;
}
/** /**
* @param modifiedDate * @param discription
* the modifiedDate to set * the discription to set
*/ */
public void setModifiedDate(final String modifiedDate) {
this.modifiedDate = modifiedDate;
}
/** public void setDiscription(String discription) {
* @return the isActionRecieved this.discription = discription;
*/ }
public Boolean getIsActionRecieved() {
return isActionRecieved;
}
/** /**
* @param isActionRecieved * @return the type
* the isActionRecieved to set */
*/ public String getType() {
public void setIsActionRecieved(final Boolean isActionRecieved) { return type;
this.isActionRecieved = isActionRecieved; }
}
/** /**
* @return the totalTargetsCount * @param type
*/ * the type to set
public String getTotalTargetsCount() { */
return totalTargetsCount;
}
/** public void setType(String type) {
* @param totalTargetsCount this.type = type;
* the totalTargetsCount to set }
*/
public void setTotalTargetsCount(final String totalTargetsCount) {
this.totalTargetsCount = totalTargetsCount;
}
public String getAction() { /**
return FontAwesome.CIRCLE_O.getHtml(); *
} * @return the Set of Software modules
*/
public Set<SoftwareModule> getSwModules() {
return swModules;
}
/**
* @param swModules
* Set<SoftwareModule> to set
*/
public void setSwModules(Set<SoftwareModule> 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();
}
} }

View File

@@ -17,6 +17,7 @@ import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; 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.customrenderers.client.renderers.RolloutRendererData;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -40,165 +41,171 @@ import com.google.common.base.Strings;
*/ */
public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> { public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
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. * Parametric Constructor.
* *
* @param definition * @param definition
* as QueryDefinition * as QueryDefinition
* @param queryConfig * @param queryConfig
* as Config * as Config
* @param sortIds * @param sortIds
* as sort * as sort
* @param sortStates * @param sortStates
* as Sort status * as Sort status
*/ */
public RolloutBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig, public RolloutBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
final Object[] sortIds, final boolean[] sortStates) { final Object[] sortIds, final boolean[] sortStates) {
super(definition, queryConfig, sortIds, sortStates); super(definition, queryConfig, sortIds, sortStates);
searchText = getSearchText(); searchText = getSearchText();
if (HawkbitCommonUtil.checkBolArray(sortStates)) { if (HawkbitCommonUtil.checkBolArray(sortStates)) {
// Initalize Sor // Initalize Sor
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]); sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
// Add sort. // Add sort.
for (int targetId = 1; targetId < sortIds.length; targetId++) { for (int targetId = 1; targetId < sortIds.length; targetId++) {
sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId])); sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId]));
} }
} }
} }
private String getSearchText() { private String getSearchText() {
if (getRolloutUIState().getSearchText().isPresent()) { if (getRolloutUIState().getSearchText().isPresent()) {
return String.format("%%%s%%", getRolloutUIState().getSearchText().get()); return String.format("%%%s%%", getRolloutUIState().getSearchText().get());
} }
return null; return null;
} }
@Override @Override
protected ProxyRollout constructBean() { protected ProxyRollout constructBean() {
return new ProxyRollout(); return new ProxyRollout();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see * @see
* org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#loadBeans(int, * org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#loadBeans(int,
* int) * int)
*/ */
@Override @Override
protected List<ProxyRollout> loadBeans(final int startIndex, final int count) { protected List<ProxyRollout> loadBeans(final int startIndex, final int count) {
final Slice<Rollout> rolloutBeans; final Slice<Rollout> rolloutBeans;
if (Strings.isNullOrEmpty(searchText)) { if (Strings.isNullOrEmpty(searchText)) {
rolloutBeans = getRolloutManagement().findAllRolloutsWithDetailedStatus( rolloutBeans = getRolloutManagement().findAllRolloutsWithDetailedStatus(
new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort));
} else { } else {
rolloutBeans = getRolloutManagement().findRolloutByFilters( rolloutBeans = getRolloutManagement().findRolloutByFilters(
new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort), new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort),
searchText); searchText);
} }
return getProxyRolloutList(rolloutBeans); return getProxyRolloutList(rolloutBeans);
} }
private List<ProxyRollout> getProxyRolloutList(final Slice<Rollout> rolloutBeans) { private List<ProxyRollout> getProxyRolloutList(final Slice<Rollout> rolloutBeans) {
final List<ProxyRollout> proxyRolloutList = new ArrayList<>(); final List<ProxyRollout> proxyRolloutList = new ArrayList<>();
for (final Rollout rollout : rolloutBeans) { for (final Rollout rollout : rolloutBeans) {
final ProxyRollout proxyRollout = new ProxyRollout(); final ProxyRollout proxyRollout = new ProxyRollout();
proxyRollout.setName(rollout.getName()); proxyRollout.setName(rollout.getName());
proxyRollout.setDescription(rollout.getDescription()); proxyRollout.setDescription(rollout.getDescription());
final DistributionSet distributionSet = rollout.getDistributionSet(); final DistributionSet distributionSet = rollout.getDistributionSet();
proxyRollout.setDistributionSetNameVersion( proxyRollout.setDistributionSetNameVersion(
HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion())); HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), distributionSet.getVersion()));
proxyRollout.setDistributionSet(distributionSet); proxyRollout.setDistributionSet(distributionSet);
proxyRollout.setNumberOfGroups(Long.valueOf(rollout.getRolloutGroups().size())); proxyRollout.setNumberOfGroups(Long.valueOf(rollout.getRolloutGroups().size()));
proxyRollout.setCreatedDate(SPDateTimeUtil.getFormattedDate(rollout.getCreatedAt())); proxyRollout.setCreatedDate(SPDateTimeUtil.getFormattedDate(rollout.getCreatedAt()));
proxyRollout.setModifiedDate(SPDateTimeUtil.getFormattedDate(rollout.getLastModifiedAt())); proxyRollout.setModifiedDate(SPDateTimeUtil.getFormattedDate(rollout.getLastModifiedAt()));
proxyRollout.setCreatedBy(HawkbitCommonUtil.getIMUser(rollout.getCreatedBy())); proxyRollout.setCreatedBy(UserDetailsFormatter.loadAndFormatCreatedBy(rollout));
proxyRollout.setLastModifiedBy(HawkbitCommonUtil.getIMUser(rollout.getLastModifiedBy())); proxyRollout.setLastModifiedBy(UserDetailsFormatter.loadAndFormatLastModifiedBy(rollout));
proxyRollout.setForcedTime(rollout.getForcedTime()); proxyRollout.setForcedTime(rollout.getForcedTime());
proxyRollout.setId(rollout.getId()); proxyRollout.setId(rollout.getId());
proxyRollout.setStatus(rollout.getStatus()); proxyRollout.setStatus(rollout.getStatus());
proxyRollout.setRolloutRendererData(new RolloutRendererData(rollout.getName(), rollout.getStatus().toString())); proxyRollout
.setRolloutRendererData(new RolloutRendererData(rollout.getName(), rollout.getStatus().toString()));
final TotalTargetCountStatus totalTargetCountActionStatus = rollout.getTotalTargetCountStatus(); final TotalTargetCountStatus totalTargetCountActionStatus = rollout.getTotalTargetCountStatus();
proxyRollout.setTotalTargetCountStatus(totalTargetCountActionStatus); proxyRollout.setTotalTargetCountStatus(totalTargetCountActionStatus);
proxyRollout.setTotalTargetsCount(String.valueOf(rollout.getTotalTargets())); proxyRollout.setTotalTargetsCount(String.valueOf(rollout.getTotalTargets()));
proxyRolloutList.add(proxyRollout); proxyRollout.setDescription(distributionSet.getDescription());
} proxyRollout.setType(distributionSet.getType().getName());
return proxyRolloutList; proxyRollout.setIsRequiredMigrationStep(distributionSet.isRequiredMigrationStep());
} proxyRollout.setSwModules(distributionSet.getModules());
/* proxyRolloutList.add(proxyRollout);
* (non-Javadoc) }
* return proxyRolloutList;
* @see }
* org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#saveBeans(java
* .util.List, java.util.List, java.util.List)
*/
@Override
protected void saveBeans(final List<ProxyRollout> arg0, final List<ProxyRollout> arg1,
final List<ProxyRollout> arg2) {
/**
* CRUD operations on Target will be done through repository methods
*/
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#size() * @see
*/ * org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#saveBeans(java
@Override * .util.List, java.util.List, java.util.List)
public int size() { */
int size = getRolloutManagement().countRolloutsAll().intValue(); @Override
if (!Strings.isNullOrEmpty(searchText)) { protected void saveBeans(final List<ProxyRollout> arg0, final List<ProxyRollout> arg1,
size = getRolloutManagement().countRolloutsAllByFilters(searchText).intValue(); final List<ProxyRollout> arg2) {
} /**
return size; * CRUD operations on Target will be done through repository methods
} */
}
/** /*
* @return the rolloutManagement * (non-Javadoc)
*/ *
public RolloutManagement getRolloutManagement() { * @see org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#size()
if (null == rolloutManagement) { */
rolloutManagement = SpringContextHelper.getBean(RolloutManagement.class); @Override
} public int size() {
return rolloutManagement; int size = getRolloutManagement().countRolloutsAll().intValue();
} if (!Strings.isNullOrEmpty(searchText)) {
size = getRolloutManagement().countRolloutsAllByFilters(searchText).intValue();
}
return size;
}
/** /**
* @return the filterQueryManagement * @return the rolloutManagement
*/ */
public TargetFilterQueryManagement getFilterQueryManagement() { public RolloutManagement getRolloutManagement() {
if (null == filterQueryManagement) { if (null == rolloutManagement) {
filterQueryManagement = SpringContextHelper.getBean(TargetFilterQueryManagement.class); rolloutManagement = SpringContextHelper.getBean(RolloutManagement.class);
} }
return filterQueryManagement; return rolloutManagement;
} }
/** /**
* @return the rolloutUIState * @return the filterQueryManagement
*/ */
public RolloutUIState getRolloutUIState() { public TargetFilterQueryManagement getFilterQueryManagement() {
if (null == rolloutUIState) { if (null == filterQueryManagement) {
rolloutUIState = SpringContextHelper.getBean(RolloutUIState.class); filterQueryManagement = SpringContextHelper.getBean(TargetFilterQueryManagement.class);
} }
return rolloutUIState; return filterQueryManagement;
} }
/**
* @return the rolloutUIState
*/
public RolloutUIState getRolloutUIState() {
if (null == rolloutUIState) {
rolloutUIState = SpringContextHelper.getBean(RolloutUIState.class);
}
return rolloutUIState;
}
} }

View File

@@ -8,18 +8,25 @@
*/ */
package org.eclipse.hawkbit.ui.rollout.rollout; 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.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.eclipse.hawkbit.eventbus.event.RolloutChangeEvent; import org.eclipse.hawkbit.eventbus.event.RolloutChangeEvent;
import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus; 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.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.ui.common.grid.AbstractGrid; import org.eclipse.hawkbit.ui.common.grid.AbstractGrid;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData; 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 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"; private static final String ROLLOUT_RENDERER_DATA = "rolloutRendererData";
@Autowired @Autowired
@@ -160,8 +173,11 @@ public class RolloutListGrid extends AbstractGrid {
protected void addContainerProperties() { protected void addContainerProperties() {
final LazyQueryContainer rolloutGridContainer = (LazyQueryContainer) getContainerDataSource(); final LazyQueryContainer rolloutGridContainer = (LazyQueryContainer) getContainerDataSource();
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, false); 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(ROLLOUT_RENDERER_DATA, RolloutRendererData.class, null, false, false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.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, rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_STATUS, RolloutStatus.class, null, false,
false); false);
rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION, String.class, null, false, rolloutGridContainer.addContainerProperty(SPUILabelDefinitions.VAR_DIST_NAME_VERSION, String.class, null, false,
@@ -216,6 +232,9 @@ public class RolloutListGrid extends AbstractGrid {
@Override @Override
protected void setColumnHeaderNames() { protected void setColumnHeaderNames() {
getColumn(ROLLOUT_RENDERER_DATA).setHeaderCaption(i18n.get("header.name")); 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_DIST_NAME_VERSION).setHeaderCaption(i18n.get("header.distributionset"));
getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setHeaderCaption(i18n.get("header.numberofgroups")); getColumn(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS).setHeaderCaption(i18n.get("header.numberofgroups"));
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setHeaderCaption(i18n.get("header.total.targets")); getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS).setHeaderCaption(i18n.get("header.total.targets"));
@@ -240,6 +259,9 @@ public class RolloutListGrid extends AbstractGrid {
final List<Object> columnList = new ArrayList<>(); final List<Object> columnList = new ArrayList<>();
columnList.add(ROLLOUT_RENDERER_DATA); columnList.add(ROLLOUT_RENDERER_DATA);
columnList.add(SPUILabelDefinitions.VAR_DIST_NAME_VERSION); columnList.add(SPUILabelDefinitions.VAR_DIST_NAME_VERSION);
columnList.add(DS_TYPE);
columnList.add(SW_MODULES);
columnList.add(IS_REQUIRED_MIGRATION_STEP);
columnList.add(SPUILabelDefinitions.VAR_STATUS); columnList.add(SPUILabelDefinitions.VAR_STATUS);
columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS); columnList.add(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS);
columnList.add(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS); columnList.add(SPUILabelDefinitions.VAR_NUMBER_OF_GROUPS);
@@ -264,6 +286,9 @@ public class RolloutListGrid extends AbstractGrid {
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE); columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_DATE);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY); columnsToBeHidden.add(SPUILabelDefinitions.VAR_MODIFIED_BY);
columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC); columnsToBeHidden.add(SPUILabelDefinitions.VAR_DESC);
columnsToBeHidden.add(IS_REQUIRED_MIGRATION_STEP);
columnsToBeHidden.add(DS_TYPE);
columnsToBeHidden.add(SW_MODULES);
for (final Object propertyId : columnsToBeHidden) { for (final Object propertyId : columnsToBeHidden) {
getColumn(propertyId).setHidden(true); getColumn(propertyId).setHidden(true);
} }
@@ -456,10 +481,49 @@ public class RolloutListGrid extends AbstractGrid {
} else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) { } else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) {
return DistributionBarHelper return DistributionBarHelper
.getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap()); .getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap());
} else if (SPUILabelDefinitions.VAR_DIST_NAME_VERSION.equals(cell.getPropertyId())) {
return getDSDetails(cell.getItem());
} }
return null; return null;
} }
private String getDSDetails(final Item rolloutItem) {
final StringBuilder swModuleNames = new StringBuilder();
final StringBuilder swModuleVendors = new StringBuilder();
final Set<SoftwareModule> swModules = (Set<SoftwareModule>) rolloutItem.getItemProperty(SW_MODULES).getValue();
swModules.forEach(swModule -> {
swModuleNames.append(swModule.getName());
swModuleNames.append(" , ");
swModuleVendors.append(swModule.getVendor());
swModuleVendors.append(" , ");
});
final StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(HTML_UL_OPEN_TAG);
stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append(" DistributionSet Description : ")
.append((String) rolloutItem.getItemProperty(SPUILabelDefinitions.VAR_DESC).getValue());
stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append(" DistributionSet Type : ")
.append((String) rolloutItem.getItemProperty(DS_TYPE).getValue());
stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append("Required Migration step : ")
.append((boolean) rolloutItem.getItemProperty(IS_REQUIRED_MIGRATION_STEP).getValue() ? "Yes" : "No");
stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString());
stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString());
stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append(HTML_UL_CLOSE_TAG);
return stringBuilder.toString();
}
enum ACTION { enum ACTION {
PAUSE, RESUME, START, UPDATE PAUSE, RESUME, START, UPDATE
} }
@@ -569,14 +633,14 @@ public class RolloutListGrid extends AbstractGrid {
@Override @Override
public TotalTargetCountStatus convertToModel(final String value, public TotalTargetCountStatus convertToModel(final String value,
final Class<? extends TotalTargetCountStatus> targetType, final Locale locale) final Class<? extends TotalTargetCountStatus> targetType, final Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException { throws com.vaadin.data.util.converter.Converter.ConversionException {
return null; return null;
} }
@Override @Override
public String convertToPresentation(final TotalTargetCountStatus value, public String convertToPresentation(final TotalTargetCountStatus value,
final Class<? extends String> targetType, final Locale locale) final Class<? extends String> targetType, final Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException { throws com.vaadin.data.util.converter.Converter.ConversionException {
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap()); return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
} }

View File

@@ -15,6 +15,7 @@ import java.util.Map;
import org.eclipse.hawkbit.repository.RolloutGroupManagement; import org.eclipse.hawkbit.repository.RolloutGroupManagement;
import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData; import org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRendererData;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -35,160 +36,160 @@ import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
*/ */
public class RolloutGroupBeanQuery extends AbstractBeanQuery<ProxyRolloutGroup> { public class RolloutGroupBeanQuery extends AbstractBeanQuery<ProxyRolloutGroup> {
private static final long serialVersionUID = 5342450502894318589L; private static final long serialVersionUID = 5342450502894318589L;
private Sort sort = new Sort(Direction.ASC, "createdAt"); private Sort sort = new Sort(Direction.ASC, "createdAt");
private transient Page<RolloutGroup> firstPageRolloutGroupSets = null; private transient Page<RolloutGroup> firstPageRolloutGroupSets = null;
private transient RolloutManagement rolloutManagement; private transient RolloutManagement rolloutManagement;
private transient RolloutGroupManagement rolloutGroupManagement; private transient RolloutGroupManagement rolloutGroupManagement;
private transient RolloutUIState rolloutUIState; private transient RolloutUIState rolloutUIState;
private final Long rolloutId; private final Long rolloutId;
/** /**
* Parametric Constructor. * Parametric Constructor.
* *
* @param definition * @param definition
* as QueryDefinition * as QueryDefinition
* @param queryConfig * @param queryConfig
* as Config * as Config
* @param sortPropertyIds * @param sortPropertyIds
* as sort * as sort
* @param sortStates * @param sortStates
* as Sort status * as Sort status
*/ */
public RolloutGroupBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig, public RolloutGroupBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
final Object[] sortPropertyIds, final boolean[] sortStates) { final Object[] sortPropertyIds, final boolean[] sortStates) {
super(definition, queryConfig, sortPropertyIds, sortStates); super(definition, queryConfig, sortPropertyIds, sortStates);
rolloutId = getRolloutId(); rolloutId = getRolloutId();
if (HawkbitCommonUtil.checkBolArray(sortStates)) { if (HawkbitCommonUtil.checkBolArray(sortStates)) {
// Initalize Sor // Initalize Sor
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]); sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]);
// Add sort. // Add sort.
for (int targetId = 1; targetId < sortPropertyIds.length; targetId++) { for (int targetId = 1; targetId < sortPropertyIds.length; targetId++) {
sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC,
(String) sortPropertyIds[targetId])); (String) sortPropertyIds[targetId]));
} }
} }
} }
/** /**
* @return * @return
*/ */
private Long getRolloutId() { private Long getRolloutId() {
return getRolloutUIState().getRolloutId().isPresent() ? getRolloutUIState().getRolloutId().get() : null; return getRolloutUIState().getRolloutId().isPresent() ? getRolloutUIState().getRolloutId().get() : null;
} }
@Override @Override
protected ProxyRolloutGroup constructBean() { protected ProxyRolloutGroup constructBean() {
return new ProxyRolloutGroup(); return new ProxyRolloutGroup();
} }
@Override @Override
protected List<ProxyRolloutGroup> loadBeans(final int startIndex, final int count) { protected List<ProxyRolloutGroup> loadBeans(final int startIndex, final int count) {
List<RolloutGroup> proxyRolloutGroupsList = new ArrayList<>(); List<RolloutGroup> proxyRolloutGroupsList = new ArrayList<>();
if (startIndex == 0 && firstPageRolloutGroupSets != null) { if (startIndex == 0 && firstPageRolloutGroupSets != null) {
proxyRolloutGroupsList = firstPageRolloutGroupSets.getContent(); proxyRolloutGroupsList = firstPageRolloutGroupSets.getContent();
} else if (null != rolloutId) { } else if (null != rolloutId) {
proxyRolloutGroupsList = getRolloutGroupManagement() proxyRolloutGroupsList = getRolloutGroupManagement()
.findAllRolloutGroupsWithDetailedStatus(rolloutId, new PageRequest(startIndex / count, count)) .findAllRolloutGroupsWithDetailedStatus(rolloutId, new PageRequest(startIndex / count, count))
.getContent(); .getContent();
} }
return getProxyRolloutGroupList(proxyRolloutGroupsList); return getProxyRolloutGroupList(proxyRolloutGroupsList);
} }
private List<ProxyRolloutGroup> getProxyRolloutGroupList(final List<RolloutGroup> rolloutGroupBeans) { private List<ProxyRolloutGroup> getProxyRolloutGroupList(final List<RolloutGroup> rolloutGroupBeans) {
final List<ProxyRolloutGroup> proxyRolloutGroupsList = new ArrayList<>(); final List<ProxyRolloutGroup> proxyRolloutGroupsList = new ArrayList<>();
for (final RolloutGroup rolloutGroup : rolloutGroupBeans) { for (final RolloutGroup rolloutGroup : rolloutGroupBeans) {
final ProxyRolloutGroup proxyRolloutGroup = new ProxyRolloutGroup(); final ProxyRolloutGroup proxyRolloutGroup = new ProxyRolloutGroup();
proxyRolloutGroup.setName(rolloutGroup.getName()); proxyRolloutGroup.setName(rolloutGroup.getName());
proxyRolloutGroup.setDescription(rolloutGroup.getDescription()); proxyRolloutGroup.setDescription(rolloutGroup.getDescription());
proxyRolloutGroup.setCreatedDate(SPDateTimeUtil.getFormattedDate(rolloutGroup.getCreatedAt())); proxyRolloutGroup.setCreatedDate(SPDateTimeUtil.getFormattedDate(rolloutGroup.getCreatedAt()));
proxyRolloutGroup.setModifiedDate(SPDateTimeUtil.getFormattedDate(rolloutGroup.getLastModifiedAt())); proxyRolloutGroup.setModifiedDate(SPDateTimeUtil.getFormattedDate(rolloutGroup.getLastModifiedAt()));
proxyRolloutGroup.setCreatedBy(HawkbitCommonUtil.getIMUser(rolloutGroup.getCreatedBy())); proxyRolloutGroup.setCreatedBy(UserDetailsFormatter.loadAndFormatCreatedBy(rolloutGroup));
proxyRolloutGroup.setLastModifiedBy(HawkbitCommonUtil.getIMUser(rolloutGroup.getLastModifiedBy())); proxyRolloutGroup.setLastModifiedBy(UserDetailsFormatter.loadAndFormatLastModifiedBy(rolloutGroup));
proxyRolloutGroup.setId(rolloutGroup.getId()); proxyRolloutGroup.setId(rolloutGroup.getId());
proxyRolloutGroup.setStatus(rolloutGroup.getStatus()); proxyRolloutGroup.setStatus(rolloutGroup.getStatus());
proxyRolloutGroup.setErrorAction(rolloutGroup.getErrorAction()); proxyRolloutGroup.setErrorAction(rolloutGroup.getErrorAction());
proxyRolloutGroup.setErrorActionExp(rolloutGroup.getErrorActionExp()); proxyRolloutGroup.setErrorActionExp(rolloutGroup.getErrorActionExp());
proxyRolloutGroup.setErrorCondition(rolloutGroup.getErrorCondition()); proxyRolloutGroup.setErrorCondition(rolloutGroup.getErrorCondition());
proxyRolloutGroup.setErrorConditionExp(rolloutGroup.getErrorConditionExp()); proxyRolloutGroup.setErrorConditionExp(rolloutGroup.getErrorConditionExp());
proxyRolloutGroup.setSuccessCondition(rolloutGroup.getSuccessCondition()); proxyRolloutGroup.setSuccessCondition(rolloutGroup.getSuccessCondition());
proxyRolloutGroup.setSuccessConditionExp(rolloutGroup.getSuccessConditionExp()); proxyRolloutGroup.setSuccessConditionExp(rolloutGroup.getSuccessConditionExp());
proxyRolloutGroup.setFinishedPercentage(calculateFinishedPercentage(rolloutGroup)); proxyRolloutGroup.setFinishedPercentage(calculateFinishedPercentage(rolloutGroup));
proxyRolloutGroup.setRolloutRendererData(new RolloutRendererData(rolloutGroup.getName(), null)); proxyRolloutGroup.setRolloutRendererData(new RolloutRendererData(rolloutGroup.getName(), null));
proxyRolloutGroup.setTotalTargetsCount(String.valueOf(rolloutGroup.getTotalTargets())); proxyRolloutGroup.setTotalTargetsCount(String.valueOf(rolloutGroup.getTotalTargets()));
proxyRolloutGroup.setTotalTargetCountStatus(rolloutGroup.getTotalTargetCountStatus()); proxyRolloutGroup.setTotalTargetCountStatus(rolloutGroup.getTotalTargetCountStatus());
proxyRolloutGroupsList.add(proxyRolloutGroup); proxyRolloutGroupsList.add(proxyRolloutGroup);
} }
return proxyRolloutGroupsList; return proxyRolloutGroupsList;
} }
private String calculateFinishedPercentage(final RolloutGroup rolloutGroup) { private String calculateFinishedPercentage(final RolloutGroup rolloutGroup) {
return HawkbitCommonUtil.formattingFinishedPercentage(rolloutGroup, getRolloutManagement() return HawkbitCommonUtil.formattingFinishedPercentage(rolloutGroup, getRolloutManagement()
.getFinishedPercentForRunningGroup(rolloutGroup.getRollout().getId(), rolloutGroup)); .getFinishedPercentForRunningGroup(rolloutGroup.getRollout().getId(), rolloutGroup));
} }
@Override @Override
protected void saveBeans(final List<ProxyRolloutGroup> arg0, final List<ProxyRolloutGroup> arg1, protected void saveBeans(final List<ProxyRolloutGroup> arg0, final List<ProxyRolloutGroup> arg1,
final List<ProxyRolloutGroup> arg2) { final List<ProxyRolloutGroup> arg2) {
/** /**
* CRUD operations be done through repository methods. * CRUD operations be done through repository methods.
*/ */
} }
@Override @Override
public int size() { public int size() {
long size = 0; long size = 0;
if (null != rolloutId) { if (null != rolloutId) {
firstPageRolloutGroupSets = getRolloutGroupManagement().findAllRolloutGroupsWithDetailedStatus(rolloutId, firstPageRolloutGroupSets = getRolloutGroupManagement().findAllRolloutGroupsWithDetailedStatus(rolloutId,
new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort)); new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort));
size = firstPageRolloutGroupSets.getTotalElements(); size = firstPageRolloutGroupSets.getTotalElements();
} }
if (size > Integer.MAX_VALUE) { if (size > Integer.MAX_VALUE) {
return Integer.MAX_VALUE; return Integer.MAX_VALUE;
} }
return (int) size; return (int) size;
} }
/** /**
* @return the rolloutManagement * @return the rolloutManagement
*/ */
public RolloutManagement getRolloutManagement() { public RolloutManagement getRolloutManagement() {
if (null == rolloutManagement) { if (null == rolloutManagement) {
rolloutManagement = SpringContextHelper.getBean(RolloutManagement.class); rolloutManagement = SpringContextHelper.getBean(RolloutManagement.class);
} }
return rolloutManagement; return rolloutManagement;
} }
/** /**
* @return the rolloutManagement * @return the rolloutManagement
*/ */
public RolloutGroupManagement getRolloutGroupManagement() { public RolloutGroupManagement getRolloutGroupManagement() {
if (null == rolloutGroupManagement) { if (null == rolloutGroupManagement) {
rolloutGroupManagement = SpringContextHelper.getBean(RolloutGroupManagement.class); rolloutGroupManagement = SpringContextHelper.getBean(RolloutGroupManagement.class);
} }
return rolloutGroupManagement; return rolloutGroupManagement;
} }
/** /**
* @return the rolloutUIState * @return the rolloutUIState
*/ */
public RolloutUIState getRolloutUIState() { public RolloutUIState getRolloutUIState() {
if (null == rolloutUIState) { if (null == rolloutUIState) {
rolloutUIState = SpringContextHelper.getBean(RolloutUIState.class); rolloutUIState = SpringContextHelper.getBean(RolloutUIState.class);
} }
return rolloutUIState; return rolloutUIState;
} }
} }

View File

@@ -17,6 +17,7 @@ import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetWithActionStatus; import org.eclipse.hawkbit.repository.model.TargetWithActionStatus;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.components.ProxyTarget; import org.eclipse.hawkbit.ui.components.ProxyTarget;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState; import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -105,8 +106,8 @@ public class RolloutGroupTargetsBeanQuery extends AbstractBeanQuery<ProxyTarget>
prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt())); prxyTarget.setLastModifiedDate(SPDateTimeUtil.getFormattedDate(targ.getLastModifiedAt()));
prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt())); prxyTarget.setCreatedDate(SPDateTimeUtil.getFormattedDate(targ.getCreatedAt()));
prxyTarget.setCreatedAt(targ.getCreatedAt()); prxyTarget.setCreatedAt(targ.getCreatedAt());
prxyTarget.setCreatedByUser(HawkbitCommonUtil.getIMUser(targ.getCreatedBy())); prxyTarget.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(targ));
prxyTarget.setModifiedByUser(HawkbitCommonUtil.getIMUser(targ.getLastModifiedBy())); prxyTarget.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(targ));
if (targetWithActionStatus.getStatus() != null) { if (targetWithActionStatus.getStatus() != null) {
prxyTarget.setStatus(targetWithActionStatus.getStatus()); prxyTarget.setStatus(targetWithActionStatus.getStatus());
} }

View File

@@ -113,7 +113,7 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
downloadAnonymousCheckBox = SPUIComponentProvider.getCheckBox("", DIST_CHECKBOX_STYLE, null, false, ""); downloadAnonymousCheckBox = SPUIComponentProvider.getCheckBox("", DIST_CHECKBOX_STYLE, null, false, "");
downloadAnonymousCheckBox.setId("downloadanonymouscheckbox"); downloadAnonymousCheckBox.setId("downloadanonymouscheckbox");
downloadAnonymousCheckBox.setValue(targetSecurityTokenAuthenticationConfigurationItem.isConfigEnabled()); downloadAnonymousCheckBox.setValue(anonymousDownloadAuthenticationConfigurationItem.isConfigEnabled());
downloadAnonymousCheckBox.addValueChangeListener(this); downloadAnonymousCheckBox.addValueChangeListener(this);
anonymousDownloadAuthenticationConfigurationItem.addChangeListener(this); anonymousDownloadAuthenticationConfigurationItem.addChangeListener(this);
gridLayout.addComponent(downloadAnonymousCheckBox, 0, 3); gridLayout.addComponent(downloadAnonymousCheckBox, 0, 3);

View File

@@ -0,0 +1,83 @@
/**
* 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.ui.utils;
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.Set;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import com.vaadin.data.Item;
import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator;
import com.vaadin.ui.Component;
import com.vaadin.ui.Table;
public class AssignInstalledDSTooltipGenerator implements ItemDescriptionGenerator {
private static final long serialVersionUID = 688730421728162456L;
private static final String ASSIGN_DIST_SET = "assignedDistributionSet";
private static final String INSTALL_DIST_SET = "installedDistributionSet";
@Override
public String generateDescription(final Component source, final Object itemId, final Object propertyId) {
final DistributionSet distributionSet;
final Item item = ((Table) source).getItem(itemId);
if (propertyId != null) {
if (propertyId.equals(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER)) {
distributionSet = (DistributionSet) item.getItemProperty(ASSIGN_DIST_SET).getValue();
return getDSDetails(distributionSet);
} else if (propertyId.equals(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER)) {
distributionSet = (DistributionSet) item.getItemProperty(INSTALL_DIST_SET).getValue();
return getDSDetails(distributionSet);
}
}
return null;
}
private String getDSDetails(final DistributionSet distributionSet) {
if (distributionSet == null) {
return null;
}
final StringBuilder swModuleNames = new StringBuilder();
final StringBuilder swModuleVendors = new StringBuilder();
final Set<SoftwareModule> swModules = distributionSet.getModules();
swModules.forEach(swModule -> {
swModuleNames.append(swModule.getName());
swModuleNames.append(" , ");
swModuleVendors.append(swModule.getVendor());
swModuleVendors.append(" , ");
});
final StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(HTML_UL_OPEN_TAG);
stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append(" DistributionSet Description : ").append(distributionSet.getDescription());
stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append(" DistributionSet Type : ").append((distributionSet.getType()).getName());
stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append(" Required Migration step : ")
.append(distributionSet.isRequiredMigrationStep() ? "Yes" : "No");
stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append("SoftWare Modules : ").append(swModuleNames.toString());
stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append(HTML_LI_OPEN_TAG);
stringBuilder.append("Vendor(s) : ").append(swModuleVendors.toString());
stringBuilder.append(HTML_LI_CLOSE_TAG);
stringBuilder.append(HTML_UL_CLOSE_TAG);
return stringBuilder.toString();
}
}

View File

@@ -20,9 +20,9 @@ import java.util.Map.Entry;
import java.util.TimeZone; import java.util.TimeZone;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.im.authentication.UserPrincipal;
import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.model.AssignmentResult; import org.eclipse.hawkbit.repository.model.AssignmentResult;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
@@ -34,9 +34,6 @@ import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status;
import org.eclipse.hawkbit.ui.rollout.StatusFontIcon; import org.eclipse.hawkbit.ui.rollout.StatusFontIcon;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery; import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
@@ -76,6 +73,11 @@ public final class HawkbitCommonUtil {
*/ */
public static final String SPAN_CLOSE = "</span>"; public static final String SPAN_CLOSE = "</span>";
public static final String HTML_LI_CLOSE_TAG = "</li>";
public static final String HTML_LI_OPEN_TAG = "<li>";
public static final String HTML_UL_CLOSE_TAG = "</ul>";
public static final String HTML_UL_OPEN_TAG = "<ul>";
private static final Logger LOG = LoggerFactory.getLogger(HawkbitCommonUtil.class); private static final Logger LOG = LoggerFactory.getLogger(HawkbitCommonUtil.class);
private static final String JS_DRAG_COUNT_REM_CHILD = " if(x) { document.head.removeChild(x); } "; private static final String JS_DRAG_COUNT_REM_CHILD = " if(x) { document.head.removeChild(x); } ";
@@ -107,6 +109,9 @@ public final class HawkbitCommonUtil {
private static final String DELETE_DROP_CREATE_SCRIPT = "var q = document.getElementById('show-delete-drop-hint'); if(q) { } else { showDeleteDrop = document.createElement('style'); showDeleteDrop.id=\"show-delete-drop-hint\"; document.head.appendChild(showDeleteDrop); }"; private static final String DELETE_DROP_CREATE_SCRIPT = "var q = document.getElementById('show-delete-drop-hint'); if(q) { } else { showDeleteDrop = document.createElement('style'); showDeleteDrop.id=\"show-delete-drop-hint\"; document.head.appendChild(showDeleteDrop); }";
private static final String DELETE_TAG_DROP_REMOVE_SCRIPT = "var o = document.getElementById('show-delete-drop-hint'); if(o) { document.head.removeChild(o); } "; private static final String DELETE_TAG_DROP_REMOVE_SCRIPT = "var o = document.getElementById('show-delete-drop-hint'); if(o) { document.head.removeChild(o); } ";
private static final String ASSIGN_DIST_SET = "assignedDistributionSet";
private static final String INSTALL_DIST_SET = "installedDistributionSet";
/** /**
* Define empty string. * Define empty string.
*/ */
@@ -605,31 +610,6 @@ public final class HawkbitCommonUtil {
return requiredExtraWidth + minTableWidth; return requiredExtraWidth + minTableWidth;
} }
/**
* get formatted name - lastname,firstname.
*
* @param user
* user name
* @return String formatted name
*/
public static String getFormattedName(final UserDetails user) {
final StringBuilder formattedName = new StringBuilder();
if (user instanceof UserPrincipal) {
if (trimAndNullIfEmpty(((UserPrincipal) user).getLastname()) != null) {
formattedName.append(((UserPrincipal) user).getLastname());
}
if (trimAndNullIfEmpty(((UserPrincipal) user).getFirstname()) != null) {
if (formattedName.length() > 0) {
formattedName.append(", ");
}
formattedName.append(((UserPrincipal) user).getFirstname());
}
} else if (user != null) {
formattedName.append(user.getUsername());
}
return formattedName.toString();
}
/** /**
* get the Last sequence of string which is after last dot in String. * get the Last sequence of string which is after last dot in String.
* *
@@ -686,30 +666,6 @@ public final class HawkbitCommonUtil {
return exeJS.toString(); return exeJS.toString();
} }
/**
* Get IM User for user UUID.
*
* @param uuid
* @return imReslovedUser user details
*/
public static String getIMUser(final String uuid) {
// Get modifed user
String imReslovedUser = HawkbitCommonUtil.SP_STRING_SPACE;
if (HawkbitCommonUtil.trimAndNullIfEmpty(uuid) != null) {
final UserDetailsService idManagement = SpringContextHelper.getBean(UserDetailsService.class);
try {
imReslovedUser = HawkbitCommonUtil.getFormattedName(idManagement.loadUserByUsername(uuid));
} catch (final UsernameNotFoundException e) { // NOSONAR
// nope not need to handle
}
// If Null display the UID
if (HawkbitCommonUtil.trimAndNullIfEmpty(imReslovedUser) == null) {
imReslovedUser = uuid;
}
}
return imReslovedUser;
}
/** /**
* Get formatted label.Appends ellipses if content does not fit the label. * Get formatted label.Appends ellipses if content does not fit the label.
* *
@@ -1090,6 +1046,10 @@ public final class HawkbitCommonUtil {
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP, String.class, null, targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP, String.class, null,
false, true); false, true);
targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true); targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true);
targetTableContainer.addContainerProperty(ASSIGN_DIST_SET, DistributionSet.class, null, false, true);
targetTableContainer.addContainerProperty(INSTALL_DIST_SET, DistributionSet.class, null, false, true);
} }
/** /**

View File

@@ -15,7 +15,9 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DurationFormatUtils; import org.apache.commons.lang3.time.DurationFormatUtils;
import org.eclipse.hawkbit.repository.model.BaseEntity;
import com.vaadin.server.WebBrowser; import com.vaadin.server.WebBrowser;
@@ -80,14 +82,45 @@ public final class SPDateTimeUtil {
* @param lastQueryDate * @param lastQueryDate
* @return String formatted date * @return String formatted date
*/ */
public static String getFormattedDate(final Long lastQueryDate) { public static String getFormattedDate(final Long lastQueryDate) {
return formatDate(lastQueryDate, null);
}
/**
* Get formatted date 'created at' by entity.
*
* @param baseEntity
* the entity
* @return String formatted date
*/
public static String formatCreatedAt(final BaseEntity baseEntity) {
if (baseEntity == null) {
return StringUtils.EMPTY;
}
return formatDate(baseEntity.getCreatedAt(), StringUtils.EMPTY);
}
/**
* Get formatted date 'last modified at' by entity.
*
* @param baseEntity
* the entity
* @return String formatted date
*/
public static String formatLastModifiedAt(final BaseEntity baseEntity) {
if (baseEntity == null) {
return StringUtils.EMPTY;
}
return formatDate(baseEntity.getLastModifiedAt(), StringUtils.EMPTY);
}
private static String formatDate(final Long lastQueryDate, final String defaultString) {
if (lastQueryDate != null) { if (lastQueryDate != null) {
final SimpleDateFormat format = new SimpleDateFormat(SPUIDefinitions.LAST_QUERY_DATE_FORMAT); final SimpleDateFormat format = new SimpleDateFormat(SPUIDefinitions.LAST_QUERY_DATE_FORMAT);
format.setTimeZone(getBrowserTimeZone()); format.setTimeZone(getBrowserTimeZone());
return format.format(new Date(lastQueryDate)); return format.format(new Date(lastQueryDate));
} }
return null; return defaultString;
} }
/** /**

View File

@@ -143,9 +143,15 @@
.valo-menu-title { .valo-menu-title {
line-height: 1.2; line-height: 1.2;
} }
.v-menubar-user-menu:after { .v-menubar-user-menu:after {
display: none; display: none;
} }
.v-menubar-menuitem-user-menuitem {
width: 100%;
}
.v-menubar-user-menu > .v-menubar-menuitem { .v-menubar-user-menu > .v-menubar-menuitem {
white-space: normal !important; white-space: normal !important;
.v-icon { .v-icon {

View File

@@ -74,7 +74,7 @@
<!-- Vaadin versions - START --> <!-- Vaadin versions - START -->
<vaadin.spring.version>1.0.0</vaadin.spring.version> <vaadin.spring.version>1.0.0</vaadin.spring.version>
<vaadin.spring.addon.version>0.0.6.RELEASE</vaadin.spring.addon.version> <vaadin.spring.addon.version>0.0.6.RELEASE</vaadin.spring.addon.version>
<vaadin.version>7.6.4</vaadin.version> <vaadin.version>7.6.5</vaadin.version>
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version> <vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
<vaadin.addon.vaadin-lazyquerycontainer.version>7.4.0.1</vaadin.addon.vaadin-lazyquerycontainer.version> <vaadin.addon.vaadin-lazyquerycontainer.version>7.4.0.1</vaadin.addon.vaadin-lazyquerycontainer.version>
<vaadin.addon.flexibleoptiongroup.version>2.2.0</vaadin.addon.flexibleoptiongroup.version> <vaadin.addon.flexibleoptiongroup.version>2.2.0</vaadin.addon.flexibleoptiongroup.version>
@@ -94,7 +94,7 @@
<json-path.version>0.9.1</json-path.version> <json-path.version>0.9.1</json-path.version>
<aspectj.version>1.8.5</aspectj.version> <aspectj.version>1.8.5</aspectj.version>
<guava.version>19.0</guava.version> <guava.version>19.0</guava.version>
<mariadb-java-client.version>1.3.5</mariadb-java-client.version> <mariadb-java-client.version>1.4.3</mariadb-java-client.version>
<embedded-mongo.version>1.50.2</embedded-mongo.version> <embedded-mongo.version>1.50.2</embedded-mongo.version>
<jersey-client.version>1.18.1</jersey-client.version> <jersey-client.version>1.18.1</jersey-client.version>
<javax.el-api.version>2.2.4</javax.el-api.version> <javax.el-api.version>2.2.4</javax.el-api.version>