Javadoc, sonar issue, package cycles.

Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2016-05-27 15:25:08 +02:00
parent e6ff96dc5a
commit 53156cb16f
89 changed files with 548 additions and 213 deletions

View File

@@ -0,0 +1,31 @@
/**
* 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 org.eclipse.hawkbit.repository.model.ActionStatus;
import org.eclipse.hawkbit.repository.model.Target;
/**
* Repository constants.
*
*/
public final class Constants {
/**
* Prefix that the server puts in front of
* {@link ActionStatus#getMessages()} is the comments was generated by it
* and not be thy {@link Target}.
*/
public static final String SERVER_MESSAGE_PREFIX = "Update Server: ";
private Constants() {
// Utility class.
}
}

View File

@@ -12,6 +12,7 @@ import java.net.URI;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.validation.constraints.NotNull;
@@ -40,8 +41,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
*/
public interface ControllerManagement {
String SERVER_MESSAGE_PREFIX = "Update Server: ";
/**
* Adds an {@link ActionStatus} for a cancel {@link Action} including
* potential state changes for the target and the {@link Action} itself.
@@ -270,17 +269,60 @@ public interface ControllerManagement {
URI address);
/**
* Generates an empty {@link ActionStatus} without persisting it.
* Generates an empty {@link ActionStatus} object without persisting it.
*
* @return {@link ActionStatus} object
*/
ActionStatus generateActionStatus();
/**
* Generates an {@link ActionStatus} object without persisting it.
*
* @param action
* the {@link ActionStatus} belongs to.
* @param status
* as reflected by this {@link ActionStatus}.
* @param occurredAt
* time in {@link TimeUnit#MILLISECONDS} GMT when the status
* change happened.
* @param message
* optional comment
*
* @return {@link ActionStatus} object
*/
ActionStatus generateActionStatus(Action action, Status status, Long occurredAt, final String message);
/**
* Generates an {@link ActionStatus} object without persisting it.
*
* @param action
* the {@link ActionStatus} belongs to.
* @param status
* as reflected by this {@link ActionStatus}.
* @param occurredAt
* time in {@link TimeUnit#MILLISECONDS} GMT when the status
* change happened.
* @param messages
* optional comments
*
* @return {@link ActionStatus} object
*/
ActionStatus generateActionStatus(Action action, final Status status, Long occurredAt,
final Collection<String> messages);
/**
* Generates an {@link ActionStatus} object without persisting it.
*
* @param action
* the {@link ActionStatus} belongs to.
* @param status
* as reflected by this {@link ActionStatus}.
* @param occurredAt
* time in {@link TimeUnit#MILLISECONDS} GMT when the status
* change happened.
*
* @return {@link ActionStatus} object
*/
ActionStatus generateActionStatus(Action action, Status status, Long occurredAt);
}

View File

