Merge branch 'feature_split_repo_into_api_impl' of

https://github.com/bsinno/hawkbit.git into
feature_split_repo_into_api_impl

Conflicts:
	hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/Constants.java


Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>
This commit is contained in:
Michael Hirsch
2016-05-31 08:54:51 +02:00
137 changed files with 2937 additions and 2593 deletions

View File

@@ -60,6 +60,12 @@ public interface ArtifactManagement {
ExternalArtifact createExternalArtifact(@NotNull ExternalArtifactProvider externalRepository, String urlSuffix,
@NotNull Long moduleId);
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countLocalArtifactsAll();
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countExternalArtifactsAll();
/**
* Persists {@link ExternalArtifactProvider} based on given properties.
*

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.repository;
import org.eclipse.hawkbit.repository.model.ActionStatus;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
/**
* Repository constants.
@@ -23,6 +24,12 @@ public final class Constants {
*/
public static final String SERVER_MESSAGE_PREFIX = "Update Server: ";
/**
* Number of {@link DistributionSetType}s that are generated as part of
* default tenant setup.
*/
public static final int DEFAULT_DS_TYPES_IN_TENANT = 2;
private Constants() {
// Utility class.
}

View File

@@ -9,10 +9,8 @@
package org.eclipse.hawkbit.repository;
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;
@@ -268,61 +266,4 @@ public interface ControllerManagement {
TargetInfo updateTargetStatus(@NotNull TargetInfo targetInfo, TargetUpdateStatus status, Long lastTargetQuery,
URI address);
/**
* 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

@@ -187,6 +187,12 @@ public interface DeploymentManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Long countActionsByTarget(@NotNull String rsqlParam, @NotNull Target target);
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Long countActionStatusAll();
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Long countActionsAll();
/**
* counts all actions associated to a specific target.
*
@@ -274,6 +280,9 @@ public interface DeploymentManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<Action> findActionsByTarget(@NotNull Pageable pageable, @NotNull Target target);
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<Action> findActionsByDistributionSet(@NotNull Pageable pageable, @NotNull DistributionSet ds);
/**
* Retrieves all {@link Action}s assigned to a specific {@link Target} and a
* given specification.
@@ -453,13 +462,6 @@ public interface DeploymentManagement {
+ SpringEvalExpressions.IS_SYSTEM_CODE)
Action startScheduledAction(@NotNull Action action);
/**
* Generates an empty {@link Action} without persisting it.
*
* @return {@link Action} object
*/
Action generateAction();
/**
* All {@link ActionStatus} entries in the repository.
*

View File

@@ -473,26 +473,6 @@ public interface DistributionSetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
DistributionSetMetadata findOne(@NotNull DistributionSet distributionSet, @NotNull String key);
/**
* Generates an empty {@link DistributionSet} without persisting it.
*
* @return {@link DistributionSet} object
*/
DistributionSet generateDistributionSet();
DistributionSetMetadata generateDistributionSetMetadata();
DistributionSetMetadata generateDistributionSetMetadata(DistributionSet distributionSet, String key, String value);
/**
* Generates an empty {@link DistributionSetType} without persisting it.
*
* @return {@link DistributionSetType} object
*/
DistributionSetType generateDistributionSetType();
DistributionSetType generateDistributionSetType(String key, String name, String description);
/**
* Checks if a {@link DistributionSet} is currently in use by a target in
* the repository.
@@ -615,7 +595,4 @@ public interface DistributionSetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
DistributionSetType updateDistributionSetType(@NotNull DistributionSetType dsType);
DistributionSet generateDistributionSet(String name, String version, String description, DistributionSetType type,
Collection<SoftwareModule> moduleList);
}

View File

@@ -0,0 +1,333 @@
/**
* 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.concurrent.TimeUnit;
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.BaseEntity;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.hibernate.validator.constraints.NotEmpty;
/**
* central {@link BaseEntity} generation service. Objects are created but not
* persisted.
*
*/
public interface EntityFactory {
/**
* Generates an empty {@link Action} without persisting it.
*
* @return {@link Action} object
*/
Action generateAction();
/**
* 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.
*
* @return {@link ActionStatus} object
*/
ActionStatus generateActionStatus(Action action, Status status, Long occurredAt);
/**
* 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.
* @param message
* optional comment
*
* @return {@link ActionStatus} object
*/
ActionStatus generateActionStatus(Action action, Status status, Long occurredAt, final String message);
/**
* Generates an empty {@link DistributionSet} without persisting it.
*
* @return {@link DistributionSet} object
*/
DistributionSet generateDistributionSet();
/**
* Generates an {@link DistributionSet} without persisting it.
*
* @param name
* {@link DistributionSet#getName()}
* @param version
* {@link DistributionSet#getVersion()}
* @param description
* {@link DistributionSet#getDescription()}
* @param type
* {@link DistributionSet#getType()}
* @param moduleList
* {@link DistributionSet#getModules()}
*
* @return {@link DistributionSet} object
*/
DistributionSet generateDistributionSet(String name, String version, String description, DistributionSetType type,
Collection<SoftwareModule> moduleList);
/**
* Generates an empty {@link DistributionSetMetadata} element without
* persisting it.
*
* @return {@link DistributionSetMetadata} object
*/
DistributionSetMetadata generateDistributionSetMetadata();
/**
* Generates an {@link DistributionSetMetadata} element without persisting
* it.
*
* @param distributionSet
* {@link DistributionSetMetadata#getDistributionSet()}
* @param key
* {@link DistributionSetMetadata#getKey()}
* @param value
* {@link DistributionSetMetadata#getValue()}
*
* @return {@link DistributionSetMetadata} object
*/
DistributionSetMetadata generateDistributionSetMetadata(DistributionSet distributionSet, String key, String value);
/**
* Generates an empty {@link DistributionSetTag} without persisting it.
*
* @return {@link DistributionSetTag} object
*/
DistributionSetTag generateDistributionSetTag();
/**
* Generates a {@link DistributionSetTag} without persisting it.
*
* @param name
* of the tag
* @return {@link DistributionSetTag} object
*/
DistributionSetTag generateDistributionSetTag(String name);
/**
* Generates a {@link DistributionSetTag} without persisting it.
*
* @param name
* of the tag
* @param description
* of the tag
* @param colour
* of the tag
* @return {@link DistributionSetTag} object
*/
DistributionSetTag generateDistributionSetTag(String name, String description, String colour);
/**
* Generates an empty {@link DistributionSetType} without persisting it.
*
* @return {@link DistributionSetType} object
*/
DistributionSetType generateDistributionSetType();
/**
* Generates a {@link DistributionSetType} without persisting it.
*
* @param key
* {@link DistributionSetType#getKey()}
* @param name
* {@link DistributionSetType#getName()}
* @param description
* {@link DistributionSetType#getDescription()}
*
* @return {@link DistributionSetType} object
*/
DistributionSetType generateDistributionSetType(String key, String name, String description);
/**
* Generates an empty {@link Rollout} without persisting it.
*
* @return {@link Rollout} object
*/
Rollout generateRollout();
/**
* Generates an empty {@link RolloutGroup} without persisting it.
*
* @return {@link RolloutGroup} object
*/
RolloutGroup generateRolloutGroup();
/**
* Generates an empty {@link SoftwareModule} without persisting it.
*
* @return {@link SoftwareModule} object
*/
SoftwareModule generateSoftwareModule();
/**
* Generates a {@link SoftwareModule} without persisting it.
*
* @param type
* of the {@link SoftwareModule}
* @param name
* abstract name of the {@link SoftwareModule}
* @param version
* of the {@link SoftwareModule}
* @param description
* of the {@link SoftwareModule}
* @param vendor
* of the {@link SoftwareModule}
*
* @return {@link SoftwareModule} object
*/
SoftwareModule generateSoftwareModule(SoftwareModuleType type, String name, String version, String description,
String vendor);
/**
* Generates an empty {@link SoftwareModuleMetadata} pair without persisting
* it.
*
* @return {@link SoftwareModuleMetadata} object
*/
SoftwareModuleMetadata generateSoftwareModuleMetadata();
/**
* Generates a {@link SoftwareModuleMetadata} pair without persisting it.
*
* @param softwareModule
* {@link SoftwareModuleMetadata#getSoftwareModule()}
* @param key
* {@link SoftwareModuleMetadata#getKey()}
* @param value
* {@link SoftwareModuleMetadata#getValue()}
*
* @return {@link SoftwareModuleMetadata} object
*/
SoftwareModuleMetadata generateSoftwareModuleMetadata(SoftwareModule softwareModule, String key, String value);
/**
* Generates an empty {@link SoftwareModuleType} without persisting it.
*
* @return {@link SoftwareModuleType} object
*/
SoftwareModuleType generateSoftwareModuleType();
/**
* Generates a {@link SoftwareModuleType} without persisting it.
*
* @param key
* {@link SoftwareModuleType#getKey()}
* @param name
* {@link SoftwareModuleType#getName()}
* @param description
* {@link SoftwareModuleType#getDescription()}
* @param maxAssignments
* {@link SoftwareModuleType#getMaxAssignments()}
*
* @return {@link SoftwareModuleType} object
*/
SoftwareModuleType generateSoftwareModuleType(String key, String name, String description, int maxAssignments);
/**
* Generates an empty {@link Target} without persisting it.
*
* @param controllerID
* of the {@link Target}
*
* @return {@link Target} object
*/
Target generateTarget(@NotEmpty String controllerID);
/**
* Generates an empty {@link TargetFilterQuery} without persisting it.
*
* @return {@link TargetFilterQuery} object
*/
TargetFilterQuery generateTargetFilterQuery();
/**
* Generates an empty {@link TargetTag} without persisting it.
*
* @return {@link TargetTag} object
*/
TargetTag generateTargetTag();
/**
* Generates a {@link TargetTag} without persisting it.
*
* @param name
* of the tag
* @return {@link TargetTag} object
*/
TargetTag generateTargetTag(String name);
/**
* Generates a {@link TargetTag} without persisting it.
*
* @param name
* of the tag
* @param description
* of the tag
* @param colour
* of the tag
* @return {@link TargetTag} object
*/
TargetTag generateTargetTag(String name, String description, String colour);
}

View File

@@ -62,4 +62,31 @@ public final class OffsetBasedPageRequest extends PageRequest {
return "OffsetBasedPageRequest [offset=" + offset + ", getPageSize()=" + getPageSize() + ", getPageNumber()="
+ getPageNumber() + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + offset;
return result;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof OffsetBasedPageRequest)) {
return false;
}
final OffsetBasedPageRequest other = (OffsetBasedPageRequest) obj;
if (offset != other.offset) {
return false;
}
return true;
}
}

