Split repository API for module and DS management. Refactor utility usage (#524)

* Split DS management and reduce util usage.

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

* Split sw module and type management.

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

* Sonar issues.

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

* Make sonar listen to the exception!

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

* Register both beans.

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

* Split JPA implementations.

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

* Revert user details change.

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

* Fix compilation errors.

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

* Fix bean queries. Fix image path.

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

* Document preferred utility usage.

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

* Fix exmaples and revert unintended checkin.

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

* Code cleanup.

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

* Typos, readibility.

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

* Remove unused reference.

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

* Rollouts cache delete aware.

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

* Fix rolloutgroup delete event.

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

* Add new RolloutGroupDeletedEvent event

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2017-06-01 06:28:59 +02:00
committed by GitHub
parent 0ab995d1a4
commit 67a4677ef6
203 changed files with 2738 additions and 2320 deletions

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.repository;
import java.util.Collection;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.validation.constraints.NotNull;

View File

@@ -16,8 +16,6 @@ import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.builder.DistributionSetCreate;
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeCreate;
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeUpdate;
import org.eclipse.hawkbit.repository.builder.DistributionSetUpdate;
import org.eclipse.hawkbit.repository.exception.DistributionSetCreationFailedMissingMandatoryModuleException;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
@@ -33,10 +31,8 @@ import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSe
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.model.Tag;
import org.eclipse.hawkbit.repository.model.Target;
import org.hibernate.validator.constraints.NotEmpty;
@@ -101,27 +97,6 @@ public interface DistributionSetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countDistributionSetsAll();
/**
* Count all {@link DistributionSet}s in the repository that are not marked
* as deleted.
*
* @param typeId
* to look for
*
* @return number of {@link DistributionSet}s
*
* @throws EntityNotFoundException
* if type with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countDistributionSetsByType(@NotNull Long typeId);
/**
* @return number of {@link DistributionSetType}s in the repository.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countDistributionSetTypesAll();
/**
* Creates a new {@link DistributionSet}.
*
@@ -177,36 +152,6 @@ public interface DistributionSetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
List<DistributionSet> createDistributionSets(@NotNull Collection<DistributionSetCreate> creates);
/**
* Creates new {@link DistributionSetType}.
*
* @param create
* to create
* @return created entity
*
* @throws EntityNotFoundException
* if a provided linked entity does not exists (
* {@link DistributionSetType#getMandatoryModuleTypes()} or
* {@link DistributionSetType#getOptionalModuleTypes()}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
DistributionSetType createDistributionSetType(@NotNull DistributionSetTypeCreate create);
/**
* Creates multiple {@link DistributionSetType}s.
*
* @param creates
* to create
* @return created entity
*
* @throws EntityNotFoundException
* if a provided linked entity does not exists (
* {@link DistributionSetType#getMandatoryModuleTypes()} or
* {@link DistributionSetType#getOptionalModuleTypes()}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
List<DistributionSetType> createDistributionSetTypes(@NotNull Collection<DistributionSetTypeCreate> creates);
/**
* <p>
* {@link DistributionSet} can be deleted/erased from the repository if they
@@ -257,18 +202,6 @@ public interface DistributionSetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
void deleteDistributionSetMetadata(@NotNull final Long dsId, @NotEmpty final String key);
/**
* Deletes or mark as delete in case the type is in use.
*
* @param typeId
* to delete
*
* @throws EntityNotFoundException
* if given set does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
void deleteDistributionSetType(@NotNull Long typeId);
/**
* retrieves the distribution set for a given action.
*
@@ -501,58 +434,6 @@ public interface DistributionSetManagement {
Page<DistributionSet> findDistributionSetsByTag(@NotNull final Pageable pageable, @NotNull String rsqlParam,
@NotNull final Long tagId);
/**
* @param id
* as {@link DistributionSetType#getId()}
* @return {@link DistributionSetType}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Optional<DistributionSetType> findDistributionSetTypeById(@NotNull Long id);
/**
* @param key
* as {@link DistributionSetType#getKey()}
* @return {@link DistributionSetType}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Optional<DistributionSetType> findDistributionSetTypeByKey(@NotEmpty String key);
/**
* @param name
* as {@link DistributionSetType#getName()}
* @return {@link DistributionSetType}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Optional<DistributionSetType> findDistributionSetTypeByName(@NotEmpty String name);
/**
* @param pageable
* parameter
* @return all {@link DistributionSetType}s in the repository.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<DistributionSetType> findDistributionSetTypesAll(@NotNull Pageable pageable);
/**
* Generic predicate based query for {@link DistributionSetType}.
*
* @param rsqlParam
* rsql query string
* @param pageable
* parameter for paging
*
* @return the found {@link SoftwareModuleType}s
*
* @throws RSQLParameterUnsupportedFieldException
* if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider}
* @throws RSQLParameterSyntaxException
* if the RSQL syntax is wrong
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<DistributionSetType> findDistributionSetTypesAll(@NotNull String rsqlParam, @NotNull Pageable pageable);
/**
* finds a single distribution set meta data by its id.
*
@@ -668,90 +549,6 @@ public interface DistributionSetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSetMetadata updateDistributionSetMetadata(@NotNull Long dsId, @NotNull MetaData md);
/**
* Updates existing {@link DistributionSetType}. Resets assigned
* {@link SoftwareModuleType}s as well and sets as provided.
*
* @param update
* to update
*
* @return updated entity
*
* @throws EntityNotFoundException
* in case the {@link DistributionSetType} does not exists and
* cannot be updated
*
* @throws EntityReadOnlyException
* if the {@link DistributionSetType} is already in use by a
* {@link DistributionSet} and user tries to change list of
* {@link SoftwareModuleType}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSetType updateDistributionSetType(@NotNull DistributionSetTypeUpdate update);
/**
* Unassigns a {@link SoftwareModuleType} from the
* {@link DistributionSetType}. Does nothing if {@link SoftwareModuleType}
* has not been assigned in the first place.
*
* @param dsTypeId
* to update
* @param softwareModuleId
* to unassign
* @return updated {@link DistributionSetType}
*
* @throws EntityNotFoundException
* in case the {@link DistributionSetType} does not exist
*
* @throws EntityReadOnlyException
* if the {@link DistributionSetType} while it is already in use
* by a {@link DistributionSet}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSetType unassignSoftwareModuleType(@NotNull Long dsTypeId, @NotNull Long softwareModuleId);
/**
* Assigns {@link DistributionSetType#getMandatoryModuleTypes()}.
*
* @param dsTypeId
* to update
* @param softwareModuleTypeIds
* to assign
* @return updated {@link DistributionSetType}
*
* @throws EntityNotFoundException
* in case the {@link DistributionSetType} or at least one of
* the {@link SoftwareModuleType}s do not exist
*
* @throws EntityReadOnlyException
* if the {@link DistributionSetType} while it is already in use
* by a {@link DistributionSet}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSetType assignOptionalSoftwareModuleTypes(@NotNull Long dsTypeId,
@NotEmpty Collection<Long> softwareModuleTypeIds);
/**
* Assigns {@link DistributionSetType#getOptionalModuleTypes()}.
*
* @param dsTypeId
* to update
* @param softwareModuleTypes
* to assign
* @return updated {@link DistributionSetType}
*
* @throws EntityNotFoundException
* in case the {@link DistributionSetType} or at least one of
* the {@link SoftwareModuleType}s do not exist
*
* @throws EntityReadOnlyException
* if the {@link DistributionSetType} while it is already in use
* by a {@link DistributionSet}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSetType assignMandatorySoftwareModuleTypes(@NotNull Long dsTypeId,
@NotEmpty Collection<Long> softwareModuleTypes);
/**
* Retrieves all distribution set without details.
*

View File

@@ -0,0 +1,237 @@
/**
* 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;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeCreate;
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeUpdate;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.security.access.prepost.PreAuthorize;
/**
* Management service for {@link DistributionSetType}s.
*
*/
public interface DistributionSetTypeManagement {
/**
* Creates new {@link DistributionSetType}.
*
* @param create
* to create
* @return created entity
*
* @throws EntityNotFoundException
* if a provided linked entity does not exists (
* {@link DistributionSetType#getMandatoryModuleTypes()} or
* {@link DistributionSetType#getOptionalModuleTypes()}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
DistributionSetType createDistributionSetType(@NotNull DistributionSetTypeCreate create);
/**
* Creates multiple {@link DistributionSetType}s.
*
* @param creates
* to create
* @return created entity
*
* @throws EntityNotFoundException
* if a provided linked entity does not exists (
* {@link DistributionSetType#getMandatoryModuleTypes()} or
* {@link DistributionSetType#getOptionalModuleTypes()}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
List<DistributionSetType> createDistributionSetTypes(@NotNull Collection<DistributionSetTypeCreate> creates);
/**
* Count all {@link DistributionSet}s in the repository that are not marked
* as deleted.
*
* @param typeId
* to look for
*
* @return number of {@link DistributionSet}s
*
* @throws EntityNotFoundException
* if type with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countDistributionSetsByType(@NotNull Long typeId);
/**
* Deletes or mark as delete in case the type is in use.
*
* @param typeId
* to delete
*
* @throws EntityNotFoundException
* if given set does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
void deleteDistributionSetType(@NotNull Long typeId);
/**
* @param key
* as {@link DistributionSetType#getKey()}
* @return {@link DistributionSetType}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Optional<DistributionSetType> findDistributionSetTypeByKey(@NotEmpty String key);
/**
* @param name
* as {@link DistributionSetType#getName()}
* @return {@link DistributionSetType}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Optional<DistributionSetType> findDistributionSetTypeByName(@NotEmpty String name);
/**
* @param pageable
* parameter
* @return all {@link DistributionSetType}s in the repository.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<DistributionSetType> findDistributionSetTypesAll(@NotNull Pageable pageable);
/**
* Generic predicate based query for {@link DistributionSetType}.
*
* @param rsqlParam
* rsql query string
* @param pageable
* parameter for paging
*
* @return the found {@link SoftwareModuleType}s
*
* @throws RSQLParameterUnsupportedFieldException
* if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider}
* @throws RSQLParameterSyntaxException
* if the RSQL syntax is wrong
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<DistributionSetType> findDistributionSetTypesAll(@NotNull String rsqlParam, @NotNull Pageable pageable);
/**
* @param id
* as {@link DistributionSetType#getId()}
* @return {@link DistributionSetType}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Optional<DistributionSetType> findDistributionSetTypeById(@NotNull Long id);
/**
* Updates existing {@link DistributionSetType}. Resets assigned
* {@link SoftwareModuleType}s as well and sets as provided.
*
* @param update
* to update
*
* @return updated entity
*
* @throws EntityNotFoundException
* in case the {@link DistributionSetType} does not exists and
* cannot be updated
*
* @throws EntityReadOnlyException
* if the {@link DistributionSetType} is already in use by a
* {@link DistributionSet} and user tries to change list of
* {@link SoftwareModuleType}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSetType updateDistributionSetType(@NotNull DistributionSetTypeUpdate update);
/**
* Assigns {@link DistributionSetType#getMandatoryModuleTypes()}.
*
* @param dsTypeId
* to update
* @param softwareModuleTypeIds
* to assign
* @return updated {@link DistributionSetType}
*
* @throws EntityNotFoundException
* in case the {@link DistributionSetType} or at least one of
* the {@link SoftwareModuleType}s do not exist
*
* @throws EntityReadOnlyException
* if the {@link DistributionSetType} while it is already in use
* by a {@link DistributionSet}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSetType assignOptionalSoftwareModuleTypes(@NotNull Long dsTypeId,
@NotEmpty Collection<Long> softwareModuleTypeIds);
/**
* Assigns {@link DistributionSetType#getOptionalModuleTypes()}.
*
* @param dsTypeId
* to update
* @param softwareModuleTypes
* to assign
* @return updated {@link DistributionSetType}
*
* @throws EntityNotFoundException
* in case the {@link DistributionSetType} or at least one of
* the {@link SoftwareModuleType}s do not exist
*
* @throws EntityReadOnlyException
* if the {@link DistributionSetType} while it is already in use
* by a {@link DistributionSet}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSetType assignMandatorySoftwareModuleTypes(@NotNull Long dsTypeId,
@NotEmpty Collection<Long> softwareModuleTypes);
/**
* Unassigns a {@link SoftwareModuleType} from the
* {@link DistributionSetType}. Does nothing if {@link SoftwareModuleType}
* has not been assigned in the first place.
*
* @param dsTypeId
* to update
* @param softwareModuleId
* to unassign
* @return updated {@link DistributionSetType}
*
* @throws EntityNotFoundException
* in case the {@link DistributionSetType} does not exist
*
* @throws EntityReadOnlyException
* if the {@link DistributionSetType} while it is already in use
* by a {@link DistributionSet}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSetType unassignSoftwareModuleType(@NotNull Long dsTypeId, @NotNull Long softwareModuleId);
/**
* @return number of {@link DistributionSetType}s in the repository.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countDistributionSetTypesAll();
}

View File

@@ -16,8 +16,6 @@ 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.SoftwareModuleTypeCreate;
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeUpdate;
import org.eclipse.hawkbit.repository.builder.SoftwareModuleUpdate;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
@@ -39,7 +37,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
* Service for managing {@link SoftwareModule}s.
*
*/
public interface SoftwareManagement {
public interface SoftwareModuleManagement {
/**
* Counts {@link SoftwareModule}s with given
@@ -67,12 +65,6 @@ public interface SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countSoftwareModulesAll();
/**
* @return number of {@link SoftwareModuleType}s in the repository.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countSoftwareModuleTypesAll();
/**
* Create {@link SoftwareModule}s in the repository.
*
@@ -137,26 +129,6 @@ public interface SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
SoftwareModuleMetadata createSoftwareModuleMetadata(@NotNull Long moduleId, @NotNull MetaData metadata);
/**
* Creates multiple {@link SoftwareModuleType}s.
*
* @param creates
* to create
* @return created Entity
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
List<SoftwareModuleType> createSoftwareModuleType(@NotNull Collection<SoftwareModuleTypeCreate> creates);
/**
* Creates new {@link SoftwareModuleType}.
*
* @param create
* to create
* @return created Entity
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
SoftwareModuleType createSoftwareModuleType(@NotNull SoftwareModuleTypeCreate create);
/**
* Deletes the given {@link SoftwareModule} Entity.
*
@@ -192,18 +164,6 @@ public interface SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
void deleteSoftwareModules(@NotNull Collection<Long> moduleIds);
/**
* Deletes or marks as delete in case the type is in use.
*
* @param typeId
* to delete
*
* @throws EntityNotFoundException
* not found is type with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
void deleteSoftwareModuleType(@NotNull Long typeId);
/**
* @param pageable
* the page request to page the result set
@@ -433,62 +393,6 @@ public interface SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Slice<SoftwareModule> findSoftwareModulesByType(@NotNull Pageable pageable, @NotNull Long typeId);
/**
*
* @param id
* to search for
* @return {@link SoftwareModuleType} in the repository with given
* {@link SoftwareModuleType#getId()}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Optional<SoftwareModuleType> findSoftwareModuleTypeById(@NotNull Long id);
/**
*
* @param key
* to search for
* @return {@link SoftwareModuleType} in the repository with given
* {@link SoftwareModuleType#getKey()}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Optional<SoftwareModuleType> findSoftwareModuleTypeByKey(@NotEmpty String key);
/**
*
* @param name
* to search for
* @return all {@link SoftwareModuleType}s in the repository with given
* {@link SoftwareModuleType#getName()}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Optional<SoftwareModuleType> findSoftwareModuleTypeByName(@NotEmpty String name);
/**
* @param pageable
* parameter
* @return all {@link SoftwareModuleType}s in the repository.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModuleType> findSoftwareModuleTypesAll(@NotNull Pageable pageable);
/**
* Retrieves all {@link SoftwareModuleType}s with a given specification.
*
* @param rsqlParam
* filter definition in RSQL syntax
* @param pageable
* pagination parameter
* @return the found {@link SoftwareModuleType}s
*
* @throws RSQLParameterUnsupportedFieldException
* if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider}
* @throws RSQLParameterSyntaxException
* if the RSQL syntax is wrong
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModuleType> findSoftwareModuleTypesAll(@NotNull String rsqlParam, @NotNull Pageable pageable);
/**
* Updates existing {@link SoftwareModule}. Update-able values are
* {@link SoftwareModule#getDescription()}
@@ -524,19 +428,4 @@ public interface SoftwareManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
SoftwareModuleMetadata updateSoftwareModuleMetadata(@NotNull Long moduleId, @NotNull MetaData metadata);
/**
* Updates existing {@link SoftwareModuleType}.
*
* @param update
* to update
*
* @return updated Entity
*
* @throws EntityNotFoundException
* in case the {@link SoftwareModuleType} does not exists and
* cannot be updated
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
SoftwareModuleType updateSoftwareModuleType(@NotNull SoftwareModuleTypeUpdate update);
}

View File

@@ -0,0 +1,144 @@
/**
* 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;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeCreate;
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeUpdate;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.security.access.prepost.PreAuthorize;
/**
* Service for managing {@link SoftwareModuleType}s.
*
*/
public interface SoftwareModuleTypeManagement {
/**
* @return number of {@link SoftwareModuleType}s in the repository.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countSoftwareModuleTypesAll();
/**
* Creates multiple {@link SoftwareModuleType}s.
*
* @param creates
* to create
* @return created Entity
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
List<SoftwareModuleType> createSoftwareModuleType(@NotNull Collection<SoftwareModuleTypeCreate> creates);
/**
* Creates new {@link SoftwareModuleType}.
*
* @param create
* to create
* @return created Entity
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
SoftwareModuleType createSoftwareModuleType(@NotNull SoftwareModuleTypeCreate create);
/**
* Deletes or marks as delete in case the type is in use.
*
* @param typeId
* to delete
*
* @throws EntityNotFoundException
* not found is type with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
void deleteSoftwareModuleType(@NotNull Long typeId);
/**
*
* @param id
* to search for
* @return {@link SoftwareModuleType} in the repository with given
* {@link SoftwareModuleType#getId()}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Optional<SoftwareModuleType> findSoftwareModuleTypeById(@NotNull Long id);
/**
*
* @param key
* to search for
* @return {@link SoftwareModuleType} in the repository with given
* {@link SoftwareModuleType#getKey()}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Optional<SoftwareModuleType> findSoftwareModuleTypeByKey(@NotEmpty String key);
/**
*
* @param name
* to search for
* @return all {@link SoftwareModuleType}s in the repository with given
* {@link SoftwareModuleType#getName()}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Optional<SoftwareModuleType> findSoftwareModuleTypeByName(@NotEmpty String name);
/**
* @param pageable
* parameter
* @return all {@link SoftwareModuleType}s in the repository.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModuleType> findSoftwareModuleTypesAll(@NotNull Pageable pageable);
/**
* Retrieves all {@link SoftwareModuleType}s with a given specification.
*
* @param rsqlParam
* filter definition in RSQL syntax
* @param pageable
* pagination parameter
* @return the found {@link SoftwareModuleType}s
*
* @throws RSQLParameterUnsupportedFieldException
* if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider}
* @throws RSQLParameterSyntaxException
* if the RSQL syntax is wrong
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModuleType> findSoftwareModuleTypesAll(@NotNull String rsqlParam, @NotNull Pageable pageable);
/**
* Updates existing {@link SoftwareModuleType}.
*
* @param update
* to update
*
* @return updated Entity
*
* @throws EntityNotFoundException
* in case the {@link SoftwareModuleType} does not exists and
* cannot be updated
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
SoftwareModuleType updateSoftwareModuleType(@NotNull SoftwareModuleTypeUpdate update);
}

View File

@@ -8,6 +8,7 @@
*/
package org.eclipse.hawkbit.repository.builder;
import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
@@ -16,8 +17,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.hibernate.validator.constraints.NotEmpty;
import com.google.common.collect.Lists;
/**
* Builder to create a new {@link DistributionSetType} entry. Defines all fields
* that can be set at creation time. Other fields are set by the repository
@@ -67,7 +66,7 @@ public interface DistributionSetTypeCreate {
* @return updated builder instance
*/
default DistributionSetTypeCreate mandatory(final Long mandatory) {
return mandatory(Lists.newArrayList(mandatory));
return mandatory(Arrays.asList(mandatory));
}
/**
@@ -92,7 +91,7 @@ public interface DistributionSetTypeCreate {
* @return updated builder instance
*/
default DistributionSetTypeCreate optional(final Long optional) {
return optional(Lists.newArrayList(optional));
return optional(Arrays.asList(optional));
}
/**

View File

@@ -0,0 +1,45 @@
/**
* 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.event.remote;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
/**
*
* Defines the remote event of deleting a {@link RolloutGroup}.
*/
public class RolloutGroupDeletedEvent extends RemoteIdEvent {
private static final long serialVersionUID = 1L;
/**
* Default constructor.
*/
public RolloutGroupDeletedEvent() {
// for serialization libs like jackson
}
/**
* Constructor for json serialization.
*
* @param tenant
* the tenant
* @param entityId
* the entity id
* @param entityClass
* the entity class
* @param applicationId
* the origin application id
*/
public RolloutGroupDeletedEvent(final String tenant, final Long entityId, final String entityClass,
final String applicationId) {
super(entityId, tenant, entityClass, applicationId);
}
}

View File

@@ -8,7 +8,6 @@
*/
package org.eclipse.hawkbit.repository.event.remote.entity;
import org.apache.commons.lang3.ClassUtils;
import org.eclipse.hawkbit.repository.event.remote.EventEntityManagerHolder;
import org.eclipse.hawkbit.repository.event.remote.RemoteIdEvent;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
@@ -63,7 +62,7 @@ public class RemoteEntityEvent<E extends TenantAwareBaseEntity> extends RemoteId
@SuppressWarnings("unchecked")
private E reloadEntityFromRepository() {
try {
final Class<E> clazz = (Class<E>) ClassUtils.getClass(getEntityClass());
final Class<E> clazz = (Class<E>) Class.forName(getEntityClass());
return EventEntityManagerHolder.getInstance().getEventEntityManager().findEntity(getTenant(), getEntityId(),
clazz);
} catch (final ClassNotFoundException e) {

View File

@@ -10,8 +10,6 @@ package org.eclipse.hawkbit.repository.model;
import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
import com.google.common.io.BaseEncoding;
/**
* Binaries for a {@link SoftwareModule} Note: the decision which artifacts have
* to be downloaded are done on the device side. e.g. Full Package, Signatures,
@@ -35,8 +33,8 @@ public interface Artifact extends TenantAwareBaseEntity {
String getMd5Hash();
/**
* @return SHA-1 hash of the artifact in {@link BaseEncoding#base16()}
* format that identifies the {@link DbArtifact} in the system.
* @return SHA-1 hash of the artifact in Base16 format that identifies the
* {@link DbArtifact} in the system.
*/
String getSha1Hash();

View File

@@ -9,10 +9,9 @@
package org.eclipse.hawkbit.repository.report.model;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.ImmutableList;
/**
* Bean for holding the system usage stats.
*
@@ -89,7 +88,7 @@ public class SystemUsageReport {
* @return tenant data
*/
public List<TenantUsage> getTenants() {
return ImmutableList.copyOf(tenants);
return Collections.unmodifiableList(tenants);
}
}

View File

@@ -9,10 +9,9 @@
package org.eclipse.hawkbit.repository.report.model;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import com.google.common.collect.Maps;
/**
* System usage stats element for a tenant.
*
@@ -58,7 +57,7 @@ public class TenantUsage {
private Map<String, String> getLazyUsageData() {
if (usageData == null) {
usageData = Maps.newHashMap();
usageData = new HashMap<>();
}
return usageData;
}