Software module metadata available to targets (in DMF and DDI) (#608)

* Software module metadata can be configure as target visible.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Added metadata to DDI.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Managed by UI.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Complete DMF integration and started UI.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Add DMF tests and completed UI.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Add RSQL test. Fix sonar issues.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Add JavaDocs. foreachtenant robustness.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Review feedback included.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Updated DMF docs.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* targetVisible optional in builder.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix typos.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix checkbox ID.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* DB optimization.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix component ID of sm metadat details tab.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2017-12-16 17:17:54 +01:00
committed by GitHub
parent c3035231e2
commit 80d9f1b8fc
108 changed files with 1883 additions and 917 deletions

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.repository;
import java.net.URI;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -25,6 +26,7 @@ import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.ActionStatus;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
@@ -72,7 +74,20 @@ public interface ControllerManagement {
* @return {@link SoftwareModule} identified by ID
*/
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
Optional<SoftwareModule> getSoftwareModule(@NotNull final Long moduleId);
Optional<SoftwareModule> getSoftwareModule(@NotNull Long moduleId);
/**
* Retrieves {@link SoftwareModuleMetadata} where
* {@link SoftwareModuleMetadata#isTargetVisible()}.
*
* @param moduleId
* of the {@link SoftwareModule}
* @return list of {@link SoftwareModuleMetadata} with maximum size of
* {@link RepositoryConstants#MAX_META_DATA_COUNT}
*/
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
Map<Long, List<SoftwareModuleMetadata>> findTargetVisibleMetaDataBySoftwareModuleId(
@NotNull Collection<Long> moduleId);
/**
* Simple addition of a new {@link ActionStatus} entry to the {@link Action}

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.repository;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.builder.ActionStatusBuilder;
import org.eclipse.hawkbit.repository.builder.DistributionSetBuilder;
@@ -16,13 +17,13 @@ import org.eclipse.hawkbit.repository.builder.DistributionSetTypeBuilder;
import org.eclipse.hawkbit.repository.builder.RolloutBuilder;
import org.eclipse.hawkbit.repository.builder.RolloutGroupBuilder;
import org.eclipse.hawkbit.repository.builder.SoftwareModuleBuilder;
import org.eclipse.hawkbit.repository.builder.SoftwareModuleMetadataBuilder;
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeBuilder;
import org.eclipse.hawkbit.repository.builder.TagBuilder;
import org.eclipse.hawkbit.repository.builder.TargetBuilder;
import org.eclipse.hawkbit.repository.builder.TargetFilterQueryBuilder;
import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.hibernate.validator.constraints.NotEmpty;
/**
* central {@link BaseEntity} generation service. Objects are created but not
@@ -51,7 +52,13 @@ public interface EntityFactory {
*
* @return {@link MetaData} object
*/
MetaData generateMetadata(@NotEmpty String key, @NotNull String value);
MetaData generateMetadata(@Size(min = 1, max = MetaData.KEY_MAX_SIZE) @NotNull String key,
@Size(min = 1, max = MetaData.VALUE_MAX_SIZE) @NotNull String value);
/**
* @return {@link SoftwareModuleMetadataBuilder} object
*/
SoftwareModuleMetadataBuilder softwareModuleMetadata();
/**
* @return {@link TagBuilder} object

View File

@@ -8,8 +8,10 @@
*/
package org.eclipse.hawkbit.repository;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.ActionStatus;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
/**
* Repository constants.
@@ -36,6 +38,13 @@ public final class RepositoryConstants {
*/
public static final int MAX_ACTION_HISTORY_MSG_COUNT = 100;
/**
* Maximum number of metadata entries provided to controllers.
*
* @see SoftwareModuleMetadata#isTargetVisible()
*/
public static final int MAX_META_DATA_COUNT = 50;
private RepositoryConstants() {
// Utility class.
}

View File

@@ -16,6 +16,8 @@ import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.builder.SoftwareModuleCreate;
import org.eclipse.hawkbit.repository.builder.SoftwareModuleMetadataCreate;
import org.eclipse.hawkbit.repository.builder.SoftwareModuleMetadataUpdate;
import org.eclipse.hawkbit.repository.builder.SoftwareModuleUpdate;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
@@ -23,7 +25,6 @@ import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
import org.eclipse.hawkbit.repository.model.AssignedSoftwareModule;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@@ -60,10 +61,8 @@ public interface SoftwareModuleManagement
/**
* creates a list of software module meta data entries.
*
* @param moduleId
* the metadata belongs to
* @param metadata
* the meta data entries to create or update
* the meta data entries to create
* @return the updated or created software module meta data entries
* @throws EntityAlreadyExistsException
* in case one of the meta data entry already exists for the
@@ -72,15 +71,13 @@ public interface SoftwareModuleManagement
* if software module with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
List<SoftwareModuleMetadata> createMetaData(@NotNull Long moduleId, @NotNull Collection<MetaData> metadata);
List<SoftwareModuleMetadata> createMetaData(@NotNull Collection<SoftwareModuleMetadataCreate> metadata);
/**
* creates or updates a single software module meta data entry.
*
* @param moduleId
* the metadata belongs to
* @param metadata
* the meta data entry to create or update
* the meta data entry to create
* @return the updated or created software module meta data entry
* @throws EntityAlreadyExistsException
* in case the meta data entry already exists for the specific
@@ -89,7 +86,7 @@ public interface SoftwareModuleManagement
* if software module with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
SoftwareModuleMetadata createMetaData(@NotNull Long moduleId, @NotNull MetaData metadata);
SoftwareModuleMetadata createMetaData(@NotNull SoftwareModuleMetadataCreate metadata);
/**
* deletes a software module meta data entry.
@@ -188,6 +185,25 @@ public interface SoftwareModuleManagement
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleId(@NotNull Pageable pageable, @NotNull Long moduleId);
/**
* finds all meta data by the given software module id where
* {@link SoftwareModuleMetadata#isTargetVisible()}.
*
* @param pageable
* the page request to page the result
* @param moduleId
* the software module id to retrieve the meta data from
*
* @return a paged result of all meta data entries for a given software
* module id
*
* @throws EntityNotFoundException
* if software module with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleIdAndTargetVisible(@NotNull Pageable pageable,
@NotNull Long moduleId);
/**
* finds all meta data by the given software module id.
*
@@ -259,9 +275,7 @@ public interface SoftwareModuleManagement
/**
* updates a distribution set meta data value if corresponding entry exists.
*
* @param moduleId
* the metadata belongs to
* @param metadata
* @param update
* the meta data entry to be updated
*
* @return the updated meta data entry
@@ -271,5 +285,5 @@ public interface SoftwareModuleManagement
* updated
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
SoftwareModuleMetadata updateMetaData(@NotNull Long moduleId, @NotNull MetaData metadata);
SoftwareModuleMetadata updateMetaData(@NotNull SoftwareModuleMetadataUpdate update);
}

View File

@@ -57,6 +57,8 @@ public interface SystemManagement {
/**
* Runs consumer for each teant as
* {@link TenantAware#runAsTenant(String, org.eclipse.hawkbit.tenancy.TenantAware.TenantRunner)}
* sliently (i.e. exceptions will be logged but operations will continue for
* further tenants).
*
* @param consumer
* to run as teanant

View File

@@ -0,0 +1,37 @@
/**
* 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.repository.builder;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
/**
* Builder for {@link SoftwareModuleMetadata}.
*
*/
public interface SoftwareModuleMetadataBuilder {
/**
* @param softwareModuleId
* of the {@link SoftwareModule} the {@link MetaData} belongs to
* @param key
* of {@link MetaData#getKey()}
* @return builder instance
*/
SoftwareModuleMetadataUpdate update(long softwareModuleId, String key);
/**
* @param softwareModuleId
* of the {@link SoftwareModule} the {@link MetaData} belongs to
* @return builder instance
*/
SoftwareModuleMetadataCreate create(long softwareModuleId);
}

View File

@@ -0,0 +1,53 @@
/**
* 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.repository.builder;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
/**
* Builder to create a new {@link SoftwareModuleMetadata} entry. Defines all
* fields that can be set at creation time. Other fields are set by the
* repository automatically, e.g. {@link BaseEntity#getCreatedAt()}.
*
*/
public interface SoftwareModuleMetadataCreate {
/**
* @param key
* for {@link MetaData#getKey()}
* @return updated builder instance
*/
SoftwareModuleMetadataCreate key(@Size(min = 1, max = MetaData.KEY_MAX_SIZE) @NotNull String key);
/**
* @param value
* for {@link MetaData#getValue()}
* @return updated builder instance
*/
SoftwareModuleMetadataCreate value(@Size(min = 1, max = MetaData.VALUE_MAX_SIZE) @NotNull String value);
/**
* @param visible
* for {@link SoftwareModuleMetadata#isTargetVisible()}
* @return updated builder instance
*/
SoftwareModuleMetadataCreate targetVisible(Boolean visible);
/**
* @return peek on current state of {@link SoftwareModuleMetadata} in the
* builder
*/
SoftwareModuleMetadata build();
}

View File

@@ -0,0 +1,37 @@
/**
* 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.repository.builder;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
/**
* Builder to update an existing {@link SoftwareModuleMetadata} entry. Defines
* all fields that can be updated.
*
*/
public interface SoftwareModuleMetadataUpdate {
/**
* @param value
* for {@link MetaData#getValue()}
* @return updated builder instance
*/
SoftwareModuleMetadataUpdate value(@Size(min = 1, max = MetaData.VALUE_MAX_SIZE) @NotNull String value);
/**
* @param visible
* for {@link SoftwareModuleMetadata#isTargetVisible()}
* @return updated builder instance
*/
SoftwareModuleMetadataUpdate targetVisible(Boolean visible);
}

View File

@@ -19,4 +19,9 @@ public interface DistributionSetMetadata extends MetaData {
*/
DistributionSet getDistributionSet();
@Override
default Long getEntityId() {
return getDistributionSet().getId();
}
}

View File

@@ -15,6 +15,20 @@ import java.io.Serializable;
*
*/
public interface MetaData extends Serializable {
/**
* Maximum length of metadata key.
*/
int KEY_MAX_SIZE = 128;
/**
* Maximum length of metadata value.
*/
int VALUE_MAX_SIZE = 4000;
/**
* @return {@link BaseEntity#getId()} the metadata is related to
*/
Long getEntityId();
/**
* @return the key

View File

@@ -18,4 +18,15 @@ public interface SoftwareModuleMetadata extends MetaData {
* @return {@link SoftwareModule} this entry belongs to.
*/
SoftwareModule getSoftwareModule();
@Override
default Long getEntityId() {
return getSoftwareModule().getId();
}
/**
* @return <code>true</code> if element is visible for targets as part of
* {@link Action}.
*/
boolean isTargetVisible();
}