View File

@@ -150,11 +150,4 @@ public interface RolloutGroupManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
RolloutGroup findRolloutGroupWithDetailedStatus(@NotNull Long rolloutGroupId);
/**
* Generates an empty {@link RolloutGroup} without persisting it.
*
* @return {@link RolloutGroup} object
*/
RolloutGroup generateRolloutGroup();
}

View File

@@ -341,11 +341,4 @@ public interface RolloutManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
Rollout updateRollout(@NotNull Rollout rollout);
/**
* Generates an empty {@link Rollout} without persisting it.
*
* @return {@link Rollout} object
*/
Rollout generateRollout();
}

View File

@@ -483,50 +483,4 @@ public interface SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
SoftwareModuleType updateSoftwareModuleType(@NotNull SoftwareModuleType sm);
/**
* Generates an empty {@link SoftwareModuleType} without persisting it.
*
* @return {@link SoftwareModuleType} object
*/
SoftwareModuleType generateSoftwareModuleType();
/**
* Generates an empty {@link SoftwareModule} without persisting it.
*
* @return {@link SoftwareModule} object
*/
SoftwareModule generateSoftwareModule();
/**
* Generates a {@link SoftwareModule} without persisting it.
*
* @param type
* of the {@link SoftwareModule}
* @param name
* abstract name of the {@link SoftwareModule}
* @param version
* of the {@link SoftwareModule}
* @param description
* of the {@link SoftwareModule}
* @param vendor
* of the {@link SoftwareModule}
*
* @return {@link SoftwareModule} object
*/
SoftwareModule generateSoftwareModule(SoftwareModuleType type, String name, String version, String description,
String vendor);
/**
* Generates an empty {@link SoftwareModuleMetadata} pair without persisting
* it.
*
* @return {@link SoftwareModuleMetadata} object
*/
SoftwareModuleMetadata generateSoftwareModuleMetadata();
SoftwareModuleMetadata generateSoftwareModuleMetadata(SoftwareModule softwareModule, String key, String value);
SoftwareModuleType generateSoftwareModuleType(final String key, final String name, final String description,
final int maxAssignments);
}