@@ -16,8 +16,11 @@ import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException;
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.Action;
import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.ActionStatus;
import org.eclipse.hawkbit.repository.model.ActionWithStatusCount;
import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -26,6 +29,7 @@ import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetWithActionType;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -147,17 +151,17 @@ public interface DeploymentManagement {
/**
* Cancels given {@link Action} for given {@link Target}. The method will
* immediately add a {@link ActionStatus.Status#CANCELED} status to the
* action. However, it might be possible that the controller will continue
* to work on the cancellation.
* immediately add a {@link Status#CANCELED} status to the action. However,
* it might be possible that the controller will continue to work on the
* cancellation.
*
* @param action
* to be canceled
* @param target
* for which the action needs cancellation
*
* @return generated {@link CancelAction} or <code>null</code> if not in
* {@link Target#getActiveActions()}.
* @return generated {@link Action} or <code>null</code> if not active on
* given {@link Target}.
* @throws CancelActionNotAllowedException
* in case the given action is not active or is already a cancel
* action
@@ -173,6 +177,12 @@ public interface DeploymentManagement {
* @param target
* the target associated to the actions to count
* @return the count value of found actions associated to the target
*
* @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_TARGET)
Long countActionsByTarget(@NotNull String rsqlParam, @NotNull Target target);
@@ -276,6 +286,12 @@ public interface DeploymentManagement {
* the page request
* @return a slice of actions assigned to the specific target and the
* specification
*
* @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_TARGET)
Slice<Action> findActionsByTarget(@NotNull String rsqlParam, @NotNull Target target, @NotNull Pageable pageable);
@@ -404,8 +420,8 @@ public interface DeploymentManagement {
* @param target
* for which the action needs cancellation
*
* @return generated {@link CancelAction} or <code>null</code> if not in
* {@link Target#getActiveActions()}.
* @return generated {@link Action} or <code>null</code> if not active on
* {@link Target}.
* @throws CancelActionNotAllowedException
* in case the given action is not active
*/
@@ -413,14 +429,14 @@ public interface DeploymentManagement {
Action forceQuitAction(@NotNull Action action);
/**
* Updates a {@link TargetAction} and forces the {@link TargetAction} if
* it's not already forced.
* Updates a {@link Action} and forces the {@link Action} if it's not
* already forced.
*
* @param targetId
* the ID of the target
* @param actionId
* the ID of the action
* @return the updated or the found {@link TargetAction}
* @return the updated or the found {@link Action}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
Action forceTargetAction(@NotNull Long actionId);
@@ -444,6 +460,13 @@ public interface DeploymentManagement {
*/
Action generateAction();
/**
* All {@link ActionStatus} entries in the repository.
*
* @param pageable
* the pagination parameter
* @return {@link Page} of {@link ActionStatus} entries
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<ActionStatus> findActionStatusAll(@NotNull Pageable pageable);
}

View File

@@ -15,13 +15,15 @@ import java.util.Set;
import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder;
import org.eclipse.hawkbit.repository.exception.DistributionSetCreationFailedMissingMandatoryModuleException;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
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.Action;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
@@ -30,6 +32,7 @@ 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.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -292,6 +295,12 @@ public interface DistributionSetManagement {
* the page request to page the result
* @return a paged result of all meta data entries for a given distribution
* set id
*
* @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<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(@NotNull Long distributionSetId,
@@ -350,6 +359,12 @@ public interface DistributionSetManagement {
* {@link DistributionSet#isDeleted()} == FALSE are returned.
* <code>null</code> if both are to be returned
* @return all found {@link DistributionSet}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<DistributionSet> findDistributionSetsAll(@NotNull String rsqlParam, @NotNull Pageable pageReq,
@@ -435,6 +450,12 @@ public interface DistributionSetManagement {
* 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);

View File

@@ -18,6 +18,7 @@ import java.util.List;
import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.report.model.DataReportSeries;
import org.eclipse.hawkbit.repository.report.model.InnerOuterDataReportSeries;
@@ -182,7 +183,7 @@ public interface ReportManagement {
/**
* Generates a report as a {@link ListReportSeries} targets polled based on
* the {@link TargetStatus#getLastTargetQuery()} within an hour, day, week,
* the {@link TargetInfo#getLastTargetQuery()} within an hour, day, week,
* month, year, more than a year, never.
*
* The order of the numbers within the {@link DataReportSeries} is the order

View File

@@ -11,6 +11,8 @@ package org.eclipse.hawkbit.repository;
import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.Target;
@@ -70,16 +72,22 @@ public interface RolloutGroupManagement {
/**
* Retrieves a page of {@link RolloutGroup}s filtered by a given
* {@link Rollout} and the given {@link Specification}.
* {@link Rollout} and the an rsql filter.
*
* @param rolloutId
* the ID of the rollout to filter the {@link RolloutGroup}s
* @param specification
* @param rollout
* the rollout to filter the {@link RolloutGroup}s
* @param rsqlParam
* the specification to filter the result set based on attributes
* of the {@link RolloutGroup}
* @param pageable
* the page request to sort and limit the result
* @return a page of found {@link RolloutGroup}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_ROLLOUT_MANAGEMENT_READ)
Page<RolloutGroup> findRolloutGroupsAll(@NotNull Rollout rollout, @NotNull String rsqlParam,
@@ -116,12 +124,18 @@ public interface RolloutGroupManagement {
*
* @param rolloutGroup
* rollout group
* @param specification
* @param rsqlParam
* the specification for filtering the targets of a rollout group
* @param pageable
* the page request to sort and limit the result
*
* @return Page<Target> list of targets of a rollout group
*
* @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_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
Page<Target> findRolloutGroupTargets(@NotNull RolloutGroup rolloutGroup, @NotNull String rsqlParam,

View File

@@ -12,6 +12,8 @@ import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.eventbus.event.RolloutGroupCreatedEvent;
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
import org.eclipse.hawkbit.repository.exception.RolloutIllegalStateException;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
@@ -171,11 +173,17 @@ public interface RolloutManagement {
/**
* Retrieves all rollouts found by the given specification.
*
* @param specification
* @param rsqlParam
* the specification to filter rollouts
* @param pageable
* the page request to sort and limit the result
* @return a page of found rollouts
*
* @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_ROLLOUT_MANAGEMENT_READ)
Page<Rollout> findAllWithDetailedStatusByPredicate(@NotNull String rsqlParam, @NotNull Pageable pageable);

View File

@@ -1,80 +0,0 @@
/**
* 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.List;
import org.eclipse.hawkbit.security.SystemSecurityContext;
import org.eclipse.hawkbit.tenancy.TenantAware;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* Scheduler to schedule the
* {@link RolloutManagement#checkRunningRollouts(long)}. The delay between the
* checks be be configured using the property
* {@link #PROP_SCHEDULER_DELAY_PLACEHOLDER}.
*/
@Component
// don't active the rollout scheduler in test, otherwise it is hard to test
// rolloutmanagement and leads weird side-effects maybe.
@Profile("!test")
public class RolloutScheduler {
private static final Logger LOGGER = LoggerFactory.getLogger(RolloutScheduler.class);
@Autowired
private TenantAware tenantAware;
@Autowired
private SystemManagement systemManagement;
@Autowired
private RolloutManagement rolloutManagement;
@Autowired
private SystemSecurityContext systemSecurityContext;
@Autowired
private RolloutProperties rolloutProperties;
/**
* Scheduler method called by the spring-async mechanism. Retrieves all
* tenants from the {@link SystemManagement#findTenants()} and runs for each
* tenant the {@link RolloutManagement#checkRunningRollouts(long)} in the
* {@link SystemSecurityContext}.
*/
@Scheduled(initialDelayString = RolloutProperties.Scheduler.PROP_SCHEDULER_DELAY_PLACEHOLDER, fixedDelayString = RolloutProperties.Scheduler.PROP_SCHEDULER_DELAY_PLACEHOLDER)
public void rolloutScheduler() {
LOGGER.debug("rollout schedule checker has been triggered.");
// run this code in system code privileged to have the necessary
// permission to query and create entities.
systemSecurityContext.runAsSystem(() -> {
// workaround eclipselink that is currently not possible to
// execute a query without multitenancy if MultiTenant
// annotation is used.
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=355458. So
// iterate through all tenants and execute the rollout check for
// each tenant seperately.
final List<String> tenants = systemManagement.findTenants();
LOGGER.info("Checking rollouts for {} tenants", tenants.size());
for (final String tenant : tenants) {
tenantAware.runAsTenant(tenant, () -> {
rolloutManagement.checkRunningRollouts(rolloutProperties.getScheduler().getFixedDelay());
return null;
});
}
return null;
});
}
}

View File

@@ -16,6 +16,8 @@ import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
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.AssignedSoftwareModule;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
@@ -284,6 +286,12 @@ public interface SoftwareManagement {
* the page request to page the result
* @return a paged result of all meta data entries for a given software
* module id
*
* @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<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Long softwareModuleId,
@@ -342,6 +350,12 @@ public interface SoftwareManagement {
* @param pageable
* pagination parameter
* @return the found {@link SoftwareModule}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<SoftwareModule> findSoftwareModulesByPredicate(@NotNull String rsqlParam, @NotNull Pageable pageable);
@@ -405,6 +419,12 @@ public interface SoftwareManagement {
* @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);

View File

@@ -15,6 +15,8 @@ import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
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.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.Tag;
@@ -135,6 +137,12 @@ public interface TagManagement {
* @param pageable
* pagination parameter
* @return the found {@link DistributionSetTag}s, never {@code null}
*
* @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<DistributionSetTag> findAllDistributionSetTags(@NotNull String rsqlParam, @NotNull Pageable pageable);
@@ -164,6 +172,12 @@ public interface TagManagement {
* @param pageable
* pagination parameter
* @return the found {@link Target}s, never {@code null}
*
* @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_TARGET)
Page<TargetTag> findAllTargetTags(@NotNull String rsqlParam, @NotNull Pageable pageable);

View File

@@ -16,6 +16,8 @@ import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
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.Tag;
import org.eclipse.hawkbit.repository.model.Target;
@@ -281,11 +283,17 @@ public interface TargetManagement {
*
* @param distributionSetID
* the ID of the {@link DistributionSet}
* @param spec
* @param rsqlParam
* the specification to filter the result set
* @param pageReq
* page parameter
* @return the found {@link Target}s, never {@code null}
* @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_AND_READ_TARGET)
Page<Target> findTargetByAssignedDistributionSet(@NotNull Long distributionSetID, @NotNull String rsqlParam,
@@ -381,11 +389,17 @@ public interface TargetManagement {
*
* @param distributionSetId
* the ID of the {@link DistributionSet}
* @param spec
* @param rsqlParam
* the specification to filter the result
* @param pageable
* page parameter
* @return the found {@link Target}s, never {@code null}
*
* @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_AND_READ_TARGET)
Page<Target> findTargetByInstalledDistributionSet(@NotNull Long distributionSetId, @NotNull String rsqlParam,
@@ -531,7 +545,7 @@ public interface TargetManagement {
TargetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<String> targetIds, @NotEmpty String tagName);
/**
* {@link Entity} based method call for
* {@link Target} based method call for
* {@link #toggleTagAssignment(Collection, String)}.
*
* @param targets

View File

@@ -19,12 +19,6 @@ import java.util.concurrent.TimeUnit;
*/
public interface Action extends TenantAwareBaseEntity {
/**
* indicating that target action has no force time which is only needed in
* case of {@link ActionType#TIMEFORCED}.
*/
long NO_FORCE_TIME = 0L;
/**
* @return the distributionSet
*/

View File

@@ -12,6 +12,9 @@ import java.util.List;
/**
* Generic assignment result bean.
*
* @param <T>
* type of the assigned and unassigned {@link BaseEntity}s.
*
*/
public class AssignmentResult<T extends BaseEntity> {

View File

@@ -0,0 +1,27 @@
/**
* 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.model;
/**
* Repository model constants.
*
*/
public final class Constants {
/**
* indicating that target action has no force time which is only needed in
* case of {@link Action.ActionType#TIMEFORCED}.
*/
public static final Long NO_FORCE_TIME = 0L;
private Constants() {
// Utility class.
}
}

View File

@@ -84,11 +84,6 @@ public interface DistributionSet extends NamedVersionedEntity {
*/
Set<SoftwareModule> getModules();
/**
* @return {@link DistributionSetIdName} view.
*/
DistributionSetIdName getDistributionSetIdName();
/**
* @param softwareModule
* @return <code>true</code> if the module was added and <code>false</code>

View File

@@ -6,12 +6,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository;
package org.eclipse.hawkbit.repository.model;
import java.util.Collection;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
/**
* Holds distribution set filter parameters.
*/

View File

@@ -1,87 +0,0 @@
/**
* 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.model;
import java.io.Serializable;
/**
*
*
*/
public class DistributionSetIdName implements Serializable {
private static final long serialVersionUID = 1L;
private final Long id;
private final String name;
private final String version;
/**
* @param id
* the {@link DistributionSet#getId()}
* @param name
* the {@link DistributionSet#getName()}
* @param version
* the {@link DistributionSet#getVersion()}
*
*/
public DistributionSetIdName(final Long id, final String name, final String version) {
this.id = id;
this.name = name;
this.version = version;
}
public Long getId() {
return id;
}
public String getVersion() {
return version;
}
public String getName() {
return name;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (id == null ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof DistributionSetIdName)) {
return false;
}
final DistributionSetIdName other = (DistributionSetIdName) obj;
if (id == null) {
if (other.id != null) {
return false;
}
} else if (!id.equals(other.id)) {
return false;
}
return true;
}
@Override
public String toString() {
// only return the ID because it's used in vaadin for setting the item
// id in the dom
return id.toString();
}
}

View File

@@ -47,51 +47,59 @@ public interface DistributionSetType extends NamedEntity {
* search for
* @return <code>true</code> if found
*/
boolean containsModuleType(SoftwareModuleType softwareModuleType);
default boolean containsModuleType(final SoftwareModuleType softwareModuleType) {
return containsMandatoryModuleType(softwareModuleType) || containsOptionalModuleType(softwareModuleType);
}
/**
* Checks if the given {@link SoftwareModuleType} is in this
* {@link DistributionSetType} and defined as
* {@link DistributionSetTypeElement#isMandatory()}.
* Checks if the given {@link SoftwareModuleType} is in
* {@link #getMandatoryModuleTypes()}.
*
* @param softwareModuleType
* search for
* @return <code>true</code> if found
*/
boolean containsMandatoryModuleType(SoftwareModuleType softwareModuleType);
default boolean containsMandatoryModuleType(final SoftwareModuleType softwareModuleType) {
return containsMandatoryModuleType(softwareModuleType.getId());
}
/**
* Checks if the given {@link SoftwareModuleType} is in this
* {@link DistributionSetType} and defined as
* {@link DistributionSetTypeElement#isMandatory()}.
* Checks if the given {@link SoftwareModuleType} is in
* {@link #getMandatoryModuleTypes()}.
*
* @param softwareModuleTypeId
* search for by {@link SoftwareModuleType#getId()}
* @return <code>true</code> if found
*/
boolean containsMandatoryModuleType(Long softwareModuleTypeId);
default boolean containsMandatoryModuleType(final Long softwareModuleTypeId) {
return getMandatoryModuleTypes().stream().filter(element -> element.getId().equals(softwareModuleTypeId))
.findFirst().isPresent();
}
/**
* Checks if the given {@link SoftwareModuleType} is in this
* {@link DistributionSetType} and NOT defined as
* {@link DistributionSetTypeElement#isMandatory()}.
* Checks if the given {@link SoftwareModuleType} is in
* {@link #getOptionalModuleTypes()}.
*
* @param softwareModuleType
* search for
* @return <code>true</code> if found
*/
boolean containsOptionalModuleType(SoftwareModuleType softwareModuleType);
default boolean containsOptionalModuleType(final SoftwareModuleType softwareModuleType) {
return containsOptionalModuleType(softwareModuleType.getId());
}
/**
* Checks if the given {@link SoftwareModuleType} is in this
* {@link DistributionSetType} and NOT defined as
* {@link DistributionSetTypeElement#isMandatory()}.
* Checks if the given {@link SoftwareModuleType} is in
* {@link #getOptionalModuleTypes()}.
*
* @param softwareModuleTypeId
* search by {@link SoftwareModuleType#getId()}
* @return <code>true</code> if found
*/
boolean containsOptionalModuleType(Long softwareModuleTypeId);
default boolean containsOptionalModuleType(final Long softwareModuleTypeId) {
return getOptionalModuleTypes().stream().filter(element -> element.getId().equals(softwareModuleTypeId))
.findFirst().isPresent();
}
/**
* Compares the modules of this {@link DistributionSetType} and the given

View File

@@ -8,10 +8,21 @@
*/
package org.eclipse.hawkbit.repository.model;
/**
* {@link MetaData} element of a {@link SoftwareModule}.
*
*/
public interface SoftwareModuleMetadata extends MetaData {
/**
* @return {@link SoftwareModule} this entry belongs to.
*/
SoftwareModule getSoftwareModule();
/**
* @param softwareModule
* this entry belongs to.
*/
void setSoftwareModule(SoftwareModule softwareModule);
}

View File

@@ -8,10 +8,20 @@
*/
package org.eclipse.hawkbit.repository.model;
/**
* {@link Tag} entry.
*
*/
public interface Tag extends NamedEntity {
/**
* @return colour code of the tag used in Management UI.
*/
String getColour();
/**
* @param colour
*/
void setColour(String colour);
}

View File

@@ -8,14 +8,52 @@
*/
package org.eclipse.hawkbit.repository.model;
/**
* Managed filter entity.
*
* Supported operators.
* <ul>
* <li>Equal to : ==</li>
* <li>Not equal to : !=</li>
* <li>Less than : =lt= or <</li>
* <li>Less than or equal to : =le= or <=</li>
* <li>Greater than operator : =gt= or ></li>
* <li>Greater than or equal to : =ge= or >=</li>
* </ul>
* Examples of RSQL expressions in both FIQL-like and alternative notation:
* <ul>
* <li>version==2.0.0</li>
* <li>name==targetId1;description==plugAndPlay</li>
* <li>name==targetId1 and description==plugAndPlay</li>
* <li>name==targetId1;description==plugAndPlay</li>
* <li>name==targetId1 and description==plugAndPlay</li>
* <li>name==targetId1,description==plugAndPlay,updateStatus==UNKNOWN</li>
* <li>name==targetId1 or description==plugAndPlay or updateStatus==UNKNOWN</li>
* </ul>
*
*/
public interface TargetFilterQuery extends TenantAwareBaseEntity {
/**
* @return name of the {@link TargetFilterQuery}.
*/
String getName();
/**
* @param name
* of the {@link TargetFilterQuery}.
*/
void setName(String name);
/**
* @return RSQL query
*/
String getQuery();
/**
* @param query
* in RSQL notation.
*/
void setQuery(String query);
}

View File

@@ -10,27 +10,48 @@ package org.eclipse.hawkbit.repository.model;
import java.io.Serializable;
import java.net.URI;
import java.text.AttributedCharacterIterator;
import java.util.Map;
import java.util.concurrent.TimeUnit;
public interface TargetInfo extends Serializable {
Long getId();
/**
* @return the ipAddress
* @return the address under whioch the target can be reached
*/
URI getAddress();
/**
* @return {@link Target} this info element belongs to.
*/
Target getTarget();
/**
* @return time in {@link TimeUnit#MILLISECONDS} GMT when the {@link Target}
* polled the server the last time.
*/
Long getLastTargetQuery();
/**
* @return {@link AttributedCharacterIterator} that have been provided by
* the {@link Target} itself, e.g. hardware revision, serial number,
* mac address etc.
*/
Map<String, String> getControllerAttributes();
/**
* @return time in {@link TimeUnit#MILLISECONDS} GMT when
* {@link #getInstalledDistributionSet()} was applied.
*/
Long getInstallationDate();
/**
* @return current status of the {@link Target}.
*/
TargetUpdateStatus getUpdateStatus();
/**
* @return currently installed {@link DistributionSet}.
*/
DistributionSet getInstalledDistributionSet();
/**
@@ -41,6 +62,10 @@ public interface TargetInfo extends Serializable {
*/
PollStatus getPollStatus();
/**
* @return <code>true</code> if the {@link Target} has not jet provided
* {@link #getControllerAttributes()}.
*/
boolean isRequestControllerAttributes();
}

View File

@@ -10,8 +10,15 @@ package org.eclipse.hawkbit.repository.model;
import java.util.List;
/**
* Target tag element.
*
*/
public interface TargetTag extends Tag {
/**
* @return {@link List} of targets assigned to this {@link Tag}.
*/
List<Target> getAssignedToTargets();
}

View File

@@ -6,11 +6,9 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository;
package org.eclipse.hawkbit.repository.model;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.Target;
/**
* A custom view on {@link Target} with {@link ActionType}.
@@ -53,7 +51,7 @@ public class TargetWithActionType {
if (actionType == ActionType.TIMEFORCED) {
return forceTime;
}
return Action.NO_FORCE_TIME;
return Constants.NO_FORCE_TIME;
}
/**

View File

@@ -8,14 +8,33 @@
*/
package org.eclipse.hawkbit.repository.model;
/**
* Unstructured tenant configuration elements. Can be used to store arbitrary
* tenant configuration elements.
*
*/
public interface TenantConfiguration extends TenantAwareBaseEntity {
/**
* @return key of the entry
*/
String getKey();
/**
* @param key
* of the entry
*/
void setKey(String key);
/**
* @return value of the entry
*/
String getValue();
/**
* @param value
* of the entry
*/
void setValue(String value);
}