View File

@@ -13,6 +13,8 @@ import java.util.List;
import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.model.TenantMetaData;
import org.eclipse.hawkbit.repository.report.model.SystemUsageReport;
import org.eclipse.hawkbit.tenancy.TenantAware;
@@ -39,7 +41,8 @@ public interface SystemManagement {
* @param tenant
* to delete
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_SYSTEM_CODE)
void deleteTenant(@NotNull String tenant);
/**
@@ -69,7 +72,10 @@ public interface SystemManagement {
KeyGenerator currentTenantKeyGenerator();
/**
* Returns {@link TenantMetaData} of given and current tenant.
* Returns {@link TenantMetaData} of given and current tenant. Creates for
* new tenants also two {@link SoftwareModuleType} (os and app) and
* {@link Constants#DEFAULT_DS_TYPES_IN_TENANT} {@link DistributionSetType}s
* (os and os_app).
*
* DISCLAIMER: this variant is used during initial login (where the tenant
* is not yet in the session). Please user {@link #getTenantMetadata()} for

View File

@@ -245,62 +245,4 @@ public interface TagManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
TargetTag updateTargetTag(@NotNull TargetTag targetTag);
/**
* Generates an empty {@link TargetTag} without persisting it.
*
* @return {@link TargetTag} object
*/
TargetTag generateTargetTag();
/**
* Generates an empty {@link DistributionSetTag} without persisting it.
*
* @return {@link DistributionSetTag} object
*/
DistributionSetTag generateDistributionSetTag();
/**
* Generates a {@link TargetTag} without persisting it.
*
* @param name
* of the tag
* @param description
* of the tag
* @param colour
* of the tag
* @return {@link TargetTag} object
*/
TargetTag generateTargetTag(String name, String description, String colour);
/**
* Generates a {@link TargetTag} without persisting it.
*
* @param name
* of the tag
* @return {@link TargetTag} object
*/
TargetTag generateTargetTag(String name);
/**
* Generates a {@link DistributionSetTag} without persisting it.
*
* @param name
* of the tag
* @param description
* of the tag
* @param colour
* of the tag
* @return {@link DistributionSetTag} object
*/
DistributionSetTag generateDistributionSetTag(String name, String description, String colour);
/**
* Generates a {@link DistributionSetTag} without persisting it.
*
* @param name
* of the tag
* @return {@link DistributionSetTag} object
*/
DistributionSetTag generateDistributionSetTag(String name);
}

View File

@@ -95,11 +95,4 @@ public interface TargetFilterQueryManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
TargetFilterQuery updateTargetFilterQuery(@NotNull TargetFilterQuery targetFilterQuery);
/**
* Generates an empty {@link TargetFilterQuery} without persisting it.
*
* @return {@link TargetFilterQuery} object
*/
TargetFilterQuery generateTargetFilterQuery();
}

View File

@@ -601,14 +601,4 @@ public interface TargetManagement {
+ SpringEvalExpressions.IS_CONTROLLER)
List<Target> updateTargets(@NotNull Collection<Target> targets);
/**
* Generates an empty {@link Target} without persisting it.
*
* @param controllerID
* of the {@link Target}
*
* @return {@link Target} object
*/
Target generateTarget(@NotEmpty String controllerID);
}

View File

@@ -16,6 +16,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
* Management service for statistics of a single tenant.
*
*/
@FunctionalInterface
public interface TenantStatsManagement {
/**